@osdk/generator 2.4.0-beta.12 → 2.4.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +10 -10
  3. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
  4. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +4 -0
  5. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
  6. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js +3 -0
  7. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
  8. package/build/browser/v2.0/generatePerInterfaceDataFiles.js +2 -1
  9. package/build/browser/v2.0/generatePerInterfaceDataFiles.js.map +1 -1
  10. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +4 -2
  11. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
  12. package/build/cjs/index.cjs +15 -10
  13. package/build/cjs/index.cjs.map +1 -1
  14. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +10 -10
  15. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
  16. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +4 -0
  17. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
  18. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js +3 -0
  19. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
  20. package/build/esm/v2.0/generatePerInterfaceDataFiles.js +2 -1
  21. package/build/esm/v2.0/generatePerInterfaceDataFiles.js.map +1 -1
  22. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +4 -2
  23. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
  24. package/build/types/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
  25. package/package.json +3 -3
@@ -34,10 +34,11 @@ export async function generatePerInterfaceDataFiles({
34
34
  });
35
35
  for (const obj of Object.values(ontology.interfaceTypes)) {
36
36
  if (obj instanceof ForeignType) continue;
37
+ const relPath = path.join(".", "ontology", "interfaces", `${obj.shortApiName}.ts`);
37
38
  await fs.writeFile(path.join(interfacesDir, `${obj.shortApiName}.ts`), await formatTs(`
38
39
  import type { PropertyDef as $PropertyDef } from "${forInternalUse ? "@osdk/api" : "@osdk/client"}";
39
40
  import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
40
- ${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true, forInternalUse)}
41
+ ${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true, forInternalUse, relPath)}
41
42
  `));
42
43
  }
43
44
  await fs.writeFile(interfacesDir + ".ts", await formatTs(`
@@ -1 +1 @@
1
- {"version":3,"file":"generatePerInterfaceDataFiles.js","names":["path","EnhancedInterfaceType","ForeignType","formatTs","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst","generatePerInterfaceDataFiles","fs","outDir","ontology","importExt","forInternalUse","interfacesDir","join","mkdir","recursive","obj","Object","values","interfaceTypes","writeFile","shortApiName","filter","i","map","interfaceType","keys","length"],"sources":["generatePerInterfaceDataFiles.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from \"node:path\";\nimport { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport { formatTs } from \"../util/test/formatTs.js\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst } from \"./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js\";\n\n/** @internal */\nexport async function generatePerInterfaceDataFiles(\n { fs, outDir, ontology, importExt, forInternalUse }: GenerateContext,\n) {\n const interfacesDir = path.join(outDir, \"ontology\", \"interfaces\");\n await fs.mkdir(interfacesDir, {\n recursive: true,\n });\n\n for (const obj of Object.values(ontology.interfaceTypes)) {\n if (obj instanceof ForeignType) continue;\n\n await fs.writeFile(\n path.join(interfacesDir, `${obj.shortApiName}.ts`),\n await formatTs(`\n import type { PropertyDef as $PropertyDef } from \"${\n forInternalUse ? \"@osdk/api\" : \"@osdk/client\"\n }\";\n import { $osdkMetadata } from \"../../OntologyMetadata${importExt}\";\n ${\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n obj,\n ontology,\n true,\n forInternalUse,\n )\n }\n `),\n );\n }\n\n await fs.writeFile(\n interfacesDir + \".ts\",\n await formatTs(`\n ${\n Object.values(ontology.interfaceTypes).filter(i =>\n i instanceof EnhancedInterfaceType\n ).map(interfaceType =>\n `export {${interfaceType.shortApiName}} from \"./interfaces/${interfaceType.shortApiName}${importExt}\";`\n ).join(\"\\n\")\n }\n ${\n Object.keys(ontology.interfaceTypes).length === 0\n ? \"export {}\"\n : \"\"\n }\n `),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,WAAW;AAC5B,SAASC,qBA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CAACjB,QAAQ,CAACU,cAAc,CAAC,CAACQ,MAAM,KAAK,CAAC,GAC7C,WAAW,GACX,EAAE;AACZ,KACK,CACH,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"generatePerInterfaceDataFiles.js","names":["path","EnhancedInterfaceType","ForeignType","formatTs","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst","generatePerInterfaceDataFiles","fs","outDir","ontology","importExt","forInternalUse","interfacesDir","join","mkdir","recursive","obj","Object","values","interfaceTypes","relPath","shortApiName","writeFile","filter","i","map","interfaceType","keys","length"],"sources":["generatePerInterfaceDataFiles.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from \"node:path\";\nimport { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport { formatTs } from \"../util/test/formatTs.js\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst } from \"./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js\";\n\n/** @internal */\nexport async function generatePerInterfaceDataFiles(\n { fs, outDir, ontology, importExt, forInternalUse }: GenerateContext,\n) {\n const interfacesDir = path.join(outDir, \"ontology\", \"interfaces\");\n await fs.mkdir(interfacesDir, {\n recursive: true,\n });\n\n for (const obj of Object.values(ontology.interfaceTypes)) {\n if (obj instanceof ForeignType) continue;\n const relPath = path.join(\n \".\",\n \"ontology\",\n \"interfaces\",\n `${obj.shortApiName}.ts`,\n );\n\n await fs.writeFile(\n path.join(interfacesDir, `${obj.shortApiName}.ts`),\n await formatTs(`\n import type { PropertyDef as $PropertyDef } from \"${\n forInternalUse ? \"@osdk/api\" : \"@osdk/client\"\n }\";\n import { $osdkMetadata } from \"../../OntologyMetadata${importExt}\";\n ${\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n obj,\n ontology,\n true,\n forInternalUse,\n relPath,\n )\n }\n `),\n );\n }\n\n await fs.writeFile(\n interfacesDir + \".ts\",\n await formatTs(`\n ${\n Object.values(ontology.interfaceTypes).filter(i =>\n i instanceof EnhancedInterfaceType\n ).map(interfaceType =>\n `export {${interfaceType.shortApiName}} from \"./interfaces/${interfaceType.shortApiName}${importExt}\";`\n ).join(\"\\n\")\n }\n ${\n Object.keys(ontology.interfaceTypes).length === 0\n ? \"export {}\"\n : \"\"\n }\n `),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,WAAW;AAC5B,SAASC,qBAAqB,QAAQ,6CAA6C;AACnF,SAASC,WAAW,QAAQ,mCAAmC;AAE/D,SAASC,QAAQ,QAAQ,0BAA0B;AACnD,SAASC,8CAA8C,QAAQ,mDAAmD;;AAElH;AACA,OAAO,eAAeC,6BAA6BA,CACjD;EAAEC,EAAE;EAAEC,MAAM;EAAEC,QAAQ;EAAEC,SAAS;EAAEC;AAAgC,CAAC,EACpE;EACA,MAAMC,aAAa,GAAGX,IAAI,CAACY,IAAI,CAACL,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC;EACjE,MAAMD,EAAE,CAACO,KAAK,CAACF,aAAa,EAAE;IAC5BG,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,KAAK,MAAMC,GAAG,IAAIC,MAAM,CAACC,MAAM,CAACT,QAAQ,CAACU,cAAc,CAAC,EAAE;IACxD,IAAIH,GAAG,YAAYb,WAAW,EAAE;IAChC,MAAMiB,OAAO,GAAGnB,IAAI,CAACY,IAAI,CACvB,GAAG,EACH,UAAU,EACV,YAAY,EACZ,GAAGG,GAAG,CAACK,YAAY,KACrB,CAAC;IAED,MAAMd,EAAE,CAACe,SAAS,CAChBrB,IAAI,CAACY,IAAI,CAACD,aAAa,EAAE,GAAGI,GAAG,CAACK,YAAY,KAAK,CAAC,EAClD,MAAMjB,QAAQ,CAAC;AACrB,4DACQO,cAAc,GAAG,WAAW,GAAG,cAAc;AACrD,+DAC+DD,SAAS;AACxE,QACQL,8CAA8C,CAC5CW,GAAG,EACHP,QAAQ,EACR,IAAI,EACJE,cAAc,EACdS,OACF,CAAC;AACT,KACK,CACD,CAAC;EACH;EAEA,MAAMb,EAAE,CAACe,SAAS,CAChBV,aAAa,GAAG,KAAK,EACrB,MAAMR,QAAQ,CAAC;AACnB,MACMa,MAAM,CAACC,MAAM,CAACT,QAAQ,CAACU,cAAc,CAAC,CAACI,MAAM,CAACC,CAAC,IAC7CA,CAAC,YAAYtB,qBACf,CAAC,CAACuB,GAAG,CAACC,aAAa,IACjB,WAAWA,aAAa,CAACL,YAAY,wBAAwBK,aAAa,CAACL,YAAY,GAAGX,SAAS,IACrG,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC;AAClB,MAEMI,MAAM,CAACU,IAAI,CAAClB,QAAQ,CAACU,cAAc,CAAC,CAACS,MAAM,KAAK,CAAC,GAC7C,WAAW,GACX,EAAE;AACZ,KACK,CACH,CAAC;AACH","ignoreList":[]}
@@ -182,8 +182,10 @@ export function createDefinition(object, ontology, identifier, {
182
182
  strictProps: ${osdkObjectStrictPropsIdentifier};
183
183
  ${stringify(definition, {
184
184
  links: () => `{
185
- ${stringify(definition.links, {
186
- "*": definition => `$ObjectMetadata.Link<${ontology.requireObjectType(definition.targetType).getImportedDefinitionIdentifier(true)}, ${definition.multiplicity}>`
185
+ ${definition.type === "interface" ? stringify(definition.links, {
186
+ "*": linkDefinition => `$InterfaceMetadata.Link<${linkDefinition.targetType === "interface" ? ontology.requireInterfaceType(linkDefinition.targetTypeApiName).getImportedDefinitionIdentifier(true) : ontology.requireObjectType(linkDefinition.targetTypeApiName).getImportedDefinitionIdentifier(true)}, ${linkDefinition.multiplicity}>`
187
+ }) : stringify(definition.links, {
188
+ "*": linkDefinition => `$ObjectMetadata.Link<${ontology.requireObjectType(linkDefinition.targetType).getImportedDefinitionIdentifier(true)}, ${linkDefinition.multiplicity}>`
187
189
  })}
188
190
  }`,
189
191
  properties: () => `{
@@ -1 +1 @@
1
- {"version":3,"file":"wireObjectTypeV2ToSdkObjectConstV2.js","names":["wireObjectTypeFullMetadataToSdkObjectMetadata","consola","EnhancedObjectType","ForeignType","getObjectImports","propertyJsdoc","stringify","wireObjectTypeV2ToSdkObjectConstV2","wireObject","ontology","forInternalUse","currentFilePath","object","requireObjectType","objectType","apiName","Error","uniqueLinkTargetTypes","Set","linkTypes","map","a","objectTypeApiName","definition","raw","objectDefIdentifier","getDefinitionIdentifier","objectSetIdentifier","shortApiName","propertyKeysIdentifier","osdkObjectPropsIdentifier","osdkObjectStrictPropsIdentifier","osdkObjectLinksIdentifier","osdkObjectIdentifier","identifiers","imports","createPropertyKeys","createLinks","createProps","createObjectSet","createOsdkObject","createDefinition","fullApiName","identifier","getCleanedUpDefinition","maybeStripNamespace","type","q","apiNamespace","startsWith","slice","length","strict","propertyMetadata","properties","undefined","*","propertyDefinition","_","remapStructType","JSON","multiplicity","nullable","primaryKeyApiName","links","targetType","getImportedDefinitionIdentifier","Object","keys","key","linkTarget","join","structType","output","entries","value"],"sources":["wireObjectTypeV2ToSdkObjectConstV2.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectTypeFullMetadata } from \"@osdk/foundry.ontologies\";\nimport { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"@osdk/generator-converters\";\nimport consola from \"consola\";\nimport type { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport { EnhancedObjectType } from \"../GenerateContext/EnhancedObjectType.js\";\nimport type { EnhancedOntologyDefinition } from \"../GenerateContext/EnhancedOntologyDefinition.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { propertyJsdoc } from \"../shared/propertyJsdoc.js\";\nimport { stringify } from \"../util/stringify.js\";\n\n/** @internal */\nexport function wireObjectTypeV2ToSdkObjectConstV2(\n wireObject: ObjectTypeFullMetadata,\n { ontology, forInternalUse }: Pick<\n GenerateContext,\n \"ontology\" | \"forInternalUse\"\n >,\n currentFilePath: string,\n) {\n const object = ontology.requireObjectType(\n wireObject.objectType.apiName,\n true,\n );\n if (object instanceof ForeignType) {\n throw new Error(\"Should not be generating types for an external type\");\n }\n const uniqueLinkTargetTypes = new Set(\n wireObject.linkTypes.map(a =>\n ontology.requireObjectType(a.objectTypeApiName, false)\n ),\n );\n\n const definition = wireObjectTypeFullMetadataToSdkObjectMetadata(\n object.raw,\n true,\n consola,\n );\n\n const objectDefIdentifier = object.getDefinitionIdentifier(true);\n\n const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;\n const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;\n // const osdkObjectPropsIdentifier = `OsdkObjectProps$${objectDefIdentifier}`;\n const osdkObjectPropsIdentifier = `${object.shortApiName}.Props`;\n const osdkObjectStrictPropsIdentifier = `${object.shortApiName}.StrictProps`;\n const osdkObjectLinksIdentifier = `${object.shortApiName}.Links`;\n const osdkObjectIdentifier = `${object.shortApiName}.OsdkObject`;\n\n const identifiers: Identifiers = {\n objectDefIdentifier: object.shortApiName,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n\n function getV2Types(\n object: EnhancedObjectType,\n forInternalUse: boolean = false,\n ) {\n return `import type {\n PropertyKeys as $PropertyKeys, \n ObjectTypeDefinition as $ObjectTypeDefinition,\n ObjectMetadata as $ObjectMetadata,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n import type {\n ObjectSet as $ObjectSet, \n Osdk as $Osdk,\n OsdkObject as $OsdkObject,\n PropertyValueWireToClient as $PropType,\n SingleLinkAccessor as $SingleLinkAccessor,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n\n\n export namespace ${object.shortApiName} {\n\n ${createPropertyKeys(object)}\n\n\n ${createLinks(ontology, object, \"Links\")}\n\n ${createProps(object, \"Props\", false)}\n ${createProps(object, \"StrictProps\", true)}\n\n ${createObjectSet(object, identifiers)}\n \n ${createOsdkObject(object, \"OsdkInstance\", identifiers)}\n } \n\n\n\n ${createDefinition(object, ontology, object.shortApiName, identifiers)}\n `;\n }\n\n const imports = getObjectImports(\n uniqueLinkTargetTypes,\n definition.apiName,\n currentFilePath,\n true,\n );\n\n return `${imports}${getV2Types(object, forInternalUse)}\n\n export const ${object.shortApiName}: ${objectDefIdentifier}\n = {\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\",\n apiName: \"${object.fullApiName}\",\n osdkMetadata: $osdkMetadata, \n };`;\n}\n\nexport interface Identifiers extends\n Record<\n | \"osdkObjectIdentifier\"\n | \"propertyKeysIdentifier\"\n | \"osdkObjectPropsIdentifier\"\n | \"objectDefIdentifier\"\n | \"osdkObjectLinksIdentifier\"\n | \"osdkObjectStrictPropsIdentifier\"\n | \"objectSetIdentifier\",\n string\n >\n{}\n\nexport function createOsdkObject(\n object: EnhancedObjectType | EnhancedInterfaceType,\n identifier: string,\n {\n osdkObjectPropsIdentifier,\n objectDefIdentifier,\n osdkObjectStrictPropsIdentifier,\n osdkObjectLinksIdentifier,\n }: Identifiers,\n) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export type ${identifier}<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > \n = $Osdk.Instance<\n ${objectDefIdentifier}, \n OPTIONS,\n K\n >;\n \n\n /** @deprecated use ${identifier} */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > = ${identifier}<OPTIONS, K>;\n ;\n `;\n}\n\nexport function createObjectSet(\n object: EnhancedObjectType | EnhancedInterfaceType,\n {\n objectDefIdentifier,\n objectSetIdentifier,\n propertyKeysIdentifier,\n osdkObjectIdentifier,\n }: Identifiers,\n) {\n return `\nexport interface ObjectSet extends \n$ObjectSet<${objectDefIdentifier},\n\n${objectSetIdentifier}\n>\n{\n\n}\n`;\n}\n\nfunction maybeStripNamespace(\n type: EnhancedInterfaceType | EnhancedObjectType,\n q: string,\n) {\n if (\n type.apiNamespace && q.startsWith(`${type.apiNamespace}.`)\n ) {\n return q.slice(type.apiNamespace.length + 1);\n } else {\n return q;\n }\n}\n\nexport function createProps(\n type: EnhancedInterfaceType | EnhancedObjectType,\n identifier: string,\n strict: boolean,\n): string {\n if (identifier === \"StrictProps\") {\n return `export type StrictProps = Props`;\n }\n const definition = type.getCleanedUpDefinition(true);\n const propertyMetadata = type instanceof EnhancedObjectType\n ? type.raw.objectType.properties\n : undefined;\n return `export interface ${identifier} {\n${\n stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => {\n return [\n `${\n propertyJsdoc(propertyDefinition, propertyMetadata?.[apiName], {\n apiName,\n })\n }readonly \"${maybeStripNamespace(type, apiName)}\"`,\n (typeof propertyDefinition.type === \"object\"\n ? remapStructType(propertyDefinition.type)\n : `$PropType[${JSON.stringify(propertyDefinition.type)}]`)\n + `${propertyDefinition.multiplicity ? \"[]\" : \"\"}${\n propertyDefinition.nullable\n || (!strict\n && !(definition.type === \"object\"\n && definition.primaryKeyApiName === apiName))\n ? `| undefined`\n : \"\"\n }`,\n ] as [string, string];\n },\n })\n }\n }`;\n}\n\nexport function createDefinition(\n object: EnhancedObjectType | EnhancedInterfaceType,\n ontology: EnhancedOntologyDefinition,\n identifier: string,\n {\n objectDefIdentifier,\n objectSetIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n osdkObjectLinksIdentifier,\n }: Identifiers,\n) {\n const definition = object.getCleanedUpDefinition(true);\n const propertyMetadata = object instanceof EnhancedObjectType\n ? object.raw.objectType.properties\n : undefined;\n return `\n export interface ${identifier} extends ${\n object instanceof EnhancedObjectType\n ? `$ObjectTypeDefinition`\n : `$InterfaceDefinition`\n } {\n osdkMetadata: typeof $osdkMetadata;\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\";\n apiName: \"${object.fullApiName}\";\n __DefinitionMetadata?: {\n objectSet: ${objectSetIdentifier};\n props: ${osdkObjectPropsIdentifier};\n linksType: ${osdkObjectLinksIdentifier};\n strictProps: ${osdkObjectStrictPropsIdentifier};\n ${\n stringify(definition, {\n links: (_value) =>\n `{\n ${\n stringify(definition.links, {\n \"*\": (definition) =>\n `$ObjectMetadata.Link<${\n ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(true)\n }, ${definition.multiplicity}>`,\n })\n }\n }`,\n properties: (_value) => (`{\n ${\n stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) =>\n [\n `${\n propertyJsdoc(propertyDefinition, propertyMetadata?.[apiName], {\n apiName,\n })\n }\"${maybeStripNamespace(object, apiName)}\"`,\n `$PropertyDef<${JSON.stringify(propertyDefinition.type)}, \"${\n propertyDefinition.nullable ? \"nullable\" : \"non-nullable\"\n }\", \"${propertyDefinition.multiplicity ? \"array\" : \"single\"}\">`,\n ] as [string, string],\n })\n }\n }`),\n })\n }\n } \n}\n `;\n}\n\nexport function createLinks(\n ontology: EnhancedOntologyDefinition,\n object: EnhancedObjectType | EnhancedInterfaceType,\n identifier: string,\n) {\n const definition = object.getCleanedUpDefinition(true);\n\n return `\n ${\n Object.keys(definition.links).length === 0\n ? `export type ${identifier} = {};`\n : `\n export interface ${identifier} {\n${\n stringify(definition.links, {\n \"*\": (definition, _, key) => {\n const linkTarget = ontology.requireObjectType(\n definition.targetType,\n )\n .getImportedDefinitionIdentifier(true);\n\n return [\n `readonly ${key}`,\n `${\n definition.multiplicity\n ? `${linkTarget}.ObjectSet`\n : `$SingleLinkAccessor<${linkTarget}>`\n }\n `,\n ];\n },\n })\n }\n }\n `\n }`;\n}\n\nexport function createPropertyKeys(\n type: EnhancedObjectType | EnhancedInterfaceType,\n) {\n const properties = Object.keys(type.getCleanedUpDefinition(true).properties);\n return `export type PropertyKeys = ${\n properties.length === 0\n ? \"never\"\n : properties.map(\n (a) => maybeStripNamespace(type, a),\n ).map(a => `\"${a}\"`).join(\"|\")\n };`;\n}\n\nfunction remapStructType(structType: Record<string, any>): string {\n let output = `{`;\n Object.entries(structType).map(([key, value]) =>\n output += `${key}:$PropType[${JSON.stringify(value)}]|undefined;`\n );\n output += \"}\";\n return output;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,6CAA6C,QAAQ,4BAA4B;AAC1F,OAAOC,OAAO,MAAM,SAAS;AAE7B,SAASC,kBAAkB,QAAQ,0CAA0C;AAE7E,SAASC,WAAW,QAAQ,mCAAmC;AAE/D,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,SAAS,QAAQ,sBAAsB;;AAE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AS,CAACiB,UAAU,CAACyC,KAAK,EAAE;IAC1B,GAAG,EAAER,CAACjC,UAAU,EAAEmC,CAAC,EAAEW,GAAG,KAAK;MAC3B,MAAMC,UAAU,GAAG7D,QAAQ,CAACI,iBAAiB,CAC3CU,UAAU,CAAC0C,UACb,CAAC,CACEC,+BAA+B,CAAC,IAAI,CAAC;MAExC,OAAO,CACL,YAAYG,GAAG,EAAE,EACjB,GACE9C,UAAU,CAACsC,YAAY,GACnB,GAAGS,UAAU,YAAY,GACzB,uBAAuBA,UAAU,GAAG;AACxD,WACW,CACE;IACH;EACF,CAAC,CAAC;AACV;AACA,KACK,EACD;AACJ;AAEA,OAAO,SAASlC,kBAAkBA,CAChCU,IAAgD,EAChD;EACA,MAAMQ,UAAU,GAAGa,MAAM,CAACC,IAAI,CAACtB,IAAI,CAACF,sBAAsB,CAAC,IAAI,CAAC,CAACU,UAAU,CAAC;EAC5E,OAAO,8BACLA,UAAU,CAACH,MAAM,KAAK,CAAC,GACnB,OAAO,GACPG,UAAU,CAAClC,GAAG,CACbC,CAAC,IAAKwB,mBAAmB,CAACC,IAAI,EAAEzB,CAAC,CACpC,CAAC,CAACD,GAAG,CAACC,CAAC,IAAI,IAAIA,CAAC,GAAG,CAAC,CAACkD,IAAI,CAAC,GAAG,CAAC,GAC/B;AACL;AAEA,SAASZ,eAAeA,CAACa,UAA+B,EAAU;EAChE,IAAIC,MAAM,GAAG,GAAG;EAChBN,MAAM,CAACO,OAAO,CAACF,UAAU,CAAC,CAACpD,GAAG,CAAC,CAAC,CAACiD,GAAG,EAAEM,KAAK,CAAC,KAC1CF,MAAM,IAAI,GAAGJ,GAAG,cAAcT,IAAI,CAACtD,SAAS,CAACqE,KAAK,CAAC,cACrD,CAAC;EACDF,MAAM,IAAI,GAAG;EACb,OAAOA,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"wireObjectTypeV2ToSdkObjectConstV2.js","names":["wireObjectTypeFullMetadataToSdkObjectMetadata","consola","EnhancedObjectType","ForeignType","getObjectImports","propertyJsdoc","stringify","wireObjectTypeV2ToSdkObjectConstV2","wireObject","ontology","forInternalUse","currentFilePath","object","requireObjectType","objectType","apiName","Error","uniqueLinkTargetTypes","Set","linkTypes","map","a","objectTypeApiName","definition","raw","objectDefIdentifier","getDefinitionIdentifier","objectSetIdentifier","shortApiName","propertyKeysIdentifier","osdkObjectPropsIdentifier","osdkObjectStrictPropsIdentifier","osdkObjectLinksIdentifier","osdkObjectIdentifier","identifiers","imports","createPropertyKeys","createLinks","createProps","createObjectSet","createOsdkObject","createDefinition","fullApiName","identifier","getCleanedUpDefinition","maybeStripNamespace","type","q","apiNamespace","startsWith","slice","length","strict","propertyMetadata","properties","undefined","*","propertyDefinition","_","remapStructType","JSON","multiplicity","nullable","primaryKeyApiName","links","linkDefinition","targetType","requireInterfaceType","targetTypeApiName","getImportedDefinitionIdentifier","Object","keys","key","linkTarget","join","structType","output","entries","value"],"sources":["wireObjectTypeV2ToSdkObjectConstV2.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectTypeFullMetadata } from \"@osdk/foundry.ontologies\";\nimport { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"@osdk/generator-converters\";\nimport consola from \"consola\";\nimport type { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport { EnhancedObjectType } from \"../GenerateContext/EnhancedObjectType.js\";\nimport type { EnhancedOntologyDefinition } from \"../GenerateContext/EnhancedOntologyDefinition.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { propertyJsdoc } from \"../shared/propertyJsdoc.js\";\nimport { stringify } from \"../util/stringify.js\";\n\n/** @internal */\nexport function wireObjectTypeV2ToSdkObjectConstV2(\n wireObject: ObjectTypeFullMetadata,\n { ontology, forInternalUse }: Pick<\n GenerateContext,\n \"ontology\" | \"forInternalUse\"\n >,\n currentFilePath: string,\n) {\n const object = ontology.requireObjectType(\n wireObject.objectType.apiName,\n true,\n );\n if (object instanceof ForeignType) {\n throw new Error(\"Should not be generating types for an external type\");\n }\n const uniqueLinkTargetTypes = new Set(\n wireObject.linkTypes.map(a =>\n ontology.requireObjectType(a.objectTypeApiName, false)\n ),\n );\n\n const definition = wireObjectTypeFullMetadataToSdkObjectMetadata(\n object.raw,\n true,\n consola,\n );\n\n const objectDefIdentifier = object.getDefinitionIdentifier(true);\n\n const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;\n const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;\n // const osdkObjectPropsIdentifier = `OsdkObjectProps$${objectDefIdentifier}`;\n const osdkObjectPropsIdentifier = `${object.shortApiName}.Props`;\n const osdkObjectStrictPropsIdentifier = `${object.shortApiName}.StrictProps`;\n const osdkObjectLinksIdentifier = `${object.shortApiName}.Links`;\n const osdkObjectIdentifier = `${object.shortApiName}.OsdkObject`;\n\n const identifiers: Identifiers = {\n objectDefIdentifier: object.shortApiName,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n\n function getV2Types(\n object: EnhancedObjectType,\n forInternalUse: boolean = false,\n ) {\n return `import type {\n PropertyKeys as $PropertyKeys, \n ObjectTypeDefinition as $ObjectTypeDefinition,\n ObjectMetadata as $ObjectMetadata,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n import type {\n ObjectSet as $ObjectSet, \n Osdk as $Osdk,\n OsdkObject as $OsdkObject,\n PropertyValueWireToClient as $PropType,\n SingleLinkAccessor as $SingleLinkAccessor,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n\n\n export namespace ${object.shortApiName} {\n\n ${createPropertyKeys(object)}\n\n\n ${createLinks(ontology, object, \"Links\")}\n\n ${createProps(object, \"Props\", false)}\n ${createProps(object, \"StrictProps\", true)}\n\n ${createObjectSet(object, identifiers)}\n \n ${createOsdkObject(object, \"OsdkInstance\", identifiers)}\n } \n\n\n\n ${createDefinition(object, ontology, object.shortApiName, identifiers)}\n `;\n }\n\n const imports = getObjectImports(\n uniqueLinkTargetTypes,\n definition.apiName,\n currentFilePath,\n true,\n );\n\n return `${imports}${getV2Types(object, forInternalUse)}\n\n export const ${object.shortApiName}: ${objectDefIdentifier}\n = {\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\",\n apiName: \"${object.fullApiName}\",\n osdkMetadata: $osdkMetadata, \n };`;\n}\n\nexport interface Identifiers extends\n Record<\n | \"osdkObjectIdentifier\"\n | \"propertyKeysIdentifier\"\n | \"osdkObjectPropsIdentifier\"\n | \"objectDefIdentifier\"\n | \"osdkObjectLinksIdentifier\"\n | \"osdkObjectStrictPropsIdentifier\"\n | \"objectSetIdentifier\",\n string\n >\n{}\n\nexport function createOsdkObject(\n object: EnhancedObjectType | EnhancedInterfaceType,\n identifier: string,\n {\n osdkObjectPropsIdentifier,\n objectDefIdentifier,\n osdkObjectStrictPropsIdentifier,\n osdkObjectLinksIdentifier,\n }: Identifiers,\n) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export type ${identifier}<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > \n = $Osdk.Instance<\n ${objectDefIdentifier}, \n OPTIONS,\n K\n >;\n \n\n /** @deprecated use ${identifier} */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > = ${identifier}<OPTIONS, K>;\n ;\n `;\n}\n\nexport function createObjectSet(\n object: EnhancedObjectType | EnhancedInterfaceType,\n {\n objectDefIdentifier,\n objectSetIdentifier,\n propertyKeysIdentifier,\n osdkObjectIdentifier,\n }: Identifiers,\n) {\n return `\nexport interface ObjectSet extends \n$ObjectSet<${objectDefIdentifier},\n\n${objectSetIdentifier}\n>\n{\n\n}\n`;\n}\n\nfunction maybeStripNamespace(\n type: EnhancedInterfaceType | EnhancedObjectType,\n q: string,\n) {\n if (\n type.apiNamespace && q.startsWith(`${type.apiNamespace}.`)\n ) {\n return q.slice(type.apiNamespace.length + 1);\n } else {\n return q;\n }\n}\n\nexport function createProps(\n type: EnhancedInterfaceType | EnhancedObjectType,\n identifier: string,\n strict: boolean,\n): string {\n if (identifier === \"StrictProps\") {\n return `export type StrictProps = Props`;\n }\n const definition = type.getCleanedUpDefinition(true);\n const propertyMetadata = type instanceof EnhancedObjectType\n ? type.raw.objectType.properties\n : undefined;\n return `export interface ${identifier} {\n${\n stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => {\n return [\n `${\n propertyJsdoc(propertyDefinition, propertyMetadata?.[apiName], {\n apiName,\n })\n }readonly \"${maybeStripNamespace(type, apiName)}\"`,\n (typeof propertyDefinition.type === \"object\"\n ? remapStructType(propertyDefinition.type)\n : `$PropType[${JSON.stringify(propertyDefinition.type)}]`)\n + `${propertyDefinition.multiplicity ? \"[]\" : \"\"}${\n propertyDefinition.nullable\n || (!strict\n && !(definition.type === \"object\"\n && definition.primaryKeyApiName === apiName))\n ? `| undefined`\n : \"\"\n }`,\n ] as [string, string];\n },\n })\n }\n }`;\n}\n\nexport function createDefinition(\n object: EnhancedObjectType | EnhancedInterfaceType,\n ontology: EnhancedOntologyDefinition,\n identifier: string,\n {\n objectDefIdentifier,\n objectSetIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n osdkObjectLinksIdentifier,\n }: Identifiers,\n) {\n const definition = object.getCleanedUpDefinition(true);\n const propertyMetadata = object instanceof EnhancedObjectType\n ? object.raw.objectType.properties\n : undefined;\n return `\n export interface ${identifier} extends ${\n object instanceof EnhancedObjectType\n ? `$ObjectTypeDefinition`\n : `$InterfaceDefinition`\n } {\n osdkMetadata: typeof $osdkMetadata;\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\";\n apiName: \"${object.fullApiName}\";\n __DefinitionMetadata?: {\n objectSet: ${objectSetIdentifier};\n props: ${osdkObjectPropsIdentifier};\n linksType: ${osdkObjectLinksIdentifier};\n strictProps: ${osdkObjectStrictPropsIdentifier};\n ${\n stringify(definition, {\n links: (_value) =>\n `{\n ${\n definition.type === \"interface\"\n ? stringify(definition.links, {\n \"*\": (linkDefinition) =>\n `$InterfaceMetadata.Link<${\n linkDefinition.targetType === \"interface\"\n ? ontology.requireInterfaceType(\n linkDefinition.targetTypeApiName,\n )\n .getImportedDefinitionIdentifier(true)\n : ontology.requireObjectType(\n linkDefinition.targetTypeApiName,\n ).getImportedDefinitionIdentifier(true)\n }, ${linkDefinition.multiplicity}>`,\n })\n : stringify(definition.links, {\n \"*\": (linkDefinition) =>\n `$ObjectMetadata.Link<${\n ontology.requireObjectType(linkDefinition.targetType)\n .getImportedDefinitionIdentifier(true)\n }, ${linkDefinition.multiplicity}>`,\n })\n }\n }`,\n properties: (_value) => (`{\n ${\n stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) =>\n [\n `${\n propertyJsdoc(propertyDefinition, propertyMetadata?.[apiName], {\n apiName,\n })\n }\"${maybeStripNamespace(object, apiName)}\"`,\n `$PropertyDef<${JSON.stringify(propertyDefinition.type)}, \"${\n propertyDefinition.nullable ? \"nullable\" : \"non-nullable\"\n }\", \"${propertyDefinition.multiplicity ? \"array\" : \"single\"}\">`,\n ] as [string, string],\n })\n }\n }`),\n })\n }\n } \n}\n `;\n}\n\nexport function createLinks(\n ontology: EnhancedOntologyDefinition,\n object: EnhancedObjectType | EnhancedInterfaceType,\n identifier: string,\n) {\n const definition = object.getCleanedUpDefinition(true);\n\n return `\n ${\n Object.keys(definition.links).length === 0\n ? `export type ${identifier} = {};`\n : `\n export interface ${identifier} {\n${\n stringify(definition.links, {\n \"*\": (definition, _, key) => {\n const linkTarget = ontology.requireObjectType(\n definition.targetType,\n )\n .getImportedDefinitionIdentifier(true);\n\n return [\n `readonly ${key}`,\n `${\n definition.multiplicity\n ? `${linkTarget}.ObjectSet`\n : `$SingleLinkAccessor<${linkTarget}>`\n }\n `,\n ];\n },\n })\n }\n }\n `\n }`;\n}\n\nexport function createPropertyKeys(\n type: EnhancedObjectType | EnhancedInterfaceType,\n) {\n const properties = Object.keys(type.getCleanedUpDefinition(true).properties);\n return `export type PropertyKeys = ${\n properties.length === 0\n ? \"never\"\n : properties.map(\n (a) => maybeStripNamespace(type, a),\n ).map(a => `\"${a}\"`).join(\"|\")\n };`;\n}\n\nfunction remapStructType(structType: Record<string, any>): string {\n let output = `{`;\n Object.entries(structType).map(([key, value]) =>\n output += `${key}:$PropType[${JSON.stringify(value)}]|undefined;`\n );\n output += \"}\";\n return output;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,6CAA6C,QAAQ,4BAA4B;AAC1F,OAAOC,OAAO,MAAM,SAAS;AAE7B,SAASC,kBAAkB,QAAQ,0CAA0C;AAE7E,SAASC,WAAW,QAAQ,mCAAmC;AAE/D,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,SAAS,QAAQ,sBAAsB;;AAEhD;AACA,OAAO,SAASC,kCAAkCA,CAChDC,UAAkC,EAClC;EAAEC,QAAQ;EAAEC;AAGZ,CAAC,EACDC,eAAuB,EACvB;EACA,MAAMC,MA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ACoD,GAAG,EAAEM,KAAK,CAAC,KAC1CF,MAAM,IAAI,GAAGJ,GAAG,cAAcZ,IAAI,CAACtD,SAAS,CAACwE,KAAK,CAAC,cACrD,CAAC;EACDF,MAAM,IAAI,GAAG;EACb,OAAOA,MAAM;AACf","ignoreList":[]}
@@ -814,8 +814,10 @@ function createDefinition(object, ontology, identifier, {
814
814
  strictProps: ${osdkObjectStrictPropsIdentifier};
815
815
  ${stringify(definition, {
816
816
  links: (_value) => `{
817
- ${stringify(definition.links, {
818
- "*": (definition2) => `$ObjectMetadata.Link<${ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(true)}, ${definition2.multiplicity}>`
817
+ ${definition.type === "interface" ? stringify(definition.links, {
818
+ "*": (linkDefinition) => `$InterfaceMetadata.Link<${linkDefinition.targetType === "interface" ? ontology.requireInterfaceType(linkDefinition.targetTypeApiName).getImportedDefinitionIdentifier(true) : ontology.requireObjectType(linkDefinition.targetTypeApiName).getImportedDefinitionIdentifier(true)}, ${linkDefinition.multiplicity}>`
819
+ }) : stringify(definition.links, {
820
+ "*": (linkDefinition) => `$ObjectMetadata.Link<${ontology.requireObjectType(linkDefinition.targetType).getImportedDefinitionIdentifier(true)}, ${linkDefinition.multiplicity}>`
819
821
  })}
820
822
  }`,
821
823
  properties: (_value) => `{
@@ -857,8 +859,9 @@ function remapStructType(structType) {
857
859
  }
858
860
 
859
861
  // src/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.ts
860
- function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false, forInternalUse = false) {
862
+ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false, forInternalUse = false, currentFilePath = "") {
861
863
  const definition = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef.raw, v2));
864
+ const uniqueLinkTargetTypes = new Set(definition.links ? Object.values(definition.links).map((a) => a.targetType === "object" ? ontology.requireObjectType(a.targetTypeApiName) : ontology.requireInterfaceType(a.targetTypeApiName)) : []);
862
865
  const objectDefIdentifier = interfaceDef.getDefinitionIdentifier(v2);
863
866
  const parents = definition.implements?.map((p) => {
864
867
  const parent = ontology.requireInterfaceType(p, true);
@@ -908,22 +911,23 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology,
908
911
  function getV2Types(forInternalUse2 = false) {
909
912
  return `import type {
910
913
  InterfaceDefinition as $InterfaceDefinition,
914
+ InterfaceMetadata as $InterfaceMetadata,
911
915
  ObjectSet as $ObjectSet,
912
916
  Osdk as $Osdk,
913
917
  PropertyValueWireToClient as $PropType,
914
918
  } from "${forInternalUse2 ? "@osdk/api" : "@osdk/client"}";
915
919
 
916
- ${Object.keys(definition.links).length === 0 ? `export type ${osdkObjectLinksIdentifier} = {};` : `
920
+ ${definition.links ? Object.keys(definition.links).length > 0 ? `
917
921
  export interface ${osdkObjectLinksIdentifier} {
918
922
  ${stringify(definition.links, {
919
923
  "*": (definition2) => {
920
- const linkTarget = ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(v2);
921
- return `${definition2.multiplicity ? `${linkTarget}["objectSet"]` : `SingleLinkAccessor<${linkTarget}>`}
924
+ const linkTarget = definition2.targetType === "object" ? ontology.requireObjectType(definition2.targetTypeApiName).getImportedDefinitionIdentifier(v2) : ontology.requireInterfaceType(definition2.targetTypeApiName).getImportedDefinitionIdentifier(v2);
925
+ return `${definition2.multiplicity ? `${linkTarget}.ObjectSet` : `${linkTarget}.ObjectSet`}
922
926
  `;
923
927
  }
924
928
  })}
925
929
  }
926
- `}
930
+ ` : `export type ${osdkObjectLinksIdentifier} = {};` : `export type ${osdkObjectLinksIdentifier} = {};`}
927
931
 
928
932
  export namespace ${interfaceDef.shortApiName} {
929
933
 
@@ -944,8 +948,8 @@ ${stringify(definition.links, {
944
948
 
945
949
  `;
946
950
  }
947
- const imports = [];
948
- return `${imports.join("\n")}
951
+ const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);
952
+ return `${imports}
949
953
  ${v2 ? getV2Types(forInternalUse) : ""}
950
954
 
951
955
  export const ${interfaceDef.shortApiName}: ${interfaceDef.shortApiName} = {
@@ -969,10 +973,11 @@ async function generatePerInterfaceDataFiles({
969
973
  });
970
974
  for (const obj of Object.values(ontology.interfaceTypes)) {
971
975
  if (obj instanceof ForeignType) continue;
976
+ const relPath = path8__namespace.default.join(".", "ontology", "interfaces", `${obj.shortApiName}.ts`);
972
977
  await fs2.writeFile(path8__namespace.default.join(interfacesDir, `${obj.shortApiName}.ts`), await formatTs(`
973
978
  import type { PropertyDef as $PropertyDef } from "${forInternalUse ? "@osdk/api" : "@osdk/client"}";
974
979
  import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
975
- ${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true, forInternalUse)}
980
+ ${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true, forInternalUse, relPath)}
976
981
  `));
977
982
  }
978
983
  await fs2.writeFile(interfacesDir + ".ts", await formatTs(`