@osdk/generator 1.6.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.
- package/build/js/index.cjs +50 -25
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +51 -26
- package/build/js/index.mjs.map +1 -1
- package/build/types/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts +1 -1
- package/build/types/util/test/TodoWireOntology.d.ts +2 -0
- package/changelog/1.7.0/pr-101.v2.yml +5 -0
- package/changelog/1.7.0/pr-102.v2.yml +5 -0
- package/changelog/1.7.0/pr-113.v2.yml +5 -0
- package/changelog/1.7.0/pr-120.v2.yml +5 -0
- package/changelog/1.7.0/pr-121.v2.yml +5 -0
- package/changelog/1.7.0/pr-124.v2.yml +5 -0
- package/package.json +5 -5
package/build/js/index.cjs
CHANGED
|
@@ -872,7 +872,9 @@ var defaultCustomizer = (value, defaultValueFormatter, key, defaultKeyFormatter)
|
|
|
872
872
|
function stringify(obj, customizer = {}, separator = ",\n") {
|
|
873
873
|
const defaultKeyFormatter = (key) => `${JSON.stringify(key)}`;
|
|
874
874
|
const entries = [];
|
|
875
|
-
|
|
875
|
+
const sortedKeys = Object.keys(obj).sort((a, b) => a.localeCompare(b));
|
|
876
|
+
for (const key of sortedKeys) {
|
|
877
|
+
const value = obj[key];
|
|
876
878
|
const res = (customizer[key] ?? customizer["*"] ?? defaultCustomizer)(value, (value2) => JSON.stringify(value2, null, 2), key, defaultKeyFormatter);
|
|
877
879
|
if (res) {
|
|
878
880
|
if (typeof res === "string") {
|
|
@@ -986,7 +988,7 @@ function wirePropertyTypeV2ToTypeScriptType(property) {
|
|
|
986
988
|
case "date":
|
|
987
989
|
return "LocalDate";
|
|
988
990
|
case "decimal":
|
|
989
|
-
return "
|
|
991
|
+
return "string";
|
|
990
992
|
case "double":
|
|
991
993
|
return "number";
|
|
992
994
|
case "float":
|
|
@@ -996,7 +998,7 @@ function wirePropertyTypeV2ToTypeScriptType(property) {
|
|
|
996
998
|
case "geoshape":
|
|
997
999
|
return "GeoShape";
|
|
998
1000
|
case "long":
|
|
999
|
-
return "
|
|
1001
|
+
return "string";
|
|
1000
1002
|
case "short":
|
|
1001
1003
|
return "number";
|
|
1002
1004
|
case "timestamp":
|
|
@@ -1036,13 +1038,14 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
|
|
|
1036
1038
|
const paramsIdentifier = `${action.apiName}$Params`;
|
|
1037
1039
|
function createParamsDef() {
|
|
1038
1040
|
const entries = Object.entries(parameters);
|
|
1041
|
+
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
|
1039
1042
|
if (entries.length === 0) {
|
|
1040
1043
|
return `// Represents the definition of the parameters for the action
|
|
1041
1044
|
export type ${paramsDefIdentifier} = Record<string, never>;`;
|
|
1042
1045
|
}
|
|
1043
1046
|
return `// Represents the definition of the parameters for the action
|
|
1044
1047
|
export type ${paramsDefIdentifier} = {
|
|
1045
|
-
${
|
|
1048
|
+
${entries.map(([key, value]) => {
|
|
1046
1049
|
return `"${key}": {
|
|
1047
1050
|
${stringify(value, {
|
|
1048
1051
|
description: (value2, d) => value2 ? d(value2) : void 0,
|
|
@@ -1081,7 +1084,7 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
|
|
|
1081
1084
|
|
|
1082
1085
|
// Represents the definition of the action
|
|
1083
1086
|
export interface ${actionDefIdentifier} extends ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}, ${action.apiName}>{
|
|
1084
|
-
${Object.entries(actionDefSansParameters).map(([key, value]) => {
|
|
1087
|
+
${Object.entries(actionDefSansParameters).sort((a, b) => a[0].localeCompare(b[0])).map(([key, value]) => {
|
|
1085
1088
|
return `${key}: ${JSON.stringify(value)};`;
|
|
1086
1089
|
}).join("\n")}
|
|
1087
1090
|
parameters: ${paramsDefIdentifier}
|
|
@@ -1114,6 +1117,7 @@ async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
|
|
|
1114
1117
|
}));
|
|
1115
1118
|
await fs.writeFile(path15__namespace.default.join(outDir, `index.ts`), await formatTs(`
|
|
1116
1119
|
${Object.values(ontology.actionTypes).map((action) => `export {${action.apiName}} from "./${action.apiName}${importExt}";`).join("\n")}
|
|
1120
|
+
${Object.keys(ontology.actionTypes).length === 0 ? "export {};" : ""}
|
|
1117
1121
|
`));
|
|
1118
1122
|
}
|
|
1119
1123
|
function extractReferencedObjectsFromAction(actionType) {
|
|
@@ -1437,8 +1441,9 @@ function handleQueryDataType(dataType, importedObjects, isReturnValue) {
|
|
|
1437
1441
|
case "double":
|
|
1438
1442
|
case "float":
|
|
1439
1443
|
case "integer":
|
|
1440
|
-
case "long":
|
|
1441
1444
|
return "number";
|
|
1445
|
+
case "long":
|
|
1446
|
+
return isReturnValue ? "string" : "string | number";
|
|
1442
1447
|
case "date":
|
|
1443
1448
|
return "LocalDate";
|
|
1444
1449
|
case "timestamp":
|
|
@@ -1560,20 +1565,38 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs, outDir
|
|
|
1560
1565
|
await generateIndexFile(fs, outDir, importExt);
|
|
1561
1566
|
await generateBackCompatDeprecatedExports(fs, outDir, importExt);
|
|
1562
1567
|
}
|
|
1563
|
-
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1568
|
+
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false) {
|
|
1569
|
+
const definition = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef, v2));
|
|
1570
|
+
const objectDefIdentifier = getObjectDefIdentifier(interfaceDef.apiName, v2);
|
|
1571
|
+
function getV2Types() {
|
|
1572
|
+
return `
|
|
1573
|
+
export interface ${objectDefIdentifier} extends InterfaceDefinition<"${interfaceDef.apiName}", ${interfaceDef.apiName}> {
|
|
1574
|
+
${stringify(definition, {
|
|
1575
|
+
type: () => void 0,
|
|
1576
|
+
apiName: () => void 0,
|
|
1577
|
+
links: (_value) => `{
|
|
1578
|
+
${stringify(definition.links, {
|
|
1579
|
+
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
1580
|
+
})}
|
|
1581
|
+
}`,
|
|
1582
|
+
properties: (_value) => `{
|
|
1583
|
+
${stringify(definition.properties, {
|
|
1584
|
+
"*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
|
|
1585
|
+
})}
|
|
1586
|
+
}`
|
|
1587
|
+
})}
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
`;
|
|
1591
|
+
}
|
|
1592
|
+
const imports = [];
|
|
1593
|
+
return `${imports.join("\n")}
|
|
1594
|
+
|
|
1595
|
+
${v2 ? getV2Types() : ""}
|
|
1596
|
+
|
|
1597
|
+
export const ${definition.apiName}: ${objectDefIdentifier} = {
|
|
1598
|
+
${stringify(definition)}
|
|
1599
|
+
};`;
|
|
1577
1600
|
}
|
|
1578
1601
|
async function generateOntologyMetadataFile(ontology, userAgent, fs, outDir) {
|
|
1579
1602
|
fs.writeFile(path15__namespace.default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
@@ -1589,9 +1612,10 @@ async function generateOntologyMetadataFile(ontology, userAgent, fs, outDir) {
|
|
|
1589
1612
|
async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, outDir, packageType = "commonjs") {
|
|
1590
1613
|
await verifyOutdir(outDir, fs);
|
|
1591
1614
|
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
1592
|
-
const objectNames = Object.keys(sanitizedOntology.objectTypes);
|
|
1593
|
-
const actionNames = Object.keys(sanitizedOntology.actionTypes);
|
|
1594
|
-
|
|
1615
|
+
const objectNames = Object.keys(sanitizedOntology.objectTypes).sort((a, b) => a.localeCompare(b));
|
|
1616
|
+
const actionNames = Object.keys(sanitizedOntology.actionTypes).sort((a, b) => a.localeCompare(b));
|
|
1617
|
+
Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
|
|
1618
|
+
const interfaceNames = Object.keys(sanitizedOntology.interfaceTypes ?? {}).sort((a, b) => a.localeCompare(b));
|
|
1595
1619
|
const importExt = packageType === "module" ? ".js" : "";
|
|
1596
1620
|
await fs.mkdir(outDir, {
|
|
1597
1621
|
recursive: true
|
|
@@ -1657,7 +1681,8 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, out
|
|
|
1657
1681
|
});
|
|
1658
1682
|
await generatePerActionDataFiles(sanitizedOntology, fs, actionsDir, importExt, true);
|
|
1659
1683
|
await fs.writeFile(path15__namespace.default.join(outDir, "ontology", "objects.ts"), await formatTs(`
|
|
1660
|
-
${Object.keys(ontology.objectTypes).map((apiName) => `export * from "./objects/${apiName}${importExt}";`).join("\n")}
|
|
1684
|
+
${Object.keys(ontology.objectTypes).sort((a, b) => a.localeCompare(b)).map((apiName) => `export * from "./objects/${apiName}${importExt}";`).join("\n")}
|
|
1685
|
+
${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
|
|
1661
1686
|
`));
|
|
1662
1687
|
}
|
|
1663
1688
|
function stringUnionFrom2(values) {
|
|
@@ -1676,7 +1701,7 @@ async function generateOntologyInterfaces(fs, outDir, interfaceNames, ontology,
|
|
|
1676
1701
|
const obj = ontology.interfaceTypes[name];
|
|
1677
1702
|
await fs.writeFile(path15__namespace.default.join(interfacesDir, `${name}.ts`), await formatTs(`
|
|
1678
1703
|
|
|
1679
|
-
import type { InterfaceDefinition } from "@osdk/api";
|
|
1704
|
+
import type { InterfaceDefinition, PropertyDef } from "@osdk/api";
|
|
1680
1705
|
|
|
1681
1706
|
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, true)}
|
|
1682
1707
|
`));
|