File tree Expand file tree Collapse file tree 6 files changed +87
-0
lines changed Expand file tree Collapse file tree 6 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 1+ import extraction from './functions/extraction' ;
2+
13export const functionFactory = {
24 // Add your functions here
5+ extraction,
36} as const ;
47
58export type FunctionFactoryType = keyof typeof functionFactory ;
Original file line number Diff line number Diff line change 1+ import { convertToAirdropEvent } from '../../core/utils' ;
2+ import { FunctionInput } from '../../core/types' ;
3+ import { spawn , EventType } from '@devrev/ts-adaas' ;
4+
5+ export interface ExtractorState { }
6+
7+ export const initialState : ExtractorState = { } ;
8+
9+
10+ function getWorkerPerExtractionPhase ( event : FunctionInput ) {
11+ let path ;
12+ switch ( event . payload . event_type ) {
13+ case EventType . ExtractionExternalSyncUnitsStart :
14+ path = __dirname + '/workers/external-sync-units-extraction' ;
15+ break ;
16+ case EventType . ExtractionMetadataStart :
17+ path = __dirname + '/workers/metadata-extraction' ;
18+ break ;
19+ case EventType . ExtractionDataStart :
20+ case EventType . ExtractionDataContinue :
21+ path = __dirname + '/workers/data-extraction' ;
22+ break ;
23+ case EventType . ExtractionAttachmentsStart :
24+ case EventType . ExtractionAttachmentsContinue :
25+ path = __dirname + '/workers/attachments-extraction' ;
26+ break ;
27+ }
28+ return path ;
29+ }
30+
31+ const run = async ( events : FunctionInput [ ] ) => {
32+ for ( const event of events ) {
33+ const file = getWorkerPerExtractionPhase ( event ) ;
34+ await spawn ( {
35+ event : convertToAirdropEvent ( event ) ,
36+ workerPath : file ,
37+ initialState : initialState ,
38+ } ) ;
39+ }
40+ } ;
41+
42+ export default run ;
Original file line number Diff line number Diff line change 1+ import { ExtractorEventType , processTask } from '@devrev/ts-adaas' ;
2+ import { ExtractorState } from "../index" ;
3+
4+ processTask < ExtractorState > ( {
5+ task : async ( { adapter } ) => { } ,
6+ onTimeout : async ( { adapter } ) => {
7+ await adapter . emit ( ExtractorEventType . ExtractionAttachmentsProgress ) ;
8+ } ,
9+ } ) ;
Original file line number Diff line number Diff line change 1+ import { ExtractorEventType , processTask } from "@devrev/ts-adaas" ;
2+ import { ExtractorState } from "../index" ;
3+
4+ processTask < ExtractorState > ( {
5+ task : async ( { adapter } ) => { } ,
6+ onTimeout : async ( { adapter } ) => {
7+ await adapter . emit ( ExtractorEventType . ExtractionDataProgress ) ;
8+ } ,
9+ } ) ;
Original file line number Diff line number Diff line change 1+ import { ExtractorEventType , processTask } from "@devrev/ts-adaas" ;
2+ import { ExtractorState } from "../index" ;
3+
4+ processTask < ExtractorState > ( {
5+ task : async ( { adapter } ) => { } ,
6+ onTimeout : async ( { adapter } ) => {
7+ await adapter . emit ( ExtractorEventType . ExtractionExternalSyncUnitsError , {
8+ error : {
9+ message : 'Failed to extract external sync units. Lambda timeout.' ,
10+ } ,
11+ } ) ;
12+ } ,
13+ } ) ;
Original file line number Diff line number Diff line change 1+ import { processTask , ExtractorEventType } from '@devrev/ts-adaas' ;
2+ import { ExtractorState } from '../index' ;
3+
4+ processTask < ExtractorState > ( {
5+ task : async ( { adapter } ) => { } ,
6+ onTimeout : async ( { adapter } ) => {
7+ await adapter . emit ( ExtractorEventType . ExtractionMetadataError , {
8+ error : { message : 'Failed to extract metadata. Lambda timeout.' } ,
9+ } ) ;
10+ } ,
11+ } ) ;
You can’t perform that action at this time.
0 commit comments