@osdk/foundry-sdk-generator 2.1.0-beta.9 → 2.1.0
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 +438 -0
- package/build/esm/index.js +121 -61
- package/build/esm/index.js.map +1 -1
- package/build/types/cli/foundrySdkGeneratorCli.d.ts +1 -0
- package/build/types/cli/foundrySdkGeneratorCli.d.ts.map +1 -0
- package/build/types/generate/GeneratePackageCommand.d.ts +24 -0
- package/build/types/generate/GeneratePackageCommand.d.ts.map +1 -0
- package/build/types/generate/betaClient/__tests__/bundleDependencies.test.d.ts +1 -0
- package/build/types/generate/betaClient/__tests__/bundleDependencies.test.d.ts.map +1 -0
- package/build/{esm → types}/generate/betaClient/bundleDependencies.d.ts +1 -2
- package/build/types/generate/betaClient/bundleDependencies.d.ts.map +1 -0
- package/build/types/generate/betaClient/compileInMemory.d.ts +15 -0
- package/build/types/generate/betaClient/compileInMemory.d.ts.map +1 -0
- package/build/{esm → types}/generate/betaClient/copyFiles.d.ts +1 -2
- package/build/types/generate/betaClient/copyFiles.d.ts.map +1 -0
- package/build/{esm → types}/generate/betaClient/generatePackage.d.ts +4 -5
- package/build/types/generate/betaClient/generatePackage.d.ts.map +1 -0
- package/build/types/generate/betaClient/generatePackageJson.d.ts +24 -0
- package/build/types/generate/betaClient/generatePackageJson.d.ts.map +1 -0
- package/build/types/generate/betaClient/getModuleSourceFile.d.ts +3 -0
- package/build/types/generate/betaClient/getModuleSourceFile.d.ts.map +1 -0
- package/build/types/generate/betaClient/minifyBundle.d.ts +22 -0
- package/build/types/generate/betaClient/minifyBundle.d.ts.map +1 -0
- package/build/{esm → types}/generate/commandUtils.d.ts +0 -1
- package/build/types/generate/commandUtils.d.ts.map +1 -0
- package/build/{esm → types}/generate/generateBundles.d.ts +0 -1
- package/build/types/generate/generateBundles.d.ts.map +1 -0
- package/build/types/generate/index.d.ts +2 -0
- package/build/types/generate/index.d.ts.map +1 -0
- package/build/{esm → types}/index.d.ts +0 -1
- package/build/types/index.d.ts.map +1 -0
- package/build/types/ontologyMetadata/Result.d.ts +55 -0
- package/build/types/ontologyMetadata/Result.d.ts.map +1 -0
- package/build/{esm → types}/ontologyMetadata/index.d.ts +0 -1
- package/build/types/ontologyMetadata/index.d.ts.map +1 -0
- package/build/types/ontologyMetadata/metadataResolver.test.d.ts +1 -0
- package/build/types/ontologyMetadata/metadataResolver.test.d.ts.map +1 -0
- package/build/types/ontologyMetadata/ontologyMetadataResolver.d.ts +35 -0
- package/build/types/ontologyMetadata/ontologyMetadataResolver.d.ts.map +1 -0
- package/build/{esm → types}/utils/UserAgent.d.ts +0 -1
- package/build/types/utils/UserAgent.d.ts.map +1 -0
- package/build/types/utils/index.d.ts +1 -0
- package/build/types/utils/index.d.ts.map +1 -0
- package/build/{esm → types}/utils/semverUtils.d.ts +0 -1
- package/build/types/utils/semverUtils.d.ts.map +1 -0
- package/package.json +26 -26
- package/build/browser/index.js +0 -1049
- package/build/browser/index.js.map +0 -1
- package/build/esm/cli/foundrySdkGeneratorCli.d.ts +0 -6
- package/build/esm/cli/foundrySdkGeneratorCli.d.ts.map +0 -1
- package/build/esm/generate/GeneratePackageCommand.d.ts +0 -25
- package/build/esm/generate/GeneratePackageCommand.d.ts.map +0 -1
- package/build/esm/generate/betaClient/__tests__/bundleDependencies.test.d.ts +0 -2
- package/build/esm/generate/betaClient/__tests__/bundleDependencies.test.d.ts.map +0 -1
- package/build/esm/generate/betaClient/bundleDependencies.d.ts.map +0 -1
- package/build/esm/generate/betaClient/compileInMemory.d.ts +0 -18
- package/build/esm/generate/betaClient/compileInMemory.d.ts.map +0 -1
- package/build/esm/generate/betaClient/copyFiles.d.ts.map +0 -1
- package/build/esm/generate/betaClient/generatePackage.d.ts.map +0 -1
- package/build/esm/generate/betaClient/generatePackageJson.d.ts +0 -15
- package/build/esm/generate/betaClient/generatePackageJson.d.ts.map +0 -1
- package/build/esm/generate/betaClient/getModuleSourceFile.d.ts +0 -4
- package/build/esm/generate/betaClient/getModuleSourceFile.d.ts.map +0 -1
- package/build/esm/generate/betaClient/minifyBundle.d.ts +0 -23
- package/build/esm/generate/betaClient/minifyBundle.d.ts.map +0 -1
- package/build/esm/generate/commandUtils.d.ts.map +0 -1
- package/build/esm/generate/generateBundles.d.ts.map +0 -1
- package/build/esm/generate/index.d.ts +0 -3
- package/build/esm/generate/index.d.ts.map +0 -1
- package/build/esm/index.d.ts.map +0 -1
- package/build/esm/ontologyMetadata/Result.d.ts +0 -32
- package/build/esm/ontologyMetadata/Result.d.ts.map +0 -1
- package/build/esm/ontologyMetadata/index.d.ts.map +0 -1
- package/build/esm/ontologyMetadata/metadataResolver.test.d.ts +0 -2
- package/build/esm/ontologyMetadata/metadataResolver.test.d.ts.map +0 -1
- package/build/esm/ontologyMetadata/ontologyMetadataResolver.d.ts +0 -36
- package/build/esm/ontologyMetadata/ontologyMetadataResolver.d.ts.map +0 -1
- package/build/esm/utils/UserAgent.d.ts.map +0 -1
- package/build/esm/utils/index.d.ts +0 -2
- package/build/esm/utils/index.d.ts.map +0 -1
- package/build/esm/utils/semverUtils.d.ts.map +0 -1
package/build/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import path2__default, { join, dirname, isAbsolute, normalize } from 'path';
|
|
|
4
4
|
import yargs from 'yargs';
|
|
5
5
|
import { hideBin } from 'yargs/helpers';
|
|
6
6
|
import { exit } from 'process';
|
|
7
|
-
import {
|
|
7
|
+
import { createSharedClientContext } from '@osdk/shared.client.impl';
|
|
8
8
|
import { generateClientSdkVersionTwoPointZero } from '@osdk/generator';
|
|
9
9
|
import { mkdir, writeFile, readdir, readFile } from 'fs/promises';
|
|
10
10
|
import commonjs from '@rollup/plugin-commonjs';
|
|
@@ -15,7 +15,7 @@ import { Project, Node } from 'ts-morph';
|
|
|
15
15
|
import * as fs from 'fs';
|
|
16
16
|
import { ModuleKind, ScriptTarget, createCompilerHost, createSourceFile, createProgram } from 'typescript';
|
|
17
17
|
|
|
18
|
-
// ../../node_modules/.pnpm/tsup@8.2.3_@microsoft+api-extractor@7.
|
|
18
|
+
// ../../node_modules/.pnpm/tsup@8.2.3_@microsoft+api-extractor@7.49.1_@types+node@18.19.74__@swc+core@1.7.39_jiti@2.4.2__cusz3dqci6tomwziqqbdrtlnre/node_modules/tsup/assets/esm_shims.js
|
|
19
19
|
var getFilename = () => fileURLToPath(import.meta.url);
|
|
20
20
|
var getDirname = () => path2__default.dirname(getFilename());
|
|
21
21
|
var __dirname = /* @__PURE__ */ getDirname();
|
|
@@ -192,7 +192,7 @@ var OntologyMetadataResolver = class {
|
|
|
192
192
|
this.#authToken = authToken;
|
|
193
193
|
}
|
|
194
194
|
getClientContext() {
|
|
195
|
-
return
|
|
195
|
+
return createSharedClientContext(this.stackName.match(/^https?:\/\//) ? this.stackName : `https://${this.stackName}`, () => Promise.resolve(this.#authToken), `foundry-typescript-osdk-generator/${process.env.npm_package_version}`);
|
|
196
196
|
}
|
|
197
197
|
filterMetadataByApiName(ontologyFullMetadata, expectedEntities, pkgInfo) {
|
|
198
198
|
const filteredObjectTypes = Object.fromEntries(Object.entries(ontologyFullMetadata.objectTypes).filter(([, {
|
|
@@ -258,14 +258,11 @@ var OntologyMetadataResolver = class {
|
|
|
258
258
|
}
|
|
259
259
|
async getWireOntologyDefinition(ontologyRid, entities, extPackageInfo = /* @__PURE__ */ new Map()) {
|
|
260
260
|
let ontology;
|
|
261
|
-
const {
|
|
262
|
-
Ontologies
|
|
263
|
-
} = await import('@osdk/internal.foundry.ontologies');
|
|
264
261
|
const {
|
|
265
262
|
OntologiesV2
|
|
266
|
-
} = await import('@osdk/
|
|
263
|
+
} = await import('@osdk/foundry.ontologies');
|
|
267
264
|
try {
|
|
268
|
-
ontology = await
|
|
265
|
+
ontology = await OntologiesV2.get(this.getClientContext(), ontologyRid);
|
|
269
266
|
} catch (e) {
|
|
270
267
|
return Result.err([`Unable to load the specified Ontology with network error: ${JSON.stringify(e)}`]);
|
|
271
268
|
}
|
|
@@ -321,7 +318,8 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
321
318
|
objectTypes,
|
|
322
319
|
linkTypes,
|
|
323
320
|
actionTypes,
|
|
324
|
-
queryTypes
|
|
321
|
+
queryTypes,
|
|
322
|
+
interfaceTypes
|
|
325
323
|
}, ontologyFullMetadata, extPackageInfo);
|
|
326
324
|
if (validData.isErr()) {
|
|
327
325
|
return Result.err(validData.error);
|
|
@@ -336,6 +334,7 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
336
334
|
const errors = [];
|
|
337
335
|
const loadedObjectTypes = Object.fromEntries(Object.values(filteredFullMetadata.objectTypes).map((object) => [object.objectType.apiName, object]));
|
|
338
336
|
const loadedLinkTypes = Object.fromEntries(Object.values(filteredFullMetadata.objectTypes).map((object) => [object.objectType.apiName, Object.fromEntries(object.linkTypes.map((link) => [link.apiName, link]))]));
|
|
337
|
+
const loadedInterfaceTypes = Object.fromEntries(Object.values(filteredFullMetadata.interfaceTypes).map((interfaceType) => [interfaceType.apiName, interfaceType]));
|
|
339
338
|
const missingObjectTypes = [];
|
|
340
339
|
for (const object of expectedEntities.objectTypes) {
|
|
341
340
|
if (!loadedObjectTypes[object]) {
|
|
@@ -360,6 +359,16 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
360
359
|
if (missingObjectTypes.length > 0) {
|
|
361
360
|
errors.push(`Unable to find the following Object Types: ${missingObjectTypes.join(", ")}`);
|
|
362
361
|
}
|
|
362
|
+
const missingInterfaceTypes = [];
|
|
363
|
+
for (const expectedInterface of expectedEntities.interfaceTypes) {
|
|
364
|
+
if (!loadedInterfaceTypes[expectedInterface]) {
|
|
365
|
+
missingInterfaceTypes.push(expectedInterface);
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (missingInterfaceTypes.length > 0) {
|
|
370
|
+
errors.push(`Unable to find the following Interface Types: ${missingInterfaceTypes.join(", ")}`);
|
|
371
|
+
}
|
|
363
372
|
const loadedQueryTypes = Object.fromEntries(Object.entries(filteredFullMetadata.queryTypes).map(([queryApiName, query]) => [queryApiName, query]));
|
|
364
373
|
const missingQueryTypes = [];
|
|
365
374
|
for (const queryApiName of expectedEntities.queryTypes) {
|
|
@@ -386,7 +395,7 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
386
395
|
}
|
|
387
396
|
}
|
|
388
397
|
for (const action of Object.values(loadedActionTypes)) {
|
|
389
|
-
const result = this.validateActionParameters(action, expectedEntities.objectTypes);
|
|
398
|
+
const result = this.validateActionParameters(action, expectedEntities.objectTypes, expectedEntities.interfaceTypes);
|
|
390
399
|
if (result.isErr()) {
|
|
391
400
|
for (const errorString of result.error) {
|
|
392
401
|
errors.push(errorString);
|
|
@@ -407,9 +416,9 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
407
416
|
const results = Result.coalesce(parameterValidation);
|
|
408
417
|
return results;
|
|
409
418
|
}
|
|
410
|
-
validateActionParameters(actionType, loadedObjectApiNames) {
|
|
419
|
+
validateActionParameters(actionType, loadedObjectApiNames, loadedInterfaceApiNames) {
|
|
411
420
|
const camelizedApiName = this.camelize(actionType.apiName);
|
|
412
|
-
const parameterValidation = Object.entries(actionType.parameters).map(([_paramName, paramData]) => this.isSupportedActionTypeParameter(camelizedApiName, paramData.dataType, loadedObjectApiNames));
|
|
421
|
+
const parameterValidation = Object.entries(actionType.parameters).map(([_paramName, paramData]) => this.isSupportedActionTypeParameter(camelizedApiName, paramData.dataType, loadedObjectApiNames, loadedInterfaceApiNames));
|
|
413
422
|
return Result.coalesce(parameterValidation);
|
|
414
423
|
}
|
|
415
424
|
visitSupportedQueryTypes(queryApiName, propertyName, baseType, loadedObjectApiNames) {
|
|
@@ -454,10 +463,10 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
454
463
|
return Result.err([`Unable to load query ${queryApiName} because it takes an unsupported parameter type: ${JSON.stringify(baseType)} in parameter ${propertyName}`]);
|
|
455
464
|
}
|
|
456
465
|
}
|
|
457
|
-
isSupportedActionTypeParameter(actionApiName, actonTypeParameter, loadedObjectApiNames) {
|
|
466
|
+
isSupportedActionTypeParameter(actionApiName, actonTypeParameter, loadedObjectApiNames, loadedInterfaceApiNames) {
|
|
458
467
|
switch (actonTypeParameter.type) {
|
|
459
468
|
case "array":
|
|
460
|
-
return this.isSupportedActionTypeParameter(actionApiName, actonTypeParameter.subType, loadedObjectApiNames);
|
|
469
|
+
return this.isSupportedActionTypeParameter(actionApiName, actonTypeParameter.subType, loadedObjectApiNames, loadedInterfaceApiNames);
|
|
461
470
|
case "object":
|
|
462
471
|
if (loadedObjectApiNames.has(actonTypeParameter.objectTypeApiName)) {
|
|
463
472
|
return Result.ok({});
|
|
@@ -468,6 +477,11 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
468
477
|
return Result.ok({});
|
|
469
478
|
}
|
|
470
479
|
return Result.err([`Unable to load action ${actionApiName} because it takes an ObjectSet of unloaded object type as a parameter: ${actonTypeParameter.objectTypeApiName} make sure to specify it as an argument with --ontologyObjects ${actonTypeParameter.objectTypeApiName})`]);
|
|
480
|
+
case "interfaceObject":
|
|
481
|
+
if (loadedInterfaceApiNames.has(actonTypeParameter.interfaceTypeApiName)) {
|
|
482
|
+
return Result.ok({});
|
|
483
|
+
}
|
|
484
|
+
return Result.err([`Unable to load action ${actionApiName} because it takes an unloaded interface type as a parameter: ${actonTypeParameter.interfaceTypeApiName} make sure to specify it as an argument with --ontologyInterfaces ${actonTypeParameter.interfaceTypeApiName}`]);
|
|
471
485
|
case "string":
|
|
472
486
|
case "boolean":
|
|
473
487
|
case "attachment":
|
|
@@ -476,6 +490,9 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
476
490
|
case "integer":
|
|
477
491
|
case "long":
|
|
478
492
|
case "timestamp":
|
|
493
|
+
case "struct":
|
|
494
|
+
case "mediaReference":
|
|
495
|
+
case "objectType":
|
|
479
496
|
return Result.ok({});
|
|
480
497
|
default:
|
|
481
498
|
return Result.err([`Unable to load action ${actionApiName} because it takes an unsupported parameter: ${JSON.stringify(actonTypeParameter)} specify only the actions you want to load with the --actions argument.`]);
|
|
@@ -533,7 +550,7 @@ async function getDependencyVersionFromFindUpPackageJson(name, opts) {
|
|
|
533
550
|
findUp
|
|
534
551
|
} = await import('find-up');
|
|
535
552
|
const packageJsonPath = await findUp("package.json", opts);
|
|
536
|
-
!(packageJsonPath !==
|
|
553
|
+
!(packageJsonPath !== undefined) ? process.env.NODE_ENV !== "production" ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not find package.json") : invariant() : process.env.NODE_ENV !== "production" ? invariant() : invariant() : undefined;
|
|
537
554
|
const packageJson = await readFile(packageJsonPath, {
|
|
538
555
|
encoding: "utf-8"
|
|
539
556
|
});
|
|
@@ -542,7 +559,7 @@ async function getDependencyVersionFromFindUpPackageJson(name, opts) {
|
|
|
542
559
|
}
|
|
543
560
|
const parsedPackageJson = JSON.parse(packageJson);
|
|
544
561
|
const version = parsedPackageJson.dependencies?.[name] ?? parsedPackageJson.devDependencies?.[name] ?? parsedPackageJson.peerDependencies?.[name];
|
|
545
|
-
!(version !==
|
|
562
|
+
!(version !== undefined) ? process.env.NODE_ENV !== "production" ? process.env.NODE_ENV !== "production" ? invariant(false, `Could not find a dependency for ${name} in ${packageJsonPath}`) : invariant() : process.env.NODE_ENV !== "production" ? invariant() : invariant() : undefined;
|
|
546
563
|
return version;
|
|
547
564
|
}
|
|
548
565
|
|
|
@@ -559,9 +576,9 @@ async function resolveDependenciesFromFindUp(deps, cwd) {
|
|
|
559
576
|
}
|
|
560
577
|
|
|
561
578
|
// src/utils/UserAgent.ts
|
|
562
|
-
var USER_AGENT = `typescript-sdk-generator/${"2.1.0
|
|
579
|
+
var USER_AGENT = `typescript-sdk-generator/${"2.1.0"}`;
|
|
563
580
|
async function createRollupBuild(absolutePackagePath, packageName) {
|
|
564
|
-
const inputPath = `${absolutePackagePath}/${packageName}/index.js`;
|
|
581
|
+
const inputPath = `${absolutePackagePath}/${packageName}/esm/index.js`;
|
|
565
582
|
const {
|
|
566
583
|
findUp
|
|
567
584
|
} = await import('find-up');
|
|
@@ -569,7 +586,7 @@ async function createRollupBuild(absolutePackagePath, packageName) {
|
|
|
569
586
|
cwd: __dirname,
|
|
570
587
|
type: "directory"
|
|
571
588
|
});
|
|
572
|
-
return rollup({
|
|
589
|
+
return await rollup({
|
|
573
590
|
input: inputPath,
|
|
574
591
|
plugins: [nodeResolve({
|
|
575
592
|
browser: true,
|
|
@@ -584,7 +601,7 @@ async function createRollupBuild(absolutePackagePath, packageName) {
|
|
|
584
601
|
});
|
|
585
602
|
}
|
|
586
603
|
async function writeRollupBuild(rollupBuild, absolutePackagePath, packageName, format) {
|
|
587
|
-
const outputPath = `${absolutePackagePath}/${packageName}/dist/bundle/index.${
|
|
604
|
+
const outputPath = `${absolutePackagePath}/${packageName}/dist/bundle/index.${"mjs"}`;
|
|
588
605
|
await Promise.all([rollupBuild.write({
|
|
589
606
|
file: outputPath,
|
|
590
607
|
format,
|
|
@@ -771,11 +788,12 @@ function outputModule(project) {
|
|
|
771
788
|
});
|
|
772
789
|
return modules.join("\n");
|
|
773
790
|
}
|
|
774
|
-
function compileInMemory(files,
|
|
791
|
+
function compileInMemory(files, type) {
|
|
775
792
|
const inMemoryOutputFileSystem = {};
|
|
776
793
|
const compilerOptions = {
|
|
777
|
-
module:
|
|
778
|
-
target: ScriptTarget.
|
|
794
|
+
module: type === "cjs" ? ModuleKind.CommonJS : ModuleKind.ES2022,
|
|
795
|
+
target: ScriptTarget.ES2020,
|
|
796
|
+
resolvePackageJsonExports: true,
|
|
779
797
|
declaration: true,
|
|
780
798
|
skipLibCheck: true
|
|
781
799
|
};
|
|
@@ -786,7 +804,7 @@ function compileInMemory(files, opts) {
|
|
|
786
804
|
const originalSourceFile = compilerHost.getSourceFile;
|
|
787
805
|
compilerHost.getSourceFile = (fileName, languageVersion) => {
|
|
788
806
|
const sourceText = files[fileName];
|
|
789
|
-
return sourceText !==
|
|
807
|
+
return sourceText !== undefined ? createSourceFile(fileName, sourceText, languageVersion) : originalSourceFile(fileName, languageVersion);
|
|
790
808
|
};
|
|
791
809
|
const program = createProgram(Object.keys(files), compilerOptions, compilerHost);
|
|
792
810
|
const emitOutput = program.emit();
|
|
@@ -801,23 +819,32 @@ async function generatePackageJson(options) {
|
|
|
801
819
|
const packageJson = {
|
|
802
820
|
name: options.packageName,
|
|
803
821
|
version: options.packageVersion,
|
|
804
|
-
main: "./index.js",
|
|
805
|
-
types: "./index.d.ts",
|
|
822
|
+
main: "./cjs/index.js",
|
|
823
|
+
types: "./cjs/index.d.ts",
|
|
806
824
|
exports: {
|
|
807
825
|
".": {
|
|
808
|
-
types: "./index.d.ts",
|
|
809
826
|
script: {
|
|
810
|
-
types: "./dist/bundle/index.d.
|
|
811
|
-
default: "./dist/bundle/index.
|
|
827
|
+
types: "./dist/bundle/index.d.mts",
|
|
828
|
+
default: "./dist/bundle/index.mjs"
|
|
812
829
|
},
|
|
813
|
-
|
|
830
|
+
require: {
|
|
831
|
+
types: "./cjs/index.d.ts",
|
|
832
|
+
default: "./cjs/index.js"
|
|
833
|
+
},
|
|
834
|
+
import: {
|
|
835
|
+
types: "./esm/index.d.ts",
|
|
836
|
+
default: "./esm/index.js"
|
|
837
|
+
},
|
|
838
|
+
types: "./cjs/index.d.ts",
|
|
839
|
+
default: "./cjs/index.js"
|
|
814
840
|
}
|
|
815
841
|
},
|
|
816
842
|
dependencies: packageDeps,
|
|
817
843
|
peerDependencies: packagePeerDeps,
|
|
818
|
-
type: "
|
|
844
|
+
type: "commonjs"
|
|
819
845
|
};
|
|
820
|
-
await writeFile(join(options.packagePath, "package.json"), JSON.stringify(packageJson,
|
|
846
|
+
await writeFile(join(options.packagePath, "package.json"), JSON.stringify(packageJson, undefined, 4));
|
|
847
|
+
return packageJson;
|
|
821
848
|
}
|
|
822
849
|
function constructDependencies(dependencies) {
|
|
823
850
|
return dependencies?.reduce((acc, value) => {
|
|
@@ -828,12 +855,13 @@ function constructDependencies(dependencies) {
|
|
|
828
855
|
|
|
829
856
|
// src/generate/betaClient/generatePackage.ts
|
|
830
857
|
var betaPeerDependencies = {
|
|
831
|
-
"@osdk/client":
|
|
858
|
+
"@osdk/client": undefined
|
|
832
859
|
};
|
|
833
860
|
async function generatePackage(ontologyInfo, options) {
|
|
834
861
|
const {
|
|
835
862
|
consola
|
|
836
863
|
} = await import('consola');
|
|
864
|
+
let success = true;
|
|
837
865
|
const packagePath = join(options.outputDir, options.packageName);
|
|
838
866
|
const resolvedPeerDependencies = await resolveDependenciesFromFindUp(betaPeerDependencies, dirname(fileURLToPath(import.meta.url)));
|
|
839
867
|
await mkdir(packagePath, {
|
|
@@ -841,8 +869,8 @@ async function generatePackage(ontologyInfo, options) {
|
|
|
841
869
|
});
|
|
842
870
|
const inMemoryFileSystem = {};
|
|
843
871
|
const hostFs = {
|
|
844
|
-
writeFile: async (path3,
|
|
845
|
-
inMemoryFileSystem[normalize(path3)] =
|
|
872
|
+
writeFile: async (path3, contents2) => {
|
|
873
|
+
inMemoryFileSystem[normalize(path3)] = contents2;
|
|
846
874
|
},
|
|
847
875
|
mkdir: async (path3, _options) => {
|
|
848
876
|
await mkdir(normalize(path3), {
|
|
@@ -852,10 +880,47 @@ async function generatePackage(ontologyInfo, options) {
|
|
|
852
880
|
readdir: (path3) => readdir(path3)
|
|
853
881
|
};
|
|
854
882
|
await generateClientSdkVersionTwoPointZero(ontologyInfo.filteredFullMetadata, `typescript-sdk/${options.packageVersion} ${USER_AGENT}`, hostFs, packagePath, "module", ontologyInfo.externalObjects, ontologyInfo.externalInterfaces);
|
|
855
|
-
const
|
|
856
|
-
|
|
883
|
+
const contents = await generatePackageJson({
|
|
884
|
+
packageName: options.packageName,
|
|
885
|
+
packagePath,
|
|
886
|
+
packageVersion: options.packageVersion,
|
|
887
|
+
dependencies: [],
|
|
888
|
+
peerDependencies: resolvedPeerDependencies,
|
|
889
|
+
beta: options.beta
|
|
857
890
|
});
|
|
858
|
-
compilerOutput
|
|
891
|
+
const compilerOutput = {};
|
|
892
|
+
for (const type of ["esm", "cjs"]) {
|
|
893
|
+
await hostFs.writeFile(join(packagePath, "package.json"), JSON.stringify({
|
|
894
|
+
...contents,
|
|
895
|
+
type: type === "cjs" ? "commonjs" : "module"
|
|
896
|
+
}));
|
|
897
|
+
compilerOutput[type] = compileInMemory(inMemoryFileSystem, type);
|
|
898
|
+
compilerOutput[type].diagnostics.forEach((d) => {
|
|
899
|
+
consola.error(`Error compiling file`, d.file?.fileName, d.messageText);
|
|
900
|
+
success = false;
|
|
901
|
+
});
|
|
902
|
+
await mkdir(join(packagePath, "dist", "bundle"), {
|
|
903
|
+
recursive: true
|
|
904
|
+
});
|
|
905
|
+
await mkdir(join(packagePath, "esm"), {
|
|
906
|
+
recursive: true
|
|
907
|
+
});
|
|
908
|
+
await mkdir(join(packagePath, "cjs"), {
|
|
909
|
+
recursive: true
|
|
910
|
+
});
|
|
911
|
+
for (const [path3, contents2] of Object.entries(compilerOutput[type].files)) {
|
|
912
|
+
const newPath = path3.replace(packagePath, join(packagePath, type));
|
|
913
|
+
await mkdir(dirname(newPath), {
|
|
914
|
+
recursive: true
|
|
915
|
+
});
|
|
916
|
+
await writeFile(newPath, contents2, {
|
|
917
|
+
flag: "w"
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
void await writeFile(join(packagePath, type, "package.json"), JSON.stringify({
|
|
921
|
+
type: type === "esm" ? "module" : "commonjs"
|
|
922
|
+
}));
|
|
923
|
+
}
|
|
859
924
|
await mkdir(join(packagePath, "dist", "bundle"), {
|
|
860
925
|
recursive: true
|
|
861
926
|
});
|
|
@@ -869,40 +934,35 @@ async function generatePackage(ontologyInfo, options) {
|
|
|
869
934
|
let bundleDts = "";
|
|
870
935
|
if (nodeModulesPath) {
|
|
871
936
|
try {
|
|
872
|
-
bundleDts = await bundleDependencies([], options.packageName, compilerOutput.files, void 0);
|
|
937
|
+
bundleDts = await bundleDependencies([], options.packageName, compilerOutput["esm"].files, void 0);
|
|
873
938
|
} catch (e) {
|
|
874
939
|
consola.error("Failed bundling DTS", e);
|
|
940
|
+
success = false;
|
|
875
941
|
}
|
|
876
942
|
} else {
|
|
877
943
|
consola.error("Could not find node_modules directory, skipping DTS bundling");
|
|
944
|
+
success = false;
|
|
878
945
|
}
|
|
879
|
-
await
|
|
880
|
-
await writeFile(path3, contents, {
|
|
881
|
-
flag: "w"
|
|
882
|
-
});
|
|
883
|
-
}), await writeFile(join(packagePath, "dist", "bundle", "index.d.ts"), bundleDts, {
|
|
946
|
+
await writeFile(join(packagePath, "dist", "bundle", "index.d.mts"), bundleDts, {
|
|
884
947
|
flag: "w"
|
|
885
|
-
})
|
|
886
|
-
packageName: options.packageName,
|
|
887
|
-
packagePath,
|
|
888
|
-
packageVersion: options.packageVersion,
|
|
889
|
-
dependencies: [],
|
|
890
|
-
peerDependencies: resolvedPeerDependencies,
|
|
891
|
-
beta: options.beta
|
|
892
|
-
})]);
|
|
948
|
+
});
|
|
893
949
|
const absolutePackagePath = isAbsolute(options.outputDir) ? options.outputDir : join(process.cwd(), options.outputDir);
|
|
894
950
|
try {
|
|
895
951
|
await generateBundles(absolutePackagePath, options.packageName);
|
|
896
952
|
} catch (e) {
|
|
897
953
|
consola.error(e);
|
|
954
|
+
success = false;
|
|
955
|
+
}
|
|
956
|
+
if (!success) {
|
|
957
|
+
throw new Error("Failed to generate package");
|
|
898
958
|
}
|
|
899
959
|
}
|
|
900
960
|
|
|
901
961
|
// src/generate/commandUtils.ts
|
|
902
962
|
function transformArrayArg(arg) {
|
|
903
963
|
if (arg && arg.length > 0) {
|
|
904
|
-
if (arg[0] ===
|
|
905
|
-
return
|
|
964
|
+
if (arg[0] === undefined) {
|
|
965
|
+
return undefined;
|
|
906
966
|
}
|
|
907
967
|
}
|
|
908
968
|
return arg;
|
|
@@ -943,42 +1003,42 @@ var GeneratePackageCommand = class {
|
|
|
943
1003
|
string: true,
|
|
944
1004
|
demandOption: false,
|
|
945
1005
|
description: `The API names of the object types to generate. Example Usage: --objectTypes Aircraft Airport`,
|
|
946
|
-
default:
|
|
1006
|
+
default: undefined,
|
|
947
1007
|
defaultDescription: `By default, no arguments will not load any object type.`
|
|
948
1008
|
}).options("actionTypes", {
|
|
949
1009
|
array: true,
|
|
950
1010
|
string: true,
|
|
951
1011
|
demandOption: false,
|
|
952
1012
|
description: `The API names of the action types to generate. Example Usage: --actionTypes schedule-airplane-maintenance`,
|
|
953
|
-
default:
|
|
1013
|
+
default: undefined,
|
|
954
1014
|
defaultDescription: `By default, no arguments will not load any action type.`
|
|
955
1015
|
}).options("linkTypes", {
|
|
956
1016
|
array: true,
|
|
957
1017
|
string: true,
|
|
958
1018
|
demandOption: false,
|
|
959
1019
|
description: `The link types to generate in the format of ObjectTypeApiName.LinkTypeApiName. Example Usage: --linkTypes Aircraft.scheduledFlight`,
|
|
960
|
-
default:
|
|
1020
|
+
default: undefined,
|
|
961
1021
|
defaultDescription: `By default, no arguments will not load any link type.`
|
|
962
1022
|
}).options("queryTypes", {
|
|
963
1023
|
array: true,
|
|
964
1024
|
string: true,
|
|
965
1025
|
demandOption: false,
|
|
966
1026
|
description: `The API Names of the query types to generate. Example Usage: --queryTypes calculateMetric`,
|
|
967
|
-
default:
|
|
1027
|
+
default: undefined,
|
|
968
1028
|
defaultDescription: `By default, no arguments will not load any query type.`
|
|
969
1029
|
}).options("interfaceTypes", {
|
|
970
1030
|
array: true,
|
|
971
1031
|
string: true,
|
|
972
1032
|
demandOption: false,
|
|
973
1033
|
description: `The API Names of the interface types to generate. Example Usage: --interfaceTypes Geolocatable`,
|
|
974
|
-
default:
|
|
1034
|
+
default: undefined,
|
|
975
1035
|
defaultDescription: `By default, no arguments will not load any interface type.`
|
|
976
1036
|
}).options("experimentalFeatures", {
|
|
977
1037
|
array: true,
|
|
978
1038
|
string: true,
|
|
979
1039
|
demandOption: false,
|
|
980
1040
|
description: `Experimental features that can be modified or removed at any time. Example Usage: --experimentalFeatures realtimeUpdates`,
|
|
981
|
-
default:
|
|
1041
|
+
default: undefined,
|
|
982
1042
|
defaultDescription: `By default, no arguments will not enable any experimental features.`
|
|
983
1043
|
}).options("beta", {
|
|
984
1044
|
boolean: true,
|
|
@@ -1038,7 +1098,7 @@ var GeneratePackageCommand = class {
|
|
|
1038
1098
|
async function cli(args = process.argv) {
|
|
1039
1099
|
const base = yargs(hideBin(args)).command(new GeneratePackageCommand()).demandCommand().recommendCommands().strict().showHelpOnFail(true).help().version(process.env.npm_package_version);
|
|
1040
1100
|
try {
|
|
1041
|
-
return base.parseAsync();
|
|
1101
|
+
return await base.parseAsync();
|
|
1042
1102
|
} catch (e) {
|
|
1043
1103
|
console.log(e);
|
|
1044
1104
|
}
|