Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,16 @@ export type EdgesOptionsSpec = OffsetLimitSpec & {
direction?: Direction;
};

export type ColumnType = 'number' | 'label' | 'category' | 'date' | 'boolean';
Comment thread
jjnesbitt marked this conversation as resolved.

export interface FileUploadOptionsSpec {
type: UploadType;
data: string | File;
key?: string;
overwrite?: boolean;
columnTypes?: {
[key: string]: ColumnType;
};
}

export interface CreateGraphOptionsSpec {
Expand Down Expand Up @@ -189,7 +194,7 @@ class MultinetAPI {
): Promise<Array<{}>> {
const headers = config ? config.headers : undefined;
const params = config ? config.params : undefined;
const { type, data, key, overwrite } = options;
const { type, data, key, overwrite, columnTypes } = options;

let text;

Expand All @@ -199,13 +204,24 @@ class MultinetAPI {
text = await fileToText(data);
}

let metadata;
if (columnTypes) {
const columns = Object.keys(columnTypes).map((column) => ({
key: column,
type: columnTypes[column],
}));

metadata = { columns };
}

return this.client.post(`/${type}/${workspace}/${table}`, text, {
...config,
headers: { ...headers, 'Content-Type': 'text/plain' },
params: {
...params,
key: key || undefined,
overwrite: overwrite || undefined,
metadata: metadata || undefined,
},
});
}
Expand Down