@osdk/generator 2.0.0-beta.11 → 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 CHANGED
@@ -1,5 +1,35 @@
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
+
25
+ ## 2.0.0-beta.12
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [dc25fb4]
30
+ - @osdk/generator-converters@2.0.0-beta.12
31
+ - @osdk/api@2.0.0-beta.12
32
+
3
33
  ## 2.0.0-beta.11
4
34
 
5
35
  ### Patch Changes
@@ -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 { wireQueryTypeV2ToSdkQueryDefinitionNoParams, wireQueryDataTypeToQueryDataTypeDefinition, wireQueryParameterV2ToQueryParameterDefinition, __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition, wireObjectTypeFullMetadataToSdkObjectTypeDefinition } from '@osdk/generator-converters';
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(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(this.raw, v2));
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}.Definition`;
142
+ return `${this.shortApiName}`;
143
143
  }
144
144
  get definitionParamsIdentifier() {
145
145
  return `${this.definitionIdentifier}$Params`;
@@ -296,94 +296,6 @@ function getObjectImports(objects, curApiName, currentFilePath, v2) {
296
296
  }).join("\n");
297
297
  }
298
298
 
299
- // src/shared/getEditedEntities.ts
300
- function getModifiedEntityTypes(action) {
301
- const addedObjects = /* @__PURE__ */ new Set();
302
- const modifiedObjects = /* @__PURE__ */ new Set();
303
- for (const operation of action.operations) {
304
- switch (operation.type) {
305
- case "createObject":
306
- addedObjects.add(operation.objectTypeApiName);
307
- break;
308
- case "modifyObject":
309
- modifiedObjects.add(operation.objectTypeApiName);
310
- break;
311
- }
312
- }
313
- return {
314
- addedObjects,
315
- modifiedObjects
316
- };
317
- }
318
-
319
- // src/shared/wireActionTypeV2ToSdkActionDefinition.ts
320
- function wireActionTypeV2ToSdkActionDefinition(input) {
321
- const modifiedEntityTypes = getModifiedEntityTypes(input);
322
- return {
323
- type: "action",
324
- apiName: input.apiName,
325
- parameters: Object.fromEntries(Object.entries(input.parameters).map(([key, value]) => [key, wireActionParameterV2ToSdkParameterDefinition(value)])),
326
- displayName: input.displayName,
327
- description: input.description,
328
- modifiedEntities: createModifiedEntities(modifiedEntityTypes.addedObjects, modifiedEntityTypes.modifiedObjects)
329
- };
330
- }
331
- function wireActionParameterV2ToSdkParameterDefinition(value) {
332
- return {
333
- multiplicity: value.dataType.type === "array",
334
- type: actionPropertyToSdkPropertyDefinition(value.dataType.type === "array" ? value.dataType.subType : value.dataType),
335
- nullable: !value.required,
336
- description: value.description
337
- };
338
- }
339
- function actionPropertyToSdkPropertyDefinition(parameterType) {
340
- switch (parameterType.type) {
341
- case "string":
342
- case "boolean":
343
- case "attachment":
344
- case "double":
345
- case "integer":
346
- case "long":
347
- case "timestamp":
348
- case "marking":
349
- return parameterType.type;
350
- case "date":
351
- return "datetime";
352
- case "objectSet":
353
- return {
354
- type: "objectSet",
355
- objectSet: parameterType.objectTypeApiName
356
- };
357
- case "object":
358
- return {
359
- type: "object",
360
- object: parameterType.objectTypeApiName
361
- };
362
- case "array":
363
- return actionPropertyToSdkPropertyDefinition(parameterType.subType);
364
- }
365
- }
366
- function createModifiedEntities(addedObjects, modifiedObjects) {
367
- let entities = {};
368
- for (const key of addedObjects) {
369
- entities[key] = {
370
- created: true,
371
- modified: false
372
- };
373
- }
374
- for (const key of modifiedObjects) {
375
- if (entities[key]) {
376
- entities[key].modified = true;
377
- } else {
378
- entities[key] = {
379
- created: false,
380
- modified: true
381
- };
382
- }
383
- }
384
- return entities;
385
- }
386
-
387
299
  // src/util/stringify.ts
388
300
  var defaultCustomizer = (value, defaultValueFormatter, key, defaultKeyFormatter) => {
389
301
  return [defaultKeyFormatter(key), defaultValueFormatter(value)];
@@ -464,7 +376,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
464
376
  }, currentFilePath) {
465
377
  const object = ontology.requireObjectType(wireObject.objectType.apiName, true);
466
378
  const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map((a) => ontology.requireObjectType(a.objectTypeApiName, false)));
467
- const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object.raw, true));
379
+ const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectMetadata(object.raw, true));
468
380
  const objectDefIdentifier = object.getDefinitionIdentifier(true);
469
381
  const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;
470
382
  const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;
@@ -484,7 +396,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
484
396
  function getV2Types() {
485
397
  return `import type {
486
398
  ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
487
- MinObjectDef as $ObjectTypeDefinition,
399
+ ObjectTypeDefinition as $ObjectTypeDefinition,
488
400
  ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
489
401
  } from "@osdk/api";
490
402
  import type {
@@ -602,8 +514,6 @@ function createDefinition(object, ontology, identifier, {
602
514
  linksType: ${osdkObjectLinksIdentifier};
603
515
  strictProps: ${osdkObjectStrictPropsIdentifier};
604
516
  ${stringify(definition, {
605
- osdkMetadata: () => void 0,
606
- // we are going to reference another object instead
607
517
  links: (_value) => `{
608
518
  ${stringify(definition.links, {
609
519
  "*": (definition2) => `$ObjectTypeLinkDefinition<${ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(true)}, ${definition2.multiplicity}>`
@@ -657,7 +567,7 @@ async function generatePerActionDataFiles({
657
567
  const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.raw);
658
568
  const uniqueApiNames = new Set(uniqueApiNamesArray);
659
569
  const uniqueApiNamesString = stringUnionFrom([...uniqueApiNames]);
660
- const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action.raw));
570
+ const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionMetadata(action.raw));
661
571
  function createParamsDef() {
662
572
  const entries = Object.entries(fullActionDef.parameters ?? {});
663
573
  entries.sort((a, b) => a[0].localeCompare(b[0]));
@@ -734,7 +644,7 @@ async function generatePerActionDataFiles({
734
644
 
735
645
  ${jsDocBlock.join("\n")}
736
646
  */
737
- export interface ${action.shortApiName} extends MinActionDef<"${action.shortApiName}", ${uniqueApiNamesString}, ${action.shortApiName}.Signatures> {
647
+ export interface ${action.shortApiName} extends ActionDefinition<"${action.fullApiName}", ${uniqueApiNamesString}, ${action.shortApiName}.Signatures> {
738
648
  __DefinitionMetadata?: {
739
649
  ${stringify(fullActionDef, {
740
650
  "parameters": () => action.definitionParamsIdentifier
@@ -746,7 +656,9 @@ async function generatePerActionDataFiles({
746
656
  "description": () => void 0,
747
657
  "displayName": () => void 0,
748
658
  "modifiedEntities": () => void 0,
749
- "parameters": () => void 0
659
+ "parameters": () => void 0,
660
+ "rid": () => void 0,
661
+ "status": () => void 0
750
662
  })}
751
663
  osdkMetadata: typeof $osdkMetadata;
752
664
  }
@@ -759,7 +671,9 @@ async function generatePerActionDataFiles({
759
671
  "description": () => void 0,
760
672
  "displayName": () => void 0,
761
673
  "modifiedEntities": () => void 0,
762
- "parameters": () => void 0
674
+ "parameters": () => void 0,
675
+ "rid": () => void 0,
676
+ "status": () => void 0
763
677
  })},
764
678
  osdkMetadata: $osdkMetadata
765
679
  }
@@ -786,7 +700,7 @@ async function generatePerActionDataFiles({
786
700
  }
787
701
  const imports = getObjectImports(referencedObjectDefs, void 0, currentFilePath, true);
788
702
  await fs2.writeFile(path5__default.join(rootOutDir, currentFilePath), await formatTs(`
789
- import type { MinActionDef, ObjectActionDataType, ObjectSetActionDataType } from "@osdk/api";
703
+ import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from "@osdk/api";
790
704
  import type { ActionParam, ActionReturnTypeForOptions, ApplyActionOptions, ApplyBatchActionOptions, } from '@osdk/client.api';
791
705
  import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
792
706
  ${imports}
@@ -931,9 +845,10 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
931
845
  const outputBase = deleteUndefineds(wireQueryDataTypeToQueryDataTypeDefinition(query.output));
932
846
  const referencedObjectTypes = objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never";
933
847
  await fs2.writeFile(path5__default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
934
- import type { MinQueryDef , VersionBound} from "@osdk/api";
848
+ import type { QueryDefinition , VersionBound} from "@osdk/api";
935
849
  import type { QueryParam, QueryResult } from "@osdk/client.api";
936
850
  import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
851
+ import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
937
852
  ${importObjects}
938
853
 
939
854
  export namespace ${query.shortApiName} {
@@ -959,12 +874,17 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
959
874
 
960
875
  ` : ""}
961
876
 
962
- export interface Definition extends MinQueryDef<
877
+
878
+
879
+ }
880
+
881
+ export interface ${query.shortApiName} extends QueryDefinition<
963
882
  "${query.fullApiName}",
964
883
  ${referencedObjectTypes},
965
884
  ${query.shortApiName}.Signature
966
885
  >, VersionBound<$ExpectedClientVersion>{
967
- ${stringify(baseProps)},
886
+ __DefinitionMetadata?: {
887
+ ${stringify(baseProps)}
968
888
  parameters: {
969
889
  ${parameterDefsForType(ontology, query)}
970
890
  };
@@ -972,33 +892,27 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
972
892
  ${stringify(outputBase)},
973
893
  ${getLineFor__OsdkTargetType(ontology, query.output)}
974
894
  };
975
- }
976
-
977
- }
978
-
979
- /** @deprecated use \`${query.shortApiName}.Signature' instead */
980
- export type ${query.shortApiName} = ${query.shortApiName}.Signature;
981
-
982
-
983
-
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
+ }
984
904
 
985
905
 
986
906
  export const ${query.shortApiName}: ${query.definitionIdentifier} = {
987
- ${stringify(baseProps)},
988
- parameters: {
989
- ${parametersForConst(query)}
990
- },
991
- output: {
992
- ${stringify(outputBase)},
993
- }
907
+ ${stringify(baseProps, {
908
+ "description": () => void 0,
909
+ "displayName": () => void 0,
910
+ "rid": () => void 0
911
+ })},
912
+ osdkMetadata: $osdkMetadata
994
913
  };
995
914
  `));
996
915
  }
997
- function parametersForConst(query) {
998
- return stringify(query.parameters, {
999
- "*": (parameter, formatter) => formatter(deleteUndefineds(wireQueryParameterV2ToQueryParameterDefinition(parameter)))
1000
- });
1001
- }
1002
916
  function parameterDefsForType(ontology, query) {
1003
917
  return stringify(query.parameters, {
1004
918
  "*": (parameter, valueFormatter, apiName) => [`${queryParamJsDoc(wireQueryParameterV2ToQueryParameterDefinition(parameter), {
@@ -1095,13 +1009,6 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology,
1095
1009
  }
1096
1010
  definition.properties;
1097
1011
  definition.properties = mergedProperties;
1098
- function maybeStripNamespace2(q) {
1099
- if (interfaceDef.apiNamespace && q.startsWith(`${interfaceDef.apiNamespace}.`)) {
1100
- return q.slice(interfaceDef.apiNamespace.length + 1);
1101
- } else {
1102
- return q;
1103
- }
1104
- }
1105
1012
  const objectSetIdentifier = `${interfaceDef.shortApiName}.ObjectSet`;
1106
1013
  const propertyKeysIdentifier = `${interfaceDef.shortApiName}.PropertyKeys`;
1107
1014
  const osdkObjectPropsIdentifier = `${interfaceDef.shortApiName}.Props`;
@@ -1109,7 +1016,7 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology,
1109
1016
  const osdkObjectLinksIdentifier = `OsdkObjectLinks$${objectDefIdentifier}`;
1110
1017
  const osdkObjectIdentifier = `${interfaceDef.shortApiName}.OsdkObject`;
1111
1018
  const ids = {
1112
- objectDefIdentifier: `${interfaceDef.shortApiName}.Definition`,
1019
+ objectDefIdentifier: interfaceDef.shortApiName,
1113
1020
  osdkObjectLinksIdentifier,
1114
1021
  osdkObjectPropsIdentifier,
1115
1022
  osdkObjectStrictPropsIdentifier,
@@ -1153,20 +1060,11 @@ ${stringify(definition.links, {
1153
1060
 
1154
1061
  ${createObjectSet(interfaceDef, ids)}
1155
1062
 
1156
- ${createDefinition(interfaceDef, ontology, "Definition", ids)}
1157
-
1158
1063
  ${createOsdkObject(interfaceDef, "OsdkObject", ids)}
1159
1064
 
1160
1065
  }
1161
1066
 
1162
-
1163
-
1164
-
1165
- /** @deprecated use ${interfaceDef.shortApiName}.Definition **/
1166
- export type ${objectDefIdentifier} = ${interfaceDef.shortApiName}.Definition;
1167
-
1168
-
1169
-
1067
+ ${createDefinition(interfaceDef, ontology, interfaceDef.shortApiName, ids)}
1170
1068
 
1171
1069
  `;
1172
1070
  }
@@ -1174,22 +1072,11 @@ ${stringify(definition.links, {
1174
1072
  return `${imports.join("\n")}
1175
1073
  ${v2 ? getV2Types() : ""}
1176
1074
 
1177
- export const ${interfaceDef.shortApiName}: ${interfaceDef.shortApiName}.Definition = {
1075
+ export const ${interfaceDef.shortApiName}: ${interfaceDef.shortApiName} = {
1076
+ type: "interface",
1077
+ apiName: "${interfaceDef.fullApiName}",
1178
1078
  osdkMetadata: $osdkMetadata,
1179
- objectSet: undefined as any,
1180
- props: undefined as any,
1181
- linksType: undefined as any,
1182
- strictProps: undefined as any,
1183
- ${stringify(definition, {
1184
- osdkMetadata: () => void 0,
1185
- properties: (properties) => `{
1186
- ${stringify(properties, {
1187
- "*": (propertyDefinition, _, key) => [`"${maybeStripNamespace2(key)}"`, _(propertyDefinition)]
1188
- })}
1189
- }`
1190
- })}
1191
-
1192
- };`;
1079
+ };`;
1193
1080
  }
1194
1081
 
1195
1082
  // src/v2.0/generateClientSdkVersionTwoPointZero.ts