snapshot of https://github.com/toeverything/AFFiNE.git (canary, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 4s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Analyze (javascript, affine) (push) Failing after 3s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-16 00:31:07 +05:00
commit 50f788e799
7907 changed files with 988785 additions and 0 deletions

View File

@@ -0,0 +1,297 @@
[**BlockSuite API Documentation**](../../../README.md)
***
[BlockSuite API Documentation](../../../README.md) / [@blocksuite/store](../README.md) / Schema
# Class: Schema
Represents a schema manager for block flavours and their relationships.
Provides methods to register, validate, and query block schemas.
## Properties
### flavourSchemaMap
> `readonly` **flavourSchemaMap**: `Map`\<`string`, \{ `model`: \{ `children?`: `string`[]; `flavour`: `string`; `isFlatData?`: `boolean`; `parent?`: `string`[]; `props?`: (...`args`) => `Record`\<`string`, `any`\>; `role`: `string`; `toModel?`: (...`args`) => `BlockModel`\<`object`\>; \}; `transformer?`: (...`args`) => `BaseBlockTransformer`\<`object`\>; `version`: `number`; \}\>
A map storing block flavour names to their corresponding schema definitions.
## Accessors
### versions
#### Get Signature
> **get** **versions**(): `object`
Returns an object mapping each registered flavour to its version number.
##### Returns
`object`
## Methods
### get()
> **get**(`flavour`): \{ `model`: \{ `children?`: `string`[]; `flavour`: `string`; `isFlatData?`: `boolean`; `parent?`: `string`[]; `props?`: (...`args`) => `Record`\<`string`, `any`\>; `role`: `string`; `toModel?`: (...`args`) => `BlockModel`\<`object`\>; \}; `transformer?`: (...`args`) => `BaseBlockTransformer`\<`object`\>; `version`: `number`; \} \| `undefined`
Retrieves the schema for a given block flavour.
#### Parameters
##### flavour
`string`
The block flavour name.
#### Returns
\{ `model`: \{ `children?`: `string`[]; `flavour`: `string`; `isFlatData?`: `boolean`; `parent?`: `string`[]; `props?`: (...`args`) => `Record`\<`string`, `any`\>; `role`: `string`; `toModel?`: (...`args`) => `BlockModel`\<`object`\>; \}; `transformer?`: (...`args`) => `BaseBlockTransformer`\<`object`\>; `version`: `number`; \} \| `undefined`
The corresponding BlockSchemaType or undefined if not found.
***
### isValid()
> **isValid**(`child`, `parent`): `boolean`
Checks if the child flavour is valid under the parent flavour.
#### Parameters
##### child
`string`
The child block flavour name.
##### parent
`string`
The parent block flavour name.
#### Returns
`boolean`
True if the relationship is valid, false otherwise.
***
### register()
> **register**(`blockSchema`): `Schema`
Registers an array of block schemas into the schema manager.
#### Parameters
##### blockSchema
`object`[]
An array of block schema definitions to register.
#### Returns
`Schema`
The Schema instance (for chaining).
***
### safeValidate()
> **safeValidate**(`flavour`, `parentFlavour?`, `childFlavours?`): `boolean`
Safely validates the schema relationship for a given flavour, parent, and children.
Returns true if valid, false otherwise (does not throw).
#### Parameters
##### flavour
`string`
The block flavour to validate.
##### parentFlavour?
`string`
The parent block flavour (optional).
##### childFlavours?
`string`[]
The child block flavours (optional).
#### Returns
`boolean`
True if the schema relationship is valid, false otherwise.
***
### toJSON()
> **toJSON**(): `object`
Serializes the schema map to a plain object for JSON output.
#### Returns
`object`
An object mapping each flavour to its role, parent, and children.
***
### validate()
> **validate**(`flavour`, `parentFlavour?`, `childFlavours?`): `void`
Validates the schema relationship for a given flavour, parent, and children.
Throws SchemaValidateError if invalid.
#### Parameters
##### flavour
`string`
The block flavour to validate.
##### parentFlavour?
`string`
The parent block flavour (optional).
##### childFlavours?
`string`[]
The child block flavours (optional).
#### Returns
`void`
#### Throws
If the schema relationship is invalid.
***
### validateSchema()
> **validateSchema**(`child`, `parent`): `void`
Validates the relationship between a child and parent schema.
Throws if the relationship is invalid.
#### Parameters
##### child
The child block schema.
###### model
\{ `children?`: `string`[]; `flavour`: `string`; `isFlatData?`: `boolean`; `parent?`: `string`[]; `props?`: (...`args`) => `Record`\<`string`, `any`\>; `role`: `string`; `toModel?`: (...`args`) => `BlockModel`\<`object`\>; \} = `...`
###### model.children?
`string`[] = `ContentSchema`
###### model.flavour
`string` = `FlavourSchema`
###### model.isFlatData?
`boolean` = `...`
###### model.parent?
`string`[] = `ParentSchema`
###### model.props?
(...`args`) => `Record`\<`string`, `any`\> = `...`
###### model.role
`string` = `RoleSchema`
###### model.toModel?
(...`args`) => `BlockModel`\<`object`\> = `...`
###### transformer?
(...`args`) => `BaseBlockTransformer`\<`object`\> = `...`
###### version
`number` = `...`
##### parent
The parent block schema.
###### model
\{ `children?`: `string`[]; `flavour`: `string`; `isFlatData?`: `boolean`; `parent?`: `string`[]; `props?`: (...`args`) => `Record`\<`string`, `any`\>; `role`: `string`; `toModel?`: (...`args`) => `BlockModel`\<`object`\>; \} = `...`
###### model.children?
`string`[] = `ContentSchema`
###### model.flavour
`string` = `FlavourSchema`
###### model.isFlatData?
`boolean` = `...`
###### model.parent?
`string`[] = `ParentSchema`
###### model.props?
(...`args`) => `Record`\<`string`, `any`\> = `...`
###### model.role
`string` = `RoleSchema`
###### model.toModel?
(...`args`) => `BlockModel`\<`object`\> = `...`
###### transformer?
(...`args`) => `BaseBlockTransformer`\<`object`\> = `...`
###### version
`number` = `...`
#### Returns
`void`
#### Throws
If the relationship is invalid.