Skip to content

Commit

Permalink
Merge pull request #67 from palantir/ea/callable-client-objects-v2
Browse files Browse the repository at this point in the history
Finish future types
  • Loading branch information
ericanderson authored Feb 21, 2024
2 parents 387130b + cf219ad commit 3e230d0
Show file tree
Hide file tree
Showing 54 changed files with 932 additions and 682 deletions.
24 changes: 0 additions & 24 deletions examples/basic/cli/src/OntologyType.ts

This file was deleted.

7 changes: 3 additions & 4 deletions examples/basic/cli/src/examples/fetchEmployeePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
* limitations under the License.
*/

import type { Client } from "@osdk/client";
import type { Ontology } from "@osdk/examples.basic.sdk";
import type { Client, Osdk } from "@osdk/client";
import type { Employee, Ontology } from "@osdk/examples.basic.sdk";
import { expectType } from "ts-expect";
import type { Employee } from "../OntologyType.js";

export async function fetchEmployeePage(client: Client<Ontology>) {
const result = await client.objectSet("Employee").fetchPageOrThrow();
Expand Down Expand Up @@ -52,7 +51,7 @@ export async function fetchEmployeePage(client: Client<Ontology>) {
console.log();
}

function printEmployees(employees: Employee[]) {
function printEmployees(employees: Osdk<Employee>[]) {
console.table(
employees.map(({ adUsername, businessTitle, employeeNumber }) => ({
adUsername,
Expand Down
8 changes: 4 additions & 4 deletions examples/basic/cli/src/typeChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import type { Client, OsdkObjectFrom, PageResult } from "@osdk/client";
import type { Client, Osdk, PageResult } from "@osdk/client";
import type { Ontology } from "@osdk/examples.basic.sdk";
import type { TypeOf } from "ts-expect";
import { expectType } from "ts-expect";
Expand Down Expand Up @@ -81,7 +81,7 @@ export async function typeChecks(client: Client<Ontology>) {
// lead is an employee
const lead = await employee.$link.lead.get();
expectType<
TypeOf<typeof lead, OsdkObjectFrom<Ontology["objects"]["Employee"]>>
TypeOf<typeof lead, Osdk<Ontology["objects"]["Employee"]>>
>(true);

// lead is an employee but we downselect to just their adUsername
Expand All @@ -99,7 +99,7 @@ export async function typeChecks(client: Client<Ontology>) {
TypeOf<
typeof peeps,
PageResult<
OsdkObjectFrom<
Osdk<
Ontology["objects"]["Employee"],
"adUsername" | "employeeNumber"
>
Expand All @@ -117,7 +117,7 @@ export async function typeChecks(client: Client<Ontology>) {
expectType<
TypeOf<
typeof peepById,
OsdkObjectFrom<Ontology["objects"]["Employee"], "adUsername">
Osdk<Ontology["objects"]["Employee"], "adUsername">
>
>(
true,
Expand Down
3 changes: 3 additions & 0 deletions examples/basic/sdk/src/generatedNoCheck/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export { Ontology } from './Ontology.js';
export * from './ontology/actions/index.js';
export * from './ontology/interfaces.js';
export * from './ontology/objects.js';
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from '@osdk/api';
import type { ActionReturnTypeForOptions, ApplyActionOptions, NOOP, OsdkActionParameters } from '@osdk/client';
import type { PersonDef, TodoDef } from '../objects.js';
import type { Person, Todo } from '../objects.js';

// Represents the definition of the parameters for the action
export type ActionDef$actionTakesAllParameterTypes$Params = {
objectSet: {
type: ObjectSetActionDataType<'Todo', TodoDef>;
multiplicity: false;
type: ObjectSetActionDataType<'Todo', Todo>;
nullable: false;
};
object: {
type: ObjectActionDataType<'Person', PersonDef>;
multiplicity: false;
type: ObjectActionDataType<'Person', Person>;
nullable: true;
description: 'A person Object';
};
string: {
type: 'string';
multiplicity: false;
type: 'string';
nullable: false;
};
'time-stamp': {
type: 'timestamp';
multiplicity: false;
type: 'timestamp';
nullable: false;
};
dateArray: {
type: 'datetime';
multiplicity: true;
type: 'datetime';
nullable: true;
};
attachmentArray: {
type: 'attachment';
multiplicity: true;
type: 'attachment';
nullable: false;
};
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import type { ObjectTypeDefinition } from '@osdk/api';
import type { ObjectTypeDefinition, PropertyDef } from '@osdk/api';

export interface BoundariesUsStateDef extends ObjectTypeDefinition<'BoundariesUsState'> {
type: 'object';
apiName: 'BoundariesUsState';
export interface BoundariesUsState extends ObjectTypeDefinition<'BoundariesUsState', BoundariesUsState> {
description: 'Boundaries US State';
primaryKeyType: 'string';
links: {};
properties: {
usState: {
multiplicity: false;
type: 'string';
nullable: false;
};
geometry10M: {
multiplicity: false;
description: 'geoshape';
type: 'geoshape';
nullable: true;
};
usState: PropertyDef<'string', 'non-nullable', 'single'>;
geometry10M: PropertyDef<'geoshape', 'nullable', 'single'>;
};
}

export const BoundariesUsState: BoundariesUsStateDef = {
export const BoundariesUsState: BoundariesUsState = {
type: 'object',
apiName: 'BoundariesUsState',
description: 'Boundaries US State',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,61 +1,26 @@
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition } from '@osdk/api';
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from '@osdk/api';

export interface EmployeeDef extends ObjectTypeDefinition<'Employee'> {
type: 'object';
apiName: 'Employee';
export interface Employee extends ObjectTypeDefinition<'Employee', Employee> {
description: 'An employee';
primaryKeyType: 'string';
links: { lead: ObjectTypeLinkDefinition<EmployeeDef, false>; peeps: ObjectTypeLinkDefinition<EmployeeDef, true> };
links: {
lead: ObjectTypeLinkDefinition<Employee, false>;
peeps: ObjectTypeLinkDefinition<Employee, true>;
};
properties: {
adUsername: {
multiplicity: false;
type: 'string';
nullable: false;
};
locationName: {
multiplicity: false;
type: 'string';
nullable: true;
};
locationCity: {
multiplicity: false;
type: 'string';
nullable: true;
};
firstFullTimeStartDate: {
multiplicity: false;
type: 'datetime';
nullable: true;
};
businessTitle: {
multiplicity: false;
type: 'string';
nullable: true;
};
employeeNumber: {
multiplicity: false;
type: 'double';
nullable: true;
};
jobProfile: {
multiplicity: false;
type: 'string';
nullable: true;
};
locationType: {
multiplicity: false;
type: 'string';
nullable: true;
};
favPlace: {
multiplicity: false;
type: 'geopoint';
nullable: true;
};
adUsername: PropertyDef<'string', 'non-nullable', 'single'>;
locationName: PropertyDef<'string', 'nullable', 'single'>;
locationCity: PropertyDef<'string', 'nullable', 'single'>;
firstFullTimeStartDate: PropertyDef<'datetime', 'nullable', 'single'>;
businessTitle: PropertyDef<'string', 'nullable', 'single'>;
employeeNumber: PropertyDef<'double', 'nullable', 'single'>;
jobProfile: PropertyDef<'string', 'nullable', 'single'>;
locationType: PropertyDef<'string', 'nullable', 'single'>;
favPlace: PropertyDef<'geopoint', 'nullable', 'single'>;
};
}

export const Employee: EmployeeDef = {
export const Employee: Employee = {
type: 'object',
apiName: 'Employee',
description: 'An employee',
Expand Down
Loading

0 comments on commit 3e230d0

Please sign in to comment.