Skip to content

Commit

Permalink
docs: add api translation. (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert-mah authored Jan 7, 2025
1 parent c3951bc commit 14bc62d
Show file tree
Hide file tree
Showing 130 changed files with 3,823 additions and 4,027 deletions.
44 changes: 21 additions & 23 deletions docs/en-US/api/data-source-manager/data-source.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,78 @@
# DataSource (abstract)

`DataSource` 抽象类,用于表示一种类型的数据源,可以是数据库、API等。
The `DataSource` abstract class is used to represent a type of data source, which can be a database, API, etc.

## 成员
## Members

### collectionManager

数据源的 CollectionManager 实例,需实现 [`ICollectionManager`](/api/data-source-manager/i-collection-manager) 接口。
The CollectionManager instance of the data source, which needs to implement the [`ICollectionManager`](/api/data-source-manager/i-collection-manager) interface.

### resourceManager

数据源的 resourceManager 实例,详见:[`resourceManager`](/api/resourcer/resource-manager)
The resourceManager instance of the data source, see: [`resourceManager`](/api/resourcer/resource-manager)

### acl

数据源的 ACL 实例,详见: [`ACL`](/api/acl/acl)
The ACL instance of the data source, see: [`ACL`](/api/acl/acl)

## API

### constructor()

构造函数,创建一个 `DataSource` 实例。
Constructor, creates a `DataSource` instance.

#### 签名
#### Signature

- `constructor(options: DataSourceOptions)`

### init()
### init()

初始化函数,在 `constructor` 之后既被调用。
Initialization function, called immediately after `constructor`.

#### 签名
#### Signature

- `init(options: DataSourceOptions)`


### name

#### 签名
#### Signature

- `get name()`

响应数据源的实例名称
Returns the instance name of the data source.

### middleware()

获得 DataSource 的中间件,用于挂载到 Server 中接收请求。
Gets the middleware of the DataSource, used to mount to the Server to receive requests.

### testConnection()

静态方法,在测试连接操作时调用,可用于参数校验,具体逻辑由子类实现。
Static method, called during the test connection operation, can be used for parameter validation, specific logic is implemented by subclasses.

#### 签名
#### Signature

- `static testConnection(options?: any): Promise<boolean>`

### load()

#### 签名
#### Signature

- `async load(options: any = {})`

数据源的加载操作,逻辑由子类实现。
The loading operation of the data source, logic is implemented by subclasses.

### createCollectionManager()

#### 签名
#### Signature
- `abstract createCollectionManager(options?: any): ICollectionManager`

创建数据源的 CollectionManager 实例,逻辑由子类实现。
Creates a CollectionManager instance for the data source, logic is implemented by subclasses.

### createResourceManager()

创建数据源的 ResourceManager 实例,字类可覆盖实现,默认创建 `@nocobase/resourcer` 中的 `ResourceManager`
Creates a ResourceManager instance for the data source, subclasses can override the implementation, by default creates `ResourceManager` from `@nocobase/resourcer`.

### createACL()

- 创建 DataSource 的 ACL 实例,字类可覆盖实现,默认创建 `@nocobase/acl` 中的 `ACL`

- Creates an ACL instance for the DataSource, subclasses can override the implementation, by default creates `ACL` from `@nocobase/acl`.
59 changes: 28 additions & 31 deletions docs/en-US/api/data-source-manager/i-collection-manager.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,109 @@
# ICollectionManager

`ICollectionManager` 接口,用于管理数据源的 `Collection` 实例。
The `ICollectionManager` interface is used to manage `Collection` instances of data sources.

## API

### registerFieldTypes()

注册 `Collection` 中的字段类型。
Registers the field types in a `Collection`.

#### 签名
#### Signature

- `registerFieldTypes(types: Record<string, any>): void`

### registerFieldInterfaces()

注册 `Collection``Interface`
Registers the `Interface` for a `Collection`.

#### 签名
#### Signature

- `registerFieldInterfaces(interfaces: Record<string, any>): void`

### registerCollectionTemplates()

注册 `Collection Template`
Registers `Collection Templates`.

#### 签名
#### Signature

- `registerCollectionTemplates(templates: Record<string, any>): void`

### registerModels()

注册 `Model`
Registers `Models`.

#### 签名
#### Signature

- `registerModels(models: Record<string, any>): void`

### registerRepositories()

注册 `Repository`
Registers `Repositories`.

#### 签名
#### Signature

- `registerRepositories(repositories: Record<string, any>): void`

### getRegisteredRepository()

获取已注册的仓库实例。
Retrieves an instance of a registered repository.

#### 签名
#### Signature

- `getRegisteredRepository(key: string): IRepository`

### defineCollection()

定义一个 `Collection`
Defines a `Collection`.

#### 签名
#### Signature

- `defineCollection(options: CollectionOptions): ICollection`

### extendCollection()

修改一个已存在的 `Collection` 属性。
Modifies an existing `Collection` property.

#### 签名
#### Signature

- `extendCollection(collectionOptions: CollectionOptions, mergeOptions?: MergeOptions): ICollection`

### hasCollection()

判断 `Collection` 是否存在。

#### 签名
Determines if a `Collection` exists.

#### Signature

- `hasCollection(name: string): boolean`

### getCollection()

获取 `Collection` 实例。
Retrieves an instance of a `Collection`.

#### 签名
#### Signature

- `getCollection(name: string): ICollection`

### getCollections()

获取所有的 `Collection` 实例。
Retrieves all instances of `Collection`.

#### 签名
#### Signature

- `getCollections(): Array<ICollection>`

### getRepository()

获取 `Repository` 实例。
Retrieves an instance of a `Repository`.

#### 签名
#### Signature

- `getRepository(name: string, sourceId?: string | number): IRepository`

### sync()

同步数据源,逻辑由子类实现。

#### 签名

- `sync(): Promise<void>`
Synchronizes the data source, with the logic implemented by subclasses.

#### Signature

- `sync(): Promise<void>`
28 changes: 14 additions & 14 deletions docs/en-US/api/data-source-manager/i-collection.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ICollection

`ICollection` 是数据模型的接口,其中包含了模型的名称、字段、关联等信息。
`ICollection` is an interface for data models, which includes information such as the model's name, fields, associations, etc.

```typescript
export interface ICollection {
Expand All @@ -20,50 +20,50 @@ export interface ICollection {
}
```

## 成员
## Members

### repository

`ICollection` 所属的 `Repository` 实例
The `Repository` instance to which `ICollection` belongs.

## API

### updateOptions()

更新 `Collection` 的属性
Updates the properties of the `Collection`.

#### 签名
#### Signature

- `updateOptions(options: any): void`

### setField()

设置 `Collection` 的字段
Sets a field of the `Collection`.

#### 签名
#### Signature

- `setField(name: string, options: any): IField`

### removeField()

移除 `Collection` 的字段
Removes a field from the `Collection`.

#### 签名
#### Signature

- `removeField(name: string): void`

### getFields()

获取 `Collection` 的所有字段
Retrieves all fields of the `Collection`.

#### 签名
#### Signature

- `getFields(): Array<IField>`

### getField()

根据名称获取 `Collection` 的字段
Retrieves a field of the `Collection` by name.

#### 签名
#### Signature

- `getField(name: string): IField`
- `getField(name: string): IField`
7 changes: 3 additions & 4 deletions docs/en-US/api/data-source-manager/i-field.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IField

`IField` 定义了字段需要实现的接口。
`IField` defines the interface that fields need to implement.

```typescript
export type FieldOptions = {
Expand All @@ -26,9 +26,8 @@ export interface IField {
```


## 属性
## Properties

### options

- **类型**`FieldOptions`

- **Type**: `FieldOptions`
4 changes: 2 additions & 2 deletions docs/en-US/api/data-source-manager/i-model.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IModel

`IModel` 接口定义了模型对象的基本属性和方法。
The `IModel` interface defines the basic properties and methods of a model object.

```typescript
export interface IModel {
Expand All @@ -12,4 +12,4 @@ export interface IModel {

### toJSON()

将模型对象转换为 JSON 格式
Converts the model object to JSON format.
Loading

0 comments on commit 14bc62d

Please sign in to comment.