enonic-api-reference

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Enonic XP Server-Side API Reference

Enonic XP 服务端API参考

Procedures

操作流程

Step 1: Identify the Target Library
  1. Determine which
    /lib/xp/*
    library the query relates to.
  2. Map the library to the appropriate reference file:
    LibraryReference File
    lib-content
    references/lib-content-reference.md
    lib-node
    references/lib-node-reference.md
    lib-auth
    references/lib-auth-reference.md
    lib-portal
    references/lib-portal-reference.md
    lib-context, lib-event, lib-task
    references/lib-context-reference.md
    lib-io, lib-mail, lib-repo, lib-schema
    references/lib-utilities-reference.md
  3. If the query spans multiple libraries or asks for a usage pattern, read
    references/examples.md
    .
Step 2: Look Up the Function
  1. Read the identified reference file.
  2. Locate the specific function by name.
  3. Extract the following details:
    • Signature: Function name and import path.
    • Parameters: Name, type, required/optional, default value, description.
    • Return type: Type and shape of the returned value.
    • Example: Code snippet demonstrating correct usage.
Step 3: Provide the Answer
  1. Present the function signature with its import statement.
  2. Include the parameter table with types and descriptions.
  3. Include the return type and shape.
  4. Add a usage example. If the reference file includes one, use it. Otherwise, compose a minimal working example consistent with the documented signature.
  5. Note any version requirements (e.g., "Requires XP 7.8.0+").
Step 4: Handle Cross-Library Patterns
  1. If the query involves combining multiple libraries (e.g., "create content as admin"), read
    references/examples.md
    for established patterns.
  2. If a pattern is not documented, compose it by combining individual function signatures from the relevant reference files.
Step 5: Troubleshoot Common Issues
  1. If the query describes an error or unexpected behavior, read
    references/troubleshooting.md
    .
  2. Match the error message or symptom to a known issue.
  3. Provide the documented fix and any version-compatibility notes.
Step 6: Generate Import Blocks
  1. If the user needs a reusable import block, read
    assets/enonic-imports.template.ts
    .
  2. Uncomment only the libraries required for the user's controller.
步骤1:确定目标库
  1. 明确查询涉及的
    /lib/xp/*
    库是哪一个。
  2. 将库映射到对应的参考文件:
    参考文件
    lib-content
    references/lib-content-reference.md
    lib-node
    references/lib-node-reference.md
    lib-auth
    references/lib-auth-reference.md
    lib-portal
    references/lib-portal-reference.md
    lib-context, lib-event, lib-task
    references/lib-context-reference.md
    lib-io, lib-mail, lib-repo, lib-schema
    references/lib-utilities-reference.md
  3. 如果查询涉及多个库或者询问使用模式,请阅读
    references/examples.md
步骤2:查找对应函数
  1. 打开确定好的参考文件。
  2. 通过名称定位到具体函数。
  3. 提取以下详细信息:
    • 签名: 函数名称与导入路径。
    • 参数: 名称、类型、必填/可选、默认值、描述。
    • 返回类型: 返回值的类型与结构。
    • 示例: 演示正确用法的代码片段。
步骤3:给出解答
  1. 展示函数签名及其导入语句。
  2. 附上包含参数类型与描述的参数表格。
  3. 说明返回类型与结构。
  4. 添加使用示例。如果参考文件中有示例直接使用,否则根据文档记录的签名编写一个最小可运行示例。
  5. 标注任何版本要求(例如:"Requires XP 7.8.0+")。
步骤4:处理跨库使用模式
  1. 如果查询涉及多个库的组合使用(例如:"create content as admin"),请阅读
    references/examples.md
    查看已有的成熟模式。
  2. 如果没有对应的模式记录,可以结合相关参考文件中的单个函数签名自行编写。
步骤5:常见问题排查
  1. 如果查询描述了错误或不符合预期的行为,请阅读
    references/troubleshooting.md
  2. 将错误信息或症状匹配到已知问题。
  3. 提供文档记录的修复方案以及所有版本兼容性说明。
步骤6:生成导入块
  1. 如果用户需要可复用的导入块,请阅读
    assets/enonic-imports.template.ts
  2. 仅取消注释用户控制器所需的库对应的行。

Error Handling

错误处理

  • If a function is not found in any reference file, report that it may belong to a community library or a newer XP version not yet documented, and suggest checking https://developer.enonic.com/docs/xp/stable/api.
  • If the query relates to Guillotine/GraphQL, content type schemas, or Enonic CLI, indicate that this skill does not cover those topics.
  • If a version mismatch is suspected, consult the version compatibility table in
    references/troubleshooting.md
    .
  • 如果在任何参考文件中都找不到对应函数,请说明它可能属于社区库或者尚未被文档覆盖的更新XP版本,建议查看https://developer.enonic.com/docs/xp/stable/api。
  • 如果查询涉及Guillotine/GraphQL、内容类型schema或Enonic CLI,请说明本技能不涵盖这些主题。
  • 如果怀疑存在版本不匹配问题,请查阅
    references/troubleshooting.md
    中的版本兼容性表格。