summaryrefslogtreecommitdiff
path: root/packages/backend/src/models/RegistryItem.ts
blob: 335e8b9eab8826c9c9528ef512b528d6dbbe6226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * SPDX-FileCopyrightText: syuilo and misskey-project
 * SPDX-License-Identifier: AGPL-3.0-only
 */

import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
import { id } from './util/id.js';
import { MiUser } from './User.js';

// TODO: 同じdomain、同じscope、同じkeyのレコードは二つ以上存在しないように制約付けたい
@Entity('registry_item')
export class MiRegistryItem {
	@PrimaryColumn(id())
	public id: string;

	@Column('timestamp with time zone', {
		comment: 'The updated date of the RegistryItem.',
	})
	public updatedAt: Date;

	@Index()
	@Column({
		...id(),
		comment: 'The owner ID.',
	})
	public userId: MiUser['id'];

	@ManyToOne(type => MiUser, {
		onDelete: 'CASCADE',
	})
	@JoinColumn()
	public user: MiUser | null;

	@Column('varchar', {
		length: 1024,
		comment: 'The key of the RegistryItem.',
	})
	public key: string;

	@Column('jsonb', {
		default: {}, nullable: true,
		comment: 'The value of the RegistryItem.',
	})
	public value: any | null;

	@Index()
	@Column('varchar', {
		length: 1024, array: true, default: '{}',
	})
	public scope: string[];

	// サードパーティアプリに開放するときのためのカラム
	@Index()
	@Column('varchar', {
		length: 512, nullable: true,
	})
	public domain: string | null;
}