Environments data model

This commit is contained in:
Gregory Schier
2023-10-22 18:28:56 -07:00
parent afe6a3bf57
commit 8328d20150
26 changed files with 132 additions and 1179 deletions

View File

@@ -1,3 +1,15 @@
export const BODY_TYPE_NONE = null;
export const BODY_TYPE_GRAPHQL = 'graphql';
export const BODY_TYPE_JSON = 'application/json';
export const BODY_TYPE_XML = 'text/xml';
export const AUTH_TYPE_NONE = null;
export const AUTH_TYPE_BASIC = 'basic';
export const AUTH_TYPE_BEARER = 'bearer';
export type Model = Workspace | HttpRequest | HttpResponse | KeyValue | Environment;
export interface BaseModel {
readonly id: string;
readonly createdAt: string;
@@ -16,25 +28,11 @@ export interface HttpHeader {
enabled?: boolean;
}
export const BODY_TYPE_NONE = null;
export const BODY_TYPE_GRAPHQL = 'graphql';
export const BODY_TYPE_JSON = 'application/json';
export const BODY_TYPE_XML = 'text/xml';
export const AUTH_TYPE_NONE = null;
export const AUTH_TYPE_BASIC = 'basic';
export const AUTH_TYPE_BEARER = 'bearer';
export type Model = Workspace | HttpRequest | HttpResponse | KeyValue;
export function modelsEq(a: Model, b: Model) {
if (a.model === 'key_value' && b.model === 'key_value') {
return a.key === b.key && a.namespace === b.namespace;
}
if ('id' in a && 'id' in b) {
return a.id === b.id;
}
return false;
export interface Environment extends BaseModel {
readonly workspaceId: string;
readonly model: 'environment';
name: string;
data: Record<string, string | number | boolean | null | undefined>;
}
export interface HttpRequest extends BaseModel {
@@ -78,3 +76,13 @@ export interface HttpResponse extends BaseModel {
export function isResponseLoading(response: HttpResponse): boolean {
return !(response.body || response.status || response.error);
}
export function modelsEq(a: Model, b: Model) {
if (a.model === 'key_value' && b.model === 'key_value') {
return a.key === b.key && a.namespace === b.namespace;
}
if ('id' in a && 'id' in b) {
return a.id === b.id;
}
return false;
}