@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.
- package/CHANGELOG.md +7 -3
- package/build/js/index.cjs +52 -0
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +52 -0
- 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/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
# @osdk/generator
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.10.0-main-20240412174954
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 11434b95: Deprecated bulk actions with renamed batchActions functionality
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
7
11
|
- 9906a41e: Extract package generation
|
|
8
12
|
- 9906a41e: Compatible version checks now use versions that are both embedded in the code and updated automatically as part of the release process.
|
|
9
13
|
- f7287ae8: For 2.0, fixes codegen version matching in snapshot builds
|
|
10
|
-
- @osdk/api@1.6.1-main-
|
|
11
|
-
- @osdk/generator-converters@0.4.1-main-
|
|
14
|
+
- @osdk/api@1.6.1-main-20240412174954
|
|
15
|
+
- @osdk/generator-converters@0.4.1-main-20240412174954
|
|
12
16
|
|
|
13
17
|
## 1.1.1
|
|
14
18
|
|
package/build/js/index.cjs
CHANGED
|
@@ -951,6 +951,54 @@ async function generateBackCompatDeprecatedExports(fs2, outDir, importExt = "")
|
|
|
951
951
|
await generateOntologyRuntimeDistDir(outDir, fs2, importExt);
|
|
952
952
|
await generateOAuthClientDistDir(outDir, fs2, importExt);
|
|
953
953
|
}
|
|
954
|
+
async function generateBatchActions(ontology, fs2, outDir, importExt = "") {
|
|
955
|
+
const importedObjects = /* @__PURE__ */ new Set();
|
|
956
|
+
let actionSignatures = [];
|
|
957
|
+
for (const action of Object.values(ontology.actionTypes)) {
|
|
958
|
+
const entries = Object.entries(action.parameters);
|
|
959
|
+
const modifiedEntityTypes = getModifiedEntityTypes(action);
|
|
960
|
+
const addedObjects = Array.from(modifiedEntityTypes.addedObjects);
|
|
961
|
+
const modifiedObjects = Array.from(modifiedEntityTypes.modifiedObjects);
|
|
962
|
+
addedObjects.forEach(importedObjects.add, importedObjects);
|
|
963
|
+
modifiedObjects.forEach(importedObjects.add, importedObjects);
|
|
964
|
+
let jsDocBlock = ["/**"];
|
|
965
|
+
if (action.description) {
|
|
966
|
+
jsDocBlock.push(`* ${action.description}`);
|
|
967
|
+
}
|
|
968
|
+
let parameterBlock = "";
|
|
969
|
+
if (entries.length > 0) {
|
|
970
|
+
parameterBlock = `params: {
|
|
971
|
+
`;
|
|
972
|
+
for (const [parameterName, parameterData] of entries) {
|
|
973
|
+
parameterBlock += `"${parameterName}"`;
|
|
974
|
+
parameterBlock += parameterData.required ? ": " : "?: ";
|
|
975
|
+
const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
|
|
976
|
+
parameterBlock += `${typeScriptType};
|
|
977
|
+
`;
|
|
978
|
+
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
979
|
+
}
|
|
980
|
+
parameterBlock += "}[], ";
|
|
981
|
+
} else {
|
|
982
|
+
parameterBlock = `params: Record<string,never>[], `;
|
|
983
|
+
}
|
|
984
|
+
jsDocBlock.push(`*/`);
|
|
985
|
+
actionSignatures.push(`
|
|
986
|
+
${jsDocBlock.join("\n")}
|
|
987
|
+
${action.apiName}<O extends BatchActionExecutionOptions>(${parameterBlock}options?: O):
|
|
988
|
+
Promise<Result<BatchActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;
|
|
989
|
+
`);
|
|
990
|
+
}
|
|
991
|
+
await fs2.mkdir(outDir, {
|
|
992
|
+
recursive: true
|
|
993
|
+
});
|
|
994
|
+
await fs2.writeFile(path16__namespace.default.join(outDir, "BatchActions.ts"), await formatTs(`
|
|
995
|
+
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, BatchActionExecutionOptions, ActionError, Result, ActionResponseFromOptions, BatchActionResponseFromOptions } from "@osdk/legacy-client";
|
|
996
|
+
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
997
|
+
export interface BatchActions {
|
|
998
|
+
${actionSignatures.join("\n")}
|
|
999
|
+
}
|
|
1000
|
+
`));
|
|
1001
|
+
}
|
|
954
1002
|
async function generateBulkActions(ontology, fs2, outDir, importExt = "") {
|
|
955
1003
|
const importedObjects = /* @__PURE__ */ new Set();
|
|
956
1004
|
let actionSignatures = [];
|
|
@@ -1076,6 +1124,7 @@ async function generateMetadataFile(ontology, userAgent, fs2, outDir, importExt
|
|
|
1076
1124
|
import type { Objects } from "./ontology/objects/Objects${importExt}";
|
|
1077
1125
|
import type { Actions } from "./ontology/actions/Actions${importExt}";
|
|
1078
1126
|
import type { Queries } from "./ontology/queries/Queries${importExt}";
|
|
1127
|
+
import type { BatchActions } from "./ontology/actions/BatchActions${importExt}";
|
|
1079
1128
|
import type { BulkActions } from "./ontology/actions/BulkActions${importExt}";
|
|
1080
1129
|
${objectNames.map((name) => `import {${name}} from "./ontology/objects/${name}${importExt}";`).join("\n")}
|
|
1081
1130
|
${actionNames.map((name) => `import {${getImportClause(name, actionAltNames)}} from "./ontology/actions/${name}${importExt}";`).join("\n")}
|
|
@@ -1119,7 +1168,9 @@ async function generateMetadataFile(ontology, userAgent, fs2, outDir, importExt
|
|
|
1119
1168
|
export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
1120
1169
|
objects: Objects;
|
|
1121
1170
|
actions: Actions;
|
|
1171
|
+
/** @deprecated use batchActions */
|
|
1122
1172
|
bulkActions: BulkActions;
|
|
1173
|
+
batchActions: BatchActions;
|
|
1123
1174
|
queries: Queries;
|
|
1124
1175
|
}`));
|
|
1125
1176
|
}
|
|
@@ -1581,6 +1632,7 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
|
|
|
1581
1632
|
await generateObjectsInterfaceSupportFiles(sanitizedOntology, fs2, path16__namespace.join(objectsDir, "objects-api"), importExt);
|
|
1582
1633
|
await generatePerObjectInterfaceAndDataFiles(sanitizedOntology, fs2, objectsDir, importExt);
|
|
1583
1634
|
await generateActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1635
|
+
await generateBatchActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1584
1636
|
await generateBulkActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1585
1637
|
await generatePerActionDataFiles(sanitizedOntology, fs2, actionsDir, importExt, false);
|
|
1586
1638
|
await generateQueries(sanitizedOntology, fs2, queriesDir, importExt);
|