@osdk/generator 1.5.0 → 1.7.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.
@@ -2,6 +2,7 @@ import * as path15 from 'path';
2
2
  import path15__default, { join } from 'path';
3
3
  import { format } from 'prettier';
4
4
  import organizeImports from 'prettier-plugin-organize-imports';
5
+ import { wireObjectTypeFullMetadataToSdkObjectTypeDefinition, __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from '@osdk/generator-converters';
5
6
 
6
7
  // src/v1.1/generateClientSdkVersionOneDotOne.ts
7
8
 
@@ -780,32 +781,12 @@ function wireActionTypeV2ToSdkActionDefinition(input) {
780
781
  };
781
782
  }
782
783
  function wireActionParameterV2ToSdkParameterDefinition(value) {
783
- switch (value.dataType.type) {
784
- case "string":
785
- case "boolean":
786
- case "object":
787
- case "attachment":
788
- case "date":
789
- case "double":
790
- case "integer":
791
- case "long":
792
- case "objectSet":
793
- case "timestamp":
794
- case "marking":
795
- return {
796
- multiplicity: false,
797
- type: actionPropertyToSdkPropertyDefinition(value.dataType),
798
- nullable: value.required ? false : true,
799
- description: value.description
800
- };
801
- case "array":
802
- return {
803
- multiplicity: true,
804
- type: actionPropertyToSdkPropertyDefinition(value.dataType.subType),
805
- nullable: value.required ? false : true,
806
- description: value.description
807
- };
808
- }
784
+ return {
785
+ multiplicity: value.dataType.type === "array",
786
+ type: actionPropertyToSdkPropertyDefinition(value.dataType.type === "array" ? value.dataType.subType : value.dataType),
787
+ nullable: !value.required,
788
+ description: value.description
789
+ };
809
790
  }
810
791
  function actionPropertyToSdkPropertyDefinition(parameterType) {
811
792
  switch (parameterType.type) {
@@ -860,6 +841,80 @@ function deleteUndefineds(obj) {
860
841
  return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0));
861
842
  }
862
843
 
844
+ // src/util/stringify.ts
845
+ var defaultCustomizer = (value, defaultValueFormatter, key, defaultKeyFormatter) => {
846
+ return [defaultKeyFormatter(key), defaultValueFormatter(value)];
847
+ };
848
+ function stringify(obj, customizer = {}, separator = ",\n") {
849
+ const defaultKeyFormatter = (key) => `${JSON.stringify(key)}`;
850
+ const entries = [];
851
+ const sortedKeys = Object.keys(obj).sort((a, b) => a.localeCompare(b));
852
+ for (const key of sortedKeys) {
853
+ const value = obj[key];
854
+ const res = (customizer[key] ?? customizer["*"] ?? defaultCustomizer)(value, (value2) => JSON.stringify(value2, null, 2), key, defaultKeyFormatter);
855
+ if (res) {
856
+ if (typeof res === "string") {
857
+ entries.push(`${defaultKeyFormatter(key)}: ${res}`);
858
+ } else {
859
+ entries.push(`${res[0]}: ${res[1]}`);
860
+ }
861
+ }
862
+ }
863
+ return entries.join(separator);
864
+ }
865
+
866
+ // src/shared/wireObjectTypeV2ToSdkObjectConst.ts
867
+ function getObjectDefIdentifier(name, v2) {
868
+ return v2 ? name : `${name}Def`;
869
+ }
870
+ function wireObjectTypeV2ToSdkObjectConst(object, importExt, v2 = false) {
871
+ const uniqueLinkTargetTypes = new Set(object.linkTypes.map((a) => a.objectTypeApiName));
872
+ const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object, v2));
873
+ const objectDefIdentifier = getObjectDefIdentifier(object.objectType.apiName, v2);
874
+ function getV1Types() {
875
+ return `
876
+ export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}> {
877
+ ${stringify(definition, {
878
+ links: (_value) => `{
879
+ ${stringify(definition.links, {
880
+ "*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
881
+ })}
882
+ }`
883
+ })}
884
+ }
885
+ `;
886
+ }
887
+ function getV2Types() {
888
+ return `
889
+ export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}> {
890
+ ${stringify(definition, {
891
+ type: () => void 0,
892
+ apiName: () => void 0,
893
+ links: (_value) => `{
894
+ ${stringify(definition.links, {
895
+ "*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
896
+ })}
897
+ }`,
898
+ properties: (_value) => `{
899
+ ${stringify(definition.properties, {
900
+ "*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
901
+ })}
902
+ }`
903
+ })}
904
+ }
905
+
906
+ `;
907
+ }
908
+ const imports = Array.from(uniqueLinkTargetTypes).filter((type) => type !== definition.apiName).map((type) => `import type { ${getObjectDefIdentifier(type, v2)} } from "./${type}${importExt}";`);
909
+ return `${imports.join("\n")}
910
+
911
+ ${v2 ? getV2Types() : getV1Types()}
912
+
913
+ export const ${object.objectType.apiName}: ${objectDefIdentifier} = {
914
+ ${stringify(definition)}
915
+ };`;
916
+ }
917
+
863
918
  // src/util/reservedKeywords.ts
864
919
  var reservedKeywords = /* @__PURE__ */ new Set(["break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", "enum", "export", "extends", "false", "finally", "for", "function", "if", "import", "in", "instanceof", "new", "null", "return", "super", "switch", "this", "throw", "true", "try", "typeof", "var", "void", "while", "with", "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"]);
865
920
  function isReservedKeyword(name) {
@@ -909,7 +964,7 @@ function wirePropertyTypeV2ToTypeScriptType(property) {
909
964
  case "date":
910
965
  return "LocalDate";
911
966
  case "decimal":
912
- return "number";
967
+ return "string";
913
968
  case "double":
914
969
  return "number";
915
970
  case "float":
@@ -919,7 +974,7 @@ function wirePropertyTypeV2ToTypeScriptType(property) {
919
974
  case "geoshape":
920
975
  return "GeoShape";
921
976
  case "long":
922
- return "number";
977
+ return "string";
923
978
  case "short":
924
979
  return "number";
925
980
  case "timestamp":
@@ -942,9 +997,6 @@ function getDescriptionIfPresent(description, includeNewline) {
942
997
  }
943
998
 
944
999
  // src/v1.1/generatePerActionDataFiles.ts
945
- function stringifyWithoutOuterBraces(obj) {
946
- return JSON.stringify(obj, null, 2).replace(/^\{\n/, "").replace(/\n\}$/, "");
947
- }
948
1000
  async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
949
1001
  await fs.mkdir(outDir, {
950
1002
  recursive: true
@@ -962,30 +1014,30 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
962
1014
  const paramsIdentifier = `${action.apiName}$Params`;
963
1015
  function createParamsDef() {
964
1016
  const entries = Object.entries(parameters);
1017
+ entries.sort((a, b) => a[0].localeCompare(b[0]));
965
1018
  if (entries.length === 0) {
966
1019
  return `// Represents the definition of the parameters for the action
967
1020
  export type ${paramsDefIdentifier} = Record<string, never>;`;
968
1021
  }
969
1022
  return `// Represents the definition of the parameters for the action
970
1023
  export type ${paramsDefIdentifier} = {
971
- ${Object.entries(parameters).map(([key, value]) => {
972
- const {
973
- type,
974
- ...remain
975
- } = value;
976
- let q;
977
- if (typeof type === "string") {
978
- q = JSON.stringify(type);
979
- } else if (type.type === "object") {
980
- q = `ObjectActionDataType<"${type.object}", ${type.object}Def>`;
981
- } else if (type.type === "objectSet") {
982
- q = `ObjectSetActionDataType<"${type.objectSet}", ${type.objectSet}Def>`;
983
- }
1024
+ ${entries.map(([key, value]) => {
984
1025
  return `"${key}": {
985
- type: ${q};
986
- ${stringifyWithoutOuterBraces(remain)}
1026
+ ${stringify(value, {
1027
+ description: (value2, d) => value2 ? d(value2) : void 0,
1028
+ // trick to remove undefineds
1029
+ type: (type) => {
1030
+ if (typeof type === "string") {
1031
+ return JSON.stringify(type);
1032
+ } else if (type.type === "object") {
1033
+ return `ObjectActionDataType<"${type.object}", ${getObjectDefIdentifier(type.object, v2)}>`;
1034
+ } else if (type.type === "objectSet") {
1035
+ return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, v2)}>`;
987
1036
  }
988
- `;
1037
+ return void 0;
1038
+ }
1039
+ })}
1040
+ }`;
989
1041
  }).join(";\n")}
990
1042
  }`;
991
1043
  }
@@ -1008,7 +1060,7 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
1008
1060
 
1009
1061
  // Represents the definition of the action
1010
1062
  export interface ${actionDefIdentifier} extends ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}, ${action.apiName}>{
1011
- ${Object.entries(actionDefSansParameters).map(([key, value]) => {
1063
+ ${Object.entries(actionDefSansParameters).sort((a, b) => a[0].localeCompare(b[0])).map(([key, value]) => {
1012
1064
  return `${key}: ${JSON.stringify(value)};`;
1013
1065
  }).join("\n")}
1014
1066
  parameters: ${paramsDefIdentifier}
@@ -1023,8 +1075,8 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
1023
1075
  const referencedObjectDefs = /* @__PURE__ */ new Set();
1024
1076
  for (const p of Object.values(action.parameters)) {
1025
1077
  if (p.dataType.type === "object" || p.dataType.type === "objectSet") {
1026
- referencedObjectDefs.add(p.dataType.objectApiName + "Def");
1027
- referencedObjectDefs.add(p.dataType.objectTypeApiName + "Def");
1078
+ referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.objectApiName, v2));
1079
+ referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.objectTypeApiName, v2));
1028
1080
  }
1029
1081
  }
1030
1082
  const importObjects = referencedObjectDefs.size > 0 ? `import type {${[...referencedObjectDefs].join(",")}} from "../objects${importExt}";` : "";
@@ -1041,6 +1093,7 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
1041
1093
  }));
1042
1094
  await fs.writeFile(path15__default.join(outDir, `index.ts`), await formatTs(`
1043
1095
  ${Object.values(ontology.actionTypes).map((action) => `export {${action.apiName}} from "./${action.apiName}${importExt}";`).join("\n")}
1096
+ ${Object.keys(ontology.actionTypes).length === 0 ? "export {};" : ""}
1044
1097
  `));
1045
1098
  }
1046
1099
  function extractReferencedObjectsFromAction(actionType) {
@@ -1082,157 +1135,6 @@ function extractReferencedObjectsFromActionParameter(actionParameter) {
1082
1135
  return void 0;
1083
1136
  }
1084
1137
  }
1085
-
1086
- // src/shared/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts
1087
- function wirePropertyV2ToSdkPrimaryKeyTypeDefinition(input) {
1088
- switch (input.dataType.type) {
1089
- case "integer":
1090
- case "double":
1091
- case "string":
1092
- case "boolean":
1093
- case "attachment":
1094
- case "byte":
1095
- case "decimal":
1096
- case "float":
1097
- case "geopoint":
1098
- case "geoshape":
1099
- case "long":
1100
- case "short": {
1101
- return input.dataType.type;
1102
- }
1103
- case "date": {
1104
- return "datetime";
1105
- }
1106
- case "timestamp": {
1107
- return "timestamp";
1108
- }
1109
- case "timeseries":
1110
- case "array":
1111
- case "marking":
1112
- throw new Error(`Type not supported for primaryKey: ${input.dataType.type}`);
1113
- default:
1114
- input.dataType;
1115
- throw new Error(`Unknown type encountered for primaryKey: ${input.dataType}`);
1116
- }
1117
- }
1118
-
1119
- // src/shared/wirePropertyV2ToSdkPropertyDefinition.ts
1120
- function wirePropertyV2ToSdkPropertyDefinition(input, isNullable = true) {
1121
- switch (input.dataType.type) {
1122
- case "integer":
1123
- case "string":
1124
- case "byte":
1125
- case "decimal":
1126
- case "double":
1127
- case "float":
1128
- case "long":
1129
- case "short":
1130
- case "boolean":
1131
- case "date":
1132
- case "attachment":
1133
- case "geopoint":
1134
- case "geoshape":
1135
- case "timestamp":
1136
- case "timeseries":
1137
- case "marking":
1138
- return {
1139
- multiplicity: false,
1140
- description: input.description,
1141
- type: objectPropertyTypeToSdkPropertyDefinition(input.dataType),
1142
- nullable: isNullable
1143
- };
1144
- case "array": {
1145
- return {
1146
- multiplicity: true,
1147
- description: input.description,
1148
- type: objectPropertyTypeToSdkPropertyDefinition(input.dataType),
1149
- nullable: true
1150
- };
1151
- }
1152
- default:
1153
- input.dataType;
1154
- throw new Error(`Unexpected data type ${JSON.stringify(input.dataType)}`);
1155
- }
1156
- }
1157
- function objectPropertyTypeToSdkPropertyDefinition(propertyType) {
1158
- switch (propertyType.type) {
1159
- case "integer":
1160
- case "string":
1161
- case "byte":
1162
- case "decimal":
1163
- case "double":
1164
- case "float":
1165
- case "long":
1166
- case "short":
1167
- case "boolean":
1168
- case "attachment":
1169
- case "geopoint":
1170
- case "geoshape":
1171
- case "timestamp":
1172
- case "marking":
1173
- return propertyType.type;
1174
- case "date":
1175
- return "datetime";
1176
- case "array":
1177
- return objectPropertyTypeToSdkPropertyDefinition(propertyType.subType);
1178
- case "timeseries":
1179
- if (propertyType.itemType.type === "string") {
1180
- return "stringTimeseries";
1181
- }
1182
- return "numericTimeseries";
1183
- default:
1184
- throw new Error(`Unexecpected data type ${JSON.stringify(propertyType)}`);
1185
- }
1186
- }
1187
-
1188
- // src/shared/wireObjectTypeV2ToSdkObjectDefinition.ts
1189
- function wireObjectTypeV2ToSdkObjectDefinition(objectTypeWithLink, v2) {
1190
- if (objectTypeWithLink.objectType.properties[objectTypeWithLink.objectType.primaryKey] === void 0) {
1191
- throw new Error(`Primary key ${objectTypeWithLink.objectType.primaryKey} not found in ${objectTypeWithLink.objectType.apiName}`);
1192
- }
1193
- return {
1194
- type: "object",
1195
- apiName: objectTypeWithLink.objectType.apiName,
1196
- description: objectTypeWithLink.objectType.description,
1197
- primaryKeyType: wirePropertyV2ToSdkPrimaryKeyTypeDefinition(objectTypeWithLink.objectType.properties[objectTypeWithLink.objectType.primaryKey]),
1198
- links: Object.fromEntries(objectTypeWithLink.linkTypes.map((linkType) => {
1199
- return [linkType.apiName, {
1200
- multiplicity: linkType.cardinality === "MANY",
1201
- targetType: linkType.objectTypeApiName
1202
- }];
1203
- })),
1204
- properties: Object.fromEntries(Object.entries(objectTypeWithLink.objectType.properties).map(([key, value]) => [key, wirePropertyV2ToSdkPropertyDefinition(value, !(v2 && objectTypeWithLink.objectType.primaryKey === key))]))
1205
- };
1206
- }
1207
-
1208
- // src/shared/wireObjectTypeV2ToSdkObjectConst.ts
1209
- function wireObjectTypeV2ToSdkObjectConst(object, importExt, v2 = false) {
1210
- const uniqueLinkTargetTypes = new Set(object.linkTypes.map((a) => a.objectTypeApiName));
1211
- const definition = wireObjectTypeV2ToSdkObjectDefinition(object, v2);
1212
- const imports = Array.from(uniqueLinkTargetTypes).filter((type) => type !== definition.apiName).map((type) => `import type { ${type}Def } from "./${type}${importExt}";`);
1213
- return `
1214
- ${imports.join("\n")}
1215
- export interface ${object.objectType.apiName}Def extends ObjectTypeDefinition<"${object.objectType.apiName}"> {
1216
- type: "${definition.type}",
1217
- apiName: "${definition.apiName}",
1218
- ${definition.description != null ? `description: ${JSON.stringify(definition.description)},` : ""}
1219
- primaryKeyType: ${JSON.stringify(definition.primaryKeyType)},
1220
- links: {${Object.entries(definition.links).map(([linkApiName, definition2]) => `${linkApiName}: ObjectTypeLinkDefinition<${definition2.targetType}Def, ${definition2.multiplicity}>`).join(",\n")}
1221
- },
1222
- properties: ${JSON.stringify(definition.properties, null, 2)},
1223
- }
1224
-
1225
- export const ${object.objectType.apiName}: ${object.objectType.apiName}Def = {
1226
- type: "${definition.type}",
1227
- apiName: "${definition.apiName}",
1228
- ${definition.description != null ? `description: ${JSON.stringify(definition.description)},` : ""}
1229
- primaryKeyType: ${JSON.stringify(definition.primaryKeyType)},
1230
- links: ${JSON.stringify(definition.links, null, 2)},
1231
- properties: ${JSON.stringify(definition.properties, null, 2)},
1232
- };`;
1233
- }
1234
-
1235
- // src/v1.1/generatePerObjectInterfaceAndDataFiles.ts
1236
1138
  async function generatePerObjectInterfaceAndDataFiles(ontology, fs, outDir, importExt = "") {
1237
1139
  await fs.mkdir(outDir, {
1238
1140
  recursive: true
@@ -1240,7 +1142,7 @@ async function generatePerObjectInterfaceAndDataFiles(ontology, fs, outDir, impo
1240
1142
  await Promise.all(Object.values(ontology.objectTypes).map(async (object) => {
1241
1143
  object.linkTypes;
1242
1144
  await fs.writeFile(path15__default.join(outDir, `${object.objectType.apiName}.ts`), await formatTs(`
1243
- import type { ObjectTypeDefinition, ObjectTypeLinkDefinition } from "@osdk/api";
1145
+ import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
1244
1146
  ${wireObjectTypeV2ToObjectInterfaceStringV1(object, importExt)}
1245
1147
 
1246
1148
  ${wireObjectTypeV2ToSdkObjectConst(object, importExt)}
@@ -1515,8 +1417,9 @@ function handleQueryDataType(dataType, importedObjects, isReturnValue) {
1515
1417
  case "double":
1516
1418
  case "float":
1517
1419
  case "integer":
1518
- case "long":
1519
1420
  return "number";
1421
+ case "long":
1422
+ return isReturnValue ? "string" : "string | number";
1520
1423
  case "date":
1521
1424
  return "LocalDate";
1522
1425
  case "timestamp":
@@ -1638,22 +1541,38 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs, outDir
1638
1541
  await generateIndexFile(fs, outDir, importExt);
1639
1542
  await generateBackCompatDeprecatedExports(fs, outDir, importExt);
1640
1543
  }
1544
+ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false) {
1545
+ const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef, v2));
1546
+ const objectDefIdentifier = getObjectDefIdentifier(interfaceDef.apiName, v2);
1547
+ function getV2Types() {
1548
+ return `
1549
+ export interface ${objectDefIdentifier} extends InterfaceDefinition<"${interfaceDef.apiName}", ${interfaceDef.apiName}> {
1550
+ ${stringify(definition, {
1551
+ type: () => void 0,
1552
+ apiName: () => void 0,
1553
+ links: (_value) => `{
1554
+ ${stringify(definition.links, {
1555
+ "*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
1556
+ })}
1557
+ }`,
1558
+ properties: (_value) => `{
1559
+ ${stringify(definition.properties, {
1560
+ "*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
1561
+ })}
1562
+ }`
1563
+ })}
1564
+ }
1641
1565
 
1642
- // src/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.ts
1643
- function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceType, v2 = false) {
1644
- return `
1645
- export const ${interfaceType.apiName} = ${JSON.stringify(wireInterfaceTypeV2ToSdkObjectDefinition(interfaceType), null, 2)} satisfies InterfaceDefinition<"${interfaceType.apiName}", "">;`;
1646
- }
1647
- function wireInterfaceTypeV2ToSdkObjectDefinition(interfaceType, v2) {
1648
- return {
1649
- type: "interface",
1650
- apiName: interfaceType.apiName,
1651
- description: interfaceType.description,
1652
- properties: Object.fromEntries(Object.entries(interfaceType.properties).map(([key, value]) => {
1653
- return [key, wirePropertyV2ToSdkPropertyDefinition(value, true)];
1654
- })),
1655
- links: {}
1656
- };
1566
+ `;
1567
+ }
1568
+ const imports = [];
1569
+ return `${imports.join("\n")}
1570
+
1571
+ ${v2 ? getV2Types() : ""}
1572
+
1573
+ export const ${definition.apiName}: ${objectDefIdentifier} = {
1574
+ ${stringify(definition)}
1575
+ };`;
1657
1576
  }
1658
1577
  async function generateOntologyMetadataFile(ontology, userAgent, fs, outDir) {
1659
1578
  fs.writeFile(path15__default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
@@ -1669,15 +1588,19 @@ async function generateOntologyMetadataFile(ontology, userAgent, fs, outDir) {
1669
1588
  async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, outDir, packageType = "commonjs") {
1670
1589
  await verifyOutdir(outDir, fs);
1671
1590
  const sanitizedOntology = sanitizeMetadata(ontology);
1672
- const objectNames = Object.keys(sanitizedOntology.objectTypes);
1673
- const actionNames = Object.keys(sanitizedOntology.actionTypes);
1674
- const interfaceNames = Object.keys(sanitizedOntology.interfaceTypes ?? {});
1591
+ const objectNames = Object.keys(sanitizedOntology.objectTypes).sort((a, b) => a.localeCompare(b));
1592
+ const actionNames = Object.keys(sanitizedOntology.actionTypes).sort((a, b) => a.localeCompare(b));
1593
+ Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
1594
+ const interfaceNames = Object.keys(sanitizedOntology.interfaceTypes ?? {}).sort((a, b) => a.localeCompare(b));
1675
1595
  const importExt = packageType === "module" ? ".js" : "";
1676
1596
  await fs.mkdir(outDir, {
1677
1597
  recursive: true
1678
1598
  });
1679
1599
  fs.writeFile(path15__default.join(outDir, "index.ts"), await formatTs(`
1680
1600
  export { Ontology } from "./Ontology${importExt}";
1601
+ export * from "./ontology/actions/index${importExt}";
1602
+ export * from "./ontology/objects${importExt}";
1603
+ export * from "./ontology/interfaces${importExt}";
1681
1604
  `));
1682
1605
  await generateOntologyMetadataFile(sanitizedOntology, userAgent, fs, outDir);
1683
1606
  await fs.writeFile(path15__default.join(outDir, "Ontology.ts"), await formatTs(`
@@ -1721,18 +1644,11 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, out
1721
1644
  for (const name of objectNames) {
1722
1645
  const obj = ontology.objectTypes[name];
1723
1646
  await fs.writeFile(path15__default.join(outDir, "ontology", `objects`, `${name}.ts`), await formatTs(`
1724
-
1725
- import type { ObjectTypeDefinition, ObjectTypeLinkDefinition } from "@osdk/api";
1726
-
1727
- ${wireObjectTypeV2ToSdkObjectConst(obj, importExt, true)}
1647
+ import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
1648
+ import { Osdk } from "@osdk/client";
1728
1649
 
1729
- ${/* TODO: FIXME
1730
- // wireObjectTypeV2ToObjectDefinitionInterfaceString(
1731
- // obj,
1732
- // )
1733
- */
1734
- ""}
1735
- `));
1650
+ ${wireObjectTypeV2ToSdkObjectConst(obj, importExt, true)}
1651
+ `));
1736
1652
  }
1737
1653
  await generateOntologyInterfaces(fs, outDir, interfaceNames, ontology, importExt);
1738
1654
  const actionsDir = path15__default.join(outDir, "ontology", "actions");
@@ -1741,7 +1657,8 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, out
1741
1657
  });
1742
1658
  await generatePerActionDataFiles(sanitizedOntology, fs, actionsDir, importExt, true);
1743
1659
  await fs.writeFile(path15__default.join(outDir, "ontology", "objects.ts"), await formatTs(`
1744
- ${Object.keys(ontology.objectTypes).map((apiName) => `export * from "./objects/${apiName}${importExt}";`).join("\n")}
1660
+ ${Object.keys(ontology.objectTypes).sort((a, b) => a.localeCompare(b)).map((apiName) => `export * from "./objects/${apiName}${importExt}";`).join("\n")}
1661
+ ${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
1745
1662
  `));
1746
1663
  }
1747
1664
  function stringUnionFrom2(values) {
@@ -1760,13 +1677,14 @@ async function generateOntologyInterfaces(fs, outDir, interfaceNames, ontology,
1760
1677
  const obj = ontology.interfaceTypes[name];
1761
1678
  await fs.writeFile(path15__default.join(interfacesDir, `${name}.ts`), await formatTs(`
1762
1679
 
1763
- import type { InterfaceDefinition } from "@osdk/api";
1680
+ import type { InterfaceDefinition, PropertyDef } from "@osdk/api";
1764
1681
 
1765
1682
  ${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, true)}
1766
1683
  `));
1767
1684
  }
1768
1685
  await fs.writeFile(interfacesDir + ".ts", await formatTs(`
1769
1686
  ${Object.keys(ontology.interfaceTypes ?? {}).map((apiName) => `export * from "./interfaces/${apiName}${importExt}";`).join("\n")}
1687
+ ${Object.keys(ontology.interfaceTypes ?? {}).length === 0 ? "export {}" : ""}
1770
1688
  `));
1771
1689
  }
1772
1690