@osdk/foundry-sdk-generator 2.2.0-beta.8 → 2.3.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 +329 -0
- package/build/esm/index.js +179 -107
- package/build/esm/index.js.map +1 -1
- package/build/types/generate/GeneratePackageCommand.d.ts.map +1 -1
- package/build/types/generate/betaClient/__tests__/customNormalize.test.d.ts +1 -0
- package/build/types/generate/betaClient/__tests__/customNormalize.test.d.ts.map +1 -0
- package/build/types/generate/betaClient/generatePackage.d.ts +2 -0
- package/build/types/generate/betaClient/generatePackage.d.ts.map +1 -1
- package/build/types/generate/index.d.ts +1 -1
- package/build/types/generate/index.d.ts.map +1 -1
- package/build/types/ontologyMetadata/Result.d.ts.map +1 -1
- package/build/types/ontologyMetadata/ontologyMetadataResolver.d.ts +2 -2
- package/build/types/ontologyMetadata/ontologyMetadataResolver.d.ts.map +1 -1
- package/package.json +15 -14
package/build/esm/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { fileURLToPath as fileURLToPath$1 } from 'url';
|
|
2
|
-
import path, { join, dirname, isAbsolute
|
|
2
|
+
import path, { join, dirname, isAbsolute } from 'path';
|
|
3
3
|
import yargs from 'yargs';
|
|
4
4
|
import { hideBin } from 'yargs/helpers';
|
|
5
5
|
import { exit } from 'process';
|
|
6
6
|
import { createSharedClientContext } from '@osdk/shared.client.impl';
|
|
7
7
|
import { generateClientSdkVersionTwoPointZero } from '@osdk/generator';
|
|
8
8
|
import { mkdir, writeFile, readdir, readFile } from 'fs/promises';
|
|
9
|
+
import * as path2 from 'node:path';
|
|
10
|
+
import path2__default from 'node:path';
|
|
11
|
+
import { normalize } from 'node:path/posix';
|
|
9
12
|
import { fileURLToPath } from 'node:url';
|
|
10
13
|
import commonjs from '@rollup/plugin-commonjs';
|
|
11
14
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
@@ -13,10 +16,9 @@ import { rollup } from 'rollup';
|
|
|
13
16
|
import nodePolyfill from 'rollup-plugin-polyfill-node';
|
|
14
17
|
import { Project, Node } from 'ts-morph';
|
|
15
18
|
import * as fs from 'node:fs';
|
|
16
|
-
import
|
|
17
|
-
import { ModuleKind, ScriptTarget, createCompilerHost, createSourceFile, createProgram } from 'typescript';
|
|
19
|
+
import { ScriptTarget, ModuleKind, createCompilerHost, createSourceFile, createProgram } from 'typescript';
|
|
18
20
|
|
|
19
|
-
// ../../node_modules/.pnpm/tsup@8.
|
|
21
|
+
// ../../node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.52.7_@types+node@18.19.97__@swc+core@1.7.39_jiti@2.4.2__2dta44cza7xfoposuc4x3z55ly/node_modules/tsup/assets/esm_shims.js
|
|
20
22
|
var getFilename = () => fileURLToPath$1(import.meta.url);
|
|
21
23
|
var getDirname = () => path.dirname(getFilename());
|
|
22
24
|
var __dirname = /* @__PURE__ */ getDirname();
|
|
@@ -224,7 +226,7 @@ var OntologyMetadataResolver = class {
|
|
|
224
226
|
objectType.linkTypes = objectType.linkTypes.filter((linkType) => linkTypesToKeep.has(linkType.apiName));
|
|
225
227
|
});
|
|
226
228
|
const filteredActionTypes = Object.fromEntries(Object.entries(ontologyFullMetadata.actionTypes).filter(([actionApiName]) => {
|
|
227
|
-
if (expectedEntities.actionTypes.has(
|
|
229
|
+
if (expectedEntities.actionTypes.has(actionApiName)) {
|
|
228
230
|
return true;
|
|
229
231
|
}
|
|
230
232
|
return false;
|
|
@@ -267,71 +269,129 @@ var OntologyMetadataResolver = class {
|
|
|
267
269
|
} catch (e) {
|
|
268
270
|
return Result.err([`Unable to load the specified Ontology with network error: ${JSON.stringify(e)}`]);
|
|
269
271
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
if (extPackageInfo.size > 0) {
|
|
273
|
+
const ontologyFullMetadata = await OntologiesV2.getFullMetadata(this.getClientContext(), ontology.rid);
|
|
274
|
+
if (ontologyFullMetadata.errorName != null) {
|
|
275
|
+
return Result.err([`Unable to load the specified Ontology metadata.
|
|
273
276
|
${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
274
|
-
}
|
|
275
|
-
const externalObjects = /* @__PURE__ */ new Map();
|
|
276
|
-
const externalInterfaces = /* @__PURE__ */ new Map();
|
|
277
|
-
for (const {
|
|
278
|
-
sdk
|
|
279
|
-
} of extPackageInfo.values()) {
|
|
280
|
-
if (sdk.npm?.npmPackageName == null) {
|
|
281
|
-
throw new Error("External package is not generated as an npm package");
|
|
282
277
|
}
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
278
|
+
const externalObjects = /* @__PURE__ */ new Map();
|
|
279
|
+
const externalInterfaces = /* @__PURE__ */ new Map();
|
|
280
|
+
for (const {
|
|
281
|
+
sdk
|
|
282
|
+
} of extPackageInfo.values()) {
|
|
283
|
+
if (sdk.npm?.npmPackageName == null) {
|
|
284
|
+
throw new Error("External package is not generated as an npm package");
|
|
285
|
+
}
|
|
286
|
+
const dataScope = sdk.inputs.dataScope.ontologyV2;
|
|
287
|
+
for (const rid of dataScope.objectTypes) {
|
|
288
|
+
const ot = Object.values(ontologyFullMetadata.objectTypes).find((ot2) => ot2.objectType.rid === rid);
|
|
289
|
+
if (!ot) {
|
|
290
|
+
throw new Error(`Could not find external object type with rid ${rid}`);
|
|
291
|
+
}
|
|
292
|
+
externalObjects.set(ot.objectType.apiName, sdk.npm.npmPackageName);
|
|
293
|
+
}
|
|
294
|
+
for (const rid of dataScope.interfaceTypes) {
|
|
295
|
+
const it = Object.values(ontologyFullMetadata.interfaceTypes).find((it2) => it2.rid === rid);
|
|
296
|
+
if (!it) {
|
|
297
|
+
throw new Error(`Could not find external interface type with rid ${rid}`);
|
|
298
|
+
}
|
|
299
|
+
externalInterfaces.set(it.apiName, sdk.npm.npmPackageName);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const linkTypes = /* @__PURE__ */ new Map();
|
|
303
|
+
const objectTypes = new Set(entities.objectTypesApiNamesToLoad);
|
|
304
|
+
const queryTypes = new Set(entities.queryTypesApiNamesToLoad);
|
|
305
|
+
for (const queryType of entities.queryTypesApiNamesToLoad ?? []) {
|
|
306
|
+
if (queryType.includes(":")) {
|
|
307
|
+
throw new Error(`Query types with fixed versions are not supported with external packages: ${queryType}`);
|
|
288
308
|
}
|
|
289
|
-
externalObjects.set(ot.objectType.apiName, sdk.npm.npmPackageName);
|
|
290
309
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
310
|
+
const actionTypes = new Set(entities.actionTypesApiNamesToLoad);
|
|
311
|
+
const interfaceTypes = new Set(entities.interfaceTypesApiNamesToLoad);
|
|
312
|
+
for (const linkType of entities.linkTypesApiNamesToLoad ?? []) {
|
|
313
|
+
const [objectTypeApiName, linkTypeApiName] = linkType.split(".");
|
|
314
|
+
if (!linkTypes.has(objectTypeApiName)) {
|
|
315
|
+
linkTypes.set(objectTypeApiName, /* @__PURE__ */ new Set());
|
|
295
316
|
}
|
|
296
|
-
|
|
317
|
+
linkTypes.get(objectTypeApiName)?.add(linkTypeApiName);
|
|
297
318
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
linkTypes
|
|
319
|
+
const filteredFullMetadata = this.filterMetadataByApiName(ontologyFullMetadata, {
|
|
320
|
+
objectTypes,
|
|
321
|
+
linkTypes,
|
|
322
|
+
actionTypes,
|
|
323
|
+
queryTypes,
|
|
324
|
+
interfaceTypes
|
|
325
|
+
}, extPackageInfo);
|
|
326
|
+
const validData = this.validateLoadedOntologyMetadata(filteredFullMetadata, {
|
|
327
|
+
objectTypes,
|
|
328
|
+
linkTypes,
|
|
329
|
+
actionTypes,
|
|
330
|
+
queryTypes,
|
|
331
|
+
interfaceTypes
|
|
332
|
+
}, extPackageInfo, ontologyFullMetadata);
|
|
333
|
+
if (validData.isErr()) {
|
|
334
|
+
return Result.err(validData.error);
|
|
308
335
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
336
|
+
return Result.ok({
|
|
337
|
+
requestedMetadata: filteredFullMetadata,
|
|
338
|
+
externalInterfaces,
|
|
339
|
+
externalObjects,
|
|
340
|
+
fixedVersionQueryTypes: []
|
|
341
|
+
});
|
|
342
|
+
} else {
|
|
343
|
+
const objectTypes = new Set(entities.objectTypesApiNamesToLoad);
|
|
344
|
+
const interfaceTypes = new Set(entities.interfaceTypesApiNamesToLoad);
|
|
345
|
+
const actionTypes = new Set(entities.actionTypesApiNamesToLoad);
|
|
346
|
+
const linkTypes = /* @__PURE__ */ new Map();
|
|
347
|
+
for (const linkType of entities.linkTypesApiNamesToLoad ?? []) {
|
|
348
|
+
const [objectTypeApiName, linkTypeApiName] = linkType.split(".");
|
|
349
|
+
if (!linkTypes.has(objectTypeApiName)) {
|
|
350
|
+
linkTypes.set(objectTypeApiName, /* @__PURE__ */ new Set());
|
|
351
|
+
}
|
|
352
|
+
linkTypes.get(objectTypeApiName)?.add(linkTypeApiName);
|
|
353
|
+
}
|
|
354
|
+
const queryTypes = /* @__PURE__ */ new Set();
|
|
355
|
+
const fixedVersionQueryTypes = [];
|
|
356
|
+
for (const queryType of entities.queryTypesApiNamesToLoad ?? []) {
|
|
357
|
+
if (queryTypes.has(queryType)) {
|
|
358
|
+
return Result.err([`Query type ${queryType} was specified multiple times.`]);
|
|
359
|
+
}
|
|
360
|
+
const lastColonIndex = queryType.lastIndexOf(":");
|
|
361
|
+
if (lastColonIndex !== -1) {
|
|
362
|
+
const queryTypeApiName = queryType.substring(0, lastColonIndex);
|
|
363
|
+
fixedVersionQueryTypes.push(queryTypeApiName);
|
|
364
|
+
}
|
|
365
|
+
queryTypes.add(queryType);
|
|
366
|
+
}
|
|
367
|
+
const requestedMetadata = await OntologiesV2.loadMetadata(this.getClientContext(), ontology.rid, {
|
|
368
|
+
actionTypes: [...actionTypes],
|
|
369
|
+
objectTypes: [...objectTypes],
|
|
370
|
+
queryTypes: [...queryTypes],
|
|
371
|
+
interfaceTypes: [...interfaceTypes],
|
|
372
|
+
linkTypes: Array.from(linkTypes.entries()).flatMap(([_, linkTypeApiNames]) => [...linkTypeApiNames])
|
|
373
|
+
}, {
|
|
374
|
+
preview: true
|
|
375
|
+
});
|
|
376
|
+
const validData = this.validateLoadedOntologyMetadata(requestedMetadata, {
|
|
377
|
+
objectTypes,
|
|
378
|
+
linkTypes,
|
|
379
|
+
actionTypes,
|
|
380
|
+
queryTypes,
|
|
381
|
+
interfaceTypes
|
|
382
|
+
}, extPackageInfo);
|
|
383
|
+
if (validData.isErr()) {
|
|
384
|
+
return Result.err(validData.error);
|
|
385
|
+
}
|
|
386
|
+
return Result.ok({
|
|
387
|
+
requestedMetadata,
|
|
388
|
+
externalInterfaces: /* @__PURE__ */ new Map(),
|
|
389
|
+
externalObjects: /* @__PURE__ */ new Map(),
|
|
390
|
+
fixedVersionQueryTypes
|
|
391
|
+
});
|
|
327
392
|
}
|
|
328
|
-
return Result.ok({
|
|
329
|
-
filteredFullMetadata,
|
|
330
|
-
externalInterfaces,
|
|
331
|
-
externalObjects
|
|
332
|
-
});
|
|
333
393
|
}
|
|
334
|
-
validateLoadedOntologyMetadata(filteredFullMetadata, expectedEntities,
|
|
394
|
+
validateLoadedOntologyMetadata(filteredFullMetadata, expectedEntities, packageInfo, fullMetadata) {
|
|
335
395
|
const errors = [];
|
|
336
396
|
const loadedObjectTypes = Object.fromEntries(Object.values(filteredFullMetadata.objectTypes).map((object) => [object.objectType.apiName, object]));
|
|
337
397
|
const loadedLinkTypes = Object.fromEntries(Object.values(filteredFullMetadata.objectTypes).map((object) => [object.objectType.apiName, Object.fromEntries(object.linkTypes.map((link) => [link.apiName, link]))]));
|
|
@@ -349,7 +409,7 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
349
409
|
}
|
|
350
410
|
for (const [, link] of Object.entries(loadedLinkTypes[object])) {
|
|
351
411
|
if (!expectedEntities.objectTypes.has(link.objectTypeApiName)) {
|
|
352
|
-
const fromFull =
|
|
412
|
+
const fromFull = fullMetadata?.objectTypes[link.objectTypeApiName];
|
|
353
413
|
if (fromFull && hasObjectType(packageInfo, fromFull)) {
|
|
354
414
|
continue;
|
|
355
415
|
}
|
|
@@ -388,14 +448,13 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
388
448
|
if (missingQueryTypes.length > 0) {
|
|
389
449
|
errors.push(`Unable to find the following Query Types: ${missingQueryTypes.join()}`);
|
|
390
450
|
}
|
|
391
|
-
const loadedActionTypes = Object.fromEntries(Object.entries(filteredFullMetadata.actionTypes).map(([actionApiName, action]) => [this.camelize(actionApiName), action]));
|
|
392
451
|
const missingActionTypes = [];
|
|
393
452
|
for (const actionApiName of expectedEntities.actionTypes) {
|
|
394
|
-
if (!
|
|
453
|
+
if (!filteredFullMetadata.actionTypes[actionApiName]) {
|
|
395
454
|
missingActionTypes.push(actionApiName);
|
|
396
455
|
}
|
|
397
456
|
}
|
|
398
|
-
for (const action of Object.values(
|
|
457
|
+
for (const action of Object.values(filteredFullMetadata.actionTypes)) {
|
|
399
458
|
const result = this.validateActionParameters(action, expectedEntities.objectTypes, expectedEntities.interfaceTypes);
|
|
400
459
|
if (result.isErr()) {
|
|
401
460
|
for (const errorString of result.error) {
|
|
@@ -418,8 +477,7 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
418
477
|
return results;
|
|
419
478
|
}
|
|
420
479
|
validateActionParameters(actionType, loadedObjectApiNames, loadedInterfaceApiNames) {
|
|
421
|
-
const
|
|
422
|
-
const parameterValidation = Object.entries(actionType.parameters).map(([_paramName, paramData]) => this.isSupportedActionTypeParameter(camelizedApiName, paramData.dataType, loadedObjectApiNames, loadedInterfaceApiNames));
|
|
480
|
+
const parameterValidation = Object.entries(actionType.parameters).map(([_paramName, paramData]) => this.isSupportedActionTypeParameter(actionType.apiName, paramData.dataType, loadedObjectApiNames, loadedInterfaceApiNames));
|
|
423
481
|
return Result.coalesce(parameterValidation);
|
|
424
482
|
}
|
|
425
483
|
visitSupportedQueryTypes(queryApiName, propertyName, baseType, loadedObjectApiNames) {
|
|
@@ -446,6 +504,8 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
446
504
|
return Result.ok({});
|
|
447
505
|
}
|
|
448
506
|
return Result.err([`Unable to load query ${queryApiName} because it takes an unsupported parameter type: ${JSON.stringify(baseType)} in parameter ${propertyName}`]);
|
|
507
|
+
case "entrySet":
|
|
508
|
+
return Result.coalesce([this.visitSupportedQueryTypes(queryApiName, propertyName, baseType.keyType, loadedObjectApiNames), this.visitSupportedQueryTypes(queryApiName, propertyName, baseType.valueType, loadedObjectApiNames)]);
|
|
449
509
|
case "string":
|
|
450
510
|
case "boolean":
|
|
451
511
|
case "attachment":
|
|
@@ -460,29 +520,30 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
460
520
|
case "null":
|
|
461
521
|
return Result.ok({});
|
|
462
522
|
case "unsupported":
|
|
523
|
+
return Result.err([`Unable to load query ${queryApiName} because it takes an unsupported parameter type: ${JSON.stringify(baseType)} in parameter ${propertyName}`]);
|
|
463
524
|
default:
|
|
464
525
|
return Result.err([`Unable to load query ${queryApiName} because it takes an unsupported parameter type: ${JSON.stringify(baseType)} in parameter ${propertyName}`]);
|
|
465
526
|
}
|
|
466
527
|
}
|
|
467
|
-
isSupportedActionTypeParameter(actionApiName,
|
|
468
|
-
switch (
|
|
528
|
+
isSupportedActionTypeParameter(actionApiName, actionTypeParameter, loadedObjectApiNames, loadedInterfaceApiNames) {
|
|
529
|
+
switch (actionTypeParameter.type) {
|
|
469
530
|
case "array":
|
|
470
|
-
return this.isSupportedActionTypeParameter(actionApiName,
|
|
531
|
+
return this.isSupportedActionTypeParameter(actionApiName, actionTypeParameter.subType, loadedObjectApiNames, loadedInterfaceApiNames);
|
|
471
532
|
case "object":
|
|
472
|
-
if (loadedObjectApiNames.has(
|
|
533
|
+
if (loadedObjectApiNames.has(actionTypeParameter.objectTypeApiName)) {
|
|
473
534
|
return Result.ok({});
|
|
474
535
|
}
|
|
475
|
-
return Result.err([`Unable to load action ${actionApiName} because it takes an unloaded object type as a parameter: ${
|
|
536
|
+
return Result.err([`Unable to load action ${actionApiName} because it takes an unloaded object type as a parameter: ${actionTypeParameter.objectTypeApiName} make sure to specify it as an argument with --ontologyObjects ${actionTypeParameter.objectTypeApiName})`]);
|
|
476
537
|
case "objectSet":
|
|
477
|
-
if (loadedObjectApiNames.has(
|
|
538
|
+
if (loadedObjectApiNames.has(actionTypeParameter.objectTypeApiName)) {
|
|
478
539
|
return Result.ok({});
|
|
479
540
|
}
|
|
480
|
-
return Result.err([`Unable to load action ${actionApiName} because it takes an ObjectSet of unloaded object type as a parameter: ${
|
|
541
|
+
return Result.err([`Unable to load action ${actionApiName} because it takes an ObjectSet of unloaded object type as a parameter: ${actionTypeParameter.objectTypeApiName} make sure to specify it as an argument with --ontologyObjects ${actionTypeParameter.objectTypeApiName})`]);
|
|
481
542
|
case "interfaceObject":
|
|
482
|
-
if (loadedInterfaceApiNames.has(
|
|
543
|
+
if (loadedInterfaceApiNames.has(actionTypeParameter.interfaceTypeApiName)) {
|
|
483
544
|
return Result.ok({});
|
|
484
545
|
}
|
|
485
|
-
return Result.err([`Unable to load action ${actionApiName} because it takes an unloaded interface type as a parameter: ${
|
|
546
|
+
return Result.err([`Unable to load action ${actionApiName} because it takes an unloaded interface type as a parameter: ${actionTypeParameter.interfaceTypeApiName} make sure to specify it as an argument with --ontologyInterfaces ${actionTypeParameter.interfaceTypeApiName}`]);
|
|
486
547
|
case "string":
|
|
487
548
|
case "boolean":
|
|
488
549
|
case "attachment":
|
|
@@ -494,14 +555,16 @@ ${JSON.stringify(ontologyFullMetadata, null, 2)}`]);
|
|
|
494
555
|
case "struct":
|
|
495
556
|
case "mediaReference":
|
|
496
557
|
case "objectType":
|
|
558
|
+
case "marking":
|
|
559
|
+
case "geohash":
|
|
560
|
+
case "geoshape":
|
|
497
561
|
return Result.ok({});
|
|
562
|
+
case "vector":
|
|
563
|
+
return Result.err([`Unable to load action ${actionApiName} because it takes an unsupported parameter: ${JSON.stringify(actionTypeParameter)} specify only the actions you want to load with the --actions argument.`]);
|
|
498
564
|
default:
|
|
499
|
-
return Result.err([`Unable to load action ${actionApiName} because it takes an unsupported parameter: ${JSON.stringify(
|
|
565
|
+
return Result.err([`Unable to load action ${actionApiName} because it takes an unsupported parameter: ${JSON.stringify(actionTypeParameter)} specify only the actions you want to load with the --actions argument.`]);
|
|
500
566
|
}
|
|
501
567
|
}
|
|
502
|
-
camelize(name) {
|
|
503
|
-
return name.replace(/-./g, (segment) => segment[1].toUpperCase());
|
|
504
|
-
}
|
|
505
568
|
};
|
|
506
569
|
function hasObjectType(z, fromFull) {
|
|
507
570
|
for (const q of z.values()) {
|
|
@@ -551,7 +614,7 @@ async function getDependencyVersionFromFindUpPackageJson(name, opts) {
|
|
|
551
614
|
findUp
|
|
552
615
|
} = await import('find-up');
|
|
553
616
|
const packageJsonPath = await findUp("package.json", opts);
|
|
554
|
-
!(packageJsonPath !==
|
|
617
|
+
!(packageJsonPath !== void 0) ? 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() : void 0;
|
|
555
618
|
const packageJson = await readFile(packageJsonPath, {
|
|
556
619
|
encoding: "utf-8"
|
|
557
620
|
});
|
|
@@ -560,7 +623,7 @@ async function getDependencyVersionFromFindUpPackageJson(name, opts) {
|
|
|
560
623
|
}
|
|
561
624
|
const parsedPackageJson = JSON.parse(packageJson);
|
|
562
625
|
const version = parsedPackageJson.dependencies?.[name] ?? parsedPackageJson.devDependencies?.[name] ?? parsedPackageJson.peerDependencies?.[name];
|
|
563
|
-
!(version !==
|
|
626
|
+
!(version !== void 0) ? 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() : void 0;
|
|
564
627
|
return version;
|
|
565
628
|
}
|
|
566
629
|
|
|
@@ -577,7 +640,7 @@ async function resolveDependenciesFromFindUp(deps, cwd) {
|
|
|
577
640
|
}
|
|
578
641
|
|
|
579
642
|
// src/utils/UserAgent.ts
|
|
580
|
-
var USER_AGENT = `typescript-sdk-generator/${"2.
|
|
643
|
+
var USER_AGENT = `typescript-sdk-generator/${"2.3.0-beta.1"}`;
|
|
581
644
|
async function createRollupBuild(absolutePackagePath, packageName) {
|
|
582
645
|
const inputPath = `${absolutePackagePath}/${packageName}/esm/index.js`;
|
|
583
646
|
const {
|
|
@@ -805,7 +868,7 @@ function compileInMemory(files, type) {
|
|
|
805
868
|
const originalSourceFile = compilerHost.getSourceFile;
|
|
806
869
|
compilerHost.getSourceFile = (fileName, languageVersion) => {
|
|
807
870
|
const sourceText = files[fileName];
|
|
808
|
-
return sourceText !==
|
|
871
|
+
return sourceText !== void 0 ? createSourceFile(fileName, sourceText, languageVersion) : originalSourceFile(fileName, languageVersion);
|
|
809
872
|
};
|
|
810
873
|
const program = createProgram(Object.keys(files), compilerOptions, compilerHost);
|
|
811
874
|
const emitOutput = program.emit();
|
|
@@ -844,7 +907,7 @@ async function generatePackageJson(options) {
|
|
|
844
907
|
peerDependencies: packagePeerDeps,
|
|
845
908
|
type: "commonjs"
|
|
846
909
|
};
|
|
847
|
-
await writeFile(join(options.packagePath, "package.json"), JSON.stringify(packageJson,
|
|
910
|
+
await writeFile(join(options.packagePath, "package.json"), JSON.stringify(packageJson, void 0, 4));
|
|
848
911
|
return packageJson;
|
|
849
912
|
}
|
|
850
913
|
function constructDependencies(dependencies) {
|
|
@@ -856,39 +919,44 @@ function constructDependencies(dependencies) {
|
|
|
856
919
|
|
|
857
920
|
// src/generate/betaClient/generatePackage.ts
|
|
858
921
|
var betaPeerDependencies = {
|
|
859
|
-
"@osdk/client":
|
|
922
|
+
"@osdk/client": void 0
|
|
860
923
|
};
|
|
861
924
|
async function generatePackage(ontologyInfo, options) {
|
|
862
925
|
const {
|
|
863
926
|
consola
|
|
864
927
|
} = await import('consola');
|
|
865
928
|
let success = true;
|
|
866
|
-
|
|
929
|
+
if (options.ontologyJsonOnly) {
|
|
930
|
+
await mkdir(options.outputDir, {
|
|
931
|
+
recursive: true
|
|
932
|
+
});
|
|
933
|
+
await writeFile(path2__default.join(options.outputDir, "ontology.json"), JSON.stringify(ontologyInfo.requestedMetadata, null, 2), "utf-8");
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
const packagePath = customNormalize(join(options.outputDir, options.packageName));
|
|
867
937
|
const resolvedPeerDependencies = await resolveDependenciesFromFindUp(betaPeerDependencies, dirname(fileURLToPath(import.meta.url)));
|
|
868
938
|
await mkdir(packagePath, {
|
|
869
939
|
recursive: true
|
|
870
940
|
});
|
|
871
941
|
const inMemoryFileSystem = {};
|
|
872
942
|
const hostFs = {
|
|
873
|
-
writeFile: async (
|
|
874
|
-
inMemoryFileSystem[
|
|
943
|
+
writeFile: async (path4, contents2) => {
|
|
944
|
+
inMemoryFileSystem[customNormalize(path4)] = contents2;
|
|
875
945
|
},
|
|
876
|
-
mkdir: async (
|
|
877
|
-
await mkdir(
|
|
946
|
+
mkdir: async (path4, _options) => {
|
|
947
|
+
await mkdir(customNormalize(path4), {
|
|
878
948
|
recursive: true
|
|
879
949
|
});
|
|
880
950
|
},
|
|
881
|
-
readdir: (
|
|
951
|
+
readdir: (path4) => readdir(path4)
|
|
882
952
|
};
|
|
883
|
-
await generateClientSdkVersionTwoPointZero(ontologyInfo.
|
|
953
|
+
await generateClientSdkVersionTwoPointZero(ontologyInfo.requestedMetadata, `typescript-sdk/${options.packageVersion} ${USER_AGENT}`, hostFs, packagePath, "module", ontologyInfo.externalObjects, ontologyInfo.externalInterfaces, /* @__PURE__ */ new Map(), false, ontologyInfo.fixedVersionQueryTypes);
|
|
884
954
|
const contents = await generatePackageJson({
|
|
885
955
|
packageName: options.packageName,
|
|
886
956
|
packagePath,
|
|
887
957
|
packageVersion: options.packageVersion,
|
|
888
958
|
dependencies: [],
|
|
889
|
-
peerDependencies: resolvedPeerDependencies
|
|
890
|
-
beta: options.beta
|
|
891
|
-
});
|
|
959
|
+
peerDependencies: resolvedPeerDependencies});
|
|
892
960
|
const compilerOutput = {};
|
|
893
961
|
for (const type of ["esm", "cjs"]) {
|
|
894
962
|
await hostFs.writeFile(join(packagePath, "package.json"), JSON.stringify({
|
|
@@ -909,8 +977,8 @@ async function generatePackage(ontologyInfo, options) {
|
|
|
909
977
|
await mkdir(join(packagePath, "cjs"), {
|
|
910
978
|
recursive: true
|
|
911
979
|
});
|
|
912
|
-
for (const [
|
|
913
|
-
const newPath =
|
|
980
|
+
for (const [path4, contents2] of Object.entries(compilerOutput[type].files)) {
|
|
981
|
+
const newPath = path4.replace(packagePath, join(packagePath, type));
|
|
914
982
|
await mkdir(dirname(newPath), {
|
|
915
983
|
recursive: true
|
|
916
984
|
});
|
|
@@ -958,12 +1026,15 @@ async function generatePackage(ontologyInfo, options) {
|
|
|
958
1026
|
throw new Error("Failed to generate package");
|
|
959
1027
|
}
|
|
960
1028
|
}
|
|
1029
|
+
function customNormalize(pathName) {
|
|
1030
|
+
return normalize(pathName.replace(/\\/g, "/"));
|
|
1031
|
+
}
|
|
961
1032
|
|
|
962
1033
|
// src/generate/commandUtils.ts
|
|
963
1034
|
function transformArrayArg(arg) {
|
|
964
1035
|
if (arg && arg.length > 0) {
|
|
965
|
-
if (arg[0] ===
|
|
966
|
-
return
|
|
1036
|
+
if (arg[0] === void 0) {
|
|
1037
|
+
return void 0;
|
|
967
1038
|
}
|
|
968
1039
|
}
|
|
969
1040
|
return arg;
|
|
@@ -1004,42 +1075,42 @@ var GeneratePackageCommand = class {
|
|
|
1004
1075
|
string: true,
|
|
1005
1076
|
demandOption: false,
|
|
1006
1077
|
description: `The API names of the object types to generate. Example Usage: --objectTypes Aircraft Airport`,
|
|
1007
|
-
default:
|
|
1078
|
+
default: void 0,
|
|
1008
1079
|
defaultDescription: `By default, no arguments will not load any object type.`
|
|
1009
1080
|
}).options("actionTypes", {
|
|
1010
1081
|
array: true,
|
|
1011
1082
|
string: true,
|
|
1012
1083
|
demandOption: false,
|
|
1013
1084
|
description: `The API names of the action types to generate. Example Usage: --actionTypes schedule-airplane-maintenance`,
|
|
1014
|
-
default:
|
|
1085
|
+
default: void 0,
|
|
1015
1086
|
defaultDescription: `By default, no arguments will not load any action type.`
|
|
1016
1087
|
}).options("linkTypes", {
|
|
1017
1088
|
array: true,
|
|
1018
1089
|
string: true,
|
|
1019
1090
|
demandOption: false,
|
|
1020
1091
|
description: `The link types to generate in the format of ObjectTypeApiName.LinkTypeApiName. Example Usage: --linkTypes Aircraft.scheduledFlight`,
|
|
1021
|
-
default:
|
|
1092
|
+
default: void 0,
|
|
1022
1093
|
defaultDescription: `By default, no arguments will not load any link type.`
|
|
1023
1094
|
}).options("queryTypes", {
|
|
1024
1095
|
array: true,
|
|
1025
1096
|
string: true,
|
|
1026
1097
|
demandOption: false,
|
|
1027
1098
|
description: `The API Names of the query types to generate. Example Usage: --queryTypes calculateMetric`,
|
|
1028
|
-
default:
|
|
1099
|
+
default: void 0,
|
|
1029
1100
|
defaultDescription: `By default, no arguments will not load any query type.`
|
|
1030
1101
|
}).options("interfaceTypes", {
|
|
1031
1102
|
array: true,
|
|
1032
1103
|
string: true,
|
|
1033
1104
|
demandOption: false,
|
|
1034
1105
|
description: `The API Names of the interface types to generate. Example Usage: --interfaceTypes Geolocatable`,
|
|
1035
|
-
default:
|
|
1106
|
+
default: void 0,
|
|
1036
1107
|
defaultDescription: `By default, no arguments will not load any interface type.`
|
|
1037
1108
|
}).options("experimentalFeatures", {
|
|
1038
1109
|
array: true,
|
|
1039
1110
|
string: true,
|
|
1040
1111
|
demandOption: false,
|
|
1041
1112
|
description: `Experimental features that can be modified or removed at any time. Example Usage: --experimentalFeatures realtimeUpdates`,
|
|
1042
|
-
default:
|
|
1113
|
+
default: void 0,
|
|
1043
1114
|
defaultDescription: `By default, no arguments will not enable any experimental features.`
|
|
1044
1115
|
}).options("beta", {
|
|
1045
1116
|
boolean: true,
|
|
@@ -1087,7 +1158,8 @@ var GeneratePackageCommand = class {
|
|
|
1087
1158
|
packageName: args.packageName,
|
|
1088
1159
|
packageVersion: args.packageVersion,
|
|
1089
1160
|
outputDir: args.outputDir,
|
|
1090
|
-
beta: !!args.beta
|
|
1161
|
+
beta: !!args.beta,
|
|
1162
|
+
ontologyJsonOnly: args.experimentalFeatures?.includes("ontologyJsonOnly") ?? false
|
|
1091
1163
|
});
|
|
1092
1164
|
const elapsedTime = Date.now() - timeStart;
|
|
1093
1165
|
consola.success(`Finished generating package in ${(elapsedTime / 1e3).toFixed(2)}s`);
|