@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.
Files changed (112) hide show
  1. package/package.json +13 -13
  2. package/src/config.ts +8 -2
  3. package/src/data/conversations.ts +2 -4
  4. package/src/data/email.ts +3 -4
  5. package/src/data/files.ts +2 -2
  6. package/src/data/images.ts +5 -5
  7. package/src/data/posts.ts +239 -167
  8. package/src/data/users.ts +0 -2
  9. package/src/types/apps.ts +0 -1
  10. package/src/types/auth.ts +1 -0
  11. package/src/types/files.ts +0 -2
  12. package/src/types/groups.ts +0 -1
  13. package/src/types/images.ts +0 -1
  14. package/src/types/locations.ts +0 -1
  15. package/src/types/payments.ts +0 -5
  16. package/src/types/posts.ts +13 -4
  17. package/src/types/tags.ts +0 -1
  18. package/src/utils/auth.ts +35 -2
  19. package/src/utils/graphql.ts +7 -0
  20. package/src/utils/index.ts +1 -0
  21. package/lib/config.d.ts +0 -21
  22. package/lib/config.js +0 -127
  23. package/lib/data/conversations.d.ts +0 -6
  24. package/lib/data/conversations.js +0 -201
  25. package/lib/data/dynamodb.d.ts +0 -8
  26. package/lib/data/dynamodb.js +0 -139
  27. package/lib/data/email.d.ts +0 -7
  28. package/lib/data/email.js +0 -164
  29. package/lib/data/files.d.ts +0 -16
  30. package/lib/data/files.js +0 -407
  31. package/lib/data/groups.d.ts +0 -13
  32. package/lib/data/groups.js +0 -354
  33. package/lib/data/images.d.ts +0 -12
  34. package/lib/data/images.js +0 -668
  35. package/lib/data/index.d.ts +0 -19
  36. package/lib/data/index.js +0 -24
  37. package/lib/data/ios.d.ts +0 -6
  38. package/lib/data/ios.js +0 -302
  39. package/lib/data/locations.d.ts +0 -3
  40. package/lib/data/locations.js +0 -132
  41. package/lib/data/messages.d.ts +0 -9
  42. package/lib/data/messages.js +0 -248
  43. package/lib/data/notifications.d.ts +0 -5
  44. package/lib/data/notifications.js +0 -42
  45. package/lib/data/payments.d.ts +0 -11
  46. package/lib/data/payments.js +0 -748
  47. package/lib/data/posts.d.ts +0 -14
  48. package/lib/data/posts.js +0 -458
  49. package/lib/data/reactions.d.ts +0 -6
  50. package/lib/data/reactions.js +0 -218
  51. package/lib/data/s3.d.ts +0 -6
  52. package/lib/data/s3.js +0 -103
  53. package/lib/data/search.d.ts +0 -3
  54. package/lib/data/search.js +0 -98
  55. package/lib/data/sms.d.ts +0 -3
  56. package/lib/data/sms.js +0 -59
  57. package/lib/data/subscription.d.ts +0 -7
  58. package/lib/data/subscription.js +0 -284
  59. package/lib/data/tags.d.ts +0 -14
  60. package/lib/data/tags.js +0 -304
  61. package/lib/data/users.d.ts +0 -12
  62. package/lib/data/users.js +0 -312
  63. package/lib/index.d.ts +0 -3
  64. package/lib/index.js +0 -8
  65. package/lib/types/apps.d.ts +0 -44
  66. package/lib/types/apps.js +0 -2
  67. package/lib/types/arangodb.d.ts +0 -17
  68. package/lib/types/arangodb.js +0 -2
  69. package/lib/types/auth.d.ts +0 -9
  70. package/lib/types/auth.js +0 -2
  71. package/lib/types/conversations.d.ts +0 -6
  72. package/lib/types/conversations.js +0 -2
  73. package/lib/types/email.d.ts +0 -12
  74. package/lib/types/email.js +0 -2
  75. package/lib/types/files.d.ts +0 -28
  76. package/lib/types/files.js +0 -2
  77. package/lib/types/google.d.ts +0 -27
  78. package/lib/types/google.js +0 -2
  79. package/lib/types/groups.d.ts +0 -22
  80. package/lib/types/groups.js +0 -2
  81. package/lib/types/images.d.ts +0 -25
  82. package/lib/types/images.js +0 -2
  83. package/lib/types/index.d.ts +0 -17
  84. package/lib/types/index.js +0 -22
  85. package/lib/types/locations.d.ts +0 -21
  86. package/lib/types/locations.js +0 -2
  87. package/lib/types/messages.d.ts +0 -12
  88. package/lib/types/messages.js +0 -2
  89. package/lib/types/notifications.d.ts +0 -19
  90. package/lib/types/notifications.js +0 -2
  91. package/lib/types/payments.d.ts +0 -119
  92. package/lib/types/payments.js +0 -2
  93. package/lib/types/posts.d.ts +0 -20
  94. package/lib/types/posts.js +0 -2
  95. package/lib/types/reactions.d.ts +0 -4
  96. package/lib/types/reactions.js +0 -2
  97. package/lib/types/tags.d.ts +0 -10
  98. package/lib/types/tags.js +0 -2
  99. package/lib/types/users.d.ts +0 -78
  100. package/lib/types/users.js +0 -2
  101. package/lib/utils/analytics.d.ts +0 -3
  102. package/lib/utils/analytics.js +0 -47
  103. package/lib/utils/arangodb.d.ts +0 -9
  104. package/lib/utils/arangodb.js +0 -98
  105. package/lib/utils/auth.d.ts +0 -2
  106. package/lib/utils/auth.js +0 -43
  107. package/lib/utils/index.d.ts +0 -5
  108. package/lib/utils/index.js +0 -10
  109. package/lib/utils/objects.d.ts +0 -3
  110. package/lib/utils/objects.js +0 -34
  111. package/lib/utils/redis.d.ts +0 -1
  112. 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.0",
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.0",
38
- "@nlabs/utils": "^1.2.0",
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.411.0",
41
+ "aws-sdk": "^2.421.0",
42
42
  "gm": "^1.23.1",
43
43
  "google-libphonenumber": "^3.0.10",
44
- "googleapis": "^37.2.0",
44
+ "googleapis": "^38.0.0",
45
45
  "graphql": "^14.0.2",
46
46
  "graphql-errors": "^2.1.0",
47
- "graphql-fields": "^2.0.1",
47
+ "graphql-fields": "^2.0.3",
48
48
  "hiredis": "^0.5.0",
49
49
  "lodash": "^4.17.4",
50
- "luxon": "^1.3.3",
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.12.1",
55
+ "stripe": "^6.26.0",
56
56
  "to": "^0.2.9",
57
- "twilio": "^3.11.0",
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.9",
65
+ "@types/jest": "^24.0.11",
66
66
  "@types/luxon": "^1.11.0",
67
- "@types/node": "^11.9.4",
67
+ "@types/node": "^11.11.3",
68
68
  "@types/twilio": "^0.0.10",
69
- "eslint": "^5.13.0",
70
- "eslint-config-styleguidejs": "^1.0.3",
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 {arangodbDatabase, arangodbPassword, arangodbPort = '8529', arangodbUrl, arangodbUsername} = process.env;
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://${arangodbUsername}:${arangodbPassword}@${arangodbUrl}:${arangodbPort}`,
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 {appId: sessionApp, database, userId: sessionId} = context;
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 {appId: sessionApp, database, userId: sessionId} = context;
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: appId, hasCustomEmail, urlFacebook, urlTwitter} = app;
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/${appId}/templates/email.html`};
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 {appId: sessionApp, database, userId: sessionId, userType} = context;
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}-${sessionApp}`);
38
+ const fileId: string = id ? parseId(id) : createHash(`file-${sessionId}`);
39
39
 
40
40
  // Name
41
41
  const isUrl: boolean = url !== '';
@@ -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 {appId, imgId, directory = 'images', imgType = 'profile', isThumb, type, typeId} = data;
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}/${appId}/${type}/${directory}/${imgId}${suffix}.jpg`;
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}/${appId}/${type}/${typeId}/${directory}/${imgId}${suffix}.jpg`;
423
+ return `${host}/${type}/${typeId}/${directory}/${imgId}${suffix}.jpg`;
424
424
  }
425
425
 
426
426
  if(imgType === 'profile') {
427
- return `${host}/${appId}/defaults/${type}_bk${suffix}.jpg`;
427
+ return `${host}/defaults/${type}_bk${suffix}.jpg`;
428
428
  }
429
429
 
430
- return `${host}/${appId}/defaults/${type}_wh${suffix}.jpg`;
430
+ return `${host}/defaults/${type}_wh${suffix}.jpg`;
431
431
  }
432
432
 
433
433
  return '';