@osdk/generator 1.12.0-main-20240530094422 → 1.12.1
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 +63 -6
- package/build/browser/index.js +150 -44
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +152 -44
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.cts +1 -3
- package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts.map +1 -1
- package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.cts +2 -0
- package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts.map +1 -0
- package/build/cjs/shared/generatePerActionDataFiles.d.ts.map +1 -1
- package/build/cjs/shared/propertyJsdoc.d.cts +6 -0
- package/build/cjs/shared/propertyJsdoc.d.ts.map +1 -0
- package/build/cjs/shared/sanitizeMetadata.d.cts +1 -9
- package/build/cjs/shared/sanitizeMetadata.d.ts.map +1 -1
- package/build/cjs/shared/wireObjectTypeV2ToSdkObjectConst.d.cts +0 -3
- package/build/cjs/shared/wireObjectTypeV2ToSdkObjectConst.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 +10 -2
- package/build/cjs/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts.map +1 -1
- package/build/cjs/util/stringify.d.cts +3 -3
- package/build/cjs/util/stringify.d.ts.map +1 -1
- package/build/cjs/util/test/createMockMinimalFiles.d.ts.map +1 -1
- package/build/cjs/util/{verifyOutdir.d.cts → verifyOutDir.d.cts} +2 -2
- package/build/cjs/util/{verifyOutdir.d.ts.map → verifyOutDir.d.ts.map} +1 -1
- package/build/cjs/v1.1/backcompat/generateOntologyRuntimeDistDir.d.ts.map +1 -1
- package/build/cjs/v1.1/generatePerQueryDataFiles.d.cts +1 -1
- package/build/cjs/v1.1/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/cjs/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/esm/index.js +150 -44
- package/build/esm/index.js.map +1 -1
- package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts +1 -3
- package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts.map +1 -1
- package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts +2 -0
- package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts.map +1 -0
- package/build/esm/shared/generatePerActionDataFiles.d.ts.map +1 -1
- package/build/esm/shared/propertyJsdoc.d.ts +6 -0
- package/build/esm/shared/propertyJsdoc.d.ts.map +1 -0
- package/build/esm/shared/sanitizeMetadata.d.ts +1 -9
- package/build/esm/shared/sanitizeMetadata.d.ts.map +1 -1
- package/build/esm/shared/wireObjectTypeV2ToSdkObjectConst.d.ts +0 -3
- package/build/esm/shared/wireObjectTypeV2ToSdkObjectConst.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 +10 -2
- package/build/esm/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts.map +1 -1
- package/build/esm/util/stringify.d.ts +3 -3
- package/build/esm/util/stringify.d.ts.map +1 -1
- package/build/esm/util/test/createMockMinimalFiles.d.ts.map +1 -1
- package/build/esm/util/{verifyOutdir.d.ts → verifyOutDir.d.ts} +2 -2
- package/build/esm/util/{verifyOutdir.d.ts.map → verifyOutDir.d.ts.map} +1 -1
- package/build/esm/v1.1/backcompat/generateOntologyRuntimeDistDir.d.ts.map +1 -1
- package/build/esm/v1.1/generatePerQueryDataFiles.d.ts +1 -1
- package/build/esm/v1.1/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/package.json +18 -13
package/build/cjs/index.cjs
CHANGED
|
@@ -5,6 +5,8 @@ var path16 = require('path');
|
|
|
5
5
|
var prettier = require('prettier');
|
|
6
6
|
var organizeImports = require('prettier-plugin-organize-imports');
|
|
7
7
|
var generatorConverters = require('@osdk/generator-converters');
|
|
8
|
+
var fastDeepEqual = require('fast-deep-equal');
|
|
9
|
+
var invariant = require('tiny-invariant');
|
|
8
10
|
|
|
9
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
12
|
|
|
@@ -29,6 +31,8 @@ function _interopNamespace(e) {
|
|
|
29
31
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
30
32
|
var path16__namespace = /*#__PURE__*/_interopNamespace(path16);
|
|
31
33
|
var organizeImports__default = /*#__PURE__*/_interopDefault(organizeImports);
|
|
34
|
+
var fastDeepEqual__default = /*#__PURE__*/_interopDefault(fastDeepEqual);
|
|
35
|
+
var invariant__default = /*#__PURE__*/_interopDefault(invariant);
|
|
32
36
|
|
|
33
37
|
// src/generateClientSdkPackage.ts
|
|
34
38
|
|
|
@@ -78,7 +82,7 @@ function isReservedKeyword(name) {
|
|
|
78
82
|
// src/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.ts
|
|
79
83
|
function wireObjectTypeV2ToObjectInterfaceStringV1(objectTypeWithLinks, importExt = "") {
|
|
80
84
|
const uniqueLinkTargets = new Set(objectTypeWithLinks.linkTypes.map((a) => a.objectTypeApiName).filter((a) => a !== objectTypeWithLinks.objectType.apiName));
|
|
81
|
-
return `import type { OntologyObject, LocalDate, Timestamp, GeoShape, GeoPoint, Attachment, TimeSeries, MultiLink, SingleLink } from "@osdk/legacy-client";
|
|
85
|
+
return `import type { OntologyObject, LocalDate, Timestamp, GeoShape, GeoPoint, Attachment, TimeSeries, MultiLink, SingleLink, StringLong } from "@osdk/legacy-client";
|
|
82
86
|
${Array.from(uniqueLinkTargets).map((linkTarget) => `import type { ${linkTarget} } from "./${linkTarget}${importExt}";`).join("\n")}
|
|
83
87
|
|
|
84
88
|
${getDescriptionIfPresent(objectTypeWithLinks.objectType.description)}
|
|
@@ -134,7 +138,7 @@ function wirePropertyTypeV2ToTypeScriptType(property) {
|
|
|
134
138
|
case "geoshape":
|
|
135
139
|
return "GeoShape";
|
|
136
140
|
case "long":
|
|
137
|
-
return "
|
|
141
|
+
return "StringLong";
|
|
138
142
|
case "short":
|
|
139
143
|
return "number";
|
|
140
144
|
case "timestamp":
|
|
@@ -243,6 +247,38 @@ function createModifiedEntities(addedObjects, modifiedObjects) {
|
|
|
243
247
|
}
|
|
244
248
|
return entities;
|
|
245
249
|
}
|
|
250
|
+
|
|
251
|
+
// src/shared/propertyJsdoc.ts
|
|
252
|
+
function propertyJsdoc(property, {
|
|
253
|
+
isInherited,
|
|
254
|
+
apiName
|
|
255
|
+
}) {
|
|
256
|
+
let ret = `/**
|
|
257
|
+
`;
|
|
258
|
+
const renderDisplayName = property.displayName && property.displayName !== apiName;
|
|
259
|
+
if (isInherited || renderDisplayName || property.description) {
|
|
260
|
+
if (isInherited) {
|
|
261
|
+
ret += ` * (inherited from parent)
|
|
262
|
+
`;
|
|
263
|
+
}
|
|
264
|
+
if (renderDisplayName) {
|
|
265
|
+
ret += ` * display name: '${property.displayName}'${property.description ? "," : ""}
|
|
266
|
+
`;
|
|
267
|
+
}
|
|
268
|
+
if (property.description) {
|
|
269
|
+
ret += ` * description: ${property.description}
|
|
270
|
+
`;
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
ret += ` * (no ontology metadata)
|
|
274
|
+
`;
|
|
275
|
+
}
|
|
276
|
+
ret += ` */
|
|
277
|
+
`;
|
|
278
|
+
return ret;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/shared/wireObjectTypeV2ToSdkObjectConst.ts
|
|
246
282
|
function getObjectDefIdentifier(name, v2) {
|
|
247
283
|
return v2 ? name : `${name}Def`;
|
|
248
284
|
}
|
|
@@ -281,7 +317,9 @@ function wireObjectTypeV2ToSdkObjectConst(object, importExt, v2 = false) {
|
|
|
281
317
|
}`,
|
|
282
318
|
properties: (_value) => `{
|
|
283
319
|
${stringify(definition.properties, {
|
|
284
|
-
"*": (propertyDefinition) =>
|
|
320
|
+
"*": (propertyDefinition, _, apiName) => [`${propertyJsdoc(propertyDefinition, {
|
|
321
|
+
apiName
|
|
322
|
+
})}${apiName}`, `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`]
|
|
285
323
|
})}
|
|
286
324
|
}`
|
|
287
325
|
})}
|
|
@@ -356,18 +394,18 @@ async function generatePerActionDataFiles(ontology, fs2, outDir, importExt, v2)
|
|
|
356
394
|
|
|
357
395
|
|
|
358
396
|
// Represents the runtime arguments for the action
|
|
359
|
-
export type ${paramsIdentifier} = NOOP<OsdkActionParameters<${paramsDefIdentifier}
|
|
397
|
+
export type ${paramsIdentifier} = NOOP<OsdkActionParameters<${paramsDefIdentifier}>> | NOOP<OsdkActionParameters<${paramsDefIdentifier}>>[];
|
|
360
398
|
|
|
361
399
|
|
|
362
400
|
// Represents a fqn of the action
|
|
363
401
|
export interface ${action.apiName} {
|
|
364
402
|
${getDescriptionIfPresent(action.description)}
|
|
365
|
-
<OP extends ApplyActionOptions>(args:
|
|
403
|
+
<P extends ${paramsIdentifier}, OP extends P extends NOOP<OsdkActionParameters<${paramsDefIdentifier}>>[]? ApplyBatchActionOptions: ApplyActionOptions>(args: P, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;
|
|
366
404
|
}
|
|
367
405
|
|
|
368
406
|
|
|
369
407
|
// Represents the definition of the action
|
|
370
|
-
export interface ${actionDefIdentifier} extends ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}, ${action.apiName}>{
|
|
408
|
+
export interface ${actionDefIdentifier} extends ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}, ${action.apiName}>, VersionBound<$ExpectedClientVersion> {
|
|
371
409
|
${Object.entries(actionDefSansParameters).sort((a, b) => a[0].localeCompare(b[0])).map(([key, value]) => {
|
|
372
410
|
return `${key}: ${JSON.stringify(value)};`;
|
|
373
411
|
}).join("\n")}
|
|
@@ -399,9 +437,10 @@ async function generatePerActionDataFiles(ontology, fs2, outDir, importExt, v2)
|
|
|
399
437
|
}
|
|
400
438
|
const importObjects = referencedObjectDefs.size > 0 ? `import type {${[...referencedObjectDefs].join(",")}} from "../objects${importExt}";` : "";
|
|
401
439
|
await fs2.writeFile(path16__namespace.default.join(outDir, `${action.apiName}.ts`), await formatTs(`
|
|
402
|
-
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from "@osdk/api";
|
|
403
|
-
import type { ActionSignature, ApplyActionOptions, OsdkActionParameters,ActionReturnTypeForOptions, NOOP } from '@osdk/client.api';
|
|
440
|
+
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound} from "@osdk/api";
|
|
441
|
+
import type { ActionSignature, ApplyActionOptions, ApplyBatchActionOptions, OsdkActionParameters,ActionReturnTypeForOptions, NOOP } from '@osdk/client.api';
|
|
404
442
|
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
443
|
+
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
405
444
|
${importObjects}
|
|
406
445
|
|
|
407
446
|
|
|
@@ -471,8 +510,8 @@ function camelize(name) {
|
|
|
471
510
|
return name.replace(/-./g, (segment) => segment[1].toUpperCase());
|
|
472
511
|
}
|
|
473
512
|
|
|
474
|
-
// src/util/
|
|
475
|
-
async function
|
|
513
|
+
// src/util/verifyOutDir.ts
|
|
514
|
+
async function verifyOutDir(outDir, fs2) {
|
|
476
515
|
try {
|
|
477
516
|
const contents = await fs2.readdir(outDir);
|
|
478
517
|
if (contents.length !== 0) {
|
|
@@ -570,7 +609,7 @@ function reexportConsts(typesToExport) {
|
|
|
570
609
|
import { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
|
|
571
610
|
|
|
572
611
|
${typesToExport.map((q) => `
|
|
573
|
-
/** @deprecated submodule imports
|
|
612
|
+
/** @deprecated submodule imports aren't public api **/
|
|
574
613
|
export const ${q} = OG_${q};
|
|
575
614
|
`).join("\n\n")}
|
|
576
615
|
`;
|
|
@@ -620,7 +659,7 @@ function reexportTypes(typesToExport, genericArgsLeft = "", genericArgsRight = c
|
|
|
620
659
|
import type { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
|
|
621
660
|
|
|
622
661
|
${typesToExport.map((q) => `
|
|
623
|
-
/** @deprecated submodule imports
|
|
662
|
+
/** @deprecated submodule imports aren't public api **/
|
|
624
663
|
export type ${q}${genericArgsLeft} = OG_${q}${genericArgsRight};
|
|
625
664
|
`).join("\n\n")}
|
|
626
665
|
`;
|
|
@@ -628,8 +667,7 @@ function reexportTypes(typesToExport, genericArgsLeft = "", genericArgsRight = c
|
|
|
628
667
|
var captureInBracketsRegex = /<(.*?)>/;
|
|
629
668
|
var captureGenericParamNameRegex = /^\s?(.+?)( extends .*?)?( = .*?)?\s?$/;
|
|
630
669
|
function cleanup(s) {
|
|
631
|
-
if (s.length === 0)
|
|
632
|
-
return "";
|
|
670
|
+
if (s.length === 0) return "";
|
|
633
671
|
const genericParameterNames = captureInBracketsRegex.exec(s)?.[1]?.split(",")?.map((a) => {
|
|
634
672
|
return captureGenericParamNameRegex.exec(a)?.[1] ?? a;
|
|
635
673
|
});
|
|
@@ -931,10 +969,7 @@ async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
|
|
|
931
969
|
await generateBaseTypesDir(runtimeDistDir, fs2, importExt);
|
|
932
970
|
await generateClientDir(runtimeDistDir, fs2, importExt);
|
|
933
971
|
await generateFiltersDir(runtimeDistDir, fs2, importExt);
|
|
934
|
-
await fs2.writeFile(
|
|
935
|
-
path16__namespace.join(runtimeDistDir, "index.ts"),
|
|
936
|
-
// TRASHFIXME
|
|
937
|
-
await formatTs(`
|
|
972
|
+
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "index.ts"), await formatTs(`
|
|
938
973
|
export * from "./aggregations/index${importExt}";
|
|
939
974
|
export * from "./baseTypes/index${importExt}";
|
|
940
975
|
${""}
|
|
@@ -944,8 +979,7 @@ async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
|
|
|
944
979
|
|
|
945
980
|
export * from "./ontologyProvider/index${importExt}";
|
|
946
981
|
export * from "./paging/index${importExt}";
|
|
947
|
-
`)
|
|
948
|
-
);
|
|
982
|
+
`));
|
|
949
983
|
}
|
|
950
984
|
|
|
951
985
|
// src/v1.1/generateBackCompatDeprecatedExports.ts
|
|
@@ -1308,10 +1342,10 @@ function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
|
1308
1342
|
case "union":
|
|
1309
1343
|
const allowNulls = isNullableQueryDataType(input);
|
|
1310
1344
|
if (allowNulls && input.unionTypes.length === 2) {
|
|
1311
|
-
const
|
|
1312
|
-
if (
|
|
1345
|
+
const nonNull = input.unionTypes.find((t) => t.type != null);
|
|
1346
|
+
if (nonNull) {
|
|
1313
1347
|
return {
|
|
1314
|
-
...wireQueryDataTypeToQueryDataTypeDefinition(
|
|
1348
|
+
...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),
|
|
1315
1349
|
nullable: true
|
|
1316
1350
|
};
|
|
1317
1351
|
}
|
|
@@ -1336,12 +1370,14 @@ function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
|
1336
1370
|
case "twoDimensionalAggregation":
|
|
1337
1371
|
return {
|
|
1338
1372
|
type: "twoDimensionalAggregation",
|
|
1339
|
-
twoDimensionalAggregation: get2DQueryAggregationProps(input)
|
|
1373
|
+
twoDimensionalAggregation: get2DQueryAggregationProps(input),
|
|
1374
|
+
nullable: false
|
|
1340
1375
|
};
|
|
1341
1376
|
case "threeDimensionalAggregation":
|
|
1342
1377
|
return {
|
|
1343
1378
|
type: "threeDimensionalAggregation",
|
|
1344
|
-
threeDimensionalAggregation: get3DQueryAggregationProps(input)
|
|
1379
|
+
threeDimensionalAggregation: get3DQueryAggregationProps(input),
|
|
1380
|
+
nullable: false
|
|
1345
1381
|
};
|
|
1346
1382
|
case "null":
|
|
1347
1383
|
case "unsupported":
|
|
@@ -1400,6 +1436,15 @@ function wireQueryTypeV2ToSdkQueryDefinition(input) {
|
|
|
1400
1436
|
output: wireQueryDataTypeToQueryDataTypeDefinition(input.output)
|
|
1401
1437
|
};
|
|
1402
1438
|
}
|
|
1439
|
+
function wireQueryTypeV2ToSdkQueryDefinitionNoParams(input) {
|
|
1440
|
+
return {
|
|
1441
|
+
type: "query",
|
|
1442
|
+
apiName: input.apiName,
|
|
1443
|
+
description: input.description,
|
|
1444
|
+
displayName: input.displayName,
|
|
1445
|
+
version: input.version
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1403
1448
|
function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
1404
1449
|
return {
|
|
1405
1450
|
description: parameter.description,
|
|
@@ -1408,19 +1453,36 @@ function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
|
1408
1453
|
}
|
|
1409
1454
|
|
|
1410
1455
|
// src/v1.1/generatePerQueryDataFiles.ts
|
|
1411
|
-
async function generatePerQueryDataFiles(ontology, fs2, outDir, importExt = "") {
|
|
1456
|
+
async function generatePerQueryDataFiles(ontology, fs2, outDir, importExt = "", v2 = false) {
|
|
1412
1457
|
await fs2.mkdir(outDir, {
|
|
1413
1458
|
recursive: true
|
|
1414
1459
|
});
|
|
1415
1460
|
await Promise.all(Object.values(ontology.queryTypes).map(async (query) => {
|
|
1416
1461
|
const objectTypes = getObjectTypesFromQuery(query);
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1462
|
+
const importObjects = objectTypes.length > 0 ? `import {${[...objectTypes].join(",")}} from "../objects${importExt}";` : "";
|
|
1463
|
+
if (v2) {
|
|
1464
|
+
await fs2.writeFile(path16__namespace.default.join(outDir, `${query.apiName}.ts`), await formatTs(`
|
|
1465
|
+
import { QueryDefinition } from "@osdk/api";
|
|
1466
|
+
${importObjects}
|
|
1467
|
+
export const ${query.apiName} = {
|
|
1468
|
+
${stringify(deleteUndefineds(wireQueryTypeV2ToSdkQueryDefinitionNoParams(query)))},
|
|
1469
|
+
parameters: {${Object.entries(query.parameters).map(([name, parameter]) => {
|
|
1470
|
+
return `${name} : {${stringify(deleteUndefineds(wireQueryParameterV2ToQueryParameterDefinition(parameter)))},
|
|
1471
|
+
${parameter.dataType.type === "object" || parameter.dataType.type === "objectSet" ? getOsdkTargetTypeIfPresent(parameter.dataType.objectTypeApiName, v2) : ``}}`;
|
|
1472
|
+
})}},
|
|
1473
|
+
output: {${stringify(deleteUndefineds(wireQueryDataTypeToQueryDataTypeDefinition(query.output)))},
|
|
1474
|
+
${query.output.type === "object" || query.output.type === "objectSet" ? getOsdkTargetTypeIfPresent(query.output.objectTypeApiName, v2) : ``}}
|
|
1475
|
+
} ${getQueryDefSatisfies(query.apiName, objectTypes)}`));
|
|
1476
|
+
} else {
|
|
1477
|
+
await fs2.writeFile(path16__namespace.default.join(outDir, `${query.apiName}.ts`), await formatTs(`
|
|
1478
|
+
import { QueryDefinition } from "@osdk/api";
|
|
1479
|
+
|
|
1480
|
+
export const ${query.apiName} = ${JSON.stringify(wireQueryTypeV2ToSdkQueryDefinition(query))} ${getQueryDefSatisfies(query.apiName, objectTypes)}`));
|
|
1481
|
+
}
|
|
1421
1482
|
}));
|
|
1422
1483
|
await fs2.writeFile(path16__namespace.default.join(outDir, "index.ts"), await formatTs(`
|
|
1423
1484
|
${Object.values(ontology.queryTypes).map((query) => `export * from "./${query.apiName}${importExt}";`).join("\n")}
|
|
1485
|
+
${Object.keys(ontology.queryTypes).length === 0 ? "export {};" : ""}
|
|
1424
1486
|
`));
|
|
1425
1487
|
}
|
|
1426
1488
|
function getObjectTypesFromQuery(query) {
|
|
@@ -1473,6 +1535,14 @@ function getObjectTypesFromDataType(dataType, types) {
|
|
|
1473
1535
|
throw new Error(`Cannot find object types from unsupported QueryDataType ${dataType.type}`);
|
|
1474
1536
|
}
|
|
1475
1537
|
}
|
|
1538
|
+
function getQueryDefSatisfies(apiName, objectTypes) {
|
|
1539
|
+
return `satisfies QueryDefinition<"${apiName}", ${objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never"}>;`;
|
|
1540
|
+
}
|
|
1541
|
+
function getOsdkTargetTypeIfPresent(objectTypeApiName, v2) {
|
|
1542
|
+
return `
|
|
1543
|
+
__OsdkTargetType: ${getObjectDefIdentifier(objectTypeApiName, v2)}
|
|
1544
|
+
`;
|
|
1545
|
+
}
|
|
1476
1546
|
async function generateQueries(ontology, fs2, outDir, importExt = "") {
|
|
1477
1547
|
const importedObjects = /* @__PURE__ */ new Set();
|
|
1478
1548
|
const signatures = [];
|
|
@@ -1622,7 +1692,7 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
|
|
|
1622
1692
|
const objectsDir = path16__namespace.join(outDir, "ontology", "objects");
|
|
1623
1693
|
const actionsDir = path16__namespace.join(outDir, "ontology", "actions");
|
|
1624
1694
|
const queriesDir = path16__namespace.join(outDir, "ontology", "queries");
|
|
1625
|
-
await
|
|
1695
|
+
await verifyOutDir(outDir, fs2);
|
|
1626
1696
|
await fs2.mkdir(outDir, {
|
|
1627
1697
|
recursive: true
|
|
1628
1698
|
});
|
|
@@ -1642,9 +1712,37 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
|
|
|
1642
1712
|
await generateIndexFile(fs2, outDir, importExt);
|
|
1643
1713
|
await generateBackCompatDeprecatedExports(fs2, outDir, importExt);
|
|
1644
1714
|
}
|
|
1645
|
-
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false) {
|
|
1715
|
+
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false) {
|
|
1646
1716
|
const definition = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef, v2));
|
|
1647
1717
|
const objectDefIdentifier = getObjectDefIdentifier(interfaceDef.apiName, v2);
|
|
1718
|
+
const parents = definition.implements?.map((p) => {
|
|
1719
|
+
!(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;
|
|
1720
|
+
const it = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.interfaceTypes[p], v2));
|
|
1721
|
+
return it;
|
|
1722
|
+
}) ?? [];
|
|
1723
|
+
const mergedProperties = {
|
|
1724
|
+
...definition.properties
|
|
1725
|
+
};
|
|
1726
|
+
for (const parent of parents) {
|
|
1727
|
+
for (const apiName of Object.keys(parent.properties)) {
|
|
1728
|
+
if (definition.properties[apiName] != null) {
|
|
1729
|
+
!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;
|
|
1730
|
+
} else if (mergedProperties[apiName] != null) {
|
|
1731
|
+
!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;
|
|
1732
|
+
}
|
|
1733
|
+
mergedProperties[apiName] = parent.properties[apiName];
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
const ogProperties = definition.properties;
|
|
1737
|
+
definition.properties = mergedProperties;
|
|
1738
|
+
function localPropertyJsdoc(apiName) {
|
|
1739
|
+
const property = definition.properties[apiName];
|
|
1740
|
+
const isInherited = ogProperties[apiName] == null;
|
|
1741
|
+
return propertyJsdoc(property, {
|
|
1742
|
+
isInherited,
|
|
1743
|
+
apiName
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1648
1746
|
function getV2Types() {
|
|
1649
1747
|
return `
|
|
1650
1748
|
export interface ${objectDefIdentifier} extends InterfaceDefinition<"${interfaceDef.apiName}", ${interfaceDef.apiName}>, VersionBound<$ExpectedClientVersion> {
|
|
@@ -1658,9 +1756,9 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false
|
|
|
1658
1756
|
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
1659
1757
|
})}
|
|
1660
1758
|
}`,
|
|
1661
|
-
properties: (
|
|
1662
|
-
${stringify(
|
|
1663
|
-
"*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
|
|
1759
|
+
properties: (properties) => `{
|
|
1760
|
+
${stringify(properties, {
|
|
1761
|
+
"*": (propertyDefinition, _, key) => [`${localPropertyJsdoc(key)}${key}`, `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`]
|
|
1664
1762
|
})}
|
|
1665
1763
|
}`
|
|
1666
1764
|
})}
|
|
@@ -1681,7 +1779,7 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false
|
|
|
1681
1779
|
|
|
1682
1780
|
};`;
|
|
1683
1781
|
}
|
|
1684
|
-
var ExpectedOsdkVersion = "0.
|
|
1782
|
+
var ExpectedOsdkVersion = "0.20.0";
|
|
1685
1783
|
async function generateOntologyMetadataFile(ontology, userAgent, fs2, outDir) {
|
|
1686
1784
|
fs2.writeFile(path16__namespace.default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
1687
1785
|
import { OntologyMetadata as OM } from "@osdk/api";
|
|
@@ -1702,11 +1800,11 @@ async function generateOntologyMetadataFile(ontology, userAgent, fs2, outDir) {
|
|
|
1702
1800
|
|
|
1703
1801
|
// src/v2.0/generateClientSdkVersionTwoPointZero.ts
|
|
1704
1802
|
async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, outDir, packageType = "commonjs") {
|
|
1705
|
-
await
|
|
1803
|
+
await verifyOutDir(outDir, fs2);
|
|
1706
1804
|
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
1707
1805
|
const objectNames = Object.keys(sanitizedOntology.objectTypes).sort((a, b) => a.localeCompare(b));
|
|
1708
1806
|
const actionNames = Object.keys(sanitizedOntology.actionTypes).sort((a, b) => a.localeCompare(b));
|
|
1709
|
-
Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
|
|
1807
|
+
const queryNames = Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
|
|
1710
1808
|
const interfaceNames = Object.keys(sanitizedOntology.interfaceTypes ?? {}).sort((a, b) => a.localeCompare(b));
|
|
1711
1809
|
const importExt = packageType === "module" ? ".js" : "";
|
|
1712
1810
|
await fs2.mkdir(outDir, {
|
|
@@ -1717,6 +1815,7 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1717
1815
|
export * from "./ontology/actions/index${importExt}";
|
|
1718
1816
|
export * from "./ontology/objects${importExt}";
|
|
1719
1817
|
export * from "./ontology/interfaces${importExt}";
|
|
1818
|
+
export * from "./ontology/queries/index${importExt}";
|
|
1720
1819
|
`));
|
|
1721
1820
|
await generateOntologyMetadataFile(sanitizedOntology, userAgent, fs2, outDir);
|
|
1722
1821
|
await fs2.writeFile(path16__namespace.default.join(outDir, "Ontology.ts"), await formatTs(`
|
|
@@ -1724,6 +1823,7 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1724
1823
|
import * as Actions from "./ontology/actions/index${importExt}";
|
|
1725
1824
|
import * as Objects from "./ontology/objects${importExt}";
|
|
1726
1825
|
import * as Interfaces from "./ontology/interfaces${importExt}";
|
|
1826
|
+
import * as Queries from "./ontology/queries/index${importExt}";
|
|
1727
1827
|
import { OntologyMetadata } from "./OntologyMetadata${importExt}";
|
|
1728
1828
|
|
|
1729
1829
|
export interface Ontology extends OntologyDefinition<${stringUnionFrom2(objectNames)}> {
|
|
@@ -1739,7 +1839,9 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1739
1839
|
}).join(",\n")}
|
|
1740
1840
|
},
|
|
1741
1841
|
queries: {
|
|
1742
|
-
|
|
1842
|
+
${queryNames.map((queryName) => {
|
|
1843
|
+
return `${queryName}: typeof Queries.${queryName}`;
|
|
1844
|
+
}).join(",\n")}
|
|
1743
1845
|
},
|
|
1744
1846
|
interfaces: {
|
|
1745
1847
|
${interfaceNames.map((objectName) => {
|
|
@@ -1762,7 +1864,9 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1762
1864
|
}).join(",\n")}
|
|
1763
1865
|
},
|
|
1764
1866
|
queries: {
|
|
1765
|
-
|
|
1867
|
+
${queryNames.map((queryName) => {
|
|
1868
|
+
return `${queryName}: Queries.${queryName}`;
|
|
1869
|
+
}).join(",\n")}
|
|
1766
1870
|
},
|
|
1767
1871
|
interfaces: {
|
|
1768
1872
|
${interfaceNames.map((objectName) => {
|
|
@@ -1797,6 +1901,11 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1797
1901
|
${Object.keys(ontology.objectTypes).sort((a, b) => a.localeCompare(b)).map((apiName) => `export * from "./objects/${apiName}${importExt}";`).join("\n")}
|
|
1798
1902
|
${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
|
|
1799
1903
|
`));
|
|
1904
|
+
const queriesDir = path16__namespace.default.join(outDir, "ontology", "queries");
|
|
1905
|
+
await fs2.mkdir(queriesDir, {
|
|
1906
|
+
recursive: true
|
|
1907
|
+
});
|
|
1908
|
+
await generatePerQueryDataFiles(sanitizedOntology, fs2, queriesDir, importExt, true);
|
|
1800
1909
|
}
|
|
1801
1910
|
function stringUnionFrom2(values) {
|
|
1802
1911
|
if (values.length === 0) {
|
|
@@ -1818,7 +1927,7 @@ async function generateOntologyInterfaces(fs2, outDir, interfaceNames, ontology,
|
|
|
1818
1927
|
import { $osdkMetadata, $expectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1819
1928
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1820
1929
|
|
|
1821
|
-
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, true)}
|
|
1930
|
+
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true)}
|
|
1822
1931
|
`));
|
|
1823
1932
|
}
|
|
1824
1933
|
await fs2.writeFile(interfacesDir + ".ts", await formatTs(`
|
|
@@ -1829,8 +1938,7 @@ async function generateOntologyInterfaces(fs2, outDir, interfaceNames, ontology,
|
|
|
1829
1938
|
|
|
1830
1939
|
// src/generateClientSdkPackage.ts
|
|
1831
1940
|
async function generateClientSdkPackage(packageName, packageVersion, sdkVersion, baseOutDir, ontology, minimalFs, dependencyVersions, cliVersion) {
|
|
1832
|
-
if (!packageName)
|
|
1833
|
-
throw new Error("Package name is require");
|
|
1941
|
+
if (!packageName) throw new Error("Package name is require");
|
|
1834
1942
|
for (const packageType of ["module", "commonjs"]) {
|
|
1835
1943
|
const outDir = path16__namespace.join(baseOutDir, "dist", packageType);
|
|
1836
1944
|
await (sdkVersion === "1.1" ? generateClientSdkVersionOneDotOne : sdkVersion === "2.0" ? generateClientSdkVersionTwoPointZero : void 0)(ontology, `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`, minimalFs, outDir, packageType);
|
|
@@ -1951,5 +2059,5 @@ exports.__UNSTABLE_generateClientSdkPackage = generateClientSdkPackage;
|
|
|
1951
2059
|
exports.generateClientSdkVersionOneDotOne = generateClientSdkVersionOneDotOne;
|
|
1952
2060
|
exports.generateClientSdkVersionTwoPointZero = generateClientSdkVersionTwoPointZero;
|
|
1953
2061
|
exports.getExpectedDependencies = getExpectedDependencies;
|
|
1954
|
-
//# sourceMappingURL=
|
|
2062
|
+
//# sourceMappingURL=index.cjs.map
|
|
1955
2063
|
//# sourceMappingURL=index.cjs.map
|