> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/contributor-zh/jiao-cheng/how-to-create-new-entity-type.md).

# 如何创建新的实体类型

#### 什么时候需要创建一个新实体？

首先，检查现有实体是否可以解决所需的用例，以避免对解决方案进行过度设计。如果 <https://github.com/decentraland/common-schemas/blob/main/src/platform/entity.ts#L13> 中定义的现有实体类型都不能满足需求，那么你可能需要创建一种新的实体类型。

#### 首先回答：

* 这个新实体是 NFT 集合吗？
* 如何验证所有权？
* 它的大小会是多少？
* 将创建多少个实体？

#### 步骤

首先在 <https://github.com/decentraland/adr> 创建一个 ADR，在其中定义 schema 以及开始验证新实体的日期。

**仓库**

**@dcl/schemas**

1. 在枚举中创建新的实体类型：<https://github.com/decentraland/common-schemas/blob/main/src/platform/entity.ts#L19>
2. 在 <https://github.com/decentraland/common-schemas/tree/main/src/platform> 中创建文件夹和文件，生成类型和 JSON schema，例如：<https://github.com/decentraland/common-schemas/blob/main/src/platform/profile/profile.ts#L20>

**@dcl/content-validator**

实现 ADR 中定义的校验，并考虑该 ADR 的日期，代码位于 <https://github.com/decentraland/content-validator/blob/main/src/validations/timestamps.ts。例如：https://github.com/decentraland/content-validator/blob/main/src/validations/items/emotes.ts#L8>

1. 在 <https://github.com/decentraland/content-validator/tree/main/src/validations/access-checker> 中添加检查新实体类型所有权的代码
2. 为新类型实现 validationForType，例如：<https://github.com/decentraland/content-validator/blob/main/src/validations/profile.ts#L112>
3. 在这里你需要在 <https://github.com/decentraland/content-validator/blob/main/src/validations/ADR51.ts> 中定义每个实体的最大大小。

**@dcl/urn-resolver**

1. 如果新实体对应的是一个集合，那么不需要添加任何内容。
2. 如果不是，则为新实体创建一个新的 urn，并在 <https://github.com/decentraland/urn-resolver> 中定义它，同时在 <https://github.com/decentraland/urn-resolver/blob/main/src/resolvers.ts#L23> 添加一个 resolver

**Catalyst：Content Server**

1. 数据库无需更改。
2. 更新上述所有已修改的库。

**Catalyst：Lambdas Server**

1. 更新上述所有已修改的库。
2. 检查是否需要更新 profile sanitization（`/lambdas/profiles` 端点）
3. 检查是否需要更新 erc collections 端点（`/lambdas/collections` 端点）
4. 创建一个端点来展示该实体，例如 `/lambdas/wearables-by-owner`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.decentraland.org/contributor/contributor-zh/jiao-cheng/how-to-create-new-entity-type.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
