Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export * from './src/api/GraphEdge';
export * from './src/api/GraphNode';
export * from './src/api/GraphQuery';
export * from './src/api/GraphSchema';
export * from './src/api/import';
export * from './src/api/License';
export * from './src/api/Linkurious';
export * from './src/api/Plugin';
Expand Down
57 changes: 57 additions & 0 deletions src/api/import/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* LINKURIOUS CONFIDENTIAL
* Copyright Linkurious SAS 2012 - 2025
*
* - Created on 2025-11-27.
*/
import {Request} from '../../http/request';
import {LkErrorKey} from '../../http/response';

import {
CreateImportTemplateParams,
DeleteImportTemplateParams,
GetImportTemplatesParams,
ImportTemplate
} from './types';

export * from './types';

const {UNAUTHORIZED, DATA_SOURCE_UNAVAILABLE, FORBIDDEN, NOT_FOUND} = LkErrorKey;

export class ImportAPI extends Request {
/**
* Create a new import template.
*/
createImportTemplate(this: Request<ImportTemplate>, params: CreateImportTemplateParams) {
return this.request({
errors: [UNAUTHORIZED, FORBIDDEN, DATA_SOURCE_UNAVAILABLE],
url: '/:sourceKey/imports/templates',
method: 'POST',
params: params
});
}

/**
* Delete an existing import template.
*/
deleteImportTemplate(params: DeleteImportTemplateParams) {
return this.request({
errors: [UNAUTHORIZED, FORBIDDEN, DATA_SOURCE_UNAVAILABLE, NOT_FOUND],
url: '/:sourceKey/imports/templates/:id',
method: 'DELETE',
params: params
});
}

/**
* List all the import templates (the publicly shared ones and the private ones owned by the user).
*/
getImportTemplates(this: Request<{items: ImportTemplate[]}>, params: GetImportTemplatesParams) {
return this.request({
errors: [UNAUTHORIZED, FORBIDDEN, DATA_SOURCE_UNAVAILABLE],
url: '/:sourceKey/imports/templates',
method: 'GET',
params: params
});
}
}
74 changes: 74 additions & 0 deletions src/api/import/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* LINKURIOUS CONFIDENTIAL
* Copyright Linkurious SAS 2012 - 2025
*
* - Created on 2025-11-27.
*/
import {IDataSourceParams, SharingMode} from '../commonTypes';
import {EntityType} from '../GraphSchema';

export interface CreateImportTemplateParams extends IDataSourceParams {
name: string;
description?: string;
sharing: SharingMode.PRIVATE | SharingMode.SOURCE;
/**
* Whether the destination is an edge or a node.
*/
entityType: EntityType;
/**
* The reference of the node that the edge starts from. Only defined if the destination is an edge.
*/
sourceNode?: ImportTemplateNodeReference;
/**
* The reference of the node that the edge ends to. Only defined if the destination is an edge.
*/
targetNode?: ImportTemplateNodeReference;
/**
* The destination node category / edge type.
*/
itemType: string;
/**
* How to map imported fields to node/edge properties.
*/
properties: ImportTemplatePropertyMapping[];
}

export interface ImportTemplatePropertyMapping {
/**
* The field in the imported file.
*/
importedFileField: string;
/**
* The destination property key on the node/edge.
*/
destinationProperty: string;
}

export interface ImportTemplateNodeReference {
/**
* The field in the imported file.
*/
importedFileField: string;
/**
* The destination node category.
*/
destinationCategory: string;
/**
* The destination property key on the node. If it is undefined, the destination is the native
* ID of the node.
*/
destinationProperty?: string;
}

export interface DeleteImportTemplateParams extends IDataSourceParams {
id: number;
}

export interface GetImportTemplatesParams extends IDataSourceParams {
entityType?: EntityType;
}

export type ImportTemplate = CreateImportTemplateParams & {
id: number;
sourceKey: string;
};
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {GraphEdgeAPI} from './api/GraphEdge';
import {GraphNodeAPI} from './api/GraphNode';
import {GraphQueryAPI} from './api/GraphQuery';
import {GraphSchemaAPI} from './api/GraphSchema';
import {ImportAPI} from './api/import';
import {LicenseAPI} from './api/License';
import {LinkuriousAPI} from './api/Linkurious';
import {PluginAPI} from './api/Plugin';
Expand Down Expand Up @@ -50,6 +51,7 @@ export class RestClient extends ErrorListener {
public readonly graphNode: GraphNodeAPI;
public readonly graphQuery: GraphQueryAPI;
public readonly graphSchema: GraphSchemaAPI;
public readonly import: ImportAPI;
public readonly license: LicenseAPI;
public readonly linkurious: LinkuriousAPI;
public readonly plugin: PluginAPI;
Expand Down Expand Up @@ -97,6 +99,7 @@ export class RestClient extends ErrorListener {
this.graphNode = new GraphNodeAPI(moduleProps);
this.graphQuery = new GraphQueryAPI(moduleProps);
this.graphSchema = new GraphSchemaAPI(moduleProps);
this.import = new ImportAPI(moduleProps);
this.license = new LicenseAPI(moduleProps);
this.linkurious = new LinkuriousAPI(moduleProps);
this.plugin = new PluginAPI(moduleProps);
Expand Down