Skip to content

Commit bef1734

Browse files
authored
Merge pull request #81 from Abhijithchintu/instance_version_warning
instance_version_warning
2 parents 26eb1ea + 8e1d504 commit bef1734

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

src/data/path.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { isValidStringProperty } from '../validation/string';
22
import { DbVersionSupport } from '../utils/dbVersion';
33
import { ConsistencyLevel } from './replication';
4+
import { isValidWeaviateVersion } from '../validation/version';
45

56
const objectsPathPrefix = '/objects';
67

@@ -176,6 +177,11 @@ export class ReferencesPath {
176177
} else {
177178
support.warns.notSupportedClassNamespacedEndpointsForReferences();
178179
}
180+
if (support.version) {
181+
if (!isValidWeaviateVersion(support.version)) {
182+
support.warns.deprecatedWeaviateTooOld();
183+
}
184+
}
179185
if (isValidStringProperty(id)) {
180186
path = `${path}/${id}`;
181187
}

src/utils/beaconPath.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { isValidStringProperty } from '../validation/string';
22
import { DbVersionSupport } from './dbVersion';
3+
import { isValidWeaviateVersion } from '../validation/version';
34

45
const beaconPathPrefix = 'weaviate://localhost';
56

@@ -41,6 +42,11 @@ export class BeaconPath {
4142
} else {
4243
support.warns.notSupportedClassNamespacedEndpointsForBeacons();
4344
}
45+
if (support.version) {
46+
if (!isValidWeaviateVersion(support.version)) {
47+
support.warns.deprecatedWeaviateTooOld();
48+
}
49+
}
4450
if (isValidStringProperty(id)) {
4551
beaconPath = `${beaconPath}/${id}`;
4652
}

src/utils/dbVersion.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export class DbVersionSupport {
2222
console.warn(
2323
`Usage of beacons paths without className is deprecated in Weaviate ${version}. Please provide className parameter`
2424
),
25+
deprecatedWeaviateTooOld: () =>
26+
console.warn(
27+
`Usage of weaviate ${version} is deprecated. Please consider upgrading to the latest version. See https://www.weaviate.io/developers/weaviate for details.`
28+
),
2529
notSupportedClassNamespacedEndpointsForObjects: () =>
2630
console.warn(
2731
`Usage of objects paths with className is not supported in Weaviate ${version}. className parameter is ignored`

src/validation/version.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export function isValidWeaviateVersion(version: string) {
2+
if (typeof version === 'string') {
3+
const versionNumbers = version.split('.');
4+
if (versionNumbers.length >= 2) {
5+
const major = parseInt(versionNumbers[0], 10);
6+
const minor = parseInt(versionNumbers[1], 10);
7+
return !(major <= 1 && minor < 16);
8+
}
9+
}
10+
return true;
11+
}

0 commit comments

Comments
 (0)