0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

feat: connector DB schema (#164)

* chore: add boolean type for postgres

* chore: remove bool

* feat: connector DB

* fix: remove identifier

* chore: genenrate

* chore: remove data

* chore: todo

* chore: test TODO
This commit is contained in:
Wang Sijie 2022-01-10 12:24:22 +08:00 committed by GitHub
parent aafc258ad9
commit bf165644c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,44 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
import { z } from 'zod';
import { ConnectorConfig, connectorConfigGuard, GeneratedSchema, Guard } from '../foundations';
import { ConnectorType } from './custom-types';
export type ConnectorDBEntry = {
id: string;
enabled?: boolean;
type: ConnectorType;
config?: ConnectorConfig;
createdAt?: number;
};
export type Connector = {
id: string;
enabled: boolean;
type: ConnectorType;
config: ConnectorConfig;
createdAt: number;
};
const guard: Guard<ConnectorDBEntry> = z.object({
id: z.string(),
enabled: z.boolean().optional(),
type: z.nativeEnum(ConnectorType),
config: connectorConfigGuard.optional(),
createdAt: z.number().optional(),
});
export const Connectors: GeneratedSchema<ConnectorDBEntry> = Object.freeze({
table: 'connectors',
tableSingular: 'connector',
fields: {
id: 'id',
enabled: 'enabled',
type: 'type',
config: 'config',
createdAt: 'created_at',
},
fieldKeys: ['id', 'enabled', 'type', 'config', 'createdAt'],
guard,
});

View file

@ -5,6 +5,11 @@ export enum ApplicationType {
SPA = 'SPA',
Traditional = 'Traditional',
}
export enum ConnectorType {
SMS = 'SMS',
Email = 'Email',
Social = 'Social',
}
export enum SignAlgorithmType {
RS256 = 'RS256',
}

View file

@ -2,6 +2,7 @@
export * from './custom-types';
export * from './application';
export * from './connector';
export * from './oidc-model-instance';
export * from './resource-scope';
export * from './resource';

View file

@ -31,3 +31,8 @@ export const userLogPayloadGuard = z.object({
});
export type UserLogPayload = z.infer<typeof userLogPayloadGuard>;
// TODO: support empty shape of object
export const connectorConfigGuard = z.object({});
export type ConnectorConfig = z.infer<typeof connectorConfigGuard>;

View file

@ -0,0 +1,10 @@
create type connector_type as enum ('SMS', 'Email', 'Social');
create table connectors (
id varchar(128) not null,
enabled boolean not null default TRUE,
type connector_type not null,
config jsonb /* @use ConnectorConfig */ not null default '{}'::jsonb,
created_at timestamptz not null default(now()),
primary key (id, type)
);