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 getNewInvites = this._wrapMethod('getNewInvites');
|
||||||
public getLocalInvites = this._wrapMethod('getLocalInvites');
|
public getLocalInvites = this._wrapMethod('getLocalInvites');
|
||||||
public ignoreLocalInvite = this._wrapMethod('ignoreLocalInvite');
|
public ignoreLocalInvite = this._wrapMethod('ignoreLocalInvite');
|
||||||
public downloadSharedDoc = this._wrapMethod('downloadSharedDoc');
|
|
||||||
public showItemInFolder = this._wrapMethod('showItemInFolder');
|
public showItemInFolder = this._wrapMethod('showItemInFolder');
|
||||||
public getBasketTables = this._wrapMethod('getBasketTables');
|
public getBasketTables = this._wrapMethod('getBasketTables');
|
||||||
public embedTable = this._wrapMethod('embedTable');
|
public embedTable = this._wrapMethod('embedTable');
|
||||||
|
@ -45,7 +45,6 @@ export class DocComm extends Disposable implements ActiveDocAPI {
|
|||||||
public getFormulaError = this._wrapMethod("getFormulaError");
|
public getFormulaError = this._wrapMethod("getFormulaError");
|
||||||
public fetchURL = this._wrapMethod("fetchURL");
|
public fetchURL = this._wrapMethod("fetchURL");
|
||||||
public autocomplete = this._wrapMethod("autocomplete");
|
public autocomplete = this._wrapMethod("autocomplete");
|
||||||
public shareDoc = this._wrapMethod("shareDoc");
|
|
||||||
public removeInstanceFromDoc = this._wrapMethod("removeInstanceFromDoc");
|
public removeInstanceFromDoc = this._wrapMethod("removeInstanceFromDoc");
|
||||||
public getActionSummaries = this._wrapMethod("getActionSummaries");
|
public getActionSummaries = this._wrapMethod("getActionSummaries");
|
||||||
public startBundleUserActions = this._wrapMethod("startBundleUserActions");
|
public startBundleUserActions = this._wrapMethod("startBundleUserActions");
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {ActionGroup} from 'app/common/ActionGroup';
|
import {ActionGroup} from 'app/common/ActionGroup';
|
||||||
import {CellValue, TableDataAction, UserAction} from 'app/common/DocActions';
|
import {CellValue, TableDataAction, UserAction} from 'app/common/DocActions';
|
||||||
import {FormulaProperties} from 'app/common/GranularAccessClause';
|
import {FormulaProperties} from 'app/common/GranularAccessClause';
|
||||||
import {Peer} from 'app/common/sharing';
|
|
||||||
import {UploadResult} from 'app/common/uploads';
|
import {UploadResult} from 'app/common/uploads';
|
||||||
import {ParseOptions} from 'app/plugin/FileParserAPI';
|
import {ParseOptions} from 'app/plugin/FileParserAPI';
|
||||||
import {IMessage} from 'grain-rpc';
|
import {IMessage} from 'grain-rpc';
|
||||||
@ -179,11 +178,6 @@ export interface ActiveDocAPI {
|
|||||||
*/
|
*/
|
||||||
autocomplete(txt: string, tableId: string): Promise<string[]>;
|
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.
|
* Removes the current instance from the doc.
|
||||||
*/
|
*/
|
||||||
|
@ -56,12 +56,6 @@ interface SharingAPI {
|
|||||||
*/
|
*/
|
||||||
ignoreLocalInvite(docId: string): Promise<void>;
|
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 {
|
interface MiscAPI {
|
||||||
|
@ -10,31 +10,38 @@ import * as bluebird from 'bluebird';
|
|||||||
import {EventEmitter} from 'events';
|
import {EventEmitter} from 'events';
|
||||||
import {IMessage, MsgType} from 'grain-rpc';
|
import {IMessage, MsgType} from 'grain-rpc';
|
||||||
import * as imageSize from 'image-size';
|
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 * as moment from 'moment-timezone';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import * as tmp from 'tmp';
|
import * as tmp from 'tmp';
|
||||||
|
|
||||||
import {getEnvContent, LocalActionBundle} from 'app/common/ActionBundle';
|
import {getEnvContent, LocalActionBundle, SandboxActionBundle, UserActionBundle} from 'app/common/ActionBundle';
|
||||||
import {SandboxActionBundle, UserActionBundle} from 'app/common/ActionBundle';
|
|
||||||
import {ActionGroup} from 'app/common/ActionGroup';
|
import {ActionGroup} from 'app/common/ActionGroup';
|
||||||
import {ApplyUAOptions, ApplyUAResult, ForkResult} from 'app/common/ActiveDocAPI';
|
import {
|
||||||
import {DataSourceTransformed, ImportResult, Query, QueryResult} from 'app/common/ActiveDocAPI';
|
ApplyUAOptions,
|
||||||
|
ApplyUAResult,
|
||||||
|
DataSourceTransformed,
|
||||||
|
ForkResult,
|
||||||
|
ImportResult,
|
||||||
|
Query,
|
||||||
|
QueryResult
|
||||||
|
} from 'app/common/ActiveDocAPI';
|
||||||
import {ApiError} from 'app/common/ApiError';
|
import {ApiError} from 'app/common/ApiError';
|
||||||
import {mapGetOrSet, MapWithTTL} from 'app/common/AsyncCreate';
|
import {mapGetOrSet, MapWithTTL} from 'app/common/AsyncCreate';
|
||||||
import {BulkColValues, CellValue, DocAction, RowRecord, TableDataAction, UserAction} from 'app/common/DocActions';
|
import {
|
||||||
import {toTableDataAction} from 'app/common/DocActions';
|
BulkColValues,
|
||||||
|
CellValue,
|
||||||
|
DocAction,
|
||||||
|
RowRecord,
|
||||||
|
TableDataAction,
|
||||||
|
toTableDataAction,
|
||||||
|
UserAction
|
||||||
|
} from 'app/common/DocActions';
|
||||||
import {DocData} from 'app/common/DocData';
|
import {DocData} from 'app/common/DocData';
|
||||||
import {DocSnapshots} from 'app/common/DocSnapshot';
|
import {DocSnapshots} from 'app/common/DocSnapshot';
|
||||||
import {EncActionBundleFromHub} from 'app/common/EncActionBundle';
|
|
||||||
import {FormulaProperties, getFormulaProperties} from 'app/common/GranularAccessClause';
|
import {FormulaProperties, getFormulaProperties} from 'app/common/GranularAccessClause';
|
||||||
import {byteString, countIf} from 'app/common/gutil';
|
import {byteString, countIf} from 'app/common/gutil';
|
||||||
import {InactivityTimer} from 'app/common/InactivityTimer';
|
import {InactivityTimer} from 'app/common/InactivityTimer';
|
||||||
import * as marshal from 'app/common/marshal';
|
import * as marshal from 'app/common/marshal';
|
||||||
import {Peer} from 'app/common/sharing';
|
|
||||||
import {UploadResult} from 'app/common/uploads';
|
import {UploadResult} from 'app/common/uploads';
|
||||||
import {DocReplacementOptions, DocState} from 'app/common/UserAPI';
|
import {DocReplacementOptions, DocState} from 'app/common/UserAPI';
|
||||||
import {ParseOptions} from 'app/plugin/FileParserAPI';
|
import {ParseOptions} from 'app/plugin/FileParserAPI';
|
||||||
@ -55,13 +62,23 @@ import {ActionHistoryImpl} from './ActionHistoryImpl';
|
|||||||
import {ActiveDocImport} from './ActiveDocImport';
|
import {ActiveDocImport} from './ActiveDocImport';
|
||||||
import {DocClients} from './DocClients';
|
import {DocClients} from './DocClients';
|
||||||
import {DocPluginManager} from './DocPluginManager';
|
import {DocPluginManager} from './DocPluginManager';
|
||||||
import {DocSession, getDocSessionAccess, getDocSessionUser, getDocSessionUserId,
|
import {
|
||||||
makeExceptionalDocSession, OptDocSession} from './DocSession';
|
DocSession,
|
||||||
|
getDocSessionAccess,
|
||||||
|
getDocSessionUser,
|
||||||
|
getDocSessionUserId,
|
||||||
|
makeExceptionalDocSession,
|
||||||
|
OptDocSession
|
||||||
|
} from './DocSession';
|
||||||
import {DocStorage} from './DocStorage';
|
import {DocStorage} from './DocStorage';
|
||||||
import {expandQuery} from './ExpandedQuery';
|
import {expandQuery} from './ExpandedQuery';
|
||||||
import {GranularAccess, GranularAccessForBundle} from './GranularAccess';
|
import {GranularAccess, GranularAccessForBundle} from './GranularAccess';
|
||||||
import {OnDemandActions} from './OnDemandActions';
|
import {OnDemandActions} from './OnDemandActions';
|
||||||
import {findOrAddAllEnvelope, Sharing} from './Sharing';
|
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);
|
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.
|
* 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);
|
}, this.recoveryMode, this._docManager.getHomeDbManager(), this.docName);
|
||||||
await this._granularAccess.update();
|
await this._granularAccess.update();
|
||||||
this._sharing = new Sharing(this, this._actionHistory, this._modificationLock);
|
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);
|
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> {
|
public async removeInstanceFromDoc(docSession: DocSession): Promise<void> {
|
||||||
await this._sharing.removeInstanceFromDoc();
|
await this._sharing.removeInstanceFromDoc();
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,6 @@ function Comm(server, options) {
|
|||||||
this.sessions = options.sessions;
|
this.sessions = options.sessions;
|
||||||
|
|
||||||
this._settings = options.settings;
|
this._settings = options.settings;
|
||||||
this._instanceManager = options.instanceManager;
|
|
||||||
this._hosts = options.hosts;
|
this._hosts = options.hosts;
|
||||||
|
|
||||||
// This maps method names to their implementation.
|
// This maps method names to their implementation.
|
||||||
@ -125,7 +124,7 @@ Comm.prototype.getClient = function(clientId) {
|
|||||||
Comm.prototype.getOrCreateSession = function(sid, req, userSelector) {
|
Comm.prototype.getOrCreateSession = function(sid, req, userSelector) {
|
||||||
// LoginSessions are specific to a session id / org combination.
|
// LoginSessions are specific to a session id / org combination.
|
||||||
const org = req.org || "";
|
const org = req.org || "";
|
||||||
return this.sessions.getOrCreateLoginSession(sid, org, this, this._instanceManager,
|
return this.sessions.getOrCreateLoginSession(sid, org, this,
|
||||||
userSelector);
|
userSelector);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
import * as pidusage from '@gristlabs/pidusage';
|
import * as pidusage from '@gristlabs/pidusage';
|
||||||
import * as bluebird from 'bluebird';
|
import * as bluebird from 'bluebird';
|
||||||
import {EventEmitter} from 'events';
|
import {EventEmitter} from 'events';
|
||||||
import noop = require('lodash/noop');
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import {ApiError} from 'app/common/ApiError';
|
import {ApiError} from 'app/common/ApiError';
|
||||||
import {mapSetOrClear} from 'app/common/AsyncCreate';
|
import {mapSetOrClear} from 'app/common/AsyncCreate';
|
||||||
import {BrowserSettings} from 'app/common/BrowserSettings';
|
import {BrowserSettings} from 'app/common/BrowserSettings';
|
||||||
import {DocCreationInfo, DocEntry, DocListAPI, OpenDocMode, OpenLocalDocResult} from 'app/common/DocListAPI';
|
import {DocCreationInfo, DocEntry, DocListAPI, OpenDocMode, OpenLocalDocResult} from 'app/common/DocListAPI';
|
||||||
import {EncActionBundleFromHub} from 'app/common/EncActionBundle';
|
|
||||||
import {Invite} from 'app/common/sharing';
|
import {Invite} from 'app/common/sharing';
|
||||||
import {tbind} from 'app/common/tbind';
|
import {tbind} from 'app/common/tbind';
|
||||||
import {NEW_DOCUMENT_CODE} from 'app/common/UserAPI';
|
import {NEW_DOCUMENT_CODE} from 'app/common/UserAPI';
|
||||||
import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager';
|
import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager';
|
||||||
import {assertAccess, Authorizer, DocAuthorizer, DummyAuthorizer,
|
import {assertAccess, Authorizer, DocAuthorizer, DummyAuthorizer, isSingleUserMode} from 'app/server/lib/Authorizer';
|
||||||
isSingleUserMode} from 'app/server/lib/Authorizer';
|
|
||||||
import {Client} from 'app/server/lib/Client';
|
import {Client} from 'app/server/lib/Client';
|
||||||
import {getDocSessionCachedDoc, makeExceptionalDocSession, makeOptDocSession} from 'app/server/lib/DocSession';
|
import {
|
||||||
import {OptDocSession} from 'app/server/lib/DocSession';
|
getDocSessionCachedDoc,
|
||||||
|
makeExceptionalDocSession,
|
||||||
|
makeOptDocSession,
|
||||||
|
OptDocSession
|
||||||
|
} from 'app/server/lib/DocSession';
|
||||||
import * as docUtils from 'app/server/lib/docUtils';
|
import * as docUtils from 'app/server/lib/docUtils';
|
||||||
import {GristServer} from 'app/server/lib/GristServer';
|
import {GristServer} from 'app/server/lib/GristServer';
|
||||||
import {IDocStorageManager} from 'app/server/lib/IDocStorageManager';
|
import {IDocStorageManager} from 'app/server/lib/IDocStorageManager';
|
||||||
@ -26,6 +27,7 @@ import * as log from 'app/server/lib/log';
|
|||||||
import {ActiveDoc} from './ActiveDoc';
|
import {ActiveDoc} from './ActiveDoc';
|
||||||
import {PluginManager} from './PluginManager';
|
import {PluginManager} from './PluginManager';
|
||||||
import {getFileUploadInfo, globalUploadSet, makeAccessId, UploadInfo} from './uploads';
|
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
|
// A TTL in milliseconds to use for material that can easily be recomputed / refetched
|
||||||
// but is a bit of a burden under heavy traffic.
|
// but is a bit of a burden under heavy traffic.
|
||||||
@ -123,15 +125,6 @@ export class DocManager extends EventEmitter {
|
|||||||
return activeDoc.docName;
|
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.
|
* Creates a new document, fetches it, and adds a table to it.
|
||||||
* @param {String} sampleDocName: Doc name of a sample document.
|
* @param {String} sampleDocName: Doc name of a sample document.
|
||||||
@ -417,23 +410,6 @@ export class DocManager extends EventEmitter {
|
|||||||
return userId === this._homeDbManager.getAnonymousUserId();
|
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) {
|
private async _createActiveDoc(docSession: OptDocSession, docName: string, safeMode?: boolean) {
|
||||||
// Get URL for document for use with SELF_HYPERLINK().
|
// Get URL for document for use with SELF_HYPERLINK().
|
||||||
const cachedDoc = getDocSessionCachedDoc(docSession);
|
const cachedDoc = getDocSessionCachedDoc(docSession);
|
||||||
|
@ -743,7 +743,6 @@ export class FlexServer implements GristServer {
|
|||||||
this.comm = new Comm(this.server, {
|
this.comm = new Comm(this.server, {
|
||||||
settings: this.settings,
|
settings: this.settings,
|
||||||
sessions: this.sessions,
|
sessions: this.sessions,
|
||||||
instanceStore: null, // no instanceStore
|
|
||||||
hosts: this._hosts,
|
hosts: this._hosts,
|
||||||
httpsServer: this.httpsServer,
|
httpsServer: this.httpsServer,
|
||||||
});
|
});
|
||||||
@ -846,7 +845,7 @@ export class FlexServer implements GristServer {
|
|||||||
|
|
||||||
public async addTestingHooks(workerServers?: FlexServer[]) {
|
public async addTestingHooks(workerServers?: FlexServer[]) {
|
||||||
if (process.env.GRIST_TESTING_SOCKET) {
|
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 || []);
|
workerServers || []);
|
||||||
this._hasTestingHooks = true;
|
this._hasTestingHooks = true;
|
||||||
}
|
}
|
||||||
@ -900,16 +899,7 @@ export class FlexServer implements GristServer {
|
|||||||
|
|
||||||
shutdown.addCleanupHandler(null, this._shutdown.bind(this), 25000, 'FlexServer._shutdown');
|
shutdown.addCleanupHandler(null, this._shutdown.bind(this), 25000, 'FlexServer._shutdown');
|
||||||
|
|
||||||
if (isSingleUserMode()) {
|
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 {
|
|
||||||
this.comm.registerMethods({
|
this.comm.registerMethods({
|
||||||
openDoc: docManager.openDoc.bind(docManager),
|
openDoc: docManager.openDoc.bind(docManager),
|
||||||
});
|
});
|
||||||
|
@ -1,22 +1,18 @@
|
|||||||
import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager';
|
import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager';
|
||||||
import { ActiveDoc } from 'app/server/lib/ActiveDoc';
|
import {ActiveDoc} from 'app/server/lib/ActiveDoc';
|
||||||
import { ScopedSession } from 'app/server/lib/BrowserSession';
|
import {ScopedSession} from 'app/server/lib/BrowserSession';
|
||||||
import * as Comm from 'app/server/lib/Comm';
|
import * as Comm from 'app/server/lib/Comm';
|
||||||
import { DocManager } from 'app/server/lib/DocManager';
|
import {DocManager} from 'app/server/lib/DocManager';
|
||||||
import { ExternalStorage } from 'app/server/lib/ExternalStorage';
|
import {ExternalStorage} from 'app/server/lib/ExternalStorage';
|
||||||
import { GristServer } from 'app/server/lib/GristServer';
|
import {GristServer} from 'app/server/lib/GristServer';
|
||||||
import { IBilling } from 'app/server/lib/IBilling';
|
import {IBilling} from 'app/server/lib/IBilling';
|
||||||
import { IDocStorageManager } from 'app/server/lib/IDocStorageManager';
|
import {ILoginSession} from 'app/server/lib/ILoginSession';
|
||||||
import { IInstanceManager } from 'app/server/lib/IInstanceManager';
|
import {INotifier} from 'app/server/lib/INotifier';
|
||||||
import { ILoginSession } from 'app/server/lib/ILoginSession';
|
import {ISandbox, ISandboxCreationOptions} from 'app/server/lib/ISandbox';
|
||||||
import { INotifier } from 'app/server/lib/INotifier';
|
import {IShell} from 'app/server/lib/IShell';
|
||||||
import { ISandbox, ISandboxCreationOptions } from 'app/server/lib/ISandbox';
|
|
||||||
import { IShell } from 'app/server/lib/IShell';
|
|
||||||
import { PluginManager } from 'app/server/lib/PluginManager';
|
|
||||||
|
|
||||||
export interface ICreate {
|
export interface ICreate {
|
||||||
LoginSession(comm: Comm, sid: string, domain: string, scopeSession: ScopedSession,
|
LoginSession(comm: Comm, sid: string, domain: string, scopeSession: ScopedSession): ILoginSession;
|
||||||
instanceManager: IInstanceManager|null): ILoginSession;
|
|
||||||
Billing(dbManager: HomeDBManager, gristConfig: GristServer): IBilling;
|
Billing(dbManager: HomeDBManager, gristConfig: GristServer): IBilling;
|
||||||
Notifier(dbManager: HomeDBManager, gristConfig: GristServer): INotifier;
|
Notifier(dbManager: HomeDBManager, gristConfig: GristServer): INotifier;
|
||||||
Shell(): IShell|undefined;
|
Shell(): IShell|undefined;
|
||||||
@ -29,8 +25,6 @@ export interface ICreate {
|
|||||||
ExternalStorage(purpose: 'doc' | 'meta', testExtraPrefix: string): ExternalStorage|undefined;
|
ExternalStorage(purpose: 'doc' | 'meta', testExtraPrefix: string): ExternalStorage|undefined;
|
||||||
|
|
||||||
ActiveDoc(docManager: DocManager, docName: string, options: ICreateActiveDocOptions): ActiveDoc;
|
ActiveDoc(docManager: DocManager, docName: string, options: ICreateActiveDocOptions): ActiveDoc;
|
||||||
DocManager(storageManager: IDocStorageManager, pluginManager: PluginManager,
|
|
||||||
homeDbManager: HomeDBManager|null, gristServer: GristServer): DocManager;
|
|
||||||
NSandbox(options: ISandboxCreationOptions): ISandbox;
|
NSandbox(options: ISandboxCreationOptions): ISandbox;
|
||||||
|
|
||||||
sessionSecret(): string;
|
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.
|
// For testing only. If no email address, profile is wiped, otherwise it is set.
|
||||||
testSetProfile(profile: UserProfile|null): Promise<void>;
|
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([], {
|
export const ITestingHooks = t.iface([], {
|
||||||
"getOwnPort": t.func("number"),
|
"getOwnPort": t.func("number"),
|
||||||
"getPort": 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)),
|
"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"))),
|
"setServerVersion": t.func("void", t.param("version", t.union("string", "null"))),
|
||||||
"disconnectClients": t.func("void"),
|
"disconnectClients": t.func("void"),
|
||||||
|
@ -3,9 +3,6 @@ import {UserProfile} from 'app/common/LoginSessionAPI';
|
|||||||
export interface ITestingHooks {
|
export interface ITestingHooks {
|
||||||
getOwnPort(): Promise<number>;
|
getOwnPort(): Promise<number>;
|
||||||
getPort(): 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>;
|
setLoginSessionProfile(gristSidCookie: string, profile: UserProfile|null, org?: string): Promise<void>;
|
||||||
setServerVersion(version: string|null): Promise<void>;
|
setServerVersion(version: string|null): Promise<void>;
|
||||||
disconnectClients(): 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 * as Comm from 'app/server/lib/Comm';
|
||||||
import {GristServer} from 'app/server/lib/GristServer';
|
import {GristServer} from 'app/server/lib/GristServer';
|
||||||
import {cookieName, SessionStore} from 'app/server/lib/gristSessions';
|
import {cookieName, SessionStore} from 'app/server/lib/gristSessions';
|
||||||
import {IInstanceManager} from 'app/server/lib/IInstanceManager';
|
|
||||||
import {ILoginSession} from 'app/server/lib/ILoginSession';
|
import {ILoginSession} from 'app/server/lib/ILoginSession';
|
||||||
import * as cookie from 'cookie';
|
import * as cookie from 'cookie';
|
||||||
import * as cookieParser from 'cookie-parser';
|
import * as cookieParser from 'cookie-parser';
|
||||||
@ -67,12 +66,10 @@ export class Sessions {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public getOrCreateLoginSession(sid: string, domain: string, comm: Comm,
|
public getOrCreateLoginSession(sid: string, domain: string, comm: Comm,
|
||||||
instanceManager: IInstanceManager|null,
|
|
||||||
userSelector: string): ILoginSession {
|
userSelector: string): ILoginSession {
|
||||||
const sess = this.getOrCreateSession(sid, domain, userSelector);
|
const sess = this.getOrCreateSession(sid, domain, userSelector);
|
||||||
if (!sess.loginSession) {
|
if (!sess.loginSession) {
|
||||||
sess.loginSession = this._server.create.LoginSession(comm, sid, domain, sess.scopedSession,
|
sess.loginSession = this._server.create.LoginSession(comm, sid, domain, sess.scopedSession);
|
||||||
instanceManager);
|
|
||||||
}
|
}
|
||||||
return sess.loginSession;
|
return sess.loginSession;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import {ActionBundle, LocalActionBundle, UserActionBundle} from 'app/common/ActionBundle';
|
import {
|
||||||
import {ActionInfo, Envelope, getEnvContent} from 'app/common/ActionBundle';
|
ActionBundle,
|
||||||
|
ActionInfo,
|
||||||
|
Envelope,
|
||||||
|
getEnvContent,
|
||||||
|
LocalActionBundle,
|
||||||
|
UserActionBundle
|
||||||
|
} from 'app/common/ActionBundle';
|
||||||
import {DocAction, UserAction} from 'app/common/DocActions';
|
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 {timeFormat} from 'app/common/timeFormat';
|
||||||
import * as log from 'app/server/lib/log';
|
import * as log from 'app/server/lib/log';
|
||||||
import {shortDesc} from 'app/server/lib/shortDesc';
|
import {shortDesc} from 'app/server/lib/shortDesc';
|
||||||
@ -51,16 +57,6 @@ export class Sharing {
|
|||||||
this._workCoordinator = new WorkCoordinator(() => this._doNextStep());
|
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
|
* Returns whether this doc is shared. It's shared if and only if HubDocClient is set (though it
|
||||||
* may be disconnected).
|
* may be disconnected).
|
||||||
@ -78,10 +74,6 @@ export class Sharing {
|
|||||||
throw new Error('sendLocalAction not implemented');
|
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> {
|
public async removeInstanceFromDoc(): Promise<string> {
|
||||||
throw new Error('removeInstanceFromDoc not implemented');
|
throw new Error('removeInstanceFromDoc not implemented');
|
||||||
}
|
}
|
||||||
|
@ -3,19 +3,17 @@ import * as net from 'net';
|
|||||||
import {UserProfile} from 'app/common/LoginSessionAPI';
|
import {UserProfile} from 'app/common/LoginSessionAPI';
|
||||||
import {Deps as ActiveDocDeps} from 'app/server/lib/ActiveDoc';
|
import {Deps as ActiveDocDeps} from 'app/server/lib/ActiveDoc';
|
||||||
import * as Comm from 'app/server/lib/Comm';
|
import * as Comm from 'app/server/lib/Comm';
|
||||||
import {ILoginSession} from 'app/server/lib/ILoginSession';
|
|
||||||
import * as log from 'app/server/lib/log';
|
import * as log from 'app/server/lib/log';
|
||||||
import {IMessage, Rpc} from 'grain-rpc';
|
import {IMessage, Rpc} from 'grain-rpc';
|
||||||
import * as t from 'ts-interface-checker';
|
import * as t from 'ts-interface-checker';
|
||||||
import {FlexServer} from './FlexServer';
|
import {FlexServer} from './FlexServer';
|
||||||
import {IInstanceManager} from './IInstanceManager';
|
|
||||||
import {ITestingHooks} from './ITestingHooks';
|
import {ITestingHooks} from './ITestingHooks';
|
||||||
import ITestingHooksTI from './ITestingHooks-ti';
|
import ITestingHooksTI from './ITestingHooks-ti';
|
||||||
import {connect, fromCallback} from './serverUtils';
|
import {connect, fromCallback} from './serverUtils';
|
||||||
|
|
||||||
const tiCheckers = t.createCheckers(ITestingHooksTI, {UserProfile: t.name("object")});
|
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,
|
comm: Comm, flexServer: FlexServer,
|
||||||
workerServers: FlexServer[]): Promise<net.Server> {
|
workerServers: FlexServer[]): Promise<net.Server> {
|
||||||
// Create socket server listening on the given path for testing connections.
|
// 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);
|
const rpc = connectToSocket(new Rpc({logger: {}}), socket);
|
||||||
// Register the testing implementation.
|
// Register the testing implementation.
|
||||||
rpc.registerImpl('testing',
|
rpc.registerImpl('testing',
|
||||||
new TestingHooks(port, instanceManager, comm, flexServer, workerServers),
|
new TestingHooks(port, comm, flexServer, workerServers),
|
||||||
tiCheckers.ITestingHooks);
|
tiCheckers.ITestingHooks);
|
||||||
});
|
});
|
||||||
server.listen(socketPath);
|
server.listen(socketPath);
|
||||||
@ -57,7 +55,6 @@ export async function connectTestingHooks(socketPath: string): Promise<TestingHo
|
|||||||
export class TestingHooks implements ITestingHooks {
|
export class TestingHooks implements ITestingHooks {
|
||||||
constructor(
|
constructor(
|
||||||
private _port: number,
|
private _port: number,
|
||||||
private _instanceManager: IInstanceManager,
|
|
||||||
private _comm: Comm,
|
private _comm: Comm,
|
||||||
private _server: FlexServer,
|
private _server: FlexServer,
|
||||||
private _workerServers: FlexServer[]
|
private _workerServers: FlexServer[]
|
||||||
@ -73,24 +70,6 @@ export class TestingHooks implements ITestingHooks {
|
|||||||
return this._port;
|
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> {
|
public async setLoginSessionProfile(gristSidCookie: string, profile: UserProfile|null, org?: string): Promise<void> {
|
||||||
log.info("TestingHooks.setLoginSessionProfile called with", gristSidCookie, profile, org);
|
log.info("TestingHooks.setLoginSessionProfile called with", gristSidCookie, profile, org);
|
||||||
const sessionId = this._comm.getSessionIdFromCookie(gristSidCookie);
|
const sessionId = this._comm.getSessionIdFromCookie(gristSidCookie);
|
||||||
@ -201,7 +180,4 @@ export class TestingHooks implements ITestingHooks {
|
|||||||
return prev;
|
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> {
|
public async testSetProfile(profile: UserProfile|null): Promise<void> {
|
||||||
// do nothing
|
// 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 { ActiveDoc } from 'app/server/lib/ActiveDoc';
|
import {ICreate} from 'app/server/lib/ICreate';
|
||||||
import { DocManager } from 'app/server/lib/DocManager';
|
import {LoginSession} from 'app/server/lib/LoginSession';
|
||||||
import { ICreate } from 'app/server/lib/ICreate';
|
import {NSandboxCreator} from 'app/server/lib/NSandbox';
|
||||||
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.
|
// Use raw python - update when pynbox or other solution is set up for core.
|
||||||
const sandboxCreator = new NSandboxCreator('unsandboxed');
|
const sandboxCreator = new NSandboxCreator('unsandboxed');
|
||||||
@ -12,11 +10,11 @@ export const create: ICreate = {
|
|||||||
LoginSession() {
|
LoginSession() {
|
||||||
return new LoginSession();
|
return new LoginSession();
|
||||||
},
|
},
|
||||||
Billing(dbManager: HomeDBManager) {
|
Billing() {
|
||||||
return {
|
return {
|
||||||
addEndpoints(app: any) { /* do nothing */ },
|
addEndpoints() { /* do nothing */ },
|
||||||
addEventHandlers() { /* do nothing */ },
|
addEventHandlers() { /* do nothing */ },
|
||||||
addWebhooks(app: any) { /* do nothing */ }
|
addWebhooks() { /* do nothing */ }
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
Notifier() {
|
Notifier() {
|
||||||
@ -32,9 +30,6 @@ export const create: ICreate = {
|
|||||||
},
|
},
|
||||||
ExternalStorage() { return undefined; },
|
ExternalStorage() { return undefined; },
|
||||||
ActiveDoc(docManager, docName, options) { return new ActiveDoc(docManager, docName, options); },
|
ActiveDoc(docManager, docName, options) { return new ActiveDoc(docManager, docName, options); },
|
||||||
DocManager(storageManager, pluginManager, homeDBManager, gristServer) {
|
|
||||||
return new DocManager(storageManager, pluginManager, homeDBManager, gristServer);
|
|
||||||
},
|
|
||||||
NSandbox(options) {
|
NSandbox(options) {
|
||||||
return sandboxCreator.create(options);
|
return sandboxCreator.create(options);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user