Model and DB refactor (#61)

- [x] Move from `sqlx` to `rusqlite`
- [x] Generate TS types from Rust models
This commit is contained in:
Gregory Schier
2024-08-05 07:58:20 -07:00
committed by GitHub
parent 71013fd701
commit 989b5a8058
193 changed files with 7083 additions and 8337 deletions

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EnvironmentVariable } from "./EnvironmentVariable";
export type Environment = { id: string, workspaceId: string, model: "environment", createdAt: string, updatedAt: string, name: string, variables: Array<EnvironmentVariable>, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type EnvironmentVariable = { enabled?: boolean, name: string, value: string, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type Folder = { createdAt: string, updatedAt: string, id: string, workspaceId: string, folderId: string | null, model: "folder", name: string, sortPriority: number, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type GrpcConnection = { id: string, model: "grpc_connection", workspaceId: string, requestId: string, createdAt: string, updatedAt: string, service: string, method: string, elapsed: number, status: number, url: string, error: string | null, trailers: { [key: string]: string }, };

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { GrpcEventType } from "./GrpcEventType";
export type GrpcEvent = { id: string, model: "grpc_event", workspaceId: string, requestId: string, connectionId: string, createdAt: string, content: string, eventType: GrpcEventType, metadata: { [key: string]: string }, status: number | null, error: string | null, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type GrpcEventType = "info" | "error" | "client_message" | "server_message" | "connection_start" | "connection_end";

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type GrpcMetadataEntry = { enabled?: boolean, name: string, value: string, };

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { GrpcMetadataEntry } from "./GrpcMetadataEntry";
export type GrpcRequest = { id: string, model: "grpc_request", workspaceId: string, createdAt: string, updatedAt: string, folderId: string | null, name: string, sortPriority: number, url: string, service: string | null, method: string | null, message: string, authenticationType: string | null, authentication: Record<string, any>, metadata: Array<GrpcMetadataEntry>, };

View File

@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { HttpRequestHeader } from "./HttpRequestHeader";
import type { HttpUrlParameter } from "./HttpUrlParameter";
export type HttpRequest = { createdAt: string, updatedAt: string, id: string, workspaceId: string, folderId: string | null, model: "http_request", sortPriority: number, name: string, url: string, urlParameters: Array<HttpUrlParameter>, method: string, body: Record<string, any>, bodyType: string | null, authentication: Record<string, any>, authenticationType: string | null, headers: Array<HttpRequestHeader>, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type HttpRequestHeader = { enabled?: boolean, name: string, value: string, };

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { HttpResponseHeader } from "./HttpResponseHeader";
export type HttpResponse = { id: string, model: "http_response", workspaceId: string, requestId: string, createdAt: string, updatedAt: string, error: string | null, url: string, contentLength: number | null, version: string | null, elapsed: number, elapsedHeaders: number, remoteAddr: string | null, status: number, statusReason: string | null, bodyPath: string | null, headers: Array<HttpResponseHeader>, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type HttpResponseHeader = { name: string, value: string, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type HttpUrlParameter = { enabled?: boolean, name: string, value: string, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type KeyValue = { model: "key_value", createdAt: string, updatedAt: string, namespace: string, key: string, value: string, };

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EnvironmentVariable } from "./EnvironmentVariable";
export type Workspace = { id: string, model: "workspace", createdAt: string, updatedAt: string, name: string, description: string, variables: Array<EnvironmentVariable>, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };

View File

@@ -1,3 +1,18 @@
export type * from './models';
export type * from './plugins';
export type * from './themes';
export * from './gen/Environment';
export * from './gen/EnvironmentVariable';
export * from './gen/Folder';
export * from './gen/GrpcConnection';
export * from './gen/GrpcEvent';
export * from './gen/GrpcEventType';
export * from './gen/GrpcMetadataEntry';
export * from './gen/GrpcRequest';
export * from './gen/HttpRequest';
export * from './gen/HttpRequestHeader';
export * from './gen/HttpResponse';
export * from './gen/HttpResponseHeader';
export * from './gen/HttpUrlParameter';
export * from './gen/KeyValue';
export * from './gen/Workspace';

View File

@@ -1 +0,0 @@
export * from './types';

View File

@@ -1,135 +0,0 @@
export interface BaseModel {
readonly model: string;
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
}
export interface Workspace extends BaseModel {
readonly model: 'workspace';
name: string;
description: string;
variables: EnvironmentVariable[];
settingValidateCertificates: boolean;
settingFollowRedirects: boolean;
settingRequestTimeout: number;
}
export interface EnvironmentVariable {
name: string;
value: string;
enabled?: boolean;
}
export interface Folder extends BaseModel {
readonly workspaceId: string;
readonly model: 'folder';
folderId: string | null;
sortPriority: number;
name: string;
}
export interface Environment extends BaseModel {
readonly workspaceId: string;
readonly model: 'environment';
name: string;
variables: EnvironmentVariable[];
}
export interface HttpHeader {
name: string;
value: string;
enabled?: boolean;
}
export interface HttpUrlParameter {
name: string;
value: string;
enabled?: boolean;
}
export interface GrpcMetadataEntry {
name: string;
value: string;
enabled?: boolean;
}
export interface GrpcRequest extends BaseModel {
readonly workspaceId: string;
readonly model: 'grpc_request';
folderId: string | null;
sortPriority: number;
name: string;
url: string;
service: string | null;
method: string | null;
message: string;
authentication: Record<string, string | number | boolean | null | undefined>;
authenticationType: string | null;
metadata: GrpcMetadataEntry[];
}
export interface GrpcEvent extends BaseModel {
readonly workspaceId: string;
readonly requestId: string;
readonly connectionId: string;
readonly model: 'grpc_event';
content: string;
status: number | null;
error: string | null;
eventType:
| 'info'
| 'error'
| 'client_message'
| 'server_message'
| 'connection_start'
| 'connection_end';
metadata: Record<string, string>;
}
export interface GrpcConnection extends BaseModel {
readonly workspaceId: string;
readonly requestId: string;
readonly model: 'grpc_connection';
service: string;
method: string;
elapsed: number;
elapsedConnection: number;
status: number;
url: string;
error: string | null;
trailers: Record<string, string>;
}
export interface HttpRequest extends BaseModel {
readonly workspaceId: string;
readonly model: 'http_request';
folderId: string | null;
sortPriority: number;
name: string;
url: string;
urlParameters: HttpUrlParameter[];
body: Record<string, unknown>;
bodyType: string | null;
authentication: Record<string, string | number | boolean | null | undefined>;
authenticationType: string | null;
method: string;
headers: HttpHeader[];
}
export interface HttpResponse extends BaseModel {
readonly workspaceId: string;
readonly model: 'http_response';
readonly requestId: string;
readonly bodyPath: string | null;
readonly contentLength: number | null;
readonly error: string;
readonly status: number;
readonly elapsed: number;
readonly elapsedHeaders: number;
readonly statusReason: string;
readonly version: string;
readonly remoteAddr: string;
readonly url: string;
readonly headers: HttpHeader[];
}

View File

@@ -1,4 +1,5 @@
import { HttpRequest, HttpResponse } from '../models';
import { HttpRequest } from '../gen/HttpRequest';
import { HttpResponse } from '../gen/HttpResponse';
export type YaakContext = {
metadata: {

View File

@@ -1,4 +1,4 @@
import { HttpRequest } from '../models';
import { HttpRequest } from '../gen/HttpRequest';
import { YaakContext } from './context';
export type HttpRequestActionPlugin = {

View File

@@ -1,5 +1,8 @@
import { Environment } from '../gen/Environment';
import { Folder } from '../gen/Folder';
import { HttpRequest } from '../gen/HttpRequest';
import { Workspace } from '../gen/Workspace';
import { AtLeast } from '../helpers';
import { Environment, Folder, HttpRequest, Workspace } from '../models';
import { YaakContext } from './context';
export type ImportPluginResponse = null | {