Skip to content

Commit

Permalink
Merge pull request #137 from palantir/ea/fix-maker
Browse files Browse the repository at this point in the history
Fix maker
  • Loading branch information
ericanderson authored Mar 19, 2024
2 parents 39b75b9 + 39fb807 commit dcb6d64
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 30 deletions.
5 changes: 5 additions & 0 deletions packages/maker/changelog/@unreleased/pr-137.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: fix
fix:
description: Fix maker paths
links:
- https://github.com/palantir/osdk-ts/pull/137
21 changes: 13 additions & 8 deletions packages/maker/src/api/defineOntology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,34 @@ export async function defineOntology(
throw e;
}

return ontologyDefinition;
return convertToWireOntology(ontologyDefinition);
}

export function dumpOntologyFullMetadata(): Gateway.OntologyFullMetadata {
function convertToWireOntology(ontology: Ontology) {
return {
ontology: {
apiName: "IDK",
description: "IDK",
displayName: "IDK",
rid: "IDK",
rid: "ri.ontology.main.generated-object.foo",
},
...ontologyDefinition,
...ontology,
sharedPropertyTypes: Object.fromEntries(
Object.entries(
ontologyDefinition.sharedPropertyTypes,
ontology.sharedPropertyTypes,
)
.map<[string, Gateway.SharedPropertyType]>((
[apiName, spt],
) => [apiName, convertSpt(spt)]),
),
interfaceTypes: Object.fromEntries(
Object.entries(
ontologyDefinition.interfaceTypes,
ontology.interfaceTypes,
)
.map<[string, Gateway.InterfaceType]>(
([apiName, { displayName, description, properties }]) => {
return [apiName, {
rid: "IDK",
rid: "ri.ontology.main.generated-object.foo",
apiName,
displayName: displayName ?? apiName,
description,
Expand All @@ -92,11 +92,16 @@ export function dumpOntologyFullMetadata(): Gateway.OntologyFullMetadata {
),
};
}

export function dumpOntologyFullMetadata(): Gateway.OntologyFullMetadata {
return convertToWireOntology(ontologyDefinition);
}

function convertSpt(
{ type, array, description, apiName, displayName }: SharedPropertyType,
): Gateway.SharedPropertyType {
return {
rid: "IDK",
rid: "ri.ontology.main.generated-object.foo",
apiName,
displayName: displayName ?? apiName,
description,
Expand Down
20 changes: 10 additions & 10 deletions packages/maker/src/api/overall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ describe("Ontology Defining", () => {
},
"description": undefined,
"displayName": "foo",
"rid": "IDK",
"rid": "ri.ontology.main.generated-object.foo",
},
},
"rid": "IDK",
"rid": "ri.ontology.main.generated-object.foo",
},
},
"objectTypes": {},
"ontology": {
"apiName": "IDK",
"description": "IDK",
"displayName": "IDK",
"rid": "IDK",
"rid": "ri.ontology.main.generated-object.foo",
},
"queryTypes": {},
"sharedPropertyTypes": {
Expand All @@ -97,7 +97,7 @@ describe("Ontology Defining", () => {
},
"description": undefined,
"displayName": "foo",
"rid": "IDK",
"rid": "ri.ontology.main.generated-object.foo",
},
},
}
Expand All @@ -118,7 +118,7 @@ describe("Ontology Defining", () => {
"apiName": "IDK",
"description": "IDK",
"displayName": "IDK",
"rid": "IDK",
"rid": "ri.ontology.main.generated-object.foo",
},
"queryTypes": {},
"sharedPropertyTypes": {
Expand All @@ -129,7 +129,7 @@ describe("Ontology Defining", () => {
},
"description": undefined,
"displayName": "foo",
"rid": "IDK",
"rid": "ri.ontology.main.generated-object.foo",
},
},
}
Expand Down Expand Up @@ -200,18 +200,18 @@ describe("Ontology Defining", () => {
},
"description": undefined,
"displayName": "fooSpt",
"rid": "IDK",
"rid": "ri.ontology.main.generated-object.foo",
},
},
"rid": "IDK",
"rid": "ri.ontology.main.generated-object.foo",
},
},
"objectTypes": {},
"ontology": {
"apiName": "IDK",
"description": "IDK",
"displayName": "IDK",
"rid": "IDK",
"rid": "ri.ontology.main.generated-object.foo",
},
"queryTypes": {},
"sharedPropertyTypes": {
Expand All @@ -222,7 +222,7 @@ describe("Ontology Defining", () => {
},
"description": undefined,
"displayName": "fooSpt",
"rid": "IDK",
"rid": "ri.ontology.main.generated-object.foo",
},
},
}
Expand Down
23 changes: 11 additions & 12 deletions packages/maker/src/cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { consola } from "consola";
import * as fs from "node:fs/promises";
import { join } from "node:path";
import * as path from "node:path";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { defineInterface } from "../api/defineInterface.js";
Expand All @@ -41,29 +41,30 @@ export default async function main(args: string[] = process.argv) {
describe: "Input file",
type: "string",
default: ".ontology/ontology.ts",
coerce: path.resolve,
},
output: {
alias: "o",
describe: "Output file",
type: "string",
default: "ontology.json",
coerce: path.resolve,
},
snapshotDir: {
alias: "s",
describe: "Snapshot directory",
type: "string",
default: "snapshots",
coerce: path.resolve,
},
}).parseAsync();
})
.parseAsync();

const fullInputPath = join(process.cwd(), commandLineOpts.input);
const fullOutputPath = join(process.cwd(), commandLineOpts.output);
consola.info(`Loading ontology from ${fullInputPath}`);
consola.info(`Loading ontology from ${commandLineOpts.input}`);
const ontology = await loadOntology(commandLineOpts.input);

const ontology = await loadOntology(fullInputPath);

consola.info(`Saving ontology to ${fullOutputPath}`);
fs.writeFile(fullOutputPath, JSON.stringify(ontology, null, 2));
consola.info(`Saving ontology to ${commandLineOpts.output}`);
fs.writeFile(commandLineOpts.output, JSON.stringify(ontology, null, 2));
}

async function loadOntologyViaJiti(input: string) {
Expand Down Expand Up @@ -103,9 +104,7 @@ async function loadOntologyViaTsNode(input: string) {

tsNodeService.enabled(true);

const fullPath = join(process.cwd(), input);

const q = await import(fullPath);
const q = await import(input);
return q;
}

Expand Down

0 comments on commit dcb6d64

Please sign in to comment.