integrate-webapi

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Integrate Web API

集成Web API

Integrate Power Pages Web API into a code site's frontend. This skill orchestrates the full lifecycle: analyzing where integrations are needed, implementing API client code for each table, configuring permissions and site settings, and deploying the site.
将Power Pages Web API集成到代码站点的前端中。此技能编排完整的生命周期:分析集成需求、为每个表实现API客户端代码、配置权限和站点设置,以及部署站点。

Core Principles

核心原则

  • First table sequential, then parallel: The first table must be processed alone because it creates the shared
    powerPagesApi.ts
    client. Once that exists, remaining tables can be processed in parallel since each creates independent files (types, service, hooks).
  • Parallelize independent agents: The
    table-permissions-architect
    and
    webapi-settings-architect
    agents are independent — invoke them in parallel rather than sequentially.
  • Permissions require deployment: The
    .powerpages-site
    folder must exist before table permissions and site settings can be configured. Integration code can be written without it, but permissions cannot.
  • Use TaskCreate/TaskUpdate: Track all progress throughout all phases — create the todo list upfront with all phases before starting any work.
Prerequisites:
  • An existing Power Pages code site created via
    /create-site
  • A Dataverse data model (tables/columns) already set up via
    /setup-datamodel
    or created manually
  • The site must be deployed at least once (
    .powerpages-site
    folder must exist) for permissions setup
Initial request: $ARGUMENTS

  • 第一个表串行处理,后续表并行处理:第一个表必须单独处理,因为它会创建共享的
    powerPagesApi.ts
    客户端。一旦该客户端存在,剩余表可以并行处理,因为每个表都会创建独立的文件(类型定义、服务、钩子)。
  • 并行调用独立Agent
    table-permissions-architect
    webapi-settings-architect
    Agent是独立的——应并行调用而非串行。
  • 权限配置需要部署:在配置表权限和站点设置之前,必须存在
    .powerpages-site
    文件夹。集成代码可以在没有该文件夹的情况下编写,但权限配置不行。
  • 使用TaskCreate/TaskUpdate:在所有阶段跟踪所有进度——在开始任何工作之前,预先创建包含所有阶段的待办事项列表。
前提条件:
  • 已通过
    /create-site
    创建现有Power Pages代码站点
  • 已通过
    /setup-datamodel
    或手动创建Dataverse数据模型(表/列)
  • 站点至少已部署一次(必须存在
    .powerpages-site
    文件夹)才能进行权限设置
初始请求: $ARGUMENTS

Workflow

工作流程

  1. Verify Site Exists — Locate the Power Pages project and verify prerequisites
  2. Explore Integration Points — Analyze site code and data model to identify tables needing Web API integration
  3. Review Integration Plan — Present findings to the user and confirm which tables to integrate
  4. Implement Integrations — Use the
    webapi-integration
    agent for each table
  5. Verify Integrations — Validate all expected files exist and the project builds successfully
  6. Setup Permissions & Settings — Choose permissions source (upload diagram or let the architects analyze), then configure table permissions and Web API site settings with case-sensitive validated column names
  7. Review & Deploy — Ask the user to deploy the site and invoke
    /deploy-site
    if confirmed

  1. 验证站点存在 — 定位Power Pages项目并验证前提条件
  2. 探索集成点 — 分析站点代码和数据模型,确定需要Web API集成的表
  3. 审核集成计划 — 向用户展示发现结果并确认要集成的表
  4. 实现集成 — 为每个表使用
    webapi-integration
    Agent
  5. 验证集成 — 验证所有预期文件是否存在,项目是否能成功构建
  6. 设置权限和设置 — 选择权限来源(上传图表或让架构师分析),然后使用区分大小写的已验证列名配置表权限和Web API站点设置
  7. 审核与部署 — 请用户部署站点,若用户确认则调用
    /deploy-site

Phase 1: Verify Site Exists

阶段1:验证站点存在

Goal: Locate the Power Pages project root and confirm that prerequisites are met
Actions:
目标:定位Power Pages项目根目录并确认满足前提条件
操作

1.1 Locate Project

1.1 定位项目

Look for
powerpages.config.json
in the current directory or immediate subdirectories to find the project root.
powershell
Get-ChildItem -Path . -Filter "powerpages.config.json" -Recurse -Depth 1
If not found: Tell the user to create a site first with
/create-site
.
在当前目录或直接子目录中查找
powerpages.config.json
以确定项目根目录。
powershell
Get-ChildItem -Path . -Filter "powerpages.config.json" -Recurse -Depth 1
若未找到:告知用户先使用
/create-site
创建站点。

1.2 Read Existing Config

1.2 读取现有配置

Read
powerpages.config.json
to get the site name:
powershell
Get-Content "<PROJECT_ROOT>/powerpages.config.json" | ConvertFrom-Json
读取
powerpages.config.json
以获取站点名称:
powershell
Get-Content "<PROJECT_ROOT>/powerpages.config.json" | ConvertFrom-Json

1.3 Detect Framework

1.3 检测框架

Read
package.json
to determine the framework (React, Vue, Angular, or Astro). See
${CLAUDE_PLUGIN_ROOT}/references/framework-conventions.md
for the full framework detection mapping.
读取
package.json
以确定框架(React、Vue、Angular或Astro)。有关完整的框架检测映射,请参阅
${CLAUDE_PLUGIN_ROOT}/references/framework-conventions.md

1.4 Check for Data Model

1.4 检查数据模型

Look for
.datamodel-manifest.json
to discover available tables:
text
**/.datamodel-manifest.json
If found, read it — this is the primary source for table discovery.
查找
.datamodel-manifest.json
以发现可用表:
text
**/.datamodel-manifest.json
若找到,读取该文件——这是表发现的主要来源。

1.5 Check Deployment Status

1.5 检查部署状态

Look for the
.powerpages-site
folder:
text
**/.powerpages-site
If not found: Warn the user that the permissions phase (Phase 5) will require deployment first. The integration code (Phases 2–4) can still proceed.
Output: Confirmed project root, framework, data model availability, and deployment status

查找
.powerpages-site
文件夹:
text
**/.powerpages-site
若未找到:警告用户权限阶段(阶段5)需要先部署站点。集成代码(阶段2–4)仍可继续进行。
输出:已确认的项目根目录、框架、数据模型可用性和部署状态

Phase 2: Explore Integration Points

阶段2:探索集成点

Goal: Analyze the site code and data model to identify all tables needing Web API integration
Actions:
Use the Explore agent (via
Task
tool with
agent_type: "explore"
) to analyze the site code and data model. The Explore agent should answer these questions:
目标:分析站点代码和数据模型,确定所有需要Web API集成的表
操作
使用Explore Agent(通过
Task
工具,
agent_type: "explore"
)分析站点代码和数据模型。Explore Agent应回答以下问题:

2.1 Discover Tables

2.1 发现表

Ask the Explore agent to identify all Dataverse tables that need Web API integration by examining:
  • .datamodel-manifest.json
    — List of tables and their columns
  • src/**/*.{ts,tsx,js,jsx,vue,astro}
    — Source code files that reference table data, mock data, or placeholder API calls
  • Existing
    /_api/
    fetch patterns in the code
  • TypeScript interfaces or types that map to Dataverse table schemas
  • Component files that display or manipulate data from Dataverse tables
  • Mock data files or hardcoded arrays that should be replaced with API calls
  • TODO
    or
    FIXME
    comments mentioning API integration
Prompt for the Explore agent:
"Analyze this Power Pages code site and identify all Dataverse tables that need Web API integration. Check
.datamodel-manifest.json
for the data model, then search the source code for: mock data arrays, hardcoded data, placeholder fetch calls to
/_api/
, TypeScript interfaces matching Dataverse column patterns (publisher prefix like
cr*_
), TODO/FIXME comments about API integration, and components that display table data. For each table found, report: the table logical name, the entity set name (plural), which source files reference it, what operations are needed (read/create/update/delete), and whether an existing API client or service already exists in
src/shared/
or
src/services/
. Also check if
src/shared/powerPagesApi.ts
already exists."
请Explore Agent通过检查以下内容,确定所有需要Web API集成的Dataverse表:
  • .datamodel-manifest.json
    — 表及其列的列表
  • src/**/*.{ts,tsx,js,jsx,vue,astro}
    — 引用表数据、模拟数据或占位符API调用的源代码文件
  • 代码中现有的
    /_api/
    获取模式
  • 映射到Dataverse表架构的TypeScript接口或类型
  • 显示或操作Dataverse表数据的组件文件
  • 应替换为API调用的模拟数据文件或硬编码数组
  • 提及API集成的
    TODO
    FIXME
    注释
给Explore Agent的提示:
"分析此Power Pages代码站点,确定所有需要Web API集成的Dataverse表。检查
.datamodel-manifest.json
获取数据模型,然后在源代码中搜索:模拟数据数组、硬编码数据、对
/_api/
的占位符获取调用、匹配Dataverse列模式的TypeScript接口(发布者前缀如
cr*_
)、关于API集成的TODO/FIXME注释,以及显示表数据的组件。对于每个找到的表,报告:表逻辑名称、实体集名称(复数形式)、引用它的源文件、需要的操作(读取/创建/更新/删除),以及
src/shared/
src/services/
中是否已存在API客户端或服务。同时检查
src/shared/powerPagesApi.ts
是否已存在。"

2.2 Identify Existing Integration Code

2.2 识别现有集成代码

The Explore agent should also report:
  • Whether
    src/shared/powerPagesApi.ts
    (or equivalent API client) already exists
  • Which tables already have service files in
    src/shared/services/
    or
    src/services/
  • Which tables already have type definitions in
    src/types/
  • Any framework-specific hooks/composables already created
This avoids duplicating work that was already done.
Explore Agent还应报告:
  • src/shared/powerPagesApi.ts
    (或等效的API客户端)是否已存在
  • 哪些表在
    src/shared/services/
    src/services/
    中已有服务文件
  • 哪些表在
    src/types/
    中已有类型定义
  • 已创建的任何框架特定钩子/组合式函数
这避免了重复已完成的工作。

2.3 Compile Integration Manifest

2.3 编译集成清单

From the Explore agent's findings, compile a list of tables needing integration:
TableLogical NameEntity SetOperationsFiles ReferencingExisting Service
Products
cr4fc_product
cr4fc_products
CRUD
ProductList.tsx
,
ProductCard.tsx
None
Categories
cr4fc_category
cr4fc_categories
Read
CategoryFilter.tsx
None
Output: Complete integration manifest listing all tables, their operations, referencing files, and existing service status

根据Explore Agent的发现,编译需要集成的表列表:
逻辑名称实体集操作引用文件现有服务
Products
cr4fc_product
cr4fc_products
CRUD
ProductList.tsx
,
ProductCard.tsx
Categories
cr4fc_category
cr4fc_categories
读取
CategoryFilter.tsx
输出:完整的集成清单,列出所有表、它们的操作、引用文件和现有服务状态

Phase 3: Review Integration Plan

阶段3:审核集成计划

Goal: Present the integration manifest to the user and confirm which tables to integrate
Actions:
目标:向用户展示集成清单并确认要集成的表
操作

3.1 Present Findings

3.1 展示发现结果

Show the user:
  1. The tables that were identified for Web API integration
  2. For each table: which files reference it, what operations are needed
  3. Whether a shared API client already exists or needs to be created
  4. Any tables that were skipped (already have services)
向用户展示:
  1. 已确定需要Web API集成的表
  2. 每个表:哪些文件引用它、需要哪些操作
  3. 共享API客户端是否已存在或需要创建
  4. 已跳过的表(已有服务)

3.2 Confirm Tables

3.2 确认表

Use
AskUserQuestion
to confirm:
QuestionOptions
I found the following tables that need Web API integration: [list tables]. Which tables should I integrate?All of them (Recommended), Let me select specific tables, I need to add more tables
If the user selects specific tables or adds more, update the integration manifest accordingly.
Output: User-confirmed list of tables to integrate

使用
AskUserQuestion
确认:
问题选项
我找到了以下需要Web API集成的表:[表列表]。我应该集成哪些表?全部集成(推荐),让我选择特定表,我需要添加更多表
如果用户选择特定表或添加更多表,相应更新集成清单。
输出:用户确认的要集成的表列表

Phase 4: Implement Integrations

阶段4:实现集成

Goal: Create Web API integration code for each confirmed table using the
webapi-integration
agent
Actions:
目标:使用
webapi-integration
Agent为每个已确认的表创建Web API集成代码
操作

4.1 Invoke Agent Per Table

4.1 为每个表调用Agent

For each table, use the
Task
tool to invoke the
webapi-integration
agent at
${CLAUDE_PLUGIN_ROOT}/agents/webapi-integration.md
:
Prompt template for the agent:
"Integrate Power Pages Web API for the [Table Display Name] table.
  • Table logical name:
    [logical_name]
  • Entity set name:
    [entity_set_name]
  • Operations needed: [read/create/update/delete]
  • Framework: [React/Vue/Angular/Astro]
  • Project root: [path]
  • Source files referencing this table: [list of files]
  • Data model manifest path: [path to .datamodel-manifest.json if available]
Create the TypeScript types, CRUD service layer, and framework-specific hooks/composables. Replace any mock data or placeholder API calls in the referencing source files with the new service."
对于每个表,使用
Task
工具调用位于
${CLAUDE_PLUGIN_ROOT}/agents/webapi-integration.md
webapi-integration
Agent:
Agent提示模板:
"为**[表显示名称]**表集成Power Pages Web API。
  • 表逻辑名称:
    [logical_name]
  • 实体集名称:
    [entity_set_name]
  • 需要的操作:[read/create/update/delete]
  • 框架:[React/Vue/Angular/Astro]
  • 项目根目录:[path]
  • 引用此表的源文件:[文件列表]
  • 数据模型清单路径:[.datamodel-manifest.json的路径(若可用)]
创建TypeScript类型、CRUD服务层和框架特定的钩子/组合式函数。将引用源文件中的任何模拟数据或占位符API调用替换为新服务。"

4.2 Process First Table, Then Parallelize Remaining

4.2 先处理第一个表,然后并行处理剩余表

The first table must be processed alone — it creates the shared
powerPagesApi.ts
client that all other tables depend on. After the first table completes and the shared client exists:
  • Verify the shared API client was created at
    src/shared/powerPagesApi.ts
  • Then invoke all remaining tables in parallel using multiple
    Task
    calls — each table creates independent files (its own types in
    src/types/
    , service in
    src/shared/services/
    , and hook/composable), so there are no conflicts
If there is only one table, this step is simply sequential.
第一个表必须单独处理——它会创建所有其他表依赖的共享
powerPagesApi.ts
客户端。第一个表完成且共享客户端存在后:
  • 验证共享API客户端是否已创建在
    src/shared/powerPagesApi.ts
  • 然后并行调用所有剩余表——使用多个
    Task
    调用,每个表创建独立文件(其自己的类型在
    src/types/
    、服务在
    src/shared/services/
    、钩子/组合式函数),因此不会有冲突
如果只有一个表,此步骤只需串行处理。

4.3 Verify Each Integration

4.3 验证每个集成

After each agent completes (or after all parallel agents complete), verify the output:
  • Check that the expected files were created (types, service, hook/composable)
  • Confirm the shared API client exists after the first table is processed
  • Note any issues reported by the agent
每个Agent完成后(或所有并行Agent完成后),验证输出:
  • 检查是否创建了预期文件(类型、服务、钩子/组合式函数)
  • 确认第一个表处理完成后共享API客户端已存在
  • 记录Agent报告的任何问题

4.4 Git Commit

4.4 Git提交

After all integrations are complete, stage and commit:
powershell
git add -A
git commit -m "Add Web API integration for [table names]"
Output: Integration code created for all confirmed tables, verified and committed

所有集成完成后,暂存并提交:
powershell
git add -A
git commit -m "Add Web API integration for [table names]"
输出:为所有已确认的表创建了集成代码,已验证并提交

Phase 5: Verify Integrations

阶段5:验证集成

Goal: Validate that all expected integration files exist, imports are correct, and the project builds successfully
Actions:
目标:验证所有预期集成文件是否存在、导入是否正确、项目是否能成功构建
操作

5.1 Verify File Inventory

5.1 验证文件清单

For each integrated table, confirm the following files exist:
  • Type definition in
    src/types/
    (e.g.,
    src/types/product.ts
    )
  • Service file in
    src/shared/services/
    or
    src/services/
    (e.g.,
    productService.ts
    )
  • Framework-specific hook/composable (e.g.,
    src/shared/hooks/useProducts.ts
    for React,
    src/composables/useProducts.ts
    for Vue)
Also verify:
  • Shared API client at
    src/shared/powerPagesApi.ts
    exists
  • Each service file references
    /_api/
    endpoints
  • Each service file imports from the shared API client
对于每个已集成的表,确认以下文件存在:
  • 类型定义
    src/types/
    中(例如
    src/types/product.ts
  • 服务文件
    src/shared/services/
    src/services/
    中(例如
    productService.ts
  • 框架特定的钩子/组合式函数(例如React的
    src/shared/hooks/useProducts.ts
    ,Vue的
    src/composables/useProducts.ts
同时验证:
  • 共享API客户端存在于
    src/shared/powerPagesApi.ts
  • 每个服务文件引用
    /_api/
    端点
  • 每个服务文件从共享API客户端导入

5.2 Verify Build

5.2 验证构建

Run the project build to catch any import errors, type errors, or missing dependencies:
powershell
npm run build
If the build fails, fix the issues before proceeding. Common issues:
  • Missing imports between generated files
  • Type mismatches between service and type definitions
  • Framework-specific compilation errors
运行项目构建以捕获任何导入错误、类型错误或缺失的依赖项:
powershell
npm run build
如果构建失败,在继续之前修复问题。常见问题:
  • 生成文件之间缺少导入
  • 服务和类型定义之间的类型不匹配
  • 框架特定的编译错误

5.3 Present Verification Results

5.3 展示验证结果

Present a table summarizing the verification:
TableTypesServiceHook/ComposableAPI References
Products
src/types/product.ts
src/shared/services/productService.ts
src/shared/hooks/useProducts.ts
/_api/cr4fc_products
...............
Build status: Pass / Fail (with details)
Output: All integration files verified, project builds successfully

展示总结验证结果的表格:
类型服务钩子/组合式函数API引用
Products
src/types/product.ts
src/shared/services/productService.ts
src/shared/hooks/useProducts.ts
/_api/cr4fc_products
...............
构建状态:通过/失败(含详细信息)
输出:所有集成文件已验证,项目构建成功

Phase 6: Setup Permissions & Settings

阶段6:设置权限和设置

Goal: Configure table permissions and Web API site settings for all integrated tables using the
table-permissions-architect
and
webapi-settings-architect
agents
Actions:
目标:使用
table-permissions-architect
webapi-settings-architect
Agent为所有已集成的表配置表权限和Web API站点设置
操作

6.1 Check Deployment Prerequisite

6.1 检查部署前提条件

Both agents require the
.powerpages-site
folder. If it doesn't exist:
Use
AskUserQuestion
:
QuestionOptions
The
.powerpages-site
folder was not found. The site needs to be deployed once before permissions and site settings can be configured. Would you like to deploy now?
Yes, deploy now (Recommended), Skip permissions for now — I'll set them up later
If "Yes, deploy now": Invoke
/deploy-site
first, then resume this phase.
If "Skip": Skip to Phase 7 with a note that permissions and site settings still need to be configured.
两个Agent都需要
.powerpages-site
文件夹。若不存在:
使用
AskUserQuestion
问题选项
未找到
.powerpages-site
文件夹。在配置权限和站点设置之前,站点需要部署一次。您现在要部署吗?
是,现在部署(推荐),暂时跳过权限设置——我稍后再配置
若选择“是,现在部署”:先调用
/deploy-site
,然后恢复此阶段。
若选择“跳过”:跳到阶段7,并记录权限和站点设置仍需配置的提示。

6.2 Choose Permissions Source

6.2 选择权限来源

Ask the user how they want to define the permissions using the
AskUserQuestion
tool:
Question: "How would you like to define the Web API permissions and settings for your site?"
OptionDescription
Upload an existing permissions diagramProvide an image (PNG/JPG) or Mermaid diagram of your existing permissions structure
Let the architects figure it outThe Table Permissions Architect and Web API Settings Architect will analyze your site's code, data model, and Dataverse environment, then propose permissions and settings automatically
Route to the appropriate path:
使用
AskUserQuestion
工具询问用户如何定义权限:
问题:"您希望如何定义站点的Web API权限和设置?"
选项描述
上传现有权限图表提供现有权限结构的图像(PNG/JPG)或Mermaid图表
让架构师自动分析表权限架构师和Web API设置架构师将分析您的站点代码、数据模型和Dataverse环境,然后自动提出权限和设置建议
根据选择路由到相应路径:

Path A: Upload Existing Permissions Diagram

路径A:上传现有权限图表

If the user chooses to upload an existing diagram:
  1. Ask the user to provide their permissions diagram. Supported formats:
    • Image file (PNG, JPG) — Use the
      Read
      tool to view the image and extract web roles, table permissions, CRUD flags, scopes, and site settings from it
    • Mermaid syntax — The user can paste a Mermaid flowchart diagram text directly in chat
    • Text description — A structured list of web roles, table permissions, scopes, and site settings
  2. Parse the diagram into structured format:
    • Web roles: Match with existing roles from
      .powerpages-site/web-roles/
      by name to get their UUIDs
    • Table permissions: Permission name, table logical name, web role UUID(s), scope, CRUD flags (read/create/write/delete/append/appendto), parent permission and relationship name (if Parent scope)
    • Site settings:
      Webapi/<table>/enabled
      and
      Webapi/<table>/fields
      CRITICAL: fields normally list specific column logical names; only use
      *
      when the site relies on aggregate OData queries (
      $apply
      /aggregate) that otherwise fail with 403
  3. Validate column names against Dataverse — Even when using a user-provided diagram, query Dataverse for each table's column LogicalNames and verify that every column in the
    Webapi/<table>/fields
    values uses the exact Dataverse LogicalName (case-sensitive). Correct any mismatches before creating files.
  4. Cross-check with existing configuration in
    .powerpages-site/
    to identify which permissions and site settings are new vs. already exist.
  5. Generate a Mermaid flowchart from the parsed data (if the user provided an image or text) for visual confirmation.
  6. Present the parsed permissions plan to the user for approval using
    AskUserQuestion
    :
    QuestionOptions
    Does this permissions plan look correct?Approve and create files (Recommended), Request changes, Cancel
  7. Proceed directly to section 6.4: Create Permission & Settings Files with the parsed data.
如果用户选择上传现有图表:
  1. 请用户提供其权限图表。支持的格式:
    • 图像文件(PNG、JPG)——使用
      Read
      工具查看图像并从中提取Web角色、表权限、CRUD标志、范围和站点设置
    • Mermaid语法——用户可直接在聊天中粘贴Mermaid流程图文本
    • 文本描述——Web角色、表权限、范围和站点设置的结构化列表
  2. 将图表解析为结构化格式:
    • Web角色:通过名称与
      .powerpages-site/web-roles/
      中的现有角色匹配以获取其UUID
    • 表权限:权限名称、表逻辑名称、Web角色UUID、范围、CRUD标志(read/create/write/delete/append/appendto)、父权限和关系名称(若为Parent范围)
    • 站点设置
      Webapi/<table>/enabled
      Webapi/<table>/fields
      ——关键:字段通常列出特定列逻辑名称;只有当站点依赖聚合OData查询(
      $apply
      /aggregate)且否则会失败返回403时,才使用
      *
  3. 针对Dataverse验证列名称——即使使用用户提供的图表,也要查询Dataverse获取每个表的列LogicalNames,并验证
    Webapi/<table>/fields
    值中的每个列都使用了精确的Dataverse LogicalName(区分大小写)。在创建文件之前纠正任何不匹配。
  4. .powerpages-site/
    中的现有配置交叉检查,以确定哪些权限和站点设置是新的,哪些已存在。
  5. 从解析的数据生成Mermaid流程图(若用户提供的是图像或文本)以进行可视化确认。
  6. 使用
    AskUserQuestion
    向用户展示解析后的权限计划以获得批准:
    问题选项
    此权限计划看起来正确吗?批准并创建文件(推荐),请求更改,取消
  7. 使用解析的数据直接进入第6.4节:创建权限和设置文件

Path B: Let the Architects Figure It Out

路径B:让架构师自动分析

If the user chooses to let the architects figure it out, proceed to section 6.3: Invoke Table Permissions Agent.
如果用户选择让架构师自动分析,进入第6.3节:调用表权限Agent

6.3 Invoke Table Permissions and Web API Settings Agents (in Parallel)

6.3 并行调用表权限和Web API设置Agent

These two agents are independent — invoke them in parallel using two
Task
calls simultaneously:
这两个Agent是独立的——使用两个
Task
调用同时并行调用:

Table Permissions Agent

表权限Agent

Use the
Task
tool to invoke the
table-permissions-architect
agent at
${CLAUDE_PLUGIN_ROOT}/agents/table-permissions-architect.md
:
Prompt:
"Analyze this Power Pages code site and propose table permissions. The following tables have been integrated with Web API: [list of tables integrated in Phase 4]. Check for existing web roles and table permissions. Propose a complete table permissions plan covering all integrated tables. After I approve the plan, create the web role and table permission YAML files using the deterministic scripts."
The agent will:
  1. Analyze the site and propose a plan (with Mermaid diagram)
  2. Present the plan via plan mode for user approval
  3. After approval, create any needed web roles using
    create-web-role.js
  4. Create all table permission files using
    create-table-permission.js
  5. Return a summary of created files
使用
Task
工具调用位于
${CLAUDE_PLUGIN_ROOT}/agents/table-permissions-architect.md
table-permissions-architect
Agent:
提示:
"分析此Power Pages代码站点并提出表权限建议。以下表已与Web API集成:[阶段4中集成的表列表]。检查现有Web角色和表权限。提出涵盖所有已集成表的完整表权限计划。我批准计划后,使用确定性脚本创建Web角色和表权限YAML文件。"
该Agent将:
  1. 分析站点并提出计划(含Mermaid图表)
  2. 通过计划模式向用户展示计划以获得批准
  3. 批准后,使用
    create-web-role.js
    创建任何需要的Web角色
  4. 使用
    create-table-permission.js
    创建所有表权限文件
  5. 返回已创建文件的摘要

Web API Settings Agent

Web API设置Agent

Use the
Task
tool to invoke the
webapi-settings-architect
agent at
${CLAUDE_PLUGIN_ROOT}/agents/webapi-settings-architect.md
:
Prompt:
"Analyze this Power Pages code site and propose Web API site settings. The following tables have been integrated with Web API: [list of tables integrated in Phase 4]. Check for existing site settings and query Dataverse for exact column LogicalNames. Propose site settings with case-sensitive validated column names. After I approve the plan, create the site setting YAML files using the deterministic scripts."
The agent will:
  1. Analyze the site, query Dataverse for exact column LogicalNames
  2. Cross-validate column names (case-sensitive)
  3. Present the plan via plan mode for user approval
  4. After approval, create all site setting files using
    create-site-setting.js
  5. Return a summary of created files
Wait for both agents to complete before proceeding to 6.4.
使用
Task
工具调用位于
${CLAUDE_PLUGIN_ROOT}/agents/webapi-settings-architect.md
webapi-settings-architect
Agent:
提示:
"分析此Power Pages代码站点并提出Web API站点设置建议。以下表已与Web API集成:[阶段4中集成的表列表]。检查现有站点设置并查询Dataverse获取精确的列LogicalNames。提出使用区分大小写的已验证列名称的站点设置。我批准计划后,使用确定性脚本创建站点设置YAML文件。"
该Agent将:
  1. 分析站点,查询Dataverse获取精确的列LogicalNames
  2. 交叉验证列名称(区分大小写)
  3. 通过计划模式向用户展示计划以获得批准
  4. 批准后,使用
    create-site-setting.js
    创建所有站点设置文件
  5. 返回已创建文件的摘要
继续进行6.4之前,等待两个Agent完成。

6.4 Create Permission & Settings Files (Path A Only)

6.4 创建权限和设置文件(仅路径A)

This section applies only to Path A (user-provided permissions diagram). For Path B, the architect agents create the files directly in section 6.3.
After parsing the user's diagram, create the YAML files using the deterministic scripts below. Do NOT write YAML files manually — always use these scripts which handle UUID generation, field ordering, formatting, and file naming automatically.
本节仅适用于路径A(用户提供的权限图表)。对于路径B,架构师Agent在第6.3节中直接创建文件。
解析用户的图表后,使用以下确定性脚本创建YAML文件。请勿手动编写YAML文件——始终使用这些脚本,它们会自动处理UUID生成、字段排序、格式和文件命名。

6.4.1 Create Web Roles (if needed)

6.4.1 创建Web角色(若需要)

If the plan requires new web roles that don't already exist, create them first (their UUIDs are needed for table permissions):
powershell
node "${CLAUDE_PLUGIN_ROOT}/skills/create-webroles/scripts/create-web-role.js" --projectRoot "<PROJECT_ROOT>" --name "<Role Name>" [--anonymous] [--authenticated]
Capture the JSON output (
{ "id": "<uuid>", "filePath": "<path>" }
) — use the
id
as the
--webRoleIds
value when creating table permissions.
如果计划需要新的Web角色(当前不存在),先创建它们(表权限需要它们的UUID):
powershell
node "${CLAUDE_PLUGIN_ROOT}/skills/create-webroles/scripts/create-web-role.js" --projectRoot "<PROJECT_ROOT>" --name "<Role Name>" [--anonymous] [--authenticated]
捕获JSON输出(
{ "id": "<uuid>", "filePath": "<path>" }
)——创建表权限时使用
id
作为
--webRoleIds
的值。

6.4.2 Create Table Permissions

6.4.2 创建表权限

For each table permission in the plan. Process parent permissions before child permissions — children need the parent's UUID from the JSON output.
For Global/Contact/Account/Self scope:
powershell
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-table-permission.js" --projectRoot "<PROJECT_ROOT>" --permissionName "<Permission Name>" --tableName "<table_logical_name>" --webRoleIds "<uuid1,uuid2>" --scope "Global" [--read] [--create] [--write] [--delete] [--append] [--appendto]
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-table-permission.js" --projectRoot "<PROJECT_ROOT>" --permissionName "<Permission Name>" --tableName "<table_logical_name>" --webRoleIds "<uuid1,uuid2>" --scope "Contact" --contactRelationshipName "<lookup_to_contact>" [--read] [--create] [--write] [--delete] [--append] [--appendto]
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-table-permission.js" --projectRoot "<PROJECT_ROOT>" --permissionName "<Permission Name>" --tableName "<table_logical_name>" --webRoleIds "<uuid1,uuid2>" --scope "Account" --accountRelationshipName "<lookup_to_account>" [--read] [--create] [--write] [--delete] [--append] [--appendto]
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-table-permission.js" --projectRoot "<PROJECT_ROOT>" --permissionName "<Permission Name>" --tableName "<table_logical_name>" --webRoleIds "<uuid1,uuid2>" --scope "Self" [--read] [--create] [--write] [--delete] [--append] [--appendto]
For Parent scope (requires parent permission UUID and relationship name):
powershell
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-table-permission.js" --projectRoot "<PROJECT_ROOT>" --permissionName "<Permission Name>" --tableName "<table_logical_name>" --webRoleIds "<uuid1>" --scope "Parent" --parentPermissionId "<parent-uuid>" --parentRelationshipName "<relationship_name>" [--read] [--create] [--write] [--delete] [--append] [--appendto]
Each invocation outputs
{ "id": "<uuid>", "filePath": "<path>" }
. Use the
id
as
--parentPermissionId
for child permissions.
对于计划中的每个表权限。先处理父权限再处理子权限——子权限需要父权限的JSON输出中的UUID。
对于Global/Contact/Account/Self范围:
powershell
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-table-permission.js" --projectRoot "<PROJECT_ROOT>" --permissionName "<Permission Name>" --tableName "<table_logical_name>" --webRoleIds "<uuid1,uuid2>" --scope "Global" [--read] [--create] [--write] [--delete] [--append] [--appendto]
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-table-permission.js" --projectRoot "<PROJECT_ROOT>" --permissionName "<Permission Name>" --tableName "<table_logical_name>" --webRoleIds "<uuid1,uuid2>" --scope "Contact" --contactRelationshipName "<lookup_to_contact>" [--read] [--create] [--write] [--delete] [--append] [--appendto]
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-table-permission.js" --projectRoot "<PROJECT_ROOT>" --permissionName "<Permission Name>" --tableName "<table_logical_name>" --webRoleIds "<uuid1,uuid2>" --scope "Account" --accountRelationshipName "<lookup_to_account>" [--read] [--create] [--write] [--delete] [--append] [--appendto]
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-table-permission.js" --projectRoot "<PROJECT_ROOT>" --permissionName "<Permission Name>" --tableName "<table_logical_name>" --webRoleIds "<uuid1,uuid2>" --scope "Self" [--read] [--create] [--write] [--delete] [--append] [--appendto]
对于Parent范围(需要父权限UUID和关系名称):
powershell
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-table-permission.js" --projectRoot "<PROJECT_ROOT>" --permissionName "<Permission Name>" --tableName "<table_logical_name>" --webRoleIds "<uuid1>" --scope "Parent" --parentPermissionId "<parent-uuid>" --parentRelationshipName "<relationship_name>" [--read] [--create] [--write] [--delete] [--append] [--appendto]
每次调用输出
{ "id": "<uuid>", "filePath": "<path>" }
。将
id
用作子权限的
--parentPermissionId

6.4.3 Create Site Settings

6.4.3 创建站点设置

For each site setting in the plan:
Enabled setting (boolean):
powershell
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-site-setting.js" --projectRoot "<PROJECT_ROOT>" --name "Webapi/<table>/enabled" --value "true" --description "Enable Web API access for <table> table" --type "boolean"
Fields setting (string — use the validated column names from the diagram):
powershell
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-site-setting.js" --projectRoot "<PROJECT_ROOT>" --name "Webapi/<table>/fields" --value "<comma-separated-validated-columns>" --description "Allowed fields for <table> Web API access"
Inner error setting (boolean, optional for debugging):
powershell
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-site-setting.js" --projectRoot "<PROJECT_ROOT>" --name "Webapi/error/innererror" --value "true" --description "Enable detailed error messages for debugging" --type "boolean"
Important: The
--value
for fields settings MUST use exact Dataverse LogicalNames (case-sensitive, all lowercase) for normal CRUD/read scenarios. Using incorrect casing causes 403 Forbidden errors.
Aggregate exception: If the site uses aggregate OData queries (
$apply
,
aggregate
, grouped totals, etc.), set
Webapi/<table>/fields
to
*
. Power Pages rejects some aggregate queries with 403 unless wildcard field access is enabled.
Lookup columns: For every lookup column, include both the LogicalName (
cr87b_categoryid
) AND the OData computed attribute (
_cr87b_categoryid_value
) in the fields value. The Power Pages Web API does a literal match — the LogicalName is needed for write operations, the
_..._value
form is needed for read operations (
$select
,
$filter
). Missing either form causes 403 errors.
对于计划中的每个站点设置:
启用设置(布尔值):
powershell
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-site-setting.js" --projectRoot "<PROJECT_ROOT>" --name "Webapi/<table>/enabled" --value "true" --description "Enable Web API access for <table> table" --type "boolean"
字段设置(字符串——使用图表中已验证的列名称):
powershell
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-site-setting.js" --projectRoot "<PROJECT_ROOT>" --name "Webapi/<table>/fields" --value "<comma-separated-validated-columns>" --description "Allowed fields for <table> Web API access"
内部错误设置(布尔值,调试可选):
powershell
node "${CLAUDE_PLUGIN_ROOT}/scripts/create-site-setting.js" --projectRoot "<PROJECT_ROOT>" --name "Webapi/error/innererror" --value "true" --description "Enable detailed error messages for debugging" --type "boolean"
重要提示:对于常规CRUD/读取场景,字段设置的
--value
必须使用精确的Dataverse LogicalNames(区分大小写,全部小写)。使用不正确的大小写会导致403 Forbidden错误。
聚合例外:如果站点使用聚合OData查询(
$apply
aggregate
、分组总计等),将
Webapi/<table>/fields
设置为
*
。除非启用通配符字段访问,否则Power Pages会拒绝某些聚合查询并返回403。
查找列:对于每个查找列,在字段值中同时包含LogicalName(
cr87b_categoryid
)和OData计算属性(
_cr87b_categoryid_value
。Power Pages Web API会进行字面匹配——LogicalName用于写入操作,
_..._value
形式用于读取操作(
$select
$filter
)。缺少任何一种形式都会导致403错误。

6.5 Git Commit

6.5 Git提交

Stage and commit the permission and settings files:
powershell
git add -A
git commit -m "Add table permissions and Web API site settings for [table names]"
Output: Table permissions and site settings created, verified, and committed

暂存并提交权限和设置文件:
powershell
git add -A
git commit -m "Add table permissions and Web API site settings for [table names]"
输出:表权限和站点设置已创建、验证并提交

Phase 7: Review & Deploy

阶段7:审核与部署

Goal: Present a summary of all work performed and offer deployment
Actions:
目标:展示所有已执行工作的摘要并提供部署选项
操作

7.1 Record Skill Usage

7.1 记录技能使用情况

Reference:
${CLAUDE_PLUGIN_ROOT}/references/skill-tracking-reference.md
Follow the skill tracking instructions in the reference to record this skill's usage. Use
--skillName "IntegrateWebApi"
.
参考:
${CLAUDE_PLUGIN_ROOT}/references/skill-tracking-reference.md
按照参考中的技能跟踪说明记录此技能的使用情况。使用
--skillName "IntegrateWebApi"

7.2 Present Summary

7.2 展示摘要

Present a summary of everything that was done:
StepStatusDetails
API ClientCreated/Existed
src/shared/powerPagesApi.ts
TypesCreated
src/types/product.ts
,
src/types/category.ts
ServicesCreated
src/shared/services/productService.ts
, etc.
HooksCreated
src/shared/hooks/useProducts.ts
, etc.
Components UpdatedX filesMock data replaced with API calls
Table PermissionsCreatedX permission files
Site SettingsCreatedX setting files
展示已完成工作的摘要:
步骤状态详情
API客户端已创建/已存在
src/shared/powerPagesApi.ts
类型已创建
src/types/product.ts
,
src/types/category.ts
服务已创建
src/shared/services/productService.ts
钩子已创建
src/shared/hooks/useProducts.ts
组件已更新X个文件模拟数据已替换为API调用
表权限已创建X个权限文件
站点设置已创建X个设置文件

7.3 Ask to Deploy

7.3 询问是否部署

Use
AskUserQuestion
:
QuestionOptions
The Web API integration and permissions are ready. To make everything live, the site needs to be deployed. Would you like to deploy now?Yes, deploy now (Recommended), No, I'll deploy later
If "Yes, deploy now": Invoke the
/deploy-site
skill to deploy the site.
If "No, I'll deploy later": Acknowledge and remind:
"No problem! Remember to deploy your site using
/deploy-site
when you're ready. The Web API calls will not work until the site is deployed with the new permissions."
使用
AskUserQuestion
问题选项
Web API集成和权限已准备就绪。要使所有内容生效,需要部署站点。您现在要部署吗?是,现在部署(推荐),否,我稍后再部署
若选择“是,现在部署”:调用
/deploy-site
技能部署站点。
若选择“否,我稍后再部署”:确认并提醒:
"没问题!请记住准备好后使用
/deploy-site
部署您的站点。在使用新权限部署站点之前,Web API调用将无法工作。"

7.4 Post-Deploy Notes

7.4 部署后说明

After deployment (or if skipped), remind the user:
  • Test the API: Open the deployed site and verify Web API calls work in the browser's Network tab
  • Check permissions: If any API call returns 403, verify table permissions and site settings are correct. The most common cause of 403 errors is column names in
    Webapi/<table>/fields
    not matching the exact Dataverse LogicalName (case-sensitive — must be all lowercase). If the failing request uses aggregate OData (
    $apply
    ,
    aggregate
    , grouped totals), also verify
    Webapi/<table>/fields
    is set to
    *
    .
  • Disable innererror in production: If
    Webapi/error/innererror
    was enabled for debugging, disable it before going live
  • Web roles: Users must be assigned the appropriate web roles to access protected APIs
Output: Summary presented, deployment completed or deferred, post-deploy guidance provided

部署后(或若跳过部署),提醒用户:
  • 测试API:打开已部署的站点并在浏览器的网络选项卡中验证Web API调用是否正常工作
  • 检查权限:如果任何API调用返回403,验证表权限和站点设置是否正确。403错误最常见的原因是
    Webapi/<table>/fields
    中的列名称与精确的Dataverse LogicalName不匹配(区分大小写——必须全部小写)。如果失败的请求使用聚合OData(
    $apply
    aggregate
    、分组总计),还要验证
    Webapi/<table>/fields
    是否设置为
    *
  • 在生产环境中禁用innererror:如果为调试启用了
    Webapi/error/innererror
    ,上线前请禁用它
  • Web角色:用户必须分配适当的Web角色才能访问受保护的API
输出:已展示摘要,部署已完成或推迟,已提供部署后指导

Important Notes

重要说明

Throughout All Phases

所有阶段通用

  • Use TaskCreate/TaskUpdate to track progress at every phase
  • Ask for user confirmation at key decision points (see list below)
  • First table sequential, then parallel — the first table creates the shared API client; after that, remaining tables can be processed in parallel since each creates independent files
  • Commit at milestones — after integration code and after permission files
  • Verify each integration — confirm expected files exist after each agent invocation
  • 使用TaskCreate/TaskUpdate跟踪每个阶段的进度
  • 在关键决策点请求用户确认(请参阅下面的列表)
  • 第一个表串行,后续表并行——第一个表创建共享API客户端;之后,剩余表可并行处理,因为每个表创建独立文件
  • 在里程碑处提交——集成代码完成后和权限文件完成后
  • 验证每个集成——每个Agent调用后确认预期文件是否存在

Key Decision Points (Wait for User)

关键决策点(等待用户操作)

  1. After Phase 2: Confirm which tables to integrate
  2. After Phase 3: Approve integration plan
  3. At Phase 6.1: Deploy now or skip permissions (if
    .powerpages-site
    missing)
  4. At Phase 6.2: Choose permissions source (upload diagram or let the architects analyze)
  5. At Phase 6.3: Approve table permissions plan and Web API site settings plan (both agents run in parallel for Path B, each presents its own plan for approval)
  6. At Phase 7.2: Deploy now or deploy later
  1. 阶段2后:确认要集成的表
  2. 阶段3后:批准集成计划
  3. 阶段6.1:现在部署或跳过权限设置(若
    .powerpages-site
    缺失)
  4. 阶段6.2:选择权限来源(上传图表或让架构师分析)
  5. 阶段6.3:批准表权限计划和Web API站点设置计划(路径B中两个Agent并行运行,每个都展示自己的计划以获得批准)
  6. 阶段7.2:现在部署或稍后部署

Progress Tracking

进度跟踪

Before starting Phase 1, create a task list with all phases using
TaskCreate
:
Task subjectactiveFormDescription
Verify site existsVerifying site prerequisitesLocate project root, detect framework, check data model and deployment status
Explore integration pointsAnalyzing code for integration pointsUse Explore agent to discover tables, existing services, and compile integration manifest
Review integration planReviewing integration plan with userPresent findings and confirm which tables to integrate
Implement integrationsImplementing Web API integrationsInvoke webapi-integration agent for first table (creates shared client), then remaining tables in parallel, verify output, git commit
Verify integrationsVerifying integrationsValidate all expected files exist, check imports and API references, run project build
Setup permissions and settingsConfiguring permissions and site settingsChoose permissions source (upload diagram or architects), invoke table-permissions-architect and webapi-settings-architect agents in parallel, create YAML files with case-sensitive validated column names, git commit
Review and deployReviewing summary and deployingPresent summary, ask about deployment, provide post-deploy guidance
Mark each task
in_progress
when starting it and
completed
when done via
TaskUpdate
. This gives the user visibility into progress and keeps the workflow deterministic.

Begin with Phase 1: Verify Site Exists
开始阶段1之前,使用
TaskCreate
创建包含所有阶段的任务列表:
任务主题activeForm描述
验证站点存在验证站点前提条件定位项目根目录、检测框架、检查数据模型和部署状态
探索集成点分析代码中的集成点使用Explore Agent发现表、现有服务并编译集成清单
审核集成计划与用户审核集成计划展示发现结果并确认要集成的表
实现集成实现Web API集成为第一个表调用webapi-integration Agent(创建共享客户端),然后并行调用剩余表,验证输出,git提交
验证集成验证集成验证所有预期文件是否存在,检查导入和API引用,运行项目构建
设置权限和设置配置权限和站点设置选择权限来源(上传图表或架构师分析),并行调用table-permissions-architect和webapi-settings-architect Agent,使用区分大小写的已验证列名称创建YAML文件,git提交
审核与部署审核摘要并部署展示摘要,询问部署事宜,提供部署后指导
开始每个任务时将其标记为
in_progress
,完成后通过
TaskUpdate
标记为
completed
。这使用户能了解进度并保持工作流的确定性。

从阶段1:验证站点存在开始