Skip to content

Commit

Permalink
update SDK to 4.5.0 & change to dockerized command
Browse files Browse the repository at this point in the history
  • Loading branch information
TristenHarr committed Apr 17, 2024
1 parent b294781 commit c70fbd1
Show file tree
Hide file tree
Showing 7 changed files with 2,056 additions and 7,484 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
dist/
.DS_Store
configuration.json
PRIVATE_REMOTE_CONFIGURATION.http
PRIVATE_REMOTE_CONFIGURATION.http
config.json
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Qdrant Connector Changelog
This changelog documents changes between release tags.


## [Unreleased]
Upcoming changes for the next versioned release.
## [0.1.8] - 2024-04-17
* Update SDK to 4.5.0
* Update packaging to use a Dockerized Command
* Fix generate-config to only re-write the config if the introspection results are different

## [0.1.7] - 2024-03-25
* Add handling for recommend with UUID's
Expand Down
8 changes: 6 additions & 2 deletions connector-definition/connector-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
packagingDefinition:
type: PrebuiltDockerImage
dockerImage: ghcr.io/hasura/ndc-qdrant:v0.1.7
dockerImage: ghcr.io/hasura/ndc-qdrant:v0.1.8
supportedEnvironmentVariables:
- name: QDRANT_URL
description: The url for the Qdrant database
- name: QDRANT_API_KEY
description: The Qdrant API Key
commands:
update: docker run --rm -e QDRANT_URL="$QDRANT_URL" -e QDRANT_API_KEY="$QDRANT_API_KEY" -v "$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH":/etc/connector ghcr.io/hasura/ndc-qdrant:v0.1.7 update
update:
type: Dockerized
dockerImage: ghcr.io/hasura/ndc-qdrant:v0.1.8
commandArgs:
- update
dockerComposeWatch:
- path: ./
target: /etc/connector
Expand Down
25 changes: 20 additions & 5 deletions generate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ import fs from "fs";
import { promisify } from "util";
import { insertion } from "./src/utilities";
import { RESTRICTED_OBJECTS, BASE_FIELDS, BASE_TYPES, INSERT_FIELDS } from "./src/constants";

const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);

let HASURA_CONFIGURATION_DIRECTORY = process.env["HASURA_CONFIGURATION_DIRECTORY"] as string | undefined;
if (HASURA_CONFIGURATION_DIRECTORY === undefined || HASURA_CONFIGURATION_DIRECTORY.length === 0){
HASURA_CONFIGURATION_DIRECTORY = ".";
}
const QDRANT_URL = process.env["QDRANT_URL"] as string;
let QDRANT_API_KEY = process.env["QDRANT_API_KEY"] as string | undefined;
if (QDRANT_API_KEY?.length === 0){
QDRANT_API_KEY = undefined;
}


let client = getQdrantClient(QDRANT_URL, QDRANT_API_KEY);

async function main() {
Expand All @@ -33,7 +37,6 @@ async function main() {
let baseFields = {};
let insertFields = {};
if (records.length > 0) {
console.log(records);
const recordPayload = records[0].payload;
fieldDict = insertion(cn, recordPayload!, objectTypes);
if (typeof records[0].id === "number"){
Expand Down Expand Up @@ -80,7 +83,6 @@ async function main() {
};
}
}
console.log(fieldDict);

objectTypes[cn] = {
description: null,
Expand Down Expand Up @@ -113,7 +115,20 @@ async function main() {
functions: [],
procedures: [],
}
await writeFile(`/etc/connector/config.json`, JSON.stringify(res, null, 4));
const jsonString = JSON.stringify(res, null, 4);
let filePath = `${HASURA_CONFIGURATION_DIRECTORY}/config.json`;
try {
const existingData = await readFile(filePath, 'utf8');
if (existingData !== jsonString) {
await writeFile(filePath, jsonString);
console.log('File updated.');
} else {
console.log('No changes detected. File not updated.');
}
} catch (error) {
await writeFile(filePath, jsonString);
console.log('New file written.');
}
}

main();
Loading

0 comments on commit c70fbd1

Please sign in to comment.