@nlabs/reaktor 0.1.0 → 0.1.2
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 +13 -13
- package/src/config.ts +8 -2
- package/src/data/conversations.ts +2 -4
- package/src/data/email.ts +3 -4
- package/src/data/files.ts +2 -2
- package/src/data/images.ts +5 -5
- package/src/data/posts.ts +239 -167
- package/src/data/users.ts +0 -2
- package/src/types/apps.ts +0 -1
- package/src/types/auth.ts +1 -0
- package/src/types/files.ts +0 -2
- package/src/types/groups.ts +0 -1
- package/src/types/images.ts +0 -1
- package/src/types/locations.ts +0 -1
- package/src/types/payments.ts +0 -5
- package/src/types/posts.ts +13 -4
- package/src/types/tags.ts +0 -1
- package/src/utils/auth.ts +35 -2
- package/src/utils/graphql.ts +7 -0
- package/src/utils/index.ts +1 -0
- package/lib/config.d.ts +0 -21
- package/lib/config.js +0 -127
- package/lib/data/conversations.d.ts +0 -6
- package/lib/data/conversations.js +0 -201
- package/lib/data/dynamodb.d.ts +0 -8
- package/lib/data/dynamodb.js +0 -139
- package/lib/data/email.d.ts +0 -7
- package/lib/data/email.js +0 -164
- package/lib/data/files.d.ts +0 -16
- package/lib/data/files.js +0 -407
- package/lib/data/groups.d.ts +0 -13
- package/lib/data/groups.js +0 -354
- package/lib/data/images.d.ts +0 -12
- package/lib/data/images.js +0 -668
- package/lib/data/index.d.ts +0 -19
- package/lib/data/index.js +0 -24
- package/lib/data/ios.d.ts +0 -6
- package/lib/data/ios.js +0 -302
- package/lib/data/locations.d.ts +0 -3
- package/lib/data/locations.js +0 -132
- package/lib/data/messages.d.ts +0 -9
- package/lib/data/messages.js +0 -248
- package/lib/data/notifications.d.ts +0 -5
- package/lib/data/notifications.js +0 -42
- package/lib/data/payments.d.ts +0 -11
- package/lib/data/payments.js +0 -748
- package/lib/data/posts.d.ts +0 -14
- package/lib/data/posts.js +0 -458
- package/lib/data/reactions.d.ts +0 -6
- package/lib/data/reactions.js +0 -218
- package/lib/data/s3.d.ts +0 -6
- package/lib/data/s3.js +0 -103
- package/lib/data/search.d.ts +0 -3
- package/lib/data/search.js +0 -98
- package/lib/data/sms.d.ts +0 -3
- package/lib/data/sms.js +0 -59
- package/lib/data/subscription.d.ts +0 -7
- package/lib/data/subscription.js +0 -284
- package/lib/data/tags.d.ts +0 -14
- package/lib/data/tags.js +0 -304
- package/lib/data/users.d.ts +0 -12
- package/lib/data/users.js +0 -312
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -8
- package/lib/types/apps.d.ts +0 -44
- package/lib/types/apps.js +0 -2
- package/lib/types/arangodb.d.ts +0 -17
- package/lib/types/arangodb.js +0 -2
- package/lib/types/auth.d.ts +0 -9
- package/lib/types/auth.js +0 -2
- package/lib/types/conversations.d.ts +0 -6
- package/lib/types/conversations.js +0 -2
- package/lib/types/email.d.ts +0 -12
- package/lib/types/email.js +0 -2
- package/lib/types/files.d.ts +0 -28
- package/lib/types/files.js +0 -2
- package/lib/types/google.d.ts +0 -27
- package/lib/types/google.js +0 -2
- package/lib/types/groups.d.ts +0 -22
- package/lib/types/groups.js +0 -2
- package/lib/types/images.d.ts +0 -25
- package/lib/types/images.js +0 -2
- package/lib/types/index.d.ts +0 -17
- package/lib/types/index.js +0 -22
- package/lib/types/locations.d.ts +0 -21
- package/lib/types/locations.js +0 -2
- package/lib/types/messages.d.ts +0 -12
- package/lib/types/messages.js +0 -2
- package/lib/types/notifications.d.ts +0 -19
- package/lib/types/notifications.js +0 -2
- package/lib/types/payments.d.ts +0 -119
- package/lib/types/payments.js +0 -2
- package/lib/types/posts.d.ts +0 -20
- package/lib/types/posts.js +0 -2
- package/lib/types/reactions.d.ts +0 -4
- package/lib/types/reactions.js +0 -2
- package/lib/types/tags.d.ts +0 -10
- package/lib/types/tags.js +0 -2
- package/lib/types/users.d.ts +0 -78
- package/lib/types/users.js +0 -2
- package/lib/utils/analytics.d.ts +0 -3
- package/lib/utils/analytics.js +0 -47
- package/lib/utils/arangodb.d.ts +0 -9
- package/lib/utils/arangodb.js +0 -98
- package/lib/utils/auth.d.ts +0 -2
- package/lib/utils/auth.js +0 -43
- package/lib/utils/index.d.ts +0 -5
- package/lib/utils/index.js +0 -10
- package/lib/utils/objects.d.ts +0 -3
- package/lib/utils/objects.js +0 -34
- package/lib/utils/redis.d.ts +0 -1
- package/lib/utils/redis.js +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nlabs/reaktor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Reaktor",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./lib/index.d.js",
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@nlabs/arkhamjs": "^3.11.11",
|
|
37
|
-
"@nlabs/rip-hunter": "^2.0.
|
|
38
|
-
"@nlabs/utils": "^1.2.
|
|
37
|
+
"@nlabs/rip-hunter": "^2.0.1",
|
|
38
|
+
"@nlabs/utils": "^1.2.2",
|
|
39
39
|
"apn": "^2.2.0",
|
|
40
40
|
"arangojs": "^6.0.0",
|
|
41
|
-
"aws-sdk": "^2.
|
|
41
|
+
"aws-sdk": "^2.421.0",
|
|
42
42
|
"gm": "^1.23.1",
|
|
43
43
|
"google-libphonenumber": "^3.0.10",
|
|
44
|
-
"googleapis": "^
|
|
44
|
+
"googleapis": "^38.0.0",
|
|
45
45
|
"graphql": "^14.0.2",
|
|
46
46
|
"graphql-errors": "^2.1.0",
|
|
47
|
-
"graphql-fields": "^2.0.
|
|
47
|
+
"graphql-fields": "^2.0.3",
|
|
48
48
|
"hiredis": "^0.5.0",
|
|
49
49
|
"lodash": "^4.17.4",
|
|
50
|
-
"luxon": "^1.
|
|
50
|
+
"luxon": "^1.11.4",
|
|
51
51
|
"node-yelp": "0.0.3",
|
|
52
52
|
"numeral": "^2.0.6",
|
|
53
53
|
"redis": "^2.8.0",
|
|
54
54
|
"request-promise": "^4.2.2",
|
|
55
|
-
"stripe": "^6.
|
|
55
|
+
"stripe": "^6.26.0",
|
|
56
56
|
"to": "^0.2.9",
|
|
57
|
-
"twilio": "^3.
|
|
57
|
+
"twilio": "^3.29.1",
|
|
58
58
|
"typed-promisify": "^0.4.0",
|
|
59
59
|
"universal-analytics": "^0.4.16",
|
|
60
60
|
"update": "^0.7.4"
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/graphql": "^14.0.1",
|
|
64
64
|
"@types/history": "^4.6.2",
|
|
65
|
-
"@types/jest": "^24.0.
|
|
65
|
+
"@types/jest": "^24.0.11",
|
|
66
66
|
"@types/luxon": "^1.11.0",
|
|
67
|
-
"@types/node": "^11.
|
|
67
|
+
"@types/node": "^11.11.3",
|
|
68
68
|
"@types/twilio": "^0.0.10",
|
|
69
|
-
"eslint": "^5.
|
|
70
|
-
"eslint-config-styleguidejs": "^1.0.
|
|
69
|
+
"eslint": "^5.15.1",
|
|
70
|
+
"eslint-config-styleguidejs": "^1.0.8",
|
|
71
71
|
"graphql-tools": "^4.0.0",
|
|
72
72
|
"source-map-loader": "^0.2.4",
|
|
73
73
|
"typescript": "^3.0.3"
|
package/src/config.ts
CHANGED
|
@@ -26,7 +26,13 @@ export interface EnvConfig {
|
|
|
26
26
|
|
|
27
27
|
const appPackage: any = require('../package.json');
|
|
28
28
|
|
|
29
|
-
const {
|
|
29
|
+
const {
|
|
30
|
+
arangodbDatabase = 'reaktor',
|
|
31
|
+
arangodbPassword,
|
|
32
|
+
arangodbPort = '8529',
|
|
33
|
+
arangodbUrl = 'db.reaktor.io',
|
|
34
|
+
arangodbUsername = 'reaktor'
|
|
35
|
+
} = process.env;
|
|
30
36
|
|
|
31
37
|
export class Config {
|
|
32
38
|
static values: EnvConfig = {
|
|
@@ -37,7 +43,7 @@ export class Config {
|
|
|
37
43
|
version: appPackage.version
|
|
38
44
|
},
|
|
39
45
|
arangodb: {
|
|
40
|
-
apiUrl: `http://${
|
|
46
|
+
apiUrl: `http://${arangodbUrl}:${arangodbPort}`,
|
|
41
47
|
database: arangodbDatabase,
|
|
42
48
|
dump: '/Applications/ArangoDB-CLI.app/Contents/MacOS/arangodump',
|
|
43
49
|
password: arangodbPassword,
|
|
@@ -47,7 +47,7 @@ export const getConversationList = (context: ApiContext, from: number, to: numbe
|
|
|
47
47
|
|
|
48
48
|
export const getDirectConversation = (context: ApiContext, userId: string): Promise<ConversationType> => {
|
|
49
49
|
const action: string = 'getDirect';
|
|
50
|
-
const {
|
|
50
|
+
const {database, userId: sessionId} = context;
|
|
51
51
|
const formatUserId: string = parseId(userId);
|
|
52
52
|
|
|
53
53
|
const aqlQry: AqlQuery = aql`FOR c IN conversations
|
|
@@ -72,7 +72,6 @@ export const getDirectConversation = (context: ApiContext, userId: string): Prom
|
|
|
72
72
|
conversation.users = users.map((user: UserType) => {
|
|
73
73
|
const {_key: userKey, imgId} = user;
|
|
74
74
|
const thumbUrlData: ImageUrlData = {
|
|
75
|
-
appId: sessionApp,
|
|
76
75
|
directory: 'images',
|
|
77
76
|
imgId,
|
|
78
77
|
isThumb: true,
|
|
@@ -98,7 +97,7 @@ export const getDirectConversation = (context: ApiContext, userId: string): Prom
|
|
|
98
97
|
|
|
99
98
|
export const getConversation = (context: ApiContext, convoId: string): Promise<ConversationType> => {
|
|
100
99
|
const action: string = 'getItem';
|
|
101
|
-
const {
|
|
100
|
+
const {database, userId: sessionId} = context;
|
|
102
101
|
const formatConvoId: string = parseId(convoId);
|
|
103
102
|
|
|
104
103
|
const aqlQry: AqlQuery = aql`FOR c IN conversations
|
|
@@ -120,7 +119,6 @@ export const getConversation = (context: ApiContext, convoId: string): Promise<C
|
|
|
120
119
|
conversation.users = conversation.users.map((user: UserType) => {
|
|
121
120
|
const {_key: userKey, imgId} = user;
|
|
122
121
|
const thumbUrlData: ImageUrlData = {
|
|
123
|
-
appId: sessionApp,
|
|
124
122
|
directory: 'images',
|
|
125
123
|
imgId,
|
|
126
124
|
isThumb: true,
|
package/src/data/email.ts
CHANGED
|
@@ -21,8 +21,7 @@ export const appTemplate = (app: AppType, message: string = '', vars = {}): stri
|
|
|
21
21
|
if(!isEmpty(app)) {
|
|
22
22
|
updatedMessage = message.replace(/\[appName\]/g, app.name)
|
|
23
23
|
.replace(/\[appUrl\]/g, app.url)
|
|
24
|
-
.replace(/\[appEmail\]/g, app.email)
|
|
25
|
-
.replace(/\[appId\]/g, app.id);
|
|
24
|
+
.replace(/\[appEmail\]/g, app.email);
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
Object.keys(vars).forEach((key: string) => {
|
|
@@ -53,7 +52,7 @@ export const sendEmail = (params: EmailType): Promise<boolean> => {
|
|
|
53
52
|
const formatTitle: string = appTemplate(app, title);
|
|
54
53
|
const formatText: string = appTemplate(app, text);
|
|
55
54
|
const formatHtml: string = appTemplate(app, html);
|
|
56
|
-
const {_key:
|
|
55
|
+
const {_key: hasCustomEmail, urlFacebook, urlTwitter} = app;
|
|
57
56
|
|
|
58
57
|
const parseTemplate = (body: string) => {
|
|
59
58
|
const templateBody: string = appTemplate(app, body || '');
|
|
@@ -89,7 +88,7 @@ export const sendEmail = (params: EmailType): Promise<boolean> => {
|
|
|
89
88
|
};
|
|
90
89
|
|
|
91
90
|
if(hasCustomEmail) {
|
|
92
|
-
const s3Params: GetObjectRequest = {Bucket: null, Key: `apps
|
|
91
|
+
const s3Params: GetObjectRequest = {Bucket: null, Key: `apps/templates/email.html`};
|
|
93
92
|
promise = s3Get(s3Params).then((results) => parseTemplate(results.Body.toString()));
|
|
94
93
|
} else {
|
|
95
94
|
promise = new Promise((resolve, reject) => {
|
package/src/data/files.ts
CHANGED
|
@@ -25,7 +25,7 @@ request.defaults({encoding: null});
|
|
|
25
25
|
|
|
26
26
|
// Upload file
|
|
27
27
|
export const addFile = (context: ApiContext, item: FileType = {}): Promise<FileType> => {
|
|
28
|
-
const {
|
|
28
|
+
const {database, userId: sessionId, userType} = context;
|
|
29
29
|
const {
|
|
30
30
|
description = '',
|
|
31
31
|
fileType = '',
|
|
@@ -35,7 +35,7 @@ export const addFile = (context: ApiContext, item: FileType = {}): Promise<FileT
|
|
|
35
35
|
} = item;
|
|
36
36
|
|
|
37
37
|
// Id
|
|
38
|
-
const fileId: string = id ? parseId(id) : createHash(`file-${sessionId}
|
|
38
|
+
const fileId: string = id ? parseId(id) : createHash(`file-${sessionId}`);
|
|
39
39
|
|
|
40
40
|
// Name
|
|
41
41
|
const isUrl: boolean = url !== '';
|
package/src/data/images.ts
CHANGED
|
@@ -407,7 +407,7 @@ export const getPathUserImages = (userID: string, photoId: string, type: string,
|
|
|
407
407
|
};
|
|
408
408
|
|
|
409
409
|
export const getUrlImages = (data: ImageUrlData): string => {
|
|
410
|
-
const {
|
|
410
|
+
const {imgId, directory = 'images', imgType = 'profile', isThumb, type, typeId} = data;
|
|
411
411
|
const host: string = Config.get('environment') === 'production'
|
|
412
412
|
? `https://box.${Config.get('app.url')}`
|
|
413
413
|
: `https://s3.amazonaws.com/dev.${Config.get('app.url')}`;
|
|
@@ -417,17 +417,17 @@ export const getUrlImages = (data: ImageUrlData): string => {
|
|
|
417
417
|
switch(type) {
|
|
418
418
|
case 'app':
|
|
419
419
|
// https://box.reaktor.io/myApp/app/images/123.jpg
|
|
420
|
-
return `${host}/${
|
|
420
|
+
return `${host}/${type}/${directory}/${imgId}${suffix}.jpg`;
|
|
421
421
|
case 'users':
|
|
422
422
|
// https://box.reaktor.io/myApp/users/demoUser/images/123.jpg
|
|
423
|
-
return `${host}/${
|
|
423
|
+
return `${host}/${type}/${typeId}/${directory}/${imgId}${suffix}.jpg`;
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
if(imgType === 'profile') {
|
|
427
|
-
return `${host}
|
|
427
|
+
return `${host}/defaults/${type}_bk${suffix}.jpg`;
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
return `${host}
|
|
430
|
+
return `${host}/defaults/${type}_wh${suffix}.jpg`;
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
return '';
|