Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge into one file and update #144

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tripsit_drug_db",
"version": "1.0.2",
"version": "1.1.0",
"description": "TripSit's Drug Database",
"main": "./scripts/index.ts",
"scripts": {
Expand All @@ -26,7 +26,7 @@
"url": "https://github.com/TripSit/drugs/issues"
},
"homepage": "https://github.com/TripSit/drugs#readme",
"types": "types/drugs.d.ts",
"types": "types/tripsit.d.ts",
"devDependencies": {
"ajv": "^8.12.0",
"ajv-formats": "^3.0.1",
Expand Down
13 changes: 6 additions & 7 deletions scripts/combosToDrugs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ The steps to achieve this are:

import fs from 'fs/promises';
import path from 'path';
import { Combo, Drug } from '../types/drugs';
import { ComboData, Combos, Interactions } from '../types/combos';
import { Drug, ComboData, Combos, Interactions } from '../types/tripsit';
import drugsData from '../drugs.json';
import combosData from '../combos.json';
import { log } from 'console';
Expand Down Expand Up @@ -113,7 +112,7 @@ function schemaValidated(): boolean {
log(`Drugs.json is valid!`)
}

const comboSchema: JSONSchemaType<Combo> = JSON.parse(fsSync.readFileSync(
const comboSchema: JSONSchemaType<ComboData> = JSON.parse(fsSync.readFileSync(
path.join(__dirname, '..', 'schemas', 'combos-schema.json'), 'utf8'));

const comboValidate = ajv.compile(comboSchema);
Expand Down Expand Up @@ -223,7 +222,7 @@ async function compareData(): Promise<boolean> {
pretty_name: drugAName.slice(0, 1).toUpperCase() + drugAName.slice(1),
properties: {},
combos: {
[drugBName]: interaction as Combo
[drugBName]: interaction
}
};
dataMatches = false;
Expand All @@ -239,12 +238,12 @@ async function compareData(): Promise<boolean> {

// Need to declare the type for drugACombos
const drugACombos = drugData[drugAName].combos as {
[key: string]: Combo;
[key: string]: ComboData;
};

// If the combo interaction does not exist, create it
if (!drugACombos[drugBName]) {
drugACombos[drugBName] = interaction as Combo;
drugACombos[drugBName] = interaction;
dataMatches = false;
log(`+ ${drugBName} + ${drugAName}`);
}
Expand All @@ -255,7 +254,7 @@ async function compareData(): Promise<boolean> {
log(`combo.json: ${JSON.stringify(interaction)}`);
log(`drugs.json: ${JSON.stringify(drugACombos[drugBName])}`);
// Update the drugBInfo with the new data from interaction
drugACombos[drugBName] = interaction as Combo;
drugACombos[drugBName] = interaction;
dataMatches = false;
}
});
Expand Down
4 changes: 3 additions & 1 deletion scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import drugs from '../drugs.json';
import drugsSchema from '../schemas/drugs-schema.json';
import combos from '../combos.json';
import combosSchema from '../schemas/combos-schema.json';

export { drugs, drugsSchema };
export { drugs, drugsSchema, combos, combosSchema};
7 changes: 0 additions & 7 deletions types/combo_definitions.d.ts

This file was deleted.

85 changes: 0 additions & 85 deletions types/combos.d.ts

This file was deleted.

141 changes: 108 additions & 33 deletions types/drugs.d.ts → types/tripsit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type Drug = {
pweffects?: { [key: string]: string };
dose_note?: string;
sources?: Sources;
combos?: { [key: string]: Combo };
combos?: Interactions;
};

export enum Category {
Expand All @@ -36,15 +36,27 @@ export enum Category {
Tentative = "tentative",
}

export type Dosage = {
common?: string;
light?: string;
strong?: string;
threshold?: string;
heavy?: string;
dangerous?: string;
fatal?: string;
note?: string;
export type Duration = {
_unit: Unit;
value?: string;
insufflated?: string;
oral?: string;
rectal?: string;
vapourized?: string;
smoked?: string;
Oral_ER?: string;
Oral_IR?: string;
Oral_MAOI?: string;
intramuscular?: string;
intravenous?: string;
metabolites?: string;
parent?: string;
oralMAOI?: string;
buccal?: string;
transdermal?: string;
sublingual?: string;
Insufflated_IR?: string;
Insufflated_XR?: string;
};

export type Dose = {
Expand All @@ -69,27 +81,15 @@ export type Dose = {
wet?: Dosage;
};

export type Duration = {
_unit: Unit;
value?: string;
insufflated?: string;
oral?: string;
rectal?: string;
vapourized?: string;
smoked?: string;
Oral_ER?: string;
Oral_IR?: string;
Oral_MAOI?: string;
intramuscular?: string;
intravenous?: string;
metabolites?: string;
parent?: string;
oralMAOI?: string;
buccal?: string;
transdermal?: string;
sublingual?: string;
Insufflated_IR?: string;
Insufflated_XR?: string;
export type Dosage = {
common?: string;
light?: string;
strong?: string;
threshold?: string;
heavy?: string;
dangerous?: string;
fatal?: string;
note?: string;
};

export type Links = {
Expand Down Expand Up @@ -141,25 +141,100 @@ export type Properties = {
potentiators?: string;
};

export type Combo = {
export interface Combos {
"2c-t-x": Interactions;
"2c-x": Interactions;
"5-meo-xxt": Interactions;
alcohol: Interactions;
amphetamines: Interactions;
amt: Interactions;
benzodiazepines: Interactions;
caffeine: Interactions;
cannabis: Interactions;
cocaine: Interactions;
diphenhydramine: Interactions;
dextromethorphan: Interactions;
dmt: Interactions;
dox: Interactions;
"ghb/gbl": Interactions;
ketamine: Interactions;
lithium: Interactions;
lsd: Interactions;
maois: Interactions;
mdma: Interactions;
mephedrone: Interactions;
mescaline: Interactions;
mushrooms: Interactions;
mxe: Interactions;
nbomes: Interactions;
nitrous: Interactions;
opioids: Interactions;
pcp: Interactions;
ssris: Interactions;
tramadol: Interactions;
}

export interface Interactions {
"2c-t-x"?: ComboData;
"2c-x"?: ComboData;
"5-meo-xxt"?: ComboData;
alcohol?: ComboData;
amphetamines?: ComboData;
amt?: ComboData;
benzodiazepines?: ComboData;
caffeine?: ComboData;
cannabis?: ComboData;
cocaine?: ComboData;
diphenhydramine?: ComboData;
dextromethorphan?: ComboData;
dmt?: ComboData;
dox?: ComboData;
"ghb/gbl"?: ComboData;
lithium?: ComboData;
ketamine?: ComboData;
lsd?: ComboData;
maois?: ComboData;
mdma?: ComboData;
mephedrone?: ComboData;
mescaline?: ComboData;
mushrooms?: ComboData;
mxe?: ComboData;
nbomes?: ComboData;
nitrous?: ComboData;
opioids?: ComboData;
pcp?: ComboData;
ssris?: ComboData;
tramadol?: ComboData;
}

export interface ComboData {
note?: string;
sources?: {
author: string;
title: string;
url: string;
}[];
status: Status;
};
}

export enum Status {
Caution = "Caution",
Dangerous = "Dangerous",
LowRiskDecrease = "Low Risk & Decrease",
LowRiskNoSynergy = "Low Risk & No Synergy",
LowRiskSynergy = "Low Risk & Synergy",
Self = "Self",
Unsafe = "Unsafe",
}

export type ComboDefinitions = {
status: Status;
emoji: string;
color: string;
definition: string;
thumbnail: string;
}

export enum Unit {
Hours = "hours",
Minutes = "minutes",
Expand Down
Loading