(core) API console

Summary: Adds a custom interactive Swagger API console at `/apiconsole`. For now, this isn't visibly linked anywhere.

Test Plan: Manual, this is still an experimental and private feature. The idea is to merge this soon so that we have a chance to try it out in production.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D4151
This commit is contained in:
Alex Hall
2023-12-27 14:19:56 +02:00
parent a5544b9b01
commit a2bd753649
3 changed files with 234 additions and 0 deletions

View File

@@ -100,6 +100,17 @@ export function tools(owner: Disposable, gristDoc: GristDoc, leftPanelOpen: Obse
testId('settings'),
),
cssSpacer(),
// TODO make this look nice, then make it visible when the console is ready.
// For now let's keep it private, so this shouldn't be uncommented.
// cssPageEntry(
// cssPageLink(
// cssPageIcon('Code'),
// cssPageIcon('FieldLink'),
// cssLinkText(t("API Console")),
// {href: window.origin + '/apiconsole', target: '_blank'}
// ),
// testId('api'),
// ),
dom.maybe(docPageModel.currentDoc, (doc) => {
const ex = buildExamples().find(e => e.urlId === doc.urlId);
if (!ex || !ex.tutorialUrl) { return null; }

View File

@@ -44,6 +44,9 @@ export function attachAppEndpoint(options: AttachOptions): void {
app.get(['/', '/ws/:wsId', '/p/:page'], ...middleware, expressWrap(async (req, res) =>
sendAppPage(req, res, {path: 'app.html', status: 200, config: {plugins}, googleTagManager: 'anon'})));
app.get('/apiconsole', expressWrap(async (req, res) =>
sendAppPage(req, res, {path: 'apiconsole.html', status: 200, config: {}})));
app.get('/api/worker/:assignmentId([^/]+)/?*', expressWrap(async (req, res) => {
if (!useWorkerPool()) {
// Let the client know there is not a separate pool of workers,