From 8951fb6960ddb533f2c3a8dd9ebcd30aaacb0520 Mon Sep 17 00:00:00 2001 From: Saurav Date: Sat, 7 Dec 2024 14:21:31 -0500 Subject: [PATCH 1/6] structs functionality --- packages/api/src/Definitions.ts | 17 +- .../api/src/aggregate/AggregatableKeys.ts | 9 +- packages/api/src/index.ts | 5 +- .../api/src/mapping/PropertyValueMapping.ts | 13 ++ .../api/src/ontology/WirePropertyTypes.ts | 4 + packages/cli.cmd.typescript/package.json | 4 +- packages/client/package.json | 4 +- packages/client/src/object/aggregate.test.ts | 33 ++-- packages/client/src/object/object.test.ts | 1 + .../client/src/objectSet/ObjectSet.test.ts | 34 ++++ packages/e2e.generated.catchall/ontology.json | 83 ++++++++ .../src/generatedNoCheck/index.ts | 1 + .../src/generatedNoCheck/ontology/objects.ts | 1 + .../ontology/objects/BgaoNflPlayer.ts | 116 +++++++++++ packages/foundry-sdk-generator/package.json | 10 +- packages/generator-converters/package.json | 2 +- ...PropertyV2ToSdkPrimaryKeyTypeDefinition.ts | 2 + .../wirePropertyV2ToSdkPropertyDefinition.ts | 27 ++- packages/generator/package.json | 2 +- .../wireObjectTypeV2ToSdkObjectConstV2.ts | 33 ++-- packages/maker/package.json | 2 +- packages/maker/src/api/defineObject.ts | 3 +- packages/monorepo.cspell/dict.osdk-code.txt | 8 +- packages/shared.test/package.json | 8 +- .../shared.test/src/stubs/objectSetRequest.ts | 16 ++ .../shared.test/src/stubs/objectTypeV2.ts | 81 ++++++++ .../src/stubs/objectTypesWithLinkTypes.ts | 10 + packages/shared.test/src/stubs/objects.ts | 21 ++ pnpm-lock.yaml | 181 ++++++++++-------- 29 files changed, 598 insertions(+), 133 deletions(-) create mode 100644 packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/BgaoNflPlayer.ts diff --git a/packages/api/src/Definitions.ts b/packages/api/src/Definitions.ts index eaa3b6c1b..ecf4c4601 100644 --- a/packages/api/src/Definitions.ts +++ b/packages/api/src/Definitions.ts @@ -14,7 +14,10 @@ * limitations under the License. */ -import type { PropertyValueWireToClient } from "./mapping/PropertyValueMapping.js"; +import type { + getClientPropertyValueFromWire, + PropertyValueWireToClient, +} from "./mapping/PropertyValueMapping.js"; import type { ObjectMetadata } from "./ontology/ObjectTypeDefinition.js"; type MaybeArray = @@ -34,12 +37,16 @@ type Converted = T extends Array ? T[1] : T; export type OsdkObjectPropertyType< T extends ObjectMetadata.Property, STRICTLY_ENFORCE_NULLABLE extends boolean = true, -> = STRICTLY_ENFORCE_NULLABLE extends false - ? MaybeArray> | undefined +> = STRICTLY_ENFORCE_NULLABLE extends false ? + | MaybeArray>> + | undefined : MaybeNullable< T, - MaybeArray> + MaybeArray>> >; export type OsdkObjectRawPropertyType = - MaybeNullable>>; + MaybeNullable< + T, + MaybeArray>> + >; diff --git a/packages/api/src/aggregate/AggregatableKeys.ts b/packages/api/src/aggregate/AggregatableKeys.ts index be41e468f..2c944e856 100644 --- a/packages/api/src/aggregate/AggregatableKeys.ts +++ b/packages/api/src/aggregate/AggregatableKeys.ts @@ -14,7 +14,10 @@ * limitations under the License. */ -import type { PropertyValueClientToWire } from "../mapping/PropertyValueMapping.js"; +import type { + getWirePropertyValueFromClient, + PropertyValueClientToWire, +} from "../mapping/PropertyValueMapping.js"; import type { ObjectOrInterfaceDefinition, PropertyKeys, @@ -40,9 +43,9 @@ export type ValidAggregationKeys< & { [ KK in AggregatableKeys as `${KK & string}:${AGG_FOR_TYPE< - PropertyValueClientToWire[ + getWirePropertyValueFromClient< CompileTimeMetadata["properties"][KK]["type"] - ] + > >}` ]?: any; } diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index 690d7a1c8..b1e5d36c2 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -107,7 +107,10 @@ export type { ThreeDimensionalQueryAggregationDefinition, TwoDimensionalQueryAggregationDefinition, } from "./ontology/QueryDefinition.js"; -export type { WirePropertyTypes } from "./ontology/WirePropertyTypes.js"; +export type { + SimpleWirePropertyTypes, + WirePropertyTypes, +} from "./ontology/WirePropertyTypes.js"; export type { OsdkBase, PrimaryKeyType } from "./OsdkBase.js"; export type { OsdkObject } from "./OsdkObject.js"; export type { ConvertProps, Osdk } from "./OsdkObjectFrom.js"; diff --git a/packages/api/src/mapping/PropertyValueMapping.ts b/packages/api/src/mapping/PropertyValueMapping.ts index b1908f331..fb9bd87a6 100644 --- a/packages/api/src/mapping/PropertyValueMapping.ts +++ b/packages/api/src/mapping/PropertyValueMapping.ts @@ -46,6 +46,13 @@ export interface PropertyValueWireToClient { geotimeSeriesReference: GeotimeSeriesProperty; } +export type getClientPropertyValueFromWire< + T extends + | keyof PropertyValueWireToClient + | Record, +> = T extends keyof PropertyValueWireToClient ? PropertyValueWireToClient[T] + : T; + /** * Map from the PropertyDefinition type to the typescript type that we accept */ @@ -71,3 +78,9 @@ export interface PropertyValueClientToWire { sensorTimeseries: TimeSeriesProperty; geotimeSeriesReference: GeotimeSeriesProperty; } +export type getWirePropertyValueFromClient< + T extends + | keyof PropertyValueClientToWire + | Record, +> = T extends keyof PropertyValueClientToWire ? PropertyValueClientToWire[T] + : T; diff --git a/packages/api/src/ontology/WirePropertyTypes.ts b/packages/api/src/ontology/WirePropertyTypes.ts index e30e40c10..173ce8c42 100644 --- a/packages/api/src/ontology/WirePropertyTypes.ts +++ b/packages/api/src/ontology/WirePropertyTypes.ts @@ -15,6 +15,10 @@ */ export type WirePropertyTypes = + | SimpleWirePropertyTypes + | Record; + +export type SimpleWirePropertyTypes = | "string" | "datetime" | "double" diff --git a/packages/cli.cmd.typescript/package.json b/packages/cli.cmd.typescript/package.json index 98aac85eb..0e5e89a05 100644 --- a/packages/cli.cmd.typescript/package.json +++ b/packages/cli.cmd.typescript/package.json @@ -32,8 +32,8 @@ "@arethetypeswrong/cli": "^0.15.2", "@osdk/cli.common": "workspace:~", "@osdk/generator": "workspace:~", - "@osdk/internal.foundry.core": "2.6.0-beta.1", - "@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.1", + "@osdk/internal.foundry.core": "2.8.0", + "@osdk/internal.foundry.ontologiesv2": "2.8.0", "@osdk/shared.client.impl": "workspace:~", "consola": "^3.2.3", "fast-deep-equal": "^3.1.3", diff --git a/packages/client/package.json b/packages/client/package.json index a3b3e6c78..bfd0d51eb 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -35,8 +35,8 @@ "@osdk/api": "workspace:~", "@osdk/client.unstable": "workspace:*", "@osdk/generator-converters": "workspace:*", - "@osdk/internal.foundry.core": "2.6.0-beta.1", - "@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.1", + "@osdk/internal.foundry.core": "2.8.0", + "@osdk/internal.foundry.ontologiesv2": "2.8.0", "@osdk/shared.client": "^1.0.1", "@osdk/shared.client.impl": "workspace:~", "@osdk/shared.client2": "^1.0.0", diff --git a/packages/client/src/object/aggregate.test.ts b/packages/client/src/object/aggregate.test.ts index 500f7fd4d..e390d6e54 100644 --- a/packages/client/src/object/aggregate.test.ts +++ b/packages/client/src/object/aggregate.test.ts @@ -17,7 +17,10 @@ import type { AggregateOpts, AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy, + CompileTimeMetadata, GroupByClause, + ObjectOrInterfaceDefinition, + PropertyKeys, ValidAggregationKeys, } from "@osdk/api"; import type { Employee } from "@osdk/client.test.ontology"; @@ -37,6 +40,9 @@ import { type Mock, vi, } from "vitest"; +import type { getWirePropertyValueFromClient } from "../../../api/build/esm/mapping/PropertyValueMapping.js"; +import type { Client } from "../Client.js"; +import { createClient } from "../createClient.js"; import { createMinimalClient } from "../createMinimalClient.js"; import type { MinimalClient } from "../MinimalClientContext.js"; import { aggregate } from "./aggregate.js"; @@ -50,6 +56,7 @@ const metadata = { let mockFetch: Mock; let clientCtx: MinimalClient; +let client: Client; beforeAll(() => { mockFetch = vi.fn(); @@ -63,10 +70,18 @@ beforeAll(() => { clientCtx = createMinimalClient( metadata, "https://host.com", - async () => "", + async () => "myAccessToken", {}, mockFetch, ); + + client = createClient( + "https://host.com", + metadata.ontologyRid, + async () => "", + undefined, + mockFetch, + ); }); const aggregationResponse: AggregateObjectsResponseV2 = { @@ -171,13 +186,7 @@ describe("aggregate", () => { > >(false); // subSelect should hide unused keys - const grouped = await aggregate( - clientCtx, - objectTypeWithAllPropertyTypes, - { - type: "base", - objectType: "ToDo", - }, + const grouped = await client(objectTypeWithAllPropertyTypes).aggregate( { $select: { "id:approximateDistinct": "unordered", @@ -509,13 +518,7 @@ describe("aggregate", () => { }); it("prohibits ordered select with multiple groupBy", async () => { - aggregate( - clientCtx, - Todo, - { - type: "base", - objectType: "ToDo", - }, + client(Todo).aggregate( { $select: { // @ts-expect-error diff --git a/packages/client/src/object/object.test.ts b/packages/client/src/object/object.test.ts index ea66c4209..c822fbdfa 100644 --- a/packages/client/src/object/object.test.ts +++ b/packages/client/src/object/object.test.ts @@ -185,6 +185,7 @@ describe("OsdkObject", () => { it("objects are enumerable in an sdk", async () => { const objects = Object.keys($Objects); expect(objects.sort()).toStrictEqual([ + "BgaoNflPlayer", "Employee", "ObjectWithTimestampPrimaryKey", "Office", diff --git a/packages/client/src/objectSet/ObjectSet.test.ts b/packages/client/src/objectSet/ObjectSet.test.ts index becabb943..a87dd25bf 100644 --- a/packages/client/src/objectSet/ObjectSet.test.ts +++ b/packages/client/src/objectSet/ObjectSet.test.ts @@ -29,6 +29,7 @@ import { isOk, WhereClause } from "@osdk/api"; import { $ontologyRid, BarInterface, + BgaoNflPlayer, Employee, FooInterface, Office, @@ -207,6 +208,39 @@ describe("ObjectSet", () => { expect(employee.$primaryKey).toBe(stubData.employee1.employeeId); }); + it("check struct parsing", async () => { + const player = await client(BgaoNflPlayer).fetchOne( + "tkelce", + ); + expectTypeOf().toMatchTypeOf< + Osdk> + >; + + expectTypeOf().toMatchTypeOf< + string | undefined + >; + expect(player.address.addressLine1).toEqual("15 Muppets Lane"); + expectTypeOf().toMatchTypeOf< + string | undefined + >; + expect(player.address.addressLine2).toEqual("Resort No 4"); + + expectTypeOf().toMatchTypeOf< + string | undefined + >; + expect(player.address.city).toEqual("Memphis"); + expectTypeOf().toMatchTypeOf< + string | undefined + >; + expect(player.address.state).toEqual("TN"); + expectTypeOf().toMatchTypeOf< + number | undefined + >; + expect(player.address.zipCode).toEqual(11100); + expect(player.$primaryKey).toEqual(stubData.travisPlayer.__primaryKey); + expect(player.address).toEqual(stubData.travisPlayer.address); + }); + it("allows fetching by PK from a base object set - fetchOneWithErrors", async () => { const employeeResult = await client(Employee) .fetchOneWithErrors( diff --git a/packages/e2e.generated.catchall/ontology.json b/packages/e2e.generated.catchall/ontology.json index ea1ea2a41..8bf03a106 100644 --- a/packages/e2e.generated.catchall/ontology.json +++ b/packages/e2e.generated.catchall/ontology.json @@ -510,6 +510,89 @@ }, "linkTypes": [] }, + "BgaoNflPlayer": { + "objectType": { + "apiName": "BgaoNflPlayer", + "primaryKey": "id", + "displayName": "BgaoNflPlayer", + "description": "BgaoNflPlayer", + "properties": { + "id": { + "dataType": { + "type": "string" + } + }, + "gamesPlayed": { + "dataType": { + "type": "integer" + } + }, + "name": { + "dataType": { + "type": "string" + } + }, + "number": { + "dataType": { + "type": "integer" + } + }, + "wikiUrl": { + "dataType": { + "type": "string" + } + }, + "address": { + "dataType": { + "type": "struct", + "structFieldTypes": [ + { + "apiName": "addressLine1", + "dataType": { + "type": "string" + } + }, + { + "apiName": "addressLine2", + "dataType": { + "type": "string" + } + }, + { + "apiName": "city", + "dataType": { + "type": "string" + } + }, + { + "apiName": "state", + "dataType": { + "type": "string" + } + }, + { + "apiName": "zipCode", + "dataType": { + "type": "integer" + } + } + ] + } + } + }, + + "status": "ACTIVE", + "rid": "ri.a.b.c.d", + "icon": { + "type": "blueprint", + "name": "traffic", + "color": "color" + }, + "titleProperty": "entityId", + "pluralDisplayName": "GtfsTripTrackObject" + }, + "linkTypes": [] + }, "DherlihyComplexObject": { "objectType": { "apiName": "DherlihyComplexObject", diff --git a/packages/e2e.generated.catchall/src/generatedNoCheck/index.ts b/packages/e2e.generated.catchall/src/generatedNoCheck/index.ts index b22d4be86..3344b40be 100644 --- a/packages/e2e.generated.catchall/src/generatedNoCheck/index.ts +++ b/packages/e2e.generated.catchall/src/generatedNoCheck/index.ts @@ -10,6 +10,7 @@ export * as $Actions from './ontology/actions.js'; export { FooInterface, InterfaceNoProps, OsdkTestInterface } from './ontology/interfaces.js'; export * as $Interfaces from './ontology/interfaces.js'; export { + BgaoNflPlayer, BoundariesUsState, BuilderDeploymentState, DherlihyComplexObject, diff --git a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects.ts b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects.ts index 9fd264ee6..6344d4430 100644 --- a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects.ts +++ b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects.ts @@ -1,3 +1,4 @@ +export { BgaoNflPlayer } from './objects/BgaoNflPlayer.js'; export { BoundariesUsState } from './objects/BoundariesUsState.js'; export { BuilderDeploymentState } from './objects/BuilderDeploymentState.js'; export { DherlihyComplexObject } from './objects/DherlihyComplexObject.js'; diff --git a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/BgaoNflPlayer.ts b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/BgaoNflPlayer.ts new file mode 100644 index 000000000..6bce9a52e --- /dev/null +++ b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/BgaoNflPlayer.ts @@ -0,0 +1,116 @@ +import type { PropertyDef as $PropertyDef } from '@osdk/client'; +import { $osdkMetadata } from '../../OntologyMetadata.js'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata.js'; +import type { + PropertyKeys as $PropertyKeys, + ObjectTypeDefinition as $ObjectTypeDefinition, + ObjectMetadata as $ObjectMetadata, +} from '@osdk/client'; +import type { + ObjectSet as $ObjectSet, + Osdk as $Osdk, + OsdkObject as $OsdkObject, + PropertyValueWireToClient as $PropType, + SingleLinkAccessor as $SingleLinkAccessor, +} from '@osdk/client'; + +export namespace BgaoNflPlayer { + export type PropertyKeys = 'id' | 'gamesPlayed' | 'name' | 'number' | 'wikiUrl' | 'address'; + + export type Links = {}; + + export interface Props { + readonly address: { + addressLine1: $PropType['string'] | undefined; + addressLine2: $PropType['string'] | undefined; + city: $PropType['string'] | undefined; + state: $PropType['string'] | undefined; + zipCode: $PropType['integer'] | undefined; + }; + readonly gamesPlayed: $PropType['integer'] | undefined; + readonly id: $PropType['string']; + readonly name: $PropType['string'] | undefined; + readonly number: $PropType['integer'] | undefined; + readonly wikiUrl: $PropType['string'] | undefined; + } + export type StrictProps = Props; + + export interface ObjectSet extends $ObjectSet {} + + export type OsdkInstance< + OPTIONS extends never | '$rid' = never, + K extends keyof BgaoNflPlayer.Props = keyof BgaoNflPlayer.Props, + > = $Osdk.Instance; + + /** @deprecated use OsdkInstance */ + export type OsdkObject< + OPTIONS extends never | '$rid' = never, + K extends keyof BgaoNflPlayer.Props = keyof BgaoNflPlayer.Props, + > = OsdkInstance; +} + +export interface BgaoNflPlayer extends $ObjectTypeDefinition { + osdkMetadata: typeof $osdkMetadata; + type: 'object'; + apiName: 'BgaoNflPlayer'; + __DefinitionMetadata?: { + objectSet: BgaoNflPlayer.ObjectSet; + props: BgaoNflPlayer.Props; + linksType: BgaoNflPlayer.Links; + strictProps: BgaoNflPlayer.StrictProps; + apiName: 'BgaoNflPlayer'; + description: 'BgaoNflPlayer'; + displayName: 'BgaoNflPlayer'; + icon: { + type: 'blueprint'; + name: 'traffic'; + color: 'color'; + }; + interfaceMap: {}; + inverseInterfaceMap: {}; + links: {}; + pluralDisplayName: 'GtfsTripTrackObject'; + primaryKeyApiName: 'id'; + primaryKeyType: 'string'; + properties: { + /** + * (no ontology metadata) + */ + address: $PropertyDef< + { addressLine1: 'string'; addressLine2: 'string'; city: 'string'; state: 'string'; zipCode: 'integer' }, + 'nullable', + 'single' + >; + /** + * (no ontology metadata) + */ + gamesPlayed: $PropertyDef<'integer', 'nullable', 'single'>; + /** + * (no ontology metadata) + */ + id: $PropertyDef<'string', 'non-nullable', 'single'>; + /** + * (no ontology metadata) + */ + name: $PropertyDef<'string', 'nullable', 'single'>; + /** + * (no ontology metadata) + */ + number: $PropertyDef<'integer', 'nullable', 'single'>; + /** + * (no ontology metadata) + */ + wikiUrl: $PropertyDef<'string', 'nullable', 'single'>; + }; + rid: 'ri.a.b.c.d'; + status: 'ACTIVE'; + titleProperty: 'entityId'; + type: 'object'; + }; +} + +export const BgaoNflPlayer: BgaoNflPlayer = { + type: 'object', + apiName: 'BgaoNflPlayer', + osdkMetadata: $osdkMetadata, +}; diff --git a/packages/foundry-sdk-generator/package.json b/packages/foundry-sdk-generator/package.json index 18d1a5d95..f0c702f31 100644 --- a/packages/foundry-sdk-generator/package.json +++ b/packages/foundry-sdk-generator/package.json @@ -33,12 +33,12 @@ "dependencies": { "@osdk/api": "workspace:*", "@osdk/client": "workspace:*", - "@osdk/foundry.core": "2.6.0-beta.1", - "@osdk/foundry.thirdpartyapplications": "2.6.0-beta.1", + "@osdk/foundry.core": "2.8.0", + "@osdk/foundry.thirdpartyapplications": "2.8.0", "@osdk/generator": "workspace:*", - "@osdk/internal.foundry.core": "2.6.0-beta.1", - "@osdk/internal.foundry.ontologies": "2.6.0-beta.1", - "@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.1", + "@osdk/internal.foundry.core": "2.8.0", + "@osdk/internal.foundry.ontologies": "2.8.0", + "@osdk/internal.foundry.ontologiesv2": "2.8.0", "@osdk/shared.client.impl": "workspace:*", "@rollup/plugin-commonjs": "28.0.0", "@rollup/plugin-node-resolve": "15.3.0", diff --git a/packages/generator-converters/package.json b/packages/generator-converters/package.json index 6f843eeb6..0107d8bbd 100644 --- a/packages/generator-converters/package.json +++ b/packages/generator-converters/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "@osdk/api": "workspace:~", - "@osdk/internal.foundry.core": "2.6.0-beta.1" + "@osdk/internal.foundry.core": "2.8.0" }, "devDependencies": { "@osdk/monorepo.api-extractor": "workspace:~", diff --git a/packages/generator-converters/src/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts b/packages/generator-converters/src/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts index c89cd9aff..f0788bc93 100644 --- a/packages/generator-converters/src/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts +++ b/packages/generator-converters/src/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts @@ -46,6 +46,8 @@ export function wirePropertyV2ToSdkPrimaryKeyTypeDefinition( case "float": case "geotimeSeriesReference": case "mediaReference": + case "struct": + case "cipherText": throw new Error( `Type not supported for primaryKey: ${input.dataType.type}`, ); diff --git a/packages/generator-converters/src/wirePropertyV2ToSdkPropertyDefinition.ts b/packages/generator-converters/src/wirePropertyV2ToSdkPropertyDefinition.ts index 8fcf668e9..b5602d50e 100644 --- a/packages/generator-converters/src/wirePropertyV2ToSdkPropertyDefinition.ts +++ b/packages/generator-converters/src/wirePropertyV2ToSdkPropertyDefinition.ts @@ -14,7 +14,11 @@ * limitations under the License. */ -import type { ObjectMetadata, WirePropertyTypes } from "@osdk/api"; +import type { + ObjectMetadata, + SimpleWirePropertyTypes, + WirePropertyTypes, +} from "@osdk/api"; import type { ObjectPropertyType, PropertyV2, @@ -43,6 +47,7 @@ export function wirePropertyV2ToSdkPropertyDefinition( case "timeseries": case "marking": case "geotimeSeriesReference": + case "struct": return { displayName: input.displayName, multiplicity: false, @@ -59,9 +64,10 @@ export function wirePropertyV2ToSdkPropertyDefinition( nullable: true, }; } + case "cipherText": case "mediaReference": { throw new Error( - `Media references not supported yet`, + `${input.dataType.type} not supported yet`, ); } default: @@ -102,10 +108,23 @@ function objectPropertyTypeToSdkPropertyDefinition( } else if (propertyType.itemType?.type === "double") { return "numericTimeseries"; } else return "sensorTimeseries"; + case "struct": { + return propertyType.structFieldTypes.reduce( + (structMap: Record, structField) => { + structMap[structField.apiName] = + objectPropertyTypeToSdkPropertyDefinition( + structField.dataType, + ) as SimpleWirePropertyTypes; + return structMap; + }, + {}, + ); + } - case "mediaReference": { + case "mediaReference": + case "cipherText": { throw new Error( - `Media references not supported yet`, + `${propertyType.type} not supported yet`, ); } default: diff --git a/packages/generator/package.json b/packages/generator/package.json index 1c03c4862..830cd4d42 100644 --- a/packages/generator/package.json +++ b/packages/generator/package.json @@ -33,7 +33,7 @@ "dependencies": { "@osdk/api": "workspace:~", "@osdk/generator-converters": "workspace:~", - "@osdk/internal.foundry.core": "2.6.0-beta.1", + "@osdk/internal.foundry.core": "2.8.0", "fast-deep-equal": "^3.1.3", "fetch-retry": "^6.0.0", "prettier": "^3.0.3", diff --git a/packages/generator/src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts b/packages/generator/src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts index 0f5f2172e..49b25744b 100644 --- a/packages/generator/src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts +++ b/packages/generator/src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts @@ -228,16 +228,18 @@ ${ // after we convert everything over we can do this: // !strict || propertyDefinition.nullable ? "?" : "" ""}`, - `$PropType[${JSON.stringify(propertyDefinition.type)}]${ - propertyDefinition.multiplicity ? "[]" : "" - }${ - propertyDefinition.nullable - || (!strict - && !(definition.type === "object" - && definition.primaryKeyApiName === apiName)) - ? `| undefined` - : "" - }`, + typeof propertyDefinition.type === "object" + ? `${remapStructType(propertyDefinition.type)}` + : `$PropType[${JSON.stringify(propertyDefinition.type)}]${ + propertyDefinition.multiplicity ? "[]" : "" + }${ + propertyDefinition.nullable + || (!strict + && !(definition.type === "object" + && definition.primaryKeyApiName === apiName)) + ? `| undefined` + : "" + }`, ] as [string, string]; }, }) @@ -294,7 +296,7 @@ export function createDefinition( `${propertyJsdoc(propertyDefinition, { apiName })}"${ maybeStripNamespace(object, apiName) }"`, - `$PropertyDef<"${propertyDefinition.type}", "${ + `$PropertyDef<${JSON.stringify(propertyDefinition.type)}, "${ propertyDefinition.nullable ? "nullable" : "non-nullable" }", "${propertyDefinition.multiplicity ? "array" : "single"}">`, ] as [string, string], @@ -358,3 +360,12 @@ export function createPropertyKeys( ).map(a => `"${a}"`).join("|") };`; } + +function remapStructType(structType: Record): string { + let output = `{`; + Object.entries(structType).map(([key, value]) => + output += `${key}:$PropType[${JSON.stringify(value)}]|undefined;` + ); + output += "}"; + return output; +} diff --git a/packages/maker/package.json b/packages/maker/package.json index 6ff4ad744..e8fd1aca3 100644 --- a/packages/maker/package.json +++ b/packages/maker/package.json @@ -37,7 +37,7 @@ }, "devDependencies": { "@osdk/client.unstable": "workspace:~", - "@osdk/internal.foundry.core": "2.6.0-beta.1", + "@osdk/internal.foundry.core": "2.8.0", "@osdk/monorepo.api-extractor": "workspace:~", "@osdk/monorepo.tsconfig": "workspace:~", "@osdk/monorepo.tsup": "workspace:~", diff --git a/packages/maker/src/api/defineObject.ts b/packages/maker/src/api/defineObject.ts index 70ba4215c..d23d322a0 100644 --- a/packages/maker/src/api/defineObject.ts +++ b/packages/maker/src/api/defineObject.ts @@ -88,7 +88,8 @@ function convertType( t: api.ObjectMetadata.Property & { apiName: string; }, -): PropertyV2["dataType"] { + // TODO: ssanjay fix return type +): any { switch (true) { case t.multiplicity === true: return { diff --git a/packages/monorepo.cspell/dict.osdk-code.txt b/packages/monorepo.cspell/dict.osdk-code.txt index 29e9db723..098adb884 100644 --- a/packages/monorepo.cspell/dict.osdk-code.txt +++ b/packages/monorepo.cspell/dict.osdk-code.txt @@ -49,4 +49,10 @@ Fintraffic Rhemmings mnsi Gtfs -wmata \ No newline at end of file +wmata +Bgao +tkelce +Muppets +ssanjay +Kelce +nflplayer \ No newline at end of file diff --git a/packages/shared.test/package.json b/packages/shared.test/package.json index 5d1335ab4..4f5f5f315 100644 --- a/packages/shared.test/package.json +++ b/packages/shared.test/package.json @@ -31,10 +31,10 @@ }, "dependencies": { "@osdk/api": "workspace:~", - "@osdk/internal.foundry.core": "2.6.0-beta.1", - "@osdk/internal.foundry.geo": "2.6.0-beta.1", - "@osdk/internal.foundry.ontologies": "2.6.0-beta.1", - "@osdk/internal.foundry.ontologiesv2": "2.6.0-beta.1", + "@osdk/internal.foundry.core": "2.8.0", + "@osdk/internal.foundry.geo": "2.8.0", + "@osdk/internal.foundry.ontologies": "2.8.0", + "@osdk/internal.foundry.ontologiesv2": "2.8.0", "fetch-retry": "^6.0.0", "json-stable-stringify": "^1.1.1", "msw": "^2.3.4", diff --git a/packages/shared.test/src/stubs/objectSetRequest.ts b/packages/shared.test/src/stubs/objectSetRequest.ts index 9a8439b4b..8357e9b81 100644 --- a/packages/shared.test/src/stubs/objectSetRequest.ts +++ b/packages/shared.test/src/stubs/objectSetRequest.ts @@ -27,8 +27,10 @@ import { nycOffice, objectWithAllPropertyTypes1, objectWithAllPropertyTypesEmptyEntries, + travisPlayer, } from "./objects.js"; import { employeeObjectType, officeObjectType } from "./objectTypes.js"; +import { BGaoNflPlayerObjectType } from "./objectTypeV2.js"; const baseObjectSet: LoadObjectSetRequestV2 = { objectSet: { type: "base", objectType: employeeObjectType.apiName }, @@ -107,6 +109,19 @@ const eqSearchBody2: LoadObjectSetRequestV2 = { select: [], }; +const eqSearchBody3: LoadObjectSetRequestV2 = { + objectSet: { + type: "filter", + objectSet: { type: "base", objectType: BGaoNflPlayerObjectType.apiName }, + where: { + type: "eq", + field: BGaoNflPlayerObjectType.primaryKey, + value: "tkelce", + }, + }, + select: [], +}; + const eqSearchBodyBadObject: LoadObjectSetRequestV2 = { objectSet: { type: "filter", @@ -469,4 +484,5 @@ export const loadObjectSetRequestHandlers: { [stableStringify(employee1LeadSearchAround)]: [employee2], [stableStringify(employee2ToPeepsSearchAround)]: [employee1, employee2], [stableStringify(employee2ToToEmployee1PeepByPk)]: [employee1], + [stableStringify(eqSearchBody3)]: [travisPlayer], }; diff --git a/packages/shared.test/src/stubs/objectTypeV2.ts b/packages/shared.test/src/stubs/objectTypeV2.ts index d4d5880ec..99c76b759 100644 --- a/packages/shared.test/src/stubs/objectTypeV2.ts +++ b/packages/shared.test/src/stubs/objectTypeV2.ts @@ -492,3 +492,84 @@ export const personObjectType: ObjectTypeV2 = { status: "ACTIVE", titleProperty: "name", }; + +export const BGaoNflPlayerObjectType: ObjectTypeV2 = { + apiName: "BgaoNflPlayer", + displayName: "id", + pluralDisplayName: "BgaoNflPlayers", + icon: { type: "blueprint", color: "blue", name: "box" }, + primaryKey: "id", + properties: { + id: { + dataType: { + type: "string", + }, + rid: "rid", + }, + gamesPlayed: { + dataType: { + type: "integer", + }, + rid: "rid", + }, + name: { + dataType: { + type: "string", + }, + rid: "rid", + }, + number: { + dataType: { + type: "integer", + }, + rid: "rid", + }, + wikiUrl: { + dataType: { + type: "string", + }, + rid: "rid", + }, + address: { + dataType: { + type: "struct", + structFieldTypes: [ + { + apiName: "addressLine1", + dataType: { + type: "string", + }, + }, + { + apiName: "addressLine2", + dataType: { + type: "string", + }, + }, + { + apiName: "city", + dataType: { + type: "string", + }, + }, + { + apiName: "state", + dataType: { + type: "string", + }, + }, + { + apiName: "zipCode", + dataType: { + type: "integer", + }, + }, + ], + }, + rid: "rid", + }, + }, + rid: "ri.nflplayer", + status: "ACTIVE", + titleProperty: "name", +}; diff --git a/packages/shared.test/src/stubs/objectTypesWithLinkTypes.ts b/packages/shared.test/src/stubs/objectTypesWithLinkTypes.ts index 31ebac678..748c14bfa 100644 --- a/packages/shared.test/src/stubs/objectTypesWithLinkTypes.ts +++ b/packages/shared.test/src/stubs/objectTypesWithLinkTypes.ts @@ -25,6 +25,7 @@ import { peepsLinkType, } from "./linkTypes.js"; import { + BGaoNflPlayerObjectType, employeeObjectType, equipmentObjectType, objectTypeWithAllPropertyTypes, @@ -124,6 +125,14 @@ export const personWithLinkTypes: ObjectTypeFullMetadata = { sharedPropertyTypeMapping: {}, }; +export const bGaoNflPlayerWithLinkTypes: ObjectTypeFullMetadata = { + objectType: BGaoNflPlayerObjectType, + linkTypes: [], + implementsInterfaces: [], + implementsInterfaces2: {}, + sharedPropertyTypeMapping: {}, +}; + export const objectTypesWithLinkTypes: { [objectTypeApiName: string]: ObjectTypeFullMetadata; } = { @@ -138,4 +147,5 @@ export const objectTypesWithLinkTypes: { [todoObjectType.apiName]: todoWithLinkTypes, [taskObjectType.apiName]: taskWithLinkTypes, [personObjectType.apiName]: personWithLinkTypes, + [BGaoNflPlayerObjectType.apiName]: bGaoNflPlayerWithLinkTypes, }; diff --git a/packages/shared.test/src/stubs/objects.ts b/packages/shared.test/src/stubs/objects.ts index b0b3e3307..e338e7abf 100644 --- a/packages/shared.test/src/stubs/objects.ts +++ b/packages/shared.test/src/stubs/objects.ts @@ -106,6 +106,26 @@ export const nycOffice: OntologyObjectV2 = { occupiedArea: officeAreaGeoJson, }; +export const travisPlayer = { + __rid: + "ri.phonograph2-objects.main.object.c0c0c3c0-c0c0-c0c0-c0c0-c0c0c0c0c0c0", + __primaryKey: "tkelce", + __apiName: "BgaoNflPlayer", + __title: "tkelce", + gamesPlayed: 171, + name: "Travis Kelce", + number: 87, + wikiUrl: "myKelce.com", + address: { + addressLine1: "15 Muppets Lane", + addressLine2: "Resort No 4", + city: "Memphis", + state: "TN", + zipCode: 11100, + }, + id: "tkelce", +}; + export const objectWithAllPropertyTypes1: OntologyObjectV2 = { __rid: "ri.phonograph2-objects.main.object.401ac022-89eb-4591-8b7e-0a912b9efb44", @@ -210,4 +230,5 @@ export const objectLoadResponseMap: { [objectWithAllPropertyTypesEmptyEntries.__primaryKey.toString()]: objectWithAllPropertyTypesEmptyEntries, }, + BgaoNflPlayer: { [travisPlayer.__primaryKey.toString()]: travisPlayer }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1a82b45f8..b8544d286 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1064,11 +1064,11 @@ importers: specifier: workspace:~ version: link:../generator '@osdk/internal.foundry.core': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/internal.foundry.ontologiesv2': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/shared.client.impl': specifier: workspace:~ version: link:../shared.client.impl @@ -1156,11 +1156,11 @@ importers: specifier: workspace:* version: link:../generator-converters '@osdk/internal.foundry.core': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/internal.foundry.ontologiesv2': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/shared.client': specifier: ^1.0.1 version: 1.0.1 @@ -2715,23 +2715,23 @@ importers: specifier: workspace:* version: link:../client '@osdk/foundry.core': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/foundry.thirdpartyapplications': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/generator': specifier: workspace:* version: link:../generator '@osdk/internal.foundry.core': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/internal.foundry.ontologies': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/internal.foundry.ontologiesv2': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/shared.client.impl': specifier: workspace:* version: link:../shared.client.impl @@ -2800,8 +2800,8 @@ importers: specifier: workspace:~ version: link:../generator-converters '@osdk/internal.foundry.core': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 fast-deep-equal: specifier: ^3.1.3 version: 3.1.3 @@ -2846,8 +2846,8 @@ importers: specifier: workspace:~ version: link:../api '@osdk/internal.foundry.core': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 devDependencies: '@osdk/monorepo.api-extractor': specifier: workspace:~ @@ -2924,8 +2924,8 @@ importers: specifier: workspace:~ version: link:../client.unstable '@osdk/internal.foundry.core': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/monorepo.api-extractor': specifier: workspace:~ version: link:../monorepo.api-extractor @@ -3147,17 +3147,17 @@ importers: specifier: workspace:~ version: link:../api '@osdk/internal.foundry.core': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/internal.foundry.geo': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/internal.foundry.ontologies': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 '@osdk/internal.foundry.ontologiesv2': - specifier: 2.6.0-beta.1 - version: 2.6.0-beta.1 + specifier: 2.8.0 + version: 2.8.0 fetch-retry: specifier: ^6.0.0 version: 6.0.0 @@ -4938,8 +4938,8 @@ packages: '@osdk/foundry.core@2.5.0': resolution: {integrity: sha512-LV+m6/3Y+Q0lN16PAwQvoWtutY0xXdntuwOQjMR2ZqdLRlZOK2KSvfwNZnX4q8EKuvF1mJC8iaTtWh3lChpU1Q==} - '@osdk/foundry.core@2.6.0-beta.1': - resolution: {integrity: sha512-4/nX4we3w3oM57Y2THeNfZtQtZAwP8bniGTfL/5xAIhvYfFbTFkh7LhsLglym7LIfGEISu+pu9zYHT4O82JfZQ==} + '@osdk/foundry.core@2.8.0': + resolution: {integrity: sha512-Q7ubdwbRKIv6CC1ePwd0boIwp2Zp8yHHrniNsa/AqmgIT7+tC+8XKirOa/6ok4OooOUmpk1ufwZZUjjsYe1xPg==} '@osdk/foundry.datasets@2.1.0': resolution: {integrity: sha512-cqQAhiC+w/775SlifFV7yyvlQxMM8VKuRrSgXy93CCyI4W73jWEwS9+/PtKPXVa48T3G9bql8FckaIuwlknQfA==} @@ -4959,8 +4959,8 @@ packages: '@osdk/foundry.geo@2.5.0': resolution: {integrity: sha512-kL615eqHvn1MkP0le2r6vx/ub+lit5bKdmoWNRELMqi9s2BlLuoKAQW5H9YDQPqhHuJDjrBJAWiviOin9mUKqw==} - '@osdk/foundry.geo@2.6.0-beta.1': - resolution: {integrity: sha512-gOb17fWCk8PulqltSz0gmoHgD0TkdKdGYBE09WSsaYDJLxQSwTvPjwWHNZqZFwpHJWfrH33qiCugrF62PKcNOw==} + '@osdk/foundry.geo@2.8.0': + resolution: {integrity: sha512-BBvP1ZHfrkA8VWHHvBPwqmhzgTA+Hh9skZNCrU79t2YMyf+MqJQM1tMi9Di8SzqXAF7sxbUtQFCp7H4W/9Bcbw==} '@osdk/foundry.ontologies@2.1.0': resolution: {integrity: sha512-CypiwtfyKXDIJU2S5tKkVuo7KRRIUQ42bWkUX94vDisqIkgJavMjVO+bevAcJ2sOkaGxbx8acjN1g7yOTdj+Wg==} @@ -4977,8 +4977,8 @@ packages: '@osdk/foundry.thirdpartyapplications@2.1.0': resolution: {integrity: sha512-xEu8PNb4f54JF1FgWJ+wJicqWtWMXQbvLXIdpwMLBEv5HtCXySvwYB0QChAhJbDxSfL0HP/e2VGF24VzkRzeKg==} - '@osdk/foundry.thirdpartyapplications@2.6.0-beta.1': - resolution: {integrity: sha512-5Vp68+oc8HCZaEEz2GEv+0w3bRqb+Ka3CYV4yl76q0CcWL6N1ELXH3RakplhEA3KSVi0NJ6KoukINrBd8kC39A==} + '@osdk/foundry.thirdpartyapplications@2.8.0': + resolution: {integrity: sha512-ie0j7is02dMb3K0KyopedQOFemNG70eNWbdab5FG1jAWcAqh13dV0QaaCXdlfm3OCHbPaFRyeBLZt+rO+JMY4A==} '@osdk/foundry@2.1.0': resolution: {integrity: sha512-F8xKprD8L00pfyreByzyqvTX3q4txEFnXziUW14o1K5Q+dWolUfL79ReRSSTRZ+R7A6yIDd2WZOWb4m9ee58LA==} @@ -4989,8 +4989,8 @@ packages: '@osdk/internal.foundry.core@0.2.0': resolution: {integrity: sha512-+It/huASzz4nK/kNVw+hILo2wapzE2ZfptIiem6iEt19KEQVtw/fqJ2VRGMUEop0Q4+rT3VLHdqkNxq5nSUzdA==} - '@osdk/internal.foundry.core@2.6.0-beta.1': - resolution: {integrity: sha512-zkxWo4Hdwrzz1IjFqvEg5s0dyrGszJw0wdGdSMZmsUICQtCA1k1DyGntKTVEY/76MSKTRCdIMlhTnT7WTiFTMA==} + '@osdk/internal.foundry.core@2.8.0': + resolution: {integrity: sha512-Qb12ztwkizw/zoS0JZGKmQwxoQPYxf2NrFL2zRnUIHItjOBemQhaPKU+0ku8hx+/z2VqSVifLRqrrSuSg6dKjA==} '@osdk/internal.foundry.datasets@0.2.0': resolution: {integrity: sha512-U1adaMni2PDMuF5S5ql4jzRY1drah10besAsO6rO3jkbcP+ISGja14t8161oAjKNiECFYT+CtTNhjyp4E3Xe2w==} @@ -4998,20 +4998,20 @@ packages: '@osdk/internal.foundry.geo@0.1.0': resolution: {integrity: sha512-6NbTIEos7LdderlnDj/kTqFSlAjgZe8gkXAqTYWSipRP6UqKRDPwYeOcnMIR4wHZwNblxGohgY6IELvAM2exoA==} - '@osdk/internal.foundry.geo@2.6.0-beta.1': - resolution: {integrity: sha512-tXi6dFLbOhmeFfmnGrNdZX2Zq8Fi1IONId1C+6l2y0WucSXfWrBR6qIfcw2+fgPDkO9TT9aExce8N9kBzj0ejA==} + '@osdk/internal.foundry.geo@2.8.0': + resolution: {integrity: sha512-rVpKWPZdSs40YqBrrpzieM+2psg/2PfPFCAQuuluqjAYQ7F4RSfpvwpZRfo4DHFDA3JYRBp7N2LBCv3hEopfNg==} '@osdk/internal.foundry.ontologies@0.2.0': resolution: {integrity: sha512-tAJtBupT5VShN9Q7XJ+bsx+3SeTle+l7kRuaYvVkfUvju1yxzHvhmJWyYHbnPpa4fFwZUVclcHI4NwNkbNK9cQ==} - '@osdk/internal.foundry.ontologies@2.6.0-beta.1': - resolution: {integrity: sha512-prS1K/rsODTQO5a25FoATAyMSYCEzJQfk2rPFvTX5XvQK1k1N2C6WNdIsJskRz61hSDh6SwFfdaXRAbFT1bpsg==} + '@osdk/internal.foundry.ontologies@2.8.0': + resolution: {integrity: sha512-iSPFKesgInWp5isWVWXDdng9oEWCn+AAPQYgJ6HrlrAriE+vON7MGXUJ34Qj5QR/yti3EHObERCz4ebS/1jJYA==} '@osdk/internal.foundry.ontologiesv2@0.2.0': resolution: {integrity: sha512-UUxcwGCfiX1+kvYrWgYxWe1JxttZk7X16XwrRUr8qLKjUTgqLXOvNMq6XtzfytQ7J/nOfbfcjxHBM2LNQwudag==} - '@osdk/internal.foundry.ontologiesv2@2.6.0-beta.1': - resolution: {integrity: sha512-bINbZdrqPUq8RUW+ViRENkVmFUxG9X3yn3lefZsG7lhVMTiYp7UpVJhYZh4qw0uSjcyUgwcyA53IpsoTjPYuWA==} + '@osdk/internal.foundry.ontologiesv2@2.8.0': + resolution: {integrity: sha512-+jg2xn5XRBMvXu/us7jyJnfuVD9VJRGLlRvP314b/SjfNkvm+3rpamZ6Di0hwL53EIePpsOFgpXl+Vf5iZ32pA==} '@osdk/internal.foundry@0.5.0': resolution: {integrity: sha512-mCxhEnzOkLde+3h7noVi9V+p1gh7kEzwquLXjGRJ2Ad8nDAyCxJRFkLpnzvsfjGHYrzgk2tZIuzjoQ0I7TlGaw==} @@ -5052,8 +5052,8 @@ packages: '@osdk/shared.net.platformapi@1.1.0': resolution: {integrity: sha512-386O8rYgxFAmhdwrPydTDTQZPvu7yLc4+kDiW/Xq+EbOzpNPfGR9x/YlCu6Q5YvSPZ4zWv5nApOPCw/nL6TQsg==} - '@osdk/shared.net.platformapi@1.2.0-beta.1': - resolution: {integrity: sha512-mMET8u54It/bJgK4MMim15iwifWLFsN+qzKM+v6t9IaE+jytFqrHmtM7DYsCeGxC1HKs4fbyf8iLFCbNDL5/5g==} + '@osdk/shared.net.platformapi@1.2.0': + resolution: {integrity: sha512-DbGitmb9/Cu9ok+hMUggo9l4coFWBidyu2Jn4w390hrjffHikT6pXk0q3XhaVT6WItHaEu32Jv2MYOyCrZrpQQ==} '@osdk/shared.net@1.12.1': resolution: {integrity: sha512-uJE124K3O21A1Of2TdOqMHBfrIYshcDSLr5em4v1vNZZGSsSCYUYGo5vvkS6vzUVDA2xSn/Uf2FgdzX6BWxIhQ==} @@ -11616,12 +11616,12 @@ snapshots: '@osdk/shared.client2': 1.0.0 '@osdk/shared.net.platformapi': 1.1.0 - '@osdk/foundry.core@2.6.0-beta.1': + '@osdk/foundry.core@2.8.0': dependencies: - '@osdk/foundry.geo': 2.6.0-beta.1 + '@osdk/foundry.geo': 2.8.0 '@osdk/shared.client': 1.0.1 '@osdk/shared.client2': 1.0.0 - '@osdk/shared.net.platformapi': 1.2.0-beta.1 + '@osdk/shared.net.platformapi': 1.2.0 '@osdk/foundry.datasets@2.1.0': dependencies: @@ -11663,11 +11663,11 @@ snapshots: '@osdk/shared.client2': 1.0.0 '@osdk/shared.net.platformapi': 1.1.0 - '@osdk/foundry.geo@2.6.0-beta.1': + '@osdk/foundry.geo@2.8.0': dependencies: '@osdk/shared.client': 1.0.1 '@osdk/shared.client2': 1.0.0 - '@osdk/shared.net.platformapi': 1.2.0-beta.1 + '@osdk/shared.net.platformapi': 1.2.0 '@osdk/foundry.ontologies@2.1.0': dependencies: @@ -11702,12 +11702,12 @@ snapshots: '@osdk/shared.client': 1.0.1 '@osdk/shared.net.platformapi': 0.3.2 - '@osdk/foundry.thirdpartyapplications@2.6.0-beta.1': + '@osdk/foundry.thirdpartyapplications@2.8.0': dependencies: - '@osdk/foundry.core': 2.6.0-beta.1 + '@osdk/foundry.core': 2.8.0 '@osdk/shared.client': 1.0.1 '@osdk/shared.client2': 1.0.0 - '@osdk/shared.net.platformapi': 1.2.0-beta.1 + '@osdk/shared.net.platformapi': 1.2.0 '@osdk/foundry@2.1.0': dependencies: @@ -11735,12 +11735,12 @@ snapshots: '@osdk/shared.client': 1.0.1 '@osdk/shared.net.platformapi': 0.3.2 - '@osdk/internal.foundry.core@2.6.0-beta.1': + '@osdk/internal.foundry.core@2.8.0': dependencies: - '@osdk/internal.foundry.geo': 2.6.0-beta.1 + '@osdk/internal.foundry.geo': 2.8.0 '@osdk/shared.client': 1.0.1 '@osdk/shared.client2': 1.0.0 - '@osdk/shared.net.platformapi': 1.2.0-beta.1 + '@osdk/shared.net.platformapi': 1.2.0 '@osdk/internal.foundry.datasets@0.2.0': dependencies: @@ -11753,11 +11753,11 @@ snapshots: '@osdk/shared.client': 1.0.1 '@osdk/shared.net.platformapi': 0.3.2 - '@osdk/internal.foundry.geo@2.6.0-beta.1': + '@osdk/internal.foundry.geo@2.8.0': dependencies: '@osdk/shared.client': 1.0.1 '@osdk/shared.client2': 1.0.0 - '@osdk/shared.net.platformapi': 1.2.0-beta.1 + '@osdk/shared.net.platformapi': 1.2.0 '@osdk/internal.foundry.ontologies@0.2.0': dependencies: @@ -11765,12 +11765,12 @@ snapshots: '@osdk/shared.client': 1.0.1 '@osdk/shared.net.platformapi': 0.3.2 - '@osdk/internal.foundry.ontologies@2.6.0-beta.1': + '@osdk/internal.foundry.ontologies@2.8.0': dependencies: - '@osdk/internal.foundry.core': 2.6.0-beta.1 + '@osdk/internal.foundry.core': 2.8.0 '@osdk/shared.client': 1.0.1 '@osdk/shared.client2': 1.0.0 - '@osdk/shared.net.platformapi': 1.2.0-beta.1 + '@osdk/shared.net.platformapi': 1.2.0 '@osdk/internal.foundry.ontologiesv2@0.2.0': dependencies: @@ -11778,12 +11778,12 @@ snapshots: '@osdk/shared.client': 1.0.1 '@osdk/shared.net.platformapi': 0.3.2 - '@osdk/internal.foundry.ontologiesv2@2.6.0-beta.1': + '@osdk/internal.foundry.ontologiesv2@2.8.0': dependencies: - '@osdk/internal.foundry.core': 2.6.0-beta.1 + '@osdk/internal.foundry.core': 2.8.0 '@osdk/shared.client': 1.0.1 '@osdk/shared.client2': 1.0.0 - '@osdk/shared.net.platformapi': 1.2.0-beta.1 + '@osdk/shared.net.platformapi': 1.2.0 '@osdk/internal.foundry@0.5.0': dependencies: @@ -11845,7 +11845,7 @@ snapshots: '@osdk/shared.client2': 1.0.0 '@osdk/shared.net.errors': 2.0.1 - '@osdk/shared.net.platformapi@1.2.0-beta.1': + '@osdk/shared.net.platformapi@1.2.0': dependencies: '@osdk/shared.client': 1.0.1 '@osdk/shared.client2': 1.0.0 @@ -12698,7 +12698,7 @@ snapshots: '@testing-library/dom@10.4.0': dependencies: '@babel/code-frame': 7.24.7 - '@babel/runtime': 7.24.5 + '@babel/runtime': 7.26.0 '@types/aria-query': 5.0.4 aria-query: 5.3.0 chalk: 4.1.2 @@ -14333,8 +14333,8 @@ snapshots: '@typescript-eslint/parser': 8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4) eslint: 9.13.0(jiti@1.21.6) eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@9.13.0(jiti@1.21.6)) - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.7.0)(typescript@5.5.4))(eslint-plugin-import@2.31.0)(eslint@9.7.0))(eslint@9.13.0(jiti@1.21.6)) + eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.7.0)(typescript@5.5.4))(eslint-plugin-import@2.31.0)(eslint@9.7.0))(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@9.13.0(jiti@1.21.6)) eslint-plugin-jsx-a11y: 6.10.1(eslint@9.13.0(jiti@1.21.6)) eslint-plugin-react: 7.37.1(eslint@9.13.0(jiti@1.21.6)) eslint-plugin-react-hooks: 5.0.0(eslint@9.13.0(jiti@1.21.6)) @@ -14352,13 +14352,13 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@9.13.0(jiti@1.21.6)): + eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.7.0)(typescript@5.5.4))(eslint-plugin-import@2.31.0)(eslint@9.7.0))(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)): dependencies: debug: 4.3.7 enhanced-resolve: 5.16.1 eslint: 9.13.0(jiti@1.21.6) - eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)) - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.7.0)(typescript@5.5.4))(eslint-plugin-import@2.31.0)(eslint@9.7.0))(eslint@9.13.0(jiti@1.21.6)) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.7.0)(typescript@5.5.4))(eslint-plugin-import@2.31.0)(eslint@9.7.0))(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@9.13.0(jiti@1.21.6)) fast-glob: 3.3.2 get-tsconfig: 4.7.5 is-core-module: 2.15.1 @@ -14386,14 +14386,14 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-module-utils@2.12.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)): + eslint-module-utils@2.12.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.7.0)(typescript@5.5.4))(eslint-plugin-import@2.31.0)(eslint@9.7.0))(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)): dependencies: debug: 3.2.7 optionalDependencies: '@typescript-eslint/parser': 8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4) eslint: 9.13.0(jiti@1.21.6) eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@9.13.0(jiti@1.21.6)) + eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.7.0)(typescript@5.5.4))(eslint-plugin-import@2.31.0)(eslint@9.7.0))(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)) transitivePeerDependencies: - supports-color @@ -14462,6 +14462,35 @@ snapshots: - eslint-import-resolver-webpack - supports-color + eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@9.13.0(jiti@1.21.6)): + dependencies: + '@rtsao/scc': 1.1.0 + array-includes: 3.1.8 + array.prototype.findlastindex: 1.2.5 + array.prototype.flat: 1.3.2 + array.prototype.flatmap: 1.3.2 + debug: 3.2.7 + doctrine: 2.1.0 + eslint: 9.13.0(jiti@1.21.6) + eslint-import-resolver-node: 0.3.9 + eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.11.0(eslint@9.7.0)(typescript@5.5.4))(eslint-plugin-import@2.31.0)(eslint@9.7.0))(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)))(eslint@9.13.0(jiti@1.21.6)) + hasown: 2.0.2 + is-core-module: 2.15.1 + is-glob: 4.0.3 + minimatch: 3.1.2 + object.fromentries: 2.0.8 + object.groupby: 1.0.3 + object.values: 1.2.0 + semver: 6.3.1 + string.prototype.trimend: 1.0.8 + tsconfig-paths: 3.15.0 + optionalDependencies: + '@typescript-eslint/parser': 8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.5.4) + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color + eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.7.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@9.7.0): dependencies: '@rtsao/scc': 1.1.0 From 71dcfb2c69eafac55a24ac52205656e5b12fb645 Mon Sep 17 00:00:00 2001 From: Saurav Date: Sat, 7 Dec 2024 14:42:19 -0500 Subject: [PATCH 2/6] fix maker package --- packages/maker/src/api/defineObject.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/maker/src/api/defineObject.ts b/packages/maker/src/api/defineObject.ts index d23d322a0..0f29f29e4 100644 --- a/packages/maker/src/api/defineObject.ts +++ b/packages/maker/src/api/defineObject.ts @@ -16,6 +16,7 @@ import type * as api from "@osdk/api"; import type { + ObjectPropertyType, ObjectTypeFullMetadata, PropertyV2, } from "@osdk/internal.foundry.core"; @@ -88,8 +89,7 @@ function convertType( t: api.ObjectMetadata.Property & { apiName: string; }, - // TODO: ssanjay fix return type -): any { +): PropertyV2["dataType"] { switch (true) { case t.multiplicity === true: return { @@ -123,7 +123,15 @@ function convertType( return { type: "timestamp", }; - + case typeof t.type === "object": { + return { + type: "struct", + structFieldTypes: Object.entries(t.type).map(([apiName, dataType]) => ({ + apiName, + dataType: { type: dataType } as ObjectPropertyType, + })), + }; + } default: return { type: t.type, From a8be10e373c11e685574424eaa93c1c1a21822cb Mon Sep 17 00:00:00 2001 From: Saurav Date: Mon, 9 Dec 2024 09:23:34 -0500 Subject: [PATCH 3/6] fix types and add e2e test --- etc/api.report.api.md | 12 +- .../client/src/objectSet/ObjectSet.test.ts | 38 +++++-- packages/e2e.generated.catchall/ontology.json | 70 ++++++++++++ .../src/generatedNoCheck/index.ts | 1 + .../src/generatedNoCheck/ontology/objects.ts | 1 + .../ontology/objects/BgaoNflPlayer.ts | 16 +-- .../ontology/objects/McAirportStruct.ts | 107 ++++++++++++++++++ packages/e2e.sandbox.catchall/src/index.ts | 47 ++++---- .../src/runStructsTest.ts | 36 ++++++ .../wireObjectTypeV2ToSdkObjectConstV2.ts | 21 ++-- 10 files changed, 295 insertions(+), 54 deletions(-) create mode 100644 packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/McAirportStruct.ts create mode 100644 packages/e2e.sandbox.catchall/src/runStructsTest.ts diff --git a/etc/api.report.api.md b/etc/api.report.api.md index 8b546054e..49415d825 100644 --- a/etc/api.report.api.md +++ b/etc/api.report.api.md @@ -691,10 +691,11 @@ export type OsdkObjectLinksObject = ObjectTypeLi // Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}' // Warning: (ae-forgotten-export) The symbol "MaybeArray" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "Converted" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "getClientPropertyValueFromWire" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "MaybeNullable" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export type OsdkObjectPropertyType = STRICTLY_ENFORCE_NULLABLE extends false ? MaybeArray> | undefined : MaybeNullable>>; +export type OsdkObjectPropertyType = STRICTLY_ENFORCE_NULLABLE extends false ? MaybeArray>> | undefined : MaybeNullable>>>; // @public (undocumented) export interface PageResult { @@ -849,6 +850,9 @@ export interface SelectArg> = A extends SelectArg ? PropertyKeys : A["$select"] extends readonly string[] ? A["$select"][number] : PropertyKeys; +// @public (undocumented) +export type SimpleWirePropertyTypes = "string" | "datetime" | "double" | "boolean" | "integer" | "timestamp" | "short" | "long" | "float" | "decimal" | "byte" | "marking" | "numericTimeseries" | "stringTimeseries" | "sensorTimeseries" | "attachment" | "geopoint" | "geoshape" | "geotimeSeriesReference"; + // @public (undocumented) export interface SingleLinkAccessor { fetchOne: , boolean>>(options?: A) => Promise ? Osdk.Instance, L> : Osdk.Instance>; @@ -942,11 +946,11 @@ export type TimeSeriesQuery = { export type TwoDimensionalQueryAggregationDefinition = AggregationKeyDataType<"date" | "double" | "timestamp">; // Warning: (ae-forgotten-export) The symbol "AGG_FOR_TYPE" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "PropertyValueClientToWire" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "getWirePropertyValueFromClient" needs to be exported by the entry point index.d.ts // // @public (undocumented) export type ValidAggregationKeys = keyof ({ - [KK in AggregatableKeys as `${KK & string}:${AGG_FOR_TYPE["properties"][KK]["type"]]>}`]?: any; + [KK in AggregatableKeys as `${KK & string}:${AGG_FOR_TYPE["properties"][KK]["type"]>>}`]?: any; } & { $count?: any; }); @@ -970,7 +974,7 @@ export type WhereClause = OrWhereClause; // Warnings were encountered during analysis: // diff --git a/packages/client/src/objectSet/ObjectSet.test.ts b/packages/client/src/objectSet/ObjectSet.test.ts index a87dd25bf..a1cb787b3 100644 --- a/packages/client/src/objectSet/ObjectSet.test.ts +++ b/packages/client/src/objectSet/ObjectSet.test.ts @@ -215,28 +215,46 @@ describe("ObjectSet", () => { expectTypeOf().toMatchTypeOf< Osdk> >; + expectTypeOf().toMatchTypeOf< + { + addressLine1: string | undefined; + addressLine2: string | undefined; + city: string | undefined; + state: string | undefined; + zipCode: number | undefined; + } | undefined + >; - expectTypeOf().toMatchTypeOf< + const address1 = player.address!.addressLine1; + expectTypeOf().toMatchTypeOf< string | undefined >; - expect(player.address.addressLine1).toEqual("15 Muppets Lane"); - expectTypeOf().toMatchTypeOf< + expect(address1).toEqual("15 Muppets Lane"); + + const address2 = player.address?.addressLine2; + expectTypeOf().toMatchTypeOf< string | undefined >; - expect(player.address.addressLine2).toEqual("Resort No 4"); + expect(address2).toEqual("Resort No 4"); - expectTypeOf().toMatchTypeOf< + const city = player.address?.city; + expectTypeOf().toMatchTypeOf< string | undefined >; - expect(player.address.city).toEqual("Memphis"); - expectTypeOf().toMatchTypeOf< + expect(city).toEqual("Memphis"); + + const state = player.address?.state; + expectTypeOf().toMatchTypeOf< string | undefined >; - expect(player.address.state).toEqual("TN"); - expectTypeOf().toMatchTypeOf< + expect(state).toEqual("TN"); + + const zipCode = player.address?.zipCode; + expectTypeOf().toMatchTypeOf< number | undefined >; - expect(player.address.zipCode).toEqual(11100); + expect(zipCode).toEqual(11100); + expect(player.$primaryKey).toEqual(stubData.travisPlayer.__primaryKey); expect(player.address).toEqual(stubData.travisPlayer.address); }); diff --git a/packages/e2e.generated.catchall/ontology.json b/packages/e2e.generated.catchall/ontology.json index 8bf03a106..3f53ff98d 100644 --- a/packages/e2e.generated.catchall/ontology.json +++ b/packages/e2e.generated.catchall/ontology.json @@ -681,6 +681,76 @@ }, "linkTypes": [] }, + "McAirportStruct": { + "objectType": { + "apiName": "McAirportStruct", + "primaryKey": "airportName", + "displayName": "McAirportStruct", + "description": "McAirportStruct", + "properties": { + "airportName": { + "displayName": "Airport Name", + "dataType": { + "type": "string" + } + }, + "city": { + "displayName": "City", + "dataType": { + "type": "string" + } + }, + "airportStruct": { + "displayName": "Airport Struct", + "dataType": { + "type": "struct", + "structFieldTypes": [ + { + "apiName": "code", + "dataType": { + "type": "string" + } + }, + { + "apiName": "geoHash", + "dataType": { + "type": "string" + } + }, + { + "apiName": "timestamp", + "dataType": { + "type": "string" + } + } + ] + } + }, + "state": { + "displayName": "State", + "dataType": { + "type": "string" + } + }, + "originDate": { + "displayName": "Origin Date", + "dataType": { + "type": "timestamp" + } + } + }, + "status": "ACTIVE", + "rid": "rid.a.b.c.d", + "icon": { + "type": "blueprint", + "name": "mcAirportStruct", + "color": "color" + }, + "titleProperty": "airportName", + "pluralDisplayName": "McAirportStructs" + }, + "linkTypes": [] + }, "BuilderDeploymentState": { "objectType": { "apiName": "BuilderDeploymentState", diff --git a/packages/e2e.generated.catchall/src/generatedNoCheck/index.ts b/packages/e2e.generated.catchall/src/generatedNoCheck/index.ts index 3344b40be..3f02d3185 100644 --- a/packages/e2e.generated.catchall/src/generatedNoCheck/index.ts +++ b/packages/e2e.generated.catchall/src/generatedNoCheck/index.ts @@ -17,6 +17,7 @@ export { Employee, FintrafficAis, GtfsTripTrackObject, + McAirportStruct, MtaBus, ObjectTypeWithAllPropertyTypes, OsdkTestObject, diff --git a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects.ts b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects.ts index 6344d4430..5b53e55ff 100644 --- a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects.ts +++ b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects.ts @@ -5,6 +5,7 @@ export { DherlihyComplexObject } from './objects/DherlihyComplexObject.js'; export { Employee } from './objects/Employee.js'; export { FintrafficAis } from './objects/FintrafficAis.js'; export { GtfsTripTrackObject } from './objects/GtfsTripTrackObject.js'; +export { McAirportStruct } from './objects/McAirportStruct.js'; export { MtaBus } from './objects/MtaBus.js'; export { ObjectTypeWithAllPropertyTypes } from './objects/ObjectTypeWithAllPropertyTypes.js'; export { OsdkTestObject } from './objects/OsdkTestObject.js'; diff --git a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/BgaoNflPlayer.ts b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/BgaoNflPlayer.ts index 6bce9a52e..6b0ab11f3 100644 --- a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/BgaoNflPlayer.ts +++ b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/BgaoNflPlayer.ts @@ -20,13 +20,15 @@ export namespace BgaoNflPlayer { export type Links = {}; export interface Props { - readonly address: { - addressLine1: $PropType['string'] | undefined; - addressLine2: $PropType['string'] | undefined; - city: $PropType['string'] | undefined; - state: $PropType['string'] | undefined; - zipCode: $PropType['integer'] | undefined; - }; + readonly address: + | { + addressLine1: $PropType['string'] | undefined; + addressLine2: $PropType['string'] | undefined; + city: $PropType['string'] | undefined; + state: $PropType['string'] | undefined; + zipCode: $PropType['integer'] | undefined; + } + | undefined; readonly gamesPlayed: $PropType['integer'] | undefined; readonly id: $PropType['string']; readonly name: $PropType['string'] | undefined; diff --git a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/McAirportStruct.ts b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/McAirportStruct.ts new file mode 100644 index 000000000..6124aac51 --- /dev/null +++ b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/objects/McAirportStruct.ts @@ -0,0 +1,107 @@ +import type { PropertyDef as $PropertyDef } from '@osdk/client'; +import { $osdkMetadata } from '../../OntologyMetadata.js'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata.js'; +import type { + PropertyKeys as $PropertyKeys, + ObjectTypeDefinition as $ObjectTypeDefinition, + ObjectMetadata as $ObjectMetadata, +} from '@osdk/client'; +import type { + ObjectSet as $ObjectSet, + Osdk as $Osdk, + OsdkObject as $OsdkObject, + PropertyValueWireToClient as $PropType, + SingleLinkAccessor as $SingleLinkAccessor, +} from '@osdk/client'; + +export namespace McAirportStruct { + export type PropertyKeys = 'airportName' | 'city' | 'airportStruct' | 'state' | 'originDate'; + + export type Links = {}; + + export interface Props { + readonly airportName: $PropType['string']; + readonly airportStruct: + | { + code: $PropType['string'] | undefined; + geoHash: $PropType['string'] | undefined; + timestamp: $PropType['string'] | undefined; + } + | undefined; + readonly city: $PropType['string'] | undefined; + readonly originDate: $PropType['timestamp'] | undefined; + readonly state: $PropType['string'] | undefined; + } + export type StrictProps = Props; + + export interface ObjectSet extends $ObjectSet {} + + export type OsdkInstance< + OPTIONS extends never | '$rid' = never, + K extends keyof McAirportStruct.Props = keyof McAirportStruct.Props, + > = $Osdk.Instance; + + /** @deprecated use OsdkInstance */ + export type OsdkObject< + OPTIONS extends never | '$rid' = never, + K extends keyof McAirportStruct.Props = keyof McAirportStruct.Props, + > = OsdkInstance; +} + +export interface McAirportStruct extends $ObjectTypeDefinition { + osdkMetadata: typeof $osdkMetadata; + type: 'object'; + apiName: 'McAirportStruct'; + __DefinitionMetadata?: { + objectSet: McAirportStruct.ObjectSet; + props: McAirportStruct.Props; + linksType: McAirportStruct.Links; + strictProps: McAirportStruct.StrictProps; + apiName: 'McAirportStruct'; + description: 'McAirportStruct'; + displayName: 'McAirportStruct'; + icon: { + type: 'blueprint'; + name: 'mcAirportStruct'; + color: 'color'; + }; + interfaceMap: {}; + inverseInterfaceMap: {}; + links: {}; + pluralDisplayName: 'McAirportStructs'; + primaryKeyApiName: 'airportName'; + primaryKeyType: 'string'; + properties: { + /** + * display name: 'Airport Name' + */ + airportName: $PropertyDef<'string', 'non-nullable', 'single'>; + /** + * display name: 'Airport Struct' + */ + airportStruct: $PropertyDef<{ code: 'string'; geoHash: 'string'; timestamp: 'string' }, 'nullable', 'single'>; + /** + * display name: 'City' + */ + city: $PropertyDef<'string', 'nullable', 'single'>; + /** + * display name: 'Origin Date' + */ + originDate: $PropertyDef<'timestamp', 'nullable', 'single'>; + /** + * display name: 'State' + */ + state: $PropertyDef<'string', 'nullable', 'single'>; + }; + rid: 'rid.a.b.c.d'; + status: 'ACTIVE'; + titleProperty: 'airportName'; + type: 'object'; + }; +} + +export const McAirportStruct: McAirportStruct = { + type: 'object', + apiName: 'McAirportStruct', + osdkMetadata: $osdkMetadata, +}; diff --git a/packages/e2e.sandbox.catchall/src/index.ts b/packages/e2e.sandbox.catchall/src/index.ts index 447b1f278..d3a42b3df 100644 --- a/packages/e2e.sandbox.catchall/src/index.ts +++ b/packages/e2e.sandbox.catchall/src/index.ts @@ -25,6 +25,7 @@ import { runGeotimeSeriesReferenceTests } from "./runGeotimeSeriesTest.js"; import { runInterfacesTest } from "./runInterfacesTest.js"; import { runLegacyExamples } from "./runLegacyExamples.js"; import { runQueriesTest } from "./runQueriesTest.js"; +import { runStructsTest } from "./runStructsTest.js"; import { runSubscriptionsTest } from "./runSubscriptionsTest.js"; import { runTimeseriesTest } from "./runTimeseriesTest.js"; import { typeChecks } from "./typeChecks.js"; @@ -34,40 +35,42 @@ const testSubscriptions = false; async function runTests() { try { - await checkUnstableBulkLinks(); + // await checkUnstableBulkLinks(); - if (runOld) { - await runLegacyExamples(); - } - if (testSubscriptions) { - runSubscriptionsTest(); + // if (runOld) { + // await runLegacyExamples(); + // } + // if (testSubscriptions) { + // runSubscriptionsTest(); - // we don't need the console flooded with additional things - return; - } + // // we don't need the console flooded with additional things + // return; + // } - const datasetRid = - "ri.foundry.main.dataset.58070dbb-dd3b-4c82-b012-9c2f8a13dd83"; - await runFoundrySdkClientVerificationTest(datasetRid); + // const datasetRid = + // "ri.foundry.main.dataset.58070dbb-dd3b-4c82-b012-9c2f8a13dd83"; + // await runFoundrySdkClientVerificationTest(datasetRid); - await runInterfacesTest(); + // await runInterfacesTest(); - // only works in default ontology - await runGeoQueriesTest(); + // // only works in default ontology + // await runGeoQueriesTest(); - await runAssignEmployeeToVentureTest(); + // await runAssignEmployeeToVentureTest(); - await runAggregationsTest(); + // await runAggregationsTest(); - await runAggregationGroupByDatesTest(); + // await runAggregationGroupByDatesTest(); - await runQueriesTest(); + // await runQueriesTest(); - if (runOld) await typeChecks(client); + // if (runOld) await typeChecks(client); - await runTimeseriesTest(); + // await runTimeseriesTest(); - await runGeotimeSeriesReferenceTests(); + // await runGeotimeSeriesReferenceTests(); + + await runStructsTest(); } catch (e) { console.error(`Caught an error we did not expect, type: ${typeof e}`); console.error(e); diff --git a/packages/e2e.sandbox.catchall/src/runStructsTest.ts b/packages/e2e.sandbox.catchall/src/runStructsTest.ts new file mode 100644 index 000000000..dae434956 --- /dev/null +++ b/packages/e2e.sandbox.catchall/src/runStructsTest.ts @@ -0,0 +1,36 @@ +/* + * Copyright 2024 Palantir Technologies, Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BgaoNflPlayer, McAirportStruct } from "@osdk/e2e.generated.catchall"; +import { dsClient } from "./client.js"; + +export async function runStructsTest() { + const player = await dsClient(BgaoNflPlayer).fetchOne( + "50A409AB-C909-453A-A61A-31B51324C8E3", + ); + + // Making sure things work when struct values are not set, like with this object + console.log(player); + console.log(player.address); + console.log(player.address?.addressLine1); + + const airport = await dsClient(McAirportStruct).fetchOne( + "Ronald Reagan Washington National Airport", + ); + + console.log(airport.airportStruct); + console.log(airport.airportStruct?.geoHash); +} diff --git a/packages/generator/src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts b/packages/generator/src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts index 49b25744b..e56a9ec16 100644 --- a/packages/generator/src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts +++ b/packages/generator/src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts @@ -228,18 +228,17 @@ ${ // after we convert everything over we can do this: // !strict || propertyDefinition.nullable ? "?" : "" ""}`, - typeof propertyDefinition.type === "object" + (typeof propertyDefinition.type === "object" ? `${remapStructType(propertyDefinition.type)}` - : `$PropType[${JSON.stringify(propertyDefinition.type)}]${ - propertyDefinition.multiplicity ? "[]" : "" - }${ - propertyDefinition.nullable - || (!strict - && !(definition.type === "object" - && definition.primaryKeyApiName === apiName)) - ? `| undefined` - : "" - }`, + : `$PropType[${JSON.stringify(propertyDefinition.type)}]`) + + `${propertyDefinition.multiplicity ? "[]" : ""}${ + propertyDefinition.nullable + || (!strict + && !(definition.type === "object" + && definition.primaryKeyApiName === apiName)) + ? `| undefined` + : "" + }`, ] as [string, string]; }, }) From b6ae16dc40c1c3263e5d0364c30a92c2394c09d9 Mon Sep 17 00:00:00 2001 From: Saurav Date: Mon, 9 Dec 2024 09:54:49 -0500 Subject: [PATCH 4/6] fix index file --- packages/e2e.sandbox.catchall/src/index.ts | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/e2e.sandbox.catchall/src/index.ts b/packages/e2e.sandbox.catchall/src/index.ts index d3a42b3df..76b215c38 100644 --- a/packages/e2e.sandbox.catchall/src/index.ts +++ b/packages/e2e.sandbox.catchall/src/index.ts @@ -35,40 +35,40 @@ const testSubscriptions = false; async function runTests() { try { - // await checkUnstableBulkLinks(); + await checkUnstableBulkLinks(); - // if (runOld) { - // await runLegacyExamples(); - // } - // if (testSubscriptions) { - // runSubscriptionsTest(); + if (runOld) { + await runLegacyExamples(); + } + if (testSubscriptions) { + runSubscriptionsTest(); - // // we don't need the console flooded with additional things - // return; - // } + // we don't need the console flooded with additional things + return; + } - // const datasetRid = - // "ri.foundry.main.dataset.58070dbb-dd3b-4c82-b012-9c2f8a13dd83"; - // await runFoundrySdkClientVerificationTest(datasetRid); + const datasetRid = + "ri.foundry.main.dataset.58070dbb-dd3b-4c82-b012-9c2f8a13dd83"; + await runFoundrySdkClientVerificationTest(datasetRid); - // await runInterfacesTest(); + await runInterfacesTest(); - // // only works in default ontology - // await runGeoQueriesTest(); + // only works in default ontology + await runGeoQueriesTest(); - // await runAssignEmployeeToVentureTest(); + await runAssignEmployeeToVentureTest(); - // await runAggregationsTest(); + await runAggregationsTest(); - // await runAggregationGroupByDatesTest(); + await runAggregationGroupByDatesTest(); - // await runQueriesTest(); + await runQueriesTest(); - // if (runOld) await typeChecks(client); + if (runOld) await typeChecks(client); - // await runTimeseriesTest(); + await runTimeseriesTest(); - // await runGeotimeSeriesReferenceTests(); + await runGeotimeSeriesReferenceTests(); await runStructsTest(); } catch (e) { From 5628328ec679877f11020ada5f09f06daf0a70a7 Mon Sep 17 00:00:00 2001 From: Saurav Date: Mon, 9 Dec 2024 09:55:42 -0500 Subject: [PATCH 5/6] add changeset' --- .changeset/quiet-bears-kneel.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .changeset/quiet-bears-kneel.md diff --git a/.changeset/quiet-bears-kneel.md b/.changeset/quiet-bears-kneel.md new file mode 100644 index 000000000..3027344bb --- /dev/null +++ b/.changeset/quiet-bears-kneel.md @@ -0,0 +1,12 @@ +--- +"@osdk/foundry-sdk-generator": patch +"@osdk/generator-converters": patch +"@osdk/cli.cmd.typescript": patch +"@osdk/shared.test": patch +"@osdk/generator": patch +"@osdk/client": patch +"@osdk/maker": patch +"@osdk/api": patch +--- + +Add support for reading struct properties. From bffa0af622f48a3fc856206e93208d45a4a49d91 Mon Sep 17 00:00:00 2001 From: Saurav Date: Tue, 10 Dec 2024 11:34:24 -0600 Subject: [PATCH 6/6] fix merge conflicts --- etc/api.report.api.md | 4 +- .../api/src/mapping/PropertyValueMapping.ts | 4 + .../api/src/ontology/WirePropertyTypes.ts | 3 +- packages/e2e.generated.catchall/ontology.json | 83 +++++++++++++++++++ .../src/runInterfacesTest.ts | 1 + packages/generator-converters/package.json | 3 +- ...PropertyV2ToSdkPrimaryKeyTypeDefinition.ts | 2 +- .../wirePropertyV2ToSdkPropertyDefinition.ts | 42 +++++++--- packages/maker/src/api/defineObject.ts | 2 +- packages/monorepo.cspell/dict.osdk.txt | 1 + pnpm-lock.yaml | 3 + 11 files changed, 132 insertions(+), 16 deletions(-) diff --git a/etc/api.report.api.md b/etc/api.report.api.md index 49415d825..a7c54956c 100644 --- a/etc/api.report.api.md +++ b/etc/api.report.api.md @@ -769,6 +769,8 @@ export interface PropertyValueWireToClient { stringTimeseries: TimeSeriesProperty; // (undocumented) timestamp: string; + // (undocumented) + unknown: never; } // Warning: (ae-forgotten-export) The symbol "PrimitiveDataType" needs to be exported by the entry point index.d.ts @@ -851,7 +853,7 @@ export interface SelectArg> = A extends SelectArg ? PropertyKeys : A["$select"] extends readonly string[] ? A["$select"][number] : PropertyKeys; // @public (undocumented) -export type SimpleWirePropertyTypes = "string" | "datetime" | "double" | "boolean" | "integer" | "timestamp" | "short" | "long" | "float" | "decimal" | "byte" | "marking" | "numericTimeseries" | "stringTimeseries" | "sensorTimeseries" | "attachment" | "geopoint" | "geoshape" | "geotimeSeriesReference"; +export type SimpleWirePropertyTypes = "string" | "datetime" | "double" | "boolean" | "integer" | "timestamp" | "short" | "long" | "float" | "decimal" | "byte" | "marking" | "numericTimeseries" | "stringTimeseries" | "sensorTimeseries" | "attachment" | "geopoint" | "geoshape" | "geotimeSeriesReference" | "unknown"; // @public (undocumented) export interface SingleLinkAccessor { diff --git a/packages/api/src/mapping/PropertyValueMapping.ts b/packages/api/src/mapping/PropertyValueMapping.ts index fb9bd87a6..267da074a 100644 --- a/packages/api/src/mapping/PropertyValueMapping.ts +++ b/packages/api/src/mapping/PropertyValueMapping.ts @@ -44,6 +44,8 @@ export interface PropertyValueWireToClient { stringTimeseries: TimeSeriesProperty; sensorTimeseries: TimeSeriesProperty; geotimeSeriesReference: GeotimeSeriesProperty; + + unknown: never; } export type getClientPropertyValueFromWire< @@ -77,6 +79,8 @@ export interface PropertyValueClientToWire { stringTimeseries: TimeSeriesProperty; sensorTimeseries: TimeSeriesProperty; geotimeSeriesReference: GeotimeSeriesProperty; + + unknown: never; } export type getWirePropertyValueFromClient< T extends diff --git a/packages/api/src/ontology/WirePropertyTypes.ts b/packages/api/src/ontology/WirePropertyTypes.ts index 173ce8c42..f73608b22 100644 --- a/packages/api/src/ontology/WirePropertyTypes.ts +++ b/packages/api/src/ontology/WirePropertyTypes.ts @@ -37,4 +37,5 @@ export type SimpleWirePropertyTypes = | "attachment" | "geopoint" | "geoshape" - | "geotimeSeriesReference"; + | "geotimeSeriesReference" + | "unknown"; diff --git a/packages/e2e.generated.catchall/ontology.json b/packages/e2e.generated.catchall/ontology.json index 3f53ff98d..99cf5eabe 100644 --- a/packages/e2e.generated.catchall/ontology.json +++ b/packages/e2e.generated.catchall/ontology.json @@ -631,6 +631,89 @@ }, "linkTypes": [] }, + "BgaoNflPlayer": { + "objectType": { + "apiName": "BgaoNflPlayer", + "primaryKey": "id", + "displayName": "BgaoNflPlayer", + "description": "BgaoNflPlayer", + "properties": { + "id": { + "dataType": { + "type": "string" + } + }, + "gamesPlayed": { + "dataType": { + "type": "integer" + } + }, + "name": { + "dataType": { + "type": "string" + } + }, + "number": { + "dataType": { + "type": "integer" + } + }, + "wikiUrl": { + "dataType": { + "type": "string" + } + }, + "address": { + "dataType": { + "type": "struct", + "structFieldTypes": [ + { + "apiName": "addressLine1", + "dataType": { + "type": "string" + } + }, + { + "apiName": "addressLine2", + "dataType": { + "type": "string" + } + }, + { + "apiName": "city", + "dataType": { + "type": "string" + } + }, + { + "apiName": "state", + "dataType": { + "type": "string" + } + }, + { + "apiName": "zipCode", + "dataType": { + "type": "integer" + } + } + ] + } + } + }, + + "status": "ACTIVE", + "rid": "ri.a.b.c.d", + "icon": { + "type": "blueprint", + "name": "traffic", + "color": "color" + }, + "titleProperty": "entityId", + "pluralDisplayName": "GtfsTripTrackObject" + }, + "linkTypes": [] + }, "SotSensor": { "objectType": { "apiName": "SotSensor", diff --git a/packages/e2e.sandbox.catchall/src/runInterfacesTest.ts b/packages/e2e.sandbox.catchall/src/runInterfacesTest.ts index 3edb4fe65..3c74af916 100644 --- a/packages/e2e.sandbox.catchall/src/runInterfacesTest.ts +++ b/packages/e2e.sandbox.catchall/src/runInterfacesTest.ts @@ -16,6 +16,7 @@ import type { ConvertProps, Osdk } from "@osdk/api"; import { + BgaoNflPlayer, Employee, FooInterface, OsdkTestObject, diff --git a/packages/generator-converters/package.json b/packages/generator-converters/package.json index 21cc909c5..166c19ed9 100644 --- a/packages/generator-converters/package.json +++ b/packages/generator-converters/package.json @@ -32,7 +32,8 @@ }, "dependencies": { "@osdk/api": "workspace:~", - "@osdk/internal.foundry.core": "2.8.0" + "@osdk/internal.foundry.core": "2.8.0", + "consola": "^3.2.3" }, "devDependencies": { "@osdk/monorepo.api-extractor": "workspace:~", diff --git a/packages/generator-converters/src/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts b/packages/generator-converters/src/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts index f0788bc93..c1ba647c7 100644 --- a/packages/generator-converters/src/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts +++ b/packages/generator-converters/src/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts @@ -46,8 +46,8 @@ export function wirePropertyV2ToSdkPrimaryKeyTypeDefinition( case "float": case "geotimeSeriesReference": case "mediaReference": - case "struct": case "cipherText": + case "struct": throw new Error( `Type not supported for primaryKey: ${input.dataType.type}`, ); diff --git a/packages/generator-converters/src/wirePropertyV2ToSdkPropertyDefinition.ts b/packages/generator-converters/src/wirePropertyV2ToSdkPropertyDefinition.ts index b5602d50e..c361b1b7c 100644 --- a/packages/generator-converters/src/wirePropertyV2ToSdkPropertyDefinition.ts +++ b/packages/generator-converters/src/wirePropertyV2ToSdkPropertyDefinition.ts @@ -24,6 +24,7 @@ import type { PropertyV2, SharedPropertyType, } from "@osdk/internal.foundry.core"; +import { consola } from "consola"; export function wirePropertyV2ToSdkPropertyDefinition( input: (PropertyV2 | SharedPropertyType) & { nullable?: boolean }, @@ -64,17 +65,33 @@ export function wirePropertyV2ToSdkPropertyDefinition( nullable: true, }; } - case "cipherText": - case "mediaReference": { - throw new Error( - `${input.dataType.type} not supported yet`, + + case "mediaReference": + case "cipherText": { + consola.info( + `${ + JSON.stringify(input.dataType.type) + } is not a supported property type`, ); + return { + displayName: input.displayName, + multiplicity: false, + description: input.description, + type: objectPropertyTypeToSdkPropertyDefinition(input.dataType), + nullable: true, + }; } default: - const _: never = input.dataType; - throw new Error( - `Unexpected data type ${JSON.stringify(input.dataType)}`, + consola.info( + `${JSON.stringify(input.dataType)} is not a supported property type`, ); + return { + displayName: input.displayName, + multiplicity: false, + description: input.description, + type: objectPropertyTypeToSdkPropertyDefinition(input.dataType), + nullable: true, + }; } } @@ -123,12 +140,15 @@ function objectPropertyTypeToSdkPropertyDefinition( case "mediaReference": case "cipherText": { - throw new Error( - `${propertyType.type} not supported yet`, + consola.info( + `${JSON.stringify(propertyType)} is not a supported property type`, ); + return "unknown"; } default: - const _: never = propertyType; - throw new Error(`Unexpected data type ${JSON.stringify(propertyType)}`); + consola.info( + `${JSON.stringify(propertyType)} is not a supported property type`, + ); + return "unknown"; } } diff --git a/packages/maker/src/api/defineObject.ts b/packages/maker/src/api/defineObject.ts index 0f29f29e4..a370b1013 100644 --- a/packages/maker/src/api/defineObject.ts +++ b/packages/maker/src/api/defineObject.ts @@ -135,7 +135,7 @@ function convertType( default: return { type: t.type, - }; + } as PropertyV2["dataType"]; } invariant(false); diff --git a/packages/monorepo.cspell/dict.osdk.txt b/packages/monorepo.cspell/dict.osdk.txt index 0b03804bc..b9548951f 100644 --- a/packages/monorepo.cspell/dict.osdk.txt +++ b/packages/monorepo.cspell/dict.osdk.txt @@ -7,3 +7,4 @@ paperplane Pressable Tamagui unistyles +Bgao diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 87a08707b..01d7783e5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3231,6 +3231,9 @@ importers: '@osdk/internal.foundry.core': specifier: 2.8.0 version: 2.8.0 + consola: + specifier: ^3.2.3 + version: 3.2.3 devDependencies: '@osdk/monorepo.api-extractor': specifier: workspace:~