n8n-nodes-base
Version:
Base nodes of n8n
35 lines • 1.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.execute = execute;
const n8n_workflow_1 = require("n8n-workflow");
const helpers_1 = require("../helpers");
async function execute(i) {
const credentialType = (0, helpers_1.getActiveCredentialType)(this, i);
const host = await (0, helpers_1.getHost)(this, credentialType);
const indexName = this.getNodeParameter('indexName', i);
const endpointName = this.getNodeParameter('endpointName', i);
const primaryKey = this.getNodeParameter('primaryKey', i);
const indexType = this.getNodeParameter('indexType', i);
const body = {
name: indexName,
endpoint_name: endpointName,
primary_key: primaryKey,
index_type: indexType,
};
if (indexType === 'DELTA_SYNC') {
const raw = this.getNodeParameter('deltaSyncIndexSpec', i);
body.delta_sync_index_spec = typeof raw === 'string' ? (0, n8n_workflow_1.jsonParse)(raw) : raw;
}
else if (indexType === 'DIRECT_ACCESS') {
const raw = this.getNodeParameter('directAccessIndexSpec', i);
body.direct_access_index_spec = typeof raw === 'string' ? (0, n8n_workflow_1.jsonParse)(raw) : raw;
}
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
method: 'POST',
url: `${host}/api/2.0/vector-search/indexes`,
body,
json: true,
});
return [{ json: response, pairedItem: { item: i } }];
}
//# sourceMappingURL=createIndex.operation.js.map