@osdk/generator 1.0.2 → 1.0.3
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/CHANGELOG.md +7 -0
- package/build/js/index.cjs +10 -3
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +10 -3
- package/build/js/index.mjs.map +1 -1
- package/package.json +1 -1
package/build/js/index.mjs
CHANGED
|
@@ -996,7 +996,7 @@ ${Array.from(uniqueLinkTargets).map((linkTarget) => `import type { ${linkTarget}
|
|
|
996
996
|
${getDescriptionIfPresent(objectTypeWithLinks.objectType.description)}export interface ${objectTypeWithLinks.objectType.apiName} extends OntologyObject {
|
|
997
997
|
readonly __apiName: "${objectTypeWithLinks.objectType.apiName}";
|
|
998
998
|
readonly __primaryKey: ${wirePropertyTypeV2ToTypeScriptType(objectTypeWithLinks.objectType.properties[objectTypeWithLinks.objectType.primaryKey].dataType)};
|
|
999
|
-
${Object.entries(objectTypeWithLinks.objectType.properties).flatMap(([propertyName, propertyDefinition]) => {
|
|
999
|
+
${Object.entries(objectTypeWithLinks.objectType.properties).sort((a, b) => a[0].localeCompare(b[0])).flatMap(([propertyName, propertyDefinition]) => {
|
|
1000
1000
|
const propertyType = wirePropertyTypeV2ToTypeScriptType(propertyDefinition.dataType);
|
|
1001
1001
|
const entries = [`${getDescriptionIfPresent(propertyDefinition.description)}readonly ${propertyName}: ${propertyType} | undefined`];
|
|
1002
1002
|
if (isReservedKeyword(propertyName)) {
|
|
@@ -1068,7 +1068,7 @@ async function generatePerObjectInterfaceAndDataFiles(ontology, fs, outDir, impo
|
|
|
1068
1068
|
await Promise.all(Object.values(ontology.objectTypes).map(async (object) => {
|
|
1069
1069
|
object.linkTypes;
|
|
1070
1070
|
await fs.writeFile(path15__default.join(outDir, `${object.objectType.apiName}.ts`), await formatTs(`
|
|
1071
|
-
import { ObjectTypeDefinition } from "@osdk/api";
|
|
1071
|
+
import type { ObjectTypeDefinition } from "@osdk/api";
|
|
1072
1072
|
${wireObjectTypeV2ToObjectInterfaceStringV1(object)}
|
|
1073
1073
|
|
|
1074
1074
|
${wireObjectTypeV2ToSdkObjectConst(object)}
|
|
@@ -1530,7 +1530,7 @@ async function generateClientSdkVersionTwoPointZero(ontology, fs, outDir, packag
|
|
|
1530
1530
|
}).join(",\n")}
|
|
1531
1531
|
|
|
1532
1532
|
}
|
|
1533
|
-
} satisfies OntologyDefinition<${objectNames
|
|
1533
|
+
} satisfies OntologyDefinition<${stringUnionFrom2(objectNames)}>;
|
|
1534
1534
|
|
|
1535
1535
|
type _Ontology = typeof _Ontology;
|
|
1536
1536
|
export interface Ontology extends _Ontology {}
|
|
@@ -1565,6 +1565,13 @@ async function generateClientSdkVersionTwoPointZero(ontology, fs, outDir, packag
|
|
|
1565
1565
|
${Object.keys(ontology.objectTypes).map((apiName) => `export * from "./objects/${apiName}${importExt}";`).join("\n")}
|
|
1566
1566
|
`));
|
|
1567
1567
|
}
|
|
1568
|
+
function stringUnionFrom2(values) {
|
|
1569
|
+
if (values.length === 0) {
|
|
1570
|
+
return "never";
|
|
1571
|
+
} else {
|
|
1572
|
+
return values.map((v) => `"${v}"`).join("|");
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1568
1575
|
async function generateOntologyInterfaces(fs, outDir, interfaceNames, ontology, importExt) {
|
|
1569
1576
|
const interfacesDir = path15__default.join(outDir, "ontology", "interfaces");
|
|
1570
1577
|
await fs.mkdir(interfacesDir, {
|