@osdk/generator 1.9.1-main-20240411211601 → 1.10.0-main-20240412174954

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.
@@ -926,6 +926,54 @@ async function generateBackCompatDeprecatedExports(fs2, outDir, importExt = "")
926
926
  await generateOntologyRuntimeDistDir(outDir, fs2, importExt);
927
927
  await generateOAuthClientDistDir(outDir, fs2, importExt);
928
928
  }
929
+ async function generateBatchActions(ontology, fs2, outDir, importExt = "") {
930
+ const importedObjects = /* @__PURE__ */ new Set();
931
+ let actionSignatures = [];
932
+ for (const action of Object.values(ontology.actionTypes)) {
933
+ const entries = Object.entries(action.parameters);
934
+ const modifiedEntityTypes = getModifiedEntityTypes(action);
935
+ const addedObjects = Array.from(modifiedEntityTypes.addedObjects);
936
+ const modifiedObjects = Array.from(modifiedEntityTypes.modifiedObjects);
937
+ addedObjects.forEach(importedObjects.add, importedObjects);
938
+ modifiedObjects.forEach(importedObjects.add, importedObjects);
939
+ let jsDocBlock = ["/**"];
940
+ if (action.description) {
941
+ jsDocBlock.push(`* ${action.description}`);
942
+ }
943
+ let parameterBlock = "";
944
+ if (entries.length > 0) {
945
+ parameterBlock = `params: {
946
+ `;
947
+ for (const [parameterName, parameterData] of entries) {
948
+ parameterBlock += `"${parameterName}"`;
949
+ parameterBlock += parameterData.required ? ": " : "?: ";
950
+ const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
951
+ parameterBlock += `${typeScriptType};
952
+ `;
953
+ jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
954
+ }
955
+ parameterBlock += "}[], ";
956
+ } else {
957
+ parameterBlock = `params: Record<string,never>[], `;
958
+ }
959
+ jsDocBlock.push(`*/`);
960
+ actionSignatures.push(`
961
+ ${jsDocBlock.join("\n")}
962
+ ${action.apiName}<O extends BatchActionExecutionOptions>(${parameterBlock}options?: O):
963
+ Promise<Result<BatchActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;
964
+ `);
965
+ }
966
+ await fs2.mkdir(outDir, {
967
+ recursive: true
968
+ });
969
+ await fs2.writeFile(path16__default.join(outDir, "BatchActions.ts"), await formatTs(`
970
+ import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, BatchActionExecutionOptions, ActionError, Result, ActionResponseFromOptions, BatchActionResponseFromOptions } from "@osdk/legacy-client";
971
+ ${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
972
+ export interface BatchActions {
973
+ ${actionSignatures.join("\n")}
974
+ }
975
+ `));
976
+ }
929
977
  async function generateBulkActions(ontology, fs2, outDir, importExt = "") {
930
978
  const importedObjects = /* @__PURE__ */ new Set();
931
979
  let actionSignatures = [];
@@ -1051,6 +1099,7 @@ async function generateMetadataFile(ontology, userAgent, fs2, outDir, importExt
1051
1099
  import type { Objects } from "./ontology/objects/Objects${importExt}";
1052
1100
  import type { Actions } from "./ontology/actions/Actions${importExt}";
1053
1101
  import type { Queries } from "./ontology/queries/Queries${importExt}";
1102
+ import type { BatchActions } from "./ontology/actions/BatchActions${importExt}";
1054
1103
  import type { BulkActions } from "./ontology/actions/BulkActions${importExt}";
1055
1104
  ${objectNames.map((name) => `import {${name}} from "./ontology/objects/${name}${importExt}";`).join("\n")}
1056
1105
  ${actionNames.map((name) => `import {${getImportClause(name, actionAltNames)}} from "./ontology/actions/${name}${importExt}";`).join("\n")}
@@ -1094,7 +1143,9 @@ async function generateMetadataFile(ontology, userAgent, fs2, outDir, importExt
1094
1143
  export interface Ontology extends ClientOntology<typeof Ontology> {
1095
1144
  objects: Objects;
1096
1145
  actions: Actions;
1146
+ /** @deprecated use batchActions */
1097
1147
  bulkActions: BulkActions;
1148
+ batchActions: BatchActions;
1098
1149
  queries: Queries;
1099
1150
  }`));
1100
1151
  }
@@ -1556,6 +1607,7 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
1556
1607
  await generateObjectsInterfaceSupportFiles(sanitizedOntology, fs2, path16.join(objectsDir, "objects-api"), importExt);
1557
1608
  await generatePerObjectInterfaceAndDataFiles(sanitizedOntology, fs2, objectsDir, importExt);
1558
1609
  await generateActions(sanitizedOntology, fs2, actionsDir, importExt);
1610
+ await generateBatchActions(sanitizedOntology, fs2, actionsDir, importExt);
1559
1611
  await generateBulkActions(sanitizedOntology, fs2, actionsDir, importExt);
1560
1612
  await generatePerActionDataFiles(sanitizedOntology, fs2, actionsDir, importExt, false);
1561
1613
  await generateQueries(sanitizedOntology, fs2, queriesDir, importExt);