mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-30 11:13:08 +02:00
RoleCondFormulaValue: property type assertion
This commit is contained in:
parent
93ea327660
commit
e1b4a0438e
4 changed files with 88 additions and 86 deletions
|
@ -8,7 +8,7 @@ import { DI } from '@/di-symbols.js';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import { CacheService } from '@/core/CacheService.js';
|
||||
import type { RoleCondFormulaValue } from '@/models/entities/Role.js';
|
||||
import type { RoleCondFormulaValue } from 'misskey-js/built/schemas/role.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { StreamMessages } from '@/server/api/stream/types.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
|
|
|
@ -1,83 +1,6 @@
|
|||
import { Entity, Column, PrimaryColumn } from 'typeorm';
|
||||
import { id } from '../id.js';
|
||||
|
||||
type CondFormulaValueAnd = {
|
||||
type: 'and';
|
||||
values: RoleCondFormulaValue[];
|
||||
};
|
||||
|
||||
type CondFormulaValueOr = {
|
||||
type: 'or';
|
||||
values: RoleCondFormulaValue[];
|
||||
};
|
||||
|
||||
type CondFormulaValueNot = {
|
||||
type: 'not';
|
||||
value: RoleCondFormulaValue;
|
||||
};
|
||||
|
||||
type CondFormulaValueIsLocal = {
|
||||
type: 'isLocal';
|
||||
};
|
||||
|
||||
type CondFormulaValueIsRemote = {
|
||||
type: 'isRemote';
|
||||
};
|
||||
|
||||
type CondFormulaValueCreatedLessThan = {
|
||||
type: 'createdLessThan';
|
||||
sec: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueCreatedMoreThan = {
|
||||
type: 'createdMoreThan';
|
||||
sec: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueFollowersLessThanOrEq = {
|
||||
type: 'followersLessThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueFollowersMoreThanOrEq = {
|
||||
type: 'followersMoreThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueFollowingLessThanOrEq = {
|
||||
type: 'followingLessThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueFollowingMoreThanOrEq = {
|
||||
type: 'followingMoreThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueNotesLessThanOrEq = {
|
||||
type: 'notesLessThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueNotesMoreThanOrEq = {
|
||||
type: 'notesMoreThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
export type RoleCondFormulaValue =
|
||||
CondFormulaValueAnd |
|
||||
CondFormulaValueOr |
|
||||
CondFormulaValueNot |
|
||||
CondFormulaValueIsLocal |
|
||||
CondFormulaValueIsRemote |
|
||||
CondFormulaValueCreatedLessThan |
|
||||
CondFormulaValueCreatedMoreThan |
|
||||
CondFormulaValueFollowersLessThanOrEq |
|
||||
CondFormulaValueFollowersMoreThanOrEq |
|
||||
CondFormulaValueFollowingLessThanOrEq |
|
||||
CondFormulaValueFollowingMoreThanOrEq |
|
||||
CondFormulaValueNotesLessThanOrEq |
|
||||
CondFormulaValueNotesMoreThanOrEq;
|
||||
import type { RoleCondFormulaValue } from 'misskey-js/built/schemas/role.js';
|
||||
|
||||
@Entity()
|
||||
export class Role {
|
||||
|
|
|
@ -34,9 +34,10 @@ export const packedRoleSchema = {
|
|||
},
|
||||
condFormula: {
|
||||
type: 'object',
|
||||
// 循環参照なので難しい
|
||||
//$ref: 'https://misskey-hub.net/api/schemas/RoleCondFormula',
|
||||
},
|
||||
// 循環参照なので難しい
|
||||
// のでschema-typeのproperty type assertionに頼る
|
||||
} as unknown as RoleCondFormulaValue,
|
||||
isPublic: {
|
||||
type: 'boolean',
|
||||
},
|
||||
|
@ -281,3 +282,81 @@ export const packedRoleCondFormulaSchema = {
|
|||
},
|
||||
}
|
||||
} as const satisfies JSONSchema7Definition;
|
||||
|
||||
type CondFormulaValueAnd = {
|
||||
type: 'and';
|
||||
values: RoleCondFormulaValue[];
|
||||
};
|
||||
|
||||
type CondFormulaValueOr = {
|
||||
type: 'or';
|
||||
values: RoleCondFormulaValue[];
|
||||
};
|
||||
|
||||
type CondFormulaValueNot = {
|
||||
type: 'not';
|
||||
value: RoleCondFormulaValue;
|
||||
};
|
||||
|
||||
type CondFormulaValueIsLocal = {
|
||||
type: 'isLocal';
|
||||
};
|
||||
|
||||
type CondFormulaValueIsRemote = {
|
||||
type: 'isRemote';
|
||||
};
|
||||
|
||||
type CondFormulaValueCreatedLessThan = {
|
||||
type: 'createdLessThan';
|
||||
sec: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueCreatedMoreThan = {
|
||||
type: 'createdMoreThan';
|
||||
sec: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueFollowersLessThanOrEq = {
|
||||
type: 'followersLessThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueFollowersMoreThanOrEq = {
|
||||
type: 'followersMoreThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueFollowingLessThanOrEq = {
|
||||
type: 'followingLessThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueFollowingMoreThanOrEq = {
|
||||
type: 'followingMoreThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueNotesLessThanOrEq = {
|
||||
type: 'notesLessThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
type CondFormulaValueNotesMoreThanOrEq = {
|
||||
type: 'notesMoreThanOrEq';
|
||||
value: number;
|
||||
};
|
||||
|
||||
export type RoleCondFormulaValue =
|
||||
CondFormulaValueAnd |
|
||||
CondFormulaValueOr |
|
||||
CondFormulaValueNot |
|
||||
CondFormulaValueIsLocal |
|
||||
CondFormulaValueIsRemote |
|
||||
CondFormulaValueCreatedLessThan |
|
||||
CondFormulaValueCreatedMoreThan |
|
||||
CondFormulaValueFollowersLessThanOrEq |
|
||||
CondFormulaValueFollowersMoreThanOrEq |
|
||||
CondFormulaValueFollowingLessThanOrEq |
|
||||
CondFormulaValueFollowingMoreThanOrEq |
|
||||
CondFormulaValueNotesLessThanOrEq |
|
||||
CondFormulaValueNotesMoreThanOrEq;
|
||||
|
|
|
@ -630,7 +630,7 @@ importers:
|
|||
version: 29.5.0
|
||||
schema-type:
|
||||
specifier: github:misskey-dev/schema-type
|
||||
version: github.com/misskey-dev/schema-type/04addbe29c488e9e749bb9fe09812407da132e11(typescript@5.0.4)
|
||||
version: github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc(typescript@5.0.4)
|
||||
|
||||
packages/frontend:
|
||||
dependencies:
|
||||
|
@ -1030,7 +1030,7 @@ importers:
|
|||
version: 4.4.0
|
||||
schema-type:
|
||||
specifier: github:misskey-dev/schema-type
|
||||
version: github.com/misskey-dev/schema-type/04addbe29c488e9e749bb9fe09812407da132e11(typescript@5.0.4)
|
||||
version: github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc(typescript@5.0.4)
|
||||
ts-essentials:
|
||||
specifier: ^9.3.2
|
||||
version: 9.3.2(typescript@5.0.4)
|
||||
|
@ -20557,9 +20557,9 @@ packages:
|
|||
version: 0.0.0
|
||||
dev: false
|
||||
|
||||
github.com/misskey-dev/schema-type/04addbe29c488e9e749bb9fe09812407da132e11(typescript@5.0.4):
|
||||
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/04addbe29c488e9e749bb9fe09812407da132e11}
|
||||
id: github.com/misskey-dev/schema-type/04addbe29c488e9e749bb9fe09812407da132e11
|
||||
github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc(typescript@5.0.4):
|
||||
resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/d4ff8d1c43883a0facacc9ec47ec50aa239828bc}
|
||||
id: github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc
|
||||
name: schema-type
|
||||
version: 1.0.0
|
||||
dependencies:
|
||||
|
|
Loading…
Reference in a new issue