@flatfile/sdk
Advanced tools
Comparing version 2.0.0-rc7 to 2.0.0-rc8
@@ -6,2 +6,3 @@ import { FlatfileError } from './FlatfileError'; | ||
userMessage: string; | ||
name: string; | ||
} |
@@ -6,9 +6,6 @@ import { FlatfileError } from './errors/FlatfileError'; | ||
import { TypedEventManager } from './lib/TypedEventManager'; | ||
import { IEvents, IFlatfileConfig, IFlatfileImporterConfig, IRawToken, JsonWebToken } from './types'; | ||
import { UIService } from './service/UIService'; | ||
import { IEvents, IFlatfileConfig, IFlatfileImporterConfig, IImportSessionConfig, IRawToken, JsonWebToken } from './types'; | ||
export declare class Flatfile extends TypedEventManager<IEvents> { | ||
/** | ||
* Reference to a pre-authenticated instance of the API service | ||
*/ | ||
readonly api: ApiService; | ||
/** | ||
* The configuration of this instance of Flatfile with defaults merged in | ||
@@ -18,10 +15,17 @@ */ | ||
/** | ||
* JWT for securing user data while interacting with Flatfile | ||
* Reference to a pre-authenticated instance of the API service | ||
*/ | ||
readonly token: JsonWebToken; | ||
constructor(token: JsonWebToken, config?: IFlatfileImporterConfig); | ||
api?: ApiService; | ||
ui: UIService; | ||
constructor(config: IFlatfileImporterConfig); | ||
constructor(token: string, config: IFlatfileImporterConfig); | ||
token(): Promise<JsonWebToken>; | ||
/** | ||
* Creates a new pre-authenticated instance of the API service | ||
*/ | ||
private initApi; | ||
/** | ||
* Start a new import or resume the one that's currently in progress | ||
*/ | ||
startOrResumeImportSession(options?: IOpenOptions): Promise<ImportSession>; | ||
startOrResumeImportSession(options?: IOpenOptions & IChunkOptions & IImportSessionConfig): Promise<ImportSession>; | ||
/** | ||
@@ -31,5 +35,5 @@ * Simple function that abstracts away some of the complexity for a single line call | ||
*/ | ||
requestDataFromUser(): this; | ||
requestDataFromUser(opts: DataReqOptions): this; | ||
requestDataFromUser(callback: IteratorCallback, opts?: DataReqOptions): this; | ||
requestDataFromUser(): void; | ||
requestDataFromUser(opts: DataReqOptions): void; | ||
requestDataFromUser(cb: IteratorCallback, opts?: DataReqOptions): void; | ||
handleError(error: FlatfileError): void; | ||
@@ -46,2 +50,4 @@ /** | ||
static getDevelopmentToken(embedId: string, body?: IRawToken, key?: string): Promise<JsonWebToken>; | ||
static requestDataFromUser(options: DataReqOptions & IFlatfileImporterConfig): void; | ||
private static extractImporterOptions; | ||
/** | ||
@@ -59,3 +65,3 @@ * Merge in any user provided configuration with defaults. | ||
} | ||
declare type DataReqOptions = IOpenOptions & IChunkOptions; | ||
declare type DataReqOptions = IOpenOptions & IChunkOptions & IImportSessionConfig; | ||
export {}; |
import { ClientError, GraphQLClient } from 'graphql-request'; | ||
import { GraphQLError } from 'graphql-request/dist/types'; | ||
import { SubscriptionClient } from 'graphql-subscriptions-client'; | ||
@@ -8,3 +9,2 @@ import { IImportMeta, ImportSession } from '../importer/ImportSession'; | ||
import { GetFinalDatabaseViewResponse } from './queries/GET_FINAL_DATABASE_VIEW'; | ||
import { BatchStatusUpdatedResponse } from './subscriptions/BATCH_STATUS_UPDATED'; | ||
export declare class ApiService { | ||
@@ -78,6 +78,6 @@ token: string; | ||
*/ | ||
subscribeBatchStatusUpdated(batchId: string, observe: (d: BatchStatusUpdatedResponse) => void): void; | ||
subscribeBatchStatusUpdated(batchId: string, observe: (status: string) => void): void; | ||
handleRawError(error?: ClientError | Error | string): void; | ||
handleError(errors?: ClientError['response']['errors'], message?: string): void; | ||
handleGraphQLErrors(errors?: GraphQLError[], message?: string): void; | ||
handleResponse<T, K extends keyof T>(queryName: K, query: Promise<T>): Promise<T[K]>; | ||
} |
@@ -0,6 +1,12 @@ | ||
import { TypedEventManager } from '../lib/TypedEventManager'; | ||
import { UIService } from '../service/UIService'; | ||
import { ImportSession, IUrlOptions } from './ImportSession'; | ||
export declare class ImportFrame { | ||
private batch; | ||
export interface IImportFrameEvents { | ||
load: void; | ||
} | ||
export declare class ImportFrame extends TypedEventManager<IImportFrameEvents> { | ||
private session; | ||
ui: UIService; | ||
private $iframe?; | ||
constructor(batch: ImportSession); | ||
constructor(session: ImportSession); | ||
open(options?: IUrlOptions): this; | ||
@@ -12,5 +18,2 @@ /** | ||
private createIFrameElement; | ||
private initializeFlatfileWrapper; | ||
private get $close(); | ||
private get $container(); | ||
} |
@@ -1,13 +0,18 @@ | ||
import { Flatfile } from '../Flatfile'; | ||
import { Flatfile } from 'Flatfile'; | ||
import { UIService } from 'service/UIService'; | ||
import { ApiService } from '../graphql/ApiService'; | ||
import { GetFinalDatabaseViewResponse } from '../graphql/queries/GET_FINAL_DATABASE_VIEW'; | ||
import { IteratorCallback } from '../lib/RecordChunkIterator'; | ||
import { IteratorCallback, RecordChunkIterator } from '../lib/RecordChunkIterator'; | ||
import { TypedEventManager } from '../lib/TypedEventManager'; | ||
import { TPrimitive } from '../service/FlatfileRecord'; | ||
import { ImportFrame } from './ImportFrame'; | ||
export declare class ImportSession extends TypedEventManager<IBatchEvents> { | ||
export declare class ImportSession extends TypedEventManager<IImportSessionEvents> { | ||
flatfile: Flatfile; | ||
meta: IImportMeta; | ||
ui: UIService; | ||
api: ApiService; | ||
private $iframe?; | ||
batchId: string; | ||
constructor(flatfile: Flatfile, meta: IImportMeta); | ||
get batchId(): string; | ||
init(): Promise<IImportMeta>; | ||
/** | ||
@@ -38,6 +43,3 @@ * Open the importer in an iframe (recommended) | ||
*/ | ||
processPendingRecords(cb: IteratorCallback, options?: IChunkOptions): Promise<void>; | ||
/** | ||
* @todo make this less lines and more readable | ||
*/ | ||
processPendingRecords(cb: IteratorCallback, options?: IChunkOptions): Promise<RecordChunkIterator>; | ||
private subscribeToBatchStatus; | ||
@@ -50,4 +52,7 @@ /** | ||
} | ||
export interface IBatchEvents { | ||
init: IImportMeta; | ||
export interface IImportSessionEvents { | ||
init: { | ||
session: ImportSession; | ||
meta: IImportMeta; | ||
}; | ||
upload: { | ||
@@ -71,2 +76,3 @@ uploadId: string; | ||
batchId: string; | ||
mountUrl?: string; | ||
workspaceId: string; | ||
@@ -73,0 +79,0 @@ workbookId?: string; |
export declare function sign(payload: Record<string, any>, key: string): Promise<string>; | ||
export declare function isJWT(str: string): boolean; |
@@ -1,3 +0,2 @@ | ||
import { FlatfileRecords, FlatfileSession } from '@flatfile/hooks/dist/src'; | ||
export declare function serializeHook(fn: (payload: FlatfileRecords, session: FlatfileSession) => void): string; | ||
export declare function serializeHook(fn: (payload: any, session: any) => void): string; | ||
export declare function serializeFunction(fn: (...args: any[]) => any): string; |
@@ -10,3 +10,3 @@ import { IEvents } from '../types'; | ||
listen<K extends keyof T>(event: K, cb: (e: T[K]) => void): () => this; | ||
on<K extends keyof T>(event: K, cb: (e: T[K]) => void): this; | ||
on<K extends keyof T>(event: K, cb: (e: T[K]) => void | Promise<void>): this; | ||
off<K extends keyof T>(event: K, cb: (e: T[K]) => void): this; | ||
@@ -13,0 +13,0 @@ cleanup(): this; |
@@ -0,1 +1,3 @@ | ||
import { IImportMeta, IImportSessionEvents, ImportSession } from 'importer/ImportSession'; | ||
import { IteratorCallback } from 'lib/RecordChunkIterator'; | ||
import { FlatfileError } from './errors/FlatfileError'; | ||
@@ -6,2 +8,7 @@ import { GetFinalDatabaseViewResponse } from './graphql/queries/GET_FINAL_DATABASE_VIEW'; | ||
apiUrl?: string; | ||
token?: JsonWebToken; | ||
embedId?: string; | ||
user?: IUser; | ||
org?: IOrganization; | ||
onAuth?: () => JsonWebToken | Promise<JsonWebToken>; | ||
} | ||
@@ -11,10 +18,20 @@ export interface IFlatfileConfig { | ||
apiUrl: string; | ||
token?: JsonWebToken; | ||
embedId?: string; | ||
user?: IUser; | ||
org?: IOrganization; | ||
onAuth?: () => JsonWebToken | Promise<JsonWebToken>; | ||
} | ||
export interface IImportSessionConfig { | ||
onInit?: (payload: IImportSessionEvents['init']) => void | Promise<void>; | ||
onData?: IteratorCallback; | ||
onComplete?: (payload: IImportSessionEvents['complete']) => void | Promise<void>; | ||
onError?: (payload: { | ||
error: Error; | ||
}) => void | Promise<void>; | ||
} | ||
export interface IEvents { | ||
init: { | ||
batchId: string; | ||
schemas: { | ||
id: number; | ||
}[]; | ||
workspaceId: string; | ||
session: ImportSession; | ||
meta: IImportMeta; | ||
}; | ||
@@ -21,0 +38,0 @@ upload: { |
{ | ||
"name": "@flatfile/sdk", | ||
"version": "2.0.0-rc7", | ||
"version": "2.0.0-rc8", | ||
"description": "Flatfile SDK", | ||
@@ -47,3 +47,2 @@ "private": false, | ||
"@commitlint/config-conventional": "^12.1.4", | ||
"@flatfile/hooks": "^1.0.1", | ||
"@types/backo2": "^1.0.1", | ||
@@ -50,0 +49,0 @@ "@types/jest": "^27.0.3", |
Sorry, the diff of this file is too big to display
111731
55
39
908