Skip to content

Commit

Permalink
Merge pull request #30 from palantir/ea/add-geopoint-within
Browse files Browse the repository at this point in the history
Adds geopoint $within where clauses
  • Loading branch information
ericanderson authored Feb 5, 2024
2 parents 5030bba + 460d689 commit 4402a5a
Show file tree
Hide file tree
Showing 12 changed files with 544 additions and 78 deletions.
12 changes: 12 additions & 0 deletions examples/basic/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ async function runTests() {
interfaceResults.data[0].body;
}

// only works in default ontology
const result = await client.objects.WeatherStation.where({
geohash: {
$within: {
distance: [1_000, "miles"],
of: [0, 0],
},
},
}).fetchPageOrThrow();

console.log(result.data[0].geohash);

await typeChecks(client);
} catch (e) {
console.error("Caught an error we did not expect", typeof e);
Expand Down
29 changes: 27 additions & 2 deletions examples/basic/sdk/ontology.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ontology": {
"apiName": "OntologyApiName",
"rid": "ridHere",
"apiName": "default",
"rid": "ri.ontology.main.ontology.a35bb7f9-2c57-4199-a1cd-af461d88bd6e",
"displayName": "",
"description": ""
},
Expand Down Expand Up @@ -89,6 +89,31 @@
}
},
"objectTypes": {
"WeatherStation": {
"objectType": {
"apiName": "WeatherStation",
"primaryKey": "stationId",
"displayName": "Weather Station",
"description": "Weather Station",
"properties": {
"stationId": {
"dataType": {
"type": "string"
}
},
"geohash": {
"dataType": {
"type": "geopoint"
},
"description": "geopoint",
"displayName": "Geohash"
}
},
"status": "ACTIVE",
"rid": "ridForWeatherStation"
},
"linkTypes": []
},
"Todo": {
"objectType": {
"apiName": "Todo",
Expand Down
3 changes: 2 additions & 1 deletion examples/basic/sdk/src/generatedNoCheck/Ontology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as Objects from './ontology/objects.js';
const _Ontology = {
metadata: OntologyMetadata,
objects: {
WeatherStation: Objects.WeatherStation,
Todo: Objects.Todo,
Person: Objects.Person,
Employee: Objects.Employee,
Expand All @@ -22,7 +23,7 @@ const _Ontology = {
interfaces: {
SimpleInterface: Interfaces.SimpleInterface,
},
} satisfies OntologyDefinition<'Todo' | 'Person' | 'Employee' | 'ObjectTypeWithAllPropertyTypes'>;
} satisfies OntologyDefinition<'WeatherStation' | 'Todo' | 'Person' | 'Employee' | 'ObjectTypeWithAllPropertyTypes'>;

type _Ontology = typeof _Ontology;
export interface Ontology extends _Ontology {}
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/sdk/src/generatedNoCheck/OntologyMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const OntologyMetadata = {
ontologyRid: 'ridHere',
ontologyApiName: 'OntologyApiName',
ontologyRid: 'ri.ontology.main.ontology.a35bb7f9-2c57-4199-a1cd-af461d88bd6e',
ontologyApiName: 'default',
userAgent: 'typescript-sdk/dev osdk-cli/dev',
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './objects/Employee.js';
export * from './objects/ObjectTypeWithAllPropertyTypes.js';
export * from './objects/Person.js';
export * from './objects/Todo.js';
export * from './objects/WeatherStation.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { ObjectTypeDefinition } from '@osdk/api';

export const WeatherStation = {
apiName: 'WeatherStation',
description: 'Weather Station',
primaryKeyType: 'string',
links: {},
properties: {
stationId: {
multiplicity: false,
type: 'string',
nullable: false,
},
geohash: {
multiplicity: false,
description: 'geopoint',
type: 'geopoint',
nullable: true,
},
},
} satisfies ObjectTypeDefinition<'WeatherStation', never>;
5 changes: 5 additions & 0 deletions packages/client/changelog/@unreleased/pr-30.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: fix
fix:
description: Adds geopoint $within where clauses
links:
- https://github.com/palantir/osdk-ts/pull/30
1 change: 1 addition & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"devDependencies": {
"@osdk/generator": "workspace:*",
"@osdk/shared.test": "workspace:*",
"@types/geojson": "^7946.0.14",
"@types/ws": "^8.5.10",
"ts-expect": "^1.3.0",
"typescript": "^5.2.2"
Expand Down
Loading

0 comments on commit 4402a5a

Please sign in to comment.