@osdk/foundry-sdk-generator 2.1.0-beta.9 → 2.2.0-beta.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 +290 -0
- package/build/esm/index.js +120 -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 +28 -28
- 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,8 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
476
490
|
case "integer":
|
|
477
491
|
case "long":
|
|
478
492
|
case "timestamp":
|
|
493
|
+
case "struct":
|
|
494
|
+
case "mediaReference":
|
|
479
495
|
return Result.ok({});
|
|
480
496
|
default:
|
|
481
497
|
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 +549,7 @@ async function getDependencyVersionFromFindUpPackageJson(name, opts) {
|
|
|
533
549
|
findUp
|
|
534
550
|
} = await import('find-up');
|
|
535
551
|
const packageJsonPath = await findUp("package.json", opts);
|
|
536
|
-
!(packageJsonPath !==
|
|
552
|
+
!(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
553
|
const packageJson = await readFile(packageJsonPath, {
|
|
538
554
|
encoding: "utf-8"
|
|
539
555
|
});
|
|
@@ -542,7 +558,7 @@ async function getDependencyVersionFromFindUpPackageJson(name, opts) {
|
|
|
542
558
|
}
|
|
543
559
|
const parsedPackageJson = JSON.parse(packageJson);
|
|
544
560
|
const version = parsedPackageJson.dependencies?.[name] ?? parsedPackageJson.devDependencies?.[name] ?? parsedPackageJson.peerDependencies?.[name];
|
|
545
|
-
!(version !==
|
|
561
|
+
!(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
562
|
return version;
|
|
547
563
|
}
|
|
548
564
|
|
|
@@ -559,9 +575,9 @@ async function resolveDependenciesFromFindUp(deps, cwd) {
|
|
|
559
575
|
}
|
|
560
576
|
|
|
561
577
|
// src/utils/UserAgent.ts
|
|
562
|
-
var USER_AGENT = `typescript-sdk-generator/${"2.
|
|
578
|
+
var USER_AGENT = `typescript-sdk-generator/${"2.2.0-beta.1"}`;
|
|
563
579
|
async function createRollupBuild(absolutePackagePath, packageName) {
|
|
564
|
-
const inputPath = `${absolutePackagePath}/${packageName}/index.js`;
|
|
580
|
+
const inputPath = `${absolutePackagePath}/${packageName}/esm/index.js`;
|
|
565
581
|
const {
|
|
566
582
|
findUp
|
|
567
583
|
} = await import('find-up');
|
|
@@ -569,7 +585,7 @@ async function createRollupBuild(absolutePackagePath, packageName) {
|
|
|
569
585
|
cwd: __dirname,
|
|
570
586
|
type: "directory"
|
|
571
587
|
});
|
|
572
|
-
return rollup({
|
|
588
|
+
return await rollup({
|
|
573
589
|
input: inputPath,
|
|
574
590
|
plugins: [nodeResolve({
|
|
575
591
|
browser: true,
|
|
@@ -584,7 +600,7 @@ async function createRollupBuild(absolutePackagePath, packageName) {
|
|
|
584
600
|
});
|
|
585
601
|
}
|
|
586
602
|
async function writeRollupBuild(rollupBuild, absolutePackagePath, packageName, format) {
|
|
587
|
-
const outputPath = `${absolutePackagePath}/${packageName}/dist/bundle/index.${
|
|
603
|
+
const outputPath = `${absolutePackagePath}/${packageName}/dist/bundle/index.${"mjs"}`;
|
|
588
604
|
await Promise.all([rollupBuild.write({
|
|
589
605
|
file: outputPath,
|
|
590
606
|
format,
|
|
@@ -771,11 +787,12 @@ function outputModule(project) {
|
|
|
771
787
|
});
|
|
772
788
|
return modules.join("\n");
|
|
773
789
|
}
|
|
774
|
-
function compileInMemory(files,
|
|
790
|
+
function compileInMemory(files, type) {
|
|
775
791
|
const inMemoryOutputFileSystem = {};
|
|
776
792
|
const compilerOptions = {
|
|
777
|
-
module:
|
|
778
|
-
target: ScriptTarget.
|
|
793
|
+
module: type === "cjs" ? ModuleKind.CommonJS : ModuleKind.ES2022,
|
|
794
|
+
target: ScriptTarget.ES2020,
|
|
795
|
+
resolvePackageJsonExports: true,
|
|
779
796
|
declaration: true,
|
|
780
797
|
skipLibCheck: true
|
|
781
798
|
};
|
|
@@ -786,7 +803,7 @@ function compileInMemory(files, opts) {
|
|
|
786
803
|
const originalSourceFile = compilerHost.getSourceFile;
|
|
787
804
|
compilerHost.getSourceFile = (fileName, languageVersion) => {
|
|
788
805
|
const sourceText = files[fileName];
|
|
789
|
-
return sourceText !==
|
|
806
|
+
return sourceText !== undefined ? createSourceFile(fileName, sourceText, languageVersion) : originalSourceFile(fileName, languageVersion);
|
|
790
807
|
};
|
|
791
808
|
const program = createProgram(Object.keys(files), compilerOptions, compilerHost);
|
|
792
809
|
const emitOutput = program.emit();
|
|
@@ -801,23 +818,32 @@ async function generatePackageJson(options) {
|
|
|
801
818
|
const packageJson = {
|
|
802
819
|
name: options.packageName,
|
|
803
820
|
version: options.packageVersion,
|
|
804
|
-
main: "./index.js",
|
|
805
|
-
types: "./index.d.ts",
|
|
821
|
+
main: "./cjs/index.js",
|
|
822
|
+
types: "./cjs/index.d.ts",
|
|
806
823
|
exports: {
|
|
807
824
|
".": {
|
|
808
|
-
types: "./index.d.ts",
|
|
809
825
|
script: {
|
|
810
|
-
types: "./dist/bundle/index.d.
|
|
811
|
-
default: "./dist/bundle/index.
|
|
826
|
+
types: "./dist/bundle/index.d.mts",
|
|
827
|
+
default: "./dist/bundle/index.mjs"
|
|
812
828
|
},
|
|
813
|
-
|
|
829
|
+
require: {
|
|
830
|
+
types: "./cjs/index.d.ts",
|
|
831
|
+
default: "./cjs/index.js"
|
|
832
|
+
},
|
|
833
|
+
import: {
|
|
834
|
+
types: "./esm/index.d.ts",
|
|
835
|
+
default: "./esm/index.js"
|
|
836
|
+
},
|
|
837
|
+
types: "./cjs/index.d.ts",
|
|
838
|
+
default: "./cjs/index.js"
|
|
814
839
|
}
|
|
815
840
|
},
|
|
816
841
|
dependencies: packageDeps,
|
|
817
842
|
peerDependencies: packagePeerDeps,
|
|
818
|
-
type: "
|
|
843
|
+
type: "commonjs"
|
|
819
844
|
};
|
|
820
|
-
await writeFile(join(options.packagePath, "package.json"), JSON.stringify(packageJson,
|
|
845
|
+
await writeFile(join(options.packagePath, "package.json"), JSON.stringify(packageJson, undefined, 4));
|
|
846
|
+
return packageJson;
|
|
821
847
|
}
|
|
822
848
|
function constructDependencies(dependencies) {
|
|
823
849
|
return dependencies?.reduce((acc, value) => {
|
|
@@ -828,12 +854,13 @@ function constructDependencies(dependencies) {
|
|
|
828
854
|
|
|
829
855
|
// src/generate/betaClient/generatePackage.ts
|
|
830
856
|
var betaPeerDependencies = {
|
|
831
|
-
"@osdk/client":
|
|
857
|
+
"@osdk/client": undefined
|
|
832
858
|
};
|
|
833
859
|
async function generatePackage(ontologyInfo, options) {
|
|
834
860
|
const {
|
|
835
861
|
consola
|
|
836
862
|
} = await import('consola');
|
|
863
|
+
let success = true;
|
|
837
864
|
const packagePath = join(options.outputDir, options.packageName);
|
|
838
865
|
const resolvedPeerDependencies = await resolveDependenciesFromFindUp(betaPeerDependencies, dirname(fileURLToPath(import.meta.url)));
|
|
839
866
|
await mkdir(packagePath, {
|
|
@@ -841,8 +868,8 @@ async function generatePackage(ontologyInfo, options) {
|
|
|
841
868
|
});
|
|
842
869
|
const inMemoryFileSystem = {};
|
|
843
870
|
const hostFs = {
|
|
844
|
-
writeFile: async (path3,
|
|
845
|
-
inMemoryFileSystem[normalize(path3)] =
|
|
871
|
+
writeFile: async (path3, contents2) => {
|
|
872
|
+
inMemoryFileSystem[normalize(path3)] = contents2;
|
|
846
873
|
},
|
|
847
874
|
mkdir: async (path3, _options) => {
|
|
848
875
|
await mkdir(normalize(path3), {
|
|
@@ -852,10 +879,47 @@ async function generatePackage(ontologyInfo, options) {
|
|
|
852
879
|
readdir: (path3) => readdir(path3)
|
|
853
880
|
};
|
|
854
881
|
await generateClientSdkVersionTwoPointZero(ontologyInfo.filteredFullMetadata, `typescript-sdk/${options.packageVersion} ${USER_AGENT}`, hostFs, packagePath, "module", ontologyInfo.externalObjects, ontologyInfo.externalInterfaces);
|
|
855
|
-
const
|
|
856
|
-
|
|
882
|
+
const contents = await generatePackageJson({
|
|
883
|
+
packageName: options.packageName,
|
|
884
|
+
packagePath,
|
|
885
|
+
packageVersion: options.packageVersion,
|
|
886
|
+
dependencies: [],
|
|
887
|
+
peerDependencies: resolvedPeerDependencies,
|
|
888
|
+
beta: options.beta
|
|
857
889
|
});
|
|
858
|
-
compilerOutput
|
|
890
|
+
const compilerOutput = {};
|
|
891
|
+
for (const type of ["esm", "cjs"]) {
|
|
892
|
+
await hostFs.writeFile(join(packagePath, "package.json"), JSON.stringify({
|
|
893
|
+
...contents,
|
|
894
|
+
type: type === "cjs" ? "commonjs" : "module"
|
|
895
|
+
}));
|
|
896
|
+
compilerOutput[type] = compileInMemory(inMemoryFileSystem, type);
|
|
897
|
+
compilerOutput[type].diagnostics.forEach((d) => {
|
|
898
|
+
consola.error(`Error compiling file`, d.file?.fileName, d.messageText);
|
|
899
|
+
success = false;
|
|
900
|
+
});
|
|
901
|
+
await mkdir(join(packagePath, "dist", "bundle"), {
|
|
902
|
+
recursive: true
|
|
903
|
+
});
|
|
904
|
+
await mkdir(join(packagePath, "esm"), {
|
|
905
|
+
recursive: true
|
|
906
|
+
});
|
|
907
|
+
await mkdir(join(packagePath, "cjs"), {
|
|
908
|
+
recursive: true
|
|
909
|
+
});
|
|
910
|
+
for (const [path3, contents2] of Object.entries(compilerOutput[type].files)) {
|
|
911
|
+
const newPath = path3.replace(packagePath, join(packagePath, type));
|
|
912
|
+
await mkdir(dirname(newPath), {
|
|
913
|
+
recursive: true
|
|
914
|
+
});
|
|
915
|
+
await writeFile(newPath, contents2, {
|
|
916
|
+
flag: "w"
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
void await writeFile(join(packagePath, type, "package.json"), JSON.stringify({
|
|
920
|
+
type: type === "esm" ? "module" : "commonjs"
|
|
921
|
+
}));
|
|
922
|
+
}
|
|
859
923
|
await mkdir(join(packagePath, "dist", "bundle"), {
|
|
860
924
|
recursive: true
|
|
861
925
|
});
|
|
@@ -869,40 +933,35 @@ async function generatePackage(ontologyInfo, options) {
|
|
|
869
933
|
let bundleDts = "";
|
|
870
934
|
if (nodeModulesPath) {
|
|
871
935
|
try {
|
|
872
|
-
bundleDts = await bundleDependencies([], options.packageName, compilerOutput.files, void 0);
|
|
936
|
+
bundleDts = await bundleDependencies([], options.packageName, compilerOutput["esm"].files, void 0);
|
|
873
937
|
} catch (e) {
|
|
874
938
|
consola.error("Failed bundling DTS", e);
|
|
939
|
+
success = false;
|
|
875
940
|
}
|
|
876
941
|
} else {
|
|
877
942
|
consola.error("Could not find node_modules directory, skipping DTS bundling");
|
|
943
|
+
success = false;
|
|
878
944
|
}
|
|
879
|
-
await
|
|
880
|
-
await writeFile(path3, contents, {
|
|
881
|
-
flag: "w"
|
|
882
|
-
});
|
|
883
|
-
}), await writeFile(join(packagePath, "dist", "bundle", "index.d.ts"), bundleDts, {
|
|
945
|
+
await writeFile(join(packagePath, "dist", "bundle", "index.d.mts"), bundleDts, {
|
|
884
946
|
flag: "w"
|
|
885
|
-
})
|
|
886
|
-
packageName: options.packageName,
|
|
887
|
-
packagePath,
|
|
888
|
-
packageVersion: options.packageVersion,
|
|
889
|
-
dependencies: [],
|
|
890
|
-
peerDependencies: resolvedPeerDependencies,
|
|
891
|
-
beta: options.beta
|
|
892
|
-
})]);
|
|
947
|
+
});
|
|
893
948
|
const absolutePackagePath = isAbsolute(options.outputDir) ? options.outputDir : join(process.cwd(), options.outputDir);
|
|
894
949
|
try {
|
|
895
950
|
await generateBundles(absolutePackagePath, options.packageName);
|
|
896
951
|
} catch (e) {
|
|
897
952
|
consola.error(e);
|
|
953
|
+
success = false;
|
|
954
|
+
}
|
|
955
|
+
if (!success) {
|
|
956
|
+
throw new Error("Failed to generate package");
|
|
898
957
|
}
|
|
899
958
|
}
|
|
900
959
|
|
|
901
960
|
// src/generate/commandUtils.ts
|
|
902
961
|
function transformArrayArg(arg) {
|
|
903
962
|
if (arg && arg.length > 0) {
|
|
904
|
-
if (arg[0] ===
|
|
905
|
-
return
|
|
963
|
+
if (arg[0] === undefined) {
|
|
964
|
+
return undefined;
|
|
906
965
|
}
|
|
907
966
|
}
|
|
908
967
|
return arg;
|
|
@@ -943,42 +1002,42 @@ var GeneratePackageCommand = class {
|
|
|
943
1002
|
string: true,
|
|
944
1003
|
demandOption: false,
|
|
945
1004
|
description: `The API names of the object types to generate. Example Usage: --objectTypes Aircraft Airport`,
|
|
946
|
-
default:
|
|
1005
|
+
default: undefined,
|
|
947
1006
|
defaultDescription: `By default, no arguments will not load any object type.`
|
|
948
1007
|
}).options("actionTypes", {
|
|
949
1008
|
array: true,
|
|
950
1009
|
string: true,
|
|
951
1010
|
demandOption: false,
|
|
952
1011
|
description: `The API names of the action types to generate. Example Usage: --actionTypes schedule-airplane-maintenance`,
|
|
953
|
-
default:
|
|
1012
|
+
default: undefined,
|
|
954
1013
|
defaultDescription: `By default, no arguments will not load any action type.`
|
|
955
1014
|
}).options("linkTypes", {
|
|
956
1015
|
array: true,
|
|
957
1016
|
string: true,
|
|
958
1017
|
demandOption: false,
|
|
959
1018
|
description: `The link types to generate in the format of ObjectTypeApiName.LinkTypeApiName. Example Usage: --linkTypes Aircraft.scheduledFlight`,
|
|
960
|
-
default:
|
|
1019
|
+
default: undefined,
|
|
961
1020
|
defaultDescription: `By default, no arguments will not load any link type.`
|
|
962
1021
|
}).options("queryTypes", {
|
|
963
1022
|
array: true,
|
|
964
1023
|
string: true,
|
|
965
1024
|
demandOption: false,
|
|
966
1025
|
description: `The API Names of the query types to generate. Example Usage: --queryTypes calculateMetric`,
|
|
967
|
-
default:
|
|
1026
|
+
default: undefined,
|
|
968
1027
|
defaultDescription: `By default, no arguments will not load any query type.`
|
|
969
1028
|
}).options("interfaceTypes", {
|
|
970
1029
|
array: true,
|
|
971
1030
|
string: true,
|
|
972
1031
|
demandOption: false,
|
|
973
1032
|
description: `The API Names of the interface types to generate. Example Usage: --interfaceTypes Geolocatable`,
|
|
974
|
-
default:
|
|
1033
|
+
default: undefined,
|
|
975
1034
|
defaultDescription: `By default, no arguments will not load any interface type.`
|
|
976
1035
|
}).options("experimentalFeatures", {
|
|
977
1036
|
array: true,
|
|
978
1037
|
string: true,
|
|
979
1038
|
demandOption: false,
|
|
980
1039
|
description: `Experimental features that can be modified or removed at any time. Example Usage: --experimentalFeatures realtimeUpdates`,
|
|
981
|
-
default:
|
|
1040
|
+
default: undefined,
|
|
982
1041
|
defaultDescription: `By default, no arguments will not enable any experimental features.`
|
|
983
1042
|
}).options("beta", {
|
|
984
1043
|
boolean: true,
|
|
@@ -1038,7 +1097,7 @@ var GeneratePackageCommand = class {
|
|
|
1038
1097
|
async function cli(args = process.argv) {
|
|
1039
1098
|
const base = yargs(hideBin(args)).command(new GeneratePackageCommand()).demandCommand().recommendCommands().strict().showHelpOnFail(true).help().version(process.env.npm_package_version);
|
|
1040
1099
|
try {
|
|
1041
|
-
return base.parseAsync();
|
|
1100
|
+
return await base.parseAsync();
|
|
1042
1101
|
} catch (e) {
|
|
1043
1102
|
console.log(e);
|
|
1044
1103
|
}
|