@osdk/generator 1.4.0 → 1.6.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.
- package/build/js/index.cjs +105 -212
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +104 -211
- package/build/js/index.mjs.map +1 -1
- package/build/types/shared/index.d.ts +0 -2
- package/build/types/shared/wireObjectTypeV2ToSdkObjectConst.d.ts +1 -0
- package/build/types/util/stringify.d.ts +19 -0
- package/changelog/1.6.0/pr-67.v2.yml +5 -0
- package/changelog/1.6.0/pr-83.v2.yml +5 -0
- package/changelog/1.6.0/pr-88.v2.yml +5 -0
- package/changelog/1.6.0/pr-89.v2.yml +5 -0
- package/package.json +4 -3
- package/build/types/shared/wireObjectTypeV2ToSdkObjectDefinition.d.ts +0 -3
- package/build/types/shared/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.d.ts +0 -3
- package/build/types/shared/wirePropertyV2ToSdkPropertyDefinition.d.ts +0 -3
- package/build/types/v2.0/wireObjectTypeV2ToObjectDefinitionInterfaceString.d.ts +0 -2
package/build/js/index.mjs
CHANGED
|
@@ -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, wirePropertyV2ToSdkPropertyDefinition } 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
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
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,78 @@ 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
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
852
|
+
const res = (customizer[key] ?? customizer["*"] ?? defaultCustomizer)(value, (value2) => JSON.stringify(value2, null, 2), key, defaultKeyFormatter);
|
|
853
|
+
if (res) {
|
|
854
|
+
if (typeof res === "string") {
|
|
855
|
+
entries.push(`${defaultKeyFormatter(key)}: ${res}`);
|
|
856
|
+
} else {
|
|
857
|
+
entries.push(`${res[0]}: ${res[1]}`);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return entries.join(separator);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// src/shared/wireObjectTypeV2ToSdkObjectConst.ts
|
|
865
|
+
function getObjectDefIdentifier(name, v2) {
|
|
866
|
+
return v2 ? name : `${name}Def`;
|
|
867
|
+
}
|
|
868
|
+
function wireObjectTypeV2ToSdkObjectConst(object, importExt, v2 = false) {
|
|
869
|
+
const uniqueLinkTargetTypes = new Set(object.linkTypes.map((a) => a.objectTypeApiName));
|
|
870
|
+
const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object, v2));
|
|
871
|
+
const objectDefIdentifier = getObjectDefIdentifier(object.objectType.apiName, v2);
|
|
872
|
+
function getV1Types() {
|
|
873
|
+
return `
|
|
874
|
+
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}> {
|
|
875
|
+
${stringify(definition, {
|
|
876
|
+
links: (_value) => `{
|
|
877
|
+
${stringify(definition.links, {
|
|
878
|
+
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
879
|
+
})}
|
|
880
|
+
}`
|
|
881
|
+
})}
|
|
882
|
+
}
|
|
883
|
+
`;
|
|
884
|
+
}
|
|
885
|
+
function getV2Types() {
|
|
886
|
+
return `
|
|
887
|
+
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}> {
|
|
888
|
+
${stringify(definition, {
|
|
889
|
+
type: () => void 0,
|
|
890
|
+
apiName: () => void 0,
|
|
891
|
+
links: (_value) => `{
|
|
892
|
+
${stringify(definition.links, {
|
|
893
|
+
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
894
|
+
})}
|
|
895
|
+
}`,
|
|
896
|
+
properties: (_value) => `{
|
|
897
|
+
${stringify(definition.properties, {
|
|
898
|
+
"*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
|
|
899
|
+
})}
|
|
900
|
+
}`
|
|
901
|
+
})}
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
`;
|
|
905
|
+
}
|
|
906
|
+
const imports = Array.from(uniqueLinkTargetTypes).filter((type) => type !== definition.apiName).map((type) => `import type { ${getObjectDefIdentifier(type, v2)} } from "./${type}${importExt}";`);
|
|
907
|
+
return `${imports.join("\n")}
|
|
908
|
+
|
|
909
|
+
${v2 ? getV2Types() : getV1Types()}
|
|
910
|
+
|
|
911
|
+
export const ${object.objectType.apiName}: ${objectDefIdentifier} = {
|
|
912
|
+
${stringify(definition)}
|
|
913
|
+
};`;
|
|
914
|
+
}
|
|
915
|
+
|
|
863
916
|
// src/util/reservedKeywords.ts
|
|
864
917
|
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
918
|
function isReservedKeyword(name) {
|
|
@@ -942,9 +995,6 @@ function getDescriptionIfPresent(description, includeNewline) {
|
|
|
942
995
|
}
|
|
943
996
|
|
|
944
997
|
// src/v1.1/generatePerActionDataFiles.ts
|
|
945
|
-
function stringifyWithoutOuterBraces(obj) {
|
|
946
|
-
return JSON.stringify(obj, null, 2).replace(/^\{\n/, "").replace(/\n\}$/, "");
|
|
947
|
-
}
|
|
948
998
|
async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
|
|
949
999
|
await fs.mkdir(outDir, {
|
|
950
1000
|
recursive: true
|
|
@@ -969,23 +1019,22 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
|
|
|
969
1019
|
return `// Represents the definition of the parameters for the action
|
|
970
1020
|
export type ${paramsDefIdentifier} = {
|
|
971
1021
|
${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
|
-
}
|
|
984
1022
|
return `"${key}": {
|
|
985
|
-
|
|
986
|
-
|
|
1023
|
+
${stringify(value, {
|
|
1024
|
+
description: (value2, d) => value2 ? d(value2) : void 0,
|
|
1025
|
+
// trick to remove undefineds
|
|
1026
|
+
type: (type) => {
|
|
1027
|
+
if (typeof type === "string") {
|
|
1028
|
+
return JSON.stringify(type);
|
|
1029
|
+
} else if (type.type === "object") {
|
|
1030
|
+
return `ObjectActionDataType<"${type.object}", ${getObjectDefIdentifier(type.object, v2)}>`;
|
|
1031
|
+
} else if (type.type === "objectSet") {
|
|
1032
|
+
return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, v2)}>`;
|
|
987
1033
|
}
|
|
988
|
-
|
|
1034
|
+
return void 0;
|
|
1035
|
+
}
|
|
1036
|
+
})}
|
|
1037
|
+
}`;
|
|
989
1038
|
}).join(";\n")}
|
|
990
1039
|
}`;
|
|
991
1040
|
}
|
|
@@ -1023,8 +1072,8 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
|
|
|
1023
1072
|
const referencedObjectDefs = /* @__PURE__ */ new Set();
|
|
1024
1073
|
for (const p of Object.values(action.parameters)) {
|
|
1025
1074
|
if (p.dataType.type === "object" || p.dataType.type === "objectSet") {
|
|
1026
|
-
referencedObjectDefs.add(p.dataType.objectApiName
|
|
1027
|
-
referencedObjectDefs.add(p.dataType.objectTypeApiName
|
|
1075
|
+
referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.objectApiName, v2));
|
|
1076
|
+
referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.objectTypeApiName, v2));
|
|
1028
1077
|
}
|
|
1029
1078
|
}
|
|
1030
1079
|
const importObjects = referencedObjectDefs.size > 0 ? `import type {${[...referencedObjectDefs].join(",")}} from "../objects${importExt}";` : "";
|
|
@@ -1082,157 +1131,6 @@ function extractReferencedObjectsFromActionParameter(actionParameter) {
|
|
|
1082
1131
|
return void 0;
|
|
1083
1132
|
}
|
|
1084
1133
|
}
|
|
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 ${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
1134
|
async function generatePerObjectInterfaceAndDataFiles(ontology, fs, outDir, importExt = "") {
|
|
1237
1135
|
await fs.mkdir(outDir, {
|
|
1238
1136
|
recursive: true
|
|
@@ -1240,7 +1138,7 @@ async function generatePerObjectInterfaceAndDataFiles(ontology, fs, outDir, impo
|
|
|
1240
1138
|
await Promise.all(Object.values(ontology.objectTypes).map(async (object) => {
|
|
1241
1139
|
object.linkTypes;
|
|
1242
1140
|
await fs.writeFile(path15__default.join(outDir, `${object.objectType.apiName}.ts`), await formatTs(`
|
|
1243
|
-
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition } from "@osdk/api";
|
|
1141
|
+
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
|
|
1244
1142
|
${wireObjectTypeV2ToObjectInterfaceStringV1(object, importExt)}
|
|
1245
1143
|
|
|
1246
1144
|
${wireObjectTypeV2ToSdkObjectConst(object, importExt)}
|
|
@@ -1638,8 +1536,6 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs, outDir
|
|
|
1638
1536
|
await generateIndexFile(fs, outDir, importExt);
|
|
1639
1537
|
await generateBackCompatDeprecatedExports(fs, outDir, importExt);
|
|
1640
1538
|
}
|
|
1641
|
-
|
|
1642
|
-
// src/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.ts
|
|
1643
1539
|
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceType, v2 = false) {
|
|
1644
1540
|
return `
|
|
1645
1541
|
export const ${interfaceType.apiName} = ${JSON.stringify(wireInterfaceTypeV2ToSdkObjectDefinition(interfaceType), null, 2)} satisfies InterfaceDefinition<"${interfaceType.apiName}", "">;`;
|
|
@@ -1678,6 +1574,9 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, out
|
|
|
1678
1574
|
});
|
|
1679
1575
|
fs.writeFile(path15__default.join(outDir, "index.ts"), await formatTs(`
|
|
1680
1576
|
export { Ontology } from "./Ontology${importExt}";
|
|
1577
|
+
export * from "./ontology/actions/index${importExt}";
|
|
1578
|
+
export * from "./ontology/objects${importExt}";
|
|
1579
|
+
export * from "./ontology/interfaces${importExt}";
|
|
1681
1580
|
`));
|
|
1682
1581
|
await generateOntologyMetadataFile(sanitizedOntology, userAgent, fs, outDir);
|
|
1683
1582
|
await fs.writeFile(path15__default.join(outDir, "Ontology.ts"), await formatTs(`
|
|
@@ -1721,18 +1620,11 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, out
|
|
|
1721
1620
|
for (const name of objectNames) {
|
|
1722
1621
|
const obj = ontology.objectTypes[name];
|
|
1723
1622
|
await fs.writeFile(path15__default.join(outDir, "ontology", `objects`, `${name}.ts`), await formatTs(`
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
${wireObjectTypeV2ToSdkObjectConst(obj, importExt, true)}
|
|
1623
|
+
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
|
|
1624
|
+
import { Osdk } from "@osdk/client";
|
|
1728
1625
|
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
// obj,
|
|
1732
|
-
// )
|
|
1733
|
-
*/
|
|
1734
|
-
""}
|
|
1735
|
-
`));
|
|
1626
|
+
${wireObjectTypeV2ToSdkObjectConst(obj, importExt, true)}
|
|
1627
|
+
`));
|
|
1736
1628
|
}
|
|
1737
1629
|
await generateOntologyInterfaces(fs, outDir, interfaceNames, ontology, importExt);
|
|
1738
1630
|
const actionsDir = path15__default.join(outDir, "ontology", "actions");
|
|
@@ -1767,6 +1659,7 @@ async function generateOntologyInterfaces(fs, outDir, interfaceNames, ontology,
|
|
|
1767
1659
|
}
|
|
1768
1660
|
await fs.writeFile(interfacesDir + ".ts", await formatTs(`
|
|
1769
1661
|
${Object.keys(ontology.interfaceTypes ?? {}).map((apiName) => `export * from "./interfaces/${apiName}${importExt}";`).join("\n")}
|
|
1662
|
+
${Object.keys(ontology.interfaceTypes ?? {}).length === 0 ? "export {}" : ""}
|
|
1770
1663
|
`));
|
|
1771
1664
|
}
|
|
1772
1665
|
|