-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththots.txt
144 lines (107 loc) · 3.69 KB
/
thots.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
Add Static.load(ids?: PouchDbId[], startkey?: string, endkey?: string) methods
Add load(n, sortKey: string = 'createdAt')
Add unload(n, sortKey: string = 'createdAt')
Remove the lowest when sorting by `sortKey`
Take in and save tags in searchDefinition
Add list of IDs to expect().toBeInDatabase()
Add account tests
Reverse proxy for CouchDB?
Container for CouchDB?
Relay lambda for anything that needs keys
Check if initiator matches tracedigital.tk or localhost
Listen to the db change feed
If we don't have the ID, ignore the change (unless it's an account)
If we have it
Check for deleted
deserialize() onto the instance we already have
Logging framework
"scripts": {
"test": "jest --config jestconfig.json",
"build": "tsc",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"lint": "tslint -p tsconfig.json",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
"version": "npm run format && git add -A src",
"postversion": "git push && git push --tags"
}
"prepublishOnly": "npm test && (npm run lint || read -p '\n\nLINT FAILED!\nPress any key to bypass linter or Ctrl+C to cancel...' noop)",
if (isNode || isJsDom()) {
const thePouch: PouchDB.Static = require('pouchdb');
_localDb = new thePouch(DB_NAME);
} else {
_localDb = new PouchDB(DB_NAME);
}
Externals
https://webpack.js.org/guides/author-libraries/#externalize-lodash
import pouchDbDebug from 'pouchdb-debug';
PouchDB.plugin(pouchDbDebug);
console.log(PouchDB.debug);
PouchDB.debug.enable('*');
constructor(account: AutoSearchAccount) {
super(account.site, account.userName);
/**
* Would love to not have to copy these over by hand, but this was
* the best I could come up with for now.
*
* Some of these are shallow copies
* Shouldn't be an issue though as we don't really need the data frozen
*/
this.discoveredOn = account.discoveredOn;
this.confidence = account.confidence;
this.matchedFirstNames = account.matchedFirstNames;
this.matchedLastNames = account.matchedLastNames;
}
/**
* Flatten a `SearchResults` dictionary into an array of
* accounts that satisfy `predicate`.
*/
function resultsAsArrayHelper(results: SearchResults, predicate: (account: ThirdPartyAccount) => boolean) {
const flattened = [];
for (const accountMap of Object.values(results)) {
for (const account of Object.values(accountMap)) {
if (predicate(account)) {
flattened.push(account);
}
}
}
return flattened;
}
# Don't make request if username is invalid for the site
regex_check = net_info.get("regexCheck")
if regex_check and re.search(regex_check, username) is None:
# No need to do the check at the site: this user name is not allowed.
results_site['status'] = QueryResult(username,
social_network,
url,
QueryStatus.ILLEGAL)
import { getDb, PouchDbId } from "db";
expect.extend({
/**
* Expect database ID `id` to be present in the database.
*/
async toBeInDatabase(id: PouchDbId) {
const db = await getDb();
let exists = {
message: () =>
`expected '${id}' to be present in the database (${db.name})`,
pass: true,
};
let absent = {
message: () =>
`expected '${id}' to be present in the database (${db.name})`,
pass: false,
};
if (this.isNot) {
exists.pass = !exists.pass;
absent.pass = !absent.pass;
}
try {
await db.get(id);
return exists;
} catch (e) {
return absent;
}
},
});