Skip to content

Commit

Permalink
Cherrypick interface generator fix (#935)
Browse files Browse the repository at this point in the history
* Interfaces w no props fix

* changeset
  • Loading branch information
nihalbhatnagar authored Oct 28, 2024
1 parent c5ee0a1 commit 6bac6fb
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/pink-eyes-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osdk/generator": patch
---

Fixes generation for interfaces with no properties
10 changes: 10 additions & 0 deletions packages/e2e.generated.catchall/ontology.json
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,18 @@
},
"rid": "ri.ontology.main.interface-type.1b1b1b1b-1b1b-1b1b-1b1b-1b1b1b1b1b1b",
"status": "ACTIVE"
},
"InterfaceNoProps": {
"apiName": "InterfaceNoProps",
"displayName": "FInterfaceNoProps",
"description": "Its a Foo.",
"properties": {
},
"rid": "ri.ontology.main.interface-type.1b1b1b1b-1b1b-1b1b-1b1b-1b1b1b1b1b1b",
"status": "ACTIVE"
}
},

"sharedPropertyTypes": {
"name": {
"rid": "ri.ontology.main.shared-property.6618a6fc-5f14-4899-9540-615c9364c5d6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { actionTakesAllParameterTypes, assignEmployee1, createTodo } from './ontology/actions.js';
export * as $Actions from './ontology/actions.js';
export { FooInterface } from './ontology/interfaces.js';
export { FooInterface, InterfaceNoProps } from './ontology/interfaces.js';
export * as $Interfaces from './ontology/interfaces.js';
export {
BoundariesUsState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { FooInterface } from './interfaces/FooInterface.js';
export { InterfaceNoProps } from './interfaces/InterfaceNoProps.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import type { PropertyDef as $PropertyDef } from '@osdk/api';
import { $osdkMetadata } from '../../OntologyMetadata.js';

import type {
InterfaceDefinition as $InterfaceDefinition,
ObjectSet as $ObjectSet,
Osdk as $Osdk,
PropertyValueWireToClient as $PropType,
} from '@osdk/api';

export type OsdkObjectLinks$InterfaceNoProps = {};

export namespace InterfaceNoProps {
export type PropertyKeys = never;

export interface Props {}
export type StrictProps = Props;

export interface ObjectSet extends $ObjectSet<InterfaceNoProps, InterfaceNoProps.ObjectSet> {}

export type OsdkInstance<
OPTIONS extends never | '$rid' = never,
K extends keyof InterfaceNoProps.Props = keyof InterfaceNoProps.Props,
> = $Osdk.Instance<InterfaceNoProps, OPTIONS, K>;

/** @deprecated use OsdkInstance */
export type OsdkObject<
OPTIONS extends never | '$rid' = never,
K extends keyof InterfaceNoProps.Props = keyof InterfaceNoProps.Props,
> = OsdkInstance<OPTIONS, K>;
}

export interface InterfaceNoProps extends $InterfaceDefinition {
osdkMetadata: typeof $osdkMetadata;
type: 'interface';
apiName: 'InterfaceNoProps';
__DefinitionMetadata?: {
objectSet: InterfaceNoProps.ObjectSet;
props: InterfaceNoProps.Props;
linksType: OsdkObjectLinks$InterfaceNoProps;
strictProps: InterfaceNoProps.StrictProps;
apiName: 'InterfaceNoProps';
description: 'Its a Foo.';
displayName: 'FInterfaceNoProps';
links: {};
properties: {};
rid: 'ri.ontology.main.interface-type.1b1b1b1b-1b1b-1b1b-1b1b-1b1b1b1b1b1b';
type: 'interface';
};
}

export const InterfaceNoProps: InterfaceNoProps = {
type: 'interface',
apiName: 'InterfaceNoProps',
osdkMetadata: $osdkMetadata,
};
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,12 @@ ${
export function createPropertyKeys(
type: EnhancedObjectType | EnhancedInterfaceType,
) {
const properties = Object.keys(type.getCleanedUpDefinition(true).properties);
return `export type PropertyKeys = ${
Object.keys(type.getCleanedUpDefinition(true).properties).map(
(a) => maybeStripNamespace(type, a),
).map(a => `"${a}"`).join("|")
properties.length === 0
? "never"
: properties.map(
(a) => maybeStripNamespace(type, a),
).map(a => `"${a}"`).join("|")
};`;
}

0 comments on commit 6bac6fb

Please sign in to comment.