diff --git a/examples-extra/basic/cli/src/runFoundryPlatformApiTest.ts b/examples-extra/basic/cli/src/runFoundryPlatformApiTest.ts index 45eeaf95a..06c96f104 100644 --- a/examples-extra/basic/cli/src/runFoundryPlatformApiTest.ts +++ b/examples-extra/basic/cli/src/runFoundryPlatformApiTest.ts @@ -20,14 +20,14 @@ import { client } from "./client.js"; import { logger } from "./logger.js"; export async function runFoundryPlatformApiTest() { - const myUser = await Foundry.Security.User.getCurrentUser( + const myUser = await Foundry.Security.Users.getCurrentUser( client, { preview: true }, ); logger.info(myUser, "Loaded user"); console.log("User", myUser!.email); - const models = await Models.LanguageModel.listLanguageModels(client); + const models = await Models.LanguageModels.listLanguageModels(client); logger.info({ models: models.data.map(m => `'${m.apiName}' in ${m.source}`), }, "Loaded models"); diff --git a/examples-extra/basic/cli/src/runFoundrySdkClientVerificationTest.ts b/examples-extra/basic/cli/src/runFoundrySdkClientVerificationTest.ts index db8680d51..27ae4f64d 100644 --- a/examples-extra/basic/cli/src/runFoundrySdkClientVerificationTest.ts +++ b/examples-extra/basic/cli/src/runFoundrySdkClientVerificationTest.ts @@ -26,10 +26,10 @@ export async function runFoundrySdkClientVerificationTest( const pageSize = 10; // will throw if dataset not found - const dataset = await Datasets.Dataset.getDataset(client, datasetRid); + const dataset = await Datasets.Datasets.getDataset(client, datasetRid); logger.info({ dataset }, `Loaded dataset ${datasetRid}`); - const branchesResult = await Datasets.Branch.listBranches( + const branchesResult = await Datasets.Branches.listBranches( client, datasetRid, { pageSize }, @@ -60,7 +60,7 @@ export async function runFoundrySdkClientVerificationTest( // We want to be sure the error is filled out nicely, so we can use the `master` branch // now that we know it exists. try { - await Datasets.Branch.createBranch(client, datasetRid, { + await Datasets.Branches.createBranch(client, datasetRid, { branchId: "master", }); throw new Error("createBranch(master) should have failed"); @@ -78,7 +78,7 @@ export async function runFoundrySdkClientVerificationTest( } } - const testBranch = await Datasets.Branch.createBranch( + const testBranch = await Datasets.Branches.createBranch( client, datasetRid, { branchId: branchToCreate }, @@ -86,7 +86,7 @@ export async function runFoundrySdkClientVerificationTest( logger.info({ testBranch }, "Created test branch"); // Returns Promise and should not error - await Datasets.Branch.deleteBranch( + await Datasets.Branches.deleteBranch( client, datasetRid, testBranch.branchId, diff --git a/packages/client/src/actions/applyAction.ts b/packages/client/src/actions/applyAction.ts index 9853712ed..5ea63ed8a 100644 --- a/packages/client/src/actions/applyAction.ts +++ b/packages/client/src/actions/applyAction.ts @@ -44,7 +44,7 @@ export async function applyAction< parameters?: OsdkActionParameters, options: Op = {} as Op, ): Promise> { - const response = await OntologiesV2.Action.applyActionV2( + const response = await OntologiesV2.Actions.applyActionV2( addUserAgent(client, action), client.ontologyRid, action.apiName, diff --git a/packages/client/src/object/aggregate.ts b/packages/client/src/object/aggregate.ts index b6d5c2eaf..c1b3c783c 100644 --- a/packages/client/src/object/aggregate.ts +++ b/packages/client/src/object/aggregate.ts @@ -110,7 +110,7 @@ export async function aggregate< if (req.where) { body.where = modernToLegacyWhereClause(req.where); } - const result = await OntologiesV2.OntologyObjectSet.aggregateObjectSetV2( + const result = await OntologiesV2.OntologyObjectSets.aggregateObjectSetV2( addUserAgent(clientCtx, objectType), clientCtx.ontologyRid, { diff --git a/packages/client/src/object/fetchPage.ts b/packages/client/src/object/fetchPage.ts index f8cb0b671..617b1271e 100644 --- a/packages/client/src/object/fetchPage.ts +++ b/packages/client/src/object/fetchPage.ts @@ -165,7 +165,7 @@ async function fetchInterfacePage< args: FetchPageArgs, objectSet: ObjectSet, ): Promise> { - const result = await OntologiesV2.OntologyObjectV2.searchObjectsForInterface( + const result = await OntologiesV2.OntologyObjectsV2.searchObjectsForInterface( addUserAgent(client, interfaceType), client.ontologyRid, interfaceType.apiName, @@ -302,7 +302,7 @@ export async function fetchObjectPage< args: FetchPageArgs, objectSet: ObjectSet, ): Promise> { - const r = await OntologiesV2.OntologyObjectSet.loadObjectSetV2( + const r = await OntologiesV2.OntologyObjectSets.loadObjectSetV2( addUserAgent(client, objectType), client.ontologyRid, applyFetchArgs(args, { diff --git a/packages/client/src/objectSet/ObjectSetListenerWebsocket.ts b/packages/client/src/objectSet/ObjectSetListenerWebsocket.ts index 4b2be6932..66d08da86 100644 --- a/packages/client/src/objectSet/ObjectSetListenerWebsocket.ts +++ b/packages/client/src/objectSet/ObjectSetListenerWebsocket.ts @@ -223,7 +223,7 @@ export class ObjectSetListenerWebsocket { // look up the object type's rid and ensure that we have enabled object set watcher for that rid // TODO ??? getObjectSetBaseType(sub.objectSet).then(baseType => - OntologiesV2.ObjectTypeV2.getObjectTypeV2( + OntologiesV2.ObjectTypesV2.getObjectTypeV2( this.#client, this.#client.ontologyRid, baseType, @@ -625,11 +625,12 @@ async function getOntologyPropertyMappingForApiName( ); } - const wireObjectType = await OntologiesV2.ObjectTypeV2.getObjectTypeV2( - client, - client.ontologyRid, - objectApiName, - ); + const wireObjectType = await OntologiesV2.ObjectTypesV2 + .getObjectTypeV2( + client, + client.ontologyRid, + objectApiName, + ); return getOntologyPropertyMappingForRid( ctx, diff --git a/packages/client/src/ontology/StandardOntologyProvider.ts b/packages/client/src/ontology/StandardOntologyProvider.ts index fdacdeb22..f254baafe 100644 --- a/packages/client/src/ontology/StandardOntologyProvider.ts +++ b/packages/client/src/ontology/StandardOntologyProvider.ts @@ -43,12 +43,12 @@ const alwaysRevalidateDefault = false; // SLLLLLLOOOOOOOWWWW async function fullOntologyLoad(client: MinimalClient) { return await Promise.all([ - OntologiesV2.OntologyObjectV2.listInterfaceTypes( + OntologiesV2.OntologyObjectsV2.listInterfaceTypes( client, client.ontologyRid, { pageSize: 200, preview: true }, ), - OntologiesV2.OntologyV2.getOntologyFullMetadata( + OntologiesV2.OntologiesV2.getOntologyFullMetadata( client, client.ontologyRid, ), diff --git a/packages/client/src/ontology/loadFullObjectMetadata.ts b/packages/client/src/ontology/loadFullObjectMetadata.ts index a4aa5c452..8773ab86e 100644 --- a/packages/client/src/ontology/loadFullObjectMetadata.ts +++ b/packages/client/src/ontology/loadFullObjectMetadata.ts @@ -23,7 +23,7 @@ export async function loadFullObjectMetadata( client: MinimalClient, objtype: string, ): Promise & { rid: string }> { - const full = await OntologiesV2.OntologyObjectV2.getObjectTypeFullMetadata( + const full = await OntologiesV2.OntologyObjectsV2.getObjectTypeFullMetadata( client, client.ontologyRid, objtype, diff --git a/packages/client/src/ontology/loadInterfaceDefinition.ts b/packages/client/src/ontology/loadInterfaceDefinition.ts index 3b52070a7..c620e0253 100644 --- a/packages/client/src/ontology/loadInterfaceDefinition.ts +++ b/packages/client/src/ontology/loadInterfaceDefinition.ts @@ -23,7 +23,7 @@ export async function loadInterfaceDefinition( client: MinimalClient, objtype: string, ): Promise> { - const r = await OntologiesV2.OntologyObjectV2.getInterfaceType( + const r = await OntologiesV2.OntologyObjectsV2.getInterfaceType( client, client.ontologyRid, objtype, diff --git a/packages/foundry.core/src/index.ts b/packages/foundry.core/src/index.ts index 49c7de029..987e9ecb3 100644 --- a/packages/foundry.core/src/index.ts +++ b/packages/foundry.core/src/index.ts @@ -14,4 +14,45 @@ * limitations under the License. */ -export type * from "./_components.js"; +export type { + ArchiveFileFormat, + AttributeName, + AttributeValue, + AttributeValues, + ContentLength, + ContentType, + CreatedBy, + CreatedTime, + DisplayName, + Distance, + DistanceUnit, + Duration, + FilePath, + FolderRid, + Group, + GroupMember, + GroupMembership, + GroupMembershipExpiration, + GroupName, + OrganizationRid, + PageSize, + PageToken, + PreviewMode, + PrincipalId, + PrincipalType, + Realm, + ReleaseStatus, + SizeBytes, + Subdomain, + ThirdPartyApplication, + ThirdPartyApplicationRid, + TimeUnit, + UpdatedBy, + UpdatedTime, + User, + UserId, + UserUsername, + Version, + VersionVersion, + Website, +} from "./_components.js"; diff --git a/packages/foundry.security/src/index.ts b/packages/foundry.security/src/index.ts index 9d3a83efa..512bc2d4f 100644 --- a/packages/foundry.security/src/index.ts +++ b/packages/foundry.security/src/index.ts @@ -14,8 +14,14 @@ * limitations under the License. */ -export type * from "./_components.js"; -export * as Group from "./public/Group.js"; -export * as GroupMember from "./public/GroupMember.js"; -export * as GroupMembership from "./public/GroupMembership.js"; -export * as User from "./public/User.js"; +export type { + AddGroupMembersRequest, + CreateGroupRequest, + ListGroupMembershipsResponse, + ListGroupMembersResponse, + RemoveGroupMembersRequest, +} from "./_components.js"; +export * as Groups from "./public/Group.js"; +export * as GroupMembers from "./public/GroupMember.js"; +export * as GroupMemberships from "./public/GroupMembership.js"; +export * as Users from "./public/User.js"; diff --git a/packages/foundry.thirdpartyapplications/src/index.ts b/packages/foundry.thirdpartyapplications/src/index.ts index f187898d3..905bfe08b 100644 --- a/packages/foundry.thirdpartyapplications/src/index.ts +++ b/packages/foundry.thirdpartyapplications/src/index.ts @@ -14,7 +14,10 @@ * limitations under the License. */ -export type * from "./_components.js"; -export * as ThirdPartyApplication from "./public/ThirdPartyApplication.js"; -export * as Version from "./public/Version.js"; -export * as Website from "./public/Website.js"; +export type { + DeployWebsiteRequest, + ListVersionsResponse, +} from "./_components.js"; +export * as ThirdPartyApplications from "./public/ThirdPartyApplication.js"; +export * as Versions from "./public/Version.js"; +export * as Websites from "./public/Website.js"; diff --git a/packages/internal.foundry.core/src/index.ts b/packages/internal.foundry.core/src/index.ts index 49c7de029..33861d4af 100644 --- a/packages/internal.foundry.core/src/index.ts +++ b/packages/internal.foundry.core/src/index.ts @@ -14,4 +14,364 @@ * limitations under the License. */ -export type * from "./_components.js"; +export type { + AbsoluteTimeRange, + ActionMode, + ActionParameterArrayType, + ActionParameterType, + ActionParameterV2, + ActionResults, + ActionRid, + ActionType, + ActionTypeApiName, + ActionTypeRid, + ActionTypeV2, + AddLink, + AddObject, + AggregateObjectSetRequestV2, + AggregateObjectsRequest, + AggregateObjectsRequestV2, + AggregateObjectsResponse, + AggregateObjectsResponseItem, + AggregateObjectsResponseItemV2, + AggregateObjectsResponseV2, + Aggregation, + AggregationAccuracy, + AggregationAccuracyRequest, + AggregationDurationGrouping, + AggregationDurationGroupingV2, + AggregationExactGrouping, + AggregationExactGroupingV2, + AggregationFixedWidthGrouping, + AggregationFixedWidthGroupingV2, + AggregationGroupBy, + AggregationGroupByV2, + AggregationGroupKey, + AggregationGroupKeyV2, + AggregationGroupValue, + AggregationGroupValueV2, + AggregationMetricName, + AggregationMetricResult, + AggregationMetricResultV2, + AggregationObjectTypeGrouping, + AggregationOrderBy, + AggregationRange, + AggregationRangesGrouping, + AggregationRangesGroupingV2, + AggregationRangeV2, + AggregationV2, + AllTermsQuery, + AndQuery, + AndQueryV2, + AnyTermQuery, + AnyType, + ApplyActionMode, + ApplyActionRequest, + ApplyActionRequestOptions, + ApplyActionRequestV2, + ApplyActionResponse, + ApproximateDistinctAggregation, + ApproximateDistinctAggregationV2, + ApproximatePercentileAggregationV2, + ArchiveFileFormat, + ArraySizeConstraint, + ArtifactRepositoryRid, + AsyncActionOperation, + AsyncActionStatus, + AsyncApplyActionOperationResponseV2, + AsyncApplyActionOperationV2, + AsyncApplyActionRequest, + AsyncApplyActionRequestV2, + AsyncApplyActionResponse, + AsyncApplyActionResponseV2, + Attachment, + AttachmentMetadataResponse, + AttachmentProperty, + AttachmentRid, + AttachmentType, + AttachmentV2, + AvgAggregation, + AvgAggregationV2, + BatchApplyActionRequest, + BatchApplyActionRequestItem, + BatchApplyActionRequestOptions, + BatchApplyActionRequestV2, + BatchApplyActionResponse, + BatchApplyActionResponseV2, + BBox, + BinaryType, + BooleanType, + BoundingBoxValue, + BranchId, + ByteType, + CenterPoint, + CenterPointTypes, + ContainsAllTermsInOrderPrefixLastTerm, + ContainsAllTermsInOrderQuery, + ContainsAllTermsQuery, + ContainsAnyTermQuery, + ContainsQuery, + ContainsQueryV2, + ContentLength, + ContentType, + Coordinate, + CountAggregation, + CountAggregationV2, + CountObjectsResponseV2, + CreatedTime, + CreateLinkRule, + CreateObjectRule, + CreateTemporaryObjectSetRequestV2, + CreateTemporaryObjectSetResponseV2, + CustomTypeId, + DatasetRid, + DataValue, + DateType, + DecimalType, + DeleteLinkRule, + DeleteObjectRule, + DisplayName, + Distance, + DistanceUnit, + DoesNotIntersectBoundingBoxQuery, + DoesNotIntersectPolygonQuery, + DoubleType, + Duration, + EqualsQuery, + EqualsQueryV2, + ExecuteQueryRequest, + ExecuteQueryResponse, + Feature, + FeatureCollection, + FeatureCollectionTypes, + FeaturePropertyKey, + FieldNameV1, + Filename, + FilePath, + FilesystemResource, + FilterValue, + FloatType, + FolderRid, + FunctionRid, + FunctionVersion, + Fuzzy, + FuzzyV2, + GeoJsonObject, + Geometry, + GeometryCollection, + GeoPoint, + GeoPointType, + GeoShapeType, + GroupMemberConstraint, + GteQuery, + GteQueryV2, + GtQuery, + GtQueryV2, + IntegerType, + InterfaceLinkType, + InterfaceLinkTypeApiName, + InterfaceLinkTypeCardinality, + InterfaceLinkTypeLinkedEntityApiName, + InterfaceLinkTypeRid, + InterfaceType, + InterfaceTypeApiName, + InterfaceTypeRid, + IntersectsBoundingBoxQuery, + IntersectsPolygonQuery, + IsNullQuery, + IsNullQueryV2, + LanguageModelSource, + LinearRing, + LineString, + LineStringCoordinates, + LinkedInterfaceTypeApiName, + LinkedObjectTypeApiName, + LinkSideObject, + LinkTypeApiName, + LinkTypeSide, + LinkTypeSideCardinality, + LinkTypeSideV2, + ListActionTypesResponse, + ListActionTypesResponseV2, + ListAttachmentsResponseV2, + ListInterfaceTypesResponse, + ListLinkedObjectsResponse, + ListLinkedObjectsResponseV2, + ListObjectsResponse, + ListObjectsResponseV2, + ListObjectTypesResponse, + ListObjectTypesV2Response, + ListOntologiesResponse, + ListOntologiesV2Response, + ListOutgoingLinkTypesResponse, + ListOutgoingLinkTypesResponseV2, + ListQueryTypesResponse, + ListQueryTypesResponseV2, + LoadObjectSetRequestV2, + LoadObjectSetResponseV2, + LocalFilePath, + LogicRule, + LongType, + LteQuery, + LteQueryV2, + LtQuery, + LtQueryV2, + MarkingType, + MaxAggregation, + MaxAggregationV2, + MediaType, + MinAggregation, + MinAggregationV2, + ModifyObject, + ModifyObjectRule, + MultiLineString, + MultiPoint, + MultiPolygon, + NestedQueryAggregation, + NotQuery, + NotQueryV2, + NullType, + ObjectEdit, + ObjectEdits, + ObjectPropertyType, + ObjectPropertyValueConstraint, + ObjectQueryResultConstraint, + ObjectRid, + ObjectSet, + ObjectSetBaseType, + ObjectSetFilterType, + ObjectSetIntersectionType, + ObjectSetReferenceType, + ObjectSetRid, + ObjectSetSearchAroundType, + ObjectSetStaticType, + ObjectSetSubtractType, + ObjectSetUnionType, + ObjectType, + ObjectTypeApiName, + ObjectTypeEdits, + ObjectTypeFullMetadata, + ObjectTypeInterfaceImplementation, + ObjectTypeRid, + ObjectTypeV2, + ObjectTypeVisibility, + OneOfConstraint, + Ontology, + OntologyApiName, + OntologyArrayType, + OntologyDataType, + OntologyFullMetadata, + OntologyIdentifier, + OntologyMapType, + OntologyObject, + OntologyObjectArrayType, + OntologyObjectSetType, + OntologyObjectType, + OntologyObjectV2, + OntologyRid, + OntologySetType, + OntologyStructField, + OntologyStructType, + OntologyV2, + OrderBy, + OrderByDirection, + OrQuery, + OrQueryV2, + PageSize, + PageToken, + Parameter, + ParameterEvaluatedConstraint, + ParameterEvaluationResult, + ParameterId, + ParameterOption, + PhraseQuery, + Polygon, + PolygonValue, + Position, + PrefixQuery, + PreviewMode, + PrimaryKeyValue, + Property, + PropertyApiName, + PropertyFilter, + PropertyId, + PropertyV2, + PropertyValue, + PropertyValueEscapedString, + QueryAggregation, + QueryAggregationKeyType, + QueryAggregationRange, + QueryAggregationRangeSubType, + QueryAggregationRangeType, + QueryAggregationValueType, + QueryApiName, + QueryArrayType, + QueryDataType, + QueryOutputV2, + QueryParameterV2, + QuerySetType, + QueryStructField, + QueryStructType, + QueryThreeDimensionalAggregation, + QueryTwoDimensionalAggregation, + QueryType, + QueryTypeV2, + QueryUnionType, + RangeConstraint, + RelativeTime, + RelativeTimeRange, + RelativeTimeRelation, + RelativeTimeSeriesTimeUnit, + ReleaseStatus, + ReturnEditsMode, + SdkPackageName, + SearchJsonQuery, + SearchJsonQueryV2, + SearchObjectsForInterfaceRequest, + SearchObjectsRequest, + SearchObjectsRequestV2, + SearchObjectsResponse, + SearchObjectsResponseV2, + SearchOrderBy, + SearchOrderByV2, + SearchOrdering, + SearchOrderingV2, + SelectedPropertyApiName, + SharedPropertyType, + SharedPropertyTypeApiName, + SharedPropertyTypeRid, + ShortType, + SizeBytes, + StartsWithQuery, + StreamTimeSeriesPointsRequest, + StreamTimeSeriesPointsResponse, + StringLengthConstraint, + StringRegexMatchConstraint, + StringType, + StructFieldName, + SubmissionCriteriaEvaluation, + SumAggregation, + SumAggregationV2, + SyncApplyActionResponseV2, + ThreeDimensionalAggregation, + TimeRange, + TimeSeriesItemType, + TimeSeriesPoint, + TimeseriesType, + TimestampType, + TimeUnit, + TwoDimensionalAggregation, + UnevaluableConstraint, + UnsupportedType, + UpdatedTime, + UserId, + ValidateActionRequest, + ValidateActionResponse, + ValidateActionResponseV2, + ValidationResult, + ValueType, + WithinBoundingBoxPoint, + WithinBoundingBoxQuery, + WithinDistanceOfQuery, + WithinPolygonQuery, +} from "./_components.js"; diff --git a/packages/internal.foundry.datasets/src/index.ts b/packages/internal.foundry.datasets/src/index.ts index fe6975773..1c5e7485e 100644 --- a/packages/internal.foundry.datasets/src/index.ts +++ b/packages/internal.foundry.datasets/src/index.ts @@ -14,8 +14,24 @@ * limitations under the License. */ -export type * from "./_components.js"; -export * as Branch from "./public/Branch.js"; -export * as Dataset from "./public/Dataset.js"; -export * as File from "./public/File.js"; -export * as Transaction from "./public/Transaction.js"; +export type { + Branch, + CreateBranchRequest, + CreateDatasetRequest, + CreateTransactionRequest, + Dataset, + DatasetName, + File, + ListBranchesResponse, + ListFilesResponse, + ResourcePath, + TableExportFormat, + Transaction, + TransactionRid, + TransactionStatus, + TransactionType, +} from "./_components.js"; +export * as Branches from "./public/Branch.js"; +export * as Datasets from "./public/Dataset.js"; +export * as Files from "./public/File.js"; +export * as Transactions from "./public/Transaction.js"; diff --git a/packages/internal.foundry.models/src/index.ts b/packages/internal.foundry.models/src/index.ts index 7cfe80b82..c5bf1c964 100644 --- a/packages/internal.foundry.models/src/index.ts +++ b/packages/internal.foundry.models/src/index.ts @@ -14,5 +14,16 @@ * limitations under the License. */ -export type * from "./_components.js"; -export * as LanguageModel from "./public/LanguageModel.js"; +export type { + ChatCompletionChoice, + ChatCompletionRequest, + ChatCompletionResponse, + ChatMessage, + ChatMessageRole, + LanguageModel, + LanguageModelApiName, + ListLanguageModelsResponse, + ParameterKey, + ParameterValue, +} from "./_components.js"; +export * as LanguageModels from "./public/LanguageModel.js"; diff --git a/packages/internal.foundry.ontologies/src/index.ts b/packages/internal.foundry.ontologies/src/index.ts index f9ddf1b4c..3ebee371f 100644 --- a/packages/internal.foundry.ontologies/src/index.ts +++ b/packages/internal.foundry.ontologies/src/index.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -export type * from "./_components.js"; -export * as ActionType from "./public/ActionType.js"; -export * as Attachment from "./public/Attachment.js"; -export * as ObjectType from "./public/ObjectType.js"; -export * as Ontology from "./public/Ontology.js"; -export * as OntologyObject from "./public/OntologyObject.js"; -export * as QueryType from "./public/QueryType.js"; +export type {} from "./_components.js"; +export * as ActionTypes from "./public/ActionType.js"; +export * as Attachments from "./public/Attachment.js"; +export * as ObjectTypes from "./public/ObjectType.js"; +export * as Ontologies from "./public/Ontology.js"; +export * as OntologyObjects from "./public/OntologyObject.js"; +export * as QueryTypes from "./public/QueryType.js"; diff --git a/packages/internal.foundry.ontologiesv2/src/index.ts b/packages/internal.foundry.ontologiesv2/src/index.ts index fed9ffec6..4cf6b2cac 100644 --- a/packages/internal.foundry.ontologiesv2/src/index.ts +++ b/packages/internal.foundry.ontologiesv2/src/index.ts @@ -14,11 +14,11 @@ * limitations under the License. */ -export type * from "./_components.js"; -export * as Action from "./public/Action.js"; -export * as ActionTypeV2 from "./public/ActionTypeV2.js"; -export * as ObjectTypeV2 from "./public/ObjectTypeV2.js"; -export * as OntologyObjectSet from "./public/OntologyObjectSet.js"; -export * as OntologyObjectV2 from "./public/OntologyObjectV2.js"; -export * as OntologyV2 from "./public/OntologyV2.js"; -export * as QueryType from "./public/QueryType.js"; +export type {} from "./_components.js"; +export * as Actions from "./public/Action.js"; +export * as ActionTypesV2 from "./public/ActionTypeV2.js"; +export * as ObjectTypesV2 from "./public/ObjectTypeV2.js"; +export * as OntologyObjectSets from "./public/OntologyObjectSet.js"; +export * as OntologyObjectsV2 from "./public/OntologyObjectV2.js"; +export * as OntologiesV2 from "./public/OntologyV2.js"; +export * as QueryTypes from "./public/QueryType.js"; diff --git a/packages/platform-sdk-generator/package.json b/packages/platform-sdk-generator/package.json index 8a76ec6cc..3ec2961d4 100644 --- a/packages/platform-sdk-generator/package.json +++ b/packages/platform-sdk-generator/package.json @@ -27,6 +27,7 @@ }, "dependencies": { "find-up": "^7.0.0", + "pluralize": "^8.0.0", "prettier": "^3.2.5", "tiny-invariant": "^1.3.3", "yaml": "^2.4.2", @@ -34,6 +35,7 @@ }, "devDependencies": { "@types/node": "^20.11.30", + "@types/pluralize": "^0.0.33", "@types/yargs": "^17.0.29", "typescript": "^5.4.5" }, diff --git a/packages/platform-sdk-generator/src/generatePlatformSdkv2.ts b/packages/platform-sdk-generator/src/generatePlatformSdkv2.ts index b36ccd679..0b17eaf07 100644 --- a/packages/platform-sdk-generator/src/generatePlatformSdkv2.ts +++ b/packages/platform-sdk-generator/src/generatePlatformSdkv2.ts @@ -16,6 +16,7 @@ import fs from "node:fs/promises"; import * as path from "node:path"; +import pluralizeWord from "pluralize"; import { addPackagesToPackageJson } from "./addPackagesToPackageJson.js"; import { copyright } from "./copyright.js"; import { generateImports, SKIP } from "./generateImports.js"; @@ -38,9 +39,11 @@ export async function generatePlatformSdkV2( const npmOrg = "@osdk"; const model = await Model.create(ir, { npmOrg, outputDir, packagePrefix }); + const componentsGenerated = new Map(); + // We need to make sure the components are all populated before we generate the resources for (const ns of model.namespaces) { - await generateComponents(ns, ns.paths.srcDir); + componentsGenerated.set(ns, await generateComponents(ns, ns.paths.srcDir)); } // Now we can generate the resources @@ -65,9 +68,16 @@ export async function generatePlatformSdkV2( ns.paths.resourcesDir, ); + const resourceName = pluralize(r.component); + if (componentsGenerated.get(ns)!.some(c => c === resourceName)) { + throw new Error( + `Even the duplicated components aren't unique: ${resourceName}`, + ); + } + // path utilities are bad for urls like things because they strip the leading period nsIndexTsContents += - `export * as ${r.component} from "${resourceDirRelToSrc}/${r.component}.js";\n`; + `export * as ${resourceName} from "${resourceDirRelToSrc}/${r.component}.js";\n`; } const deps = new Set([model.commonNamespace]); @@ -86,7 +96,9 @@ export async function generatePlatformSdkV2( [...deps].map(n => n.packageName), ); - nsIndexTsContents += `export type * from "./_components.js";\n`; + nsIndexTsContents += `export type {${ + componentsGenerated.get(ns)?.sort().join(",\n") + }} from "./_components.js";\n`; await writeCode( path.join(ns.paths.srcDir, "index.ts"), nsIndexTsContents, @@ -121,13 +133,14 @@ export async function generatePlatformSdkV2( primaryPackagePath, ...[...model.namespaces].map(ns => ns.paths.packagePath), ]; -} +} // ^(.*?)(V2)?$ export async function generateComponents( ns: Namespace, outputDir: string, ) { const referencedComponents = new Set(); + const ret = []; let out = `export type LooselyBrandedString = string & {__LOOSE_BRAND?: T }; @@ -138,6 +151,7 @@ export async function generateComponents( continue; } out += component.declaration; + ret.push(component.name); addAll(referencedComponents, component.referencedComponents); } @@ -152,6 +166,8 @@ export async function generateComponents( ${out}`, ); + + return ret; } export async function ensurePackageSetup( @@ -254,3 +270,16 @@ async function createPackageJson(outputDir: string, name: string) { ), ); } + +export function pluralize(s: string) { + const parts = s.split(/(?=[A-Z])/); + if (!parts) throw new Error("Failed to pluralize"); + + const lastPart = parts[parts.length - 1] === "V2" + ? parts.length - 2 + : parts.length - 1; + + parts[lastPart] = pluralizeWord(parts[lastPart]); + + return parts.join(""); +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 65f16b446..9b2bcb09c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1247,6 +1247,9 @@ importers: find-up: specifier: ^7.0.0 version: 7.0.0 + pluralize: + specifier: ^8.0.0 + version: 8.0.0 prettier: specifier: ^3.2.5 version: 3.2.5 @@ -1263,6 +1266,9 @@ importers: '@types/node': specifier: ^20.11.30 version: 20.12.12 + '@types/pluralize': + specifier: ^0.0.33 + version: 0.0.33 '@types/yargs': specifier: ^17.0.29 version: 17.0.32 @@ -3619,6 +3625,10 @@ packages: resolution: {integrity: sha512-lqa4UEhhv/2sjjIQgjX8B+RBjj47eo0mzGasklVJ78UKGQY1r0VpB9XHDaZZO9qzEFDdy4MrXLuEaSmPrPSe/A==} dev: true + /@types/pluralize@0.0.33: + resolution: {integrity: sha512-JOqsl+ZoCpP4e8TDke9W79FDcSgPAR0l6pixx2JHkhnRjvShyYiAYw2LVsnA7K08Y6DeOnaU6ujmENO4os/cYg==} + dev: true + /@types/prop-types@15.7.10: resolution: {integrity: sha512-mxSnDQxPqsZxmeShFH+uwQ4kO4gcJcGahjjMFeLbKE95IAZiiZyiEepGZjtXJ7hN/yfu0bu9xN2ajcU0JcxX6A==} dev: true @@ -8177,6 +8187,11 @@ packages: package-json: 10.0.0 dev: false + /pluralize@8.0.0: + resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} + engines: {node: '>=4'} + dev: false + /possible-typed-array-names@1.0.0: resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==} engines: {node: '>= 0.4'}