@osdk/generator 2.0.0-beta.6 → 2.0.0-beta.8
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 +27 -0
- package/build/browser/index.js +92 -152
- package/build/browser/index.js.map +1 -1
- package/build/cjs/GenerateContext/EnhancedAction.d.cts +5 -5
- package/build/cjs/GenerateContext/EnhancedAction.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedBase.d.cts +2 -2
- package/build/cjs/GenerateContext/EnhancedBase.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedInterfaceType.d.cts +4 -4
- package/build/cjs/GenerateContext/EnhancedInterfaceType.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedObjectType.d.cts +3 -3
- package/build/cjs/GenerateContext/EnhancedObjectType.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedOntologyDefinition.d.cts +7 -7
- package/build/cjs/GenerateContext/EnhancedOntologyDefinition.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedQuery.d.cts +5 -5
- package/build/cjs/GenerateContext/EnhancedQuery.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedSharedPropertyType.d.cts +3 -3
- package/build/cjs/GenerateContext/EnhancedSharedPropertyType.d.ts.map +1 -1
- package/build/cjs/WireOntologyDefinition.d.cts +2 -2
- package/build/cjs/WireOntologyDefinition.d.ts.map +1 -1
- package/build/cjs/index.cjs +92 -153
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/shared/getEditedEntities.d.cts +1 -1
- package/build/cjs/shared/getEditedEntities.d.ts.map +1 -1
- package/build/cjs/shared/getObjectImports.d.ts.map +1 -1
- package/build/cjs/shared/getObjectTypeApiNamesFromQuery.d.cts +1 -1
- package/build/cjs/shared/getObjectTypeApiNamesFromQuery.d.ts.map +1 -1
- package/build/cjs/shared/getObjectTypesFromQueryDataType.d.cts +1 -1
- package/build/cjs/shared/getObjectTypesFromQueryDataType.d.ts.map +1 -1
- package/build/cjs/shared/isNullableQueryDataType.d.cts +1 -1
- package/build/cjs/shared/isNullableQueryDataType.d.ts.map +1 -1
- package/build/cjs/shared/wireActionTypeV2ToSdkActionDefinition.d.cts +1 -1
- package/build/cjs/shared/wireActionTypeV2ToSdkActionDefinition.d.ts.map +1 -1
- package/build/cjs/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.cts +1 -1
- package/build/cjs/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map +1 -1
- package/build/cjs/shared/wireQueryTypeV2ToSdkQueryDefinition.d.cts +4 -4
- package/build/cjs/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts.map +1 -1
- package/build/cjs/util/test/TodoWireOntology.d.cts +14 -0
- package/build/cjs/util/test/TodoWireOntology.d.ts.map +1 -1
- package/build/cjs/util/test/formatTs.d.ts.map +1 -1
- package/build/cjs/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/cjs/v2.0/generatePerActionDataFiles.d.ts.map +1 -1
- package/build/cjs/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/cjs/v2.0/getDescriptionIfPresent.d.cts +2 -0
- package/build/cjs/v2.0/getDescriptionIfPresent.d.ts.map +1 -0
- package/build/cjs/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedAction.d.ts +5 -5
- package/build/esm/GenerateContext/EnhancedAction.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedBase.d.ts +2 -2
- package/build/esm/GenerateContext/EnhancedBase.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedInterfaceType.d.ts +4 -4
- package/build/esm/GenerateContext/EnhancedInterfaceType.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedObjectType.d.ts +3 -3
- package/build/esm/GenerateContext/EnhancedObjectType.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.d.ts +7 -7
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedQuery.d.ts +5 -5
- package/build/esm/GenerateContext/EnhancedQuery.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedSharedPropertyType.d.ts +3 -3
- package/build/esm/GenerateContext/EnhancedSharedPropertyType.d.ts.map +1 -1
- package/build/esm/WireOntologyDefinition.d.ts +2 -2
- package/build/esm/WireOntologyDefinition.d.ts.map +1 -1
- package/build/esm/index.js +92 -152
- package/build/esm/index.js.map +1 -1
- package/build/esm/shared/getEditedEntities.d.ts +1 -1
- package/build/esm/shared/getEditedEntities.d.ts.map +1 -1
- package/build/esm/shared/getObjectImports.d.ts.map +1 -1
- package/build/esm/shared/getObjectTypeApiNamesFromQuery.d.ts +1 -1
- package/build/esm/shared/getObjectTypeApiNamesFromQuery.d.ts.map +1 -1
- package/build/esm/shared/getObjectTypesFromQueryDataType.d.ts +1 -1
- package/build/esm/shared/getObjectTypesFromQueryDataType.d.ts.map +1 -1
- package/build/esm/shared/isNullableQueryDataType.d.ts +1 -1
- package/build/esm/shared/isNullableQueryDataType.d.ts.map +1 -1
- package/build/esm/shared/wireActionTypeV2ToSdkActionDefinition.d.ts +1 -1
- package/build/esm/shared/wireActionTypeV2ToSdkActionDefinition.d.ts.map +1 -1
- package/build/esm/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts +1 -1
- package/build/esm/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map +1 -1
- package/build/esm/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts +4 -4
- package/build/esm/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts.map +1 -1
- package/build/esm/util/test/TodoWireOntology.d.ts +14 -0
- package/build/esm/util/test/TodoWireOntology.d.ts.map +1 -1
- package/build/esm/util/test/formatTs.d.ts.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.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/getDescriptionIfPresent.d.ts +2 -0
- package/build/esm/v2.0/getDescriptionIfPresent.d.ts.map +1 -0
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/package.json +6 -7
- package/build/cjs/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.d.cts +0 -4
- package/build/cjs/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.d.ts.map +0 -1
- package/build/esm/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.d.ts +0 -4
- package/build/esm/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.d.ts.map +0 -1
package/build/esm/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import * as path5 from 'path';
|
|
|
3
3
|
import path5__default from 'path';
|
|
4
4
|
import { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition, wireObjectTypeFullMetadataToSdkObjectTypeDefinition } from '@osdk/generator-converters';
|
|
5
5
|
import { format } from 'prettier';
|
|
6
|
-
import organizeImports from 'prettier-plugin-organize-imports';
|
|
7
6
|
import fastDeepEqual from 'fast-deep-equal';
|
|
8
7
|
import invariant from 'tiny-invariant';
|
|
9
8
|
|
|
@@ -41,9 +40,9 @@ var AbstractImportable = class {
|
|
|
41
40
|
};
|
|
42
41
|
};
|
|
43
42
|
var EnhancedBase = class extends AbstractImportable {
|
|
44
|
-
constructor(common,
|
|
43
|
+
constructor(common, raw, fullApiName, basePath) {
|
|
45
44
|
super(common, fullApiName, basePath);
|
|
46
|
-
this.
|
|
45
|
+
this.raw = raw;
|
|
47
46
|
if (!this.isLocal && !this.sourcePackage) {
|
|
48
47
|
throw new Error(`Expected { ns:'${this.apiNamespace}', shortName: '${this.shortApiName}'} to be in namespace '${common.ontologyApiNamespace}' or in a provided package mapping`);
|
|
49
48
|
}
|
|
@@ -57,18 +56,18 @@ function extractNamespace(fqApiName) {
|
|
|
57
56
|
|
|
58
57
|
// src/GenerateContext/EnhancedAction.ts
|
|
59
58
|
var EnhancedAction = class extends EnhancedBase {
|
|
60
|
-
constructor(common,
|
|
61
|
-
super(common,
|
|
62
|
-
this.
|
|
59
|
+
constructor(common, raw) {
|
|
60
|
+
super(common, raw, raw.apiName, "./ontology/actions");
|
|
61
|
+
this.raw = raw;
|
|
63
62
|
}
|
|
64
63
|
get description() {
|
|
65
|
-
return this.
|
|
64
|
+
return this.raw.description;
|
|
66
65
|
}
|
|
67
66
|
get parameters() {
|
|
68
|
-
return this.
|
|
67
|
+
return this.raw.parameters;
|
|
69
68
|
}
|
|
70
69
|
get operations() {
|
|
71
|
-
return this.
|
|
70
|
+
return this.raw.operations;
|
|
72
71
|
}
|
|
73
72
|
get paramsIdentifier() {
|
|
74
73
|
return `${this.shortApiName}.Params`;
|
|
@@ -88,9 +87,9 @@ function deleteUndefineds(obj) {
|
|
|
88
87
|
|
|
89
88
|
// src/GenerateContext/EnhancedInterfaceType.ts
|
|
90
89
|
var EnhancedInterfaceType = class extends EnhancedBase {
|
|
91
|
-
constructor(common,
|
|
92
|
-
super(common,
|
|
93
|
-
this.
|
|
90
|
+
constructor(common, raw) {
|
|
91
|
+
super(common, raw, raw.apiName, "./ontology/interfaces");
|
|
92
|
+
this.raw = raw;
|
|
94
93
|
}
|
|
95
94
|
getDefinitionIdentifier(v2) {
|
|
96
95
|
return v2 ? this.shortApiName : `${this.shortApiName}Def`;
|
|
@@ -99,16 +98,16 @@ var EnhancedInterfaceType = class extends EnhancedBase {
|
|
|
99
98
|
return this.getDefinitionIdentifier(v2);
|
|
100
99
|
}
|
|
101
100
|
get properties() {
|
|
102
|
-
return this.
|
|
101
|
+
return this.raw.properties;
|
|
103
102
|
}
|
|
104
103
|
getCleanedUpDefinition(v2) {
|
|
105
|
-
return deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(this.
|
|
104
|
+
return deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(this.raw, v2));
|
|
106
105
|
}
|
|
107
106
|
};
|
|
108
107
|
var EnhancedObjectType = class extends EnhancedBase {
|
|
109
|
-
constructor(common,
|
|
110
|
-
super(common,
|
|
111
|
-
this.
|
|
108
|
+
constructor(common, raw) {
|
|
109
|
+
super(common, raw, raw.objectType.apiName, "./ontology/objects");
|
|
110
|
+
this.raw = raw;
|
|
112
111
|
}
|
|
113
112
|
getDefinitionIdentifier(v2) {
|
|
114
113
|
return v2 ? `${this.shortApiName}` : `${this.shortApiName}Def`;
|
|
@@ -117,24 +116,24 @@ var EnhancedObjectType = class extends EnhancedBase {
|
|
|
117
116
|
return this.getDefinitionIdentifier(v2);
|
|
118
117
|
}
|
|
119
118
|
getCleanedUpDefinition(v2) {
|
|
120
|
-
return deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(this.
|
|
119
|
+
return deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(this.raw, v2));
|
|
121
120
|
}
|
|
122
121
|
};
|
|
123
122
|
|
|
124
123
|
// src/GenerateContext/EnhancedQuery.ts
|
|
125
124
|
var EnhancedQuery = class extends EnhancedBase {
|
|
126
|
-
constructor(common,
|
|
127
|
-
super(common,
|
|
128
|
-
this.
|
|
125
|
+
constructor(common, raw) {
|
|
126
|
+
super(common, raw, raw.apiName, "./ontology/queries");
|
|
127
|
+
this.raw = raw;
|
|
129
128
|
}
|
|
130
129
|
get description() {
|
|
131
|
-
return this.
|
|
130
|
+
return this.raw.description;
|
|
132
131
|
}
|
|
133
132
|
get parameters() {
|
|
134
|
-
return this.
|
|
133
|
+
return this.raw.parameters;
|
|
135
134
|
}
|
|
136
135
|
get output() {
|
|
137
|
-
return this.
|
|
136
|
+
return this.raw.output;
|
|
138
137
|
}
|
|
139
138
|
get paramsIdentifier() {
|
|
140
139
|
return `${this.shortApiName}.Parameters`;
|
|
@@ -149,9 +148,9 @@ var EnhancedQuery = class extends EnhancedBase {
|
|
|
149
148
|
|
|
150
149
|
// src/GenerateContext/EnhancedSharedPropertyType.ts
|
|
151
150
|
var EnhancedSharedPropertyType = class extends EnhancedBase {
|
|
152
|
-
constructor(common,
|
|
153
|
-
super(common,
|
|
154
|
-
this.
|
|
151
|
+
constructor(common, raw) {
|
|
152
|
+
super(common, raw, raw.apiName, "./ontology/interfaces");
|
|
153
|
+
this.raw = raw;
|
|
155
154
|
}
|
|
156
155
|
};
|
|
157
156
|
|
|
@@ -176,20 +175,21 @@ var ForeignType = class extends AbstractImportable {
|
|
|
176
175
|
|
|
177
176
|
// src/GenerateContext/EnhancedOntologyDefinition.ts
|
|
178
177
|
var EnhancedOntologyDefinition = class {
|
|
179
|
-
|
|
178
|
+
#foreignTypes = {};
|
|
179
|
+
constructor(raw, ontologyApiNamespace, apiNamespacePackageMap, importExt) {
|
|
180
180
|
this.common = {
|
|
181
181
|
apiNamespacePackageMap,
|
|
182
182
|
enhancedOntology: this,
|
|
183
183
|
importExt,
|
|
184
184
|
ontologyApiNamespace
|
|
185
185
|
};
|
|
186
|
-
this.
|
|
187
|
-
this.ontology =
|
|
188
|
-
this.objectTypes = remap(
|
|
189
|
-
this.actionTypes = remap(
|
|
190
|
-
this.queryTypes = remap(
|
|
191
|
-
this.interfaceTypes = remap(
|
|
192
|
-
this.sharedPropertyTypes = remap(
|
|
186
|
+
this.raw = raw;
|
|
187
|
+
this.ontology = raw.ontology;
|
|
188
|
+
this.objectTypes = remap(raw.objectTypes, this.common, EnhancedObjectType);
|
|
189
|
+
this.actionTypes = remap(raw.actionTypes, this.common, EnhancedAction);
|
|
190
|
+
this.queryTypes = remap(raw.queryTypes, this.common, EnhancedQuery);
|
|
191
|
+
this.interfaceTypes = remap(raw.interfaceTypes, this.common, EnhancedInterfaceType);
|
|
192
|
+
this.sharedPropertyTypes = remap(raw.sharedPropertyTypes, this.common, EnhancedSharedPropertyType);
|
|
193
193
|
}
|
|
194
194
|
#createRequireType = (type) => {
|
|
195
195
|
return (fullApiName, localOnly) => {
|
|
@@ -202,7 +202,9 @@ var EnhancedOntologyDefinition = class {
|
|
|
202
202
|
if (!this.common.apiNamespacePackageMap.has(apiNamespace)) {
|
|
203
203
|
throw new Error(`Unable to find ${type}: Unknown namespace '${apiNamespace}'`);
|
|
204
204
|
}
|
|
205
|
-
|
|
205
|
+
const ret2 = this.#foreignTypes[fullApiName] ?? new ForeignType(this.common, type, apiNamespace, shortApiName);
|
|
206
|
+
this.#foreignTypes[fullApiName] = ret2;
|
|
207
|
+
return ret2;
|
|
206
208
|
}
|
|
207
209
|
return ret;
|
|
208
210
|
};
|
|
@@ -245,7 +247,6 @@ function formatTs(contents) {
|
|
|
245
247
|
parser: "typescript",
|
|
246
248
|
singleQuote: true,
|
|
247
249
|
trailingComma: "all",
|
|
248
|
-
plugins: [organizeImports],
|
|
249
250
|
tabWidth: 2,
|
|
250
251
|
printWidth: 120
|
|
251
252
|
});
|
|
@@ -288,7 +289,10 @@ async function generateOntologyMetadataFile({
|
|
|
288
289
|
// src/shared/getObjectImports.ts
|
|
289
290
|
function getObjectImports(objects, curApiName, currentFilePath, v2) {
|
|
290
291
|
return Array.from(objects).filter((obj) => obj.fullApiName !== curApiName).map((obj) => {
|
|
291
|
-
|
|
292
|
+
const defId = obj.getDefinitionIdentifier(v2);
|
|
293
|
+
const importedId = obj.getImportedDefinitionIdentifier(v2);
|
|
294
|
+
const nameOrAlias = defId === importedId ? defId : `${defId} as ${importedId}`;
|
|
295
|
+
return `import type { ${nameOrAlias} } from "${obj.getImportPathRelTo("./" + currentFilePath)}";`;
|
|
292
296
|
}).join("\n");
|
|
293
297
|
}
|
|
294
298
|
|
|
@@ -411,7 +415,7 @@ function stringUnionFrom(values) {
|
|
|
411
415
|
}
|
|
412
416
|
}
|
|
413
417
|
|
|
414
|
-
// src/
|
|
418
|
+
// src/v2.0/getDescriptionIfPresent.ts
|
|
415
419
|
function getDescriptionIfPresent(description, includeNewline) {
|
|
416
420
|
if (description) {
|
|
417
421
|
return `/**
|
|
@@ -460,7 +464,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
460
464
|
}, currentFilePath) {
|
|
461
465
|
const object = ontology.requireObjectType(wireObject.objectType.apiName, true);
|
|
462
466
|
const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map((a) => ontology.requireObjectType(a.objectTypeApiName, false)));
|
|
463
|
-
const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object.
|
|
467
|
+
const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object.raw, true));
|
|
464
468
|
const objectDefIdentifier = object.getDefinitionIdentifier(true);
|
|
465
469
|
const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;
|
|
466
470
|
const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;
|
|
@@ -469,7 +473,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
469
473
|
const osdkObjectLinksIdentifier = `${object.shortApiName}.Links`;
|
|
470
474
|
const osdkObjectIdentifier = `${object.shortApiName}.OsdkObject`;
|
|
471
475
|
const identifiers = {
|
|
472
|
-
objectDefIdentifier: `${object.shortApiName}
|
|
476
|
+
objectDefIdentifier: `${object.shortApiName}`,
|
|
473
477
|
osdkObjectLinksIdentifier,
|
|
474
478
|
osdkObjectPropsIdentifier,
|
|
475
479
|
osdkObjectStrictPropsIdentifier,
|
|
@@ -479,42 +483,18 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
479
483
|
};
|
|
480
484
|
function getV2Types() {
|
|
481
485
|
return `import type {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
DefaultToFalse as $DefaultToFalse,
|
|
488
|
-
FetchPageArgs as $FetchPageArgs,
|
|
489
|
-
FetchPageResult as $FetchPageResult,
|
|
490
|
-
IsAny as $IsAny,
|
|
491
|
-
LinkedType as $LinkedType,
|
|
492
|
-
LinkNames as $LinkNames,
|
|
493
|
-
NullabilityAdherence as $NullabilityAdherence,
|
|
494
|
-
NullabilityAdherenceDefault as $NullabilityAdherenceDefault,
|
|
486
|
+
ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
|
|
487
|
+
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
488
|
+
ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
|
|
489
|
+
} from "@osdk/api";
|
|
490
|
+
import type {
|
|
495
491
|
ObjectSet as $ObjectSet,
|
|
496
492
|
Osdk as $Osdk,
|
|
497
493
|
OsdkObject as $OsdkObject,
|
|
498
|
-
OsdkObjectLinksEntry as $OsdkObjectLinksEntry,
|
|
499
|
-
OsdkObjectLinksObject as $OsdkObjectLinksObject,
|
|
500
|
-
OsdkObjectPropertyType as $OsdkObjectPropertyType,
|
|
501
|
-
PageResult as $PageResult,
|
|
502
|
-
PropertyValueClientToWire as $PropertyValueClientToWire,
|
|
503
494
|
PropertyValueWireToClient as $PropType,
|
|
504
|
-
Result as $Result,
|
|
505
|
-
SelectArg as $SelectArg,
|
|
506
495
|
SingleLinkAccessor as $SingleLinkAccessor,
|
|
507
|
-
SingleLinkAccessor as $SingleLinkAccessor
|
|
508
|
-
SingleOsdkResult as $SingleOsdkResult,
|
|
509
|
-
ValidToFrom as $ValidToFrom,
|
|
510
|
-
WhereClause as $WhereClause,
|
|
511
496
|
} from "@osdk/client.api";
|
|
512
|
-
|
|
513
|
-
import type {
|
|
514
|
-
ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
|
|
515
|
-
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
516
|
-
ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
|
|
517
|
-
} from "@osdk/api";
|
|
497
|
+
|
|
518
498
|
|
|
519
499
|
export namespace ${object.shortApiName} {
|
|
520
500
|
|
|
@@ -527,16 +507,15 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
527
507
|
${createProps(object, "StrictProps", true)}
|
|
528
508
|
|
|
529
509
|
${createObjectSet(object, identifiers)}
|
|
530
|
-
|
|
531
|
-
${createDefinition(object, ontology, "Definition", identifiers)}
|
|
510
|
+
|
|
532
511
|
${createOsdkObject(object, "OsdkObject", identifiers)}
|
|
533
512
|
}
|
|
534
513
|
|
|
535
514
|
|
|
536
515
|
|
|
537
|
-
|
|
516
|
+
${createDefinition(object, ontology, object.shortApiName, identifiers)}
|
|
517
|
+
|
|
538
518
|
|
|
539
|
-
export type ${objectDefIdentifier} = ${object.shortApiName}.Definition;
|
|
540
519
|
|
|
541
520
|
|
|
542
521
|
`;
|
|
@@ -658,7 +637,7 @@ function createLinks(ontology, object, identifier) {
|
|
|
658
637
|
${stringify(definition.links, {
|
|
659
638
|
"*": (definition2, _, key) => {
|
|
660
639
|
const linkTarget = ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(true);
|
|
661
|
-
return [`readonly ${key}`, `${definition2.multiplicity ? `${linkTarget}.ObjectSet` : `$SingleLinkAccessor<${linkTarget}
|
|
640
|
+
return [`readonly ${key}`, `${definition2.multiplicity ? `${linkTarget}.ObjectSet` : `$SingleLinkAccessor<${linkTarget}>`}
|
|
662
641
|
`];
|
|
663
642
|
}
|
|
664
643
|
})}
|
|
@@ -683,10 +662,10 @@ async function generatePerActionDataFiles({
|
|
|
683
662
|
});
|
|
684
663
|
await Promise.all(Object.values(enhancedOntology.actionTypes).map(async (action) => {
|
|
685
664
|
const currentFilePath = `${path5__default.join("ontology", "actions", `${action.shortApiName}.ts`)}`;
|
|
686
|
-
const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.
|
|
665
|
+
const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.raw);
|
|
687
666
|
const uniqueApiNames = new Set(uniqueApiNamesArray);
|
|
688
667
|
const uniqueApiNamesString = stringUnionFrom([...uniqueApiNames]);
|
|
689
|
-
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action.
|
|
668
|
+
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action.raw));
|
|
690
669
|
const {
|
|
691
670
|
parameters,
|
|
692
671
|
...actionDefSansParameters
|
|
@@ -710,9 +689,9 @@ async function generatePerActionDataFiles({
|
|
|
710
689
|
return JSON.stringify(type);
|
|
711
690
|
} else if (type.type === "object") {
|
|
712
691
|
const obj = enhancedOntology.requireObjectType(type.object);
|
|
713
|
-
return `ObjectActionDataType<"${obj.fullApiName}", ${obj.getImportedDefinitionIdentifier(true)}
|
|
692
|
+
return `ObjectActionDataType<"${obj.fullApiName}", ${obj.getImportedDefinitionIdentifier(true)}>`;
|
|
714
693
|
} else if (type.type === "objectSet") {
|
|
715
|
-
return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, true)}
|
|
694
|
+
return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, true)}>`;
|
|
716
695
|
}
|
|
717
696
|
return void 0;
|
|
718
697
|
}
|
|
@@ -725,13 +704,17 @@ async function generatePerActionDataFiles({
|
|
|
725
704
|
if (typeof input === "string") {
|
|
726
705
|
return `ActionParam.PrimitiveType<${JSON.stringify(input)}>`;
|
|
727
706
|
} else if (input.type === "object") {
|
|
728
|
-
return `ActionParam.ObjectType<${enhancedOntology.requireObjectType(input.object).getImportedDefinitionIdentifier(true)}
|
|
707
|
+
return `ActionParam.ObjectType<${enhancedOntology.requireObjectType(input.object).getImportedDefinitionIdentifier(true)}>`;
|
|
729
708
|
} else if (input.type === "objectSet") {
|
|
730
|
-
return `ActionParam.ObjectSetType<${enhancedOntology.requireObjectType(input.objectSet).getImportedDefinitionIdentifier(true)}
|
|
709
|
+
return `ActionParam.ObjectSetType<${enhancedOntology.requireObjectType(input.objectSet).getImportedDefinitionIdentifier(true)}>`;
|
|
731
710
|
}
|
|
732
711
|
}
|
|
733
712
|
function createV2Types() {
|
|
734
|
-
|
|
713
|
+
`${action.shortApiName}$Params`;
|
|
714
|
+
let jsDocBlock = ["/**"];
|
|
715
|
+
if (action.description != null) {
|
|
716
|
+
jsDocBlock.push(`* ${action.description}`);
|
|
717
|
+
}
|
|
735
718
|
return `
|
|
736
719
|
|
|
737
720
|
export namespace ${action.shortApiName}{
|
|
@@ -744,12 +727,11 @@ async function generatePerActionDataFiles({
|
|
|
744
727
|
const key = `${getDescriptionIfPresent(ogValue.description)}
|
|
745
728
|
readonly "${ogKey}"${ogValue.nullable ? "?" : ""}`;
|
|
746
729
|
const value = ogValue.multiplicity ? `ReadonlyArray<${getActionParamType(ogValue.type)}>` : `${getActionParamType(ogValue.type)}`;
|
|
730
|
+
jsDocBlock.push(`* @param {${getActionParamType(ogValue.type)}} ${ogValue.nullable ? `[${ogKey}]` : `${ogKey}`} ${ogValue.description ?? ""} `);
|
|
747
731
|
return [key, value];
|
|
748
732
|
}
|
|
749
733
|
})}
|
|
750
734
|
}
|
|
751
|
-
/** @deprecated **/
|
|
752
|
-
export type Parameters = Params;
|
|
753
735
|
|
|
754
736
|
|
|
755
737
|
// Represents the definition of the action
|
|
@@ -771,12 +753,8 @@ async function generatePerActionDataFiles({
|
|
|
771
753
|
|
|
772
754
|
}
|
|
773
755
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
*/
|
|
777
|
-
export type ${oldParamsIdentifier} = ${action.paramsIdentifier} | ReadonlyArray<${action.paramsIdentifier}>;
|
|
778
|
-
|
|
779
|
-
/** @deprecated Use \`${action.definitionIdentifier}\` **/
|
|
756
|
+
${jsDocBlock.join("\n")}
|
|
757
|
+
*/
|
|
780
758
|
export type ${action.shortApiName} = ${action.shortApiName}.Signatures;
|
|
781
759
|
`;
|
|
782
760
|
}
|
|
@@ -810,9 +788,9 @@ async function generatePerActionDataFiles({
|
|
|
810
788
|
const imports = getObjectImports(referencedObjectDefs, void 0, currentFilePath, true);
|
|
811
789
|
await fs2.writeFile(path5__default.join(rootOutDir, currentFilePath), await formatTs(`
|
|
812
790
|
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound} from "@osdk/api";
|
|
813
|
-
import type {
|
|
814
|
-
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
791
|
+
import type { ActionParam, ActionReturnTypeForOptions, ApplyActionOptions, ApplyBatchActionOptions, } from '@osdk/client.api';
|
|
815
792
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
793
|
+
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
816
794
|
${imports}
|
|
817
795
|
|
|
818
796
|
|
|
@@ -846,6 +824,7 @@ function extractReferencedObjectsFromAction(actionType) {
|
|
|
846
824
|
case "deleteObject":
|
|
847
825
|
case "createLink":
|
|
848
826
|
case "deleteLink":
|
|
827
|
+
default:
|
|
849
828
|
return [];
|
|
850
829
|
}
|
|
851
830
|
});
|
|
@@ -1100,8 +1079,9 @@ async function generatePerQueryDataFilesV2({
|
|
|
1100
1079
|
async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ontology) {
|
|
1101
1080
|
const relFilePath = path5__default.join(relOutDir, `${query.shortApiName}.ts`);
|
|
1102
1081
|
const objectTypes = getObjectTypeApiNamesFromQuery(query);
|
|
1103
|
-
const
|
|
1104
|
-
const
|
|
1082
|
+
const objectTypeObjects = new Set(objectTypes.map((o) => ontology.requireObjectType(o)));
|
|
1083
|
+
const importObjects = getObjectImports(objectTypeObjects, "", relFilePath, true);
|
|
1084
|
+
const baseProps = deleteUndefineds(wireQueryTypeV2ToSdkQueryDefinitionNoParams(query.raw));
|
|
1105
1085
|
const outputBase = deleteUndefineds(wireQueryDataTypeToQueryDataTypeDefinition(query.output));
|
|
1106
1086
|
const referencedObjectTypes = objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never";
|
|
1107
1087
|
await fs2.writeFile(path5__default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
@@ -1207,15 +1187,6 @@ function queryParamJsDoc(param, {
|
|
|
1207
1187
|
`;
|
|
1208
1188
|
return ret;
|
|
1209
1189
|
}
|
|
1210
|
-
function getObjectImports2(enhancedOntology, objectTypes, filePath) {
|
|
1211
|
-
let ret = "";
|
|
1212
|
-
for (const fqObjectApiName of objectTypes) {
|
|
1213
|
-
const obj = enhancedOntology.requireObjectType(fqObjectApiName);
|
|
1214
|
-
ret += `import type { ${obj.getDefinitionIdentifier(true)} as ${obj.getImportedDefinitionIdentifier(true)} } from "${obj.getImportPathRelTo(filePath)}";
|
|
1215
|
-
`;
|
|
1216
|
-
}
|
|
1217
|
-
return ret;
|
|
1218
|
-
}
|
|
1219
1190
|
function getQueryParamType(enhancedOntology, input, type) {
|
|
1220
1191
|
let inner = `unknown /* ${input.type} */`;
|
|
1221
1192
|
switch (input.type) {
|
|
@@ -1256,11 +1227,11 @@ function getQueryParamType(enhancedOntology, input, type) {
|
|
|
1256
1227
|
return inner;
|
|
1257
1228
|
}
|
|
1258
1229
|
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false) {
|
|
1259
|
-
const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef.
|
|
1230
|
+
const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef.raw, v2));
|
|
1260
1231
|
const objectDefIdentifier = interfaceDef.getDefinitionIdentifier(v2);
|
|
1261
1232
|
const parents = definition.implements?.map((p) => {
|
|
1262
1233
|
!(ontology.interfaceTypes[p] != null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Expected to find a parent interface named ${p} in the ontology and did not.`) : invariant(false) : void 0;
|
|
1263
|
-
const it = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.requireInterfaceType(p, true).
|
|
1234
|
+
const it = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.requireInterfaceType(p, true).raw, v2));
|
|
1264
1235
|
return it;
|
|
1265
1236
|
}) ?? [];
|
|
1266
1237
|
const mergedProperties = {
|
|
@@ -1301,43 +1272,15 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology,
|
|
|
1301
1272
|
propertyKeysIdentifier
|
|
1302
1273
|
};
|
|
1303
1274
|
function getV2Types() {
|
|
1304
|
-
return `import type {
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
Augments as $Augments,
|
|
1309
|
-
ConvertProps as $ConvertProps,
|
|
1310
|
-
DefaultToFalse as $DefaultToFalse,
|
|
1311
|
-
FetchPageArgs as $FetchPageArgs,
|
|
1312
|
-
FetchPageResult as $FetchPageResult,
|
|
1313
|
-
IsAny as $IsAny,
|
|
1314
|
-
LinkedType as $LinkedType,
|
|
1315
|
-
LinkNames as $LinkNames,
|
|
1316
|
-
NullabilityAdherence as $NullabilityAdherence,
|
|
1317
|
-
NullabilityAdherenceDefault as $NullabilityAdherenceDefault,
|
|
1275
|
+
return ` import type {
|
|
1276
|
+
InterfaceDefinition as $InterfaceDefinition,
|
|
1277
|
+
} from "@osdk/api";
|
|
1278
|
+
import type {
|
|
1318
1279
|
ObjectSet as $ObjectSet,
|
|
1319
1280
|
Osdk as $Osdk,
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
OsdkObjectPropertyType as $OsdkObjectPropertyType,
|
|
1324
|
-
PageResult as $PageResult,
|
|
1325
|
-
PropertyValueClientToWire as $PropertyValueClientToWire,
|
|
1326
|
-
PropertyValueWireToClient as $PropType,
|
|
1327
|
-
Result as $Result,
|
|
1328
|
-
SelectArg as $SelectArg,
|
|
1329
|
-
SingleLinkAccessor as $SingleLinkAccessor,
|
|
1330
|
-
SingleOsdkResult as $SingleOsdkResult,
|
|
1331
|
-
ValidToFrom as $ValidToFrom,
|
|
1332
|
-
WhereClause as $WhereClause,
|
|
1333
|
-
} from "@osdk/client.api";
|
|
1334
|
-
import type * as $clientApi from "@osdk/client.api";
|
|
1335
|
-
import type {
|
|
1336
|
-
ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
|
|
1337
|
-
ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
|
|
1338
|
-
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
1339
|
-
InterfaceDefinition as $InterfaceDefinition,
|
|
1340
|
-
} from "@osdk/api";
|
|
1281
|
+
PropertyValueWireToClient as $PropType, } from "@osdk/client.api";
|
|
1282
|
+
|
|
1283
|
+
|
|
1341
1284
|
|
|
1342
1285
|
|
|
1343
1286
|
|
|
@@ -1410,15 +1353,15 @@ async function generateRootIndexTsFile({
|
|
|
1410
1353
|
importExt,
|
|
1411
1354
|
ontologyApiNamespace
|
|
1412
1355
|
}) {
|
|
1413
|
-
fs2.writeFile(path5__default.join(outDir, "index.ts"), await formatTs(
|
|
1414
|
-
export * from "./ontology/actions${importExt}";
|
|
1356
|
+
fs2.writeFile(path5__default.join(outDir, "index.ts"), await formatTs(`export * from "./ontology/actions${importExt}";
|
|
1415
1357
|
export * as $Actions from "./ontology/actions${importExt}";
|
|
1416
|
-
export * from "./ontology/objects${importExt}";
|
|
1417
|
-
export * as $Objects from "./ontology/objects${importExt}";
|
|
1418
1358
|
export * from "./ontology/interfaces${importExt}";
|
|
1419
1359
|
export * as $Interfaces from "./ontology/interfaces${importExt}";
|
|
1360
|
+
export * from "./ontology/objects${importExt}";
|
|
1361
|
+
export * as $Objects from "./ontology/objects${importExt}";
|
|
1420
1362
|
export * from "./ontology/queries${importExt}";
|
|
1421
1363
|
export * as $Queries from "./ontology/queries${importExt}";
|
|
1364
|
+
${ontologyApiNamespace == null ? `export { $ontologyRid } from "./OntologyMetadata${importExt}";` : ``}
|
|
1422
1365
|
`));
|
|
1423
1366
|
}
|
|
1424
1367
|
async function generateEachObjectFile(ctx) {
|
|
@@ -1435,11 +1378,10 @@ async function generateEachObjectFile(ctx) {
|
|
|
1435
1378
|
const relPath = path5__default.join(".", "ontology", `objects`, `${obj.shortApiName}.ts`);
|
|
1436
1379
|
const outFilePath = path5__default.join(outDir, relPath);
|
|
1437
1380
|
await fs2.writeFile(outFilePath, await formatTs(`
|
|
1438
|
-
import type {
|
|
1439
|
-
import type { Osdk } from "@osdk/client.api";
|
|
1381
|
+
import type { PropertyDef as $PropertyDef } from "@osdk/api";
|
|
1440
1382
|
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
|
|
1441
1383
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1442
|
-
${wireObjectTypeV2ToSdkObjectConstV2(obj.
|
|
1384
|
+
${wireObjectTypeV2ToSdkObjectConstV2(obj.raw, ctx, relPath)}
|
|
1443
1385
|
`));
|
|
1444
1386
|
}
|
|
1445
1387
|
}
|
|
@@ -1487,10 +1429,8 @@ async function generateOntologyInterfaces({
|
|
|
1487
1429
|
});
|
|
1488
1430
|
for (const obj of Object.values(ontology.interfaceTypes)) {
|
|
1489
1431
|
await fs2.writeFile(path5__default.join(interfacesDir, `${obj.shortApiName}.ts`), await formatTs(`
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
import { $osdkMetadata, $expectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1493
|
-
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1432
|
+
import type { PropertyDef as $PropertyDef } from "@osdk/api";
|
|
1433
|
+
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
|
|
1494
1434
|
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true)}
|
|
1495
1435
|
`));
|
|
1496
1436
|
}
|