@nlabs/reaktor 0.1.2 → 0.1.4
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/.DS_Store +0 -0
- package/.eslintrc +18 -0
- package/lib/config.d.ts +21 -0
- package/lib/config.js +130 -0
- package/lib/data/conversations.d.ts +6 -0
- package/lib/data/conversations.js +197 -0
- package/lib/data/dynamodb.d.ts +8 -0
- package/lib/data/dynamodb.js +139 -0
- package/lib/data/email.d.ts +7 -0
- package/lib/data/email.js +163 -0
- package/lib/data/files.d.ts +16 -0
- package/lib/data/files.js +406 -0
- package/lib/data/groups.d.ts +13 -0
- package/lib/data/groups.js +354 -0
- package/lib/data/images.d.ts +12 -0
- package/lib/data/images.js +667 -0
- package/{src/data/index.ts → lib/data/index.d.ts} +1 -5
- package/lib/data/index.js +24 -0
- package/lib/data/ios.d.ts +6 -0
- package/lib/data/ios.js +302 -0
- package/lib/data/locations.d.ts +3 -0
- package/lib/data/locations.js +132 -0
- package/lib/data/messages.d.ts +9 -0
- package/lib/data/messages.js +248 -0
- package/lib/data/notifications.d.ts +5 -0
- package/lib/data/notifications.js +42 -0
- package/lib/data/payments.d.ts +11 -0
- package/lib/data/payments.js +748 -0
- package/lib/data/posts.d.ts +22 -0
- package/lib/data/posts.js +579 -0
- package/lib/data/reactions.d.ts +6 -0
- package/lib/data/reactions.js +218 -0
- package/lib/data/s3.d.ts +6 -0
- package/lib/data/s3.js +103 -0
- package/lib/data/search.d.ts +3 -0
- package/lib/data/search.js +98 -0
- package/lib/data/sms.d.ts +3 -0
- package/lib/data/sms.js +59 -0
- package/lib/data/subscription.d.ts +7 -0
- package/lib/data/subscription.js +284 -0
- package/lib/data/tags.d.ts +14 -0
- package/lib/data/tags.js +304 -0
- package/lib/data/users.d.ts +12 -0
- package/lib/data/users.js +310 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +8 -0
- package/lib/types/apps.d.ts +43 -0
- package/lib/types/apps.js +2 -0
- package/lib/types/arangodb.d.ts +17 -0
- package/lib/types/arangodb.js +2 -0
- package/lib/types/auth.d.ts +10 -0
- package/lib/types/auth.js +2 -0
- package/lib/types/conversations.d.ts +6 -0
- package/lib/types/conversations.js +2 -0
- package/lib/types/email.d.ts +12 -0
- package/lib/types/email.js +2 -0
- package/lib/types/files.d.ts +26 -0
- package/lib/types/files.js +2 -0
- package/lib/types/google.d.ts +27 -0
- package/lib/types/google.js +2 -0
- package/lib/types/groups.d.ts +21 -0
- package/lib/types/groups.js +2 -0
- package/lib/types/images.d.ts +24 -0
- package/lib/types/images.js +2 -0
- package/{src/types/index.ts → lib/types/index.d.ts} +0 -4
- package/lib/types/index.js +22 -0
- package/lib/types/locations.d.ts +20 -0
- package/lib/types/locations.js +2 -0
- package/lib/types/messages.d.ts +12 -0
- package/lib/types/messages.js +2 -0
- package/lib/types/notifications.d.ts +19 -0
- package/lib/types/notifications.js +2 -0
- package/lib/types/payments.d.ts +114 -0
- package/lib/types/payments.js +2 -0
- package/lib/types/posts.d.ts +28 -0
- package/lib/types/posts.js +2 -0
- package/lib/types/reactions.d.ts +4 -0
- package/lib/types/reactions.js +2 -0
- package/lib/types/tags.d.ts +9 -0
- package/lib/types/tags.js +2 -0
- package/lib/types/users.d.ts +78 -0
- package/lib/types/users.js +2 -0
- package/lib/utils/analytics.d.ts +3 -0
- package/lib/utils/analytics.js +47 -0
- package/lib/utils/arangodb.d.ts +9 -0
- package/lib/utils/arangodb.js +98 -0
- package/lib/utils/auth.d.ts +7 -0
- package/lib/utils/auth.js +80 -0
- package/lib/utils/graphql.d.ts +1 -0
- package/lib/utils/graphql.js +7 -0
- package/{src/utils/index.ts → lib/utils/index.d.ts} +0 -4
- package/lib/utils/index.js +11 -0
- package/lib/utils/objects.d.ts +3 -0
- package/lib/utils/objects.js +34 -0
- package/lib/utils/redis.d.ts +1 -0
- package/lib/utils/redis.js +15 -0
- package/package.json +8 -7
- package/.vscode/extensions.json +0 -15
- package/.vscode/settings.json +0 -82
- package/lex.config.js +0 -4
- package/src/config.ts +0 -127
- package/src/data/conversations.ts +0 -181
- package/src/data/dynamodb.ts +0 -157
- package/src/data/email.ts +0 -163
- package/src/data/files.ts +0 -352
- package/src/data/groups.ts +0 -308
- package/src/data/images.ts +0 -606
- package/src/data/ios.ts +0 -249
- package/src/data/locations.ts +0 -114
- package/src/data/messages.ts +0 -237
- package/src/data/notifications.ts +0 -48
- package/src/data/payments.ts +0 -675
- package/src/data/posts.ts +0 -580
- package/src/data/reactions.ts +0 -186
- package/src/data/s3.ts +0 -117
- package/src/data/search.ts +0 -74
- package/src/data/sms.ts +0 -60
- package/src/data/subscription.ts +0 -228
- package/src/data/tags.ts +0 -230
- package/src/data/users.ts +0 -254
- package/src/index.ts +0 -7
- package/src/types/apps.ts +0 -56
- package/src/types/arangodb.ts +0 -23
- package/src/types/auth.ts +0 -20
- package/src/types/conversations.ts +0 -11
- package/src/types/email.ts +0 -17
- package/src/types/files.ts +0 -31
- package/src/types/google.ts +0 -37
- package/src/types/groups.ts +0 -27
- package/src/types/images.ts +0 -32
- package/src/types/locations.ts +0 -24
- package/src/types/messages.ts +0 -16
- package/src/types/notifications.ts +0 -26
- package/src/types/payments.ts +0 -129
- package/src/types/posts.ts +0 -34
- package/src/types/reactions.ts +0 -8
- package/src/types/tags.ts +0 -13
- package/src/types/users.ts +0 -89
- package/src/utils/analytics.ts +0 -41
- package/src/utils/arangodb.ts +0 -100
- package/src/utils/auth.ts +0 -61
- package/src/utils/graphql.ts +0 -7
- package/src/utils/objects.ts +0 -34
- package/src/utils/redis.ts +0 -17
- package/tsconfig.json +0 -45
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2019-Present, Nitrogen Labs, Inc.
|
|
3
|
+
* Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.
|
|
4
|
+
*/
|
|
5
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
6
|
+
import isPlainObject from 'lodash/isPlainObject';
|
|
7
|
+
import mapValues from 'lodash/mapValues';
|
|
8
|
+
export var defaultObject = function defaultObject(item) {
|
|
9
|
+
return item || {};
|
|
10
|
+
};
|
|
11
|
+
export var lowerCaseKeys = function lowerCaseKeys() {
|
|
12
|
+
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
13
|
+
var newObj = cloneDeep(obj);
|
|
14
|
+
mapValues(obj, function (value) {
|
|
15
|
+
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
16
|
+
var updatedValue;
|
|
17
|
+
|
|
18
|
+
if (isPlainObject(value)) {
|
|
19
|
+
updatedValue = lowerCaseKeys(value);
|
|
20
|
+
} else {
|
|
21
|
+
updatedValue = value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
newObj[key.toLowerCase()] = updatedValue;
|
|
25
|
+
});
|
|
26
|
+
return newObj;
|
|
27
|
+
};
|
|
28
|
+
export var toQueryString = function toQueryString() {
|
|
29
|
+
var json = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
30
|
+
return Object.keys(json).map(function (key) {
|
|
31
|
+
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(json[key]));
|
|
32
|
+
}).join('&');
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9vYmplY3RzLnRzIl0sIm5hbWVzIjpbImNsb25lRGVlcCIsImlzUGxhaW5PYmplY3QiLCJtYXBWYWx1ZXMiLCJkZWZhdWx0T2JqZWN0IiwiaXRlbSIsImxvd2VyQ2FzZUtleXMiLCJvYmoiLCJuZXdPYmoiLCJ2YWx1ZSIsImtleSIsInVwZGF0ZWRWYWx1ZSIsInRvTG93ZXJDYXNlIiwidG9RdWVyeVN0cmluZyIsImpzb24iLCJPYmplY3QiLCJrZXlzIiwibWFwIiwiZW5jb2RlVVJJQ29tcG9uZW50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hbHVlID0gdmFsdWU7XG4gICAgfVxuXG4gICAgbmV3T2JqW2tleS50b0xvd2VyQ2FzZSgpXSA9IHVwZGF0ZWRWYWx1ZTtcbiAgfSk7XG5cbiAgcmV0dXJuIG5ld09iajtcbn07XG5cbmV4cG9ydCBjb25zdCB0b1F1ZXJ5U3RyaW5nID0gKGpzb246IGFueSA9IHt9KTogc3RyaW5nID0+IHtcbiAgcmV0dXJuIE9iamVjdFxuICAgIC5rZXlzKGpzb24pXG4gICAgLm1hcCgoa2V5OiBzdHJpbmcpID0+IGAke2VuY29kZVVSSUNvbXBvbmVudChrZXkpfT0ke2VuY29kZVVSSUNvbXBvbmVudChqc29uW2tleV0pfWApXG4gICAgLmpvaW4oJyYnKTtcbn07XG4iXX0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const redisClient: any;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2019-Present, Nitrogen Labs, Inc.
|
|
3
|
+
* Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.
|
|
4
|
+
*/
|
|
5
|
+
import * as redis from 'redis';
|
|
6
|
+
import * as tp from 'typed-promisify';
|
|
7
|
+
import { Config } from '../config'; // Promisify redis module
|
|
8
|
+
|
|
9
|
+
tp.promisify(redis.RedisClient.prototype);
|
|
10
|
+
export var redisClient = redis.createClient({
|
|
11
|
+
host: Config.get('redis.host'),
|
|
12
|
+
port: Config.get('redis.port'),
|
|
13
|
+
string_numbers: false
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9yZWRpcy50cyJdLCJuYW1lcyI6WyJyZWRpcyIsInRwIiwiQ29uZmlnIiwicHJvbWlzaWZ5IiwiUmVkaXNDbGllbnQiLCJwcm90b3R5cGUiLCJyZWRpc0NsaWVudCIsImNyZWF0ZUNsaWVudCIsImhvc3Qi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QgPSByZWRpcy5jcmVhdGVDbGllbnQoe1xuICBob3N0OiBDb25maWcuZ2V0KCdyZWRpcy5ob3N0JyksXG4gIHBvcnQ6IENvbmZpZy5nZXQoJ3JlZGlzLnBvcnQnKSxcbiAgc3RyaW5nX251bWJlcnM6IGZhbHNlXG59KTtcbiJdfQ==
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nlabs/reaktor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Reaktor",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./lib/index.d.js",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"build": "lex compile -r",
|
|
29
29
|
"clean": "lex clean",
|
|
30
30
|
"lint": "eslint ./src --ext .ts,.tsx",
|
|
31
|
+
"prepublishOnly": "npm run build",
|
|
31
32
|
"pretest": "stage=test npm run lint",
|
|
32
33
|
"test": "stage=test jest",
|
|
33
34
|
"update": "lex update -i"
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"@nlabs/utils": "^1.2.2",
|
|
39
40
|
"apn": "^2.2.0",
|
|
40
41
|
"arangojs": "^6.0.0",
|
|
41
|
-
"aws-sdk": "^2.
|
|
42
|
+
"aws-sdk": "^2.424.0",
|
|
42
43
|
"gm": "^1.23.1",
|
|
43
44
|
"google-libphonenumber": "^3.0.10",
|
|
44
45
|
"googleapis": "^38.0.0",
|
|
@@ -52,9 +53,9 @@
|
|
|
52
53
|
"numeral": "^2.0.6",
|
|
53
54
|
"redis": "^2.8.0",
|
|
54
55
|
"request-promise": "^4.2.2",
|
|
55
|
-
"stripe": "^6.
|
|
56
|
+
"stripe": "^6.28.0",
|
|
56
57
|
"to": "^0.2.9",
|
|
57
|
-
"twilio": "^3.29.
|
|
58
|
+
"twilio": "^3.29.2",
|
|
58
59
|
"typed-promisify": "^0.4.0",
|
|
59
60
|
"universal-analytics": "^0.4.16",
|
|
60
61
|
"update": "^0.7.4"
|
|
@@ -64,12 +65,12 @@
|
|
|
64
65
|
"@types/history": "^4.6.2",
|
|
65
66
|
"@types/jest": "^24.0.11",
|
|
66
67
|
"@types/luxon": "^1.11.0",
|
|
67
|
-
"@types/node": "^11.11.
|
|
68
|
+
"@types/node": "^11.11.4",
|
|
68
69
|
"@types/twilio": "^0.0.10",
|
|
69
|
-
"eslint": "^5.15.
|
|
70
|
+
"eslint": "^5.15.3",
|
|
70
71
|
"eslint-config-styleguidejs": "^1.0.8",
|
|
71
72
|
"graphql-tools": "^4.0.0",
|
|
72
73
|
"source-map-loader": "^0.2.4",
|
|
73
|
-
"typescript": "^3.
|
|
74
|
+
"typescript": "^3.3.4000"
|
|
74
75
|
}
|
|
75
76
|
}
|
package/.vscode/extensions.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"recommendations": [
|
|
3
|
-
"dbaeumer.vscode-eslint",
|
|
4
|
-
"streetsidesoftware.code-spell-checker",
|
|
5
|
-
"bierner.markdown-preview-github-styles",
|
|
6
|
-
"DavidAnson.vscode-markdownlint",
|
|
7
|
-
"ricard.postcss",
|
|
8
|
-
"shinnn.stylelint",
|
|
9
|
-
"jpoissonnier.vscode-styled-components",
|
|
10
|
-
"flowtype.flow-for-vscode",
|
|
11
|
-
"rbbit.typescript-hero",
|
|
12
|
-
"Equinusocio.vsc-material-theme",
|
|
13
|
-
"PKief.material-icon-theme"
|
|
14
|
-
]
|
|
15
|
-
}
|
package/.vscode/settings.json
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cSpell.words": [
|
|
3
|
-
"arkham",
|
|
4
|
-
"arkhamjs",
|
|
5
|
-
"nitrogenlabs",
|
|
6
|
-
"nlabs",
|
|
7
|
-
"polyfill",
|
|
8
|
-
"transpiler"
|
|
9
|
-
],
|
|
10
|
-
"css.validate": false,
|
|
11
|
-
"editor.autoClosingBrackets": "never",
|
|
12
|
-
"editor.detectIndentation": false,
|
|
13
|
-
"editor.formatOnSave": true,
|
|
14
|
-
"editor.rulers": [
|
|
15
|
-
120
|
|
16
|
-
],
|
|
17
|
-
"editor.tabCompletion": "on",
|
|
18
|
-
"editor.tabSize": 2,
|
|
19
|
-
"editor.wordWrap": "off",
|
|
20
|
-
"editor.wordWrapColumn": 120,
|
|
21
|
-
"editor.wrappingIndent": "indent",
|
|
22
|
-
"emmet.includeLanguages": {
|
|
23
|
-
"postcss": "css"
|
|
24
|
-
},
|
|
25
|
-
"emmet.syntaxProfiles": {
|
|
26
|
-
"postcss": "css"
|
|
27
|
-
},
|
|
28
|
-
"eslint.autoFixOnSave": true,
|
|
29
|
-
"eslint.alwaysShowStatus": true,
|
|
30
|
-
"eslint.enable": true,
|
|
31
|
-
"eslint.packageManager": "yarn",
|
|
32
|
-
"eslint.validate": [
|
|
33
|
-
{
|
|
34
|
-
"language": "javascript",
|
|
35
|
-
"autoFix": true
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"language": "javascriptreact",
|
|
39
|
-
"autoFix": true
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"language": "typescript",
|
|
43
|
-
"autoFix": true
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"language": "typescriptreact",
|
|
47
|
-
"autoFix": true
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
|
-
"explorer.decorations.badges": false,
|
|
51
|
-
"files.autoSave": "onFocusChange",
|
|
52
|
-
"html.format.indentInnerHtml": true,
|
|
53
|
-
"html.format.indentHandlebars": true,
|
|
54
|
-
"html.suggest.html5": false,
|
|
55
|
-
"explorer.confirmDragAndDrop": false,
|
|
56
|
-
"files.trimTrailingWhitespace": true,
|
|
57
|
-
"javascript.autoClosingTags": false,
|
|
58
|
-
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
|
|
59
|
-
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
|
|
60
|
-
"javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
|
|
61
|
-
"javascript.format.insertSpaceAfterKeywordsInControlFlowStatements": false,
|
|
62
|
-
"javascript.updateImportsOnFileMove.enabled": "never",
|
|
63
|
-
"html.autoClosingTags": false,
|
|
64
|
-
"html.format.enable": false,
|
|
65
|
-
"html.format.endWithNewline": true,
|
|
66
|
-
"html.format.extraLiners": "",
|
|
67
|
-
"typescript.autoClosingTags": false,
|
|
68
|
-
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
|
|
69
|
-
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
|
|
70
|
-
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
|
|
71
|
-
"typescript.format.insertSpaceAfterKeywordsInControlFlowStatements": false,
|
|
72
|
-
"typescript.updateImportsOnFileMove.enabled": "never",
|
|
73
|
-
"typescriptHero.imports.insertSpaceBeforeAndAfterImportBraces": false,
|
|
74
|
-
"typescriptHero.imports.multiLineTrailingComma": false,
|
|
75
|
-
"typescriptHero.imports.multiLineWrapThreshold": 120,
|
|
76
|
-
"typescriptHero.imports.organizeOnSave": true,
|
|
77
|
-
"window.zoomLevel": 0,
|
|
78
|
-
"javascript.preferences.importModuleSpecifier": "relative",
|
|
79
|
-
"javascript.preferences.quoteStyle": "single",
|
|
80
|
-
"typescript.preferences.importModuleSpecifier": "relative",
|
|
81
|
-
"typescript.preferences.quoteStyle": "single",
|
|
82
|
-
}
|
package/lex.config.js
DELETED
package/src/config.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2019-Present, Nitrogen Labs, Inc.
|
|
3
|
-
* Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.
|
|
4
|
-
*/
|
|
5
|
-
import get from 'lodash/get';
|
|
6
|
-
import merge from 'lodash/merge';
|
|
7
|
-
|
|
8
|
-
export interface AppConfig {
|
|
9
|
-
readonly app?: object;
|
|
10
|
-
readonly arangodb?: object;
|
|
11
|
-
readonly aws?: object;
|
|
12
|
-
readonly giphy?: object;
|
|
13
|
-
readonly google?: object;
|
|
14
|
-
readonly image?: object;
|
|
15
|
-
readonly redis?: object;
|
|
16
|
-
readonly stripe?: object;
|
|
17
|
-
readonly twilio?: object;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface EnvConfig {
|
|
21
|
-
readonly default: AppConfig;
|
|
22
|
-
readonly development: AppConfig;
|
|
23
|
-
readonly production: AppConfig;
|
|
24
|
-
readonly test: AppConfig;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const appPackage: any = require('../package.json');
|
|
28
|
-
|
|
29
|
-
const {
|
|
30
|
-
arangodbDatabase = 'reaktor',
|
|
31
|
-
arangodbPassword,
|
|
32
|
-
arangodbPort = '8529',
|
|
33
|
-
arangodbUrl = 'db.reaktor.io',
|
|
34
|
-
arangodbUsername = 'reaktor'
|
|
35
|
-
} = process.env;
|
|
36
|
-
|
|
37
|
-
export class Config {
|
|
38
|
-
static values: EnvConfig = {
|
|
39
|
-
default: {
|
|
40
|
-
app: {
|
|
41
|
-
name: 'reaktor',
|
|
42
|
-
url: 'reaktor.io',
|
|
43
|
-
version: appPackage.version
|
|
44
|
-
},
|
|
45
|
-
arangodb: {
|
|
46
|
-
apiUrl: `http://${arangodbUrl}:${arangodbPort}`,
|
|
47
|
-
database: arangodbDatabase,
|
|
48
|
-
dump: '/Applications/ArangoDB-CLI.app/Contents/MacOS/arangodump',
|
|
49
|
-
password: arangodbPassword,
|
|
50
|
-
port: arangodbPort,
|
|
51
|
-
restore: '/Applications/ArangoDB-CLI.app/Contents/MacOS/arangorestore',
|
|
52
|
-
url: arangodbUrl,
|
|
53
|
-
username: arangodbUsername
|
|
54
|
-
},
|
|
55
|
-
aws: {
|
|
56
|
-
Bucket: 'dev.reaktor.io',
|
|
57
|
-
accessKeyId: 'AKIAJIYDT3EA2ZFMTJNA',
|
|
58
|
-
maxRetries: 3,
|
|
59
|
-
region: 'us-east-1',
|
|
60
|
-
secretAccessKey: 'bUssQRtJTZC7geF9RDH5KCn8CalVnf2VT34yqS+9',
|
|
61
|
-
signatureVersion: 'v4'
|
|
62
|
-
},
|
|
63
|
-
giphy: {
|
|
64
|
-
key: 'dc6zaTOxFJmzC'
|
|
65
|
-
},
|
|
66
|
-
google: {
|
|
67
|
-
analytics: {
|
|
68
|
-
accountId: '78158717',
|
|
69
|
-
trackingId: 'UA-78158717-1'
|
|
70
|
-
},
|
|
71
|
-
geocode: {
|
|
72
|
-
key: 'AIzaSyBwjmpBjWhiJoBCZiYzRurM9m4WnCxslv0',
|
|
73
|
-
url: 'https://maps.googleapis.com/maps/api/geocode/json'
|
|
74
|
-
},
|
|
75
|
-
key: 'AIzaSyC3_f2Us3y0qjbyMJ-4t5ObtCzfq_FHIgQ'
|
|
76
|
-
},
|
|
77
|
-
image: {
|
|
78
|
-
imgQuality: 90,
|
|
79
|
-
imgSize: 1500,
|
|
80
|
-
thmQuality: 80,
|
|
81
|
-
thmSize: 150
|
|
82
|
-
},
|
|
83
|
-
redis: {
|
|
84
|
-
host: '127.0.0.1',
|
|
85
|
-
port: 6379
|
|
86
|
-
},
|
|
87
|
-
stripe: {
|
|
88
|
-
token: 'sk_test_LS956be57YUXTB5a4sLGb5BQ'
|
|
89
|
-
},
|
|
90
|
-
twilio: {
|
|
91
|
-
number: '+15005550006',
|
|
92
|
-
sid: 'AC6bd7f513cbed2e5134c650be06cc732e',
|
|
93
|
-
token: '520ae739e761bab759b147f1ad28278f'
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
development: {
|
|
97
|
-
},
|
|
98
|
-
production: {
|
|
99
|
-
arangodb: {
|
|
100
|
-
dump: '/usr/bin/arangodump',
|
|
101
|
-
restore: '/usr/bin/arangorestore',
|
|
102
|
-
},
|
|
103
|
-
aws: {
|
|
104
|
-
Bucket: 'box.reaktor.io'
|
|
105
|
-
},
|
|
106
|
-
redis: {
|
|
107
|
-
host: 'reaktor-redis.ehcvnt.0001.use1.cache.amazonaws.com'
|
|
108
|
-
},
|
|
109
|
-
stripe: {
|
|
110
|
-
token: 'sk_live_bElZl8RLhMCJy33KG4lyLD4o'
|
|
111
|
-
},
|
|
112
|
-
twilio: {
|
|
113
|
-
number: '+18554165227',
|
|
114
|
-
sid: 'AC90b0528a911e652d643329a4d7b4d2c7',
|
|
115
|
-
token: 'a7941d173bd4846d0966a186e9865b72'
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
test: {
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
static get(path: string | string[]): any {
|
|
123
|
-
const environment: string = process.env.stage || 'development';
|
|
124
|
-
const configValues: object = merge(this.values.default, this.values[environment], {environment});
|
|
125
|
-
return get(configValues, path);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2019-Present, Nitrogen Labs, Inc.
|
|
3
|
-
* Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.
|
|
4
|
-
*/
|
|
5
|
-
import {createHash, parseId} from '@nlabs/utils';
|
|
6
|
-
import {aql} from 'arangojs';
|
|
7
|
-
import {AqlQuery} from 'arangojs/lib/cjs/aql-query';
|
|
8
|
-
import {ArrayCursor} from 'arangojs/lib/cjs/cursor';
|
|
9
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
10
|
-
import identity from 'lodash/identity';
|
|
11
|
-
import isEmpty from 'lodash/isEmpty';
|
|
12
|
-
import pick from 'lodash/pick';
|
|
13
|
-
import {ApiContext} from 'types/auth';
|
|
14
|
-
|
|
15
|
-
import {ArangoDBLimit, ConversationType, ImageUrlData, UserType} from '../types';
|
|
16
|
-
import {getLimit, useDb} from '../utils';
|
|
17
|
-
import {logError} from '../utils/analytics';
|
|
18
|
-
import {getUrlImages} from './images';
|
|
19
|
-
import {getDisplayName} from './users';
|
|
20
|
-
|
|
21
|
-
const eventCategory: string = 'conversations';
|
|
22
|
-
|
|
23
|
-
export const getConversationList = (context: ApiContext, from: number, to: number): Promise<ConversationType[]> => {
|
|
24
|
-
const action: string = 'getList';
|
|
25
|
-
const {database, userId: sessionId} = context;
|
|
26
|
-
const limit: ArangoDBLimit = getLimit(from, to);
|
|
27
|
-
const aqlQry: string = `FOR c IN conversations
|
|
28
|
-
FILTER POSITION(c.users, "${sessionId}", false)
|
|
29
|
-
LET u = (
|
|
30
|
-
FOR g IN c.users
|
|
31
|
-
FOR u IN users
|
|
32
|
-
FILTER g == u._key
|
|
33
|
-
RETURN {_key:u._key, first:u.first, last:u.last, name:u.name, email:u.email, username:u.username, photo:u.photo }
|
|
34
|
-
)
|
|
35
|
-
FILTER LENGTH(u) > 1
|
|
36
|
-
${limit.aql}
|
|
37
|
-
RETURN {_key:c._key, name: c.name, direct: c.direct, users: u}`;
|
|
38
|
-
|
|
39
|
-
return useDb(database).query(aqlQry)
|
|
40
|
-
.then((cursor: ArrayCursor) => cursor.all())
|
|
41
|
-
.catch((error: Error) => logError({
|
|
42
|
-
action,
|
|
43
|
-
category: eventCategory,
|
|
44
|
-
label: 'db_error'
|
|
45
|
-
}, error, context).then(() => null));
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const getDirectConversation = (context: ApiContext, userId: string): Promise<ConversationType> => {
|
|
49
|
-
const action: string = 'getDirect';
|
|
50
|
-
const {database, userId: sessionId} = context;
|
|
51
|
-
const formatUserId: string = parseId(userId);
|
|
52
|
-
|
|
53
|
-
const aqlQry: AqlQuery = aql`FOR c IN conversations
|
|
54
|
-
FILTER LENGTH(c.users) == 2 &&
|
|
55
|
-
POSITION(c.users, ${sessionId}, false) &&
|
|
56
|
-
POSITION(c.users, ${formatUserId}, false)
|
|
57
|
-
LET u = (
|
|
58
|
-
FOR g IN c.users
|
|
59
|
-
FOR user IN users
|
|
60
|
-
FILTER user._key == g
|
|
61
|
-
RETURN user
|
|
62
|
-
)
|
|
63
|
-
LIMIT 1
|
|
64
|
-
RETURN MERGE(c, {users: u})`;
|
|
65
|
-
|
|
66
|
-
return useDb(database).query(aqlQry)
|
|
67
|
-
.then((cursor: ArrayCursor) => cursor.next())
|
|
68
|
-
.then((conversation: ConversationType = {}) => {
|
|
69
|
-
const {users = []} = conversation;
|
|
70
|
-
|
|
71
|
-
if(users.length) {
|
|
72
|
-
conversation.users = users.map((user: UserType) => {
|
|
73
|
-
const {_key: userKey, imgId} = user;
|
|
74
|
-
const thumbUrlData: ImageUrlData = {
|
|
75
|
-
directory: 'images',
|
|
76
|
-
imgId,
|
|
77
|
-
isThumb: true,
|
|
78
|
-
type: 'users',
|
|
79
|
-
typeId: userKey
|
|
80
|
-
};
|
|
81
|
-
return {
|
|
82
|
-
...user,
|
|
83
|
-
name: getDisplayName(user),
|
|
84
|
-
thumb: getUrlImages(thumbUrlData)
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return conversation;
|
|
90
|
-
})
|
|
91
|
-
.catch((error: Error) => logError({
|
|
92
|
-
action,
|
|
93
|
-
category: eventCategory,
|
|
94
|
-
label: 'db_error'
|
|
95
|
-
}, error, context).then(() => null));
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const getConversation = (context: ApiContext, convoId: string): Promise<ConversationType> => {
|
|
99
|
-
const action: string = 'getItem';
|
|
100
|
-
const {database, userId: sessionId} = context;
|
|
101
|
-
const formatConvoId: string = parseId(convoId);
|
|
102
|
-
|
|
103
|
-
const aqlQry: AqlQuery = aql`FOR c IN conversations
|
|
104
|
-
FILTER ${formatConvoId} == c._key && IS_LIST(c.users) && POSITION(c.users, ${sessionId}, false)
|
|
105
|
-
LET u = (
|
|
106
|
-
FOR g IN c.users
|
|
107
|
-
FOR u IN users
|
|
108
|
-
FILTER g == u._key
|
|
109
|
-
RETURN {_key:u._key, first:u.first, last:u.last, name:u.name, email:u.email, username:u.username, photo:u.photo }
|
|
110
|
-
)
|
|
111
|
-
FILTER LENGTH(u) > 1
|
|
112
|
-
LIMIT 1
|
|
113
|
-
RETURN MERGE(c, {users: u})`;
|
|
114
|
-
|
|
115
|
-
return useDb(database).query(aqlQry)
|
|
116
|
-
.then((cursor: ArrayCursor) => cursor.next())
|
|
117
|
-
.then((conversation: ConversationType = {}) => {
|
|
118
|
-
if(!isEmpty(conversation)) {
|
|
119
|
-
conversation.users = conversation.users.map((user: UserType) => {
|
|
120
|
-
const {_key: userKey, imgId} = user;
|
|
121
|
-
const thumbUrlData: ImageUrlData = {
|
|
122
|
-
directory: 'images',
|
|
123
|
-
imgId,
|
|
124
|
-
isThumb: true,
|
|
125
|
-
type: 'users',
|
|
126
|
-
typeId: userKey
|
|
127
|
-
};
|
|
128
|
-
return {
|
|
129
|
-
...user,
|
|
130
|
-
name: getDisplayName(user),
|
|
131
|
-
thumb: getUrlImages(thumbUrlData)
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
return conversation;
|
|
136
|
-
}
|
|
137
|
-
return {};
|
|
138
|
-
})
|
|
139
|
-
.catch((error: Error) => logError({
|
|
140
|
-
action,
|
|
141
|
-
category: eventCategory,
|
|
142
|
-
label: 'db_error'
|
|
143
|
-
}, error, context).then(() => null));
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export const updateConversation = (context: ApiContext, item): Promise<ConversationType> => {
|
|
147
|
-
const action: string = 'update';
|
|
148
|
-
const {database, userId: sessionId} = context;
|
|
149
|
-
const {direct, id, name, users} = pick(item, identity);
|
|
150
|
-
const rcpt: UserType[] = users || [];
|
|
151
|
-
const formatId: string = item.id || createHash(`convo-${sessionId}-${rcpt.join('')}`);
|
|
152
|
-
const now: number = Date.now();
|
|
153
|
-
const update: any = {
|
|
154
|
-
// Direct message
|
|
155
|
-
direct: !!direct ? direct : undefined,
|
|
156
|
-
modified: now,
|
|
157
|
-
name: !!name ? name : undefined,
|
|
158
|
-
// Users
|
|
159
|
-
users: !!users ? users : undefined
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const insert: any = {
|
|
163
|
-
...cloneDeep(update),
|
|
164
|
-
_key: formatId,
|
|
165
|
-
added: now
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const aqlQry: AqlQuery = aql`UPSERT {_key: ${id}}
|
|
169
|
-
INSERT ${insert}
|
|
170
|
-
UPDATE ${update}
|
|
171
|
-
IN conversations RETURN NEW`;
|
|
172
|
-
|
|
173
|
-
return useDb(database).query(aqlQry)
|
|
174
|
-
.then((cursor: ArrayCursor) => cursor.next())
|
|
175
|
-
.then((conversation: ConversationType = {}) => conversation)
|
|
176
|
-
.catch((error: Error) => logError({
|
|
177
|
-
action,
|
|
178
|
-
category: eventCategory,
|
|
179
|
-
label: 'db_error'
|
|
180
|
-
}, error, context).then(() => null));
|
|
181
|
-
};
|
package/src/data/dynamodb.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2019-Present, Nitrogen Labs, Inc.
|
|
3
|
-
* Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.
|
|
4
|
-
*/
|
|
5
|
-
import aws, {DynamoDB} from 'aws-sdk';
|
|
6
|
-
import {
|
|
7
|
-
BatchWriteItemInput,
|
|
8
|
-
BatchWriteItemOutput,
|
|
9
|
-
DeleteItemInput,
|
|
10
|
-
DeleteItemOutput,
|
|
11
|
-
GetItemInput,
|
|
12
|
-
GetItemOutput,
|
|
13
|
-
PutItemInput,
|
|
14
|
-
PutItemOutput,
|
|
15
|
-
QueryInput,
|
|
16
|
-
QueryOutput,
|
|
17
|
-
UpdateItemInput,
|
|
18
|
-
UpdateItemOutput
|
|
19
|
-
} from 'aws-sdk/clients/dynamodb';
|
|
20
|
-
|
|
21
|
-
import {Config} from '../config';
|
|
22
|
-
|
|
23
|
-
// const eventCategory: string = 'dynamodb';
|
|
24
|
-
|
|
25
|
-
export const dynamoGet = (params: GetItemInput): Promise<GetItemOutput> => {
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
aws.config.update(Config.get('aws'));
|
|
28
|
-
const dynamodb: DynamoDB = new DynamoDB();
|
|
29
|
-
params.ConsistentRead = false;
|
|
30
|
-
|
|
31
|
-
dynamodb.getItem(params, (error: Error, results: GetItemOutput) => {
|
|
32
|
-
if(error) {
|
|
33
|
-
return reject(error);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return resolve(results);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const dynamoGetList = (params: QueryInput, index): Promise<GetItemOutput[]> => {
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
aws.config.update(Config.get('aws'));
|
|
44
|
-
const dynamodb: DynamoDB = new DynamoDB();
|
|
45
|
-
const {ConsistentRead: consistentRead} = params;
|
|
46
|
-
const updatedParams = {...params};
|
|
47
|
-
|
|
48
|
-
if(index) {
|
|
49
|
-
updatedParams.ExclusiveStartKey = index;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if(!consistentRead) {
|
|
53
|
-
updatedParams.ConsistentRead = false;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
dynamodb.query(updatedParams, (error: Error, output: QueryOutput) => {
|
|
57
|
-
if(error) {
|
|
58
|
-
return reject(error);
|
|
59
|
-
}
|
|
60
|
-
// Save list of items
|
|
61
|
-
const list: any[] = parseDynamo(output);
|
|
62
|
-
const {LastEvaluatedKey: lastKey} = output;
|
|
63
|
-
|
|
64
|
-
if(lastKey !== undefined) {
|
|
65
|
-
// Save last index before looping
|
|
66
|
-
return dynamoGetList(params, lastKey);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Query complete, return final list
|
|
70
|
-
return resolve(list);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const dynamoPut = (params: PutItemInput): Promise<PutItemOutput> => {
|
|
76
|
-
return new Promise((resolve, reject) => {
|
|
77
|
-
aws.config.update(Config.get('aws'));
|
|
78
|
-
const dynamodb: DynamoDB = new DynamoDB();
|
|
79
|
-
|
|
80
|
-
dynamodb.putItem(params, (error, output: PutItemOutput) => {
|
|
81
|
-
if(error) {
|
|
82
|
-
return reject(error);
|
|
83
|
-
}
|
|
84
|
-
return resolve(output);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const dynamoUpdate = (params: UpdateItemInput): Promise<UpdateItemOutput> => {
|
|
90
|
-
return new Promise((resolve, reject) => {
|
|
91
|
-
aws.config.update(Config.get('aws'));
|
|
92
|
-
const dynamodb: DynamoDB = new DynamoDB();
|
|
93
|
-
|
|
94
|
-
dynamodb.updateItem(params, (error: Error, output: UpdateItemOutput) => {
|
|
95
|
-
if(error) {
|
|
96
|
-
return reject(error);
|
|
97
|
-
}
|
|
98
|
-
return resolve(output);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export const dynamoPutList = (params: BatchWriteItemInput): Promise<BatchWriteItemOutput> => {
|
|
104
|
-
return new Promise((resolve, reject) => {
|
|
105
|
-
aws.config.update(Config.get('aws'));
|
|
106
|
-
const dynamodb: DynamoDB = new DynamoDB();
|
|
107
|
-
|
|
108
|
-
dynamodb.batchWriteItem(params, (error: Error, output: BatchWriteItemOutput) => {
|
|
109
|
-
if(error) {
|
|
110
|
-
return reject(error);
|
|
111
|
-
}
|
|
112
|
-
return resolve(output);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export const dynamoDel = (params: DeleteItemInput): Promise<DeleteItemOutput> => {
|
|
118
|
-
return new Promise((resolve, reject) => {
|
|
119
|
-
aws.config.update(Config.get('aws'));
|
|
120
|
-
const dynamodb: DynamoDB = new DynamoDB();
|
|
121
|
-
|
|
122
|
-
dynamodb.deleteItem(params, (error, output: DeleteItemOutput) => {
|
|
123
|
-
if(error) {
|
|
124
|
-
return reject(error);
|
|
125
|
-
}
|
|
126
|
-
return resolve(output);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export const parseDynamo = (results: QueryOutput): any[] => {
|
|
132
|
-
const {Items: items} = results;
|
|
133
|
-
const data: any[] = [];
|
|
134
|
-
|
|
135
|
-
for(let idx: number = 0, len = items.length; idx < len; idx++) {
|
|
136
|
-
const tmp = items[idx];
|
|
137
|
-
const obj = {};
|
|
138
|
-
let key;
|
|
139
|
-
|
|
140
|
-
for(key in tmp) {
|
|
141
|
-
if(tmp.hasOwnProperty(key)) {
|
|
142
|
-
if(tmp[key].S) {
|
|
143
|
-
obj[key] = tmp[key].S.toString();
|
|
144
|
-
} else if(tmp[key].N) {
|
|
145
|
-
obj[key] = parseFloat(tmp[key].N);
|
|
146
|
-
} else {
|
|
147
|
-
obj[key] = tmp[key].B;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
data.push(obj);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return data;
|
|
156
|
-
};
|
|
157
|
-
|