@osdk/generator 2.0.0-beta.6 → 2.0.0-beta.7
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 +15 -0
- package/build/browser/index.js +85 -151
- 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 +85 -152
- 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 +85 -151
- 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/cjs/index.cjs
CHANGED
|
@@ -4,7 +4,6 @@ var fs = require('fs');
|
|
|
4
4
|
var path5 = require('path');
|
|
5
5
|
var generatorConverters = require('@osdk/generator-converters');
|
|
6
6
|
var prettier = require('prettier');
|
|
7
|
-
var organizeImports = require('prettier-plugin-organize-imports');
|
|
8
7
|
var fastDeepEqual = require('fast-deep-equal');
|
|
9
8
|
var invariant = require('tiny-invariant');
|
|
10
9
|
|
|
@@ -30,7 +29,6 @@ function _interopNamespace(e) {
|
|
|
30
29
|
|
|
31
30
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
32
31
|
var path5__namespace = /*#__PURE__*/_interopNamespace(path5);
|
|
33
|
-
var organizeImports__default = /*#__PURE__*/_interopDefault(organizeImports);
|
|
34
32
|
var fastDeepEqual__default = /*#__PURE__*/_interopDefault(fastDeepEqual);
|
|
35
33
|
var invariant__default = /*#__PURE__*/_interopDefault(invariant);
|
|
36
34
|
|
|
@@ -68,9 +66,9 @@ var AbstractImportable = class {
|
|
|
68
66
|
};
|
|
69
67
|
};
|
|
70
68
|
var EnhancedBase = class extends AbstractImportable {
|
|
71
|
-
constructor(common,
|
|
69
|
+
constructor(common, raw, fullApiName, basePath) {
|
|
72
70
|
super(common, fullApiName, basePath);
|
|
73
|
-
this.
|
|
71
|
+
this.raw = raw;
|
|
74
72
|
if (!this.isLocal && !this.sourcePackage) {
|
|
75
73
|
throw new Error(`Expected { ns:'${this.apiNamespace}', shortName: '${this.shortApiName}'} to be in namespace '${common.ontologyApiNamespace}' or in a provided package mapping`);
|
|
76
74
|
}
|
|
@@ -84,18 +82,18 @@ function extractNamespace(fqApiName) {
|
|
|
84
82
|
|
|
85
83
|
// src/GenerateContext/EnhancedAction.ts
|
|
86
84
|
var EnhancedAction = class extends EnhancedBase {
|
|
87
|
-
constructor(common,
|
|
88
|
-
super(common,
|
|
89
|
-
this.
|
|
85
|
+
constructor(common, raw) {
|
|
86
|
+
super(common, raw, raw.apiName, "./ontology/actions");
|
|
87
|
+
this.raw = raw;
|
|
90
88
|
}
|
|
91
89
|
get description() {
|
|
92
|
-
return this.
|
|
90
|
+
return this.raw.description;
|
|
93
91
|
}
|
|
94
92
|
get parameters() {
|
|
95
|
-
return this.
|
|
93
|
+
return this.raw.parameters;
|
|
96
94
|
}
|
|
97
95
|
get operations() {
|
|
98
|
-
return this.
|
|
96
|
+
return this.raw.operations;
|
|
99
97
|
}
|
|
100
98
|
get paramsIdentifier() {
|
|
101
99
|
return `${this.shortApiName}.Params`;
|
|
@@ -115,9 +113,9 @@ function deleteUndefineds(obj) {
|
|
|
115
113
|
|
|
116
114
|
// src/GenerateContext/EnhancedInterfaceType.ts
|
|
117
115
|
var EnhancedInterfaceType = class extends EnhancedBase {
|
|
118
|
-
constructor(common,
|
|
119
|
-
super(common,
|
|
120
|
-
this.
|
|
116
|
+
constructor(common, raw) {
|
|
117
|
+
super(common, raw, raw.apiName, "./ontology/interfaces");
|
|
118
|
+
this.raw = raw;
|
|
121
119
|
}
|
|
122
120
|
getDefinitionIdentifier(v2) {
|
|
123
121
|
return v2 ? this.shortApiName : `${this.shortApiName}Def`;
|
|
@@ -126,16 +124,16 @@ var EnhancedInterfaceType = class extends EnhancedBase {
|
|
|
126
124
|
return this.getDefinitionIdentifier(v2);
|
|
127
125
|
}
|
|
128
126
|
get properties() {
|
|
129
|
-
return this.
|
|
127
|
+
return this.raw.properties;
|
|
130
128
|
}
|
|
131
129
|
getCleanedUpDefinition(v2) {
|
|
132
|
-
return deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(this.
|
|
130
|
+
return deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(this.raw, v2));
|
|
133
131
|
}
|
|
134
132
|
};
|
|
135
133
|
var EnhancedObjectType = class extends EnhancedBase {
|
|
136
|
-
constructor(common,
|
|
137
|
-
super(common,
|
|
138
|
-
this.
|
|
134
|
+
constructor(common, raw) {
|
|
135
|
+
super(common, raw, raw.objectType.apiName, "./ontology/objects");
|
|
136
|
+
this.raw = raw;
|
|
139
137
|
}
|
|
140
138
|
getDefinitionIdentifier(v2) {
|
|
141
139
|
return v2 ? `${this.shortApiName}` : `${this.shortApiName}Def`;
|
|
@@ -144,24 +142,24 @@ var EnhancedObjectType = class extends EnhancedBase {
|
|
|
144
142
|
return this.getDefinitionIdentifier(v2);
|
|
145
143
|
}
|
|
146
144
|
getCleanedUpDefinition(v2) {
|
|
147
|
-
return deleteUndefineds(generatorConverters.wireObjectTypeFullMetadataToSdkObjectTypeDefinition(this.
|
|
145
|
+
return deleteUndefineds(generatorConverters.wireObjectTypeFullMetadataToSdkObjectTypeDefinition(this.raw, v2));
|
|
148
146
|
}
|
|
149
147
|
};
|
|
150
148
|
|
|
151
149
|
// src/GenerateContext/EnhancedQuery.ts
|
|
152
150
|
var EnhancedQuery = class extends EnhancedBase {
|
|
153
|
-
constructor(common,
|
|
154
|
-
super(common,
|
|
155
|
-
this.
|
|
151
|
+
constructor(common, raw) {
|
|
152
|
+
super(common, raw, raw.apiName, "./ontology/queries");
|
|
153
|
+
this.raw = raw;
|
|
156
154
|
}
|
|
157
155
|
get description() {
|
|
158
|
-
return this.
|
|
156
|
+
return this.raw.description;
|
|
159
157
|
}
|
|
160
158
|
get parameters() {
|
|
161
|
-
return this.
|
|
159
|
+
return this.raw.parameters;
|
|
162
160
|
}
|
|
163
161
|
get output() {
|
|
164
|
-
return this.
|
|
162
|
+
return this.raw.output;
|
|
165
163
|
}
|
|
166
164
|
get paramsIdentifier() {
|
|
167
165
|
return `${this.shortApiName}.Parameters`;
|
|
@@ -176,9 +174,9 @@ var EnhancedQuery = class extends EnhancedBase {
|
|
|
176
174
|
|
|
177
175
|
// src/GenerateContext/EnhancedSharedPropertyType.ts
|
|
178
176
|
var EnhancedSharedPropertyType = class extends EnhancedBase {
|
|
179
|
-
constructor(common,
|
|
180
|
-
super(common,
|
|
181
|
-
this.
|
|
177
|
+
constructor(common, raw) {
|
|
178
|
+
super(common, raw, raw.apiName, "./ontology/interfaces");
|
|
179
|
+
this.raw = raw;
|
|
182
180
|
}
|
|
183
181
|
};
|
|
184
182
|
|
|
@@ -203,20 +201,21 @@ var ForeignType = class extends AbstractImportable {
|
|
|
203
201
|
|
|
204
202
|
// src/GenerateContext/EnhancedOntologyDefinition.ts
|
|
205
203
|
var EnhancedOntologyDefinition = class {
|
|
206
|
-
|
|
204
|
+
#foreignTypes = {};
|
|
205
|
+
constructor(raw, ontologyApiNamespace, apiNamespacePackageMap, importExt) {
|
|
207
206
|
this.common = {
|
|
208
207
|
apiNamespacePackageMap,
|
|
209
208
|
enhancedOntology: this,
|
|
210
209
|
importExt,
|
|
211
210
|
ontologyApiNamespace
|
|
212
211
|
};
|
|
213
|
-
this.
|
|
214
|
-
this.ontology =
|
|
215
|
-
this.objectTypes = remap(
|
|
216
|
-
this.actionTypes = remap(
|
|
217
|
-
this.queryTypes = remap(
|
|
218
|
-
this.interfaceTypes = remap(
|
|
219
|
-
this.sharedPropertyTypes = remap(
|
|
212
|
+
this.raw = raw;
|
|
213
|
+
this.ontology = raw.ontology;
|
|
214
|
+
this.objectTypes = remap(raw.objectTypes, this.common, EnhancedObjectType);
|
|
215
|
+
this.actionTypes = remap(raw.actionTypes, this.common, EnhancedAction);
|
|
216
|
+
this.queryTypes = remap(raw.queryTypes, this.common, EnhancedQuery);
|
|
217
|
+
this.interfaceTypes = remap(raw.interfaceTypes, this.common, EnhancedInterfaceType);
|
|
218
|
+
this.sharedPropertyTypes = remap(raw.sharedPropertyTypes, this.common, EnhancedSharedPropertyType);
|
|
220
219
|
}
|
|
221
220
|
#createRequireType = (type) => {
|
|
222
221
|
return (fullApiName, localOnly) => {
|
|
@@ -229,7 +228,9 @@ var EnhancedOntologyDefinition = class {
|
|
|
229
228
|
if (!this.common.apiNamespacePackageMap.has(apiNamespace)) {
|
|
230
229
|
throw new Error(`Unable to find ${type}: Unknown namespace '${apiNamespace}'`);
|
|
231
230
|
}
|
|
232
|
-
|
|
231
|
+
const ret2 = this.#foreignTypes[fullApiName] ?? new ForeignType(this.common, type, apiNamespace, shortApiName);
|
|
232
|
+
this.#foreignTypes[fullApiName] = ret2;
|
|
233
|
+
return ret2;
|
|
233
234
|
}
|
|
234
235
|
return ret;
|
|
235
236
|
};
|
|
@@ -272,7 +273,6 @@ function formatTs(contents) {
|
|
|
272
273
|
parser: "typescript",
|
|
273
274
|
singleQuote: true,
|
|
274
275
|
trailingComma: "all",
|
|
275
|
-
plugins: [organizeImports__default.default],
|
|
276
276
|
tabWidth: 2,
|
|
277
277
|
printWidth: 120
|
|
278
278
|
});
|
|
@@ -315,7 +315,10 @@ async function generateOntologyMetadataFile({
|
|
|
315
315
|
// src/shared/getObjectImports.ts
|
|
316
316
|
function getObjectImports(objects, curApiName, currentFilePath, v2) {
|
|
317
317
|
return Array.from(objects).filter((obj) => obj.fullApiName !== curApiName).map((obj) => {
|
|
318
|
-
|
|
318
|
+
const defId = obj.getDefinitionIdentifier(v2);
|
|
319
|
+
const importedId = obj.getImportedDefinitionIdentifier(v2);
|
|
320
|
+
const nameOrAlias = defId === importedId ? defId : `${defId} as ${importedId}`;
|
|
321
|
+
return `import type { ${nameOrAlias} } from "${obj.getImportPathRelTo("./" + currentFilePath)}";`;
|
|
319
322
|
}).join("\n");
|
|
320
323
|
}
|
|
321
324
|
|
|
@@ -438,7 +441,7 @@ function stringUnionFrom(values) {
|
|
|
438
441
|
}
|
|
439
442
|
}
|
|
440
443
|
|
|
441
|
-
// src/
|
|
444
|
+
// src/v2.0/getDescriptionIfPresent.ts
|
|
442
445
|
function getDescriptionIfPresent(description, includeNewline) {
|
|
443
446
|
if (description) {
|
|
444
447
|
return `/**
|
|
@@ -487,7 +490,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
487
490
|
}, currentFilePath) {
|
|
488
491
|
const object = ontology.requireObjectType(wireObject.objectType.apiName, true);
|
|
489
492
|
const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map((a) => ontology.requireObjectType(a.objectTypeApiName, false)));
|
|
490
|
-
const definition = deleteUndefineds(generatorConverters.wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object.
|
|
493
|
+
const definition = deleteUndefineds(generatorConverters.wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object.raw, true));
|
|
491
494
|
const objectDefIdentifier = object.getDefinitionIdentifier(true);
|
|
492
495
|
const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;
|
|
493
496
|
const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;
|
|
@@ -496,7 +499,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
496
499
|
const osdkObjectLinksIdentifier = `${object.shortApiName}.Links`;
|
|
497
500
|
const osdkObjectIdentifier = `${object.shortApiName}.OsdkObject`;
|
|
498
501
|
const identifiers = {
|
|
499
|
-
objectDefIdentifier: `${object.shortApiName}
|
|
502
|
+
objectDefIdentifier: `${object.shortApiName}`,
|
|
500
503
|
osdkObjectLinksIdentifier,
|
|
501
504
|
osdkObjectPropsIdentifier,
|
|
502
505
|
osdkObjectStrictPropsIdentifier,
|
|
@@ -506,42 +509,18 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
506
509
|
};
|
|
507
510
|
function getV2Types() {
|
|
508
511
|
return `import type {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
DefaultToFalse as $DefaultToFalse,
|
|
515
|
-
FetchPageArgs as $FetchPageArgs,
|
|
516
|
-
FetchPageResult as $FetchPageResult,
|
|
517
|
-
IsAny as $IsAny,
|
|
518
|
-
LinkedType as $LinkedType,
|
|
519
|
-
LinkNames as $LinkNames,
|
|
520
|
-
NullabilityAdherence as $NullabilityAdherence,
|
|
521
|
-
NullabilityAdherenceDefault as $NullabilityAdherenceDefault,
|
|
512
|
+
ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
|
|
513
|
+
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
514
|
+
ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
|
|
515
|
+
} from "@osdk/api";
|
|
516
|
+
import type {
|
|
522
517
|
ObjectSet as $ObjectSet,
|
|
523
518
|
Osdk as $Osdk,
|
|
524
519
|
OsdkObject as $OsdkObject,
|
|
525
|
-
OsdkObjectLinksEntry as $OsdkObjectLinksEntry,
|
|
526
|
-
OsdkObjectLinksObject as $OsdkObjectLinksObject,
|
|
527
|
-
OsdkObjectPropertyType as $OsdkObjectPropertyType,
|
|
528
|
-
PageResult as $PageResult,
|
|
529
|
-
PropertyValueClientToWire as $PropertyValueClientToWire,
|
|
530
520
|
PropertyValueWireToClient as $PropType,
|
|
531
|
-
Result as $Result,
|
|
532
|
-
SelectArg as $SelectArg,
|
|
533
521
|
SingleLinkAccessor as $SingleLinkAccessor,
|
|
534
|
-
SingleLinkAccessor as $SingleLinkAccessor
|
|
535
|
-
SingleOsdkResult as $SingleOsdkResult,
|
|
536
|
-
ValidToFrom as $ValidToFrom,
|
|
537
|
-
WhereClause as $WhereClause,
|
|
538
522
|
} from "@osdk/client.api";
|
|
539
|
-
|
|
540
|
-
import type {
|
|
541
|
-
ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
|
|
542
|
-
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
543
|
-
ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
|
|
544
|
-
} from "@osdk/api";
|
|
523
|
+
|
|
545
524
|
|
|
546
525
|
export namespace ${object.shortApiName} {
|
|
547
526
|
|
|
@@ -554,16 +533,15 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
554
533
|
${createProps(object, "StrictProps", true)}
|
|
555
534
|
|
|
556
535
|
${createObjectSet(object, identifiers)}
|
|
557
|
-
|
|
558
|
-
${createDefinition(object, ontology, "Definition", identifiers)}
|
|
536
|
+
|
|
559
537
|
${createOsdkObject(object, "OsdkObject", identifiers)}
|
|
560
538
|
}
|
|
561
539
|
|
|
562
540
|
|
|
563
541
|
|
|
564
|
-
|
|
542
|
+
${createDefinition(object, ontology, object.shortApiName, identifiers)}
|
|
543
|
+
|
|
565
544
|
|
|
566
|
-
export type ${objectDefIdentifier} = ${object.shortApiName}.Definition;
|
|
567
545
|
|
|
568
546
|
|
|
569
547
|
`;
|
|
@@ -685,7 +663,7 @@ function createLinks(ontology, object, identifier) {
|
|
|
685
663
|
${stringify(definition.links, {
|
|
686
664
|
"*": (definition2, _, key) => {
|
|
687
665
|
const linkTarget = ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(true);
|
|
688
|
-
return [`readonly ${key}`, `${definition2.multiplicity ? `${linkTarget}.ObjectSet` : `$SingleLinkAccessor<${linkTarget}
|
|
666
|
+
return [`readonly ${key}`, `${definition2.multiplicity ? `${linkTarget}.ObjectSet` : `$SingleLinkAccessor<${linkTarget}>`}
|
|
689
667
|
`];
|
|
690
668
|
}
|
|
691
669
|
})}
|
|
@@ -710,10 +688,10 @@ async function generatePerActionDataFiles({
|
|
|
710
688
|
});
|
|
711
689
|
await Promise.all(Object.values(enhancedOntology.actionTypes).map(async (action) => {
|
|
712
690
|
const currentFilePath = `${path5__namespace.default.join("ontology", "actions", `${action.shortApiName}.ts`)}`;
|
|
713
|
-
const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.
|
|
691
|
+
const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.raw);
|
|
714
692
|
const uniqueApiNames = new Set(uniqueApiNamesArray);
|
|
715
693
|
const uniqueApiNamesString = stringUnionFrom([...uniqueApiNames]);
|
|
716
|
-
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action.
|
|
694
|
+
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action.raw));
|
|
717
695
|
const {
|
|
718
696
|
parameters,
|
|
719
697
|
...actionDefSansParameters
|
|
@@ -737,9 +715,9 @@ async function generatePerActionDataFiles({
|
|
|
737
715
|
return JSON.stringify(type);
|
|
738
716
|
} else if (type.type === "object") {
|
|
739
717
|
const obj = enhancedOntology.requireObjectType(type.object);
|
|
740
|
-
return `ObjectActionDataType<"${obj.fullApiName}", ${obj.getImportedDefinitionIdentifier(true)}
|
|
718
|
+
return `ObjectActionDataType<"${obj.fullApiName}", ${obj.getImportedDefinitionIdentifier(true)}>`;
|
|
741
719
|
} else if (type.type === "objectSet") {
|
|
742
|
-
return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, true)}
|
|
720
|
+
return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, true)}>`;
|
|
743
721
|
}
|
|
744
722
|
return void 0;
|
|
745
723
|
}
|
|
@@ -752,13 +730,13 @@ async function generatePerActionDataFiles({
|
|
|
752
730
|
if (typeof input === "string") {
|
|
753
731
|
return `ActionParam.PrimitiveType<${JSON.stringify(input)}>`;
|
|
754
732
|
} else if (input.type === "object") {
|
|
755
|
-
return `ActionParam.ObjectType<${enhancedOntology.requireObjectType(input.object).getImportedDefinitionIdentifier(true)}
|
|
733
|
+
return `ActionParam.ObjectType<${enhancedOntology.requireObjectType(input.object).getImportedDefinitionIdentifier(true)}>`;
|
|
756
734
|
} else if (input.type === "objectSet") {
|
|
757
|
-
return `ActionParam.ObjectSetType<${enhancedOntology.requireObjectType(input.objectSet).getImportedDefinitionIdentifier(true)}
|
|
735
|
+
return `ActionParam.ObjectSetType<${enhancedOntology.requireObjectType(input.objectSet).getImportedDefinitionIdentifier(true)}>`;
|
|
758
736
|
}
|
|
759
737
|
}
|
|
760
738
|
function createV2Types() {
|
|
761
|
-
|
|
739
|
+
`${action.shortApiName}$Params`;
|
|
762
740
|
return `
|
|
763
741
|
|
|
764
742
|
export namespace ${action.shortApiName}{
|
|
@@ -775,8 +753,6 @@ async function generatePerActionDataFiles({
|
|
|
775
753
|
}
|
|
776
754
|
})}
|
|
777
755
|
}
|
|
778
|
-
/** @deprecated **/
|
|
779
|
-
export type Parameters = Params;
|
|
780
756
|
|
|
781
757
|
|
|
782
758
|
// Represents the definition of the action
|
|
@@ -798,11 +774,6 @@ async function generatePerActionDataFiles({
|
|
|
798
774
|
|
|
799
775
|
}
|
|
800
776
|
|
|
801
|
-
/**
|
|
802
|
-
* @deprecated Use \`${action.paramsIdentifier}\`
|
|
803
|
-
*/
|
|
804
|
-
export type ${oldParamsIdentifier} = ${action.paramsIdentifier} | ReadonlyArray<${action.paramsIdentifier}>;
|
|
805
|
-
|
|
806
777
|
/** @deprecated Use \`${action.definitionIdentifier}\` **/
|
|
807
778
|
export type ${action.shortApiName} = ${action.shortApiName}.Signatures;
|
|
808
779
|
`;
|
|
@@ -837,9 +808,9 @@ async function generatePerActionDataFiles({
|
|
|
837
808
|
const imports = getObjectImports(referencedObjectDefs, void 0, currentFilePath, true);
|
|
838
809
|
await fs2.writeFile(path5__namespace.default.join(rootOutDir, currentFilePath), await formatTs(`
|
|
839
810
|
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound} from "@osdk/api";
|
|
840
|
-
import type {
|
|
841
|
-
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
811
|
+
import type { ActionParam, ActionReturnTypeForOptions, ApplyActionOptions, ApplyBatchActionOptions, } from '@osdk/client.api';
|
|
842
812
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
813
|
+
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
843
814
|
${imports}
|
|
844
815
|
|
|
845
816
|
|
|
@@ -873,6 +844,7 @@ function extractReferencedObjectsFromAction(actionType) {
|
|
|
873
844
|
case "deleteObject":
|
|
874
845
|
case "createLink":
|
|
875
846
|
case "deleteLink":
|
|
847
|
+
default:
|
|
876
848
|
return [];
|
|
877
849
|
}
|
|
878
850
|
});
|
|
@@ -1127,8 +1099,9 @@ async function generatePerQueryDataFilesV2({
|
|
|
1127
1099
|
async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ontology) {
|
|
1128
1100
|
const relFilePath = path5__namespace.default.join(relOutDir, `${query.shortApiName}.ts`);
|
|
1129
1101
|
const objectTypes = getObjectTypeApiNamesFromQuery(query);
|
|
1130
|
-
const
|
|
1131
|
-
const
|
|
1102
|
+
const objectTypeObjects = new Set(objectTypes.map((o) => ontology.requireObjectType(o)));
|
|
1103
|
+
const importObjects = getObjectImports(objectTypeObjects, "", relFilePath, true);
|
|
1104
|
+
const baseProps = deleteUndefineds(wireQueryTypeV2ToSdkQueryDefinitionNoParams(query.raw));
|
|
1132
1105
|
const outputBase = deleteUndefineds(wireQueryDataTypeToQueryDataTypeDefinition(query.output));
|
|
1133
1106
|
const referencedObjectTypes = objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never";
|
|
1134
1107
|
await fs2.writeFile(path5__namespace.default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
@@ -1234,15 +1207,6 @@ function queryParamJsDoc(param, {
|
|
|
1234
1207
|
`;
|
|
1235
1208
|
return ret;
|
|
1236
1209
|
}
|
|
1237
|
-
function getObjectImports2(enhancedOntology, objectTypes, filePath) {
|
|
1238
|
-
let ret = "";
|
|
1239
|
-
for (const fqObjectApiName of objectTypes) {
|
|
1240
|
-
const obj = enhancedOntology.requireObjectType(fqObjectApiName);
|
|
1241
|
-
ret += `import type { ${obj.getDefinitionIdentifier(true)} as ${obj.getImportedDefinitionIdentifier(true)} } from "${obj.getImportPathRelTo(filePath)}";
|
|
1242
|
-
`;
|
|
1243
|
-
}
|
|
1244
|
-
return ret;
|
|
1245
|
-
}
|
|
1246
1210
|
function getQueryParamType(enhancedOntology, input, type) {
|
|
1247
1211
|
let inner = `unknown /* ${input.type} */`;
|
|
1248
1212
|
switch (input.type) {
|
|
@@ -1283,11 +1247,11 @@ function getQueryParamType(enhancedOntology, input, type) {
|
|
|
1283
1247
|
return inner;
|
|
1284
1248
|
}
|
|
1285
1249
|
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false) {
|
|
1286
|
-
const definition = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef.
|
|
1250
|
+
const definition = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef.raw, v2));
|
|
1287
1251
|
const objectDefIdentifier = interfaceDef.getDefinitionIdentifier(v2);
|
|
1288
1252
|
const parents = definition.implements?.map((p) => {
|
|
1289
1253
|
!(ontology.interfaceTypes[p] != null) ? process.env.NODE_ENV !== "production" ? invariant__default.default(false, `Expected to find a parent interface named ${p} in the ontology and did not.`) : invariant__default.default(false) : void 0;
|
|
1290
|
-
const it = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.requireInterfaceType(p, true).
|
|
1254
|
+
const it = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.requireInterfaceType(p, true).raw, v2));
|
|
1291
1255
|
return it;
|
|
1292
1256
|
}) ?? [];
|
|
1293
1257
|
const mergedProperties = {
|
|
@@ -1328,43 +1292,15 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology,
|
|
|
1328
1292
|
propertyKeysIdentifier
|
|
1329
1293
|
};
|
|
1330
1294
|
function getV2Types() {
|
|
1331
|
-
return `import type {
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
Augments as $Augments,
|
|
1336
|
-
ConvertProps as $ConvertProps,
|
|
1337
|
-
DefaultToFalse as $DefaultToFalse,
|
|
1338
|
-
FetchPageArgs as $FetchPageArgs,
|
|
1339
|
-
FetchPageResult as $FetchPageResult,
|
|
1340
|
-
IsAny as $IsAny,
|
|
1341
|
-
LinkedType as $LinkedType,
|
|
1342
|
-
LinkNames as $LinkNames,
|
|
1343
|
-
NullabilityAdherence as $NullabilityAdherence,
|
|
1344
|
-
NullabilityAdherenceDefault as $NullabilityAdherenceDefault,
|
|
1295
|
+
return ` import type {
|
|
1296
|
+
InterfaceDefinition as $InterfaceDefinition,
|
|
1297
|
+
} from "@osdk/api";
|
|
1298
|
+
import type {
|
|
1345
1299
|
ObjectSet as $ObjectSet,
|
|
1346
1300
|
Osdk as $Osdk,
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
OsdkObjectPropertyType as $OsdkObjectPropertyType,
|
|
1351
|
-
PageResult as $PageResult,
|
|
1352
|
-
PropertyValueClientToWire as $PropertyValueClientToWire,
|
|
1353
|
-
PropertyValueWireToClient as $PropType,
|
|
1354
|
-
Result as $Result,
|
|
1355
|
-
SelectArg as $SelectArg,
|
|
1356
|
-
SingleLinkAccessor as $SingleLinkAccessor,
|
|
1357
|
-
SingleOsdkResult as $SingleOsdkResult,
|
|
1358
|
-
ValidToFrom as $ValidToFrom,
|
|
1359
|
-
WhereClause as $WhereClause,
|
|
1360
|
-
} from "@osdk/client.api";
|
|
1361
|
-
import type * as $clientApi from "@osdk/client.api";
|
|
1362
|
-
import type {
|
|
1363
|
-
ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
|
|
1364
|
-
ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
|
|
1365
|
-
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
1366
|
-
InterfaceDefinition as $InterfaceDefinition,
|
|
1367
|
-
} from "@osdk/api";
|
|
1301
|
+
PropertyValueWireToClient as $PropType, } from "@osdk/client.api";
|
|
1302
|
+
|
|
1303
|
+
|
|
1368
1304
|
|
|
1369
1305
|
|
|
1370
1306
|
|
|
@@ -1437,15 +1373,15 @@ async function generateRootIndexTsFile({
|
|
|
1437
1373
|
importExt,
|
|
1438
1374
|
ontologyApiNamespace
|
|
1439
1375
|
}) {
|
|
1440
|
-
fs2.writeFile(path5__namespace.default.join(outDir, "index.ts"), await formatTs(
|
|
1441
|
-
export * from "./ontology/actions${importExt}";
|
|
1376
|
+
fs2.writeFile(path5__namespace.default.join(outDir, "index.ts"), await formatTs(`export * from "./ontology/actions${importExt}";
|
|
1442
1377
|
export * as $Actions from "./ontology/actions${importExt}";
|
|
1443
|
-
export * from "./ontology/objects${importExt}";
|
|
1444
|
-
export * as $Objects from "./ontology/objects${importExt}";
|
|
1445
1378
|
export * from "./ontology/interfaces${importExt}";
|
|
1446
1379
|
export * as $Interfaces from "./ontology/interfaces${importExt}";
|
|
1380
|
+
export * from "./ontology/objects${importExt}";
|
|
1381
|
+
export * as $Objects from "./ontology/objects${importExt}";
|
|
1447
1382
|
export * from "./ontology/queries${importExt}";
|
|
1448
1383
|
export * as $Queries from "./ontology/queries${importExt}";
|
|
1384
|
+
${ontologyApiNamespace == null ? `export { $ontologyRid } from "./OntologyMetadata${importExt}";` : ``}
|
|
1449
1385
|
`));
|
|
1450
1386
|
}
|
|
1451
1387
|
async function generateEachObjectFile(ctx) {
|
|
@@ -1462,11 +1398,10 @@ async function generateEachObjectFile(ctx) {
|
|
|
1462
1398
|
const relPath = path5__namespace.default.join(".", "ontology", `objects`, `${obj.shortApiName}.ts`);
|
|
1463
1399
|
const outFilePath = path5__namespace.default.join(outDir, relPath);
|
|
1464
1400
|
await fs2.writeFile(outFilePath, await formatTs(`
|
|
1465
|
-
import type {
|
|
1466
|
-
import type { Osdk } from "@osdk/client.api";
|
|
1401
|
+
import type { PropertyDef as $PropertyDef } from "@osdk/api";
|
|
1467
1402
|
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
|
|
1468
1403
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1469
|
-
${wireObjectTypeV2ToSdkObjectConstV2(obj.
|
|
1404
|
+
${wireObjectTypeV2ToSdkObjectConstV2(obj.raw, ctx, relPath)}
|
|
1470
1405
|
`));
|
|
1471
1406
|
}
|
|
1472
1407
|
}
|
|
@@ -1514,10 +1449,8 @@ async function generateOntologyInterfaces({
|
|
|
1514
1449
|
});
|
|
1515
1450
|
for (const obj of Object.values(ontology.interfaceTypes)) {
|
|
1516
1451
|
await fs2.writeFile(path5__namespace.default.join(interfacesDir, `${obj.shortApiName}.ts`), await formatTs(`
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
import { $osdkMetadata, $expectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1520
|
-
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1452
|
+
import type { PropertyDef as $PropertyDef } from "@osdk/api";
|
|
1453
|
+
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
|
|
1521
1454
|
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true)}
|
|
1522
1455
|
`));
|
|
1523
1456
|
}
|