aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-08-17 05:07:38 +0530
committerLibravatar GitHub <noreply@github.com>2021-08-17 05:07:38 +0530
commit0fbee32c27a6efdfe88534303922d189ddbba817 (patch)
tree2b9dddba64ff1519e293c64b3b42b4d9172ec4d3
parentRevert "chore: update outdated node_modules (#1807)" (diff)
downloadferdium-app-0fbee32c27a6efdfe88534303922d189ddbba817.tar.gz
ferdium-app-0fbee32c27a6efdfe88534303922d189ddbba817.tar.zst
ferdium-app-0fbee32c27a6efdfe88534303922d189ddbba817.zip
Typescript conversion (#1805)
-rw-r--r--src/models/News.ts (renamed from src/models/News.js)17
-rw-r--r--src/models/Order.js22
-rw-r--r--src/models/Order.ts33
-rw-r--r--src/models/Recipe.ts (renamed from src/models/Recipe.js)66
-rw-r--r--src/models/RecipePreview.ts (renamed from src/models/RecipePreview.js)12
-rw-r--r--src/models/User.ts (renamed from src/models/User.js)34
6 files changed, 123 insertions, 61 deletions
diff --git a/src/models/News.js b/src/models/News.ts
index acacb97dd..3db812937 100644
--- a/src/models/News.js
+++ b/src/models/News.ts
@@ -1,15 +1,22 @@
1// @flow 1// @flow
2 2
3interface INews {
4 id: string;
5 message: string;
6 type: string;
7 sticky: boolean | undefined;
8}
9
3export default class News { 10export default class News {
4 id = ''; 11 id: string = '';
5 12
6 message = ''; 13 message: string = '';
7 14
8 type = 'primary'; 15 type: string = 'primary';
9 16
10 sticky = false; 17 sticky: boolean = false;
11 18
12 constructor(data) { 19 constructor(data: INews) {
13 if (!data.id) { 20 if (!data.id) {
14 throw Error('News requires Id'); 21 throw Error('News requires Id');
15 } 22 }
diff --git a/src/models/Order.js b/src/models/Order.js
deleted file mode 100644
index f7624c627..000000000
--- a/src/models/Order.js
+++ /dev/null
@@ -1,22 +0,0 @@
1export default class Order {
2 id = '';
3
4 subscriptionId = '';
5
6 name = '';
7
8 invoiceUrl = '';
9
10 price = '';
11
12 date = '';
13
14 constructor(data) {
15 this.id = data.id;
16 this.subscriptionId = data.subscriptionId;
17 this.name = data.name || this.name;
18 this.invoiceUrl = data.invoiceUrl || this.invoiceUrl;
19 this.price = data.price || this.price;
20 this.date = data.date || this.date;
21 }
22}
diff --git a/src/models/Order.ts b/src/models/Order.ts
new file mode 100644
index 000000000..546b813a0
--- /dev/null
+++ b/src/models/Order.ts
@@ -0,0 +1,33 @@
1// TODO: Can this file be deleted?
2
3interface IOrder {
4 id: string;
5 subscriptionId: string;
6 name: string;
7 invoiceUrl: string;
8 price: string;
9 date: string;
10}
11
12export default class Order {
13 id: string = '';
14
15 subscriptionId: string = '';
16
17 name: string = '';
18
19 invoiceUrl: string = '';
20
21 price: string = '';
22
23 date: string = '';
24
25 constructor(data: IOrder) {
26 this.id = data.id;
27 this.subscriptionId = data.subscriptionId;
28 this.name = data.name || this.name;
29 this.invoiceUrl = data.invoiceUrl || this.invoiceUrl;
30 this.price = data.price || this.price;
31 this.date = data.date || this.date;
32 }
33}
diff --git a/src/models/Recipe.js b/src/models/Recipe.ts
index 0d97d4472..33d383983 100644
--- a/src/models/Recipe.js
+++ b/src/models/Recipe.ts
@@ -2,47 +2,71 @@ import semver from 'semver';
2import { pathExistsSync } from 'fs-extra'; 2import { pathExistsSync } from 'fs-extra';
3import { join } from 'path'; 3import { join } from 'path';
4 4
5interface IRecipe {
6 id: string;
7 name: string;
8 version: string;
9 aliases?: string[];
10 path: string;
11 config: {
12 serviceURL?: string;
13 hasDirectMessages?: boolean;
14 hasIndirectMessages?: boolean;
15 hasNotificationSound?: boolean;
16 hasTeamId?: boolean;
17 hasCustomUrl?: boolean;
18 hasHostedOption?: boolean;
19 urlInputPrefix?: string;
20 urlInputSuffix?: string;
21 disablewebsecurity?: boolean;
22 autoHibernate?: boolean;
23 partition?: string;
24 message?: string;
25 };
26}
27
5export default class Recipe { 28export default class Recipe {
6 // Note: Do NOT change these default values. If they change, then the corresponding changes in the recipes needs to be done 29 // Note: Do NOT change these default values. If they change, then the corresponding changes in the recipes needs to be done
7 id = ''; 30 id: string = '';
8 31
9 name = ''; 32 name: string = '';
10 33
11 description = ''; 34 description = '';
12 35
13 version = ''; 36 version: string = '';
14 37
15 aliases = []; 38 aliases: string[] = [];
16 39
17 path = ''; 40 path: string = '';
18 41
19 serviceURL = ''; 42 serviceURL: string = '';
20 43
21 hasDirectMessages = true; 44 hasDirectMessages: boolean = true;
22 45
23 hasIndirectMessages = false; 46 hasIndirectMessages: boolean = false;
24 47
25 hasNotificationSound = false; 48 hasNotificationSound: boolean = false;
26 49
27 hasTeamId = false; 50 hasTeamId: boolean = false;
28 51
29 hasCustomUrl = false; 52 hasCustomUrl: boolean = false;
30 53
31 hasHostedOption = false; 54 hasHostedOption: boolean = false;
32 55
33 urlInputPrefix = ''; 56 urlInputPrefix: string = '';
34 57
35 urlInputSuffix = ''; 58 urlInputSuffix: string = '';
36 59
37 message = ''; 60 message: string = '';
38 61
39 disablewebsecurity = false; 62 disablewebsecurity: boolean = false;
40 63
41 autoHibernate = false; 64 autoHibernate: boolean = false;
42 65
43 partition = ''; 66 partition: string = '';
44 67
45 constructor(data) { 68 // TODO: Need to reconcile which of these are optional/mandatory
69 constructor(data: IRecipe) {
46 if (!data) { 70 if (!data) {
47 throw Error('Recipe config not valid'); 71 throw Error('Recipe config not valid');
48 } 72 }
@@ -88,11 +112,11 @@ export default class Recipe {
88 } 112 }
89 113
90 // TODO: Need to remove this if its not used anywhere 114 // TODO: Need to remove this if its not used anywhere
91 get author() { 115 get author(): string[] {
92 return []; 116 return [];
93 } 117 }
94 118
95 get hasDarkMode() { 119 get hasDarkMode(): boolean {
96 return pathExistsSync(join(this.path, 'darkmode.css')); 120 return pathExistsSync(join(this.path, 'darkmode.css'));
97 } 121 }
98} 122}
diff --git a/src/models/RecipePreview.js b/src/models/RecipePreview.ts
index 6a9ce3080..351ecf765 100644
--- a/src/models/RecipePreview.js
+++ b/src/models/RecipePreview.ts
@@ -1,17 +1,17 @@
1// @flow 1// @flow
2 2
3export default class RecipePreview { 3export default class RecipePreview {
4 id = ''; 4 id: string = '';
5 5
6 name = ''; 6 name: string = '';
7 7
8 icon = ''; 8 icon: string = '';
9 9
10 featured = false; 10 featured: boolean = false;
11 11
12 aliases = []; 12 aliases: string[] = [];
13 13
14 constructor(data) { 14 constructor(data: { id: any; }) {
15 if (!data.id) { 15 if (!data.id) {
16 throw Error('RecipePreview requires Id'); 16 throw Error('RecipePreview requires Id');
17 } 17 }
diff --git a/src/models/User.js b/src/models/User.ts
index d864dde0c..8c6c2b1c9 100644
--- a/src/models/User.js
+++ b/src/models/User.ts
@@ -1,20 +1,40 @@
1import { observable } from 'mobx'; 1import { observable } from 'mobx';
2 2
3interface IUser {
4 id: string | null;
5 email: string | null;
6 firstname: string | null;
7 lastname: string | null;
8 organization: string | null;
9 accountType: string | null;
10 beta: boolean;
11 donor: object;
12 isDonor: boolean;
13 isMiner: boolean;
14 locale: boolean;
15 isSubscriptionOwner: boolean;
16 hasSubscription: boolean;
17 hadSubscription: boolean;
18 team: object;
19}
20
21// TODO: Need to cleanup these fields since we have removed the tiers of the paid plans from Ferdi
3export default class User { 22export default class User {
4 id = null; 23 id: string | null = null;
5 24
6 @observable email = null; 25 @observable email: string | null = null;
7 26
8 @observable firstname = null; 27 @observable firstname: string | null = null;
9 28
10 @observable lastname = null; 29 @observable lastname: string | null = null;
11 30
12 @observable organization = null; 31 @observable organization: string | null = null;
13 32
14 @observable accountType = null; 33 @observable accountType: string | null = null;
15 34
16 @observable emailIsConfirmed = true; 35 @observable emailIsConfirmed = true;
17 36
37 // TODO: Need to delete references to 'subscription' and 'donor'
18 // better assume it's confirmed to avoid noise 38 // better assume it's confirmed to avoid noise
19 @observable subscription = {}; 39 @observable subscription = {};
20 40
@@ -36,7 +56,7 @@ export default class User {
36 56
37 @observable team = {}; 57 @observable team = {};
38 58
39 constructor(data) { 59 constructor(data: IUser) {
40 if (!data.id) { 60 if (!data.id) {
41 throw Error('User requires Id'); 61 throw Error('User requires Id');
42 } 62 }