@osdk/generator 2.0.2-rc.0 → 2.1.0-beta.0

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 (114) hide show
  1. package/CHANGELOG.md +9 -9
  2. package/build/browser/GenerateContext/EnhanceCommon.d.ts +0 -2
  3. package/build/browser/GenerateContext/EnhanceCommon.d.ts.map +1 -1
  4. package/build/browser/GenerateContext/EnhancedBase.d.ts +1 -3
  5. package/build/browser/GenerateContext/EnhancedBase.d.ts.map +1 -1
  6. package/build/browser/GenerateContext/EnhancedBase.js +2 -11
  7. package/build/browser/GenerateContext/EnhancedBase.js.map +1 -1
  8. package/build/browser/GenerateContext/EnhancedOntologyDefinition.d.ts +4 -4
  9. package/build/browser/GenerateContext/EnhancedOntologyDefinition.d.ts.map +1 -1
  10. package/build/browser/GenerateContext/EnhancedOntologyDefinition.js +27 -21
  11. package/build/browser/GenerateContext/EnhancedOntologyDefinition.js.map +1 -1
  12. package/build/browser/GenerateContext/ForeignType.d.ts +1 -2
  13. package/build/browser/GenerateContext/ForeignType.d.ts.map +1 -1
  14. package/build/browser/GenerateContext/ForeignType.js +5 -11
  15. package/build/browser/GenerateContext/ForeignType.js.map +1 -1
  16. package/build/browser/GenerateContext/enhanceOntology.d.ts +7 -1
  17. package/build/browser/GenerateContext/enhanceOntology.d.ts.map +1 -1
  18. package/build/browser/GenerateContext/enhanceOntology.js +8 -2
  19. package/build/browser/GenerateContext/enhanceOntology.js.map +1 -1
  20. package/build/browser/generateClientSdkPackage.d.ts +1 -1
  21. package/build/browser/generateClientSdkPackage.d.ts.map +1 -1
  22. package/build/browser/generateClientSdkPackage.js +2 -2
  23. package/build/browser/generateClientSdkPackage.js.map +1 -1
  24. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +19 -6
  25. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
  26. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +40 -6
  27. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
  28. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.d.ts +1 -1
  29. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
  30. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js +16 -80
  31. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
  32. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js +121 -52
  33. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
  34. package/build/browser/v2.0/generateMetadata.js +1 -1
  35. package/build/browser/v2.0/generateMetadata.js.map +1 -1
  36. package/build/browser/v2.0/generatePerActionDataFiles.test.js +14 -2
  37. package/build/browser/v2.0/generatePerActionDataFiles.test.js.map +1 -1
  38. package/build/browser/v2.0/generatePerInterfaceDataFiles.d.ts +2 -0
  39. package/build/browser/v2.0/generatePerInterfaceDataFiles.d.ts.map +1 -0
  40. package/build/browser/v2.0/generatePerInterfaceDataFiles.js +45 -0
  41. package/build/browser/v2.0/generatePerInterfaceDataFiles.js.map +1 -0
  42. package/build/browser/v2.0/generatePerObjectDataFiles.d.ts +3 -0
  43. package/build/browser/v2.0/generatePerObjectDataFiles.d.ts.map +1 -0
  44. package/build/browser/v2.0/generatePerObjectDataFiles.js +47 -0
  45. package/build/browser/v2.0/generatePerObjectDataFiles.js.map +1 -0
  46. package/build/browser/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
  47. package/build/browser/v2.0/generatePerQueryDataFiles.js +1 -1
  48. package/build/browser/v2.0/generatePerQueryDataFiles.js.map +1 -1
  49. package/build/browser/v2.0/generatePerQueryDataFiles.test.js +9 -3
  50. package/build/browser/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
  51. package/build/browser/v2.0/generateRootIndexTsFile.d.ts +3 -0
  52. package/build/browser/v2.0/generateRootIndexTsFile.d.ts.map +1 -0
  53. package/build/browser/v2.0/generateRootIndexTsFile.js +40 -0
  54. package/build/browser/v2.0/generateRootIndexTsFile.js.map +1 -0
  55. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
  56. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +19 -9
  57. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
  58. package/build/esm/GenerateContext/EnhanceCommon.d.ts +0 -2
  59. package/build/esm/GenerateContext/EnhanceCommon.d.ts.map +1 -1
  60. package/build/esm/GenerateContext/EnhancedBase.d.ts +1 -3
  61. package/build/esm/GenerateContext/EnhancedBase.d.ts.map +1 -1
  62. package/build/esm/GenerateContext/EnhancedBase.js +2 -11
  63. package/build/esm/GenerateContext/EnhancedBase.js.map +1 -1
  64. package/build/esm/GenerateContext/EnhancedOntologyDefinition.d.ts +4 -4
  65. package/build/esm/GenerateContext/EnhancedOntologyDefinition.d.ts.map +1 -1
  66. package/build/esm/GenerateContext/EnhancedOntologyDefinition.js +27 -21
  67. package/build/esm/GenerateContext/EnhancedOntologyDefinition.js.map +1 -1
  68. package/build/esm/GenerateContext/ForeignType.d.ts +1 -2
  69. package/build/esm/GenerateContext/ForeignType.d.ts.map +1 -1
  70. package/build/esm/GenerateContext/ForeignType.js +5 -11
  71. package/build/esm/GenerateContext/ForeignType.js.map +1 -1
  72. package/build/esm/GenerateContext/enhanceOntology.d.ts +7 -1
  73. package/build/esm/GenerateContext/enhanceOntology.d.ts.map +1 -1
  74. package/build/esm/GenerateContext/enhanceOntology.js +8 -2
  75. package/build/esm/GenerateContext/enhanceOntology.js.map +1 -1
  76. package/build/esm/generateClientSdkPackage.d.ts +1 -1
  77. package/build/esm/generateClientSdkPackage.d.ts.map +1 -1
  78. package/build/esm/generateClientSdkPackage.js +2 -2
  79. package/build/esm/generateClientSdkPackage.js.map +1 -1
  80. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +19 -6
  81. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
  82. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +40 -6
  83. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
  84. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts +1 -1
  85. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
  86. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js +16 -80
  87. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
  88. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js +121 -52
  89. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
  90. package/build/esm/v2.0/generateMetadata.js +1 -1
  91. package/build/esm/v2.0/generateMetadata.js.map +1 -1
  92. package/build/esm/v2.0/generatePerActionDataFiles.test.js +14 -2
  93. package/build/esm/v2.0/generatePerActionDataFiles.test.js.map +1 -1
  94. package/build/esm/v2.0/generatePerInterfaceDataFiles.d.ts +2 -0
  95. package/build/esm/v2.0/generatePerInterfaceDataFiles.d.ts.map +1 -0
  96. package/build/esm/v2.0/generatePerInterfaceDataFiles.js +45 -0
  97. package/build/esm/v2.0/generatePerInterfaceDataFiles.js.map +1 -0
  98. package/build/esm/v2.0/generatePerObjectDataFiles.d.ts +3 -0
  99. package/build/esm/v2.0/generatePerObjectDataFiles.d.ts.map +1 -0
  100. package/build/esm/v2.0/generatePerObjectDataFiles.js +47 -0
  101. package/build/esm/v2.0/generatePerObjectDataFiles.js.map +1 -0
  102. package/build/esm/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
  103. package/build/esm/v2.0/generatePerQueryDataFiles.js +1 -1
  104. package/build/esm/v2.0/generatePerQueryDataFiles.js.map +1 -1
  105. package/build/esm/v2.0/generatePerQueryDataFiles.test.js +9 -3
  106. package/build/esm/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
  107. package/build/esm/v2.0/generateRootIndexTsFile.d.ts +3 -0
  108. package/build/esm/v2.0/generateRootIndexTsFile.d.ts.map +1 -0
  109. package/build/esm/v2.0/generateRootIndexTsFile.js +40 -0
  110. package/build/esm/v2.0/generateRootIndexTsFile.js.map +1 -0
  111. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
  112. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +19 -9
  113. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
  114. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js","names":["__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","fastDeepEqual","invariant","propertyJsdoc","deleteUndefineds","stringify","createDefinition","createObjectSet","createOsdkObject","createPropertyKeys","createProps","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst","interfaceDef","ontology","v2","definition","raw","objectDefIdentifier","getDefinitionIdentifier","parents","implements","map","p","interfaceTypes","it","requireInterfaceType","mergedProperties","properties","parent","apiName","Object","keys","ogProperties","objectSetIdentifier","shortApiName","propertyKeysIdentifier","osdkObjectPropsIdentifier","osdkObjectStrictPropsIdentifier","osdkObjectLinksIdentifier","osdkObjectIdentifier","ids","join","links","length","linkTarget","requireObjectType","targetType","getImportedDefinitionIdentifier","multiplicity","fullApiName"],"sources":["UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js"],"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 */\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from \"@osdk/generator-converters\";\nimport fastDeepEqual from \"fast-deep-equal\";\nimport invariant from \"tiny-invariant\";\nimport { propertyJsdoc } from \"../shared/propertyJsdoc.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\nimport { createDefinition, createObjectSet, createOsdkObject, createPropertyKeys, createProps, } from \"./wireObjectTypeV2ToSdkObjectConstV2.js\";\n/** @internal */\nexport function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false) {\n const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef.raw, v2));\n const objectDefIdentifier = interfaceDef.getDefinitionIdentifier(v2);\n const parents = definition.implements?.map(p => {\n invariant(ontology.interfaceTypes[p] != null, `Expected to find a parent interface named ${p} in the ontology and did not.`);\n const it = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.requireInterfaceType(p, true).raw, v2));\n return it;\n }) ?? [];\n const mergedProperties = { ...definition.properties };\n for (const parent of parents) {\n for (const apiName of Object.keys(parent.properties)) {\n if (definition.properties[apiName] != null) {\n invariant(fastDeepEqual(definition.properties[apiName], parent.properties[apiName]), `Interface ${definition.apiName} redefines property '${apiName}' from parent '${parent.apiName}' but the properties do not match`);\n }\n else if (mergedProperties[apiName] != null) {\n invariant(fastDeepEqual(mergedProperties[apiName], parent.properties[apiName]), `Some interface defines a conflicting property '${apiName}' that does not match property from parent '${parent.apiName}'`);\n }\n mergedProperties[apiName] = parent.properties[apiName];\n }\n }\n const ogProperties = definition.properties;\n definition.properties = mergedProperties;\n function localPropertyJsdoc(apiName) {\n const property = definition.properties[apiName];\n const isInherited = ogProperties[apiName] == null;\n return propertyJsdoc(property, { isInherited, apiName });\n }\n function maybeStripNamespace(q) {\n if (interfaceDef.apiNamespace && q.startsWith(`${interfaceDef.apiNamespace}.`)) {\n return q.slice(interfaceDef.apiNamespace.length + 1);\n }\n else {\n return q;\n }\n }\n const objectSetIdentifier = `${interfaceDef.shortApiName}.ObjectSet`;\n const propertyKeysIdentifier = `${interfaceDef.shortApiName}.PropertyKeys`;\n // const osdkObjectPropsIdentifier = `OsdkObjectProps$${objectDefIdentifier}`;\n const osdkObjectPropsIdentifier = `${interfaceDef.shortApiName}.Props`;\n const osdkObjectStrictPropsIdentifier = `${interfaceDef.shortApiName}.StrictProps`;\n const osdkObjectLinksIdentifier = `OsdkObjectLinks$${objectDefIdentifier}`;\n const osdkObjectIdentifier = `${interfaceDef.shortApiName}.OsdkObject`;\n const ids = {\n objectDefIdentifier: interfaceDef.shortApiName,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n function getV2Types() {\n return `import type {\n InterfaceDefinition as $InterfaceDefinition,\n ObjectSet as $ObjectSet, \n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n \n ${Object.keys(definition.links).length === 0\n ? `export type ${osdkObjectLinksIdentifier} = {};`\n : `\n export interface ${osdkObjectLinksIdentifier} {\n${stringify(definition.links, {\n \"*\": (definition) => {\n const linkTarget = ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(v2);\n return `${definition.multiplicity\n ? `${linkTarget}[\"objectSet\"]`\n : `SingleLinkAccessor<${linkTarget}>`}\n `;\n },\n })}\n }\n `}\n\n export namespace ${interfaceDef.shortApiName} {\n\n ${createPropertyKeys(interfaceDef)}\n\n\n ${createProps(interfaceDef, \"Props\", false)}\n ${createProps(interfaceDef, \"StrictProps\", true)}\n\n\n ${createObjectSet(interfaceDef, ids)}\n\n ${createOsdkObject(interfaceDef, \"OsdkObject\", ids)}\n \n } \n\n ${createDefinition(interfaceDef, ontology, interfaceDef.shortApiName, ids)}\n\n`;\n }\n // FIXME: We need to fill in the imports\n // if we want links to work\n const imports = [];\n definition;\n return `${imports.join(\"\\n\")}\n ${v2 ? getV2Types() : \"\"}\n\n export const ${interfaceDef.shortApiName}: ${interfaceDef.shortApiName} = {\n type: \"interface\",\n apiName: \"${interfaceDef.fullApiName}\",\n osdkMetadata: $osdkMetadata,\n };`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mDAAmD,QAAQ,4BAA4B;AAChG,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,gBAAgB,EAAEC,eAAe,EAAEC,gBAAgB,EAAEC,kBAAkB,EAAEC,WAAW,QAAS,yCAAyC;AAC/I;AACA,OAAO,SAASC,8CAA8CA,CAACC,YAAY,EAAEC,QAAQ,EAAEC,EAAE,GAAG,KAAK,EAAE;EAC/F,MAAMC,UAAU,GAAGX,gBAAgB,CAACJ,mDAAmD,CAACY,YAAY,CAACI,GAAG,EAAEF,EAAE,CAAC,CAAC;EAC9G,MAAMG,mBAAmB,GAAGL,YAAY,CAACM,uBAAuB,CAACJ,EAAE,CAAC;EACpE,MAAMK,OAAO,GAAGJ,UAAU,CAACK,UAAU,EAAEC,GAAG,CAACC,CAAC,IAAI;IAC5C,EAAUT,QAAQ,CAACU,cAAc,CAACD,CAAC,CAAC,IAAI,IAAI,IAA5CpB,SAAS,QAAqC,6CAA6CoB,CAAC,+BAA+B;IAC3H,MAAME,EAAE,GAAGpB,gBAAgB,CAACJ,mDAAmD,CAACa,QAAQ,CAACY,oBAAoB,CAACH,CAAC,EAAE,IAAI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C1C;AACA,QAAQhC,gBAAgB,CAACI,YAAY,EAAE,YAAY,EAAE4B,GAAG,CAAC;AACzD;AACA;AACA;AACA,MAAMlC,gBAAgB,CAACM,YAAY,EAAEC,QAAQ,EAAED,YAAY,CAACsB,YAAY,EAAEM,GAAG,CAAC;AAC9E;AACA,CAAC;EACG,CAAC,CAMiB,CAAC,GAAG,EAAE;AAC5B;AACA,mBAAmB5B,YAAY,CAACsB,YAAY,KAAKtB,YAAY,CAACsB,YAAY;AAC1E;AACA,kBAAkBtB,YAAY,CAACqC,WAAW;AAC1C;AACA,UAAU;AACV","ignoreList":[]}
1
+ {"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js","names":["__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","fastDeepEqual","invariant","extractNamespace","EnhancedInterfaceType","deleteUndefineds","stringify","createDefinition","createObjectSet","createOsdkObject","createPropertyKeys","createProps","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst","interfaceDef","ontology","v2","definition","raw","objectDefIdentifier","getDefinitionIdentifier","parents","implements","map","p","parent","requireInterfaceType","it","mergedProperties","properties","apiName","Object","keys","objectSetIdentifier","shortApiName","propertyKeysIdentifier","osdkObjectPropsIdentifier","osdkObjectStrictPropsIdentifier","osdkObjectLinksIdentifier","osdkObjectIdentifier","ids","apiNamespace","badProperties","filter","length","Error","fullApiName","join","links","linkTarget","requireObjectType","targetType","getImportedDefinitionIdentifier","multiplicity"],"sources":["UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js"],"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 */\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from \"@osdk/generator-converters\";\nimport fastDeepEqual from \"fast-deep-equal\";\nimport invariant from \"tiny-invariant\";\nimport { extractNamespace } from \"../GenerateContext/EnhancedBase.js\";\nimport { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\nimport { createDefinition, createObjectSet, createOsdkObject, createPropertyKeys, createProps, } from \"./wireObjectTypeV2ToSdkObjectConstV2.js\";\n/** @internal */\nexport function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false) {\n const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef.raw, v2));\n const objectDefIdentifier = interfaceDef.getDefinitionIdentifier(v2);\n const parents = definition.implements?.map(p => {\n const parent = ontology.requireInterfaceType(p, true);\n if (parent instanceof EnhancedInterfaceType) {\n const it = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(parent.raw, v2));\n return it;\n }\n }) ?? [];\n const mergedProperties = { ...definition.properties };\n for (const parent of parents) {\n if (parent == null) {\n // came from a foreign type and we cannot merge properties yet\n // so if they weren't listed on the interface its over\n continue;\n }\n for (const apiName of Object.keys(parent.properties)) {\n if (definition.properties[apiName] != null) {\n invariant(fastDeepEqual(definition.properties[apiName], parent.properties[apiName]), `Interface ${definition.apiName} redefines property '${apiName}' from parent '${parent.apiName}' but the properties do not match`);\n }\n else if (mergedProperties[apiName] != null) {\n invariant(fastDeepEqual(mergedProperties[apiName], parent.properties[apiName]), `Some interface defines a conflicting property '${apiName}' that does not match property from parent '${parent.apiName}'`);\n }\n mergedProperties[apiName] = parent.properties[apiName];\n }\n }\n definition.properties = mergedProperties;\n const objectSetIdentifier = `${interfaceDef.shortApiName}.ObjectSet`;\n const propertyKeysIdentifier = `${interfaceDef.shortApiName}.PropertyKeys`;\n // const osdkObjectPropsIdentifier = `OsdkObjectProps$${objectDefIdentifier}`;\n const osdkObjectPropsIdentifier = `${interfaceDef.shortApiName}.Props`;\n const osdkObjectStrictPropsIdentifier = `${interfaceDef.shortApiName}.StrictProps`;\n const osdkObjectLinksIdentifier = `OsdkObjectLinks$${objectDefIdentifier}`;\n const osdkObjectIdentifier = `${interfaceDef.shortApiName}.OsdkObject`;\n const ids = {\n objectDefIdentifier: interfaceDef.shortApiName,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n if (interfaceDef.apiNamespace) {\n const badProperties = Object.keys(definition.properties).filter(apiName => extractNamespace(apiName)[0] == null);\n if (badProperties.length > 0) {\n throw new Error(`Interfaces with fully qualified api names MUST NOT have any properties with an unqualified api name. Interface: ${interfaceDef.fullApiName}, properties: ${badProperties.join(\", \")}`);\n }\n }\n function getV2Types() {\n return `import type {\n InterfaceDefinition as $InterfaceDefinition,\n ObjectSet as $ObjectSet, \n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n \n ${Object.keys(definition.links).length === 0\n ? `export type ${osdkObjectLinksIdentifier} = {};`\n : `\n export interface ${osdkObjectLinksIdentifier} {\n${stringify(definition.links, {\n \"*\": (definition) => {\n const linkTarget = ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(v2);\n return `${definition.multiplicity\n ? `${linkTarget}[\"objectSet\"]`\n : `SingleLinkAccessor<${linkTarget}>`}\n `;\n },\n })}\n }\n `}\n\n export namespace ${interfaceDef.shortApiName} {\n\n ${createPropertyKeys(interfaceDef)}\n\n\n ${createProps(interfaceDef, \"Props\", false)}\n ${createProps(interfaceDef, \"StrictProps\", true)}\n\n\n ${createObjectSet(interfaceDef, ids)}\n\n ${createOsdkObject(interfaceDef, \"OsdkInstance\", ids)}\n \n } \n\n ${createDefinition(interfaceDef, ontology, interfaceDef.shortApiName, ids)}\n\n`;\n }\n // FIXME: We need to fill in the imports\n // if we want links to work\n const imports = [];\n definition;\n return `${imports.join(\"\\n\")}\n ${v2 ? getV2Types() : \"\"}\n\n export const ${interfaceDef.shortApiName}: ${interfaceDef.shortApiName} = {\n type: \"interface\",\n apiName: \"${interfaceDef.fullApiName}\",\n osdkMetadata: $osdkMetadata,\n };`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mDAAmD,QAAQ,4BAA4B;AAChG,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,qBAAqB,QAAQ,6CAA6C;AACnF,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,gBAAgB,EAAEC,eAAe,EAAEC,gBAAgB,EAAEC,kBAAkB,EAAEC,WAAW,QAAS,yCAAyC;AAC/I;AACA,OAAO,SAASC,8CAA8CA,CAACC,YAAY,EAAEC,QAAQ,EAAEC,EAAE,GAAG,KAAK,EAAE;EAC/F,MAAMC,UAAU,GAAGX,gBAAgB,CAACL,mDAAmD,CAACa,YAAY,CAACI,GAAG,EAAEF,EAAE,CAAC,CAAC;EAC9G,MAAMG,mBAAmB,GAAGL,YAAY,CAACM,uBAAuB,CAACJ,EAAE,CAAC;EACpE,MAAMK,OAAO,GAAGJ,UAAU,CAACK,UAAU,EAAEC,GAAG,CAACC,CAAC,IAAI;IAC5C,MAAMC,MAAM,GAAGV,QAAQ,CAACW,oBAAoB,CAACF,CAAC,EAAE,IAAI,CAAC;IACrD,IAAIC,MAAM,YAAYpB,qBAAqB,EAAE;MACzC,MAAMsB,EAAE,GAAGrB,gBAAgB,CAACL,mDAAmD,CAACwB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GC,UAAU,CAACoC,YAAY,GAC3B,GAAGJ,UAAU,eAAe,GAC5B,sBAAsBA,UAAU,GAAG;AAC7D,WAAW;MACK;IACJ,CAAC,CAAC;AACd;AACA,KAAK;AACL;AACA,uBAAuBnC,YAAY,CAACoB,YAAY;AAChD;AACA,QAAQvB,kBAAkB,CAACG,YAAY,CAAC;AACxC;AACA;AACA,QAAQF,WAAW,CAACE,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC;AACjD,QAAQF,WAAW,CAACE,YAAY,EAAE,aAAa,EAAE,IAAI,CAAC;AACtD;AACA;AACA,QAAQL,eAAe,CAACK,YAAY,EAAE0B,GAAG,CAAC;AAC1C;AACA,QAAQ9B,gBAAgB,CAACI,YAAY,EAAE,cAAc,EAAE0B,GAAG,CAAC;AAC3D;AACA;AACA;AACA,MAAMhC,gBAAgB,CAACM,YAAY,EAAEC,QAAQ,EAAED,YAAY,CAACoB,YAAY,EAAEM,GAAG,CAAC;AAC9E;AACA,CAAC;EACG,CAAC,CAMiB,CAAC,GAAG,EAAE;AAC5B;AACA,mBAAmB1B,YAAY,CAACoB,YAAY,KAAKpB,YAAY,CAACoB,YAAY;AAC1E;AACA,kBAAkBpB,YAAY,CAACgC,WAAW;AAC1C;AACA,UAAU;AACV","ignoreList":[]}
@@ -15,7 +15,9 @@
15
15
  */
16
16
  import { format } from "prettier";
17
17
  import { describe, expect, it } from "vitest";
18
+ import { EnhancedInterfaceType } from "../GenerateContext/EnhancedInterfaceType.js";
18
19
  import { enhanceOntology } from "../GenerateContext/enhanceOntology.js";
20
+ import { ForeignType } from "../GenerateContext/ForeignType.js";
19
21
  import { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst } from "./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js";
20
22
  function simpleSpt(apiName, metadataLevel = 2) {
21
23
  return {
@@ -59,7 +61,15 @@ function simpleOntology(apiName, interfaces) {
59
61
  }
60
62
  describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
61
63
  it("Does not say (inherited) on properties locally defined", async () => {
62
- const ontology = enhanceOntology(simpleOntology("ontology", [simpleInterface("Bar", [simpleSpt("bar", 0)], [], 0)]), undefined, new Map(), "");
64
+ const ontology = enhanceOntology({
65
+ sanitized: simpleOntology("ontology", [simpleInterface("Bar", [simpleSpt("bar", 0)], [], 0)]),
66
+ importExt: ""
67
+ });
68
+ expect(ontology.interfaceTypes.Bar instanceof EnhancedInterfaceType).toBe(true);
69
+ // type guard for below
70
+ if (ontology.interfaceTypes.Bar instanceof ForeignType) {
71
+ throw new Error("Expected Bar to be an EnhancedInterfaceType");
72
+ }
63
73
  const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Bar, ontology, true), {
64
74
  parser: "typescript",
65
75
  printWidth: 100
@@ -86,10 +96,16 @@ describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
86
96
 
87
97
  export interface ObjectSet extends $ObjectSet<Bar, Bar.ObjectSet> {}
88
98
 
99
+ export type OsdkInstance<
100
+ OPTIONS extends never | "$notStrict" | "$rid" = never,
101
+ K extends keyof Bar.Props = keyof Bar.Props,
102
+ > = $Osdk.Instance<Bar, OPTIONS, K>;
103
+
104
+ /** @deprecated use OsdkInstance */
89
105
  export type OsdkObject<
90
106
  OPTIONS extends never | "$notStrict" | "$rid" = never,
91
107
  K extends keyof Bar.Props = keyof Bar.Props,
92
- > = $Osdk<Bar, K | OPTIONS>;
108
+ > = OsdkInstance<OPTIONS, K>;
93
109
  }
94
110
 
95
111
  export interface Bar extends $InterfaceDefinition {
@@ -127,7 +143,10 @@ describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
127
143
  it("Generates properties for inherited SPTs", async () => {
128
144
  const fooSpt = simpleSpt("foo");
129
145
  const barSpt = simpleSpt("bar");
130
- const ontology = enhanceOntology(simpleOntology("ontology", [simpleInterface("Foo", [fooSpt], ["Parent"]), simpleInterface("Parent", [barSpt], [])]), undefined, new Map(), "");
146
+ const ontology = enhanceOntology({
147
+ sanitized: simpleOntology("ontology", [simpleInterface("Foo", [fooSpt], ["Parent"]), simpleInterface("Parent", [barSpt], [])]),
148
+ importExt: ""
149
+ });
131
150
  const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Foo, ontology, true), {
132
151
  parser: "typescript"
133
152
  });
@@ -153,10 +172,16 @@ describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
153
172
 
154
173
  export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}
155
174
 
175
+ export type OsdkInstance<
176
+ OPTIONS extends never | "$notStrict" | "$rid" = never,
177
+ K extends keyof Foo.Props = keyof Foo.Props,
178
+ > = $Osdk.Instance<Foo, OPTIONS, K>;
179
+
180
+ /** @deprecated use OsdkInstance */
156
181
  export type OsdkObject<
157
182
  OPTIONS extends never | "$notStrict" | "$rid" = never,
158
183
  K extends keyof Foo.Props = keyof Foo.Props,
159
- > = $Osdk<Foo, K | OPTIONS>;
184
+ > = OsdkInstance<OPTIONS, K>;
160
185
  }
161
186
 
162
187
  export interface Foo extends $InterfaceDefinition {
@@ -196,7 +221,10 @@ describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
196
221
  it("allows for SPT reuse if the same", async () => {
197
222
  const fooSpt = simpleSpt("foo");
198
223
  const barSpt = simpleSpt("bar");
199
- const ontology = enhanceOntology(simpleOntology("ontology", [simpleInterface("Foo", [fooSpt, barSpt], ["Parent"]), simpleInterface("Parent", [barSpt], [])]), undefined, new Map(), "");
224
+ const ontology = enhanceOntology({
225
+ sanitized: simpleOntology("ontology", [simpleInterface("Foo", [fooSpt, barSpt], ["Parent"]), simpleInterface("Parent", [barSpt], [])]),
226
+ importExt: ""
227
+ });
200
228
  const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Foo, ontology, true), {
201
229
  parser: "typescript"
202
230
  });
@@ -224,10 +252,16 @@ describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
224
252
 
225
253
  export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}
226
254
 
255
+ export type OsdkInstance<
256
+ OPTIONS extends never | "$notStrict" | "$rid" = never,
257
+ K extends keyof Foo.Props = keyof Foo.Props,
258
+ > = $Osdk.Instance<Foo, OPTIONS, K>;
259
+
260
+ /** @deprecated use OsdkInstance */
227
261
  export type OsdkObject<
228
262
  OPTIONS extends never | "$notStrict" | "$rid" = never,
229
263
  K extends keyof Foo.Props = keyof Foo.Props,
230
- > = $Osdk<Foo, K | OPTIONS>;
264
+ > = OsdkInstance<OPTIONS, K>;
231
265
  }
232
266
 
233
267
  export interface Foo extends $InterfaceDefinition {
@@ -1 +1 @@
1
- {"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js","names":["format","describe","expect","it","enhanceOntology","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst","simpleSpt","apiName","metadataLevel","dataType","type","rid","displayName","description","undefined","simpleInterface","spts","parents","properties","Object","fromEntries","map","spt","extendsInterfaces","links","simpleOntology","interfaces","interfaceTypes","i","sharedPropertyTypes","flatMap","entries","actionTypes","objectTypes","ontology","queryTypes","Map","formattedCode","Bar","parser","printWidth","toMatchInlineSnapshot","fooSpt","barSpt","Foo"],"sources":["UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { format } from \"prettier\";\nimport { describe, expect, it } from \"vitest\";\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst } from \"./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js\";\nfunction simpleSpt(apiName, metadataLevel = 2) {\n return {\n apiName,\n dataType: {\n type: \"integer\",\n },\n rid: `${apiName}Rid`,\n displayName: metadataLevel >= 1 ? `${apiName} property dn` : apiName,\n description: metadataLevel >= 2 ? `${apiName} property desc` : undefined,\n };\n}\nfunction simpleInterface(apiName, spts, parents, metadataLevel = 2) {\n const properties = Object.fromEntries(spts.map(spt => [spt.apiName, spt]));\n return {\n apiName,\n rid: `${apiName}Rid`,\n displayName: metadataLevel >= 1 ? `${apiName} interface dn` : apiName,\n description: metadataLevel >= 2 ? `${apiName} interface desc` : undefined,\n extendsInterfaces: parents,\n links: {},\n properties,\n };\n}\nfunction simpleOntology(apiName, interfaces) {\n const interfaceTypes = Object\n .fromEntries(interfaces.map(i => [i.apiName, i]));\n const sharedPropertyTypes = Object\n .fromEntries(interfaces.flatMap(i => Object.entries(i.properties)));\n return {\n actionTypes: {},\n interfaceTypes,\n objectTypes: {},\n ontology: {\n apiName,\n description: `${apiName} ontology desc`,\n displayName: `${apiName} ontology dn`,\n rid: `${apiName} ontology rid`,\n },\n queryTypes: {},\n sharedPropertyTypes,\n };\n}\ndescribe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {\n it(\"Does not say (inherited) on properties locally defined\", async () => {\n const ontology = enhanceOntology(simpleOntology(\"ontology\", [\n simpleInterface(\"Bar\", [simpleSpt(\"bar\", 0)], [], 0),\n ]), undefined, new Map(), \"\");\n const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Bar, ontology, true), {\n parser: \"typescript\",\n printWidth: 100,\n });\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Bar = {};\n\n export namespace Bar {\n export type PropertyKeys = \"bar\";\n\n export interface Props {\n readonly bar: $PropType[\"integer\"] | undefined;\n }\n export interface StrictProps {\n readonly bar: $PropType[\"integer\"] | undefined;\n }\n\n export interface ObjectSet extends $ObjectSet<Bar, Bar.ObjectSet> {}\n\n export type OsdkObject<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof Bar.Props = keyof Bar.Props,\n > = $Osdk<Bar, K | OPTIONS>;\n }\n\n export interface Bar extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Bar\";\n __DefinitionMetadata?: {\n objectSet: Bar.ObjectSet;\n props: Bar.Props;\n linksType: OsdkObjectLinks$Bar;\n strictProps: Bar.StrictProps;\n apiName: \"Bar\";\n displayName: \"Bar\";\n implements: [];\n links: {};\n properties: {\n /**\n * (no ontology metadata)\n */\n bar: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"BarRid\";\n type: \"interface\";\n };\n }\n\n export const Bar: Bar = {\n type: \"interface\",\n apiName: \"Bar\",\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n it(\"Generates properties for inherited SPTs\", async () => {\n const fooSpt = simpleSpt(\"foo\");\n const barSpt = simpleSpt(\"bar\");\n const ontology = enhanceOntology(simpleOntology(\"ontology\", [\n simpleInterface(\"Foo\", [fooSpt], [\"Parent\"]),\n simpleInterface(\"Parent\", [barSpt], []),\n ]), undefined, new Map(), \"\");\n const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Foo, ontology, true), {\n parser: \"typescript\",\n });\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Foo = {};\n\n export namespace Foo {\n export type PropertyKeys = \"foo\";\n\n export interface Props {\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n export interface StrictProps {\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n\n export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}\n\n export type OsdkObject<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = $Osdk<Foo, K | OPTIONS>;\n }\n\n export interface Foo extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Foo\";\n __DefinitionMetadata?: {\n objectSet: Foo.ObjectSet;\n props: Foo.Props;\n linksType: OsdkObjectLinks$Foo;\n strictProps: Foo.StrictProps;\n apiName: \"Foo\";\n description: \"Foo interface desc\";\n displayName: \"Foo interface dn\";\n implements: [\"Parent\"];\n links: {};\n properties: {\n /**\n * display name: 'foo property dn',\n * description: foo property desc\n */\n foo: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"FooRid\";\n type: \"interface\";\n };\n }\n\n export const Foo: Foo = {\n type: \"interface\",\n apiName: \"Foo\",\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n it(\"allows for SPT reuse if the same\", async () => {\n const fooSpt = simpleSpt(\"foo\");\n const barSpt = simpleSpt(\"bar\");\n const ontology = enhanceOntology(simpleOntology(\"ontology\", [\n simpleInterface(\"Foo\", [fooSpt, barSpt], [\"Parent\"]),\n simpleInterface(\"Parent\", [barSpt], []),\n ]), undefined, new Map(), \"\");\n const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Foo, ontology, true), {\n parser: \"typescript\",\n });\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Foo = {};\n\n export namespace Foo {\n export type PropertyKeys = \"foo\" | \"bar\";\n\n export interface Props {\n readonly bar: $PropType[\"integer\"] | undefined;\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n export interface StrictProps {\n readonly bar: $PropType[\"integer\"] | undefined;\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n\n export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}\n\n export type OsdkObject<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = $Osdk<Foo, K | OPTIONS>;\n }\n\n export interface Foo extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Foo\";\n __DefinitionMetadata?: {\n objectSet: Foo.ObjectSet;\n props: Foo.Props;\n linksType: OsdkObjectLinks$Foo;\n strictProps: Foo.StrictProps;\n apiName: \"Foo\";\n description: \"Foo interface desc\";\n displayName: \"Foo interface dn\";\n implements: [\"Parent\"];\n links: {};\n properties: {\n /**\n * display name: 'bar property dn',\n * description: bar property desc\n */\n bar: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n /**\n * display name: 'foo property dn',\n * description: foo property desc\n */\n foo: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"FooRid\";\n type: \"interface\";\n };\n }\n\n export const Foo: Foo = {\n type: \"interface\",\n apiName: \"Foo\",\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,8CAA8C,QAAQ,mDAAmD;AAClH,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C,QAAQ,CAAC,CAAC,EACpD5B,eAAe,CAAC,QAAQ,EAAE,CAAC4B,MAAM,CAAC,EAAE,EAAE,CAAC,CAC1C,CAAC,EAAE7B,SAAS,EAAE,IAAIsB,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;IAC7B,MAAMC,aAAa,GAAG,MAAMrC,MAAM,CAACK,8CAA8C,CAAC6B,QAAQ,CAACP,cAAc,CAACiB,GAAG,EAAEV,QAAQ,EAAE,IAAI,CAAC,EAAE;MAC5HK,MAAM,EAAE;IACZ,CAAC,CAAC;IACFrC,MAAM,CAACmC,aAAa,CAAC,CAACI,qBAAqB,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACF,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js","names":["format","describe","expect","it","EnhancedInterfaceType","enhanceOntology","ForeignType","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst","simpleSpt","apiName","metadataLevel","dataType","type","rid","displayName","description","undefined","simpleInterface","spts","parents","properties","Object","fromEntries","map","spt","extendsInterfaces","links","simpleOntology","interfaces","interfaceTypes","i","sharedPropertyTypes","flatMap","entries","actionTypes","objectTypes","ontology","queryTypes","sanitized","importExt","Bar","toBe","Error","formattedCode","parser","printWidth","toMatchInlineSnapshot","fooSpt","barSpt","Foo"],"sources":["UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { format } from \"prettier\";\nimport { describe, expect, it } from \"vitest\";\nimport { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst } from \"./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js\";\nfunction simpleSpt(apiName, metadataLevel = 2) {\n return {\n apiName,\n dataType: {\n type: \"integer\",\n },\n rid: `${apiName}Rid`,\n displayName: metadataLevel >= 1 ? `${apiName} property dn` : apiName,\n description: metadataLevel >= 2 ? `${apiName} property desc` : undefined,\n };\n}\nfunction simpleInterface(apiName, spts, parents, metadataLevel = 2) {\n const properties = Object.fromEntries(spts.map(spt => [spt.apiName, spt]));\n return {\n apiName,\n rid: `${apiName}Rid`,\n displayName: metadataLevel >= 1 ? `${apiName} interface dn` : apiName,\n description: metadataLevel >= 2 ? `${apiName} interface desc` : undefined,\n extendsInterfaces: parents,\n links: {},\n properties,\n };\n}\nfunction simpleOntology(apiName, interfaces) {\n const interfaceTypes = Object\n .fromEntries(interfaces.map(i => [i.apiName, i]));\n const sharedPropertyTypes = Object\n .fromEntries(interfaces.flatMap(i => Object.entries(i.properties)));\n return {\n actionTypes: {},\n interfaceTypes,\n objectTypes: {},\n ontology: {\n apiName,\n description: `${apiName} ontology desc`,\n displayName: `${apiName} ontology dn`,\n rid: `${apiName} ontology rid`,\n },\n queryTypes: {},\n sharedPropertyTypes,\n };\n}\ndescribe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {\n it(\"Does not say (inherited) on properties locally defined\", async () => {\n const ontology = enhanceOntology({\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Bar\", [simpleSpt(\"bar\", 0)], [], 0),\n ]),\n importExt: \"\",\n });\n expect(ontology.interfaceTypes.Bar instanceof EnhancedInterfaceType).toBe(true);\n // type guard for below\n if (ontology.interfaceTypes.Bar instanceof ForeignType) {\n throw new Error(\"Expected Bar to be an EnhancedInterfaceType\");\n }\n const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Bar, ontology, true), {\n parser: \"typescript\",\n printWidth: 100,\n });\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Bar = {};\n\n export namespace Bar {\n export type PropertyKeys = \"bar\";\n\n export interface Props {\n readonly bar: $PropType[\"integer\"] | undefined;\n }\n export interface StrictProps {\n readonly bar: $PropType[\"integer\"] | undefined;\n }\n\n export interface ObjectSet extends $ObjectSet<Bar, Bar.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof Bar.Props = keyof Bar.Props,\n > = $Osdk.Instance<Bar, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof Bar.Props = keyof Bar.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Bar extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Bar\";\n __DefinitionMetadata?: {\n objectSet: Bar.ObjectSet;\n props: Bar.Props;\n linksType: OsdkObjectLinks$Bar;\n strictProps: Bar.StrictProps;\n apiName: \"Bar\";\n displayName: \"Bar\";\n implements: [];\n links: {};\n properties: {\n /**\n * (no ontology metadata)\n */\n bar: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"BarRid\";\n type: \"interface\";\n };\n }\n\n export const Bar: Bar = {\n type: \"interface\",\n apiName: \"Bar\",\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n it(\"Generates properties for inherited SPTs\", async () => {\n const fooSpt = simpleSpt(\"foo\");\n const barSpt = simpleSpt(\"bar\");\n const ontology = enhanceOntology({\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Foo\", [fooSpt], [\"Parent\"]),\n simpleInterface(\"Parent\", [barSpt], []),\n ]),\n importExt: \"\",\n });\n const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Foo, ontology, true), {\n parser: \"typescript\",\n });\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Foo = {};\n\n export namespace Foo {\n export type PropertyKeys = \"foo\";\n\n export interface Props {\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n export interface StrictProps {\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n\n export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = $Osdk.Instance<Foo, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Foo extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Foo\";\n __DefinitionMetadata?: {\n objectSet: Foo.ObjectSet;\n props: Foo.Props;\n linksType: OsdkObjectLinks$Foo;\n strictProps: Foo.StrictProps;\n apiName: \"Foo\";\n description: \"Foo interface desc\";\n displayName: \"Foo interface dn\";\n implements: [\"Parent\"];\n links: {};\n properties: {\n /**\n * display name: 'foo property dn',\n * description: foo property desc\n */\n foo: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"FooRid\";\n type: \"interface\";\n };\n }\n\n export const Foo: Foo = {\n type: \"interface\",\n apiName: \"Foo\",\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n it(\"allows for SPT reuse if the same\", async () => {\n const fooSpt = simpleSpt(\"foo\");\n const barSpt = simpleSpt(\"bar\");\n const ontology = enhanceOntology({\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Foo\", [fooSpt, barSpt], [\"Parent\"]),\n simpleInterface(\"Parent\", [barSpt], []),\n ]),\n importExt: \"\",\n });\n const formattedCode = await format(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(ontology.interfaceTypes.Foo, ontology, true), {\n parser: \"typescript\",\n });\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Foo = {};\n\n export namespace Foo {\n export type PropertyKeys = \"foo\" | \"bar\";\n\n export interface Props {\n readonly bar: $PropType[\"integer\"] | undefined;\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n export interface StrictProps {\n readonly bar: $PropType[\"integer\"] | undefined;\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n\n export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = $Osdk.Instance<Foo, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Foo extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Foo\";\n __DefinitionMetadata?: {\n objectSet: Foo.ObjectSet;\n props: Foo.Props;\n linksType: OsdkObjectLinks$Foo;\n strictProps: Foo.StrictProps;\n apiName: \"Foo\";\n description: \"Foo interface desc\";\n displayName: \"Foo interface dn\";\n implements: [\"Parent\"];\n links: {};\n properties: {\n /**\n * display name: 'bar property dn',\n * description: bar property desc\n */\n bar: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n /**\n * display name: 'foo property dn',\n * description: foo property desc\n */\n foo: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"FooRid\";\n type: \"interface\";\n };\n }\n\n export const Foo: Foo = {\n type: \"interface\",\n apiName: \"Foo\",\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,qBAAqB,QAAQ,6CAA6C;AACnF,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,WAAW,QAAQ,mCAAmC;AAC/D,SAASC,8CAA8C,QAAQ,mDAAmD;AAClH,SAASC,SAASA,CAACC,OAAO,EAAEC,aAAa,GAAG,CAAC,EAAE;EAC3C,OAAO;IACHD,OAAO;IACPE,QAAQ,EAAE;MACNC,IAAI,EAAE;IACV,CAAC;IACDC,GAAG,EAAE,GAAGJ,OAAO,KAAK;IACpBK,WAAW,EAAEJ,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AEX,cAAc,CAAC,UAAU,EAAE,CAClCV,eAAe,CAAC,KAAK,EAAE,CAAC8B,MAAM,EAAEC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EACpD/B,eAAe,CAAC,QAAQ,EAAE,CAAC+B,MAAM,CAAC,EAAE,EAAE,CAAC,CAC1C,CAAC;MACFT,SAAS,EAAE;IACf,CAAC,CAAC;IACF,MAAMI,aAAa,GAAG,MAAM3C,MAAM,CAACO,8CAA8C,CAAC6B,QAAQ,CAACP,cAAc,CAACoB,GAAG,EAAEb,QAAQ,EAAE,IAAI,CAAC,EAAE;MAC5HQ,MAAM,EAAE;IACZ,CAAC,CAAC;IACF1C,MAAM,CAACyC,aAAa,CAAC,CAACG,qBAAqB,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACF,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import type { MinimalFs } from "../MinimalFs.js";
2
2
  import type { WireOntologyDefinition } from "../WireOntologyDefinition.js";
3
- export declare function generateClientSdkVersionTwoPointZero(ontology: WireOntologyDefinition, userAgent: string, fs: MinimalFs, outDir: string, packageType?: "module" | "commonjs", ontologyApiNamespace?: string, apiNamespacePackageMap?: Map<string, string>): Promise<void>;
3
+ export declare function generateClientSdkVersionTwoPointZero(ontology: WireOntologyDefinition, userAgent: string, fs: MinimalFs, outDir: string, packageType?: "module" | "commonjs", externalObjects?: Map<string, string>, externalInterfaces?: Map<string, string>, externalSpts?: Map<string, string>): Promise<void>;
4
4
  //# sourceMappingURL=generateClientSdkVersionTwoPointZero.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateClientSdkVersionTwoPointZero.d.ts","sourceRoot":"","sources":["../../../src/v2.0/generateClientSdkVersionTwoPointZero.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAgE3E,wBAAsB,oCAAoC,CACxD,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,SAAS,EACb,MAAM,EAAE,MAAM,EACd,WAAW,GAAE,QAAQ,GAAG,UAAuB,EAC/C,oBAAoB,CAAC,EAAE,MAAM,EAC7B,sBAAsB,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,iBAgDxD"}
1
+ {"version":3,"file":"generateClientSdkVersionTwoPointZero.d.ts","sourceRoot":"","sources":["../../../src/v2.0/generateClientSdkVersionTwoPointZero.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAQ3E,wBAAsB,oCAAoC,CACxD,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,SAAS,EACb,MAAM,EAAE,MAAM,EACd,WAAW,GAAE,QAAQ,GAAG,UAAuB,EAC/C,eAAe,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,EAChD,kBAAkB,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,EACnD,YAAY,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,iBAkC9C"}
@@ -13,107 +13,43 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import path from "node:path";
17
16
  import { enhanceOntology } from "../GenerateContext/enhanceOntology.js";
18
17
  import { sanitizeMetadata } from "../shared/sanitizeMetadata.js";
19
- import { formatTs } from "../util/test/formatTs.js";
20
18
  import { verifyOutDir } from "../util/verifyOutDir.js";
21
19
  import { generateOntologyMetadataFile } from "./generateMetadata.js";
22
20
  import { generatePerActionDataFiles } from "./generatePerActionDataFiles.js";
21
+ import { generatePerInterfaceDataFiles } from "./generatePerInterfaceDataFiles.js";
22
+ import { generatePerObjectDataFiles } from "./generatePerObjectDataFiles.js";
23
23
  import { generatePerQueryDataFilesV2 } from "./generatePerQueryDataFiles.js";
24
- import { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst } from "./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js";
25
- import { wireObjectTypeV2ToSdkObjectConstV2 } from "./wireObjectTypeV2ToSdkObjectConstV2.js";
26
- async function generateRootIndexTsFile({
27
- fs,
28
- outDir,
29
- importExt,
30
- ontologyApiNamespace
31
- }) {
32
- fs.writeFile(path.join(outDir, "index.ts"), await formatTs(`export * from "./ontology/actions${importExt}";
33
- export * as $Actions from "./ontology/actions${importExt}";
34
- export * from "./ontology/interfaces${importExt}";
35
- export * as $Interfaces from "./ontology/interfaces${importExt}";
36
- export * from "./ontology/objects${importExt}";
37
- export * as $Objects from "./ontology/objects${importExt}";
38
- export * from "./ontology/queries${importExt}";
39
- export * as $Queries from "./ontology/queries${importExt}";
40
- ${ontologyApiNamespace == null ? `export { $ontologyRid } from "./OntologyMetadata${importExt}";` : ``}
41
- `));
42
- }
43
- async function generateEachObjectFile(ctx) {
44
- const {
45
- fs,
46
- outDir,
47
- ontology,
48
- importExt
49
- } = ctx;
50
- await fs.mkdir(path.join(outDir, "ontology", "objects"), {
51
- recursive: true
52
- });
53
- for (const obj of Object.values(ontology.objectTypes)) {
54
- const relPath = path.join(".", "ontology", `objects`, `${obj.shortApiName}.ts`);
55
- const outFilePath = path.join(outDir, relPath);
56
- await fs.writeFile(outFilePath, await formatTs(`
57
- import type { PropertyDef as $PropertyDef } from "@osdk/api";
58
- import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
59
- import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
60
- ${wireObjectTypeV2ToSdkObjectConstV2(obj.raw, ctx, relPath)}
61
- `));
62
- }
63
- }
64
- export async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, outDir, packageType = "commonjs", ontologyApiNamespace, apiNamespacePackageMap = new Map()) {
24
+ import { generateRootIndexTsFile } from "./generateRootIndexTsFile.js";
25
+ export async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, outDir, packageType = "commonjs", externalObjects = new Map(), externalInterfaces = new Map(), externalSpts = new Map()) {
65
26
  const importExt = packageType === "module" ? ".js" : "";
27
+ // Structurally, we need to have multiple ontologies read in
28
+ // with one per package.
66
29
  await verifyOutDir(outDir, fs);
67
30
  const sanitizedOntology = sanitizeMetadata(ontology);
68
31
  await fs.mkdir(outDir, {
69
32
  recursive: true
70
33
  });
71
- const enhancedOntology = enhanceOntology(sanitizedOntology, ontologyApiNamespace, apiNamespacePackageMap, importExt);
34
+ const enhancedOntology = enhanceOntology({
35
+ sanitized: sanitizedOntology,
36
+ importExt,
37
+ externalObjects,
38
+ externalInterfaces,
39
+ externalSpts
40
+ });
72
41
  const ctx = {
73
42
  sanitizedOntology,
74
43
  ontology: enhancedOntology,
75
44
  importExt,
76
45
  fs,
77
- outDir,
78
- ontologyApiNamespace,
79
- apiNamespacePackageMap
46
+ outDir
80
47
  };
81
48
  await generateRootIndexTsFile(ctx);
82
49
  await generateOntologyMetadataFile(ctx, userAgent);
83
- await generateEachObjectFile(ctx);
84
- await generateOntologyInterfaces(ctx);
85
- const actionsDir = path.join(outDir, "ontology", "actions");
86
- await fs.mkdir(actionsDir, {
87
- recursive: true
88
- });
50
+ await generatePerObjectDataFiles(ctx);
51
+ await generatePerInterfaceDataFiles(ctx);
89
52
  await generatePerActionDataFiles(ctx);
90
- await fs.writeFile(path.join(outDir, "ontology", "objects.ts"), await formatTs(`
91
- ${Object.values(enhancedOntology.objectTypes).map(objType => `export * from "./objects/${objType.shortApiName}${importExt}";`).join("\n")}
92
- ${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
93
- `));
94
53
  await generatePerQueryDataFilesV2(ctx, true);
95
54
  }
96
- /** @internal */
97
- async function generateOntologyInterfaces({
98
- fs,
99
- outDir,
100
- ontology,
101
- importExt
102
- }) {
103
- const interfacesDir = path.join(outDir, "ontology", "interfaces");
104
- await fs.mkdir(interfacesDir, {
105
- recursive: true
106
- });
107
- for (const obj of Object.values(ontology.interfaceTypes)) {
108
- await fs.writeFile(path.join(interfacesDir, `${obj.shortApiName}.ts`), await formatTs(`
109
- import type { PropertyDef as $PropertyDef } from "@osdk/api";
110
- import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
111
- ${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true)}
112
- `));
113
- }
114
- await fs.writeFile(interfacesDir + ".ts", await formatTs(`
115
- ${Object.values(ontology.interfaceTypes).map(interfaceType => `export * from "./interfaces/${interfaceType.shortApiName}${importExt}";`).join("\n")}
116
- ${Object.keys(ontology.interfaceTypes).length === 0 ? "export {}" : ""}
117
- `));
118
- }
119
55
  //# sourceMappingURL=generateClientSdkVersionTwoPointZero.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateClientSdkVersionTwoPointZero.js","names":["path","enhanceOntology","sanitizeMetadata","formatTs","verifyOutDir","generateOntologyMetadataFile","generatePerActionDataFiles","generatePerQueryDataFilesV2","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst","wireObjectTypeV2ToSdkObjectConstV2","generateRootIndexTsFile","fs","outDir","importExt","ontologyApiNamespace","writeFile","join","generateEachObjectFile","ctx","ontology","mkdir","recursive","obj","Object","values","objectTypes","relPath","shortApiName","outFilePath","raw","generateClientSdkVersionTwoPointZero","userAgent","packageType","apiNamespacePackageMap","Map","sanitizedOntology","enhancedOntology","generateOntologyInterfaces","actionsDir","map","objType","keys","length","interfacesDir","interfaceTypes","interfaceType"],"sources":["generateClientSdkVersionTwoPointZero.js"],"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 */\nimport path from \"node:path\";\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport { sanitizeMetadata } from \"../shared/sanitizeMetadata.js\";\nimport { formatTs } from \"../util/test/formatTs.js\";\nimport { verifyOutDir } from \"../util/verifyOutDir.js\";\nimport { generateOntologyMetadataFile } from \"./generateMetadata.js\";\nimport { generatePerActionDataFiles } from \"./generatePerActionDataFiles.js\";\nimport { generatePerQueryDataFilesV2 } from \"./generatePerQueryDataFiles.js\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst } from \"./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js\";\nimport { wireObjectTypeV2ToSdkObjectConstV2, } from \"./wireObjectTypeV2ToSdkObjectConstV2.js\";\nasync function generateRootIndexTsFile({ fs, outDir, importExt, ontologyApiNamespace }) {\n fs.writeFile(path.join(outDir, \"index.ts\"), await formatTs(`export * from \"./ontology/actions${importExt}\";\n export * as $Actions from \"./ontology/actions${importExt}\";\n export * from \"./ontology/interfaces${importExt}\";\n export * as $Interfaces from \"./ontology/interfaces${importExt}\";\n export * from \"./ontology/objects${importExt}\";\n export * as $Objects from \"./ontology/objects${importExt}\";\n export * from \"./ontology/queries${importExt}\";\n export * as $Queries from \"./ontology/queries${importExt}\";\n ${ontologyApiNamespace == null\n ? `export { $ontologyRid } from \"./OntologyMetadata${importExt}\";`\n : ``}\n `));\n}\nasync function generateEachObjectFile(ctx) {\n const { fs, outDir, ontology, importExt, } = ctx;\n await fs.mkdir(path.join(outDir, \"ontology\", \"objects\"), { recursive: true });\n for (const obj of Object.values(ontology.objectTypes)) {\n const relPath = path.join(\".\", \"ontology\", `objects`, `${obj.shortApiName}.ts`);\n const outFilePath = path.join(outDir, relPath);\n await fs.writeFile(outFilePath, await formatTs(`\n import type { PropertyDef as $PropertyDef } from \"@osdk/api\";\n import { $osdkMetadata } from \"../../OntologyMetadata${importExt}\";\n import type { $ExpectedClientVersion } from \"../../OntologyMetadata${importExt}\";\n ${wireObjectTypeV2ToSdkObjectConstV2(obj.raw, ctx, relPath)}\n `));\n }\n}\nexport async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, outDir, packageType = \"commonjs\", ontologyApiNamespace, apiNamespacePackageMap = new Map()) {\n const importExt = packageType === \"module\" ? \".js\" : \"\";\n await verifyOutDir(outDir, fs);\n const sanitizedOntology = sanitizeMetadata(ontology);\n await fs.mkdir(outDir, { recursive: true });\n const enhancedOntology = enhanceOntology(sanitizedOntology, ontologyApiNamespace, apiNamespacePackageMap, importExt);\n const ctx = {\n sanitizedOntology,\n ontology: enhancedOntology,\n importExt,\n fs,\n outDir,\n ontologyApiNamespace,\n apiNamespacePackageMap,\n };\n await generateRootIndexTsFile(ctx);\n await generateOntologyMetadataFile(ctx, userAgent);\n await generateEachObjectFile(ctx);\n await generateOntologyInterfaces(ctx);\n const actionsDir = path.join(outDir, \"ontology\", \"actions\");\n await fs.mkdir(actionsDir, { recursive: true });\n await generatePerActionDataFiles(ctx);\n await fs.writeFile(path.join(outDir, \"ontology\", \"objects.ts\"), await formatTs(`\n ${Object.values(enhancedOntology.objectTypes).map(objType => `export * from \"./objects/${objType.shortApiName}${importExt}\";`).join(\"\\n\")}\n ${Object.keys(ontology.objectTypes).length === 0 ? \"export {};\" : \"\"}\n `));\n await generatePerQueryDataFilesV2(ctx, true);\n}\n/** @internal */\nasync function generateOntologyInterfaces({ fs, outDir, ontology, importExt }) {\n const interfacesDir = path.join(outDir, \"ontology\", \"interfaces\");\n await fs.mkdir(interfacesDir, {\n recursive: true,\n });\n for (const obj of Object.values(ontology.interfaceTypes)) {\n await fs.writeFile(path.join(interfacesDir, `${obj.shortApiName}.ts`), await formatTs(`\n import type { PropertyDef as $PropertyDef } from \"@osdk/api\";\n import { $osdkMetadata } from \"../../OntologyMetadata${importExt}\";\n ${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true)}\n `));\n }\n await fs.writeFile(interfacesDir + \".ts\", await formatTs(`\n ${Object.values(ontology.interfaceTypes).map(interfaceType => `export * from \"./interfaces/${interfaceType.shortApiName}${importExt}\";`).join(\"\\n\")}\n ${Object.keys(ontology.interfaceTypes).length === 0\n ? \"export {}\"\n : \"\"}\n `));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,WAAW;AAC5B,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,QAAQ,QAAQ,0BAA0B;AACnD,SAASC,YAAY,QAAQ,yBAAyB;AACtD,SAASC,4BAA4B,QAAQ,uBAAuB;AACpE,SAASC,0BAA0B,QAAQ,iCAAiC;AAC5E,SAASC,2BAA2B,QAAQ,gCAAgC;AAC5E,SAASC,8CAA8C,QAAQ,mDAAmD;AAClH,SAASC,kCAAkC,QAAS,yCAAyC;AAC7F,eAAeC,uBAAuBA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC,SAAS;EAAEC;AAAqB,CAAC,EAAE;EACpFH,EAAE,CAACI,SAAS,CAACf,IAAI,CAACgB,IAAI,CAACJ,MAAM,EAAE,UAAU,CAAC,EAAE,MAAMT,QAAQ,CAAC,oCAAoCU,SAAS;AAC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C;AACP","ignoreList":[]}
1
+ {"version":3,"file":"generateClientSdkVersionTwoPointZero.js","names":["enhanceOntology","sanitizeMetadata","verifyOutDir","generateOntologyMetadataFile","generatePerActionDataFiles","generatePerInterfaceDataFiles","generatePerObjectDataFiles","generatePerQueryDataFilesV2","generateRootIndexTsFile","generateClientSdkVersionTwoPointZero","ontology","userAgent","fs","outDir","packageType","externalObjects","Map","externalInterfaces","externalSpts","importExt","sanitizedOntology","mkdir","recursive","enhancedOntology","sanitized","ctx"],"sources":["generateClientSdkVersionTwoPointZero.js"],"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 */\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport { sanitizeMetadata } from \"../shared/sanitizeMetadata.js\";\nimport { verifyOutDir } from \"../util/verifyOutDir.js\";\nimport { generateOntologyMetadataFile } from \"./generateMetadata.js\";\nimport { generatePerActionDataFiles } from \"./generatePerActionDataFiles.js\";\nimport { generatePerInterfaceDataFiles } from \"./generatePerInterfaceDataFiles.js\";\nimport { generatePerObjectDataFiles } from \"./generatePerObjectDataFiles.js\";\nimport { generatePerQueryDataFilesV2 } from \"./generatePerQueryDataFiles.js\";\nimport { generateRootIndexTsFile } from \"./generateRootIndexTsFile.js\";\nexport async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, outDir, packageType = \"commonjs\", externalObjects = new Map(), externalInterfaces = new Map(), externalSpts = new Map()) {\n const importExt = packageType === \"module\" ? \".js\" : \"\";\n // Structurally, we need to have multiple ontologies read in\n // with one per package.\n await verifyOutDir(outDir, fs);\n const sanitizedOntology = sanitizeMetadata(ontology);\n await fs.mkdir(outDir, { recursive: true });\n const enhancedOntology = enhanceOntology({\n sanitized: sanitizedOntology,\n importExt,\n externalObjects,\n externalInterfaces,\n externalSpts,\n });\n const ctx = {\n sanitizedOntology,\n ontology: enhancedOntology,\n importExt,\n fs,\n outDir,\n };\n await generateRootIndexTsFile(ctx);\n await generateOntologyMetadataFile(ctx, userAgent);\n await generatePerObjectDataFiles(ctx);\n await generatePerInterfaceDataFiles(ctx);\n await generatePerActionDataFiles(ctx);\n await generatePerQueryDataFilesV2(ctx, true);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,uCAAuC;AACvE,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,YAAY,QAAQ,yBAAyB;AACtD,SAASC,4BAA4B,QAAQ,uBAAuB;AACpE,SAASC,0BAA0B,QAAQ,iCAAiC;AAC5E,SAASC,6BAA6B,QAAQ,oCAAoC;AAClF,SAASC,0BAA0B,QAAQ,iCAAiC;AAC5E,SAASC,2BAA2B,QAAQ,gCAAgC;AAC5E,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,OAAO,eAAeC,oCAAoCA,CAACC,QAAQ,EAAEC,SAAS,EAAEC,EAAE,EAAEC,MAAM,EAAEC,WAAW,GAAG,UAAU,EAAEC,eAAe,GAAG,IAAIC,GAAG,CAAC,CAAC,EAAEC,kBAAkB,GAAG,IAAID,GAAG,CAAC,CAAC,EAAEE,YAAY,GAAG,IAAIF,GAAG,CAAC,CAAC,EAAE;EACzM,MAAMG,SAAS,GAAGL,WAAW,KAAK,QAAQ,GAAG,KAAK,GAAG,EAAE;EACvD;EACA;EACA,MAAMZ,YAAY,CAACW,MAAM,EAAED,EAAE,CAAC;EAC9B,MAAMQ,iBAAiB,GAAGnB,gBAAgB,CAACS,QAAQ,CAAC;EACpD,MAAME,E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