Skip to content

Conversation

@weareoutman
Copy link
Member

@weareoutman weareoutman commented Apr 17, 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

  • 新功能
    • 增加了对遗留属性转换的支持,包括属性批量转换和中间数据提取等能力,兼容旧版转换逻辑。
    • DataStore 类新增 has 方法,用于检测指定数据项是否存在。
  • 测试
    • 新增了全面的单元测试,覆盖遗留属性转换的多种场景和异常处理,保证转换行为的正确性。
    • 扩展了对全局上下文访问的测试,确保对 CTX.DS 属性的正确处理。
  • 重构
    • 遗留转换相关逻辑被集中到新模块,提升了代码结构清晰度和可维护性。
    • 调整了对遗留转换函数的导出方式,统一从新模块导出。

@coderabbitai
Copy link

coderabbitai bot commented Apr 17, 2025

## Walkthrough

此次更改主要围绕“legacy”属性转换逻辑的实现与重构。新增了 `legacy_transform.ts` 文件,集中实现了向后兼容的属性转换相关函数,包括 `legacyDoTransform``legacyTransformProperties``legacyTransformIntermediateData`,并提供了详细的类型定义。同时,相关接口及类型在 `getV2RuntimeFromDll.ts` 中进行了声明扩展。原本在 `secret_internals.ts` 内部实现的 `legacyDoTransform` 被移除,改为从新模块导出。新增了完整的单元测试文件 `legacy_transform.spec.ts`,覆盖各类转换场景。除此之外,还对 `evaluate` 函数增加了对全局 `CTX.DS` 的访问支持,并在 `DataStore` 类中新增了 `has` 方法用于检测数据项是否存在。

## Changes

| 文件/分组                                                         | 变更摘要                                                                                         |
|-------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|
| packages/runtime/src/getV2RuntimeFromDll.ts                       | `Kit` 接口新增 `transformProperties` 方法,新增并导出 `LegacyGeneralTransform``LegacyTransformMap``LegacyTransformItem` 类型定义。|
| packages/runtime/src/internal/legacy_transform.ts                 | 新增文件,实现 `legacyDoTransform``legacyTransformProperties``legacyTransformIntermediateData`,集中 legacy 属性转换逻辑。|
| packages/runtime/src/internal/legacy_transform.spec.ts            | 新增测试文件,针对 legacy 属性转换函数进行全面单元测试,涵盖多种输入、映射与错误场景。              |
| packages/runtime/src/internal/secret_internals.ts                 | 移除本地 `legacyDoTransform` 实现,改为从 `legacy_transform.ts` 重新导出 `legacyDoTransform``legacyTransformProperties``legacyTransformIntermediateData`|
| packages/runtime/src/internal/compute/evaluate.ts                 | 修改 `lowLevelEvaluate` 中对全局变量 `CTX` 的代理,支持从运行时上下文访问全局 `DS`,并调整代理的 `ownKeys` 处理逻辑。|
| packages/runtime/src/internal/compute/evaluate.spec.ts            | 新增针对访问全局 `CTX.DS` 的测试,验证访问不存在的属性抛错及模拟返回值的正确性。                    |
| packages/runtime/src/internal/data/DataStore.ts                   | 新增 `DataStore` 类的 `has(name: string): boolean` 方法,用于判断指定名称的数据是否存在。            |
| etc/runtime.api.md                                                | 移除并重新添加 `legacyDoTransform`,新增导出 `legacyTransformProperties``legacyTransformIntermediateData`,新增相关类型声明。|

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/runtime/src/internal/compute/evaluate.spec.ts

Oops! Something went wrong! :(

ESLint: 9.22.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

packages/runtime/src/getV2RuntimeFromDll.ts

Oops! Something went wrong! :(

ESLint: 9.22.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

packages/runtime/src/internal/compute/evaluate.ts

Oops! Something went wrong! :(

ESLint: 9.22.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@next-core/eslint-config-next' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

  • 4 others

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6f0c2ef and 0f2148a.

📒 Files selected for processing (8)
  • etc/runtime.api.md (2 hunks)
  • packages/runtime/src/getV2RuntimeFromDll.ts (2 hunks)
  • packages/runtime/src/internal/compute/evaluate.spec.ts (3 hunks)
  • packages/runtime/src/internal/compute/evaluate.ts (3 hunks)
  • packages/runtime/src/internal/data/DataStore.ts (1 hunks)
  • packages/runtime/src/internal/legacy_transform.spec.ts (1 hunks)
  • packages/runtime/src/internal/legacy_transform.ts (1 hunks)
  • packages/runtime/src/internal/secret_internals.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/runtime/src/internal/data/DataStore.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/runtime/src/internal/secret_internals.ts
  • packages/runtime/src/internal/legacy_transform.spec.ts
  • etc/runtime.api.md
  • packages/runtime/src/getV2RuntimeFromDll.ts
  • packages/runtime/src/internal/legacy_transform.ts
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/runtime/src/internal/compute/evaluate.spec.ts (2)
packages/runtime/src/internal/compute/evaluate.ts (1)
  • evaluate (105-112)
packages/runtime/src/internal/Renderer.spec.ts (1)
  • _internalApiGetRuntimeContext (70-72)
packages/runtime/src/internal/compute/evaluate.ts (1)
packages/runtime/src/internal/Renderer.spec.ts (1)
  • _internalApiGetRuntimeContext (70-72)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: build (20.x)
🔇 Additional comments (6)
packages/runtime/src/internal/compute/evaluate.spec.ts (2)

20-20: 添加了 _internalApiGetRuntimeContext 的导入和 mock

导入并 mock 了 _internalApiGetRuntimeContext 函数,为后续测试全局 CTX.DS 的访问做准备。

Also applies to: 79-79


400-420: 增加了全局 CTX.DS 访问的测试用例

这两个测试用例验证了 evaluate 函数对全局 CTX.DS 的访问行为:

  1. CTX.DS 不存在时,抛出适当的错误
  2. CTX.DS 存在于全局运行时上下文中时,能够正确获取其值

这与 PR 的目标相符,为支持遗留转换函数提供了必要的上下文访问能力。

packages/runtime/src/internal/compute/evaluate.ts (4)

32-33: 导入 _internalApiGetRuntimeContext 函数

从 Runtime.js 中导入了 _internalApiGetRuntimeContext 函数,用于获取全局运行时上下文。这是支持访问全局 CTX.DS 的必要准备。


208-208: 将 usedCtx 类型修改为可能为 undefined

usedCtx 的类型从确定的 Set<string> 改为 Set<string> | undefined,增加了代码的健壮性,避免在某些情况下出现 undefined 错误。


339-347: 增加对全局 CTX.DS 的访问支持

该修改允许从隔离的上下文(如仪表板)访问全局的 CTX.DS 属性。当本地 ctxStore 中不存在 "DS" 键时,会尝试从通过 _internalApiGetRuntimeContext() 获取的全局上下文中查找。这种回退机制使得遗留代码能够继续访问全局数据存储,增强了向后兼容性。


350-351: 安全处理 usedCtx 可能为 undefined 的情况

通过添加条件检查 usedCtx ? Array.from(usedCtx) : [],避免了当 usedCtx 为 undefined 时调用 Array.from 可能导致的运行时错误,增强了代码的健壮性。

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

coderabbitai[bot]

This comment was marked as resolved.

@weareoutman weareoutman force-pushed the steve/v3-legayc-transform branch from 88542f8 to 6f0c2ef Compare April 17, 2025 06:26
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: 0

🧹 Nitpick comments (1)
packages/runtime/src/internal/legacy_transform.ts (1)

120-127: 需要明确处理 "auto" 映射模式

当前代码仅对 true/false 做了明确的布尔判断,"auto" 值走默认路径,相当于"不改动"。为了增强代码的可读性和明确性,建议显式处理 "auto" 情况。

请考虑添加明确的 "auto" 处理逻辑:

 if (!isArray && mapArray === true) {
   isArray = true;
   fromData = [fromData];
 } else if (isArray && mapArray === false) {
   isArray = false;
+} else if (!isArray && mapArray === "auto") {
+  // 保持不变
+} else if (isArray && mapArray === "auto") {
+  // 保持映射
 }

请确认 "auto" 的预期行为是否为"数组时才映射"。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88542f8 and 6f0c2ef.

📒 Files selected for processing (5)
  • etc/runtime.api.md (2 hunks)
  • packages/runtime/src/getV2RuntimeFromDll.ts (2 hunks)
  • packages/runtime/src/internal/legacy_transform.spec.ts (1 hunks)
  • packages/runtime/src/internal/legacy_transform.ts (1 hunks)
  • packages/runtime/src/internal/secret_internals.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/runtime/src/internal/secret_internals.ts
  • packages/runtime/src/internal/legacy_transform.spec.ts
  • packages/runtime/src/getV2RuntimeFromDll.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (9)
packages/runtime/src/internal/legacy_transform.ts (6)

1-9: 导入依赖项和类型定义清晰明确

导入依赖和类型定义结构良好,与功能需求一致。特别是 getV2RuntimeFromDll 的导入显示了与 v2 运行时的兼容性设计。


10-33: 函数实现符合向后兼容设计要求

legacyDoTransform 函数实现了良好的向后兼容设计,优先尝试使用 v2 运行时,在不可用时回退到 v3 的实现。错误处理也很清晰。


35-59: transformProperties 实现方式符合预期

legacyTransformProperties 函数逻辑合理,优先使用 v2 运行时实现,回退逻辑处理清晰。使用 preprocessTransformProperties 预处理数据并设置属性是一个良好的设计决策。


61-79: 中间数据转换功能实现简洁有效

legacyTransformIntermediateData 实现简洁明了,正确处理了 from 路径的数据提取,并在必要时应用转换。


81-104: 预处理函数实现结构清晰

preprocessTransformProperties 函数实现得当,能正确处理数组和非数组转换项。


106-141: 管道转换函数设计良好

pipeableTransform 函数处理了不同类型转换的情况,包括字符串直接映射和对象映射。代码逻辑清晰,正确处理了数组和非数组数据的转换。

etc/runtime.api.md (3)

76-78: 在内部 API 中正确导出了新函数

__secret_internals 命名空间中正确导出了 legacyDoTransformlegacyTransformProperties 函数,使其可在内部使用。


264-280: 新增类型定义结构清晰

LegacyGeneralTransformLegacyTransformItemLegacyTransformMap 类型定义清晰明确,为转换功能提供了良好的类型支持。


282-283: 函数签名定义完整

legacyTransformProperties 函数签名完整,包含所有必要的参数和返回类型。

@codecov
Copy link

codecov bot commented Apr 17, 2025

Codecov Report

Attention: Patch coverage is 98.14815% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.27%. Comparing base (04d24eb) to head (0f2148a).
Report is 3 commits behind head on v3.

Files with missing lines Patch % Lines
packages/runtime/src/internal/compute/evaluate.ts 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##               v3    #4679      +/-   ##
==========================================
+ Coverage   95.25%   95.27%   +0.01%     
==========================================
  Files         208      209       +1     
  Lines        8982     9028      +46     
  Branches     1719     1734      +15     
==========================================
+ Hits         8556     8601      +45     
  Misses        319      319              
- Partials      107      108       +1     
Files with missing lines Coverage Δ
packages/runtime/src/getV2RuntimeFromDll.ts 100.00% <ø> (ø)
packages/runtime/src/internal/data/DataStore.ts 98.08% <100.00%> (+0.01%) ⬆️
packages/runtime/src/internal/legacy_transform.ts 100.00% <100.00%> (ø)
packages/runtime/src/internal/secret_internals.ts 94.89% <ø> (-0.25%) ⬇️
packages/runtime/src/internal/compute/evaluate.ts 98.41% <80.00%> (-0.51%) ⬇️
🚀 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.

@cypress
Copy link

cypress bot commented Apr 17, 2025

next-core    Run #11174

Run Properties:  status check passed Passed #11174  •  git commit a6a874ff64 ℹ️: Merge 0f2148a63549e406fe294ea8df97c17d4960708d into 04d24eb7fccdeca2050d57df1b39...
Project next-core
Branch Review steve/v3-legayc-transform
Run status status check passed Passed #11174
Run duration 00m 26s
Commit git commit a6a874ff64 ℹ️: Merge 0f2148a63549e406fe294ea8df97c17d4960708d into 04d24eb7fccdeca2050d57df1b39...
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 16
View all changes introduced in this branch ↗︎

@weareoutman weareoutman force-pushed the steve/v3-legayc-transform branch from 6f0c2ef to 0f2148a Compare April 17, 2025 07:37
@weareoutman weareoutman requested a review from Copilot April 17, 2025 07:39
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.

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

@WHChen-Alex WHChen-Alex merged commit 654cba9 into v3 Apr 17, 2025
8 checks passed
@WHChen-Alex WHChen-Alex deleted the steve/v3-legayc-transform branch April 17, 2025 08:00
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