Skip to content

Conversation

@weareoutman
Copy link
Member

@weareoutman weareoutman commented Jul 7, 2025

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

  • 新功能

    • Flow API 现在支持以对象形式传递参数(支持 params、options、filename 等),提升了参数传递的灵活性和可读性。
    • 事件监听机制新增对 Flow API 提供者的支持,实现事件参数与 Flow API 调用的集成。
  • 修复与优化

    • 优化了参数提取和校验逻辑,提升了 API 调用的兼容性和健壮性。
    • 增强了对扩展字段(如 query、body)的处理能力,支持更复杂的请求结构。
    • 优化了对可能未定义扩展字段的安全处理,简化了部分控制流。
  • 测试

    • 新增多种参数结构下的单元测试用例,确保新特性行为正确。
    • 增加了 Flow API 提供者集成的模拟测试,验证事件监听与调用流程。
  • 文档

    • 对相关类型和接口进行了注释和说明更新,提升了开发者文档的清晰度。

@coderabbitai
Copy link

coderabbitai bot commented Jul 7, 2025

Walkthrough

本次变更扩展了 Flow API 的参数处理能力,支持以对象(UseProviderContractConf)形式传递参数,而不仅限于数组形式。相关类型声明、参数签名、参数解析与测试均已适配。参数提取与校验逻辑得到统一和增强,支持更丰富的参数结构及扩展字段处理。

Changes

文件/模块 变更摘要
etc/runtime.api.md
packages/runtime/src/internal/Runtime.ts
RuntimeHooks 接口中 flowApi.getArgsOfFlowApi 方法参数类型由 unknown[] 扩展为 unknown[] | UseProviderContractConf,并引入 UseProviderContractConf 类型。
packages/types/src/manifest.ts 新增 UseProviderContractConf 接口,UseProviderResolveConf 和 UseProviderEventHandler 支持继承其可选属性,完善参数优先级注释。
packages/easyops-runtime/src/flowApi/FlowApi.ts getArgsOfFlowApi 及相关函数参数类型扩展为支持对象参数,重构参数解析与校验逻辑,统一处理流程,完善扩展字段提取。
packages/easyops-runtime/src/flowApi/FlowApiProvider.ts processExtFields、hasFields 等函数参数类型调整为可选,优化安全性和注释,简化 callFlowApi 内部判断逻辑。
packages/easyops-runtime/src/flowApi/FlowApi.spec.ts 测试用例增加多种对象参数形式的 contract mock 及对应测试,完善参数解析与 URL 构建的验证。
packages/runtime/src/internal/data/resolveData.ts resolveData、resolveByProvider 等函数参数支持对象参数,调整参数解构与传递方式,适配新的参数结构与调用流程。
packages/runtime/src/internal/bindListeners.ts 增加对 UseProviderEventHandler 中对象形式参数的支持,使用 lodash.pick 提取相关属性并重新计算参数,确保兼容 Flow API。
packages/runtime/src/internal/bindListeners.spec.ts 新增 Flow API provider 的 mock 与测试用例,验证事件监听器中 flowApi 参数处理及调用流程。

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/easyops-runtime/src/flowApi/FlowApi.spec.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

packages/easyops-runtime/src/flowApi/FlowApi.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

packages/easyops-runtime/src/flowApi/FlowApiProvider.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

  • 5 others

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between f29d4ba and e396b04.

📒 Files selected for processing (9)
  • etc/runtime.api.md (2 hunks)
  • packages/easyops-runtime/src/flowApi/FlowApi.spec.ts (5 hunks)
  • packages/easyops-runtime/src/flowApi/FlowApi.ts (5 hunks)
  • packages/easyops-runtime/src/flowApi/FlowApiProvider.ts (3 hunks)
  • packages/runtime/src/internal/Runtime.ts (2 hunks)
  • packages/runtime/src/internal/bindListeners.spec.ts (5 hunks)
  • packages/runtime/src/internal/bindListeners.ts (3 hunks)
  • packages/runtime/src/internal/data/resolveData.ts (5 hunks)
  • packages/types/src/manifest.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/runtime/src/internal/Runtime.ts
  • packages/types/src/manifest.ts
  • packages/easyops-runtime/src/flowApi/FlowApi.spec.ts
  • etc/runtime.api.md
  • packages/easyops-runtime/src/flowApi/FlowApiProvider.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/runtime/src/internal/bindListeners.ts (2)
packages/types/src/manifest.ts (1)
  • UseProviderContractConf (698-707)
packages/runtime/src/internal/compute/computeRealValue.ts (1)
  • computeRealValue (124-204)
🪛 Biome (1.9.4)
packages/runtime/src/internal/data/resolveData.ts

[error] 74-74: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)

packages/easyops-runtime/src/flowApi/FlowApi.ts

[error] 9-9: Do not shadow the global "hasOwnProperty" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (9)
packages/runtime/src/internal/bindListeners.ts (2)

14-14: LGTM! 新增的类型导入支持契约配置功能

导入的 UseProviderContractConf 类型和 pick 函数为新的契约参数处理功能提供了必要支持。

Also applies to: 18-18


454-472: 新的契约参数处理逻辑设计合理

新增的逻辑正确地处理了 Flow API 提供者的契约配置场景:

  • 适当地检查了处理程序类型和提供者类型
  • 使用 pick 函数提取相关契约属性是安全且高效的做法
  • 通过 computeRealValue 处理动态值计算确保了运行时正确性

这种设计允许同时支持传统的数组参数和新的契约配置对象参数。

packages/runtime/src/internal/data/resolveData.ts (3)

33-43: 契约配置逻辑与整体架构保持一致

新增的契约配置逻辑正确地:

  • 扩展了参数解构以支持契约相关属性
  • 使用与 bindListeners.ts 一致的条件判断逻辑
  • 适当地创建 UseProviderContractConf 对象

参数重命名为 resolveOptions 也提高了代码可读性。

Also applies to: 65-70


72-81: 并行计算和条件参数传递实现得当

更新的 Promise.all 结构高效地并行计算了参数和契约配置。条件参数传递逻辑 actualContractConf?.params ? actualContractConf : (actualArgs ?? []) 正确地优先使用契约配置,确保了向后兼容性。

Also applies to: 92-93


135-135: 函数签名更新正确支持新的参数类型

resolveByProvider 函数的参数类型扩展和相应的类型断言更新都是正确的,确保了对 UseProviderContractConf 的完整支持。

Also applies to: 168-168

packages/runtime/src/internal/bindListeners.spec.ts (2)

20-20: 测试模拟设置完整且合理

新增的测试基础设施正确地模拟了 Flow API 行为:

  • FLOW_API_PROVIDER 常量和模拟的 flowApi 对象提供了必要的测试支持
  • 自定义元素的 resolve 方法简洁地验证了参数传递
  • 模拟逻辑与实际实现保持一致

这为新功能提供了可靠的测试基础。

Also applies to: 33-42, 45-52


1287-1307: 新测试用例全面验证契约参数功能

测试用例 "useProvider with flow api" 有效地验证了:

  • 契约参数的正确提取和传递(params.input 从事件详情中获取)
  • Flow API 提供者的正确调用
  • 成功回调的期望行为

测试断言 expect(consoleInfo).toHaveBeenCalledWith("Flow received: ok") 确认了端到端的数据流正确性。

packages/easyops-runtime/src/flowApi/FlowApi.ts (2)

41-41: 文件名处理逻辑向后兼容且设计合理

更新的函数签名和文件名处理逻辑正确地支持了两种参数格式:

  • 对于数组参数,保持原有的 shift() 行为
  • 对于契约配置,直接访问 filename 属性

这种实现确保了 saveAs 方法在两种参数格式下都能正常工作。

Also applies to: 64-67, 78-87


133-187: 参数转换逻辑重构显著提升了契约使用体验

重构后的参数处理逻辑实现了重要改进:

数组参数(向后兼容):

  • 保持原有的位置参数替换行为

契约配置(新功能):

  • 按名称进行 URI 参数替换,更加直观和可靠
  • 智能处理 bodyquery 扩展字段
  • 正确分离和组织不同类型的参数
  • 支持 options 透传

这种设计使得契约使用更加类型安全和用户友好,同时保持了完全的向后兼容性。

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Jul 7, 2025

Codecov Report

Attention: Patch coverage is 96.07843% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.23%. Comparing base (d818a38) to head (e396b04).
Report is 2 commits behind head on v3.

Files with missing lines Patch % Lines
packages/runtime/src/internal/bindListeners.ts 66.66% 0 Missing and 1 partial ⚠️
packages/runtime/src/internal/data/resolveData.ts 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##               v3    #4746      +/-   ##
==========================================
+ Coverage   95.21%   95.23%   +0.01%     
==========================================
  Files         209      209              
  Lines        9082     9120      +38     
  Branches     1743     1756      +13     
==========================================
+ Hits         8647     8685      +38     
+ Misses        323      322       -1     
- Partials      112      113       +1     
Files with missing lines Coverage Δ
packages/easyops-runtime/src/flowApi/FlowApi.ts 98.80% <100.00%> (+0.85%) ⬆️
...ges/easyops-runtime/src/flowApi/FlowApiProvider.ts 96.55% <100.00%> (ø)
packages/runtime/src/internal/Runtime.ts 94.56% <ø> (ø)
packages/runtime/src/internal/bindListeners.ts 91.66% <66.66%> (+0.44%) ⬆️
packages/runtime/src/internal/data/resolveData.ts 91.66% <75.00%> (-1.96%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/runtime/src/internal/data/resolveData.ts (1)

65-70: 优化建议:简化条件判断逻辑

当前的条件判断可以更清晰地表达:

-  const contractConf =
-    !Array.isArray(args) &&
-    params &&
-    hooks?.flowApi?.isFlowApiProvider(useProvider)
-      ? ({ params, options, filename } as UserProviderContractConf)
-      : null;
+  const isContractMode = !Array.isArray(args) && params && hooks?.flowApi?.isFlowApiProvider(useProvider);
+  const contractConf = isContractMode
+    ? ({ params, options, filename } as UserProviderContractConf)
+    : null;
packages/easyops-runtime/src/flowApi/FlowApi.ts (1)

136-145: 验证错误消息的完整性

当缺少必需参数时,错误消息可以更详细,帮助开发者定位问题:

-      throw new Error(`Missing required param: "${key}"`);
+      throw new Error(`Missing required param: "${key}" for API "${api.namespace}.${api.name}"`);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between d818a38 and f29d4ba.

📒 Files selected for processing (7)
  • etc/runtime.api.md (2 hunks)
  • packages/easyops-runtime/src/flowApi/FlowApi.spec.ts (5 hunks)
  • packages/easyops-runtime/src/flowApi/FlowApi.ts (5 hunks)
  • packages/easyops-runtime/src/flowApi/FlowApiProvider.ts (3 hunks)
  • packages/runtime/src/internal/Runtime.ts (2 hunks)
  • packages/runtime/src/internal/data/resolveData.ts (5 hunks)
  • packages/types/src/manifest.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
packages/types/src/manifest.ts (1)
packages/react-runtime/src/useProvider/useProviderTypes.ts (1)
  • RequestInit (49-51)
packages/runtime/src/internal/Runtime.ts (1)
packages/types/src/manifest.ts (1)
  • UserProviderContractConf (698-707)
packages/easyops-runtime/src/flowApi/FlowApi.spec.ts (1)
packages/easyops-runtime/src/flowApi/FlowApi.ts (1)
  • getArgsOfFlowApi (39-60)
packages/easyops-runtime/src/flowApi/FlowApiProvider.ts (2)
packages/types/src/manifest.ts (1)
  • ExtField (1304-1307)
packages/http/src/http.ts (1)
  • HttpOptions (62-62)
🪛 Biome (1.9.4)
packages/runtime/src/internal/data/resolveData.ts

[error] 74-74: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)

packages/easyops-runtime/src/flowApi/FlowApi.ts

[error] 9-9: Do not shadow the global "hasOwnProperty" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (17)
packages/types/src/manifest.ts (3)

673-674: LGTM!接口扩展设计合理

通过 extends Partial<UserProviderContractConf> 的设计很好地支持了可选的契约配置,允许用户根据需要使用新的参数结构。


682-682: 优先级说明清晰

注释明确说明了 argsparams 具有更高的优先级,这对开发者理解参数处理顺序很有帮助。


698-707: 新接口定义完整且文档清晰

UserProviderContractConf 接口设计合理:

  • params 作为必需的契约参数对象
  • optionsfilename 作为可选的扩展配置
  • JSDoc 注释清楚地说明了每个属性的用途和优先级

接口设计符合预期的契约参数支持需求。

packages/runtime/src/internal/Runtime.ts (2)

12-12: 导入语句正确

正确导入了新定义的 UserProviderContractConf 类型,为后续的接口更新提供了类型支持。


87-87: 方法签名更新恰当

originalArgs 参数类型从 unknown[] 扩展为 unknown[] | UserProviderContractConf 联合类型,很好地支持了向后兼容性,同时启用了新的契约参数功能。

etc/runtime.api.md (2)

47-47: API 导入声明一致

在 API 报告中正确添加了 UserProviderContractConf 类型导入,与运行时实现保持一致。


496-496: API 签名更新一致

getArgsOfFlowApi 方法的参数类型更新与 packages/runtime/src/internal/Runtime.ts 中的实现完全一致,确保了 API 报告的准确性。

packages/easyops-runtime/src/flowApi/FlowApi.spec.ts (4)

54-54: 测试契约模拟数据设计合理

新增的三个契约模拟数据很好地覆盖了不同的测试场景:

  • TestPost:基本的 POST 请求契约
  • TestPostWithExtFieldsQuery:包含查询参数扩展字段的契约
  • TestPostWithExtFieldsBody:包含请求体扩展字段的契约

契约结构完整,包含了必要的 endpoint、request 和 namespace 配置。

Also applies to: 110-190


219-237: 对象参数支持测试完整

测试用例验证了使用对象形式的参数({ params: {} })调用 getArgsOfFlowApi 的功能,确保新的契约参数结构能够正确处理。期望的返回值包含了正确的 request 配置和空的参数对象。


266-291: 文件下载场景测试充分

测试用例验证了在 saveAs 方法中使用契约参数对象的功能,包含 filename 属性的传递。这确保了文件下载场景下新参数结构的正确性。


354-450: 扩展字段处理测试全面

三个新的测试用例很好地验证了扩展字段的不同处理方式:

  1. 基本 POST 请求的参数提取和 URL 构建
  2. 查询参数扩展字段的处理(source: "query"
  3. 请求体扩展字段的处理(source: "body"

测试覆盖了 URI 参数替换、扩展字段提取和最终参数构造的完整流程。

packages/easyops-runtime/src/flowApi/FlowApiProvider.ts (5)

24-26: 可选参数处理改进

使用可选链操作符 ext_fields?.some() 正确处理了可选的 ext_fields 参数,避免了在参数为 undefined 时的运行时错误,提高了代码的健壮性。


29-29: 函数签名更新恰当

ext_fields 参数类型从 ExtField[] 更新为 ExtField[] | undefined,与实际使用场景更加匹配,支持了不包含扩展字段的契约。


35-35: 一致的可选链使用

hasBodyParams 的计算中也使用了可选链,与 hasQueryParams 的处理方式保持一致,确保了代码风格的统一性。


37-39: 重要的兼容性说明

添加的注释清楚地说明了参数顺序与生成的 SDK 不同的情况,这对维护向后兼容性很重要。注释有助于开发者理解为什么保持当前的参数顺序。


126-126: 逻辑简化合理

移除了 ext_fields 的默认值,并简化了 noParams 的计算逻辑。这些改进使代码更加简洁,同时保持了原有的功能逻辑。使用可选链和空值合并操作符提高了代码的可读性。

Also applies to: 143-146

packages/easyops-runtime/src/flowApi/FlowApi.ts (1)

78-87: 正确处理了 saveAs 方法的特殊逻辑

代码很好地处理了数组和对象两种参数形式下的文件名提取,保持了向后兼容性。

@cypress
Copy link

cypress bot commented Jul 7, 2025

next-core    Run #11479

Run Properties:  status check passed Passed #11479  •  git commit 71f25aae80 ℹ️: Merge e396b042a9032724d43f827f2233571c649dc382 into d818a386dc40fd6071b7a9c876bb...
Project next-core
Branch Review steve/v3-use-provider-params
Run status status check passed Passed #11479
Run duration 00m 27s
Commit git commit 71f25aae80 ℹ️: Merge e396b042a9032724d43f827f2233571c649dc382 into d818a386dc40fd6071b7a9c876bb...
Committer Shenwei Wang
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 17
View all changes introduced in this branch ↗︎

@weareoutman weareoutman force-pushed the steve/v3-use-provider-params branch from f29d4ba to e396b04 Compare July 7, 2025 08:49
@weareoutman weareoutman requested a review from Copilot July 7, 2025 08:59

export interface UseProviderContractConf {
/** 根据契约定义的参数对象。优先级低于 `args`。*/
params: Record<string, unknown>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

由于 AI 生成编排时不容易理解前台的参数构造规则,现支持直接按契约定义的 request 结构传递 params

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables passing contract-based parameters (params, options, filename) when using useProvider and integrates them into the runtime resolution and event binding flows.

  • Introduces UseProviderContractConf and extends UseProviderResolveConf/UseProviderEventHandler in types to allow object-based contract params.
  • Updates resolveData and bindListeners to detect and compute contract configs and route them through the flow API.
  • Enhances Flow API modules (FlowApiProvider.ts, FlowApi.ts) to accept UseProviderContractConf and adjust URI/args transformation.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/types/src/manifest.ts Added UseProviderContractConf and extended resolve/event interfaces.
packages/runtime/src/internal/data/resolveData.ts Enhanced resolveData to detect and apply contract params.
packages/runtime/src/internal/bindListeners.ts Updated listener binding to support contract params via getArgsOfFlowApi.
packages/easyops-runtime/src/flowApi/FlowApiProvider.ts Made ext_fields handling null-safe.
packages/easyops-runtime/src/flowApi/FlowApi.ts Refactored getArgsOfFlowApi and URI/args transformations.
packages/easyops-runtime/src/flowApi/FlowApi.spec.ts Added tests for contract-based params, filename, and missing parameter error.
etc/runtime.api.md Updated API docs to reflect new UseProviderContractConf overload.
Comments suppressed due to low confidence (2)

packages/runtime/src/internal/data/resolveData.ts:34

  • [nitpick] Consider renaming the parameter resolveOptions (e.g., to runtimeOptions) to avoid confusion with the options field in UseProviderContractConf.
) {

packages/runtime/src/internal/data/resolveData.ts:34

  • There are no unit tests covering the new UseProviderContractConf path in resolveData. Add tests to validate that contract-based parameters (params, options, filename) are passed correctly through this method.
) {

@weareoutman weareoutman requested a review from qiaofengxi July 7, 2025 09:04
@qiaofengxi qiaofengxi merged commit 2d27b2a into v3 Jul 7, 2025
8 checks passed
@qiaofengxi qiaofengxi deleted the steve/v3-use-provider-params branch July 7, 2025 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants