From 215b1bbbe1b267ce86b9aa0ce00dcb7816e6aa56 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Tue, 19 Mar 2024 15:37:11 -0400 Subject: [PATCH 1/3] Fix maker paths --- packages/maker/src/cli/main.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/maker/src/cli/main.ts b/packages/maker/src/cli/main.ts index ff7dea831..8beb604da 100644 --- a/packages/maker/src/cli/main.ts +++ b/packages/maker/src/cli/main.ts @@ -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"; @@ -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) { From 56bfaa9c2fe8297129cb54c009f8f27871512f8e Mon Sep 17 00:00:00 2001 From: svc-changelog Date: Tue, 19 Mar 2024 19:37:45 +0000 Subject: [PATCH 2/3] Add generated changelog entries --- packages/maker/changelog/@unreleased/pr-137.v2.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/maker/changelog/@unreleased/pr-137.v2.yml diff --git a/packages/maker/changelog/@unreleased/pr-137.v2.yml b/packages/maker/changelog/@unreleased/pr-137.v2.yml new file mode 100644 index 000000000..e735b0f5a --- /dev/null +++ b/packages/maker/changelog/@unreleased/pr-137.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: Fix maker paths + links: + - https://github.com/palantir/osdk-ts/pull/137 From 39fb807b7555d1cf5ab57f9600de9af54ec4e087 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Tue, 19 Mar 2024 16:23:15 -0400 Subject: [PATCH 3/3] output property types --- packages/maker/src/api/defineOntology.ts | 21 +++++++++++++-------- packages/maker/src/api/overall.test.ts | 20 ++++++++++---------- packages/maker/src/cli/main.ts | 4 +--- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/packages/maker/src/api/defineOntology.ts b/packages/maker/src/api/defineOntology.ts index badfc9be7..8b0603c73 100644 --- a/packages/maker/src/api/defineOntology.ts +++ b/packages/maker/src/api/defineOntology.ts @@ -47,21 +47,21 @@ 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], @@ -69,12 +69,12 @@ export function dumpOntologyFullMetadata(): Gateway.OntologyFullMetadata { ), 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, @@ -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, diff --git a/packages/maker/src/api/overall.test.ts b/packages/maker/src/api/overall.test.ts index e09604894..386088905 100644 --- a/packages/maker/src/api/overall.test.ts +++ b/packages/maker/src/api/overall.test.ts @@ -75,10 +75,10 @@ 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": {}, @@ -86,7 +86,7 @@ describe("Ontology Defining", () => { "apiName": "IDK", "description": "IDK", "displayName": "IDK", - "rid": "IDK", + "rid": "ri.ontology.main.generated-object.foo", }, "queryTypes": {}, "sharedPropertyTypes": { @@ -97,7 +97,7 @@ describe("Ontology Defining", () => { }, "description": undefined, "displayName": "foo", - "rid": "IDK", + "rid": "ri.ontology.main.generated-object.foo", }, }, } @@ -118,7 +118,7 @@ describe("Ontology Defining", () => { "apiName": "IDK", "description": "IDK", "displayName": "IDK", - "rid": "IDK", + "rid": "ri.ontology.main.generated-object.foo", }, "queryTypes": {}, "sharedPropertyTypes": { @@ -129,7 +129,7 @@ describe("Ontology Defining", () => { }, "description": undefined, "displayName": "foo", - "rid": "IDK", + "rid": "ri.ontology.main.generated-object.foo", }, }, } @@ -200,10 +200,10 @@ 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": {}, @@ -211,7 +211,7 @@ describe("Ontology Defining", () => { "apiName": "IDK", "description": "IDK", "displayName": "IDK", - "rid": "IDK", + "rid": "ri.ontology.main.generated-object.foo", }, "queryTypes": {}, "sharedPropertyTypes": { @@ -222,7 +222,7 @@ describe("Ontology Defining", () => { }, "description": undefined, "displayName": "fooSpt", - "rid": "IDK", + "rid": "ri.ontology.main.generated-object.foo", }, }, } diff --git a/packages/maker/src/cli/main.ts b/packages/maker/src/cli/main.ts index 8beb604da..3967d07c5 100644 --- a/packages/maker/src/cli/main.ts +++ b/packages/maker/src/cli/main.ts @@ -104,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; }