@lark-apaas/fullstack-cli 1.1.71-alpha.20261104122311 → 1.1.71-alpha.20261105073806

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 (3) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +122 -16
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -155,7 +155,7 @@ fullstack-cli capability list --id create_feishu_group_for_task --summary
155
155
  # 等价写法
156
156
  fullstack-cli capability get --id create_feishu_group_for_task
157
157
 
158
- # 保存前检查:先按插件 config schema 做结构校验并补默认值,再跑插件的 validateForm
158
+ # 保存前检查:配置类插件按 config schema 做结构校验并补默认值,动作类插件检查 {{input.x}} 与 paramsSchema 是否一致,再跑插件的 validateForm
159
159
  fullstack-cli capability validate --plugin @office/feishu-bitable --form-value @./form.json [--id <id>] [--timeout 60000]
160
160
  ```
161
161
 
@@ -302,7 +302,7 @@ fullstack-cli action-plugin form-action-execute --plugin <key> --action <name> -
302
302
  fullstack-cli capability --help
303
303
  fullstack-cli capability list
304
304
  fullstack-cli capability get --id <id>
305
- fullstack-cli capability validate --plugin <key> --form-value <json|@f|-> [--id <id>] [--timeout <ms>]
305
+ fullstack-cli capability validate --plugin <key> --form-value <json|@f|-> [--id <id>] [--params-schema <json|@f|->] [--timeout <ms>]
306
306
  fullstack-cli capability create --plugin <key> --id <id> --name <name> --form-value <json|@f|->
307
307
  fullstack-cli capability update --id <id> --form-value <json|@f|-> [--name <name>]
308
308
  fullstack-cli capability migration --dry-run
package/dist/index.js CHANGED
@@ -5742,13 +5742,85 @@ async function listAll(summary) {
5742
5742
  }
5743
5743
  }
5744
5744
 
5745
- // src/commands/capability/validate.handler.ts
5745
+ // src/commands/capability/template-refs.ts
5746
+ var INPUT_REF_REGEX = /\{\{\s*input\.([a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*\s*\}\}/g;
5747
+ var BLOCK_SYNTAX_REGEX = /\{\{\s*(#if|#each|#unless|\/if|\/each|\/unless|else)\b[^}]*\}\}/;
5748
+ var TemplateIssueCode = {
5749
+ /** 表单值引用了 paramsSchema 没声明的变量 */
5750
+ UNDEFINED_INPUT_REF: "UNDEFINED_INPUT_REF",
5751
+ /** paramsSchema 声明的变量表单值里没有引用 */
5752
+ UNUSED_INPUT_PARAM: "UNUSED_INPUT_PARAM",
5753
+ /** 用了模板引擎不支持的块语法 */
5754
+ UNSUPPORTED_TEMPLATE_SYNTAX: "UNSUPPORTED_TEMPLATE_SYNTAX"
5755
+ };
5746
5756
  function toJsonPointer(path28) {
5747
5757
  if (path28.length === 0) {
5748
5758
  return "";
5749
5759
  }
5750
5760
  return "/" + path28.map((segment) => String(segment).replace(/~/g, "~0").replace(/\//g, "~1")).join("/");
5751
5761
  }
5762
+ function forEachString(value, path28, visit) {
5763
+ if (typeof value === "string") {
5764
+ visit(value, path28);
5765
+ return;
5766
+ }
5767
+ if (Array.isArray(value)) {
5768
+ value.forEach(
5769
+ (item, index) => forEachString(item, [...path28, index], visit)
5770
+ );
5771
+ return;
5772
+ }
5773
+ if (value && typeof value === "object") {
5774
+ for (const [key, item] of Object.entries(value)) {
5775
+ forEachString(item, [...path28, key], visit);
5776
+ }
5777
+ }
5778
+ }
5779
+ function declaredParams(paramsSchema) {
5780
+ const properties = paramsSchema.properties;
5781
+ if (!properties || typeof properties !== "object" || Array.isArray(properties)) {
5782
+ return [];
5783
+ }
5784
+ return Object.keys(properties);
5785
+ }
5786
+ function checkTemplateRefs(formValue, paramsSchema) {
5787
+ const issues = [];
5788
+ const declared = new Set(declaredParams(paramsSchema));
5789
+ const referenced = /* @__PURE__ */ new Set();
5790
+ forEachString(formValue, [], (str, path28) => {
5791
+ const pointer = toJsonPointer(path28);
5792
+ const block = str.match(BLOCK_SYNTAX_REGEX);
5793
+ if (block) {
5794
+ issues.push({
5795
+ code: TemplateIssueCode.UNSUPPORTED_TEMPLATE_SYNTAX,
5796
+ path: pointer,
5797
+ message: `Template block syntax ${block[0]} is not supported; only {{input.x}} references are replaced at runtime`
5798
+ });
5799
+ }
5800
+ for (const match of str.matchAll(INPUT_REF_REGEX)) {
5801
+ const name = match[1];
5802
+ referenced.add(name);
5803
+ if (!declared.has(name)) {
5804
+ issues.push({
5805
+ code: TemplateIssueCode.UNDEFINED_INPUT_REF,
5806
+ path: pointer,
5807
+ message: `{{input.${name}}} is not declared in paramsSchema.properties`
5808
+ });
5809
+ }
5810
+ }
5811
+ });
5812
+ for (const name of declared) {
5813
+ if (!referenced.has(name)) {
5814
+ issues.push({
5815
+ code: TemplateIssueCode.UNUSED_INPUT_PARAM,
5816
+ message: `paramsSchema declares "${name}" but the form value never references {{input.${name}}}, so the value passed for it would be dropped`
5817
+ });
5818
+ }
5819
+ }
5820
+ return issues;
5821
+ }
5822
+
5823
+ // src/commands/capability/validate.handler.ts
5752
5824
  function zodIssuesToFormIssues(issues) {
5753
5825
  return issues.map((issue) => ({
5754
5826
  message: issue.message,
@@ -5807,12 +5879,18 @@ function normalizeResult(raw) {
5807
5879
  });
5808
5880
  return { success: raw.success, issues };
5809
5881
  }
5810
- async function runValidate(options) {
5882
+ async function runValidate(options, resolvedParamsSchema) {
5811
5883
  const timeoutMs = parseTimeout(options.timeout);
5884
+ assertSingleStdinArg({
5885
+ "--form-value": options.formValue,
5886
+ "--params-schema": options.paramsSchema
5887
+ });
5812
5888
  const next = readJsonObjectArg(options.formValue, "--form-value");
5889
+ const explicitParamsSchema = resolvedParamsSchema ?? (options.paramsSchema === void 0 ? void 0 : readJsonObjectArg(options.paramsSchema, "--params-schema"));
5813
5890
  const resolved = await resolveInstalledPlugin(options.plugin);
5814
5891
  const { manifest, module, version: pluginVersion } = resolved;
5815
- const previous = options.id ? readMatchingCapability(options.id, options.plugin).formValue : void 0;
5892
+ const instance = options.id ? readMatchingCapability(options.id, options.plugin) : void 0;
5893
+ const previous = instance?.formValue;
5816
5894
  let normalizedFormValue = next;
5817
5895
  const configSchema = module.__definition?.config;
5818
5896
  if (manifest.form?.refType === "config" && isZodLikeSchema(configSchema)) {
@@ -5833,6 +5911,21 @@ async function runValidate(options) {
5833
5911
  normalizedFormValue = parsed.data;
5834
5912
  }
5835
5913
  }
5914
+ if (manifest.form?.refType !== "config") {
5915
+ const paramsSchema = explicitParamsSchema ?? instance?.paramsSchema ?? {};
5916
+ const issues = checkTemplateRefs(next, paramsSchema);
5917
+ if (issues.length > 0) {
5918
+ return {
5919
+ ok: false,
5920
+ code: FormCliErrorCode.INVALID_INPUT,
5921
+ message: `form value templates do not match paramsSchema (${issues.length} issue(s))`,
5922
+ hint: "Declare every {{input.x}} used in the form value under paramsSchema.properties (pass it with --params-schema), reference every declared param, and use no block syntax such as {{#if}}; then run again.",
5923
+ issues,
5924
+ validated: false,
5925
+ pluginVersion
5926
+ };
5927
+ }
5928
+ }
5836
5929
  const manifestClaims = manifest.hasValidateForm === true;
5837
5930
  const sdkReady = hasFormActionSdk(module);
5838
5931
  if (manifestClaims && (!sdkReady || typeof module.validateForm !== "function")) {
@@ -6043,11 +6136,14 @@ async function runCreate(options) {
6043
6136
  "--params-schema": options.paramsSchema
6044
6137
  });
6045
6138
  const paramsSchema = readParamsSchema(options.paramsSchema) ?? {};
6046
- const check2 = await runValidate({
6047
- plugin: options.plugin,
6048
- formValue: options.formValue,
6049
- timeout: options.timeout
6050
- });
6139
+ const check2 = await runValidate(
6140
+ {
6141
+ plugin: options.plugin,
6142
+ formValue: options.formValue,
6143
+ timeout: options.timeout
6144
+ },
6145
+ paramsSchema
6146
+ );
6051
6147
  if (!check2.ok) {
6052
6148
  return check2;
6053
6149
  }
@@ -6107,12 +6203,15 @@ async function runUpdate(options) {
6107
6203
  "--params-schema": options.paramsSchema
6108
6204
  });
6109
6205
  const paramsSchema = readParamsSchema(options.paramsSchema);
6110
- const check2 = await runValidate({
6111
- plugin: existing.pluginKey,
6112
- formValue: options.formValue,
6113
- id: options.id,
6114
- timeout: options.timeout
6115
- });
6206
+ const check2 = await runValidate(
6207
+ {
6208
+ plugin: existing.pluginKey,
6209
+ formValue: options.formValue,
6210
+ id: options.id,
6211
+ timeout: options.timeout
6212
+ },
6213
+ paramsSchema
6214
+ );
6116
6215
  if (!check2.ok) {
6117
6216
  return check2;
6118
6217
  }
@@ -6189,16 +6288,23 @@ var validateCommand = {
6189
6288
  ).option(
6190
6289
  "--id <id>",
6191
6290
  "Existing capability ID when modifying; its saved form value is passed to the plugin as the previous value. Omit when creating"
6291
+ ).option(
6292
+ "--params-schema <json>",
6293
+ `paramsSchema of an action plugin instance, used to check {{input.x}} references (default: the --id instance's, else {}): ${JSON_ARG_HINT2}`
6192
6294
  ).option("--timeout <ms>", TIMEOUT_OPTION_DESC).addHelpText(
6193
6295
  "after",
6194
6296
  `
6195
6297
  Output: {ok, validated, pluginVersion, issues, normalizedFormValue} (exit 0); when the check fails,
6196
6298
  ok: false with code VALIDATION_FAILED or INVALID_INPUT, plus issues and hint (exit 1).
6197
6299
  validated: false means the plugin has no validateForm, so only the schema check ran.
6300
+ For action plugins (form.refType is not config) the schema check is replaced by a template check:
6301
+ every {{input.x}} in the form value must be declared in paramsSchema.properties and every declared
6302
+ param must be referenced; block syntax such as {{#if}} is rejected.
6198
6303
  Requires MIAODA_AUTHN_CODE only when the plugin defines validateForm.
6199
6304
 
6200
- Example:
6201
- fullstack-cli capability validate --plugin @office/feishu-bitable --form-value @./form.json`
6305
+ Examples:
6306
+ fullstack-cli capability validate --plugin @office/feishu-bitable --form-value @./form.json
6307
+ fullstack-cli capability validate --plugin @office/ai-text-generate --form-value '{"prompt":"Summarize: {{input.text}}"}' --params-schema '{"type":"object","properties":{"text":{"type":"string","description":"text to summarize"}}}'`
6202
6308
  ).action(
6203
6309
  async (options) => {
6204
6310
  await validate(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.71-alpha.20261104122311",
3
+ "version": "1.1.71-alpha.20261105073806",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",