webpods
Version:
Append-only log service with OAuth authentication
191 lines • 4.11 kB
TypeScript
/**
* Core types for WebPods
*/
export interface DomainError {
code: string;
message: string;
details?: any;
}
export type Result<T, E = DomainError> = {
success: true;
data: T;
} | {
success: false;
error: E;
};
export declare function success<T>(data: T): Result<T>;
export declare function failure(error: DomainError): Result<never>;
export interface User {
id: string;
email?: string | null;
name?: string | null;
avatar_url?: string | null;
created_at: Date;
updated_at: Date;
}
export interface Identity {
id: string;
user_id: string;
provider: string;
provider_id: string;
email: string | null;
name: string | null;
metadata?: any;
created_at: Date;
updated_at: Date;
}
export interface Pod {
id: string;
pod_id: string;
owner_id: string;
metadata?: any;
created_at: Date;
updated_at: Date;
}
export interface Stream {
id: string;
pod_id: string;
stream_id: string;
creator_id: string;
access_permission: string;
metadata?: any;
created_at: Date;
updated_at: Date;
}
export interface StreamRecord {
id: number;
stream_id: string;
index: number;
content: string | any;
content_type: string;
name: string;
hash: string;
previous_hash: string | null;
author_id: string;
metadata?: any;
created_at: Date;
}
export interface CustomDomain {
id: string;
pod_id: string;
domain: string;
ssl_provisioned: boolean;
created_at: Date;
updated_at: Date;
}
export interface RateLimit {
id: string;
key: string;
action: "read" | "write" | "pod_create" | "stream_create";
count: number;
window_start: Date;
window_end: Date;
}
export interface StreamRecordResponse {
index: number;
content: any;
content_type: string;
name: string;
hash: string;
previous_hash: string | null;
author: string;
timestamp: string;
}
export interface StreamListResponse {
records: StreamRecordResponse[];
total: number;
has_more: boolean;
next_index: number | null;
}
export interface PodListResponse {
pod: string;
streams: string[];
}
export interface AuthResponse {
token: string;
user: {
email: string | null;
name: string | null;
provider: string;
};
}
export interface WhoAmIResponse {
user_id: string;
email: string | null;
name: string | null;
provider: string;
}
export interface OAuthProvider {
provider: string;
clientId: string;
clientSecret: string;
authorizationURL?: string;
tokenURL?: string;
userInfoURL?: string;
scope?: string;
}
export type Permission = "public" | "private" | string;
export interface PermissionRecord {
id: string;
read: boolean;
write: boolean;
}
export interface OwnerRecord {
owner: string;
}
export interface LinksRecord {
[path: string]: string;
}
export interface DomainsRecord {
domains: string[];
}
export interface JWTPayload {
user_id: string;
email?: string | null;
name?: string | null;
pod?: string;
iat?: number;
exp?: number;
}
export interface HydraAuth {
user_id: string;
email?: string | null;
name?: string | null;
client_id?: string;
pods?: string[];
scope?: string;
}
export type AuthPayload = JWTPayload | HydraAuth;
import { Request } from "express";
export interface AuthRequest extends Request {
auth?: AuthPayload;
auth_type?: "webpods" | "hydra";
pod?: Pod;
pod_id?: string;
ip_address?: string;
}
export interface CreatePodInput {
pod_id: string;
}
export interface CreateStreamInput {
stream_id: string;
access_permission?: string;
}
export interface WriteRecordInput {
content: any;
content_type?: string;
name: string;
}
export interface ListRecordsQuery {
limit?: number;
after?: number;
index?: string;
}
export interface ErrorResponse {
error: {
code: string;
message: string;
details?: any;
};
}
//# sourceMappingURL=types.d.ts.map