-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db-tabulator: expose more APIs in JS preprocessing
- Loading branch information
1 parent
ec506ee
commit 02f59f0
Showing
4 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* global __mwApiGet, __dbQueryResult, preprocess */ | ||
/* global __mwApiGet, __rawReq, __dbQueryResult, preprocess */ | ||
(async function() { | ||
"${JS_CODE}"; | ||
|
||
async function mwApiGet(params) { | ||
const response = await __mwApiGet.applySyncPromise(undefined, [JSON.stringify(params)]); | ||
return JSON.parse(response); | ||
const bot = { | ||
async request(url) { | ||
if (typeof url !== 'string') throw new Error('bot.request() needs a string url'); | ||
const response = await __rawReq.applySyncPromise(undefined, [url]); | ||
return JSON.parse(response); | ||
}, | ||
async api(params) { | ||
if (typeof params !== 'object') throw new Error('bot.api() parameters need to be an object'); | ||
const response = await __mwApiGet.applySyncPromise(undefined, [JSON.stringify(params)]); | ||
return JSON.parse(response); | ||
} | ||
} | ||
|
||
"${JS_CODE}"; | ||
|
||
return JSON.stringify(await preprocess(JSON.parse(__dbQueryResult))); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters