@osdk/generator 2.2.0-beta.2 → 2.2.0-beta.21
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 +203 -0
- package/build/browser/shared/getObjectTypesFromQueryDataType.js +5 -0
- package/build/browser/shared/getObjectTypesFromQueryDataType.js.map +1 -1
- package/build/browser/util/test/TodoWireOntology.js +6 -2
- package/build/browser/util/test/TodoWireOntology.js.map +1 -1
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +102 -3
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js +100 -30
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
- package/build/browser/v2.0/generatePerActionDataFiles.js +2 -2
- package/build/browser/v2.0/generatePerActionDataFiles.js.map +1 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.js +8 -2
- package/build/browser/v2.0/generatePerQueryDataFiles.js.map +1 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.test.js +3 -3
- package/build/browser/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +3 -4
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
- package/build/cjs/index.cjs +51 -41
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/shared/getObjectTypesFromQueryDataType.js +5 -0
- package/build/esm/shared/getObjectTypesFromQueryDataType.js.map +1 -1
- package/build/esm/util/test/TodoWireOntology.js +6 -2
- package/build/esm/util/test/TodoWireOntology.js.map +1 -1
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +102 -3
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js +100 -30
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
- package/build/esm/v2.0/generatePerActionDataFiles.js +2 -2
- package/build/esm/v2.0/generatePerActionDataFiles.js.map +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.js +8 -2
- package/build/esm/v2.0/generatePerQueryDataFiles.js.map +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.test.js +3 -3
- package/build/esm/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +3 -4
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/v2.0/generatePerQueryDataFiles.d.ts +1 -1
- package/build/types/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/types/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/package.json +5 -5
- package/build/cjs/chunk-XOCES5YA.cjs +0 -978
- package/build/cjs/chunk-XOCES5YA.cjs.map +0 -1
- package/build/cjs/prompt-YMFYYBNJ.cjs +0 -860
- package/build/cjs/prompt-YMFYYBNJ.cjs.map +0 -1
package/build/cjs/index.cjs
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunkXOCES5YA_cjs = require('./chunk-XOCES5YA.cjs');
|
|
4
3
|
var fs = require('fs');
|
|
5
4
|
var path8 = require('path');
|
|
6
5
|
var generatorConverters = require('@osdk/generator-converters');
|
|
7
6
|
var prettier = require('prettier');
|
|
8
|
-
require('
|
|
9
|
-
require('tty');
|
|
10
|
-
require('util');
|
|
7
|
+
var consola = require('consola');
|
|
11
8
|
var fastDeepEqual = require('fast-deep-equal');
|
|
12
9
|
var invariant = require('tiny-invariant');
|
|
13
10
|
|
|
@@ -33,9 +30,11 @@ function _interopNamespace(e) {
|
|
|
33
30
|
|
|
34
31
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
35
32
|
var path8__namespace = /*#__PURE__*/_interopNamespace(path8);
|
|
33
|
+
var consola__default = /*#__PURE__*/_interopDefault(consola);
|
|
36
34
|
var fastDeepEqual__default = /*#__PURE__*/_interopDefault(fastDeepEqual);
|
|
37
35
|
var invariant__default = /*#__PURE__*/_interopDefault(invariant);
|
|
38
36
|
|
|
37
|
+
// src/generateClientSdkPackage.ts
|
|
39
38
|
var AbstractImportable = class {
|
|
40
39
|
/**
|
|
41
40
|
* Either a path relative to the ourDir (e.g. "./ontology/objects/foo.js") or a normal
|
|
@@ -72,7 +71,7 @@ var EnhancedBase = class extends AbstractImportable {
|
|
|
72
71
|
};
|
|
73
72
|
function extractNamespace(fqApiName) {
|
|
74
73
|
const last = fqApiName.lastIndexOf(".");
|
|
75
|
-
if (last === -1) return [
|
|
74
|
+
if (last === -1) return [void 0, fqApiName];
|
|
76
75
|
return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];
|
|
77
76
|
}
|
|
78
77
|
|
|
@@ -104,7 +103,7 @@ var EnhancedAction = class extends EnhancedBase {
|
|
|
104
103
|
|
|
105
104
|
// src/util/deleteUndefineds.ts
|
|
106
105
|
function deleteUndefineds(obj) {
|
|
107
|
-
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !==
|
|
106
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0));
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
// src/GenerateContext/EnhancedInterfaceType.ts
|
|
@@ -210,7 +209,7 @@ var EnhancedOntologyDefinition = class {
|
|
|
210
209
|
return (fullApiName, localOnly) => {
|
|
211
210
|
const ret = this[type][fullApiName];
|
|
212
211
|
if (!ret) {
|
|
213
|
-
extractNamespace(fullApiName);
|
|
212
|
+
const [apiNamespace, shortApiName] = extractNamespace(fullApiName);
|
|
214
213
|
throw new Error(`Unable to find ${type}: No entry for '${fullApiName}`);
|
|
215
214
|
}
|
|
216
215
|
return ret;
|
|
@@ -393,7 +392,7 @@ async function generatePerActionDataFiles({
|
|
|
393
392
|
${entries.map(([key, value]) => {
|
|
394
393
|
return `"${key}": {
|
|
395
394
|
${stringify(value, {
|
|
396
|
-
description: (value2, d) => value2 ? d(value2) :
|
|
395
|
+
description: (value2, d) => value2 ? d(value2) : void 0,
|
|
397
396
|
// trick to remove undefineds
|
|
398
397
|
type: (type) => {
|
|
399
398
|
if (typeof type === "string") {
|
|
@@ -410,7 +409,7 @@ async function generatePerActionDataFiles({
|
|
|
410
409
|
} else if (type.type === "struct") {
|
|
411
410
|
return `ActionMetadata.DataType.Struct<${JSON.stringify(type.struct)}>`;
|
|
412
411
|
}
|
|
413
|
-
return
|
|
412
|
+
return void 0;
|
|
414
413
|
}
|
|
415
414
|
})}
|
|
416
415
|
}`;
|
|
@@ -457,9 +456,9 @@ async function generatePerActionDataFiles({
|
|
|
457
456
|
// Represents a fqn of the action
|
|
458
457
|
export interface Signatures {
|
|
459
458
|
${getDescriptionIfPresent(action.description)}
|
|
460
|
-
applyAction<
|
|
459
|
+
applyAction<OP extends ApplyActionOptions>(args: ${action.paramsIdentifier}, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;
|
|
461
460
|
|
|
462
|
-
batchApplyAction<
|
|
461
|
+
batchApplyAction<OP extends ApplyBatchActionOptions>(args: ReadonlyArray<${action.paramsIdentifier}>, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;
|
|
463
462
|
}
|
|
464
463
|
|
|
465
464
|
}
|
|
@@ -476,12 +475,12 @@ async function generatePerActionDataFiles({
|
|
|
476
475
|
signatures: ${action.shortApiName}.Signatures;
|
|
477
476
|
},
|
|
478
477
|
${stringify(fullActionDef, {
|
|
479
|
-
"description": () =>
|
|
480
|
-
"displayName": () =>
|
|
481
|
-
"modifiedEntities": () =>
|
|
482
|
-
"parameters": () =>
|
|
483
|
-
"rid": () =>
|
|
484
|
-
"status": () =>
|
|
478
|
+
"description": () => void 0,
|
|
479
|
+
"displayName": () => void 0,
|
|
480
|
+
"modifiedEntities": () => void 0,
|
|
481
|
+
"parameters": () => void 0,
|
|
482
|
+
"rid": () => void 0,
|
|
483
|
+
"status": () => void 0
|
|
485
484
|
})}
|
|
486
485
|
osdkMetadata: typeof $osdkMetadata;
|
|
487
486
|
}
|
|
@@ -491,12 +490,12 @@ async function generatePerActionDataFiles({
|
|
|
491
490
|
return ` export const ${action.shortApiName}: ${action.shortApiName} =
|
|
492
491
|
{
|
|
493
492
|
${stringify(fullActionDef, {
|
|
494
|
-
"description": () =>
|
|
495
|
-
"displayName": () =>
|
|
496
|
-
"modifiedEntities": () =>
|
|
497
|
-
"parameters": () =>
|
|
498
|
-
"rid": () =>
|
|
499
|
-
"status": () =>
|
|
493
|
+
"description": () => void 0,
|
|
494
|
+
"displayName": () => void 0,
|
|
495
|
+
"modifiedEntities": () => void 0,
|
|
496
|
+
"parameters": () => void 0,
|
|
497
|
+
"rid": () => void 0,
|
|
498
|
+
"status": () => void 0
|
|
500
499
|
})},
|
|
501
500
|
osdkMetadata: $osdkMetadata
|
|
502
501
|
}
|
|
@@ -533,7 +532,7 @@ async function generatePerActionDataFiles({
|
|
|
533
532
|
}
|
|
534
533
|
}
|
|
535
534
|
}
|
|
536
|
-
const imports = getObjectImports(referencedObjectDefs,
|
|
535
|
+
const imports = getObjectImports(referencedObjectDefs, void 0, currentFilePath, true);
|
|
537
536
|
await fs2.writeFile(path8__namespace.default.join(rootOutDir, currentFilePath), await formatTs(`
|
|
538
537
|
import type {
|
|
539
538
|
ActionDefinition,
|
|
@@ -598,7 +597,7 @@ function extractReferencedObjectsFromActionParameter(actionParameter) {
|
|
|
598
597
|
case "integer":
|
|
599
598
|
case "long":
|
|
600
599
|
case "timestamp":
|
|
601
|
-
return
|
|
600
|
+
return void 0;
|
|
602
601
|
}
|
|
603
602
|
}
|
|
604
603
|
|
|
@@ -642,7 +641,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
642
641
|
throw new Error("Should not be generating types for an external type");
|
|
643
642
|
}
|
|
644
643
|
const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map((a) => ontology.requireObjectType(a.objectTypeApiName, false)));
|
|
645
|
-
const definition = deleteUndefineds(generatorConverters.wireObjectTypeFullMetadataToSdkObjectMetadata(object.raw, true,
|
|
644
|
+
const definition = deleteUndefineds(generatorConverters.wireObjectTypeFullMetadataToSdkObjectMetadata(object.raw, true, consola__default.default));
|
|
646
645
|
const objectDefIdentifier = object.getDefinitionIdentifier(true);
|
|
647
646
|
const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;
|
|
648
647
|
const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;
|
|
@@ -763,9 +762,9 @@ function createProps(type, identifier, strict) {
|
|
|
763
762
|
return `export interface ${identifier} {
|
|
764
763
|
${stringify(definition.properties, {
|
|
765
764
|
"*": (propertyDefinition, _, apiName) => {
|
|
766
|
-
return [
|
|
767
|
-
|
|
768
|
-
""
|
|
765
|
+
return [`${propertyJsdoc(propertyDefinition, {
|
|
766
|
+
apiName
|
|
767
|
+
})}readonly "${maybeStripNamespace(type, apiName)}"`, (typeof propertyDefinition.type === "object" ? remapStructType(propertyDefinition.type) : `$PropType[${JSON.stringify(propertyDefinition.type)}]`) + `${propertyDefinition.multiplicity ? "[]" : ""}${propertyDefinition.nullable || !strict && !(definition.type === "object" && definition.primaryKeyApiName === apiName) ? `| undefined` : ""}`];
|
|
769
768
|
}
|
|
770
769
|
})}
|
|
771
770
|
}`;
|
|
@@ -839,7 +838,7 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology,
|
|
|
839
838
|
const parents = definition.implements?.map((p) => {
|
|
840
839
|
const parent = ontology.requireInterfaceType(p, true);
|
|
841
840
|
if (parent instanceof EnhancedInterfaceType) {
|
|
842
|
-
const it = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(parent.raw, v2,
|
|
841
|
+
const it = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(parent.raw, v2, consola__default.default));
|
|
843
842
|
return it;
|
|
844
843
|
}
|
|
845
844
|
}) ?? [];
|
|
@@ -852,9 +851,9 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology,
|
|
|
852
851
|
}
|
|
853
852
|
for (const apiName of Object.keys(parent.properties)) {
|
|
854
853
|
if (definition.properties[apiName] != null) {
|
|
855
|
-
!fastDeepEqual__default.default(definition.properties[apiName], parent.properties[apiName]) ? process.env.NODE_ENV !== "production" ? invariant__default.default(false, `Interface ${definition.apiName} redefines property '${apiName}' from parent '${parent.apiName}' but the properties do not match`) : invariant__default.default(false) :
|
|
854
|
+
!fastDeepEqual__default.default(definition.properties[apiName], parent.properties[apiName]) ? process.env.NODE_ENV !== "production" ? invariant__default.default(false, `Interface ${definition.apiName} redefines property '${apiName}' from parent '${parent.apiName}' but the properties do not match`) : invariant__default.default(false) : void 0;
|
|
856
855
|
} else if (mergedProperties[apiName] != null) {
|
|
857
|
-
!fastDeepEqual__default.default(mergedProperties[apiName], parent.properties[apiName]) ? process.env.NODE_ENV !== "production" ? invariant__default.default(false, `Some interface defines a conflicting property '${apiName}' that does not match property from parent '${parent.apiName}'`) : invariant__default.default(false) :
|
|
856
|
+
!fastDeepEqual__default.default(mergedProperties[apiName], parent.properties[apiName]) ? process.env.NODE_ENV !== "production" ? invariant__default.default(false, `Some interface defines a conflicting property '${apiName}' that does not match property from parent '${parent.apiName}'`) : invariant__default.default(false) : void 0;
|
|
858
857
|
}
|
|
859
858
|
mergedProperties[apiName] = parent.properties[apiName];
|
|
860
859
|
}
|
|
@@ -1006,6 +1005,10 @@ function getObjectTypesFromQueryDataType(dataType, types) {
|
|
|
1006
1005
|
getObjectTypesFromQueryDataType(type, types);
|
|
1007
1006
|
}
|
|
1008
1007
|
return;
|
|
1008
|
+
case "entrySet":
|
|
1009
|
+
getObjectTypesFromQueryDataType(dataType.keyType, types);
|
|
1010
|
+
getObjectTypesFromQueryDataType(dataType.valueType, types);
|
|
1011
|
+
return;
|
|
1009
1012
|
case "attachment":
|
|
1010
1013
|
case "boolean":
|
|
1011
1014
|
case "date":
|
|
@@ -1018,6 +1021,7 @@ function getObjectTypesFromQueryDataType(dataType, types) {
|
|
|
1018
1021
|
case "threeDimensionalAggregation":
|
|
1019
1022
|
case "timestamp":
|
|
1020
1023
|
case "twoDimensionalAggregation":
|
|
1024
|
+
case "entrySet":
|
|
1021
1025
|
case "unsupported":
|
|
1022
1026
|
return;
|
|
1023
1027
|
default:
|
|
@@ -1068,7 +1072,7 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
|
|
|
1068
1072
|
const outputBase = deleteUndefineds(generatorConverters.wireQueryDataTypeToQueryDataTypeDefinition(query.output));
|
|
1069
1073
|
objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never";
|
|
1070
1074
|
await fs2.writeFile(path8__namespace.default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
1071
|
-
import type { QueryDefinition
|
|
1075
|
+
import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound} from "${forInternalUse ? "@osdk/api" : "@osdk/client"}";
|
|
1072
1076
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1073
1077
|
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
1074
1078
|
${importObjects}
|
|
@@ -1120,9 +1124,9 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
|
|
|
1120
1124
|
signature: ${query.shortApiName}.Signature;
|
|
1121
1125
|
},
|
|
1122
1126
|
${stringify(baseProps, {
|
|
1123
|
-
"description": () =>
|
|
1124
|
-
"displayName": () =>
|
|
1125
|
-
"rid": () =>
|
|
1127
|
+
"description": () => void 0,
|
|
1128
|
+
"displayName": () => void 0,
|
|
1129
|
+
"rid": () => void 0
|
|
1126
1130
|
})},
|
|
1127
1131
|
osdkMetadata: typeof $osdkMetadata;
|
|
1128
1132
|
}
|
|
@@ -1130,9 +1134,9 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
|
|
|
1130
1134
|
|
|
1131
1135
|
export const ${query.shortApiName}: ${query.definitionIdentifier} = {
|
|
1132
1136
|
${stringify(baseProps, {
|
|
1133
|
-
"description": () =>
|
|
1134
|
-
"displayName": () =>
|
|
1135
|
-
"rid": () =>
|
|
1137
|
+
"description": () => void 0,
|
|
1138
|
+
"displayName": () => void 0,
|
|
1139
|
+
"rid": () => void 0
|
|
1136
1140
|
})},
|
|
1137
1141
|
osdkMetadata: $osdkMetadata
|
|
1138
1142
|
};
|
|
@@ -1172,7 +1176,7 @@ function queryParamJsDoc(param, {
|
|
|
1172
1176
|
`;
|
|
1173
1177
|
return ret;
|
|
1174
1178
|
}
|
|
1175
|
-
function getQueryParamType(enhancedOntology, input, type) {
|
|
1179
|
+
function getQueryParamType(enhancedOntology, input, type, isMapKey = false) {
|
|
1176
1180
|
let inner = `unknown /* ${input.type} */`;
|
|
1177
1181
|
switch (input.type) {
|
|
1178
1182
|
case "date":
|
|
@@ -1206,6 +1210,10 @@ function getQueryParamType(enhancedOntology, input, type) {
|
|
|
1206
1210
|
"${input.threeDimensionalAggregation.valueType.valueType}">`;
|
|
1207
1211
|
break;
|
|
1208
1212
|
case "object":
|
|
1213
|
+
if (isMapKey) {
|
|
1214
|
+
inner = `ObjectSpecifier<${enhancedOntology.requireObjectType(input.object).getImportedDefinitionIdentifier(true)}>`;
|
|
1215
|
+
break;
|
|
1216
|
+
}
|
|
1209
1217
|
inner = `Query${type}.ObjectType<${enhancedOntology.requireObjectType(input.object).getImportedDefinitionIdentifier(true)}>`;
|
|
1210
1218
|
break;
|
|
1211
1219
|
case "objectSet":
|
|
@@ -1217,6 +1225,8 @@ function getQueryParamType(enhancedOntology, input, type) {
|
|
|
1217
1225
|
case "union":
|
|
1218
1226
|
inner = input.union.map((u) => getQueryParamType(enhancedOntology, u, type)).join(" | ");
|
|
1219
1227
|
break;
|
|
1228
|
+
case "map":
|
|
1229
|
+
inner = `Partial<Record<${getQueryParamType(enhancedOntology, input.keyType, type, true)}, ${getQueryParamType(enhancedOntology, input.valueType, type)}>>`;
|
|
1220
1230
|
}
|
|
1221
1231
|
if (input.multiplicity && type === "Param") {
|
|
1222
1232
|
return `ReadonlyArray<${inner}>`;
|
|
@@ -1382,7 +1392,7 @@ function getPackageJsonContents(name, version, dependencyVersions) {
|
|
|
1382
1392
|
};
|
|
1383
1393
|
}
|
|
1384
1394
|
async function writeJson(minimalFs, filePath, body) {
|
|
1385
|
-
return void await minimalFs.writeFile(filePath, JSON.stringify(body,
|
|
1395
|
+
return void await minimalFs.writeFile(filePath, JSON.stringify(body, void 0, 2) + "\n");
|
|
1386
1396
|
}
|
|
1387
1397
|
|
|
1388
1398
|
exports.__UNSTABLE_generateClientSdkPackage = generateClientSdkPackage;
|