This PR moves the entire project to Typescript. Due to the ~1000 ignores this will lead to a messy codebase for a while, but the churn is worth it – all of those ignore comments are places that were never type-safe previously. closes #1282
42 lines
737 B
TypeScript
42 lines
737 B
TypeScript
import { extendObservable, action } from "mobx";
|
|
import BaseModel from "~/models/BaseModel";
|
|
import { client } from "~/utils/ApiClient";
|
|
|
|
type Settings = {
|
|
url: string;
|
|
channel: string;
|
|
channelId: string;
|
|
};
|
|
type Events = "documents.create" | "collections.create";
|
|
|
|
class Integration extends BaseModel {
|
|
id: string;
|
|
|
|
type: string;
|
|
|
|
service: string;
|
|
|
|
collectionId: string;
|
|
|
|
events: Events;
|
|
|
|
settings: Settings;
|
|
|
|
@action
|
|
update = async (data: Record<string, any>) => {
|
|
await client.post("/integrations.update", {
|
|
id: this.id,
|
|
...data,
|
|
});
|
|
extendObservable(this, data);
|
|
return true;
|
|
};
|
|
|
|
@action
|
|
delete = () => {
|
|
return this.store.delete(this);
|
|
};
|
|
}
|
|
|
|
export default Integration;
|