mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(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
This commit is contained in:
parent
61e7c8a127
commit
ea01ca814d
@ -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');
|
||||
|
@ -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");
|
||||
|
@ -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<string[]>;
|
||||
|
||||
/**
|
||||
* Shares the doc and invites peers.
|
||||
*/
|
||||
shareDoc(peers: Peer[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Removes the current instance from the doc.
|
||||
*/
|
||||
|
@ -56,12 +56,6 @@ interface SharingAPI {
|
||||
*/
|
||||
ignoreLocalInvite(docId: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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<string>;
|
||||
}
|
||||
|
||||
interface MiscAPI {
|
||||
|
@ -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<ActiveDoc> {
|
||||
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<void> {
|
||||
throw new Error('shareDoc not implemented');
|
||||
}
|
||||
|
||||
public async removeInstanceFromDoc(docSession: DocSession): Promise<void> {
|
||||
await this._sharing.removeInstanceFromDoc();
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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<string> {
|
||||
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<ActiveDoc> {
|
||||
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);
|
||||
|
@ -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),
|
||||
});
|
||||
|
@ -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;
|
||||
|
@ -1,5 +0,0 @@
|
||||
import { ILoginSession } from 'app/server/lib/ILoginSession';
|
||||
|
||||
export interface IInstanceManager {
|
||||
getLoginSession(instanceId: string): ILoginSession;
|
||||
}
|
@ -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<void>;
|
||||
updateTokenForTesting(idToken: string): Promise<void>;
|
||||
getCurrentTokenForTesting(): Promise<string|null>;
|
||||
useTestToken(idToken: string): Promise<void>;
|
||||
}
|
||||
|
@ -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"),
|
||||
|
@ -3,9 +3,6 @@ import {UserProfile} from 'app/common/LoginSessionAPI';
|
||||
export interface ITestingHooks {
|
||||
getOwnPort(): Promise<number>;
|
||||
getPort(): Promise<number>;
|
||||
updateAuthToken(instId: string, authToken: string): Promise<void>;
|
||||
getAuthToken(instId: string): Promise<string|null>;
|
||||
useTestToken(instId: string, token: string): Promise<void>;
|
||||
setLoginSessionProfile(gristSidCookie: string, profile: UserProfile|null, org?: string): Promise<void>;
|
||||
setServerVersion(version: string|null): Promise<void>;
|
||||
disconnectClients(): Promise<void>;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<void> {
|
||||
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<void> {
|
||||
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<void> {
|
||||
throw new Error('shareDoc not implemented');
|
||||
}
|
||||
|
||||
public async removeInstanceFromDoc(): Promise<string> {
|
||||
throw new Error('removeInstanceFromDoc not implemented');
|
||||
}
|
||||
|
@ -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<net.Server> {
|
||||
// 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<TestingHo
|
||||
export class TestingHooks implements ITestingHooks {
|
||||
constructor(
|
||||
private _port: number,
|
||||
private _instanceManager: IInstanceManager,
|
||||
private _comm: Comm,
|
||||
private _server: FlexServer,
|
||||
private _workerServers: FlexServer[]
|
||||
@ -73,24 +70,6 @@ export class TestingHooks implements ITestingHooks {
|
||||
return this._port;
|
||||
}
|
||||
|
||||
public async updateAuthToken(instId: string, authToken: string): Promise<void> {
|
||||
log.info("TestingHooks.updateAuthToken called with", instId, authToken);
|
||||
const loginSession = this._getLoginSession(instId);
|
||||
await loginSession.updateTokenForTesting(authToken);
|
||||
}
|
||||
|
||||
public async getAuthToken(instId: string): Promise<string|null> {
|
||||
log.info("TestingHooks.getAuthToken called with", instId);
|
||||
const loginSession = this._getLoginSession(instId);
|
||||
return await loginSession.getCurrentTokenForTesting();
|
||||
}
|
||||
|
||||
public async useTestToken(instId: string, token: string): Promise<void> {
|
||||
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<void> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,4 @@ export class LoginSession implements ILoginSession {
|
||||
public async testSetProfile(profile: UserProfile|null): Promise<void> {
|
||||
// do nothing
|
||||
}
|
||||
public async updateTokenForTesting(idToken: string): Promise<void> {
|
||||
// do nothing
|
||||
}
|
||||
public async getCurrentTokenForTesting(): Promise<string|null> {
|
||||
return null;
|
||||
}
|
||||
public async useTestToken(idToken: string): Promise<void> {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
export function addStandaloneMethods(...args: any[]) {
|
||||
console.log("Not adding any standalone methods");
|
||||
return {} as any;
|
||||
}
|
@ -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);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user