mirror of
https://github.com/logto-io/logto.git
synced 2025-01-27 21:39:16 -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:
parent
aafc258ad9
commit
bf165644c9
5 changed files with 65 additions and 0 deletions
44
packages/schemas/src/db-entries/connector.ts
Normal file
44
packages/schemas/src/db-entries/connector.ts
Normal 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,
|
||||||
|
});
|
|
@ -5,6 +5,11 @@ export enum ApplicationType {
|
||||||
SPA = 'SPA',
|
SPA = 'SPA',
|
||||||
Traditional = 'Traditional',
|
Traditional = 'Traditional',
|
||||||
}
|
}
|
||||||
|
export enum ConnectorType {
|
||||||
|
SMS = 'SMS',
|
||||||
|
Email = 'Email',
|
||||||
|
Social = 'Social',
|
||||||
|
}
|
||||||
export enum SignAlgorithmType {
|
export enum SignAlgorithmType {
|
||||||
RS256 = 'RS256',
|
RS256 = 'RS256',
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
export * from './custom-types';
|
export * from './custom-types';
|
||||||
export * from './application';
|
export * from './application';
|
||||||
|
export * from './connector';
|
||||||
export * from './oidc-model-instance';
|
export * from './oidc-model-instance';
|
||||||
export * from './resource-scope';
|
export * from './resource-scope';
|
||||||
export * from './resource';
|
export * from './resource';
|
||||||
|
|
|
@ -31,3 +31,8 @@ export const userLogPayloadGuard = z.object({
|
||||||
});
|
});
|
||||||
|
|
||||||
export type UserLogPayload = z.infer<typeof userLogPayloadGuard>;
|
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>;
|
||||||
|
|
10
packages/schemas/tables/connectors.sql
Normal file
10
packages/schemas/tables/connectors.sql
Normal 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)
|
||||||
|
);
|
Loading…
Add table
Reference in a new issue