@osdk/generator 1.5.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 +3 -2
- 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.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var path15 = require('path');
|
|
4
4
|
var prettier = require('prettier');
|
|
5
5
|
var organizeImports = require('prettier-plugin-organize-imports');
|
|
6
|
+
var generatorConverters = require('@osdk/generator-converters');
|
|
6
7
|
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -804,32 +805,12 @@ function wireActionTypeV2ToSdkActionDefinition(input) {
|
|
|
804
805
|
};
|
|
805
806
|
}
|
|
806
807
|
function wireActionParameterV2ToSdkParameterDefinition(value) {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
case "double":
|
|
814
|
-
case "integer":
|
|
815
|
-
case "long":
|
|
816
|
-
case "objectSet":
|
|
817
|
-
case "timestamp":
|
|
818
|
-
case "marking":
|
|
819
|
-
return {
|
|
820
|
-
multiplicity: false,
|
|
821
|
-
type: actionPropertyToSdkPropertyDefinition(value.dataType),
|
|
822
|
-
nullable: value.required ? false : true,
|
|
823
|
-
description: value.description
|
|
824
|
-
};
|
|
825
|
-
case "array":
|
|
826
|
-
return {
|
|
827
|
-
multiplicity: true,
|
|
828
|
-
type: actionPropertyToSdkPropertyDefinition(value.dataType.subType),
|
|
829
|
-
nullable: value.required ? false : true,
|
|
830
|
-
description: value.description
|
|
831
|
-
};
|
|
832
|
-
}
|
|
808
|
+
return {
|
|
809
|
+
multiplicity: value.dataType.type === "array",
|
|
810
|
+
type: actionPropertyToSdkPropertyDefinition(value.dataType.type === "array" ? value.dataType.subType : value.dataType),
|
|
811
|
+
nullable: !value.required,
|
|
812
|
+
description: value.description
|
|
813
|
+
};
|
|
833
814
|
}
|
|
834
815
|
function actionPropertyToSdkPropertyDefinition(parameterType) {
|
|
835
816
|
switch (parameterType.type) {
|
|
@@ -884,6 +865,78 @@ function deleteUndefineds(obj) {
|
|
|
884
865
|
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0));
|
|
885
866
|
}
|
|
886
867
|
|
|
868
|
+
// src/util/stringify.ts
|
|
869
|
+
var defaultCustomizer = (value, defaultValueFormatter, key, defaultKeyFormatter) => {
|
|
870
|
+
return [defaultKeyFormatter(key), defaultValueFormatter(value)];
|
|
871
|
+
};
|
|
872
|
+
function stringify(obj, customizer = {}, separator = ",\n") {
|
|
873
|
+
const defaultKeyFormatter = (key) => `${JSON.stringify(key)}`;
|
|
874
|
+
const entries = [];
|
|
875
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
876
|
+
const res = (customizer[key] ?? customizer["*"] ?? defaultCustomizer)(value, (value2) => JSON.stringify(value2, null, 2), key, defaultKeyFormatter);
|
|
877
|
+
if (res) {
|
|
878
|
+
if (typeof res === "string") {
|
|
879
|
+
entries.push(`${defaultKeyFormatter(key)}: ${res}`);
|
|
880
|
+
} else {
|
|
881
|
+
entries.push(`${res[0]}: ${res[1]}`);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return entries.join(separator);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// src/shared/wireObjectTypeV2ToSdkObjectConst.ts
|
|
889
|
+
function getObjectDefIdentifier(name, v2) {
|
|
890
|
+
return v2 ? name : `${name}Def`;
|
|
891
|
+
}
|
|
892
|
+
function wireObjectTypeV2ToSdkObjectConst(object, importExt, v2 = false) {
|
|
893
|
+
const uniqueLinkTargetTypes = new Set(object.linkTypes.map((a) => a.objectTypeApiName));
|
|
894
|
+
const definition = deleteUndefineds(generatorConverters.wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object, v2));
|
|
895
|
+
const objectDefIdentifier = getObjectDefIdentifier(object.objectType.apiName, v2);
|
|
896
|
+
function getV1Types() {
|
|
897
|
+
return `
|
|
898
|
+
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}> {
|
|
899
|
+
${stringify(definition, {
|
|
900
|
+
links: (_value) => `{
|
|
901
|
+
${stringify(definition.links, {
|
|
902
|
+
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
903
|
+
})}
|
|
904
|
+
}`
|
|
905
|
+
})}
|
|
906
|
+
}
|
|
907
|
+
`;
|
|
908
|
+
}
|
|
909
|
+
function getV2Types() {
|
|
910
|
+
return `
|
|
911
|
+
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}> {
|
|
912
|
+
${stringify(definition, {
|
|
913
|
+
type: () => void 0,
|
|
914
|
+
apiName: () => void 0,
|
|
915
|
+
links: (_value) => `{
|
|
916
|
+
${stringify(definition.links, {
|
|
917
|
+
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
918
|
+
})}
|
|
919
|
+
}`,
|
|
920
|
+
properties: (_value) => `{
|
|
921
|
+
${stringify(definition.properties, {
|
|
922
|
+
"*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
|
|
923
|
+
})}
|
|
924
|
+
}`
|
|
925
|
+
})}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
`;
|
|
929
|
+
}
|
|
930
|
+
const imports = Array.from(uniqueLinkTargetTypes).filter((type) => type !== definition.apiName).map((type) => `import type { ${getObjectDefIdentifier(type, v2)} } from "./${type}${importExt}";`);
|
|
931
|
+
return `${imports.join("\n")}
|
|
932
|
+
|
|
933
|
+
${v2 ? getV2Types() : getV1Types()}
|
|
934
|
+
|
|
935
|
+
export const ${object.objectType.apiName}: ${objectDefIdentifier} = {
|
|
936
|
+
${stringify(definition)}
|
|
937
|
+
};`;
|
|
938
|
+
}
|
|
939
|
+
|
|
887
940
|
// src/util/reservedKeywords.ts
|
|
888
941
|
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"]);
|
|
889
942
|
function isReservedKeyword(name) {
|
|
@@ -966,9 +1019,6 @@ function getDescriptionIfPresent(description, includeNewline) {
|
|
|
966
1019
|
}
|
|
967
1020
|
|
|
968
1021
|
// src/v1.1/generatePerActionDataFiles.ts
|
|
969
|
-
function stringifyWithoutOuterBraces(obj) {
|
|
970
|
-
return JSON.stringify(obj, null, 2).replace(/^\{\n/, "").replace(/\n\}$/, "");
|
|
971
|
-
}
|
|
972
1022
|
async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
|
|
973
1023
|
await fs.mkdir(outDir, {
|
|
974
1024
|
recursive: true
|
|
@@ -993,23 +1043,22 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
|
|
|
993
1043
|
return `// Represents the definition of the parameters for the action
|
|
994
1044
|
export type ${paramsDefIdentifier} = {
|
|
995
1045
|
${Object.entries(parameters).map(([key, value]) => {
|
|
996
|
-
const {
|
|
997
|
-
type,
|
|
998
|
-
...remain
|
|
999
|
-
} = value;
|
|
1000
|
-
let q;
|
|
1001
|
-
if (typeof type === "string") {
|
|
1002
|
-
q = JSON.stringify(type);
|
|
1003
|
-
} else if (type.type === "object") {
|
|
1004
|
-
q = `ObjectActionDataType<"${type.object}", ${type.object}Def>`;
|
|
1005
|
-
} else if (type.type === "objectSet") {
|
|
1006
|
-
q = `ObjectSetActionDataType<"${type.objectSet}", ${type.objectSet}Def>`;
|
|
1007
|
-
}
|
|
1008
1046
|
return `"${key}": {
|
|
1009
|
-
|
|
1010
|
-
|
|
1047
|
+
${stringify(value, {
|
|
1048
|
+
description: (value2, d) => value2 ? d(value2) : void 0,
|
|
1049
|
+
// trick to remove undefineds
|
|
1050
|
+
type: (type) => {
|
|
1051
|
+
if (typeof type === "string") {
|
|
1052
|
+
return JSON.stringify(type);
|
|
1053
|
+
} else if (type.type === "object") {
|
|
1054
|
+
return `ObjectActionDataType<"${type.object}", ${getObjectDefIdentifier(type.object, v2)}>`;
|
|
1055
|
+
} else if (type.type === "objectSet") {
|
|
1056
|
+
return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, v2)}>`;
|
|
1011
1057
|
}
|
|
1012
|
-
|
|
1058
|
+
return void 0;
|
|
1059
|
+
}
|
|
1060
|
+
})}
|
|
1061
|
+
}`;
|
|
1013
1062
|
}).join(";\n")}
|
|
1014
1063
|
}`;
|
|
1015
1064
|
}
|
|
@@ -1047,8 +1096,8 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
|
|
|
1047
1096
|
const referencedObjectDefs = /* @__PURE__ */ new Set();
|
|
1048
1097
|
for (const p of Object.values(action.parameters)) {
|
|
1049
1098
|
if (p.dataType.type === "object" || p.dataType.type === "objectSet") {
|
|
1050
|
-
referencedObjectDefs.add(p.dataType.objectApiName
|
|
1051
|
-
referencedObjectDefs.add(p.dataType.objectTypeApiName
|
|
1099
|
+
referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.objectApiName, v2));
|
|
1100
|
+
referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.objectTypeApiName, v2));
|
|
1052
1101
|
}
|
|
1053
1102
|
}
|
|
1054
1103
|
const importObjects = referencedObjectDefs.size > 0 ? `import type {${[...referencedObjectDefs].join(",")}} from "../objects${importExt}";` : "";
|
|
@@ -1106,157 +1155,6 @@ function extractReferencedObjectsFromActionParameter(actionParameter) {
|
|
|
1106
1155
|
return void 0;
|
|
1107
1156
|
}
|
|
1108
1157
|
}
|
|
1109
|
-
|
|
1110
|
-
// src/shared/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts
|
|
1111
|
-
function wirePropertyV2ToSdkPrimaryKeyTypeDefinition(input) {
|
|
1112
|
-
switch (input.dataType.type) {
|
|
1113
|
-
case "integer":
|
|
1114
|
-
case "double":
|
|
1115
|
-
case "string":
|
|
1116
|
-
case "boolean":
|
|
1117
|
-
case "attachment":
|
|
1118
|
-
case "byte":
|
|
1119
|
-
case "decimal":
|
|
1120
|
-
case "float":
|
|
1121
|
-
case "geopoint":
|
|
1122
|
-
case "geoshape":
|
|
1123
|
-
case "long":
|
|
1124
|
-
case "short": {
|
|
1125
|
-
return input.dataType.type;
|
|
1126
|
-
}
|
|
1127
|
-
case "date": {
|
|
1128
|
-
return "datetime";
|
|
1129
|
-
}
|
|
1130
|
-
case "timestamp": {
|
|
1131
|
-
return "timestamp";
|
|
1132
|
-
}
|
|
1133
|
-
case "timeseries":
|
|
1134
|
-
case "array":
|
|
1135
|
-
case "marking":
|
|
1136
|
-
throw new Error(`Type not supported for primaryKey: ${input.dataType.type}`);
|
|
1137
|
-
default:
|
|
1138
|
-
input.dataType;
|
|
1139
|
-
throw new Error(`Unknown type encountered for primaryKey: ${input.dataType}`);
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
// src/shared/wirePropertyV2ToSdkPropertyDefinition.ts
|
|
1144
|
-
function wirePropertyV2ToSdkPropertyDefinition(input, isNullable = true) {
|
|
1145
|
-
switch (input.dataType.type) {
|
|
1146
|
-
case "integer":
|
|
1147
|
-
case "string":
|
|
1148
|
-
case "byte":
|
|
1149
|
-
case "decimal":
|
|
1150
|
-
case "double":
|
|
1151
|
-
case "float":
|
|
1152
|
-
case "long":
|
|
1153
|
-
case "short":
|
|
1154
|
-
case "boolean":
|
|
1155
|
-
case "date":
|
|
1156
|
-
case "attachment":
|
|
1157
|
-
case "geopoint":
|
|
1158
|
-
case "geoshape":
|
|
1159
|
-
case "timestamp":
|
|
1160
|
-
case "timeseries":
|
|
1161
|
-
case "marking":
|
|
1162
|
-
return {
|
|
1163
|
-
multiplicity: false,
|
|
1164
|
-
description: input.description,
|
|
1165
|
-
type: objectPropertyTypeToSdkPropertyDefinition(input.dataType),
|
|
1166
|
-
nullable: isNullable
|
|
1167
|
-
};
|
|
1168
|
-
case "array": {
|
|
1169
|
-
return {
|
|
1170
|
-
multiplicity: true,
|
|
1171
|
-
description: input.description,
|
|
1172
|
-
type: objectPropertyTypeToSdkPropertyDefinition(input.dataType),
|
|
1173
|
-
nullable: true
|
|
1174
|
-
};
|
|
1175
|
-
}
|
|
1176
|
-
default:
|
|
1177
|
-
input.dataType;
|
|
1178
|
-
throw new Error(`Unexpected data type ${JSON.stringify(input.dataType)}`);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
function objectPropertyTypeToSdkPropertyDefinition(propertyType) {
|
|
1182
|
-
switch (propertyType.type) {
|
|
1183
|
-
case "integer":
|
|
1184
|
-
case "string":
|
|
1185
|
-
case "byte":
|
|
1186
|
-
case "decimal":
|
|
1187
|
-
case "double":
|
|
1188
|
-
case "float":
|
|
1189
|
-
case "long":
|
|
1190
|
-
case "short":
|
|
1191
|
-
case "boolean":
|
|
1192
|
-
case "attachment":
|
|
1193
|
-
case "geopoint":
|
|
1194
|
-
case "geoshape":
|
|
1195
|
-
case "timestamp":
|
|
1196
|
-
case "marking":
|
|
1197
|
-
return propertyType.type;
|
|
1198
|
-
case "date":
|
|
1199
|
-
return "datetime";
|
|
1200
|
-
case "array":
|
|
1201
|
-
return objectPropertyTypeToSdkPropertyDefinition(propertyType.subType);
|
|
1202
|
-
case "timeseries":
|
|
1203
|
-
if (propertyType.itemType.type === "string") {
|
|
1204
|
-
return "stringTimeseries";
|
|
1205
|
-
}
|
|
1206
|
-
return "numericTimeseries";
|
|
1207
|
-
default:
|
|
1208
|
-
throw new Error(`Unexecpected data type ${JSON.stringify(propertyType)}`);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
// src/shared/wireObjectTypeV2ToSdkObjectDefinition.ts
|
|
1213
|
-
function wireObjectTypeV2ToSdkObjectDefinition(objectTypeWithLink, v2) {
|
|
1214
|
-
if (objectTypeWithLink.objectType.properties[objectTypeWithLink.objectType.primaryKey] === void 0) {
|
|
1215
|
-
throw new Error(`Primary key ${objectTypeWithLink.objectType.primaryKey} not found in ${objectTypeWithLink.objectType.apiName}`);
|
|
1216
|
-
}
|
|
1217
|
-
return {
|
|
1218
|
-
type: "object",
|
|
1219
|
-
apiName: objectTypeWithLink.objectType.apiName,
|
|
1220
|
-
description: objectTypeWithLink.objectType.description,
|
|
1221
|
-
primaryKeyType: wirePropertyV2ToSdkPrimaryKeyTypeDefinition(objectTypeWithLink.objectType.properties[objectTypeWithLink.objectType.primaryKey]),
|
|
1222
|
-
links: Object.fromEntries(objectTypeWithLink.linkTypes.map((linkType) => {
|
|
1223
|
-
return [linkType.apiName, {
|
|
1224
|
-
multiplicity: linkType.cardinality === "MANY",
|
|
1225
|
-
targetType: linkType.objectTypeApiName
|
|
1226
|
-
}];
|
|
1227
|
-
})),
|
|
1228
|
-
properties: Object.fromEntries(Object.entries(objectTypeWithLink.objectType.properties).map(([key, value]) => [key, wirePropertyV2ToSdkPropertyDefinition(value, !(v2 && objectTypeWithLink.objectType.primaryKey === key))]))
|
|
1229
|
-
};
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
// src/shared/wireObjectTypeV2ToSdkObjectConst.ts
|
|
1233
|
-
function wireObjectTypeV2ToSdkObjectConst(object, importExt, v2 = false) {
|
|
1234
|
-
const uniqueLinkTargetTypes = new Set(object.linkTypes.map((a) => a.objectTypeApiName));
|
|
1235
|
-
const definition = wireObjectTypeV2ToSdkObjectDefinition(object, v2);
|
|
1236
|
-
const imports = Array.from(uniqueLinkTargetTypes).filter((type) => type !== definition.apiName).map((type) => `import type { ${type}Def } from "./${type}${importExt}";`);
|
|
1237
|
-
return `
|
|
1238
|
-
${imports.join("\n")}
|
|
1239
|
-
export interface ${object.objectType.apiName}Def extends ObjectTypeDefinition<"${object.objectType.apiName}"> {
|
|
1240
|
-
type: "${definition.type}",
|
|
1241
|
-
apiName: "${definition.apiName}",
|
|
1242
|
-
${definition.description != null ? `description: ${JSON.stringify(definition.description)},` : ""}
|
|
1243
|
-
primaryKeyType: ${JSON.stringify(definition.primaryKeyType)},
|
|
1244
|
-
links: {${Object.entries(definition.links).map(([linkApiName, definition2]) => `${linkApiName}: ObjectTypeLinkDefinition<${definition2.targetType}Def, ${definition2.multiplicity}>`).join(",\n")}
|
|
1245
|
-
},
|
|
1246
|
-
properties: ${JSON.stringify(definition.properties, null, 2)},
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
export const ${object.objectType.apiName}: ${object.objectType.apiName}Def = {
|
|
1250
|
-
type: "${definition.type}",
|
|
1251
|
-
apiName: "${definition.apiName}",
|
|
1252
|
-
${definition.description != null ? `description: ${JSON.stringify(definition.description)},` : ""}
|
|
1253
|
-
primaryKeyType: ${JSON.stringify(definition.primaryKeyType)},
|
|
1254
|
-
links: ${JSON.stringify(definition.links, null, 2)},
|
|
1255
|
-
properties: ${JSON.stringify(definition.properties, null, 2)},
|
|
1256
|
-
};`;
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
// src/v1.1/generatePerObjectInterfaceAndDataFiles.ts
|
|
1260
1158
|
async function generatePerObjectInterfaceAndDataFiles(ontology, fs, outDir, importExt = "") {
|
|
1261
1159
|
await fs.mkdir(outDir, {
|
|
1262
1160
|
recursive: true
|
|
@@ -1264,7 +1162,7 @@ async function generatePerObjectInterfaceAndDataFiles(ontology, fs, outDir, impo
|
|
|
1264
1162
|
await Promise.all(Object.values(ontology.objectTypes).map(async (object) => {
|
|
1265
1163
|
object.linkTypes;
|
|
1266
1164
|
await fs.writeFile(path15__namespace.default.join(outDir, `${object.objectType.apiName}.ts`), await formatTs(`
|
|
1267
|
-
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition } from "@osdk/api";
|
|
1165
|
+
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
|
|
1268
1166
|
${wireObjectTypeV2ToObjectInterfaceStringV1(object, importExt)}
|
|
1269
1167
|
|
|
1270
1168
|
${wireObjectTypeV2ToSdkObjectConst(object, importExt)}
|
|
@@ -1662,8 +1560,6 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs, outDir
|
|
|
1662
1560
|
await generateIndexFile(fs, outDir, importExt);
|
|
1663
1561
|
await generateBackCompatDeprecatedExports(fs, outDir, importExt);
|
|
1664
1562
|
}
|
|
1665
|
-
|
|
1666
|
-
// src/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.ts
|
|
1667
1563
|
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceType, v2 = false) {
|
|
1668
1564
|
return `
|
|
1669
1565
|
export const ${interfaceType.apiName} = ${JSON.stringify(wireInterfaceTypeV2ToSdkObjectDefinition(interfaceType), null, 2)} satisfies InterfaceDefinition<"${interfaceType.apiName}", "">;`;
|
|
@@ -1674,7 +1570,7 @@ function wireInterfaceTypeV2ToSdkObjectDefinition(interfaceType, v2) {
|
|
|
1674
1570
|
apiName: interfaceType.apiName,
|
|
1675
1571
|
description: interfaceType.description,
|
|
1676
1572
|
properties: Object.fromEntries(Object.entries(interfaceType.properties).map(([key, value]) => {
|
|
1677
|
-
return [key, wirePropertyV2ToSdkPropertyDefinition(value, true)];
|
|
1573
|
+
return [key, generatorConverters.wirePropertyV2ToSdkPropertyDefinition(value, true)];
|
|
1678
1574
|
})),
|
|
1679
1575
|
links: {}
|
|
1680
1576
|
};
|
|
@@ -1702,6 +1598,9 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, out
|
|
|
1702
1598
|
});
|
|
1703
1599
|
fs.writeFile(path15__namespace.default.join(outDir, "index.ts"), await formatTs(`
|
|
1704
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}";
|
|
1705
1604
|
`));
|
|
1706
1605
|
await generateOntologyMetadataFile(sanitizedOntology, userAgent, fs, outDir);
|
|
1707
1606
|
await fs.writeFile(path15__namespace.default.join(outDir, "Ontology.ts"), await formatTs(`
|
|
@@ -1745,18 +1644,11 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, out
|
|
|
1745
1644
|
for (const name of objectNames) {
|
|
1746
1645
|
const obj = ontology.objectTypes[name];
|
|
1747
1646
|
await fs.writeFile(path15__namespace.default.join(outDir, "ontology", `objects`, `${name}.ts`), await formatTs(`
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
${wireObjectTypeV2ToSdkObjectConst(obj, importExt, true)}
|
|
1647
|
+
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
|
|
1648
|
+
import { Osdk } from "@osdk/client";
|
|
1752
1649
|
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
// obj,
|
|
1756
|
-
// )
|
|
1757
|
-
*/
|
|
1758
|
-
""}
|
|
1759
|
-
`));
|
|
1650
|
+
${wireObjectTypeV2ToSdkObjectConst(obj, importExt, true)}
|
|
1651
|
+
`));
|
|
1760
1652
|
}
|
|
1761
1653
|
await generateOntologyInterfaces(fs, outDir, interfaceNames, ontology, importExt);
|
|
1762
1654
|
const actionsDir = path15__namespace.default.join(outDir, "ontology", "actions");
|
|
@@ -1791,6 +1683,7 @@ async function generateOntologyInterfaces(fs, outDir, interfaceNames, ontology,
|
|
|
1791
1683
|
}
|
|
1792
1684
|
await fs.writeFile(interfacesDir + ".ts", await formatTs(`
|
|
1793
1685
|
${Object.keys(ontology.interfaceTypes ?? {}).map((apiName) => `export * from "./interfaces/${apiName}${importExt}";`).join("\n")}
|
|
1686
|
+
${Object.keys(ontology.interfaceTypes ?? {}).length === 0 ? "export {}" : ""}
|
|
1794
1687
|
`));
|
|
1795
1688
|
}
|
|
1796
1689
|
|