mgtypes 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "mgtypes",
3
+ "version": "1.0.0",
4
+ "description": "types for mg development",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/MobGob/mgTypes.git"
12
+ },
13
+ "author": "Evan Perry",
14
+ "license": "ISC",
15
+ "bugs": {
16
+ "url": "https://github.com/MobGob/mgTypes/issues"
17
+ },
18
+ "homepage": "https://github.com/MobGob/mgTypes#readme",
19
+ "dependencies": {
20
+ "@types/geojson": "^7946.0.16"
21
+ }
22
+ }
@@ -0,0 +1,82 @@
1
+ import { Position } from 'geojson';
2
+ import { MapLabel } from './Content';
3
+
4
+ interface Configuration {
5
+ eventSpecs: EventSpecs;
6
+ eventColors: EventColors;
7
+ }
8
+
9
+ export interface EventSpecs {
10
+ EVENT_TAGS: string[];
11
+ PIN_TYPES: { [key: string]: string[] };
12
+ PLAN_TYPES: string[];
13
+ USER_CREATABLE_CONTENT_TYPES: { [key: string]: { [key: string]: any } };
14
+ USER_MAP_FILTER_OPTIONS: { [key: string]: any };
15
+ SERVICE_TYPES: { [key: string]: any };
16
+
17
+ EMERGENCY_TYPES: { [key: string]: any };
18
+
19
+ EVENT_MAP_LABELS: { zoomThresholds: number[]; labels: MapLabel[][] };
20
+
21
+ EVENT_END_DATETIME: string;
22
+
23
+ EVENT_START_DATETIME: string;
24
+ EVENT_LONGITUDE: string;
25
+ EVENT_LATITUDE: string;
26
+ EVENT_DEFAULT_MAP_BOUNDARIES: Position[];
27
+ EVENT_NAME: string;
28
+ APP_ALIAS: string;
29
+ MAP_STYLE_URL: string;
30
+ FEED_HEADER_IMAGE_NAMES: string[];
31
+ }
32
+
33
+ export interface EventColors {
34
+ success: string;
35
+ warning: string;
36
+ warningUnselected: string;
37
+ locationPuck: string;
38
+
39
+ primary: string;
40
+ onPrimary: string;
41
+ primaryContainer: string;
42
+ onPrimaryContainer: string;
43
+ onPrimaryContainerUnselected:string;
44
+ secondary: string;
45
+ onSecondary: string;
46
+ secondaryContainer: string;
47
+ onSecondaryContainer: string;
48
+ tertiary: string;
49
+ onTertiary: string;
50
+ tertiaryContainer: string;
51
+ onTertiaryContainer: string;
52
+ error: string;
53
+ onError: string;
54
+ errorContainer: string;
55
+ onErrorContainer: string;
56
+ background: string;
57
+ onBackground: string;
58
+ surface: string;
59
+ onSurface: string;
60
+ surfaceVariant: string;
61
+ onSurfaceVariant: string;
62
+ outline: string;
63
+ outlineVariant: string;
64
+ shadow: string;
65
+ scrim: string;
66
+ inverseSurface: string;
67
+ inverseOnSurface: string;
68
+ inversePrimary: string;
69
+ elevation: {
70
+ level0: string;
71
+ level1: string;
72
+ level2: string;
73
+ level3: string;
74
+ level4: string;
75
+ level5: string;
76
+ };
77
+ surfaceDisabled: string;
78
+ onSurfaceDisabled: string;
79
+ backdrop: string;
80
+ }
81
+
82
+ export default Configuration;
@@ -0,0 +1,259 @@
1
+ import { Tag } from './Tag';
2
+ import { User, UserPlan, Sender, UserRole } from './User';
3
+ import { Vote } from './Vote';
4
+ import { Emergency } from './Emergency';
5
+ import { Position } from 'geojson';
6
+
7
+ // shared posts will have sharedContentDetails, normal posts won't have sCD. Posts with threads attached have children; thread tracks who added and where a threaded post goes. A plan may have UserPlan details that indicate if user is attending the plan
8
+
9
+ interface AllAppContent {
10
+ feedData: {
11
+ mainContent: { order: number[]; content: { [contentId: string]: Post } };
12
+ sharedContent: { order: number[]; content: { [contentId: string]: Post } };
13
+ friendsContent: { order: number[]; content: { [contentId: string]: Post } };
14
+ userContent: { order: number[]; content: { [contentId: string]: Post } };
15
+ };
16
+ mapData: {
17
+ pins: { [contentId: string]: Post };
18
+ publicPlans: { [contentId: string]: Post };
19
+ userPlans: { [contentId: string]: Post };
20
+ pinAds: { [contentId: string]: Post };
21
+ planAds: { [contentId: string]: Post };
22
+ routes: { [contentId: string]: Post };
23
+ };
24
+ userData: {
25
+ user: User;
26
+ votes: Vote[];
27
+ friends: { [userId: string]: User };
28
+ plans: UserPlan[];
29
+ friendRequests: { [friendRequestId: string]: FriendRequest };
30
+ roles: UserRole[];
31
+ activeRole: string;
32
+ emergencies: Emergency[];
33
+ };
34
+ }
35
+ interface PostWithIndex {
36
+ [contentId: string]: Post;
37
+ }
38
+
39
+ interface Post {
40
+ content: Content;
41
+ contentable: Contentable;
42
+ user: User;
43
+ tags: Tag[];
44
+ sharedContentDetails?: SharedContentDetails;
45
+ userPlan?: UserPlan;
46
+ // children?: Post[];
47
+ // thread?: Thread;
48
+ userVote?: Vote;
49
+ indent?: number;
50
+ parent?: Post;
51
+ }
52
+
53
+ // indicates who embedded a piece of content: used for ThreadModal
54
+ interface Thread {
55
+ id: number;
56
+ parentId: number;
57
+ childId: number;
58
+ threaderId: number;
59
+ createdAt: string;
60
+ updatedAt: string;
61
+ threader: User;
62
+ }
63
+
64
+ interface Content {
65
+ id: number;
66
+ latitude: number | string; // should be a number but is coming back from db as a string for some reason
67
+ longitude: number | string; // same as above
68
+ upvotes: number;
69
+ placement: 'public' | 'private' | 'ad' | 'system';
70
+ contentableType: 'photo' | 'comment' | 'plan' | 'pin' | 'route' | 'embed';
71
+ contentableId: number;
72
+ parentId: null | number;
73
+ progenitorId: null | number;
74
+ createdAt: string;
75
+ updatedAt: string;
76
+ userId: number;
77
+ displayRule: string;
78
+ shareCount: number;
79
+ threadCount: number;
80
+ displayScore: number;
81
+
82
+ fakeUpvotes: number;
83
+ fakeThreadCount: number;
84
+ fakeShareCount: number;
85
+ fakeCreatedAt: string;
86
+ }
87
+
88
+ // Covers all different content types (pin, plan, comment, photo) coming in from server
89
+ interface Contentable {
90
+ id: number;
91
+ primaryText: string;
92
+ secondaryText?: string;
93
+ createdAt: string;
94
+ updatedAt: string;
95
+
96
+ // Pins, plans, routes & photos
97
+ photoURL?: string;
98
+
99
+ // Pins
100
+ pinCategory?: string;
101
+ pinType?: string;
102
+
103
+ // Plans
104
+ planType?: string;
105
+ inviteCount?: number;
106
+ attendingCount?: number;
107
+
108
+ // Plans or Route
109
+ startTime?: string | Date;
110
+ endTime?: string | Date;
111
+
112
+ // Plan or Pin
113
+ address?: string;
114
+ latitude?: number | string; // should be a number but is coming back from db as a string for some reason
115
+ longitude?: number | string; // same as above
116
+ link?: string;
117
+ phoneNumber?: string;
118
+
119
+ // Pins
120
+ pinHours?: PinHour[];
121
+
122
+ // Routes
123
+ routeType?: string;
124
+ color?: string;
125
+ coordinates?: Position[];
126
+
127
+ // Embed
128
+ embeddedContent: Post;
129
+ embeddedContentId: number;
130
+ }
131
+
132
+ interface PinHour {
133
+ id: number;
134
+ openDateTime: string;
135
+ closeDateTime: string;
136
+ createdAt: string;
137
+ updatedAt: string;
138
+ pinId: number;
139
+ }
140
+
141
+ interface SharedContentDetails {
142
+ senders: Sender[];
143
+ sharedContentStatus: {
144
+ id: number;
145
+ isArchived: boolean;
146
+ createdAt: string;
147
+ updatedAt: string;
148
+ contentId: number;
149
+ userId: number;
150
+ };
151
+ }
152
+
153
+ interface FriendRequest {
154
+ id: number;
155
+ status: 'pending' | 'approved' | 'denied' | 'blocked';
156
+ createdAt: string;
157
+ updatedAt: string;
158
+ requesterId: number;
159
+ recipientId: number;
160
+ requester: User;
161
+ recipient: User;
162
+ }
163
+
164
+ // Specific content types - type Contentable above covers all content types coming in from server, but content types below are used for creating/editing content in Create[ContentType].tsx component
165
+ interface Pin {
166
+ id: number | null; // will not have id when creating
167
+ pinCategory?: string;
168
+ pinType?: string;
169
+ photoURL?: string; // only available after post is created (ie, this is not added by the user)
170
+ primaryText: string;
171
+ secondaryText: string;
172
+ latitude?: number | string | null; // should be a number but is coming back from db as a string for some reason
173
+ longitude?: number | string | null; // same as above
174
+ createdAt: string;
175
+ updatedAt: string;
176
+ address: string;
177
+ phoneNumber?: string | null;
178
+ link?: string | null;
179
+ }
180
+
181
+ interface Plan {
182
+ id: number | null; // will not have id when creating
183
+ planType: string;
184
+ primaryText: string;
185
+ secondaryText: string;
186
+ address?: string;
187
+ startTime?: string | Date;
188
+ endTime?: string | Date;
189
+ inviteCount?: number;
190
+ attendingCount?: number;
191
+ link?: string | null;
192
+ phoneNumber?: string | null;
193
+ latitude?: number | string | null;
194
+ longitude?: number | string | null;
195
+ createdAt: string;
196
+ updatedAt: string;
197
+ }
198
+
199
+ interface Comment {
200
+ id: number | null; // will not have id when creating
201
+ primaryText: string;
202
+ createdAt: string;
203
+ updatedAt: string;
204
+ }
205
+
206
+ interface Photo {
207
+ id: number | null; // will not have id when creating
208
+ primaryText: string;
209
+ photoURL?: string; // may not have one (gets returned from Cloudinary after posting)
210
+ createdAt: string;
211
+ updatedAt: string;
212
+ }
213
+
214
+ interface Route {
215
+ routeType: string;
216
+ primaryText: string;
217
+ secondaryText: string;
218
+ photoURL?: string;
219
+ color: string;
220
+ coordinates: Position[];
221
+ startTime: string;
222
+ endTime: string;
223
+ link: string;
224
+ phoneNumber: string;
225
+ }
226
+
227
+ interface MapLabel {
228
+ longitude: number;
229
+ latitude: number;
230
+ icon: string | null;
231
+ iconColor: string | null;
232
+ image: string | null;
233
+ title: string;
234
+ boundingBox: Position[];
235
+ }
236
+
237
+ interface Route {
238
+ id: number;
239
+ name: string;
240
+ routeType: string;
241
+ coordinates: number[][];
242
+ createdAt: string;
243
+ updatedAt: string;
244
+ }
245
+
246
+ export {
247
+ Post,
248
+ FriendRequest,
249
+ Comment,
250
+ Photo,
251
+ Pin,
252
+ Plan,
253
+ PostWithIndex,
254
+ AllAppContent,
255
+ PinHour,
256
+ MapLabel,
257
+ Route,
258
+ Contentable,
259
+ };
@@ -0,0 +1,17 @@
1
+ import { User } from "./User";
2
+
3
+ interface Emergency {
4
+ id?: number;
5
+ createdAt?: string;
6
+ updatedAt?: string;
7
+ longitude: number | string | null;
8
+ latitude: number | string | null;
9
+ status: 'open' | 'closed';
10
+ reporterId?: number | null;
11
+ emergencyType: 'medical' | 'security' | 'fire' | null;
12
+ primaryText: string;
13
+ address: string | null;
14
+ reporter?: User;
15
+ }
16
+
17
+ export { Emergency };
package/types/Tag.ts ADDED
@@ -0,0 +1,19 @@
1
+ interface Tag {
2
+ id: number;
3
+ tag: string;
4
+ createdAt: string;
5
+ updatedAt: string;
6
+ content_tag: ContentTag;
7
+ }
8
+
9
+ interface ContentTag {
10
+ id: number;
11
+ createdAt: string;
12
+ updatedAt: string;
13
+ contentId: number;
14
+ tagId: number;
15
+ }
16
+
17
+ export {
18
+ Tag
19
+ }
package/types/User.ts ADDED
@@ -0,0 +1,52 @@
1
+ import { FriendRequest } from "./Content";
2
+
3
+ interface User {
4
+ id: number | null;
5
+ givenName: string | null;
6
+ familyName: string | null;
7
+ longName: string | null;
8
+ email: string | null;
9
+ phoneNumber: string | number | null; // TODO: currently this datum is a string but could/should change to numbers?
10
+ latitude: number | string | null; // same as Content interface
11
+ longitude: number | string | null; // same
12
+ shareLoc: boolean | null;
13
+ birthdate: string | null;
14
+ createdAt: string | null;
15
+ updatedAt: string | null;
16
+ imageURL: string | null;
17
+ friendRequest?: FriendRequest; // a user's friends have a record of the friendship attached
18
+ activeRole?:string; // indicates whether user is a friend ('user') or responder ('medical', 'security', etc.)
19
+ }
20
+
21
+ interface UserRole {
22
+ id: number | null;
23
+ createdAt: string | null;
24
+ updatedAt: string | null;
25
+ role: 'user' | 'admin' | 'medical' | 'fire' | 'security' | 'advertiser' |'mental-health'|'vendor'; // TODO: make this configurable
26
+ userId: number | null;
27
+ isActiveRole: boolean;
28
+ }
29
+
30
+ interface UserPlan {
31
+ status: 'accepted' | 'denied' | 'pending';
32
+ userId: number;
33
+ contentId: number;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ id: number;
37
+ }
38
+
39
+ interface Sender extends User {
40
+ shareTimeStamp: ShareTimeStamp;
41
+ }
42
+
43
+ interface ShareTimeStamp {
44
+ id: number | null;
45
+ contentId: number;
46
+ senderId: number;
47
+ recipientId: number;
48
+ createdAt: string;
49
+ updatedAt: string;
50
+ }
51
+
52
+ export { User, UserPlan, Sender, UserRole };
package/types/Vote.ts ADDED
@@ -0,0 +1,9 @@
1
+ interface Vote {
2
+ userId: number;
3
+ contentId: number;
4
+ vote: 'up'|'down'|null;
5
+ updatedAt: string;
6
+ createdAt: string;
7
+ }
8
+
9
+ export { Vote }