support other SQLite wrappers, and various hooks needed by grist-static (#516)

This commit is contained in:
Paul Fitzpatrick
2023-05-23 15:17:28 -04:00
committed by GitHub
parent bd474a382f
commit 7be0ee289d
42 changed files with 684 additions and 249 deletions

View File

@@ -13,7 +13,7 @@ export class AclRule extends BaseEntity {
@PrimaryGeneratedColumn()
public id: number;
@Column()
@Column({type: Number})
public permissions: number;
@OneToOne(type => Group, group => group.aclRule)

View File

@@ -5,13 +5,13 @@ import {Organization} from './Organization';
@Entity({name: 'aliases'})
export class Alias extends BaseEntity {
@PrimaryColumn({name: 'org_id'})
@PrimaryColumn({name: 'org_id', type: Number})
public orgId: number;
@PrimaryColumn({name: 'url_id'})
@PrimaryColumn({name: 'url_id', type: String})
public urlId: string;
@Column({name: 'doc_id'})
@Column({name: 'doc_id', type: String})
public docId: string;
@ManyToOne(type => Document)

View File

@@ -34,14 +34,14 @@ export class BillingAccount extends BaseEntity {
@JoinColumn({name: 'product_id'})
public product: Product;
@Column()
@Column({type: Boolean})
public individual: boolean;
// A flag for when all is well with the user's subscription.
// Probably shouldn't use this to drive whether service is provided or not.
// Strip recommends updating an end-of-service datetime every time payment
// is received, adding on a grace period of some days.
@Column({name: 'in_good_standing', default: nativeValues.trueValue})
@Column({name: 'in_good_standing', type: Boolean, default: nativeValues.trueValue})
public inGoodStanding: boolean;
@Column({type: nativeValues.jsonEntityType, nullable: true})

View File

@@ -10,14 +10,14 @@ export class BillingAccountManager extends BaseEntity {
@PrimaryGeneratedColumn()
public id: number;
@Column({name: 'billing_account_id'})
@Column({name: 'billing_account_id', type: Number})
public billingAccountId: number;
@ManyToOne(type => BillingAccount, { onDelete: 'CASCADE' })
@JoinColumn({name: 'billing_account_id'})
public billingAccount: BillingAccount;
@Column({name: 'user_id'})
@Column({name: 'user_id', type: Number})
public userId: number;
@ManyToOne(type => User, { onDelete: 'CASCADE' })

View File

@@ -24,7 +24,7 @@ function isValidUrlId(urlId: string) {
@Entity({name: 'docs'})
export class Document extends Resource {
@PrimaryColumn()
@PrimaryColumn({type: String})
public id: string;
@ManyToOne(type => Workspace)
@@ -35,7 +35,7 @@ export class Document extends Resource {
public aclRules: AclRuleDoc[];
// Indicates whether the doc is pinned to the org it lives in.
@Column({name: 'is_pinned', default: false})
@Column({name: 'is_pinned', type: Boolean, default: false})
public isPinned: boolean;
// Property that may be returned when the doc is fetched to indicate the access the

View File

@@ -9,7 +9,7 @@ export class Group extends BaseEntity {
@PrimaryGeneratedColumn()
public id: number;
@Column()
@Column({type: String})
public name: string;
@ManyToMany(type => User)

View File

@@ -5,18 +5,18 @@ import {User} from "./User";
@Entity({name: 'logins'})
export class Login extends BaseEntity {
@PrimaryColumn()
@PrimaryColumn({type: Number})
public id: number;
// This is the normalized email address we use for equality and indexing.
@Column()
@Column({type: String})
public email: string;
// This is how the user's email address should be displayed.
@Column({name: 'display_email'})
@Column({name: 'display_email', type: String})
public displayEmail: string;
@Column({name: 'user_id'})
@Column({name: 'user_id', type: Number})
public userId: number;
@ManyToOne(type => User)

View File

@@ -29,6 +29,7 @@ export class Organization extends Resource {
public id: number;
@Column({
type: String,
nullable: true
})
public domain: string;
@@ -46,7 +47,7 @@ export class Organization extends Resource {
@OneToMany(type => AclRuleOrg, aclRule => aclRule.organization)
public aclRules: AclRuleOrg[];
@Column({name: 'billing_account_id'})
@Column({name: 'billing_account_id', type: Number})
public billingAccountId: number;
@ManyToOne(type => BillingAccount)

View File

@@ -11,10 +11,10 @@ export class Pref {
// one, but we haven't marked them as so in the DB since the SQL standard frowns
// on nullable primary keys (and Postgres doesn't support them). We could add
// another primary key, but we don't actually need one.
@PrimaryColumn({name: 'user_id'})
@PrimaryColumn({name: 'user_id', type: Number})
public userId: number|null;
@PrimaryColumn({name: 'org_id'})
@PrimaryColumn({name: 'org_id', type: Number})
public orgId: number|null;
@ManyToOne(type => User)

View File

@@ -169,7 +169,7 @@ export class Product extends BaseEntity {
@PrimaryGeneratedColumn()
public id: number;
@Column()
@Column({type: String})
public name: string;
@Column({type: nativeValues.jsonEntityType})

View File

@@ -3,13 +3,13 @@ import {ApiError} from 'app/common/ApiError';
import {CommonProperties} from "app/common/UserAPI";
export class Resource extends BaseEntity {
@Column()
@Column({type: String})
public name: string;
@Column({name: 'created_at', default: () => "CURRENT_TIMESTAMP"})
@Column({name: 'created_at', type: Date, default: () => "CURRENT_TIMESTAMP"})
public createdAt: Date;
@Column({name: 'updated_at', default: () => "CURRENT_TIMESTAMP"})
@Column({name: 'updated_at', type: Date, default: () => "CURRENT_TIMESTAMP"})
public updatedAt: Date;
// a computed column which, when present, means the entity should be filtered out

View File

@@ -3,10 +3,10 @@ import {Document} from "./Document";
@Entity({name: 'secrets'})
export class Secret extends BaseEntity {
@PrimaryColumn()
@PrimaryColumn({type: String})
public id: string; // generally a UUID
@Column({name: 'value'})
@Column({name: 'value', type: String})
public value: string;
@ManyToOne(_type => Document, { onDelete: 'CASCADE' })

View File

@@ -15,7 +15,7 @@ export class User extends BaseEntity {
@PrimaryGeneratedColumn()
public id: number;
@Column()
@Column({type: String})
public name: string;
@Column({name: 'api_key', type: String, nullable: true})
@@ -46,7 +46,7 @@ export class User extends BaseEntity {
})
public groups: Group[];
@Column({name: 'is_first_time_user', default: false})
@Column({name: 'is_first_time_user', type: Boolean, default: false})
public isFirstTimeUser: boolean;
@Column({name: 'options', type: nativeValues.jsonEntityType, nullable: true})