@osdk/generator 1.9.1-main-20240412164446 → 1.10.0-main-20240418183121
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 +8 -3
- package/build/js/index.cjs +55 -1
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +55 -1
- package/build/js/index.mjs.map +1 -1
- package/build/types/v1.1/generateBatchActions.d.ts +4 -0
- package/build/types/v1.1/generateBatchActions.d.ts.map +1 -0
- package/build/types/v1.1/generateBatchActions.test.d.ts +2 -0
- package/build/types/v1.1/generateBatchActions.test.d.ts.map +1 -0
- package/build/types/v1.1/generateClientSdkVersionOneDotOne.d.ts.map +1 -1
- package/build/types/v1.1/generateMetadataFile.d.ts.map +1 -1
- package/build/types/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.d.ts.map +1 -1
- package/package.json +3 -3
package/build/js/index.mjs
CHANGED
|
@@ -59,7 +59,9 @@ ${Array.from(uniqueLinkTargets).map((linkTarget) => `import type { ${linkTarget}
|
|
|
59
59
|
${getDescriptionIfPresent(objectTypeWithLinks.objectType.description)}
|
|
60
60
|
export interface ${objectTypeWithLinks.objectType.apiName} extends OntologyObject {
|
|
61
61
|
/** @deprecated please migrate to $apiName instead */
|
|
62
|
-
readonly __apiName: "${objectTypeWithLinks.objectType.apiName}"
|
|
62
|
+
readonly __apiName: "${objectTypeWithLinks.objectType.apiName}" & {${objectTypeWithLinks.linkTypes.map((linkType) => {
|
|
63
|
+
return `/** @deprecated please migrate to pivotTo(${linkType.apiName}) instead */ searchAround${linkType.apiName.charAt(0).toUpperCase() + linkType.apiName.slice(1)}?: never`;
|
|
64
|
+
})}};
|
|
63
65
|
/** @deprecated please migrate to $primaryKey instead */
|
|
64
66
|
readonly __primaryKey: ${wirePropertyTypeV2ToTypeScriptType(objectTypeWithLinks.objectType.properties[objectTypeWithLinks.objectType.primaryKey].dataType)};
|
|
65
67
|
readonly $apiName: "${objectTypeWithLinks.objectType.apiName}";
|
|
@@ -926,6 +928,54 @@ async function generateBackCompatDeprecatedExports(fs2, outDir, importExt = "")
|
|
|
926
928
|
await generateOntologyRuntimeDistDir(outDir, fs2, importExt);
|
|
927
929
|
await generateOAuthClientDistDir(outDir, fs2, importExt);
|
|
928
930
|
}
|
|
931
|
+
async function generateBatchActions(ontology, fs2, outDir, importExt = "") {
|
|
932
|
+
const importedObjects = /* @__PURE__ */ new Set();
|
|
933
|
+
let actionSignatures = [];
|
|
934
|
+
for (const action of Object.values(ontology.actionTypes)) {
|
|
935
|
+
const entries = Object.entries(action.parameters);
|
|
936
|
+
const modifiedEntityTypes = getModifiedEntityTypes(action);
|
|
937
|
+
const addedObjects = Array.from(modifiedEntityTypes.addedObjects);
|
|
938
|
+
const modifiedObjects = Array.from(modifiedEntityTypes.modifiedObjects);
|
|
939
|
+
addedObjects.forEach(importedObjects.add, importedObjects);
|
|
940
|
+
modifiedObjects.forEach(importedObjects.add, importedObjects);
|
|
941
|
+
let jsDocBlock = ["/**"];
|
|
942
|
+
if (action.description) {
|
|
943
|
+
jsDocBlock.push(`* ${action.description}`);
|
|
944
|
+
}
|
|
945
|
+
let parameterBlock = "";
|
|
946
|
+
if (entries.length > 0) {
|
|
947
|
+
parameterBlock = `params: {
|
|
948
|
+
`;
|
|
949
|
+
for (const [parameterName, parameterData] of entries) {
|
|
950
|
+
parameterBlock += `"${parameterName}"`;
|
|
951
|
+
parameterBlock += parameterData.required ? ": " : "?: ";
|
|
952
|
+
const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
|
|
953
|
+
parameterBlock += `${typeScriptType};
|
|
954
|
+
`;
|
|
955
|
+
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
956
|
+
}
|
|
957
|
+
parameterBlock += "}[], ";
|
|
958
|
+
} else {
|
|
959
|
+
parameterBlock = `params: Record<string,never>[], `;
|
|
960
|
+
}
|
|
961
|
+
jsDocBlock.push(`*/`);
|
|
962
|
+
actionSignatures.push(`
|
|
963
|
+
${jsDocBlock.join("\n")}
|
|
964
|
+
${action.apiName}<O extends BatchActionExecutionOptions>(${parameterBlock}options?: O):
|
|
965
|
+
Promise<Result<BatchActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;
|
|
966
|
+
`);
|
|
967
|
+
}
|
|
968
|
+
await fs2.mkdir(outDir, {
|
|
969
|
+
recursive: true
|
|
970
|
+
});
|
|
971
|
+
await fs2.writeFile(path16__default.join(outDir, "BatchActions.ts"), await formatTs(`
|
|
972
|
+
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, BatchActionExecutionOptions, ActionError, Result, ActionResponseFromOptions, BatchActionResponseFromOptions } from "@osdk/legacy-client";
|
|
973
|
+
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
974
|
+
export interface BatchActions {
|
|
975
|
+
${actionSignatures.join("\n")}
|
|
976
|
+
}
|
|
977
|
+
`));
|
|
978
|
+
}
|
|
929
979
|
async function generateBulkActions(ontology, fs2, outDir, importExt = "") {
|
|
930
980
|
const importedObjects = /* @__PURE__ */ new Set();
|
|
931
981
|
let actionSignatures = [];
|
|
@@ -1051,6 +1101,7 @@ async function generateMetadataFile(ontology, userAgent, fs2, outDir, importExt
|
|
|
1051
1101
|
import type { Objects } from "./ontology/objects/Objects${importExt}";
|
|
1052
1102
|
import type { Actions } from "./ontology/actions/Actions${importExt}";
|
|
1053
1103
|
import type { Queries } from "./ontology/queries/Queries${importExt}";
|
|
1104
|
+
import type { BatchActions } from "./ontology/actions/BatchActions${importExt}";
|
|
1054
1105
|
import type { BulkActions } from "./ontology/actions/BulkActions${importExt}";
|
|
1055
1106
|
${objectNames.map((name) => `import {${name}} from "./ontology/objects/${name}${importExt}";`).join("\n")}
|
|
1056
1107
|
${actionNames.map((name) => `import {${getImportClause(name, actionAltNames)}} from "./ontology/actions/${name}${importExt}";`).join("\n")}
|
|
@@ -1094,7 +1145,9 @@ async function generateMetadataFile(ontology, userAgent, fs2, outDir, importExt
|
|
|
1094
1145
|
export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
1095
1146
|
objects: Objects;
|
|
1096
1147
|
actions: Actions;
|
|
1148
|
+
/** @deprecated use batchActions */
|
|
1097
1149
|
bulkActions: BulkActions;
|
|
1150
|
+
batchActions: BatchActions;
|
|
1098
1151
|
queries: Queries;
|
|
1099
1152
|
}`));
|
|
1100
1153
|
}
|
|
@@ -1556,6 +1609,7 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
|
|
|
1556
1609
|
await generateObjectsInterfaceSupportFiles(sanitizedOntology, fs2, path16.join(objectsDir, "objects-api"), importExt);
|
|
1557
1610
|
await generatePerObjectInterfaceAndDataFiles(sanitizedOntology, fs2, objectsDir, importExt);
|
|
1558
1611
|
await generateActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1612
|
+
await generateBatchActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1559
1613
|
await generateBulkActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1560
1614
|
await generatePerActionDataFiles(sanitizedOntology, fs2, actionsDir, importExt, false);
|
|
1561
1615
|
await generateQueries(sanitizedOntology, fs2, queriesDir, importExt);
|