Skip to content

Commit

Permalink
output property types
Browse files Browse the repository at this point in the history
  • Loading branch information
ericanderson committed Mar 19, 2024
1 parent 56bfaa9 commit 39fb807
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
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
4 changes: 1 addition & 3 deletions packages/maker/src/cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 39fb807

Please sign in to comment.