From ea01ca814d78ca7489019430f889e5d64a3808fe Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Thu, 1 Jul 2021 17:15:43 +0200 Subject: [PATCH] (core) Remove a bunch of dead code Summary: Removed test/aws/, most of app/server/lib/, 3 dirs in app/lambda/, corresponding tests, and more! Test Plan: a lot of this is quite the opposite... Reviewers: dsagal, paulfitz Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2894 --- app/client/components/Comm.ts | 1 - app/client/components/DocComm.ts | 1 - app/common/ActiveDocAPI.ts | 6 -- app/common/GristServerAPI.ts | 6 -- app/server/lib/ActiveDoc.ts | 75 ++++++++++-------------- app/server/lib/Comm.js | 3 +- app/server/lib/DocManager.ts | 40 +++---------- app/server/lib/FlexServer.ts | 14 +---- app/server/lib/ICreate.ts | 30 ++++------ app/server/lib/IInstanceManager.ts | 5 -- app/server/lib/ILoginSession.ts | 3 - app/server/lib/ITestingHooks-ti.ts | 3 - app/server/lib/ITestingHooks.ts | 3 - app/server/lib/Sessions.ts | 5 +- app/server/lib/Sharing.ts | 26 +++----- app/server/lib/TestingHooks.ts | 28 +-------- stubs/app/server/lib/LoginSession.ts | 9 --- stubs/app/server/lib/StandaloneExtras.ts | 4 -- stubs/app/server/lib/create.ts | 19 +++--- 19 files changed, 73 insertions(+), 208 deletions(-) delete mode 100644 app/server/lib/IInstanceManager.ts delete mode 100644 stubs/app/server/lib/StandaloneExtras.ts diff --git a/app/client/components/Comm.ts b/app/client/components/Comm.ts index a5a1789f..86378cdc 100644 --- a/app/client/components/Comm.ts +++ b/app/client/components/Comm.ts @@ -195,7 +195,6 @@ export class Comm extends dispose.Disposable implements GristServerAPI, DocListA public getNewInvites = this._wrapMethod('getNewInvites'); public getLocalInvites = this._wrapMethod('getLocalInvites'); public ignoreLocalInvite = this._wrapMethod('ignoreLocalInvite'); - public downloadSharedDoc = this._wrapMethod('downloadSharedDoc'); public showItemInFolder = this._wrapMethod('showItemInFolder'); public getBasketTables = this._wrapMethod('getBasketTables'); public embedTable = this._wrapMethod('embedTable'); diff --git a/app/client/components/DocComm.ts b/app/client/components/DocComm.ts index 6c9f0a0b..ff575f5c 100644 --- a/app/client/components/DocComm.ts +++ b/app/client/components/DocComm.ts @@ -45,7 +45,6 @@ export class DocComm extends Disposable implements ActiveDocAPI { public getFormulaError = this._wrapMethod("getFormulaError"); public fetchURL = this._wrapMethod("fetchURL"); public autocomplete = this._wrapMethod("autocomplete"); - public shareDoc = this._wrapMethod("shareDoc"); public removeInstanceFromDoc = this._wrapMethod("removeInstanceFromDoc"); public getActionSummaries = this._wrapMethod("getActionSummaries"); public startBundleUserActions = this._wrapMethod("startBundleUserActions"); diff --git a/app/common/ActiveDocAPI.ts b/app/common/ActiveDocAPI.ts index f842c238..e3444ba7 100644 --- a/app/common/ActiveDocAPI.ts +++ b/app/common/ActiveDocAPI.ts @@ -1,7 +1,6 @@ import {ActionGroup} from 'app/common/ActionGroup'; import {CellValue, TableDataAction, UserAction} from 'app/common/DocActions'; import {FormulaProperties} from 'app/common/GranularAccessClause'; -import {Peer} from 'app/common/sharing'; import {UploadResult} from 'app/common/uploads'; import {ParseOptions} from 'app/plugin/FileParserAPI'; import {IMessage} from 'grain-rpc'; @@ -179,11 +178,6 @@ export interface ActiveDocAPI { */ autocomplete(txt: string, tableId: string): Promise; - /** - * Shares the doc and invites peers. - */ - shareDoc(peers: Peer[]): Promise; - /** * Removes the current instance from the doc. */ diff --git a/app/common/GristServerAPI.ts b/app/common/GristServerAPI.ts index dcd5b718..6b8ff956 100644 --- a/app/common/GristServerAPI.ts +++ b/app/common/GristServerAPI.ts @@ -56,12 +56,6 @@ interface SharingAPI { */ ignoreLocalInvite(docId: string): Promise; - /** - * Downloads a shared doc by creating a new doc and applying the snapshot actions associated - * with the given docId on the sharing hub. Must be called from a logged in account and instance - * invited to download the doc. Returns the actual non-conflicting docName used. - */ - downloadSharedDoc(docId: string, docName: string): Promise; } interface MiscAPI { diff --git a/app/server/lib/ActiveDoc.ts b/app/server/lib/ActiveDoc.ts index 35e394a3..3f46504c 100644 --- a/app/server/lib/ActiveDoc.ts +++ b/app/server/lib/ActiveDoc.ts @@ -10,31 +10,38 @@ import * as bluebird from 'bluebird'; import {EventEmitter} from 'events'; import {IMessage, MsgType} from 'grain-rpc'; import * as imageSize from 'image-size'; -import cloneDeep = require('lodash/cloneDeep'); -import flatten = require('lodash/flatten'); -import remove = require('lodash/remove'); -import zipObject = require('lodash/zipObject'); import * as moment from 'moment-timezone'; import fetch from 'node-fetch'; import * as tmp from 'tmp'; -import {getEnvContent, LocalActionBundle} from 'app/common/ActionBundle'; -import {SandboxActionBundle, UserActionBundle} from 'app/common/ActionBundle'; +import {getEnvContent, LocalActionBundle, SandboxActionBundle, UserActionBundle} from 'app/common/ActionBundle'; import {ActionGroup} from 'app/common/ActionGroup'; -import {ApplyUAOptions, ApplyUAResult, ForkResult} from 'app/common/ActiveDocAPI'; -import {DataSourceTransformed, ImportResult, Query, QueryResult} from 'app/common/ActiveDocAPI'; +import { + ApplyUAOptions, + ApplyUAResult, + DataSourceTransformed, + ForkResult, + ImportResult, + Query, + QueryResult +} from 'app/common/ActiveDocAPI'; import {ApiError} from 'app/common/ApiError'; import {mapGetOrSet, MapWithTTL} from 'app/common/AsyncCreate'; -import {BulkColValues, CellValue, DocAction, RowRecord, TableDataAction, UserAction} from 'app/common/DocActions'; -import {toTableDataAction} from 'app/common/DocActions'; +import { + BulkColValues, + CellValue, + DocAction, + RowRecord, + TableDataAction, + toTableDataAction, + UserAction +} from 'app/common/DocActions'; import {DocData} from 'app/common/DocData'; import {DocSnapshots} from 'app/common/DocSnapshot'; -import {EncActionBundleFromHub} from 'app/common/EncActionBundle'; import {FormulaProperties, getFormulaProperties} from 'app/common/GranularAccessClause'; import {byteString, countIf} from 'app/common/gutil'; import {InactivityTimer} from 'app/common/InactivityTimer'; import * as marshal from 'app/common/marshal'; -import {Peer} from 'app/common/sharing'; import {UploadResult} from 'app/common/uploads'; import {DocReplacementOptions, DocState} from 'app/common/UserAPI'; import {ParseOptions} from 'app/plugin/FileParserAPI'; @@ -55,13 +62,23 @@ import {ActionHistoryImpl} from './ActionHistoryImpl'; import {ActiveDocImport} from './ActiveDocImport'; import {DocClients} from './DocClients'; import {DocPluginManager} from './DocPluginManager'; -import {DocSession, getDocSessionAccess, getDocSessionUser, getDocSessionUserId, - makeExceptionalDocSession, OptDocSession} from './DocSession'; +import { + DocSession, + getDocSessionAccess, + getDocSessionUser, + getDocSessionUserId, + makeExceptionalDocSession, + OptDocSession +} from './DocSession'; import {DocStorage} from './DocStorage'; import {expandQuery} from './ExpandedQuery'; import {GranularAccess, GranularAccessForBundle} from './GranularAccess'; import {OnDemandActions} from './OnDemandActions'; import {findOrAddAllEnvelope, Sharing} from './Sharing'; +import cloneDeep = require('lodash/cloneDeep'); +import flatten = require('lodash/flatten'); +import remove = require('lodash/remove'); +import zipObject = require('lodash/zipObject'); bluebird.promisifyAll(tmp); @@ -403,21 +420,6 @@ export class ActiveDoc extends EventEmitter { } } - /** - * Create a document given encrypted action bundles from the sharing hub. Part of the process - * of downloading a shared doc. - * TODO: Not only the snapshot but all actions shared to the hub before download are applied - * directly to the database, meaning they cannot be undone by this instance. We may want to - * consider applying actions following the snapshot differently. - */ - public async downloadSharedDoc( - docId: string, - instanceId: string, - encBundles: EncActionBundleFromHub[] - ): Promise { - throw new Error('downloadSharedDoc not implemented'); - } - /** * Finish initializing ActiveDoc, by initializing ActionHistory, Sharing, and docData. */ @@ -432,12 +434,6 @@ export class ActiveDoc extends EventEmitter { }, this.recoveryMode, this._docManager.getHomeDbManager(), this.docName); await this._granularAccess.update(); this._sharing = new Sharing(this, this._actionHistory, this._modificationLock); - - await this.openSharedDoc(docSession); - } - - public async openSharedDoc(docSession: OptDocSession|null) { - // Doesn't do anything special in this base class. } /** @@ -812,15 +808,6 @@ export class ActiveDoc extends EventEmitter { await this.docStorage.updateIndexes(indexes); } - /** - * Shares the doc and invites peers. - * @param {Array} peers - Array of peer objects with which the doc should be shared. - * @returns {Promise} Return promise for docId on completion. - */ - public async shareDoc(docSession: DocSession, peers: Peer[]): Promise { - throw new Error('shareDoc not implemented'); - } - public async removeInstanceFromDoc(docSession: DocSession): Promise { await this._sharing.removeInstanceFromDoc(); } diff --git a/app/server/lib/Comm.js b/app/server/lib/Comm.js index c049bc55..292ed163 100644 --- a/app/server/lib/Comm.js +++ b/app/server/lib/Comm.js @@ -82,7 +82,6 @@ function Comm(server, options) { this.sessions = options.sessions; this._settings = options.settings; - this._instanceManager = options.instanceManager; this._hosts = options.hosts; // This maps method names to their implementation. @@ -125,7 +124,7 @@ Comm.prototype.getClient = function(clientId) { Comm.prototype.getOrCreateSession = function(sid, req, userSelector) { // LoginSessions are specific to a session id / org combination. const org = req.org || ""; - return this.sessions.getOrCreateLoginSession(sid, org, this, this._instanceManager, + return this.sessions.getOrCreateLoginSession(sid, org, this, userSelector); }; diff --git a/app/server/lib/DocManager.ts b/app/server/lib/DocManager.ts index 6bde5b83..96b63834 100644 --- a/app/server/lib/DocManager.ts +++ b/app/server/lib/DocManager.ts @@ -1,23 +1,24 @@ import * as pidusage from '@gristlabs/pidusage'; import * as bluebird from 'bluebird'; import {EventEmitter} from 'events'; -import noop = require('lodash/noop'); import * as path from 'path'; import {ApiError} from 'app/common/ApiError'; import {mapSetOrClear} from 'app/common/AsyncCreate'; import {BrowserSettings} from 'app/common/BrowserSettings'; import {DocCreationInfo, DocEntry, DocListAPI, OpenDocMode, OpenLocalDocResult} from 'app/common/DocListAPI'; -import {EncActionBundleFromHub} from 'app/common/EncActionBundle'; import {Invite} from 'app/common/sharing'; import {tbind} from 'app/common/tbind'; import {NEW_DOCUMENT_CODE} from 'app/common/UserAPI'; import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager'; -import {assertAccess, Authorizer, DocAuthorizer, DummyAuthorizer, - isSingleUserMode} from 'app/server/lib/Authorizer'; +import {assertAccess, Authorizer, DocAuthorizer, DummyAuthorizer, isSingleUserMode} from 'app/server/lib/Authorizer'; import {Client} from 'app/server/lib/Client'; -import {getDocSessionCachedDoc, makeExceptionalDocSession, makeOptDocSession} from 'app/server/lib/DocSession'; -import {OptDocSession} from 'app/server/lib/DocSession'; +import { + getDocSessionCachedDoc, + makeExceptionalDocSession, + makeOptDocSession, + OptDocSession +} from 'app/server/lib/DocSession'; import * as docUtils from 'app/server/lib/docUtils'; import {GristServer} from 'app/server/lib/GristServer'; import {IDocStorageManager} from 'app/server/lib/IDocStorageManager'; @@ -26,6 +27,7 @@ import * as log from 'app/server/lib/log'; import {ActiveDoc} from './ActiveDoc'; import {PluginManager} from './PluginManager'; import {getFileUploadInfo, globalUploadSet, makeAccessId, UploadInfo} from './uploads'; +import noop = require('lodash/noop'); // A TTL in milliseconds to use for material that can easily be recomputed / refetched // but is a bit of a burden under heavy traffic. @@ -123,15 +125,6 @@ export class DocManager extends EventEmitter { return activeDoc.docName; } - /** - * Download a shared doc by creating a new doc and applying to it the shared doc snapshot actions. - * Also marks the invite to the doc as ignored, since it has already been accepted. - * @returns {Promise:String} The name of the new document. - */ - public async downloadSharedDoc(client: Client, docId: string, docName: string): Promise { - throw new Error('downloadSharedDoc not implemented'); - } - /** * Creates a new document, fetches it, and adds a table to it. * @param {String} sampleDocName: Doc name of a sample document. @@ -417,23 +410,6 @@ export class DocManager extends EventEmitter { return userId === this._homeDbManager.getAnonymousUserId(); } - /** - * Helper function for creating a new shared document given the doc snapshot bundles received - * from the sharing hub. - * @param {String} basenameHint: Suggested base name to use (no directory, no extension). - * @param {String} docId: The docId of the doc received from the hub. - * @param {String} instanceId: The user instanceId creating the doc. - * @param {EncActionBundleFromHub[]} encBundles: The action bundles making up the doc snapshot. - * @returns {Promise:ActiveDoc} ActiveDoc for the newly created document. - */ - protected async _createNewSharedDoc(basenameHint: string, docId: string, instanceId: string, - encBundles: EncActionBundleFromHub[]): Promise { - const docName = await this._createNewDoc(basenameHint); - return mapSetOrClear(this._activeDocs, docName, - this._createActiveDoc({client: null}, docName) - .then(newDoc => newDoc.downloadSharedDoc(docId, instanceId, encBundles))); - } - private async _createActiveDoc(docSession: OptDocSession, docName: string, safeMode?: boolean) { // Get URL for document for use with SELF_HYPERLINK(). const cachedDoc = getDocSessionCachedDoc(docSession); diff --git a/app/server/lib/FlexServer.ts b/app/server/lib/FlexServer.ts index 622bd8a9..c9dca744 100644 --- a/app/server/lib/FlexServer.ts +++ b/app/server/lib/FlexServer.ts @@ -743,7 +743,6 @@ export class FlexServer implements GristServer { this.comm = new Comm(this.server, { settings: this.settings, sessions: this.sessions, - instanceStore: null, // no instanceStore hosts: this._hosts, httpsServer: this.httpsServer, }); @@ -846,7 +845,7 @@ export class FlexServer implements GristServer { public async addTestingHooks(workerServers?: FlexServer[]) { if (process.env.GRIST_TESTING_SOCKET) { - await startTestingHooks(process.env.GRIST_TESTING_SOCKET, this.port, null!, this.comm, this, + await startTestingHooks(process.env.GRIST_TESTING_SOCKET, this.port, this.comm, this, workerServers || []); this._hasTestingHooks = true; } @@ -900,16 +899,7 @@ export class FlexServer implements GristServer { shutdown.addCleanupHandler(null, this._shutdown.bind(this), 25000, 'FlexServer._shutdown'); - if (isSingleUserMode()) { - // Load standalone stuff only if needed. Hosted grist doesn't currently need basket, - // sharing, etc. - const extras = await import('app/server/lib/StandaloneExtras'); - this.electronServerMethods = extras.addStandaloneMethods({ - flexServer: this, - docManager: this._docManager, - storageManager: this._storageManager, - }); - } else { + if (!isSingleUserMode()) { this.comm.registerMethods({ openDoc: docManager.openDoc.bind(docManager), }); diff --git a/app/server/lib/ICreate.ts b/app/server/lib/ICreate.ts index 8782610c..02ed988d 100644 --- a/app/server/lib/ICreate.ts +++ b/app/server/lib/ICreate.ts @@ -1,22 +1,18 @@ -import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager'; -import { ActiveDoc } from 'app/server/lib/ActiveDoc'; -import { ScopedSession } from 'app/server/lib/BrowserSession'; +import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager'; +import {ActiveDoc} from 'app/server/lib/ActiveDoc'; +import {ScopedSession} from 'app/server/lib/BrowserSession'; import * as Comm from 'app/server/lib/Comm'; -import { DocManager } from 'app/server/lib/DocManager'; -import { ExternalStorage } from 'app/server/lib/ExternalStorage'; -import { GristServer } from 'app/server/lib/GristServer'; -import { IBilling } from 'app/server/lib/IBilling'; -import { IDocStorageManager } from 'app/server/lib/IDocStorageManager'; -import { IInstanceManager } from 'app/server/lib/IInstanceManager'; -import { ILoginSession } from 'app/server/lib/ILoginSession'; -import { INotifier } from 'app/server/lib/INotifier'; -import { ISandbox, ISandboxCreationOptions } from 'app/server/lib/ISandbox'; -import { IShell } from 'app/server/lib/IShell'; -import { PluginManager } from 'app/server/lib/PluginManager'; +import {DocManager} from 'app/server/lib/DocManager'; +import {ExternalStorage} from 'app/server/lib/ExternalStorage'; +import {GristServer} from 'app/server/lib/GristServer'; +import {IBilling} from 'app/server/lib/IBilling'; +import {ILoginSession} from 'app/server/lib/ILoginSession'; +import {INotifier} from 'app/server/lib/INotifier'; +import {ISandbox, ISandboxCreationOptions} from 'app/server/lib/ISandbox'; +import {IShell} from 'app/server/lib/IShell'; export interface ICreate { - LoginSession(comm: Comm, sid: string, domain: string, scopeSession: ScopedSession, - instanceManager: IInstanceManager|null): ILoginSession; + LoginSession(comm: Comm, sid: string, domain: string, scopeSession: ScopedSession): ILoginSession; Billing(dbManager: HomeDBManager, gristConfig: GristServer): IBilling; Notifier(dbManager: HomeDBManager, gristConfig: GristServer): INotifier; Shell(): IShell|undefined; @@ -29,8 +25,6 @@ export interface ICreate { ExternalStorage(purpose: 'doc' | 'meta', testExtraPrefix: string): ExternalStorage|undefined; ActiveDoc(docManager: DocManager, docName: string, options: ICreateActiveDocOptions): ActiveDoc; - DocManager(storageManager: IDocStorageManager, pluginManager: PluginManager, - homeDbManager: HomeDBManager|null, gristServer: GristServer): DocManager; NSandbox(options: ISandboxCreationOptions): ISandbox; sessionSecret(): string; diff --git a/app/server/lib/IInstanceManager.ts b/app/server/lib/IInstanceManager.ts deleted file mode 100644 index 51cea7c4..00000000 --- a/app/server/lib/IInstanceManager.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ILoginSession } from 'app/server/lib/ILoginSession'; - -export interface IInstanceManager { - getLoginSession(instanceId: string): ILoginSession; -} diff --git a/app/server/lib/ILoginSession.ts b/app/server/lib/ILoginSession.ts index 787df09b..c180b428 100644 --- a/app/server/lib/ILoginSession.ts +++ b/app/server/lib/ILoginSession.ts @@ -10,7 +10,4 @@ export interface ILoginSession { // For testing only. If no email address, profile is wiped, otherwise it is set. testSetProfile(profile: UserProfile|null): Promise; - updateTokenForTesting(idToken: string): Promise; - getCurrentTokenForTesting(): Promise; - useTestToken(idToken: string): Promise; } diff --git a/app/server/lib/ITestingHooks-ti.ts b/app/server/lib/ITestingHooks-ti.ts index f0b2efc1..ede0abb3 100644 --- a/app/server/lib/ITestingHooks-ti.ts +++ b/app/server/lib/ITestingHooks-ti.ts @@ -7,9 +7,6 @@ import * as t from "ts-interface-checker"; export const ITestingHooks = t.iface([], { "getOwnPort": t.func("number"), "getPort": t.func("number"), - "updateAuthToken": t.func("void", t.param("instId", "string"), t.param("authToken", "string")), - "getAuthToken": t.func(t.union("string", "null"), t.param("instId", "string")), - "useTestToken": t.func("void", t.param("instId", "string"), t.param("token", "string")), "setLoginSessionProfile": t.func("void", t.param("gristSidCookie", "string"), t.param("profile", t.union("UserProfile", "null")), t.param("org", "string", true)), "setServerVersion": t.func("void", t.param("version", t.union("string", "null"))), "disconnectClients": t.func("void"), diff --git a/app/server/lib/ITestingHooks.ts b/app/server/lib/ITestingHooks.ts index a15f8cb8..d0710a75 100644 --- a/app/server/lib/ITestingHooks.ts +++ b/app/server/lib/ITestingHooks.ts @@ -3,9 +3,6 @@ import {UserProfile} from 'app/common/LoginSessionAPI'; export interface ITestingHooks { getOwnPort(): Promise; getPort(): Promise; - updateAuthToken(instId: string, authToken: string): Promise; - getAuthToken(instId: string): Promise; - useTestToken(instId: string, token: string): Promise; setLoginSessionProfile(gristSidCookie: string, profile: UserProfile|null, org?: string): Promise; setServerVersion(version: string|null): Promise; disconnectClients(): Promise; diff --git a/app/server/lib/Sessions.ts b/app/server/lib/Sessions.ts index 411b4b0d..b6cd3ee4 100644 --- a/app/server/lib/Sessions.ts +++ b/app/server/lib/Sessions.ts @@ -2,7 +2,6 @@ import {ScopedSession} from 'app/server/lib/BrowserSession'; import * as Comm from 'app/server/lib/Comm'; import {GristServer} from 'app/server/lib/GristServer'; import {cookieName, SessionStore} from 'app/server/lib/gristSessions'; -import {IInstanceManager} from 'app/server/lib/IInstanceManager'; import {ILoginSession} from 'app/server/lib/ILoginSession'; import * as cookie from 'cookie'; import * as cookieParser from 'cookie-parser'; @@ -67,12 +66,10 @@ export class Sessions { * */ public getOrCreateLoginSession(sid: string, domain: string, comm: Comm, - instanceManager: IInstanceManager|null, userSelector: string): ILoginSession { const sess = this.getOrCreateSession(sid, domain, userSelector); if (!sess.loginSession) { - sess.loginSession = this._server.create.LoginSession(comm, sid, domain, sess.scopedSession, - instanceManager); + sess.loginSession = this._server.create.LoginSession(comm, sid, domain, sess.scopedSession); } return sess.loginSession; } diff --git a/app/server/lib/Sharing.ts b/app/server/lib/Sharing.ts index 38e2e17d..bb7adf02 100644 --- a/app/server/lib/Sharing.ts +++ b/app/server/lib/Sharing.ts @@ -1,7 +1,13 @@ -import {ActionBundle, LocalActionBundle, UserActionBundle} from 'app/common/ActionBundle'; -import {ActionInfo, Envelope, getEnvContent} from 'app/common/ActionBundle'; +import { + ActionBundle, + ActionInfo, + Envelope, + getEnvContent, + LocalActionBundle, + UserActionBundle +} from 'app/common/ActionBundle'; import {DocAction, UserAction} from 'app/common/DocActions'; -import {allToken, Peer} from 'app/common/sharing'; +import {allToken} from 'app/common/sharing'; import {timeFormat} from 'app/common/timeFormat'; import * as log from 'app/server/lib/log'; import {shortDesc} from 'app/server/lib/shortDesc'; @@ -51,16 +57,6 @@ export class Sharing { this._workCoordinator = new WorkCoordinator(() => this._doNextStep()); } - /** Initialize the sharing for a previously-shared doc. */ - public async openSharedDoc(hub: any, docId: string): Promise { - throw new Error('openSharedDoc not implemented'); - } - - /** Initialize the sharing for a newly-shared doc. */ - public async createSharedDoc(hub: any, docId: string, docName: string, peers: Peer[]): Promise { - throw new Error('openSharedDoc not implemented'); - } - /** * Returns whether this doc is shared. It's shared if and only if HubDocClient is set (though it * may be disconnected). @@ -78,10 +74,6 @@ export class Sharing { throw new Error('sendLocalAction not implemented'); } - public async shareDoc(docName: string, peers: Peer[]): Promise { - throw new Error('shareDoc not implemented'); - } - public async removeInstanceFromDoc(): Promise { throw new Error('removeInstanceFromDoc not implemented'); } diff --git a/app/server/lib/TestingHooks.ts b/app/server/lib/TestingHooks.ts index aeedf7c1..980a684c 100644 --- a/app/server/lib/TestingHooks.ts +++ b/app/server/lib/TestingHooks.ts @@ -3,19 +3,17 @@ import * as net from 'net'; import {UserProfile} from 'app/common/LoginSessionAPI'; import {Deps as ActiveDocDeps} from 'app/server/lib/ActiveDoc'; import * as Comm from 'app/server/lib/Comm'; -import {ILoginSession} from 'app/server/lib/ILoginSession'; import * as log from 'app/server/lib/log'; import {IMessage, Rpc} from 'grain-rpc'; import * as t from 'ts-interface-checker'; import {FlexServer} from './FlexServer'; -import {IInstanceManager} from './IInstanceManager'; import {ITestingHooks} from './ITestingHooks'; import ITestingHooksTI from './ITestingHooks-ti'; import {connect, fromCallback} from './serverUtils'; const tiCheckers = t.createCheckers(ITestingHooksTI, {UserProfile: t.name("object")}); -export function startTestingHooks(socketPath: string, port: number, instanceManager: IInstanceManager, +export function startTestingHooks(socketPath: string, port: number, comm: Comm, flexServer: FlexServer, workerServers: FlexServer[]): Promise { // Create socket server listening on the given path for testing connections. @@ -28,7 +26,7 @@ export function startTestingHooks(socketPath: string, port: number, instanceMana const rpc = connectToSocket(new Rpc({logger: {}}), socket); // Register the testing implementation. rpc.registerImpl('testing', - new TestingHooks(port, instanceManager, comm, flexServer, workerServers), + new TestingHooks(port, comm, flexServer, workerServers), tiCheckers.ITestingHooks); }); server.listen(socketPath); @@ -57,7 +55,6 @@ export async function connectTestingHooks(socketPath: string): Promise { - log.info("TestingHooks.updateAuthToken called with", instId, authToken); - const loginSession = this._getLoginSession(instId); - await loginSession.updateTokenForTesting(authToken); - } - - public async getAuthToken(instId: string): Promise { - log.info("TestingHooks.getAuthToken called with", instId); - const loginSession = this._getLoginSession(instId); - return await loginSession.getCurrentTokenForTesting(); - } - - public async useTestToken(instId: string, token: string): Promise { - log.info("TestingHooks.useTestToken called with", token); - const loginSession = this._getLoginSession(instId); - return await loginSession.useTestToken(token); - } - public async setLoginSessionProfile(gristSidCookie: string, profile: UserProfile|null, org?: string): Promise { log.info("TestingHooks.setLoginSessionProfile called with", gristSidCookie, profile, org); const sessionId = this._comm.getSessionIdFromCookie(gristSidCookie); @@ -201,7 +180,4 @@ export class TestingHooks implements ITestingHooks { return prev; } - private _getLoginSession(instId: string): ILoginSession { - return this._instanceManager.getLoginSession(instId); - } } diff --git a/stubs/app/server/lib/LoginSession.ts b/stubs/app/server/lib/LoginSession.ts index 886517c1..0217d3d0 100644 --- a/stubs/app/server/lib/LoginSession.ts +++ b/stubs/app/server/lib/LoginSession.ts @@ -19,13 +19,4 @@ export class LoginSession implements ILoginSession { public async testSetProfile(profile: UserProfile|null): Promise { // do nothing } - public async updateTokenForTesting(idToken: string): Promise { - // do nothing - } - public async getCurrentTokenForTesting(): Promise { - return null; - } - public async useTestToken(idToken: string): Promise { - // do nothing - } } diff --git a/stubs/app/server/lib/StandaloneExtras.ts b/stubs/app/server/lib/StandaloneExtras.ts deleted file mode 100644 index c3d4a2d1..00000000 --- a/stubs/app/server/lib/StandaloneExtras.ts +++ /dev/null @@ -1,4 +0,0 @@ -export function addStandaloneMethods(...args: any[]) { - console.log("Not adding any standalone methods"); - return {} as any; -} diff --git a/stubs/app/server/lib/create.ts b/stubs/app/server/lib/create.ts index a69f9b1d..f23ad3dd 100644 --- a/stubs/app/server/lib/create.ts +++ b/stubs/app/server/lib/create.ts @@ -1,9 +1,7 @@ -import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager'; -import { ActiveDoc } from 'app/server/lib/ActiveDoc'; -import { DocManager } from 'app/server/lib/DocManager'; -import { ICreate } from 'app/server/lib/ICreate'; -import { LoginSession } from 'app/server/lib/LoginSession'; -import { NSandboxCreator } from 'app/server/lib/NSandbox'; +import {ActiveDoc} from 'app/server/lib/ActiveDoc'; +import {ICreate} from 'app/server/lib/ICreate'; +import {LoginSession} from 'app/server/lib/LoginSession'; +import {NSandboxCreator} from 'app/server/lib/NSandbox'; // Use raw python - update when pynbox or other solution is set up for core. const sandboxCreator = new NSandboxCreator('unsandboxed'); @@ -12,11 +10,11 @@ export const create: ICreate = { LoginSession() { return new LoginSession(); }, - Billing(dbManager: HomeDBManager) { + Billing() { return { - addEndpoints(app: any) { /* do nothing */ }, + addEndpoints() { /* do nothing */ }, addEventHandlers() { /* do nothing */ }, - addWebhooks(app: any) { /* do nothing */ } + addWebhooks() { /* do nothing */ } }; }, Notifier() { @@ -32,9 +30,6 @@ export const create: ICreate = { }, ExternalStorage() { return undefined; }, ActiveDoc(docManager, docName, options) { return new ActiveDoc(docManager, docName, options); }, - DocManager(storageManager, pluginManager, homeDBManager, gristServer) { - return new DocManager(storageManager, pluginManager, homeDBManager, gristServer); - }, NSandbox(options) { return sandboxCreator.create(options); },