@verentis/cli 1.0.1 → 1.0.3
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 +81 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1476,6 +1476,7 @@ function collectIconFields(manifest) {
|
|
|
1476
1476
|
}
|
|
1477
1477
|
bindings(spec["mime-types"], ["spec", "mime-types"]);
|
|
1478
1478
|
bindings(spec["file-types"], ["spec", "file-types"]);
|
|
1479
|
+
bindings(spec.creatables, ["spec", "creatables"]);
|
|
1479
1480
|
return fields;
|
|
1480
1481
|
}
|
|
1481
1482
|
async function resolveManifestIcons(manifest, manifestDir) {
|
|
@@ -2013,6 +2014,7 @@ function validatePackageManifestRules(kind, manifest) {
|
|
|
2013
2014
|
...launchKindError ? [`${launchKindError}.`] : [],
|
|
2014
2015
|
...validateNativeCollaborationSection(kind, manifest.spec),
|
|
2015
2016
|
...validateMessageChannelsSection(kind, manifest.spec),
|
|
2017
|
+
...validateChatSection(kind, manifest.spec),
|
|
2016
2018
|
...validateActorSection(kind, manifest.spec),
|
|
2017
2019
|
...validateWopiOperationsSection(manifest.spec),
|
|
2018
2020
|
...validateApplicationSplashSection(kind, manifest.spec),
|
|
@@ -2051,6 +2053,10 @@ async function loadManifest(path) {
|
|
|
2051
2053
|
if (messageErrors.length > 0) {
|
|
2052
2054
|
throw new Error(`Invalid manifest at ${path}: ${messageErrors.join(" ")}`);
|
|
2053
2055
|
}
|
|
2056
|
+
const chatErrors = validateChatSection(kind, manifest.spec);
|
|
2057
|
+
if (chatErrors.length > 0) {
|
|
2058
|
+
throw new Error(`Invalid manifest at ${path}: ${chatErrors.join(" ")}`);
|
|
2059
|
+
}
|
|
2054
2060
|
const actorErrors = validateActorSection(kind, manifest.spec);
|
|
2055
2061
|
if (actorErrors.length > 0) {
|
|
2056
2062
|
throw new Error(`Invalid manifest at ${path}: ${actorErrors.join(" ")}`);
|
|
@@ -2165,6 +2171,80 @@ function validateMessageChannelsSection(kind, spec) {
|
|
|
2165
2171
|
});
|
|
2166
2172
|
return errors;
|
|
2167
2173
|
}
|
|
2174
|
+
var CHAT_KEY_PATTERN = /^[a-z][a-z0-9-]{1,31}$/;
|
|
2175
|
+
var CHAT_ARGUMENT_PATTERN = /^[a-z][a-z0-9_]{0,31}$/;
|
|
2176
|
+
var CHAT_RESERVED_ARGUMENT_PREFIX = "chat_";
|
|
2177
|
+
var MAX_CHAT_BOTS = 5;
|
|
2178
|
+
var MAX_CHAT_COMMANDS = 25;
|
|
2179
|
+
var MAX_CHAT_ARGUMENTS = 10;
|
|
2180
|
+
function validateChatSection(kind, spec) {
|
|
2181
|
+
if (!spec || typeof spec !== "object" || Array.isArray(spec) || !Object.prototype.hasOwnProperty.call(spec, "chat")) return [];
|
|
2182
|
+
if (!isApplicationProfile(kind)) return ["spec.chat is only supported for Application manifests."];
|
|
2183
|
+
const record = spec;
|
|
2184
|
+
const chat = record.chat;
|
|
2185
|
+
if (!chat || typeof chat !== "object" || Array.isArray(chat)) return ["spec.chat must be an object with bots and/or commands."];
|
|
2186
|
+
const { bots = [], commands = [] } = chat;
|
|
2187
|
+
const errors = [];
|
|
2188
|
+
const botKeys = /* @__PURE__ */ new Set();
|
|
2189
|
+
if (!Array.isArray(bots)) errors.push("spec.chat.bots must be a list.");
|
|
2190
|
+
else {
|
|
2191
|
+
if (bots.length > MAX_CHAT_BOTS) errors.push(`spec.chat.bots declares more than ${MAX_CHAT_BOTS} bots.`);
|
|
2192
|
+
bots.forEach((value, index) => {
|
|
2193
|
+
const path = `spec.chat.bots[${index}]`;
|
|
2194
|
+
const bot = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2195
|
+
if (typeof bot.key !== "string" || !CHAT_KEY_PATTERN.test(bot.key)) errors.push(`${path}.key must match ${CHAT_KEY_PATTERN.source}.`);
|
|
2196
|
+
else if (botKeys.has(bot.key)) errors.push(`${path}.key '${bot.key}' is declared more than once.`);
|
|
2197
|
+
else botKeys.add(bot.key);
|
|
2198
|
+
if (typeof bot["display-name"] !== "string" || !bot["display-name"].trim()) errors.push(`${path}.display-name is required.`);
|
|
2199
|
+
});
|
|
2200
|
+
const permissions = Array.isArray(record.permissions) ? record.permissions : [];
|
|
2201
|
+
if (bots.length > 0 && !permissions.includes("chat.write")) {
|
|
2202
|
+
errors.push("spec.permissions must include chat.write for the app to post as its bots.");
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
const scripts = (Array.isArray(record.scripts) ? record.scripts : []).filter((script) => typeof script === "string").map((script) => script.trim().replace(/^\.\//, "").replace(/\/+$/, ""));
|
|
2206
|
+
const names = /* @__PURE__ */ new Set();
|
|
2207
|
+
if (!Array.isArray(commands)) errors.push("spec.chat.commands must be a list.");
|
|
2208
|
+
else {
|
|
2209
|
+
if (commands.length > MAX_CHAT_COMMANDS) errors.push(`spec.chat.commands declares more than ${MAX_CHAT_COMMANDS} commands.`);
|
|
2210
|
+
commands.forEach((value, index) => {
|
|
2211
|
+
const path = `spec.chat.commands[${index}]`;
|
|
2212
|
+
const command = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2213
|
+
if (typeof command.name !== "string" || !CHAT_KEY_PATTERN.test(command.name)) errors.push(`${path}.name must match ${CHAT_KEY_PATTERN.source}.`);
|
|
2214
|
+
else if (names.has(command.name)) errors.push(`${path}.name '${command.name}' is declared more than once.`);
|
|
2215
|
+
else names.add(command.name);
|
|
2216
|
+
const script = typeof command.script === "string" ? command.script.trim().replace(/^\.\//, "") : "";
|
|
2217
|
+
if (!script || script.split("/").some((segment) => segment === "" || segment === "." || segment === "..") || !scripts.some((program2) => script.startsWith(`${program2}/`))) {
|
|
2218
|
+
errors.push(`${path}.script must be the entry file of a program listed in spec.scripts (e.g. scripts/approve/main.mjs).`);
|
|
2219
|
+
}
|
|
2220
|
+
if (command.bot !== void 0 && (typeof command.bot !== "string" || !botKeys.has(command.bot))) {
|
|
2221
|
+
errors.push(`${path}.bot must name a bot declared in spec.chat.bots.`);
|
|
2222
|
+
}
|
|
2223
|
+
const args = command.arguments ?? [];
|
|
2224
|
+
if (!Array.isArray(args) || args.length > MAX_CHAT_ARGUMENTS) {
|
|
2225
|
+
errors.push(`${path}.arguments must be a list of at most ${MAX_CHAT_ARGUMENTS} arguments.`);
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2228
|
+
const argumentNames = /* @__PURE__ */ new Set();
|
|
2229
|
+
args.forEach((argumentValue, argumentIndex) => {
|
|
2230
|
+
const argumentPath = `${path}.arguments[${argumentIndex}]`;
|
|
2231
|
+
const argument = argumentValue && typeof argumentValue === "object" && !Array.isArray(argumentValue) ? argumentValue : {};
|
|
2232
|
+
if (typeof argument.name !== "string" || !CHAT_ARGUMENT_PATTERN.test(argument.name) || argumentNames.has(argument.name)) {
|
|
2233
|
+
errors.push(`${argumentPath}.name must be a unique name matching ${CHAT_ARGUMENT_PATTERN.source}.`);
|
|
2234
|
+
} else if (argument.name.startsWith(CHAT_RESERVED_ARGUMENT_PREFIX)) {
|
|
2235
|
+
errors.push(`${argumentPath}.name must not start with '${CHAT_RESERVED_ARGUMENT_PREFIX}': Chat reserves it for the context it passes to command scripts.`);
|
|
2236
|
+
} else argumentNames.add(argument.name);
|
|
2237
|
+
if (argument.type !== void 0 && !["string", "number", "boolean"].includes(argument.type)) {
|
|
2238
|
+
errors.push(`${argumentPath}.type must be string, number or boolean.`);
|
|
2239
|
+
}
|
|
2240
|
+
if (argument.required !== void 0 && typeof argument.required !== "boolean") {
|
|
2241
|
+
errors.push(`${argumentPath}.required must be true or false.`);
|
|
2242
|
+
}
|
|
2243
|
+
});
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2246
|
+
return errors;
|
|
2247
|
+
}
|
|
2168
2248
|
var ACTOR_SURFACE_KINDS = ["app-backend", "mcp", "native-collaboration", "document", "raw-file"];
|
|
2169
2249
|
var ACTOR_FILE_KINDS = /* @__PURE__ */ new Set(["native-collaboration", "document", "raw-file"]);
|
|
2170
2250
|
var MAX_ACTOR_SURFACES = 16;
|
|
@@ -2519,6 +2599,7 @@ function validateManifest(manifest) {
|
|
|
2519
2599
|
for (const message of validateDependencies(spec)) error(message);
|
|
2520
2600
|
for (const message of validateNativeCollaborationSection(kind, spec)) error(message);
|
|
2521
2601
|
for (const message of validateMessageChannelsSection(kind, spec)) error(message);
|
|
2602
|
+
for (const message of validateChatSection(kind, spec)) error(message);
|
|
2522
2603
|
for (const message of validateActorSection(kind, spec)) error(message);
|
|
2523
2604
|
for (const message of validateApplicationSplashSection(kind, spec)) error(message);
|
|
2524
2605
|
for (const message of validateTypeSpecFields(kind, spec)) error(message);
|