Skip to main content
I want to implement my dataConnector and post some custom data(like object with array of object as a field in it): 

class MyClass { 

   id:number; 

   name:string; 

   subItems: SubItem[]


class SubItem {

   id:number; 

   name:string; 

}

 

Maybe you have some examples how to do this because some examples from documentation I guess are out of date.

Hi Dennis


Thank you for contributing to the Lucid for Developers Community! I recommend taking a look at our recently released Asana integration. It serves as a more comprehensive example that you can reference.


You can find the relevant code in the asanacardintegration.ts file specifically where the editor extension requests a data action:


        import: async (
            primaryKeys: string[]
            searchFields: Map<string SerializedFieldType>
        ): Promise<{collection: CollectionProxy; primaryKeys: string[]}> => {
            const workspaceId = searchFields.get('workspace');
            if (!isString(workspaceId) || !workspaceId) {
                throw new Error('No workspace selected');
            }
            this.updateDefaultCreationProjects(searchFields.get('project'));
            await this.editorClient.performDataAction({
                dataConnectorName: 'asana'
                syncDataSourceIdNonce: workspaceId
                actionName: 'Import'
                actionData: {workspaceId taskIds: primaryKeys.map((pk) => JSON.parse(pk))}
                asynchronous: true
            });

            const collection = await this.editorClient.awaitDataImport('asana' workspaceId 'Tasks' primaryKeys);

            return {collection primaryKeys};
        }

 


And then where the data connector handles that request in importaction.ts:


export const importAction: AsanaAction<DataConnectorAsynchronousAction> = async ({action asanaClient}) => {
    if (!importBodyValidator(action.data)) {
        throw new DataConnectorRunError(404 'Body must be of type {workspaceId:string taskIds:string[]}');
    }

    const {workspaceId taskIds} = action.data;
    const fullTaskData = await importTasks(new Set(taskIds) asanaClient);
    return await uploadTasks(action.client workspaceId fullTaskData asanaClient);
};


You'll also probably want to take a look at where the data connector gets defined in index.ts.


 


Let me know if you get stuck!


Reply