diff --git a/app/server/lib/ActiveDoc.ts b/app/server/lib/ActiveDoc.ts index bb4ce879..c37f405e 100644 --- a/app/server/lib/ActiveDoc.ts +++ b/app/server/lib/ActiveDoc.ts @@ -80,7 +80,7 @@ import {guessColInfo} from 'app/common/ValueGuesser'; import {parseUserAction} from 'app/common/ValueParser'; import {TEMPLATES_ORG_DOMAIN} from 'app/gen-server/ApiServer'; import {Document} from 'app/gen-server/entity/Document'; -import {ParseOptions} from 'app/plugin/FileParserAPI'; +import {ParseFileResult, ParseOptions} from 'app/plugin/FileParserAPI'; import {AccessTokenOptions, AccessTokenResult, GristDocAPI} from 'app/plugin/GristAPI'; import {compileAclFormula} from 'app/server/lib/ACLFormula'; import {AssistanceSchemaPromptV1Context} from 'app/server/lib/Assistance'; @@ -113,7 +113,7 @@ import tmp from 'tmp'; import {ActionHistory} from './ActionHistory'; import {ActionHistoryImpl} from './ActionHistoryImpl'; -import {ActiveDocImport} from './ActiveDocImport'; +import {ActiveDocImport, FileImportOptions} from './ActiveDocImport'; import {DocClients} from './DocClients'; import {DocPluginManager} from './DocPluginManager'; import { @@ -773,6 +773,17 @@ export class ActiveDoc extends EventEmitter { await this._activeDocImport.oneStepImport(docSession, uploadInfo); } + /** + * Import data resulting from parsing a file into a new table. + * In normal circumstances this is only used internally. + * It's exposed publicly for use by grist-static which doesn't use the plugin system. + */ + public async importParsedFileAsNewTable( + docSession: OptDocSession, optionsAndData: ParseFileResult, importOptions: FileImportOptions + ): Promise { + return this._activeDocImport.importParsedFileAsNewTable(docSession, optionsAndData, importOptions); + } + /** * This function saves attachments from a given upload and creates an entry for them in the database. * It returns the list of rowIds for the rows created in the _grist_Attachments table. diff --git a/app/server/lib/ActiveDocImport.ts b/app/server/lib/ActiveDocImport.ts index d30b0da8..3e86fcd5 100644 --- a/app/server/lib/ActiveDocImport.ts +++ b/app/server/lib/ActiveDocImport.ts @@ -44,7 +44,7 @@ interface ReferenceDescription { refTableId: string; } -interface FileImportOptions { +export interface FileImportOptions { // Suggested name of the import file. It is sometimes used as a suggested table name, e.g. for csv imports. originalFilename: string; // Containing parseOptions as serialized JSON to pass to the import plugin.