@osdk/generator 2.0.0-beta.12 → 2.0.0-beta.13
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 +22 -0
- package/build/browser/index.js +45 -70
- package/build/browser/index.js.map +1 -1
- package/build/esm/GenerateContext/EnhancedBase.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedInterfaceType.d.ts +2 -2
- package/build/esm/GenerateContext/EnhancedInterfaceType.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedObjectType.d.ts +2 -2
- package/build/esm/GenerateContext/EnhancedObjectType.d.ts.map +1 -1
- package/build/esm/index.js +45 -70
- package/build/esm/index.js.map +1 -1
- package/build/esm/v2.0/generatePerActionDataFiles.d.ts.map +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @osdk/generator
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.13
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1488144: Renamed definition types to metadata
|
|
8
|
+
- bbfebfd: Fix generation of actions with full api names
|
|
9
|
+
- f6e2880: Fixes query type generation
|
|
10
|
+
- c28792e: Modified return type of fetchMetadata to return Object/Interface Definitions
|
|
11
|
+
- 26ee3bd: Updates return types of fetchMetadata to be Action and Query Definitions
|
|
12
|
+
- 6ab5d2e: Renamed Min_Definition to \_Definition
|
|
13
|
+
- 885c8e4: Fixing bug for codegen on windows machines, where we would use backslashes instead of forward slashes for import paths, which should be OS agnostic.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [1488144]
|
|
18
|
+
- Updated dependencies [c28792e]
|
|
19
|
+
- Updated dependencies [26ee3bd]
|
|
20
|
+
- Updated dependencies [6ab5d2e]
|
|
21
|
+
- @osdk/generator-converters@2.0.0-beta.13
|
|
22
|
+
- @osdk/api@2.0.0-beta.13
|
|
23
|
+
- @osdk/internal.foundry.core@0.2.0-beta.8
|
|
24
|
+
|
|
3
25
|
## 2.0.0-beta.12
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/build/browser/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path5 from 'path';
|
|
3
3
|
import path5__default from 'path';
|
|
4
|
-
import {
|
|
4
|
+
import { wireActionTypeV2ToSdkActionMetadata, wireQueryTypeV2ToSdkQueryDefinitionNoParams, wireQueryDataTypeToQueryDataTypeDefinition, wireQueryParameterV2ToQueryParameterDefinition, __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition, wireObjectTypeFullMetadataToSdkObjectMetadata } from '@osdk/generator-converters';
|
|
5
5
|
import { format } from 'prettier';
|
|
6
6
|
import fastDeepEqual from 'fast-deep-equal';
|
|
7
7
|
import invariant from 'tiny-invariant';
|
|
@@ -28,7 +28,7 @@ var AbstractImportable = class {
|
|
|
28
28
|
}
|
|
29
29
|
getImportPathRelTo = (filePath) => {
|
|
30
30
|
if (this.importPath.startsWith(".")) {
|
|
31
|
-
const result = path5.relative(path5.dirname(filePath), this.importPath);
|
|
31
|
+
const result = path5.relative(path5.dirname(filePath), this.importPath).split(path5.sep).join("/");
|
|
32
32
|
if (result.startsWith(".")) {
|
|
33
33
|
return result;
|
|
34
34
|
} else {
|
|
@@ -116,7 +116,7 @@ var EnhancedObjectType = class extends EnhancedBase {
|
|
|
116
116
|
return this.getDefinitionIdentifier(v2);
|
|
117
117
|
}
|
|
118
118
|
getCleanedUpDefinition(v2) {
|
|
119
|
-
return deleteUndefineds(
|
|
119
|
+
return deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectMetadata(this.raw, v2));
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
|
|
@@ -139,7 +139,7 @@ var EnhancedQuery = class extends EnhancedBase {
|
|
|
139
139
|
return `${this.shortApiName}.Parameters`;
|
|
140
140
|
}
|
|
141
141
|
get definitionIdentifier() {
|
|
142
|
-
return `${this.shortApiName}
|
|
142
|
+
return `${this.shortApiName}`;
|
|
143
143
|
}
|
|
144
144
|
get definitionParamsIdentifier() {
|
|
145
145
|
return `${this.definitionIdentifier}$Params`;
|
|
@@ -376,7 +376,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
376
376
|
}, currentFilePath) {
|
|
377
377
|
const object = ontology.requireObjectType(wireObject.objectType.apiName, true);
|
|
378
378
|
const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map((a) => ontology.requireObjectType(a.objectTypeApiName, false)));
|
|
379
|
-
const definition = deleteUndefineds(
|
|
379
|
+
const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectMetadata(object.raw, true));
|
|
380
380
|
const objectDefIdentifier = object.getDefinitionIdentifier(true);
|
|
381
381
|
const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;
|
|
382
382
|
const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;
|
|
@@ -396,7 +396,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
396
396
|
function getV2Types() {
|
|
397
397
|
return `import type {
|
|
398
398
|
ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
|
|
399
|
-
|
|
399
|
+
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
400
400
|
ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
|
|
401
401
|
} from "@osdk/api";
|
|
402
402
|
import type {
|
|
@@ -514,8 +514,6 @@ function createDefinition(object, ontology, identifier, {
|
|
|
514
514
|
linksType: ${osdkObjectLinksIdentifier};
|
|
515
515
|
strictProps: ${osdkObjectStrictPropsIdentifier};
|
|
516
516
|
${stringify(definition, {
|
|
517
|
-
osdkMetadata: () => void 0,
|
|
518
|
-
// we are going to reference another object instead
|
|
519
517
|
links: (_value) => `{
|
|
520
518
|
${stringify(definition.links, {
|
|
521
519
|
"*": (definition2) => `$ObjectTypeLinkDefinition<${ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(true)}, ${definition2.multiplicity}>`
|
|
@@ -569,7 +567,7 @@ async function generatePerActionDataFiles({
|
|
|
569
567
|
const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.raw);
|
|
570
568
|
const uniqueApiNames = new Set(uniqueApiNamesArray);
|
|
571
569
|
const uniqueApiNamesString = stringUnionFrom([...uniqueApiNames]);
|
|
572
|
-
const fullActionDef = deleteUndefineds(
|
|
570
|
+
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionMetadata(action.raw));
|
|
573
571
|
function createParamsDef() {
|
|
574
572
|
const entries = Object.entries(fullActionDef.parameters ?? {});
|
|
575
573
|
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
|
@@ -646,7 +644,7 @@ async function generatePerActionDataFiles({
|
|
|
646
644
|
|
|
647
645
|
${jsDocBlock.join("\n")}
|
|
648
646
|
*/
|
|
649
|
-
export interface ${action.shortApiName} extends
|
|
647
|
+
export interface ${action.shortApiName} extends ActionDefinition<"${action.fullApiName}", ${uniqueApiNamesString}, ${action.shortApiName}.Signatures> {
|
|
650
648
|
__DefinitionMetadata?: {
|
|
651
649
|
${stringify(fullActionDef, {
|
|
652
650
|
"parameters": () => action.definitionParamsIdentifier
|
|
@@ -658,7 +656,9 @@ async function generatePerActionDataFiles({
|
|
|
658
656
|
"description": () => void 0,
|
|
659
657
|
"displayName": () => void 0,
|
|
660
658
|
"modifiedEntities": () => void 0,
|
|
661
|
-
"parameters": () => void 0
|
|
659
|
+
"parameters": () => void 0,
|
|
660
|
+
"rid": () => void 0,
|
|
661
|
+
"status": () => void 0
|
|
662
662
|
})}
|
|
663
663
|
osdkMetadata: typeof $osdkMetadata;
|
|
664
664
|
}
|
|
@@ -671,7 +671,9 @@ async function generatePerActionDataFiles({
|
|
|
671
671
|
"description": () => void 0,
|
|
672
672
|
"displayName": () => void 0,
|
|
673
673
|
"modifiedEntities": () => void 0,
|
|
674
|
-
"parameters": () => void 0
|
|
674
|
+
"parameters": () => void 0,
|
|
675
|
+
"rid": () => void 0,
|
|
676
|
+
"status": () => void 0
|
|
675
677
|
})},
|
|
676
678
|
osdkMetadata: $osdkMetadata
|
|
677
679
|
}
|
|
@@ -698,7 +700,7 @@ async function generatePerActionDataFiles({
|
|
|
698
700
|
}
|
|
699
701
|
const imports = getObjectImports(referencedObjectDefs, void 0, currentFilePath, true);
|
|
700
702
|
await fs2.writeFile(path5__default.join(rootOutDir, currentFilePath), await formatTs(`
|
|
701
|
-
import type {
|
|
703
|
+
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from "@osdk/api";
|
|
702
704
|
import type { ActionParam, ActionReturnTypeForOptions, ApplyActionOptions, ApplyBatchActionOptions, } from '@osdk/client.api';
|
|
703
705
|
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
704
706
|
${imports}
|
|
@@ -843,9 +845,10 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
|
|
|
843
845
|
const outputBase = deleteUndefineds(wireQueryDataTypeToQueryDataTypeDefinition(query.output));
|
|
844
846
|
const referencedObjectTypes = objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never";
|
|
845
847
|
await fs2.writeFile(path5__default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
846
|
-
import type {
|
|
848
|
+
import type { QueryDefinition , VersionBound} from "@osdk/api";
|
|
847
849
|
import type { QueryParam, QueryResult } from "@osdk/client.api";
|
|
848
850
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
851
|
+
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
849
852
|
${importObjects}
|
|
850
853
|
|
|
851
854
|
export namespace ${query.shortApiName} {
|
|
@@ -871,12 +874,17 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
|
|
|
871
874
|
|
|
872
875
|
` : ""}
|
|
873
876
|
|
|
874
|
-
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
export interface ${query.shortApiName} extends QueryDefinition<
|
|
875
882
|
"${query.fullApiName}",
|
|
876
883
|
${referencedObjectTypes},
|
|
877
884
|
${query.shortApiName}.Signature
|
|
878
885
|
>, VersionBound<$ExpectedClientVersion>{
|
|
879
|
-
|
|
886
|
+
__DefinitionMetadata?: {
|
|
887
|
+
${stringify(baseProps)}
|
|
880
888
|
parameters: {
|
|
881
889
|
${parameterDefsForType(ontology, query)}
|
|
882
890
|
};
|
|
@@ -884,33 +892,27 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
|
|
|
884
892
|
${stringify(outputBase)},
|
|
885
893
|
${getLineFor__OsdkTargetType(ontology, query.output)}
|
|
886
894
|
};
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
895
|
+
signature: ${query.shortApiName}.Signature;
|
|
896
|
+
},
|
|
897
|
+
${stringify(baseProps, {
|
|
898
|
+
"description": () => void 0,
|
|
899
|
+
"displayName": () => void 0,
|
|
900
|
+
"rid": () => void 0
|
|
901
|
+
})},
|
|
902
|
+
osdkMetadata: typeof $osdkMetadata;
|
|
903
|
+
}
|
|
896
904
|
|
|
897
905
|
|
|
898
906
|
export const ${query.shortApiName}: ${query.definitionIdentifier} = {
|
|
899
|
-
${stringify(baseProps
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
}
|
|
907
|
+
${stringify(baseProps, {
|
|
908
|
+
"description": () => void 0,
|
|
909
|
+
"displayName": () => void 0,
|
|
910
|
+
"rid": () => void 0
|
|
911
|
+
})},
|
|
912
|
+
osdkMetadata: $osdkMetadata
|
|
906
913
|
};
|
|
907
914
|
`));
|
|
908
915
|
}
|
|
909
|
-
function parametersForConst(query) {
|
|
910
|
-
return stringify(query.parameters, {
|
|
911
|
-
"*": (parameter, formatter) => formatter(deleteUndefineds(wireQueryParameterV2ToQueryParameterDefinition(parameter)))
|
|
912
|
-
});
|
|
913
|
-
}
|
|
914
916
|
function parameterDefsForType(ontology, query) {
|
|
915
917
|
return stringify(query.parameters, {
|
|
916
918
|
"*": (parameter, valueFormatter, apiName) => [`${queryParamJsDoc(wireQueryParameterV2ToQueryParameterDefinition(parameter), {
|
|
@@ -1007,13 +1009,6 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology,
|
|
|
1007
1009
|
}
|
|
1008
1010
|
definition.properties;
|
|
1009
1011
|
definition.properties = mergedProperties;
|
|
1010
|
-
function maybeStripNamespace2(q) {
|
|
1011
|
-
if (interfaceDef.apiNamespace && q.startsWith(`${interfaceDef.apiNamespace}.`)) {
|
|
1012
|
-
return q.slice(interfaceDef.apiNamespace.length + 1);
|
|
1013
|
-
} else {
|
|
1014
|
-
return q;
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
1012
|
const objectSetIdentifier = `${interfaceDef.shortApiName}.ObjectSet`;
|
|
1018
1013
|
const propertyKeysIdentifier = `${interfaceDef.shortApiName}.PropertyKeys`;
|
|
1019
1014
|
const osdkObjectPropsIdentifier = `${interfaceDef.shortApiName}.Props`;
|
|
@@ -1021,7 +1016,7 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology,
|
|
|
1021
1016
|
const osdkObjectLinksIdentifier = `OsdkObjectLinks$${objectDefIdentifier}`;
|
|
1022
1017
|
const osdkObjectIdentifier = `${interfaceDef.shortApiName}.OsdkObject`;
|
|
1023
1018
|
const ids = {
|
|
1024
|
-
objectDefIdentifier:
|
|
1019
|
+
objectDefIdentifier: interfaceDef.shortApiName,
|
|
1025
1020
|
osdkObjectLinksIdentifier,
|
|
1026
1021
|
osdkObjectPropsIdentifier,
|
|
1027
1022
|
osdkObjectStrictPropsIdentifier,
|
|
@@ -1065,20 +1060,11 @@ ${stringify(definition.links, {
|
|
|
1065
1060
|
|
|
1066
1061
|
${createObjectSet(interfaceDef, ids)}
|
|
1067
1062
|
|
|
1068
|
-
${createDefinition(interfaceDef, ontology, "Definition", ids)}
|
|
1069
|
-
|
|
1070
1063
|
${createOsdkObject(interfaceDef, "OsdkObject", ids)}
|
|
1071
1064
|
|
|
1072
1065
|
}
|
|
1073
1066
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
/** @deprecated use ${interfaceDef.shortApiName}.Definition **/
|
|
1078
|
-
export type ${objectDefIdentifier} = ${interfaceDef.shortApiName}.Definition;
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1067
|
+
${createDefinition(interfaceDef, ontology, interfaceDef.shortApiName, ids)}
|
|
1082
1068
|
|
|
1083
1069
|
`;
|
|
1084
1070
|
}
|
|
@@ -1086,22 +1072,11 @@ ${stringify(definition.links, {
|
|
|
1086
1072
|
return `${imports.join("\n")}
|
|
1087
1073
|
${v2 ? getV2Types() : ""}
|
|
1088
1074
|
|
|
1089
|
-
export const ${interfaceDef.shortApiName}: ${interfaceDef.shortApiName}
|
|
1075
|
+
export const ${interfaceDef.shortApiName}: ${interfaceDef.shortApiName} = {
|
|
1076
|
+
type: "interface",
|
|
1077
|
+
apiName: "${interfaceDef.fullApiName}",
|
|
1090
1078
|
osdkMetadata: $osdkMetadata,
|
|
1091
|
-
|
|
1092
|
-
props: undefined as any,
|
|
1093
|
-
linksType: undefined as any,
|
|
1094
|
-
strictProps: undefined as any,
|
|
1095
|
-
${stringify(definition, {
|
|
1096
|
-
osdkMetadata: () => void 0,
|
|
1097
|
-
properties: (properties) => `{
|
|
1098
|
-
${stringify(properties, {
|
|
1099
|
-
"*": (propertyDefinition, _, key) => [`"${maybeStripNamespace2(key)}"`, _(propertyDefinition)]
|
|
1100
|
-
})}
|
|
1101
|
-
}`
|
|
1102
|
-
})}
|
|
1103
|
-
|
|
1104
|
-
};`;
|
|
1079
|
+
};`;
|
|
1105
1080
|
}
|
|
1106
1081
|
|
|
1107
1082
|
// src/v2.0/generateClientSdkVersionTwoPointZero.ts
|