@osdk/generator 1.14.0-beta.4 → 2.0.0-beta.6
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 +16 -0
- package/build/browser/index.js +386 -1670
- package/build/browser/index.js.map +1 -1
- package/build/cjs/generateClientSdkPackage.d.cts +6 -26
- package/build/cjs/generateClientSdkPackage.d.ts.map +1 -1
- package/build/cjs/index.cjs +385 -1670
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +0 -1
- package/build/cjs/index.d.ts.map +1 -1
- package/build/cjs/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/cjs/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/build/esm/generateClientSdkPackage.d.ts +6 -26
- package/build/esm/generateClientSdkPackage.d.ts.map +1 -1
- package/build/esm/index.d.ts +0 -1
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +386 -1670
- package/build/esm/index.js.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/package.json +4 -4
- package/build/cjs/v1.1/backcompat/generateOAuthDistDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/generateOAuthDistDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/generateOntologyRuntimeDistDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/generateOntologyRuntimeDistDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-oauth-dist/generateConfidentialClientDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-oauth-dist/generateConfidentialClientDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-oauth-dist/generatePublicClientDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-oauth-dist/generatePublicClientDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-oauth-dist/generateUserTokenDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-oauth-dist/generateUserTokenDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateAggregationsAggregations.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateAggregationsAggregations.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateGroupBy.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateGroupBy.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateMetrics.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateMetrics.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateAttachmentsDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateAttachmentsDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateGeoshapesDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateGeoshapesDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateObjectSetDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateObjectSetDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateSharedObjectCode.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateSharedObjectCode.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateTimeSeriesDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateTimeSeriesDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateAggregationsDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateAggregationsDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateBaseTypesDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateBaseTypesDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateClientDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateClientDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateCommonDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateCommonDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateFiltersDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateFiltersDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateOntologyProviderDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateOntologyProviderDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generatePagingDir.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generatePagingDir.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateErrors.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateErrors.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateOntologyMetadata.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateOntologyMetadata.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateResult.d.cts +0 -3
- package/build/cjs/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateResult.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/util/reexportConsts.d.cts +0 -2
- package/build/cjs/v1.1/backcompat/util/reexportConsts.d.ts.map +0 -1
- package/build/cjs/v1.1/backcompat/util/reexportTypes.d.cts +0 -2
- package/build/cjs/v1.1/backcompat/util/reexportTypes.d.ts.map +0 -1
- package/build/cjs/v1.1/generateActions.d.cts +0 -6
- package/build/cjs/v1.1/generateActions.d.ts.map +0 -1
- package/build/cjs/v1.1/generateActions.test.d.cts +0 -2
- package/build/cjs/v1.1/generateActions.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generateBackCompatDeprecatedExports.d.cts +0 -3
- package/build/cjs/v1.1/generateBackCompatDeprecatedExports.d.ts.map +0 -1
- package/build/cjs/v1.1/generateBatchActions.d.cts +0 -4
- package/build/cjs/v1.1/generateBatchActions.d.ts.map +0 -1
- package/build/cjs/v1.1/generateBatchActions.test.d.cts +0 -2
- package/build/cjs/v1.1/generateBatchActions.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generateBulkActions.d.cts +0 -4
- package/build/cjs/v1.1/generateBulkActions.d.ts.map +0 -1
- package/build/cjs/v1.1/generateBulkActions.test.d.cts +0 -2
- package/build/cjs/v1.1/generateBulkActions.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generateClientSdkVersionOneDotOne.d.cts +0 -4
- package/build/cjs/v1.1/generateClientSdkVersionOneDotOne.d.ts.map +0 -1
- package/build/cjs/v1.1/generateClientSdkVersionOneDotOne.test.d.cts +0 -2
- package/build/cjs/v1.1/generateClientSdkVersionOneDotOne.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generateFoundryClientFile.d.cts +0 -3
- package/build/cjs/v1.1/generateFoundryClientFile.d.ts.map +0 -1
- package/build/cjs/v1.1/generateFoundryClientFile.test.d.cts +0 -2
- package/build/cjs/v1.1/generateFoundryClientFile.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generateIndexFile.d.cts +0 -3
- package/build/cjs/v1.1/generateIndexFile.d.ts.map +0 -1
- package/build/cjs/v1.1/generateMetadataFile.d.cts +0 -4
- package/build/cjs/v1.1/generateMetadataFile.d.ts.map +0 -1
- package/build/cjs/v1.1/generateMetadataFile.test.d.cts +0 -2
- package/build/cjs/v1.1/generateMetadataFile.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generateObjectsInterfaceFile.d.cts +0 -4
- package/build/cjs/v1.1/generateObjectsInterfaceFile.d.ts.map +0 -1
- package/build/cjs/v1.1/generateObjectsInterfaceFile.test.d.cts +0 -2
- package/build/cjs/v1.1/generateObjectsInterfaceFile.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generateObjectsInterfaceSupportFiles.d.cts +0 -4
- package/build/cjs/v1.1/generateObjectsInterfaceSupportFiles.d.ts.map +0 -1
- package/build/cjs/v1.1/generateObjectsInterfaceSupportFiles.test.d.cts +0 -2
- package/build/cjs/v1.1/generateObjectsInterfaceSupportFiles.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generateOntologyIndexFile.d.cts +0 -3
- package/build/cjs/v1.1/generateOntologyIndexFile.d.ts.map +0 -1
- package/build/cjs/v1.1/generatePerActionDataFilesV1.d.cts +0 -3
- package/build/cjs/v1.1/generatePerActionDataFilesV1.d.ts.map +0 -1
- package/build/cjs/v1.1/generatePerActionDataFilesV1.test.d.cts +0 -2
- package/build/cjs/v1.1/generatePerActionDataFilesV1.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generatePerObjectInterfaceAndDataFiles.d.cts +0 -4
- package/build/cjs/v1.1/generatePerObjectInterfaceAndDataFiles.d.ts.map +0 -1
- package/build/cjs/v1.1/generatePerObjectInterfaceAndDataFiles.test.d.cts +0 -2
- package/build/cjs/v1.1/generatePerObjectInterfaceAndDataFiles.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generatePerQueryDataFiles.d.cts +0 -4
- package/build/cjs/v1.1/generatePerQueryDataFiles.d.ts.map +0 -1
- package/build/cjs/v1.1/generatePerQueryDataFiles.test.d.cts +0 -2
- package/build/cjs/v1.1/generatePerQueryDataFiles.test.d.ts.map +0 -1
- package/build/cjs/v1.1/generateQueries.d.cts +0 -4
- package/build/cjs/v1.1/generateQueries.d.ts.map +0 -1
- package/build/cjs/v1.1/generateQueries.test.d.cts +0 -2
- package/build/cjs/v1.1/generateQueries.test.d.ts.map +0 -1
- package/build/cjs/v1.1/wireObjectTypeV2ToSdkObjectConstV1.d.cts +0 -2
- package/build/cjs/v1.1/wireObjectTypeV2ToSdkObjectConstV1.d.ts.map +0 -1
- package/build/cjs/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.test.d.cts +0 -2
- package/build/cjs/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.test.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/generateOAuthDistDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/generateOAuthDistDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/generateOntologyRuntimeDistDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/generateOntologyRuntimeDistDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-oauth-dist/generateConfidentialClientDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-oauth-dist/generateConfidentialClientDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-oauth-dist/generatePublicClientDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-oauth-dist/generatePublicClientDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-oauth-dist/generateUserTokenDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-oauth-dist/generateUserTokenDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateAggregationsAggregations.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateAggregationsAggregations.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateGroupBy.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateGroupBy.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateMetrics.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/aggregations/generateMetrics.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateAttachmentsDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateAttachmentsDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateGeoshapesDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateGeoshapesDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateObjectSetDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateObjectSetDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateSharedObjectCode.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateSharedObjectCode.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateTimeSeriesDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/baseTypes/generateTimeSeriesDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateAggregationsDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateAggregationsDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateBaseTypesDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateBaseTypesDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateClientDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateClientDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateCommonDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateCommonDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateFiltersDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateFiltersDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateOntologyProviderDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateOntologyProviderDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generatePagingDir.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generatePagingDir.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateErrors.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateErrors.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateOntologyMetadata.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateOntologyMetadata.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateResult.d.ts +0 -3
- package/build/esm/v1.1/backcompat/internal-foundry-ontology-runtime-dist/ontologyProvider/generateResult.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/util/reexportConsts.d.ts +0 -2
- package/build/esm/v1.1/backcompat/util/reexportConsts.d.ts.map +0 -1
- package/build/esm/v1.1/backcompat/util/reexportTypes.d.ts +0 -2
- package/build/esm/v1.1/backcompat/util/reexportTypes.d.ts.map +0 -1
- package/build/esm/v1.1/generateActions.d.ts +0 -6
- package/build/esm/v1.1/generateActions.d.ts.map +0 -1
- package/build/esm/v1.1/generateActions.test.d.ts +0 -2
- package/build/esm/v1.1/generateActions.test.d.ts.map +0 -1
- package/build/esm/v1.1/generateBackCompatDeprecatedExports.d.ts +0 -3
- package/build/esm/v1.1/generateBackCompatDeprecatedExports.d.ts.map +0 -1
- package/build/esm/v1.1/generateBatchActions.d.ts +0 -4
- package/build/esm/v1.1/generateBatchActions.d.ts.map +0 -1
- package/build/esm/v1.1/generateBatchActions.test.d.ts +0 -2
- package/build/esm/v1.1/generateBatchActions.test.d.ts.map +0 -1
- package/build/esm/v1.1/generateBulkActions.d.ts +0 -4
- package/build/esm/v1.1/generateBulkActions.d.ts.map +0 -1
- package/build/esm/v1.1/generateBulkActions.test.d.ts +0 -2
- package/build/esm/v1.1/generateBulkActions.test.d.ts.map +0 -1
- package/build/esm/v1.1/generateClientSdkVersionOneDotOne.d.ts +0 -4
- package/build/esm/v1.1/generateClientSdkVersionOneDotOne.d.ts.map +0 -1
- package/build/esm/v1.1/generateClientSdkVersionOneDotOne.test.d.ts +0 -2
- package/build/esm/v1.1/generateClientSdkVersionOneDotOne.test.d.ts.map +0 -1
- package/build/esm/v1.1/generateFoundryClientFile.d.ts +0 -3
- package/build/esm/v1.1/generateFoundryClientFile.d.ts.map +0 -1
- package/build/esm/v1.1/generateFoundryClientFile.test.d.ts +0 -2
- package/build/esm/v1.1/generateFoundryClientFile.test.d.ts.map +0 -1
- package/build/esm/v1.1/generateIndexFile.d.ts +0 -3
- package/build/esm/v1.1/generateIndexFile.d.ts.map +0 -1
- package/build/esm/v1.1/generateMetadataFile.d.ts +0 -4
- package/build/esm/v1.1/generateMetadataFile.d.ts.map +0 -1
- package/build/esm/v1.1/generateMetadataFile.test.d.ts +0 -2
- package/build/esm/v1.1/generateMetadataFile.test.d.ts.map +0 -1
- package/build/esm/v1.1/generateObjectsInterfaceFile.d.ts +0 -4
- package/build/esm/v1.1/generateObjectsInterfaceFile.d.ts.map +0 -1
- package/build/esm/v1.1/generateObjectsInterfaceFile.test.d.ts +0 -2
- package/build/esm/v1.1/generateObjectsInterfaceFile.test.d.ts.map +0 -1
- package/build/esm/v1.1/generateObjectsInterfaceSupportFiles.d.ts +0 -4
- package/build/esm/v1.1/generateObjectsInterfaceSupportFiles.d.ts.map +0 -1
- package/build/esm/v1.1/generateObjectsInterfaceSupportFiles.test.d.ts +0 -2
- package/build/esm/v1.1/generateObjectsInterfaceSupportFiles.test.d.ts.map +0 -1
- package/build/esm/v1.1/generateOntologyIndexFile.d.ts +0 -3
- package/build/esm/v1.1/generateOntologyIndexFile.d.ts.map +0 -1
- package/build/esm/v1.1/generatePerActionDataFilesV1.d.ts +0 -3
- package/build/esm/v1.1/generatePerActionDataFilesV1.d.ts.map +0 -1
- package/build/esm/v1.1/generatePerActionDataFilesV1.test.d.ts +0 -2
- package/build/esm/v1.1/generatePerActionDataFilesV1.test.d.ts.map +0 -1
- package/build/esm/v1.1/generatePerObjectInterfaceAndDataFiles.d.ts +0 -4
- package/build/esm/v1.1/generatePerObjectInterfaceAndDataFiles.d.ts.map +0 -1
- package/build/esm/v1.1/generatePerObjectInterfaceAndDataFiles.test.d.ts +0 -2
- package/build/esm/v1.1/generatePerObjectInterfaceAndDataFiles.test.d.ts.map +0 -1
- package/build/esm/v1.1/generatePerQueryDataFiles.d.ts +0 -4
- package/build/esm/v1.1/generatePerQueryDataFiles.d.ts.map +0 -1
- package/build/esm/v1.1/generatePerQueryDataFiles.test.d.ts +0 -2
- package/build/esm/v1.1/generatePerQueryDataFiles.test.d.ts.map +0 -1
- package/build/esm/v1.1/generateQueries.d.ts +0 -4
- package/build/esm/v1.1/generateQueries.d.ts.map +0 -1
- package/build/esm/v1.1/generateQueries.test.d.ts +0 -2
- package/build/esm/v1.1/generateQueries.test.d.ts.map +0 -1
- package/build/esm/v1.1/wireObjectTypeV2ToSdkObjectConstV1.d.ts +0 -2
- package/build/esm/v1.1/wireObjectTypeV2ToSdkObjectConstV1.d.ts.map +0 -1
- package/build/esm/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.test.d.ts +0 -2
- package/build/esm/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.test.d.ts.map +0 -1
package/build/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var fs = require('fs');
|
|
4
|
-
var
|
|
4
|
+
var path5 = require('path');
|
|
5
5
|
var generatorConverters = require('@osdk/generator-converters');
|
|
6
6
|
var prettier = require('prettier');
|
|
7
7
|
var organizeImports = require('prettier-plugin-organize-imports');
|
|
@@ -29,7 +29,7 @@ function _interopNamespace(e) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
32
|
-
var
|
|
32
|
+
var path5__namespace = /*#__PURE__*/_interopNamespace(path5);
|
|
33
33
|
var organizeImports__default = /*#__PURE__*/_interopDefault(organizeImports);
|
|
34
34
|
var fastDeepEqual__default = /*#__PURE__*/_interopDefault(fastDeepEqual);
|
|
35
35
|
var invariant__default = /*#__PURE__*/_interopDefault(invariant);
|
|
@@ -56,7 +56,7 @@ var AbstractImportable = class {
|
|
|
56
56
|
}
|
|
57
57
|
getImportPathRelTo = (filePath) => {
|
|
58
58
|
if (this.importPath.startsWith(".")) {
|
|
59
|
-
const result =
|
|
59
|
+
const result = path5__namespace.relative(path5__namespace.dirname(filePath), this.importPath);
|
|
60
60
|
if (result.startsWith(".")) {
|
|
61
61
|
return result;
|
|
62
62
|
} else {
|
|
@@ -266,6 +266,22 @@ function sanitizeMetadata(ontology) {
|
|
|
266
266
|
function camelize(name) {
|
|
267
267
|
return name.replace(/-./g, (segment) => segment[1].toUpperCase());
|
|
268
268
|
}
|
|
269
|
+
function formatTs(contents) {
|
|
270
|
+
try {
|
|
271
|
+
return prettier.format(contents, {
|
|
272
|
+
parser: "typescript",
|
|
273
|
+
singleQuote: true,
|
|
274
|
+
trailingComma: "all",
|
|
275
|
+
plugins: [organizeImports__default.default],
|
|
276
|
+
tabWidth: 2,
|
|
277
|
+
printWidth: 120
|
|
278
|
+
});
|
|
279
|
+
} catch (e) {
|
|
280
|
+
console.error("Failed to format file", e);
|
|
281
|
+
console.log(contents);
|
|
282
|
+
return contents;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
269
285
|
|
|
270
286
|
// src/util/verifyOutDir.ts
|
|
271
287
|
async function verifyOutDir(outDir, fs2) {
|
|
@@ -280,6 +296,28 @@ async function verifyOutDir(outDir, fs2) {
|
|
|
280
296
|
}
|
|
281
297
|
}
|
|
282
298
|
}
|
|
299
|
+
var ExpectedOsdkVersion = "2.0.0";
|
|
300
|
+
async function generateOntologyMetadataFile({
|
|
301
|
+
fs: fs2,
|
|
302
|
+
outDir,
|
|
303
|
+
ontology,
|
|
304
|
+
ontologyApiNamespace
|
|
305
|
+
}, userAgent) {
|
|
306
|
+
fs2.writeFile(path5__namespace.default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
307
|
+
export type $ExpectedClientVersion = "${ExpectedOsdkVersion}";
|
|
308
|
+
export const $osdkMetadata = { extraUserAgent: "${userAgent}" };
|
|
309
|
+
${ontologyApiNamespace == null ? `
|
|
310
|
+
export const $ontologyRid = "${ontology.ontology.rid}";
|
|
311
|
+
` : ""}
|
|
312
|
+
`));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// src/shared/getObjectImports.ts
|
|
316
|
+
function getObjectImports(objects, curApiName, currentFilePath, v2) {
|
|
317
|
+
return Array.from(objects).filter((obj) => obj.fullApiName !== curApiName).map((obj) => {
|
|
318
|
+
return `import type { ${obj.getDefinitionIdentifier(v2)} as ${obj.getImportedDefinitionIdentifier(v2)} } from "${obj.getImportPathRelTo("./" + currentFilePath)}";`;
|
|
319
|
+
}).join("\n");
|
|
320
|
+
}
|
|
283
321
|
|
|
284
322
|
// src/shared/getEditedEntities.ts
|
|
285
323
|
function getModifiedEntityTypes(action) {
|
|
@@ -300,1558 +338,114 @@ function getModifiedEntityTypes(action) {
|
|
|
300
338
|
modifiedObjects
|
|
301
339
|
};
|
|
302
340
|
}
|
|
303
|
-
function formatTs(contents) {
|
|
304
|
-
try {
|
|
305
|
-
return prettier.format(contents, {
|
|
306
|
-
parser: "typescript",
|
|
307
|
-
singleQuote: true,
|
|
308
|
-
trailingComma: "all",
|
|
309
|
-
plugins: [organizeImports__default.default],
|
|
310
|
-
tabWidth: 2,
|
|
311
|
-
printWidth: 120
|
|
312
|
-
});
|
|
313
|
-
} catch (e) {
|
|
314
|
-
console.error("Failed to format file", e);
|
|
315
|
-
console.log(contents);
|
|
316
|
-
return contents;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
341
|
|
|
320
|
-
// src/
|
|
321
|
-
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
let jsDocBlock = ["/**"];
|
|
332
|
-
if (action.description) {
|
|
333
|
-
jsDocBlock.push(`* ${action.description}`);
|
|
334
|
-
}
|
|
335
|
-
let parameterBlock = "";
|
|
336
|
-
if (entries.length > 0) {
|
|
337
|
-
parameterBlock = `params: {
|
|
338
|
-
`;
|
|
339
|
-
for (const [parameterName, parameterData] of entries) {
|
|
340
|
-
parameterBlock += `"${parameterName}"`;
|
|
341
|
-
parameterBlock += parameterData.required ? ": " : "?: ";
|
|
342
|
-
const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
|
|
343
|
-
parameterBlock += `${typeScriptType};
|
|
344
|
-
`;
|
|
345
|
-
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
346
|
-
}
|
|
347
|
-
parameterBlock += "}, ";
|
|
348
|
-
}
|
|
349
|
-
jsDocBlock.push(`*/`);
|
|
350
|
-
actionSignatures.push(`
|
|
351
|
-
${jsDocBlock.join("\n")}
|
|
352
|
-
${action.apiName}<O extends ActionExecutionOptions>(${parameterBlock}options?: O):
|
|
353
|
-
Promise<Result<ActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;`);
|
|
354
|
-
}
|
|
355
|
-
await fs2.mkdir(outDir, {
|
|
356
|
-
recursive: true
|
|
357
|
-
});
|
|
358
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, "Actions.ts"), await formatTs(`
|
|
359
|
-
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, ActionError, Result, ActionResponseFromOptions } from "@osdk/legacy-client";
|
|
360
|
-
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
361
|
-
export interface Actions {
|
|
362
|
-
${actionSignatures.join("\n")}
|
|
363
|
-
}
|
|
364
|
-
`));
|
|
342
|
+
// src/shared/wireActionTypeV2ToSdkActionDefinition.ts
|
|
343
|
+
function wireActionTypeV2ToSdkActionDefinition(input) {
|
|
344
|
+
const modifiedEntityTypes = getModifiedEntityTypes(input);
|
|
345
|
+
return {
|
|
346
|
+
type: "action",
|
|
347
|
+
apiName: input.apiName,
|
|
348
|
+
parameters: Object.fromEntries(Object.entries(input.parameters).map(([key, value]) => [key, wireActionParameterV2ToSdkParameterDefinition(value)])),
|
|
349
|
+
displayName: input.displayName,
|
|
350
|
+
description: input.description,
|
|
351
|
+
modifiedEntities: createModifiedEntities(modifiedEntityTypes.addedObjects, modifiedEntityTypes.modifiedObjects)
|
|
352
|
+
};
|
|
365
353
|
}
|
|
366
|
-
function
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
return `${objectType} | ${objectType}["__primaryKey"]`;
|
|
377
|
-
}
|
|
378
|
-
case "array":
|
|
379
|
-
return `Array<${getTypeScriptTypeFromDataType(actionParameter.subType, importedObjects)}>`;
|
|
354
|
+
function wireActionParameterV2ToSdkParameterDefinition(value) {
|
|
355
|
+
return {
|
|
356
|
+
multiplicity: value.dataType.type === "array",
|
|
357
|
+
type: actionPropertyToSdkPropertyDefinition(value.dataType.type === "array" ? value.dataType.subType : value.dataType),
|
|
358
|
+
nullable: !value.required,
|
|
359
|
+
description: value.description
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function actionPropertyToSdkPropertyDefinition(parameterType) {
|
|
363
|
+
switch (parameterType.type) {
|
|
380
364
|
case "string":
|
|
381
|
-
return `string`;
|
|
382
365
|
case "boolean":
|
|
383
|
-
return `boolean`;
|
|
384
366
|
case "attachment":
|
|
385
|
-
return `Attachment`;
|
|
386
|
-
case "date":
|
|
387
|
-
return `LocalDate`;
|
|
388
367
|
case "double":
|
|
389
368
|
case "integer":
|
|
390
369
|
case "long":
|
|
391
|
-
return `number`;
|
|
392
370
|
case "timestamp":
|
|
393
|
-
return `Timestamp`;
|
|
394
371
|
case "marking":
|
|
395
|
-
return
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
`;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// src/v1.1/backcompat/internal-foundry-oauth-dist/generateConfidentialClientDir.ts
|
|
414
|
-
async function generateConfidentialClientDir(fs2, oauthDistDir, importExt = "") {
|
|
415
|
-
const confidentialClientDistDir = path16__namespace.default.join(oauthDistDir, "ConfidentialClient");
|
|
416
|
-
await fs2.mkdir(confidentialClientDistDir, {
|
|
417
|
-
recursive: true
|
|
418
|
-
});
|
|
419
|
-
await fs2.writeFile(path16__namespace.default.join(confidentialClientDistDir, "index.ts"), await formatTs(`
|
|
420
|
-
export * from "./ConfidentialClientAuth${importExt}";
|
|
421
|
-
`));
|
|
422
|
-
await fs2.writeFile(path16__namespace.default.join(confidentialClientDistDir, "ConfidentialClientAuth.ts"), await formatTs(`
|
|
423
|
-
${reexportConsts(["ConfidentialClientAuth"])}
|
|
424
|
-
`));
|
|
425
|
-
}
|
|
426
|
-
async function generatePublicClientDir(fs2, oauthDistDir, importExt = "") {
|
|
427
|
-
const publicClientDistDir = path16__namespace.default.join(oauthDistDir, "PublicClient");
|
|
428
|
-
await fs2.mkdir(publicClientDistDir, {
|
|
429
|
-
recursive: true
|
|
430
|
-
});
|
|
431
|
-
await fs2.writeFile(path16__namespace.default.join(publicClientDistDir, "index.ts"), await formatTs(`
|
|
432
|
-
export * from "./PublicClientAuth${importExt}";
|
|
433
|
-
`));
|
|
434
|
-
await fs2.writeFile(path16__namespace.default.join(publicClientDistDir, "PublicClientAuth.ts"), await formatTs(`
|
|
435
|
-
${reexportConsts(["PublicClientAuth"])}
|
|
436
|
-
`));
|
|
437
|
-
}
|
|
438
|
-
async function generateUserTokenDir(fs2, oauthDistDir, importExt = "") {
|
|
439
|
-
const userTokenDistDir = path16__namespace.default.join(oauthDistDir, "UserToken");
|
|
440
|
-
await fs2.mkdir(userTokenDistDir, {
|
|
441
|
-
recursive: true
|
|
442
|
-
});
|
|
443
|
-
await fs2.writeFile(path16__namespace.default.join(userTokenDistDir, "index.ts"), await formatTs(`
|
|
444
|
-
export * from "./UserTokenAuth${importExt}";
|
|
445
|
-
`));
|
|
446
|
-
await fs2.writeFile(path16__namespace.default.join(userTokenDistDir, "UserTokenAuth.ts"), await formatTs(`
|
|
447
|
-
${reexportConsts(["UserTokenAuth"])}
|
|
448
|
-
`));
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
// src/v1.1/backcompat/util/reexportTypes.ts
|
|
452
|
-
function reexportTypes(typesToExport, genericArgsLeft = "", genericArgsRight = cleanup(genericArgsLeft)) {
|
|
453
|
-
return `
|
|
454
|
-
import type { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
|
|
455
|
-
|
|
456
|
-
${typesToExport.map((q) => `
|
|
457
|
-
/** @deprecated submodule imports aren't public api **/
|
|
458
|
-
export type ${q}${genericArgsLeft} = OG_${q}${genericArgsRight};
|
|
459
|
-
`).join("\n\n")}
|
|
460
|
-
`;
|
|
461
|
-
}
|
|
462
|
-
var captureInBracketsRegex = /<(.*?)>/;
|
|
463
|
-
var captureGenericParamNameRegex = /^\s?(.+?)( extends .*?)?( = .*?)?\s?$/;
|
|
464
|
-
function cleanup(s) {
|
|
465
|
-
if (s.length === 0) return "";
|
|
466
|
-
const genericParameterNames = captureInBracketsRegex.exec(s)?.[1]?.split(",")?.map((a) => {
|
|
467
|
-
return captureGenericParamNameRegex.exec(a)?.[1] ?? a;
|
|
468
|
-
});
|
|
469
|
-
return `<${genericParameterNames?.join(",")}>`;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// src/v1.1/backcompat/generateOAuthDistDir.ts
|
|
473
|
-
async function generateOAuthClientDistDir(outDir, fs2, importExt = "") {
|
|
474
|
-
const oauthDistDir = path16__namespace.join(outDir, "internal", "@foundry", "oauth-client", "dist");
|
|
475
|
-
await fs2.mkdir(oauthDistDir, {
|
|
476
|
-
recursive: true
|
|
477
|
-
});
|
|
478
|
-
await fs2.writeFile(path16__namespace.join(oauthDistDir, "index.ts"), await formatTs(`
|
|
479
|
-
export * from "./Auth${importExt}";
|
|
480
|
-
export * from "./ConfidentialClient/index${importExt}";
|
|
481
|
-
export * from "./OAuthClient${importExt}";
|
|
482
|
-
export * from "./PublicClient/index${importExt}";
|
|
483
|
-
export * from "./Token${importExt}";
|
|
484
|
-
export * from "./UserToken/index${importExt}";
|
|
485
|
-
`));
|
|
486
|
-
await fs2.writeFile(path16__namespace.join(oauthDistDir, "Auth.ts"), await formatTs(reexportTypes(["Auth"])));
|
|
487
|
-
await fs2.writeFile(path16__namespace.join(oauthDistDir, "Token.ts"), await formatTs(reexportTypes(["Token", "TokenValue"])));
|
|
488
|
-
await fs2.writeFile(path16__namespace.join(oauthDistDir, "OAuthClient.ts"), await formatTs(reexportTypes(["AuthSubscription", "UnsubscribeFunction", "SignInResponse", "RefreshResponse", "SignOutResponse"])));
|
|
489
|
-
await fs2.writeFile(path16__namespace.join(oauthDistDir, "OAuthToken.ts"), await formatTs(reexportConsts(["OAuthToken"])));
|
|
490
|
-
await fs2.writeFile(path16__namespace.join(oauthDistDir, "Auth.ts"), await formatTs(reexportTypes(["Auth"])));
|
|
491
|
-
await generateConfidentialClientDir(fs2, oauthDistDir, importExt);
|
|
492
|
-
await generatePublicClientDir(fs2, oauthDistDir, importExt);
|
|
493
|
-
await generateUserTokenDir(fs2, oauthDistDir, importExt);
|
|
494
|
-
}
|
|
495
|
-
async function generateAggregationsAggregations(fs2, aggregationsDir) {
|
|
496
|
-
await fs2.writeFile(path16__namespace.join(aggregationsDir, "Aggregations.ts"), await formatTs(`
|
|
497
|
-
import { LocalDate, Timestamp } from "@osdk/legacy-client";
|
|
498
|
-
` + reexportTypes(["Double", "Rangeable", "MetricValue", "Date", "BucketKey", "BucketValue", "TimeUnit", "BucketGroup", "Metrics", "AggregatableProperties", "AggregationClause"]) + reexportTypes(["Range"], "<T extends Rangeable>", "<T>") + reexportTypes(["BaseGroupBy"], "<_T extends BucketValue = BucketValue>") + reexportTypes(["Duration"], "<_T extends Timestamp | LocalDate = Timestamp | LocalDate>") + reexportTypes(["AggregatableProperty", "MultipleAggregationsOperations"], "<_T extends MetricValue = MetricValue>") + reexportTypes(["AggregationGroup"], "<TMetrics extends Metrics | MetricValue, TBucketGroup extends BucketGroup>") + reexportTypes(["Bucketing"], "<_T extends string , _X extends BucketValue>") + reexportTypes(["AggregationResult"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue>") + reexportTypes(["BaseBucketing"], "<TBucketKey extends BucketKey, TBucketValue extends BucketValue, Kind extends string>") + reexportTypes(["ExactValueBucketing", "InternalBucketing"], `<TBucketKey extends BucketKey, TBucketValue extends BucketValue>`) + reexportTypes(["RangeBucketing", "FixedWidthBucketing"], `<TBucketKey extends BucketKey, TBucketValue extends Range<Rangeable>>`) + reexportTypes(["DurationBucketing"], `<TBucketKey extends BucketKey, TBucketValue extends Date>`) + reexportTypes(["InternalBucketingVisitor"], "<TBucketKey extends BucketKey, T extends BucketValue, R>") + reexportTypes(["AggregationBuilderResult"], "<T, TMultipleAggregationProperties>") + reexportTypes(["AggregatablePropertiesForResult", "AggregatablePropertyNamesForResult"], "<TAggregatableProperties, TResult extends MetricValue>") + reexportConsts(["assertBucketingInternal", "visitInternalBucketing"]) + reexportTypes(["AggregatableObjectSetStep"], "<TAggregatableProperties, TMultipleAggregationProperties, TBucketableProperties, TBucketGroup extends BucketGroup = {}>") + reexportTypes(["GroupedTerminalAggregationOperations"], "<TAggregatableProperties, TMultipleAggregationProperties, TBucketGroup extends BucketGroup = {}>")));
|
|
499
|
-
}
|
|
500
|
-
async function generateGroupBy(fs2, aggregationsDir, importExt = "") {
|
|
501
|
-
await fs2.mkdir(path16__namespace.join(aggregationsDir, "groupBy"), {
|
|
502
|
-
recursive: true
|
|
503
|
-
});
|
|
504
|
-
const groupBys = ["BooleanGroupBy", "LocalDateGroupBy", "NumericGroupBy", "StringGroupBy", "TimestampGroupBy"];
|
|
505
|
-
const reexportFiles = [...groupBys, "GroupKeyType"];
|
|
506
|
-
for (const key of reexportFiles) {
|
|
507
|
-
await fs2.writeFile(path16__namespace.join(aggregationsDir, "groupBy", `${key}.ts`), await formatTs(`export {${key}} from "./index${importExt}";`));
|
|
372
|
+
return parameterType.type;
|
|
373
|
+
case "date":
|
|
374
|
+
return "datetime";
|
|
375
|
+
case "objectSet":
|
|
376
|
+
return {
|
|
377
|
+
type: "objectSet",
|
|
378
|
+
objectSet: parameterType.objectTypeApiName
|
|
379
|
+
};
|
|
380
|
+
case "object":
|
|
381
|
+
return {
|
|
382
|
+
type: "object",
|
|
383
|
+
object: parameterType.objectTypeApiName
|
|
384
|
+
};
|
|
385
|
+
case "array":
|
|
386
|
+
return actionPropertyToSdkPropertyDefinition(parameterType.subType);
|
|
508
387
|
}
|
|
509
|
-
await fs2.writeFile(path16__namespace.join(aggregationsDir, "groupBy", "index.ts"), await formatTs(`import { Bucketing, BucketKey, Duration, Range, Rangeable } from "../Aggregations${importExt}";` + reexportConsts(groupBys) + reexportTypes(groupBys, "<T extends BucketKey>") + `export {GroupKeyType} from "@osdk/legacy-client";
|
|
510
|
-
`));
|
|
511
388
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
await fs2.writeFile(path16__namespace.join(metricsDir, "MultipleAggregatableProperty.ts"), await formatTs(`
|
|
520
|
-
import { Double, MetricValue, MultipleAggregationsOperations } from "../Aggregations${importExt}";
|
|
521
|
-
import { MetricValueType } from "./metrics/index${importExt}";
|
|
522
|
-
` + reexportConsts(["MultipleAggregatableProperty"]) + reexportTypes(["MultipleAggregatableProperty"], "<TResult extends MetricValue = Double>")));
|
|
523
|
-
for (const typeName of ["DefaultAggregatableProperty", "LocalDatePropertyMetric", "NumericPropertyMetric", "TimestampPropertyMetric"]) {
|
|
524
|
-
await fs2.writeFile(path16__namespace.join(metricsDir, `${typeName}.ts`), await formatTs(`
|
|
525
|
-
import { MultipleAggregatableProperty } from "./MultipleAggregatableProperty${importExt}";
|
|
526
|
-
` + reexportConsts([typeName])));
|
|
389
|
+
function createModifiedEntities(addedObjects, modifiedObjects) {
|
|
390
|
+
let entities = {};
|
|
391
|
+
for (const key of addedObjects) {
|
|
392
|
+
entities[key] = {
|
|
393
|
+
created: true,
|
|
394
|
+
modified: false
|
|
395
|
+
};
|
|
527
396
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
export * from "./LocalDatePropertyMetric${importExt}";
|
|
532
|
-
export * from "./metrics${importExt}";
|
|
533
|
-
export * from "./MultipleAggregatableProperty${importExt}";
|
|
534
|
-
export * from "./NumericPropertyMetric${importExt}";
|
|
535
|
-
export * from "./TimestampPropertyMetric${importExt}";
|
|
536
|
-
`));
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
// src/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateAggregationsDir.ts
|
|
540
|
-
async function generateAggregationsDir(fs2, runtimeDistDir, importExt = "") {
|
|
541
|
-
const aggregationsDir = path16__namespace.join(runtimeDistDir, "aggregations");
|
|
542
|
-
await fs2.mkdir(aggregationsDir, {
|
|
543
|
-
recursive: true
|
|
544
|
-
});
|
|
545
|
-
await generateGroupBy(fs2, aggregationsDir, importExt);
|
|
546
|
-
await generateAggregationsAggregations(fs2, aggregationsDir);
|
|
547
|
-
await generateMetrics(fs2, aggregationsDir, importExt);
|
|
548
|
-
await fs2.writeFile(path16__namespace.join(aggregationsDir, "index.ts"), await formatTs(`
|
|
549
|
-
${""}
|
|
550
|
-
${""}
|
|
551
|
-
|
|
552
|
-
export * from "./Aggregations${importExt}";
|
|
553
|
-
export * from "./ComputeStep${importExt}";
|
|
554
|
-
export * from "./CountOperation${importExt}";
|
|
555
|
-
export * from "./groupBy/index${importExt}";
|
|
556
|
-
export * from "./internalAggregationRequest${importExt}";
|
|
557
|
-
export * from "./metrics/index${importExt}";
|
|
558
|
-
`));
|
|
559
|
-
await fs2.writeFile(path16__namespace.join(aggregationsDir, "ComputeStep.ts"), await formatTs(`
|
|
560
|
-
import { ObjectSetDefinition } from "../baseTypes/index${importExt}";
|
|
561
|
-
import { FoundryClientOptions } from "../client/${importExt}";
|
|
562
|
-
import { AggregateObjectsError, OntologyMetadata, Result } from "../ontologyProvider/index${importExt}";
|
|
563
|
-
import { AggregationClause, AggregationResult, BucketGroup, BucketValue, InternalBucketing, Metrics, MetricValue } from "./Aggregations${importExt}";
|
|
564
|
-
` + reexportConsts(["ComputeStep"]) + reexportTypes(["ComputeStep"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue> ") + reexportTypes(["AggregationComputeStep"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue>") + `
|
|
565
|
-
|
|
566
|
-
`));
|
|
567
|
-
await fs2.writeFile(path16__namespace.join(aggregationsDir, "CountOperation.ts"), await formatTs(`` + reexportConsts(["CountOperation", "isCountOperation"]) + reexportTypes(["CountOperation"])));
|
|
568
|
-
await fs2.writeFile(path16__namespace.join(aggregationsDir, "internalAggregationRequest.ts"), await formatTs(reexportTypes(["InternalAggregationRequest"])));
|
|
569
|
-
}
|
|
570
|
-
async function generateAttachmentsDir(attachmentsDir, fs2, importExt = "") {
|
|
571
|
-
await fs2.mkdir(attachmentsDir, {
|
|
572
|
-
recursive: true
|
|
573
|
-
});
|
|
574
|
-
await fs2.writeFile(path16__namespace.default.join(attachmentsDir, "index.ts"), await formatTs(`export * from "./Attachment${importExt}";
|
|
575
|
-
export * from "./Attachments${importExt}";
|
|
576
|
-
`));
|
|
577
|
-
await fs2.writeFile(path16__namespace.default.join(attachmentsDir, "Attachment.ts"), await formatTs(reexportTypes(["Attachment", "AttachmentMetadata"])));
|
|
578
|
-
await fs2.writeFile(path16__namespace.default.join(attachmentsDir, "Attachments.ts"), await formatTs(reexportTypes(["Attachments"])));
|
|
579
|
-
}
|
|
580
|
-
async function generateGeoshapesDir(runtimeDistDir, fs2, importExt = "") {
|
|
581
|
-
await fs2.mkdir(runtimeDistDir, {
|
|
582
|
-
recursive: true
|
|
583
|
-
});
|
|
584
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "index.ts"), await formatTs(`export * from "./Distance${importExt}";
|
|
585
|
-
export * from "./GeoJson${importExt}";
|
|
586
|
-
export * from "./GeometryCollection${importExt}";
|
|
587
|
-
export * from "./GeoPoint${importExt}";
|
|
588
|
-
export * from "./GeoShape${importExt}";
|
|
589
|
-
export * from "./LineString${importExt}";
|
|
590
|
-
export * from "./MultiGeoPoint${importExt}";
|
|
591
|
-
export * from "./MultiLineString${importExt}";
|
|
592
|
-
export * from "./MultiPolygon${importExt}";
|
|
593
|
-
export * from "./Polygon${importExt}";`));
|
|
594
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "Distance.ts"), await formatTs(`` + reexportConsts(["Distance", "DistanceUnit"]) + reexportTypes(["Distance", "DistanceUnit"])));
|
|
595
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "GeoJson.ts"), await formatTs(reexportTypes(["GeoJsonPoint", "GeoJsonPolygon", "GeoJsonLineString", "GeoJsonMultiPoint", "GeoJsonMultiPolygon", "GeoJsonMultiLineString", "GeoJsonGeometryCollection", "GeoJsonGeometry", "GeoJson"])));
|
|
596
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "GeometryCollection.ts"), await formatTs(reexportConsts(["GeometryCollection"])));
|
|
597
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "GeoPoint.ts"), await formatTs(`` + reexportConsts(["isGeoPoint", "GeoPoint", "mapCoordinatesToGeoPoint"]) + reexportTypes(["GeoHash", "Coordinates", "GeoPoint"])));
|
|
598
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "GeoShape.ts"), await formatTs(reexportConsts(["GeoShape"]) + reexportTypes(["GeoShape"])));
|
|
599
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "LineString.ts"), await formatTs(reexportConsts(["LineString"]) + reexportTypes(["LineString"])));
|
|
600
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "MultiGeoPoint.ts"), await formatTs(reexportConsts(["MultiGeoPoint"]) + reexportTypes(["MultiGeoPoint"])));
|
|
601
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "MultiLineString.ts"), await formatTs(reexportConsts(["MultiLineString"]) + reexportTypes(["MultiLineString"])));
|
|
602
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "MultiPolygon.ts"), await formatTs(reexportConsts(["MultiPolygon"]) + reexportTypes(["MultiPolygon"])));
|
|
603
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "Polygon.ts"), await formatTs(reexportConsts(["Polygon"]) + reexportTypes(["LinearRing", "Polygon"])));
|
|
604
|
-
}
|
|
605
|
-
async function generateObjectSetDir(objectSetDir, fs2, importExt = "") {
|
|
606
|
-
await fs2.mkdir(objectSetDir, {
|
|
607
|
-
recursive: true
|
|
608
|
-
});
|
|
609
|
-
await fs2.writeFile(path16__namespace.default.join(objectSetDir, "index.ts"), await formatTs(`
|
|
610
|
-
export * from "./ObjectSetDefinition${importExt}";
|
|
611
|
-
export * from "./OntologyObjectSet${importExt}";
|
|
612
|
-
`));
|
|
613
|
-
await fs2.writeFile(path16__namespace.default.join(objectSetDir, "ObjectSetDefinition.ts"), await formatTs(reexportTypes(["BaseObjectSetDefinition", "ReferenceObjectSetDefinition", "StaticObjectSetDefinition", "IntersectObjectSetDefinition", "SubtractObjectSetDefinition", "SearchAroundObjectSetDefinition", "FilterObjectSetDefinition", "ObjectSetDefinition"])));
|
|
614
|
-
await fs2.writeFile(path16__namespace.default.join(objectSetDir, "OntologyObjectSet.ts"), await formatTs(reexportTypes(["OntologyObjectSet"])));
|
|
615
|
-
}
|
|
616
|
-
async function generateSharedObjectCodeDir(sharedObjectCodeDir, fs2, importExt = "") {
|
|
617
|
-
await fs2.mkdir(sharedObjectCodeDir, {
|
|
618
|
-
recursive: true
|
|
619
|
-
});
|
|
620
|
-
await fs2.writeFile(path16__namespace.default.join(sharedObjectCodeDir, "index.ts"), await formatTs(`
|
|
621
|
-
export * from "./FilteredPropertiesTerminalOperations${importExt}";
|
|
622
|
-
`));
|
|
623
|
-
await fs2.writeFile(path16__namespace.default.join(sharedObjectCodeDir, "FilteredPropertiesTerminalOperations.ts"), await formatTs(`import { OntologyObject } from "../OntologyObject${importExt}` + reexportTypes(["FilteredPropertiesTerminalOperations", "FilteredPropertiesTerminalOperationsWithGet"], "<T extends OntologyObject, V extends Array<keyof T>>")));
|
|
624
|
-
}
|
|
625
|
-
async function generateTimeSeriesDir(timeseriesDir, fs2, importExt = "") {
|
|
626
|
-
await fs2.mkdir(timeseriesDir, {
|
|
627
|
-
recursive: true
|
|
628
|
-
});
|
|
629
|
-
await fs2.writeFile(path16__namespace.join(timeseriesDir, "index.ts"), await formatTs(`
|
|
630
|
-
export * from "./TimeSeries${importExt}";
|
|
631
|
-
export * from "./TimeSeriesDuration${importExt}";
|
|
632
|
-
export * from "./TimeSeriesPoint${importExt}";
|
|
633
|
-
${""}
|
|
634
|
-
export * from "./TimeSeriesQuery${importExt}";
|
|
635
|
-
export * from "./TimeSeriesTerminalOperations${importExt}";
|
|
636
|
-
`));
|
|
637
|
-
await fs2.writeFile(path16__namespace.join(timeseriesDir, "TimeSeries.ts"), await formatTs(reexportTypes(["TimeSeries"], `<T extends number | string>`)));
|
|
638
|
-
await fs2.writeFile(path16__namespace.join(timeseriesDir, "TimeSeriesDuration.ts"), await formatTs(reexportTypes([`WhenUnit`, `DurationUnit`, `TimeSeriesDuration`])));
|
|
639
|
-
await fs2.writeFile(path16__namespace.join(timeseriesDir, "TimeSeriesPoint.ts"), await formatTs(reexportTypes(["TimeSeriesPoint"], `<T extends number | string>`)));
|
|
640
|
-
await fs2.writeFile(path16__namespace.join(timeseriesDir, "TimeSeriesQuery.ts"), await formatTs(reexportTypes(["TimeSeriesQuery"], `<T extends number | string>`)));
|
|
641
|
-
await fs2.writeFile(path16__namespace.join(timeseriesDir, "TimeSeriesTerminalOperations.ts"), await formatTs(reexportTypes(["TimeSeriesTerminalOperations", "TimeSeriesIterator"], `<T extends number | string>`)));
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
// src/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateBaseTypesDir.ts
|
|
645
|
-
async function generateBaseTypesDir(runtimeDistDir, fs2, importExt = "") {
|
|
646
|
-
const baseTypesDir = path16__namespace.join(runtimeDistDir, "baseTypes");
|
|
647
|
-
await fs2.mkdir(baseTypesDir, {
|
|
648
|
-
recursive: true
|
|
649
|
-
});
|
|
650
|
-
await fs2.writeFile(path16__namespace.join(baseTypesDir, "index.ts"), await formatTs(`export * from "./ActionType${importExt}";
|
|
651
|
-
export * from "./attachments/index${importExt}";
|
|
652
|
-
export * from "./geoshapes/index${importExt}";
|
|
653
|
-
export * from "./links${importExt}";
|
|
654
|
-
export * from "./localDate${importExt}";
|
|
655
|
-
export * from "./objectset/index${importExt}";
|
|
656
|
-
export * from "./ObjectType${importExt}";
|
|
657
|
-
export * from "./OntologyObject${importExt}";
|
|
658
|
-
export * from "./Queries${importExt}";
|
|
659
|
-
export * from "./timeseries/index${importExt}";
|
|
660
|
-
export * from "./timestamp${importExt}";`));
|
|
661
|
-
const geoshapesDir = path16__namespace.join(baseTypesDir, "geoshapes");
|
|
662
|
-
await generateGeoshapesDir(geoshapesDir, fs2, importExt);
|
|
663
|
-
const timeseriesDir = path16__namespace.join(baseTypesDir, "timeseries");
|
|
664
|
-
await generateTimeSeriesDir(timeseriesDir, fs2, importExt);
|
|
665
|
-
const attachmentsDir = path16__namespace.join(baseTypesDir, "attachments");
|
|
666
|
-
await generateAttachmentsDir(attachmentsDir, fs2, importExt);
|
|
667
|
-
const objectSetDir = path16__namespace.join(baseTypesDir, "objectset");
|
|
668
|
-
await generateObjectSetDir(objectSetDir, fs2, importExt);
|
|
669
|
-
const sharedObjectCodeDir = path16__namespace.join(baseTypesDir, "sharedObjectCode");
|
|
670
|
-
await generateSharedObjectCodeDir(sharedObjectCodeDir, fs2, importExt);
|
|
671
|
-
await fs2.writeFile(path16__namespace.join(baseTypesDir, "ActionType.ts"), await formatTs(`import { OntologyObject } from "./OntologyObject${importExt}";
|
|
672
|
-
` + reexportConsts(["ActionExecutionMode", "ReturnEditsMode", "ActionValidationResult"]) + reexportTypes(["ActionExecutionOptions", "ValidationResponse", "BulkEdits"]) + reexportTypes(["CreatedObjectEdits", "ModifiedObjectEdits"], "<T extends OntologyObject>") + reexportTypes(["Edits"], "<TAddedObjects extends OntologyObject | void, TModifiedObjects extends OntologyObject | void>") + reexportTypes(["ActionResponse"], "<TEdits extends Edits<any, any> | undefined = undefined>", "<TEdits>") + reexportTypes(["ActionResponseFromOptions"], "<TOptions extends ActionExecutionOptions | undefined = undefined, TEdits extends Edits<any, any> | undefined = undefined>", "<TOptions, TEdits>")));
|
|
673
|
-
await fs2.writeFile(path16__namespace.join(baseTypesDir, "OntologyObject.ts"), await formatTs(reexportTypes(["OntologyObject"]) + reexportConsts(["isOntologyObject"])));
|
|
674
|
-
await fs2.writeFile(path16__namespace.join(baseTypesDir, "links.ts"), await formatTs(`import { OntologyObject } from "./OntologyObject${importExt}` + reexportTypes(["SingleLink", "MultiLink"], "<T extends OntologyObject = OntologyObject>")));
|
|
675
|
-
await fs2.writeFile(path16__namespace.join(baseTypesDir, "localDate.ts"), await formatTs(reexportConsts(["LocalDate"]) + reexportTypes(["LocalDate"])));
|
|
676
|
-
await fs2.writeFile(path16__namespace.join(baseTypesDir, "timestamp.ts"), await formatTs(reexportConsts(["Timestamp"]) + reexportTypes(["Timestamp"])));
|
|
677
|
-
await fs2.writeFile(path16__namespace.join(baseTypesDir, "Queries.ts"), await formatTs(`import { BucketValue, Range, Rangeable } from "../aggregations/index${importExt}";
|
|
678
|
-
` + reexportTypes(["QueryResponse"], "<T>") + reexportTypes(["BaseBucket"], "<K, V>") + reexportTypes(["NestedBucket"], "<TGroupKey, TSegmentKey, TValue extends BucketValue>") + reexportTypes(["TwoDimensionalAggregation"], "<TGroupKey extends QueryBucketKey, TValue extends BucketValue = number>") + reexportTypes(["ThreeDimensionalAggregation"], "<TGroupKey extends QueryBucketKey, TSegmentKey extends QueryBucketKey, TValue extends BucketValue = number>") + reexportTypes(["QueryBucketKey"])));
|
|
679
|
-
await fs2.writeFile(path16__namespace.join(baseTypesDir, "ObjectType.ts"), await formatTs(`import { OntologyObject } from "./OntologyObject${importExt}";` + reexportTypes(["BaseType", "StringType", "IntegerType", "DateType", "BooleanType", "ByteType", "DecimalType", "FloatType", "TimestampType", "ShortType", "LongType", "DoubleType", "GeoPointType", "GeoShapeType", "AttachmentType", "ObjectType", "StructField", "QueryBucketRangeableType", "QueryBucketKeyType", "QueryBucketValueType", "AllValueTypes", "OntologyType", "ObjectTypeProperties", "StructType"]) + reexportTypes(["TimeSeriesType", "ArrayType", "SetType"], "<T extends BaseType>") + reexportTypes(["Property"], "<TType extends OntologyType = OntologyType>") + reexportTypes(["BaseObjectType"], "<TOntologyObject extends OntologyObject = OntologyObject>") + reexportTypes(["ObjectSetType"], "<T extends ObjectType>") + reexportTypes(["RangeType"], "<T extends QueryBucketRangeableType>") + reexportTypes(["TwoDimensionalAggregationType"], "<TGroupKey extends QueryBucketKeyType, TValue extends QueryBucketValueType>") + reexportTypes(["ThreeDimensionalAggregationType"], "<TGroupKey extends QueryBucketKeyType, TSegmentKey extends QueryBucketKeyType, TValue extends QueryBucketValueType>")));
|
|
680
|
-
}
|
|
681
|
-
async function generateClientDir(runtimeDistDir, fs2, importExt = "") {
|
|
682
|
-
const pagingDir = path16__namespace.default.join(runtimeDistDir, "client");
|
|
683
|
-
await fs2.mkdir(pagingDir, {
|
|
684
|
-
recursive: true
|
|
685
|
-
});
|
|
686
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "index.ts"), await formatTs(`export * from "./clientOptions${importExt}";`));
|
|
687
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "clientOptions.ts"), await formatTs(`import {Auth} from "@osdk/legacy-client";` + reexportTypes(["FoundryClientOptions"], "<TAuth extends Auth = Auth>")));
|
|
688
|
-
}
|
|
689
|
-
async function generateFiltersDir(runtimeDistDir, fs2, importExt = "") {
|
|
690
|
-
const pagingDir = path16__namespace.default.join(runtimeDistDir, "filters");
|
|
691
|
-
await fs2.mkdir(pagingDir, {
|
|
692
|
-
recursive: true
|
|
693
|
-
});
|
|
694
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "index.ts"), await formatTs(`export * from "./ArrayFilter${importExt}";
|
|
695
|
-
export * from "./AttachmentFilter${importExt}";
|
|
696
|
-
export * from "./BooleanFilter${importExt}";
|
|
697
|
-
export * from "./DateTimeFilters${importExt}";
|
|
698
|
-
export * from "./Filters${importExt}";
|
|
699
|
-
export * from "./GeoPointFilter${importExt}";
|
|
700
|
-
export * from "./GeoShapeFilter${importExt}";
|
|
701
|
-
export * from "./NumericFilter${importExt}";
|
|
702
|
-
export * from "./Op${importExt}";
|
|
703
|
-
export * from "./OrderByOption${importExt}";
|
|
704
|
-
export * from "./StringFilter${importExt}";`));
|
|
705
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "ArrayFilter.ts"), await formatTs(`import { Attachment, GeoPoint, GeoShape, LocalDate, Timestamp } from "../baseTypes/index${importExt}";` + reexportConsts(["ArrayFilter"]) + reexportTypes(["ArrayFilter"], "<T extends string | number | Timestamp | LocalDate | boolean | GeoShape | GeoPoint | Attachment>")));
|
|
706
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "AttachmentFilter.ts"), await formatTs(reexportConsts(["AttachmentFilter"]) + reexportTypes(["AttachmentFilter"])));
|
|
707
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "BooleanFilter.ts"), await formatTs(reexportConsts(["BooleanFilter"]) + reexportTypes(["BooleanFilter"])));
|
|
708
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "GeoPointFilter.ts"), await formatTs(reexportConsts(["GeoPointFilter"]) + reexportTypes(["GeoPointFilter", "BoundingBox"])));
|
|
709
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "DateTimeFilters.ts"), await formatTs(reexportConsts(["TimestampFilter", "LocalDateFilter"]) + reexportTypes(["TimestampFilter", "LocalDateFilter"])));
|
|
710
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "GeoShapeFilter.ts"), await formatTs(reexportConsts(["GeoShapeFilter"]) + reexportTypes(["GeoShapeFilter"])));
|
|
711
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "NumericFilter.ts"), await formatTs(reexportConsts(["NumericFilter"]) + reexportTypes(["NumericFilter"])));
|
|
712
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "Op.ts"), await formatTs(reexportConsts(["Op"])));
|
|
713
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "OrderByOption.ts"), await formatTs(reexportConsts(["OrderByOption"]) + reexportTypes(["OrderByOption"])));
|
|
714
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "StringFilter.ts"), await formatTs(reexportConsts(["StringFilter"]) + reexportTypes(["StringFilter"])));
|
|
715
|
-
await fs2.writeFile(path16__namespace.default.join(pagingDir, "Filters.ts"), await formatTs(`import { OntologyObject } from "@osdk/legacy-client";` + reexportTypes(["ObjectTypeFilterFunction", "ObjectTypeOrderByFunction"], "<T extends OntologyObject>") + reexportTypes(["BoundingBoxFilter", "DistanceOf", "SearchClause", "LtWhereClause", "GtWhereClause", "LteWhereClause", "GteWhereClause", "EqWhereClause", "IsNullWhereClause", "ContainsWhereClause", "StartsWithWhereClause", "ContainsAllTermsInOrderWhereClause", "ContainsAnyTermWhereClause", "ContainsAllTermsWhereClause", "WithinDistanceOfWhereClause", "WithinBoundingBoxWhereClause", "IntersectsBoundingBoxWhereClause", "DoesNotIntersectBoundingBoxWhereClause", "WithinPolygonWhereClause", "IntersectsPolygonWhereClause", "DoesNotIntersectPolygonWhereClause", "AndWhereClause", "OrWhereClause", "NotWhereClause", "WhereClause", "OrderByClause"]) + reexportTypes(["FilterType"], "<T extends string | number>")));
|
|
716
|
-
}
|
|
717
|
-
async function generateErrors(fs2, ontologyProviderDir) {
|
|
718
|
-
await fs2.writeFile(path16__namespace.join(ontologyProviderDir, "Errors.ts"), await formatTs(reexportTypes(["PermissionDenied", "Unauthorized", "InvalidAggregationRangeValue", "MalformedPropertyFilters", "PropertiesNotFilterable", "ParametersNotFound", "ApplyActionFailed", "PropertyTypesSearchNotSupported", "InvalidParameterValue", "QueryTimeExceededLimit", "CompositePrimaryKeyNotSupported", "PropertyBaseTypeNotSupported", "PropertiesNotSearchable", "AttachmentNotFound", "ObjectTypeNotFound", "InvalidGroupId", "OntologySyncing", "ActionNotFound", "ParameterObjectSetRidNotFound", "LinkTypeNotFound", "InvalidRangeQuery", "ActionParameterObjectNotFound", "InvalidPropertyValue", "PropertiesNotSortable", "FunctionExecutionTimedOut", "InvalidFields", "ActionTypeNotFound", "ObjectTypeNotSynced", "OntologyEditsExceededLimit", "AggregationGroupCountExceededLimit", "InvalidContentType", "PropertiesNotFound", "FunctionInvalidInput", "InvalidSortOrder", "QueryDepthExceededLimit", "InvalidPropertyFiltersCombination", "ObjectsExceededLimit", "DuplicateOrderBy", "FunctionEncounteredUserFacingError", "InvalidUserId", "QueryNotFound", "InvalidAggregationRange", "ParameterObjectNotFound", "QueryMemoryExceededLimit", "InvalidContentLength", "OntologyNotFound", "ActionParameterObjectTypeNotFound", "UnknownParameter", "InvalidSortType", "PropertyFiltersNotSupported", "ActionValidationFailed", "MultipleGroupByOnFieldNotSupported", "LinkedObjectNotFound", "ActionEditedPropertiesNotFound", "InvalidPropertyFilterValue", "QueryEncounteredUserFacingError", "AttachmentSizeExceededLimit", "ObjectNotFound", "PropertyApiNameNotFound", "ParameterTypeNotSupported", "InvalidAggregationRangePropertyType", "MissingParameter"])));
|
|
719
|
-
}
|
|
720
|
-
async function generateOntologyMetadata(fs2, ontologyProviderDir) {
|
|
721
|
-
await fs2.writeFile(path16__namespace.join(ontologyProviderDir, "OntologyMetadata.ts"), await formatTs(reexportTypes(["OntologyMetadata"])));
|
|
722
|
-
}
|
|
723
|
-
async function generateResult(fs2, ontologyProviderDir) {
|
|
724
|
-
await fs2.writeFile(path16__namespace.join(ontologyProviderDir, "Result.ts"), await formatTs(`import {FoundryApiError} from "@osdk/legacy-client";
|
|
725
|
-
` + reexportTypes(["Ok", "Err"], "<T>") + reexportTypes(["Result"], "<V, E = FoundryApiError>", "<V,E>") + reexportConsts(["isOk", "isErr", "visitError"]) + reexportTypes(["ErrorVisitor"], "<E extends FoundryApiError, R>", "<E,R>") + reexportTypes(["ExtractKeysWithType"], "<T, K extends keyof T>", "<T,K>")));
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
// src/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateOntologyProviderDir.ts
|
|
729
|
-
async function generateOntologyProviderDir(fs2, runtimeDistDir, importExt = "") {
|
|
730
|
-
const ontologyProviderDir = path16__namespace.join(runtimeDistDir, "ontologyProvider");
|
|
731
|
-
await fs2.mkdir(ontologyProviderDir, {
|
|
732
|
-
recursive: true
|
|
733
|
-
});
|
|
734
|
-
await generateErrors(fs2, ontologyProviderDir);
|
|
735
|
-
await generateOntologyMetadata(fs2, ontologyProviderDir);
|
|
736
|
-
await generateResult(fs2, ontologyProviderDir);
|
|
737
|
-
await fs2.writeFile(path16__namespace.join(ontologyProviderDir, "index.ts"), await formatTs(`
|
|
738
|
-
${""}
|
|
739
|
-
export * from "./Errors${importExt}";
|
|
740
|
-
export * from "./OntologyMetadata${importExt}";
|
|
741
|
-
${""}
|
|
742
|
-
${""}
|
|
743
|
-
// export * from "./Result${importExt}";
|
|
744
|
-
`));
|
|
745
|
-
}
|
|
746
|
-
async function generatePagingDir(runtimeDistDir, fs2, importExt = "") {
|
|
747
|
-
const pagingDir = path16__namespace.join(runtimeDistDir, "paging");
|
|
748
|
-
await fs2.mkdir(pagingDir, {
|
|
749
|
-
recursive: true
|
|
750
|
-
});
|
|
751
|
-
await fs2.writeFile(path16__namespace.join(pagingDir, "index.ts"), await formatTs(`export * from "./Page${importExt}";`));
|
|
752
|
-
await fs2.writeFile(path16__namespace.join(pagingDir, "Page.ts"), await formatTs(reexportTypes(["Page"], "<T>")));
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
// src/v1.1/backcompat/generateOntologyRuntimeDistDir.ts
|
|
756
|
-
async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
|
|
757
|
-
const runtimeDistDir = path16__namespace.join(outDir, "internal", "@foundry", "ontology-runtime", "dist");
|
|
758
|
-
await fs2.mkdir(runtimeDistDir, {
|
|
759
|
-
recursive: true
|
|
760
|
-
});
|
|
761
|
-
await generateOntologyProviderDir(fs2, runtimeDistDir, importExt);
|
|
762
|
-
await generateAggregationsDir(fs2, runtimeDistDir, importExt);
|
|
763
|
-
await generatePagingDir(runtimeDistDir, fs2, importExt);
|
|
764
|
-
await generateBaseTypesDir(runtimeDistDir, fs2, importExt);
|
|
765
|
-
await generateClientDir(runtimeDistDir, fs2, importExt);
|
|
766
|
-
await generateFiltersDir(runtimeDistDir, fs2, importExt);
|
|
767
|
-
await fs2.writeFile(path16__namespace.join(runtimeDistDir, "index.ts"), await formatTs(`
|
|
768
|
-
export * from "./aggregations/index${importExt}";
|
|
769
|
-
export * from "./baseTypes/index${importExt}";
|
|
770
|
-
${""}
|
|
771
|
-
// export * from "./filters/index${importExt}";
|
|
772
|
-
${""}
|
|
773
|
-
${""}
|
|
774
|
-
|
|
775
|
-
export * from "./ontologyProvider/index${importExt}";
|
|
776
|
-
export * from "./paging/index${importExt}";
|
|
777
|
-
`));
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
// src/v1.1/generateBackCompatDeprecatedExports.ts
|
|
781
|
-
async function generateBackCompatDeprecatedExports(fs2, outDir, importExt = "") {
|
|
782
|
-
await generateOntologyRuntimeDistDir(outDir, fs2, importExt);
|
|
783
|
-
await generateOAuthClientDistDir(outDir, fs2, importExt);
|
|
784
|
-
}
|
|
785
|
-
async function generateBatchActions(ontology, fs2, outDir, importExt = "") {
|
|
786
|
-
const importedObjects = /* @__PURE__ */ new Set();
|
|
787
|
-
let actionSignatures = [];
|
|
788
|
-
for (const action of Object.values(ontology.actionTypes)) {
|
|
789
|
-
const entries = Object.entries(action.parameters);
|
|
790
|
-
const modifiedEntityTypes = getModifiedEntityTypes(action);
|
|
791
|
-
const addedObjects = Array.from(modifiedEntityTypes.addedObjects);
|
|
792
|
-
const modifiedObjects = Array.from(modifiedEntityTypes.modifiedObjects);
|
|
793
|
-
addedObjects.forEach(importedObjects.add, importedObjects);
|
|
794
|
-
modifiedObjects.forEach(importedObjects.add, importedObjects);
|
|
795
|
-
let jsDocBlock = ["/**"];
|
|
796
|
-
if (action.description) {
|
|
797
|
-
jsDocBlock.push(`* ${action.description}`);
|
|
798
|
-
}
|
|
799
|
-
let parameterBlock = "";
|
|
800
|
-
if (entries.length > 0) {
|
|
801
|
-
parameterBlock = `params: {
|
|
802
|
-
`;
|
|
803
|
-
for (const [parameterName, parameterData] of entries) {
|
|
804
|
-
parameterBlock += `"${parameterName}"`;
|
|
805
|
-
parameterBlock += parameterData.required ? ": " : "?: ";
|
|
806
|
-
const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
|
|
807
|
-
parameterBlock += `${typeScriptType};
|
|
808
|
-
`;
|
|
809
|
-
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
810
|
-
}
|
|
811
|
-
parameterBlock += "}[], ";
|
|
397
|
+
for (const key of modifiedObjects) {
|
|
398
|
+
if (entities[key]) {
|
|
399
|
+
entities[key].modified = true;
|
|
812
400
|
} else {
|
|
813
|
-
|
|
401
|
+
entities[key] = {
|
|
402
|
+
created: false,
|
|
403
|
+
modified: true
|
|
404
|
+
};
|
|
814
405
|
}
|
|
815
|
-
jsDocBlock.push(`*/`);
|
|
816
|
-
actionSignatures.push(`
|
|
817
|
-
${jsDocBlock.join("\n")}
|
|
818
|
-
${action.apiName}<O extends BatchActionExecutionOptions>(${parameterBlock}options?: O):
|
|
819
|
-
Promise<Result<BatchActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;
|
|
820
|
-
`);
|
|
821
406
|
}
|
|
822
|
-
|
|
823
|
-
recursive: true
|
|
824
|
-
});
|
|
825
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, "BatchActions.ts"), await formatTs(`
|
|
826
|
-
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, BatchActionExecutionOptions, ActionError, Result, ActionResponseFromOptions, BatchActionResponseFromOptions } from "@osdk/legacy-client";
|
|
827
|
-
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
828
|
-
export interface BatchActions {
|
|
829
|
-
${actionSignatures.join("\n")}
|
|
830
|
-
}
|
|
831
|
-
`));
|
|
407
|
+
return entities;
|
|
832
408
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
`;
|
|
851
|
-
for (const [parameterName, parameterData] of entries) {
|
|
852
|
-
parameterBlock += `"${parameterName}"`;
|
|
853
|
-
parameterBlock += parameterData.required ? ": " : "?: ";
|
|
854
|
-
const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
|
|
855
|
-
parameterBlock += `${typeScriptType};
|
|
856
|
-
`;
|
|
857
|
-
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
409
|
+
|
|
410
|
+
// src/util/stringify.ts
|
|
411
|
+
var defaultCustomizer = (value, defaultValueFormatter, key, defaultKeyFormatter) => {
|
|
412
|
+
return [defaultKeyFormatter(key), defaultValueFormatter(value)];
|
|
413
|
+
};
|
|
414
|
+
function stringify(obj, customizer = {}, separator = ",\n") {
|
|
415
|
+
const defaultKeyFormatter = (key) => `${JSON.stringify(key)}`;
|
|
416
|
+
const entries = [];
|
|
417
|
+
const sortedKeys = Object.keys(obj).sort((a, b) => a.localeCompare(b));
|
|
418
|
+
for (const key of sortedKeys) {
|
|
419
|
+
const value = obj[key];
|
|
420
|
+
const res = (customizer[key] ?? customizer["*"] ?? defaultCustomizer)(value, (value2) => JSON.stringify(value2, null, 2), key, defaultKeyFormatter);
|
|
421
|
+
if (res) {
|
|
422
|
+
if (typeof res === "string") {
|
|
423
|
+
entries.push(`${defaultKeyFormatter(key)}: ${res}`);
|
|
424
|
+
} else {
|
|
425
|
+
entries.push(`${res[0]}: ${res[1]}`);
|
|
858
426
|
}
|
|
859
|
-
parameterBlock += "}[], ";
|
|
860
|
-
} else {
|
|
861
|
-
parameterBlock = `params: Record<string,never>[], `;
|
|
862
427
|
}
|
|
863
|
-
jsDocBlock.push(`*/`);
|
|
864
|
-
actionSignatures.push(`
|
|
865
|
-
${jsDocBlock.join("\n")}
|
|
866
|
-
${action.apiName}<O extends BulkActionExecutionOptions>(${parameterBlock}options?: O):
|
|
867
|
-
Promise<Result<BulkActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;
|
|
868
|
-
`);
|
|
869
428
|
}
|
|
870
|
-
|
|
871
|
-
recursive: true
|
|
872
|
-
});
|
|
873
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, "BulkActions.ts"), await formatTs(`
|
|
874
|
-
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, BulkActionExecutionOptions, ActionError, Result, ActionResponseFromOptions, BulkActionResponseFromOptions } from "@osdk/legacy-client";
|
|
875
|
-
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
876
|
-
export interface BulkActions {
|
|
877
|
-
${actionSignatures.join("\n")}
|
|
878
|
-
}
|
|
879
|
-
`));
|
|
880
|
-
}
|
|
881
|
-
async function generateFoundryClientFile(fs2, outDir, importExt = "") {
|
|
882
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, "FoundryClient.ts"), await formatTs(`
|
|
883
|
-
import { BaseFoundryClient } from "@osdk/legacy-client";
|
|
884
|
-
import type { Auth, FoundryClientOptions } from "@osdk/legacy-client";
|
|
885
|
-
import { Ontology } from "./Ontology${importExt}";
|
|
886
|
-
|
|
887
|
-
export class FoundryClient<TAuth extends Auth = Auth> extends BaseFoundryClient<typeof Ontology, TAuth> {
|
|
888
|
-
constructor(options: FoundryClientOptions<TAuth>) {
|
|
889
|
-
super(options, Ontology);
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
get ontology(): Ontology {
|
|
893
|
-
return super.ontology;
|
|
894
|
-
}
|
|
895
|
-
}`));
|
|
896
|
-
}
|
|
897
|
-
async function generateIndexFile(fs2, outDir, importExt) {
|
|
898
|
-
await fs2.mkdir(outDir, {
|
|
899
|
-
recursive: true
|
|
900
|
-
});
|
|
901
|
-
await fs2.writeFile(path16__namespace.join(outDir, "index.ts"), await formatTs(`
|
|
902
|
-
export * from "@osdk/legacy-client";
|
|
903
|
-
export type { Ontology } from "./Ontology${importExt}";
|
|
904
|
-
export { FoundryClient } from "./FoundryClient${importExt}";
|
|
905
|
-
`));
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
// src/util/commaSeparatedIdentifiers.ts
|
|
909
|
-
function commaSeparatedIdentifiers(identifiers, alternateNames) {
|
|
910
|
-
return identifiers.map((i) => {
|
|
911
|
-
const alt = alternateNames?.get(i);
|
|
912
|
-
if (alt) {
|
|
913
|
-
return `${i}: ${alt}`;
|
|
914
|
-
}
|
|
915
|
-
return i;
|
|
916
|
-
}).join(",");
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
// src/util/commaSeparatedTypeIdentifiers.ts
|
|
920
|
-
function commaSeparatedTypeIdentifiers(identifiers, altNames) {
|
|
921
|
-
return identifiers.map((i) => `${i}: typeof ${altNames?.get(i) ?? i}`).join(",");
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
// src/v1.1/generateMetadataFile.ts
|
|
925
|
-
async function generateMetadataFile(ontology, userAgent, fs2, outDir, importExt = "") {
|
|
926
|
-
const objectNames = Object.keys(ontology.objectTypes);
|
|
927
|
-
const actionNames = Object.keys(ontology.actionTypes);
|
|
928
|
-
const queryNames = Object.keys(ontology.queryTypes);
|
|
929
|
-
const actionAltNames = /* @__PURE__ */ new Map();
|
|
930
|
-
const queryAltNames = /* @__PURE__ */ new Map();
|
|
931
|
-
const seenIdentifiers = new Set(objectNames);
|
|
932
|
-
for (const actionName of actionNames) {
|
|
933
|
-
if (seenIdentifiers.has(actionName)) {
|
|
934
|
-
actionAltNames.set(actionName, `${actionName}Action`);
|
|
935
|
-
} else {
|
|
936
|
-
seenIdentifiers.add(actionName);
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
for (const queryName of queryNames) {
|
|
940
|
-
if (seenIdentifiers.has(queryName)) {
|
|
941
|
-
queryAltNames.set(queryName, `${queryName}Query`);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
const getImportClause = (name, altNames) => {
|
|
945
|
-
const alt = altNames.get(name);
|
|
946
|
-
if (alt) {
|
|
947
|
-
return `${name} as ${alt}`;
|
|
948
|
-
} else {
|
|
949
|
-
return name;
|
|
950
|
-
}
|
|
951
|
-
};
|
|
952
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, "Ontology.ts"), await formatTs(`
|
|
953
|
-
import type { OntologyDefinition } from "@osdk/api";
|
|
954
|
-
import type { Ontology as ClientOntology } from "@osdk/legacy-client";
|
|
955
|
-
import type { Objects } from "./ontology/objects/Objects${importExt}";
|
|
956
|
-
import type { Actions } from "./ontology/actions/Actions${importExt}";
|
|
957
|
-
import type { Queries } from "./ontology/queries/Queries${importExt}";
|
|
958
|
-
import type { BatchActions } from "./ontology/actions/BatchActions${importExt}";
|
|
959
|
-
import type { BulkActions } from "./ontology/actions/BulkActions${importExt}";
|
|
960
|
-
${objectNames.map((name) => `import {${name}} from "./ontology/objects/${name}${importExt}";`).join("\n")}
|
|
961
|
-
${actionNames.map((name) => `import {${getImportClause(name, actionAltNames)}} from "./ontology/actions/${name}${importExt}";`).join("\n")}
|
|
962
|
-
${queryNames.map((name) => `import {${getImportClause(name, queryAltNames)}} from "./ontology/queries/${name}${importExt}";`).join("\n")}
|
|
963
|
-
|
|
964
|
-
export const Ontology : {
|
|
965
|
-
metadata: {
|
|
966
|
-
ontologyRid: "${ontology.ontology.rid}",
|
|
967
|
-
ontologyApiName: "${ontology.ontology.apiName}",
|
|
968
|
-
userAgent: "${userAgent}",
|
|
969
|
-
},
|
|
970
|
-
objects: {
|
|
971
|
-
${commaSeparatedTypeIdentifiers(objectNames)}
|
|
972
|
-
},
|
|
973
|
-
actions: {
|
|
974
|
-
${commaSeparatedTypeIdentifiers(actionNames, actionAltNames)}
|
|
975
|
-
},
|
|
976
|
-
queries: {
|
|
977
|
-
${commaSeparatedTypeIdentifiers(queryNames, queryAltNames)}
|
|
978
|
-
},
|
|
979
|
-
} = {
|
|
980
|
-
metadata: {
|
|
981
|
-
ontologyRid: "${ontology.ontology.rid}" as const,
|
|
982
|
-
ontologyApiName: "${ontology.ontology.apiName}" as const,
|
|
983
|
-
userAgent: "${userAgent}" as const,
|
|
984
|
-
},
|
|
985
|
-
objects: {
|
|
986
|
-
${commaSeparatedIdentifiers(objectNames)}
|
|
987
|
-
},
|
|
988
|
-
actions: {
|
|
989
|
-
${commaSeparatedIdentifiers(actionNames, actionAltNames)}
|
|
990
|
-
},
|
|
991
|
-
queries: {
|
|
992
|
-
${commaSeparatedIdentifiers(queryNames, queryAltNames)}
|
|
993
|
-
}
|
|
994
|
-
} satisfies OntologyDefinition<
|
|
995
|
-
${stringUnionFrom(objectNames)},
|
|
996
|
-
${stringUnionFrom(Object.values(ontology.actionTypes).map((actionType) => actionType.apiName))},
|
|
997
|
-
${stringUnionFrom(Object.values(ontology.queryTypes).map((queryType) => queryType.apiName))}>;
|
|
998
|
-
|
|
999
|
-
export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
1000
|
-
objects: Objects;
|
|
1001
|
-
actions: Actions;
|
|
1002
|
-
/** @deprecated use batchActions */
|
|
1003
|
-
bulkActions: BulkActions;
|
|
1004
|
-
batchActions: BatchActions;
|
|
1005
|
-
queries: Queries;
|
|
1006
|
-
}`));
|
|
1007
|
-
}
|
|
1008
|
-
function stringUnionFrom(values) {
|
|
1009
|
-
if (values.length === 0) {
|
|
1010
|
-
return "never";
|
|
1011
|
-
}
|
|
1012
|
-
return values.map((n) => `"${n}"`).join("|");
|
|
1013
|
-
}
|
|
1014
|
-
async function generateObjectsInterfaceFile(ontology, fs2, outDir, importExt = "") {
|
|
1015
|
-
await fs2.mkdir(outDir, {
|
|
1016
|
-
recursive: true
|
|
1017
|
-
});
|
|
1018
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, "Objects.ts"), await formatTs(`
|
|
1019
|
-
import { BaseObjectSet } from "@osdk/legacy-client";
|
|
1020
|
-
${Array.from(Object.keys(ontology.objectTypes)).map((importedObject) => `import type { ${importedObject} } from "./${importedObject}${importExt}";`).join("\n")}
|
|
1021
|
-
|
|
1022
|
-
export interface Objects {
|
|
1023
|
-
${Object.keys(ontology.objectTypes).map((apiName) => `${apiName} : BaseObjectSet<${apiName}>;`).join("\n")}
|
|
1024
|
-
}
|
|
1025
|
-
;`));
|
|
1026
|
-
}
|
|
1027
|
-
async function generateObjectsInterfaceSupportFiles(ontology, fs2, outDir, importExt = "") {
|
|
1028
|
-
await fs2.mkdir(outDir, {
|
|
1029
|
-
recursive: true
|
|
1030
|
-
});
|
|
1031
|
-
for (const {
|
|
1032
|
-
objectType: {
|
|
1033
|
-
apiName
|
|
1034
|
-
}
|
|
1035
|
-
} of Object.values(ontology.objectTypes)) {
|
|
1036
|
-
const fileName = path16.join(outDir, `${apiName}.ts`);
|
|
1037
|
-
const localApiName = `OG_${apiName}`;
|
|
1038
|
-
const contents = [];
|
|
1039
|
-
contents.push(`import { ObjectSetAggregateArg, ObjectSetFilterArg, ObjectSetGroupByArg, ObjectSetMultipleAggregateArg, ObjectSetOrderByArg } from "@osdk/legacy-client";`);
|
|
1040
|
-
contents.push(`import { ${apiName} as ${localApiName} } from "../${apiName}${importExt}";`);
|
|
1041
|
-
contents.push("");
|
|
1042
|
-
contents.push(`/** @deprecated Use ${apiName} from ontology/objects instead */`, `export type ${apiName} = ${localApiName};`);
|
|
1043
|
-
contents.push(`/** @deprecated Use ObjectSetFilterArg<${apiName}> instead */`, `export type ${apiName}Filter = ObjectSetFilterArg<${localApiName}>;`);
|
|
1044
|
-
contents.push(`/** @deprecated Use ObjectSetOrderByArg<${apiName}> instead */`, `export type ${apiName}OrderBy = ObjectSetOrderByArg<${localApiName}>;`);
|
|
1045
|
-
contents.push(`/** @deprecated Use ObjectSetGroupByArg<${apiName}> instead */`, `export type ${apiName}GroupByProperties = ObjectSetGroupByArg<${localApiName}>;`);
|
|
1046
|
-
contents.push(`
|
|
1047
|
-
/**
|
|
1048
|
-
* Aggregation properties for ${apiName}
|
|
1049
|
-
* @deprecated Use ObjectSetAggregateArg<${apiName}> instead
|
|
1050
|
-
*/`, `export type ${apiName}AggregationProperties = ObjectSetAggregateArg<${localApiName}>;`);
|
|
1051
|
-
contents.push(`
|
|
1052
|
-
/**
|
|
1053
|
-
* Multiple aggregation properties for ${apiName}.
|
|
1054
|
-
* @deprecated Use ObjectSetMultipleAggregateArg<${apiName}> instead
|
|
1055
|
-
*/`, `export type ${apiName}MultipleAggregationProperties = ObjectSetMultipleAggregateArg<${localApiName}>;`);
|
|
1056
|
-
await fs2.writeFile(fileName, contents.join("\n"));
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
async function generateOntologyIndexFile(fs2, outDir) {
|
|
1060
|
-
await fs2.mkdir(outDir, {
|
|
1061
|
-
recursive: true
|
|
1062
|
-
});
|
|
1063
|
-
await fs2.writeFile(path16__namespace.join(outDir, "index.ts"), await formatTs(`
|
|
1064
|
-
export type { ObjectSet } from "@osdk/legacy-client";
|
|
1065
|
-
`));
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
// src/shared/getObjectImports.ts
|
|
1069
|
-
function getObjectImports(objects, curApiName, currentFilePath, v2) {
|
|
1070
|
-
return Array.from(objects).filter((obj) => obj.fullApiName !== curApiName).map((obj) => {
|
|
1071
|
-
return `import type { ${obj.getDefinitionIdentifier(v2)} as ${obj.getImportedDefinitionIdentifier(v2)} } from "${obj.getImportPathRelTo("./" + currentFilePath)}";`;
|
|
1072
|
-
}).join("\n");
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
// src/shared/wireActionTypeV2ToSdkActionDefinition.ts
|
|
1076
|
-
function wireActionTypeV2ToSdkActionDefinition(input) {
|
|
1077
|
-
const modifiedEntityTypes = getModifiedEntityTypes(input);
|
|
1078
|
-
return {
|
|
1079
|
-
type: "action",
|
|
1080
|
-
apiName: input.apiName,
|
|
1081
|
-
parameters: Object.fromEntries(Object.entries(input.parameters).map(([key, value]) => [key, wireActionParameterV2ToSdkParameterDefinition(value)])),
|
|
1082
|
-
displayName: input.displayName,
|
|
1083
|
-
description: input.description,
|
|
1084
|
-
modifiedEntities: createModifiedEntities(modifiedEntityTypes.addedObjects, modifiedEntityTypes.modifiedObjects)
|
|
1085
|
-
};
|
|
1086
|
-
}
|
|
1087
|
-
function wireActionParameterV2ToSdkParameterDefinition(value) {
|
|
1088
|
-
return {
|
|
1089
|
-
multiplicity: value.dataType.type === "array",
|
|
1090
|
-
type: actionPropertyToSdkPropertyDefinition(value.dataType.type === "array" ? value.dataType.subType : value.dataType),
|
|
1091
|
-
nullable: !value.required,
|
|
1092
|
-
description: value.description
|
|
1093
|
-
};
|
|
1094
|
-
}
|
|
1095
|
-
function actionPropertyToSdkPropertyDefinition(parameterType) {
|
|
1096
|
-
switch (parameterType.type) {
|
|
1097
|
-
case "string":
|
|
1098
|
-
case "boolean":
|
|
1099
|
-
case "attachment":
|
|
1100
|
-
case "double":
|
|
1101
|
-
case "integer":
|
|
1102
|
-
case "long":
|
|
1103
|
-
case "timestamp":
|
|
1104
|
-
case "marking":
|
|
1105
|
-
return parameterType.type;
|
|
1106
|
-
case "date":
|
|
1107
|
-
return "datetime";
|
|
1108
|
-
case "objectSet":
|
|
1109
|
-
return {
|
|
1110
|
-
type: "objectSet",
|
|
1111
|
-
objectSet: parameterType.objectTypeApiName
|
|
1112
|
-
};
|
|
1113
|
-
case "object":
|
|
1114
|
-
return {
|
|
1115
|
-
type: "object",
|
|
1116
|
-
object: parameterType.objectTypeApiName
|
|
1117
|
-
};
|
|
1118
|
-
case "array":
|
|
1119
|
-
return actionPropertyToSdkPropertyDefinition(parameterType.subType);
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
function createModifiedEntities(addedObjects, modifiedObjects) {
|
|
1123
|
-
let entities = {};
|
|
1124
|
-
for (const key of addedObjects) {
|
|
1125
|
-
entities[key] = {
|
|
1126
|
-
created: true,
|
|
1127
|
-
modified: false
|
|
1128
|
-
};
|
|
1129
|
-
}
|
|
1130
|
-
for (const key of modifiedObjects) {
|
|
1131
|
-
if (entities[key]) {
|
|
1132
|
-
entities[key].modified = true;
|
|
1133
|
-
} else {
|
|
1134
|
-
entities[key] = {
|
|
1135
|
-
created: false,
|
|
1136
|
-
modified: true
|
|
1137
|
-
};
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
return entities;
|
|
429
|
+
return entries.join(separator);
|
|
1141
430
|
}
|
|
1142
431
|
|
|
1143
432
|
// src/util/stringUnionFrom.ts
|
|
1144
|
-
function
|
|
1145
|
-
if (values.length === 0) {
|
|
1146
|
-
return "never";
|
|
1147
|
-
} else {
|
|
1148
|
-
return values.map((v) => `"${v}"`).join("|");
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
// src/v1.1/generatePerActionDataFilesV1.ts
|
|
1153
|
-
async function generatePerActionDataFilesV1({
|
|
1154
|
-
sanitizedOntology: ontology,
|
|
1155
|
-
fs: fs2,
|
|
1156
|
-
outDir: rootOutDir,
|
|
1157
|
-
importExt = "",
|
|
1158
|
-
ontology: enhancedOntology
|
|
1159
|
-
}) {
|
|
1160
|
-
const outDir = path16__namespace.default.join(rootOutDir, "ontology", "actions");
|
|
1161
|
-
await fs2.mkdir(outDir, {
|
|
1162
|
-
recursive: true
|
|
1163
|
-
});
|
|
1164
|
-
await Promise.all(Object.values(enhancedOntology.actionTypes).map(async (action) => {
|
|
1165
|
-
const currentFilePath = `${path16__namespace.default.join("ontology", "actions", `${action.shortApiName}.ts`)}`;
|
|
1166
|
-
const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.og);
|
|
1167
|
-
const uniqueApiNames = new Set(uniqueApiNamesArray);
|
|
1168
|
-
const uniqueApiNamesString = stringUnionFrom2([...uniqueApiNames]);
|
|
1169
|
-
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action.og));
|
|
1170
|
-
function createV1Object() {
|
|
1171
|
-
return ` export const ${action.shortApiName} = ${JSON.stringify(fullActionDef, null, 2)} satisfies ActionDefinition<"${action.shortApiName}", ${uniqueApiNamesString}>;`;
|
|
1172
|
-
}
|
|
1173
|
-
const referencedObjectDefs = /* @__PURE__ */ new Set();
|
|
1174
|
-
for (const p of Object.values(action.parameters)) {
|
|
1175
|
-
if (p.dataType.type === "object" || p.dataType.type === "objectSet") {
|
|
1176
|
-
if (p.dataType.objectApiName) {
|
|
1177
|
-
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.objectApiName));
|
|
1178
|
-
}
|
|
1179
|
-
if (p.dataType.objectTypeApiName) {
|
|
1180
|
-
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.objectTypeApiName));
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
if (p.dataType.type === "array" && (p.dataType.subType.type === "object" || p.dataType.subType.type === "objectSet")) {
|
|
1184
|
-
if (p.dataType.subType.objectApiName) {
|
|
1185
|
-
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.subType.objectApiName));
|
|
1186
|
-
}
|
|
1187
|
-
if (p.dataType.subType.objectTypeApiName) {
|
|
1188
|
-
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.subType.objectTypeApiName));
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
const imports = getObjectImports(referencedObjectDefs, void 0, currentFilePath, false);
|
|
1193
|
-
await fs2.writeFile(path16__namespace.default.join(rootOutDir, currentFilePath), await formatTs(`
|
|
1194
|
-
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound} from "@osdk/api";
|
|
1195
|
-
import type { ApplyActionOptions, ApplyBatchActionOptions, ActionReturnTypeForOptions, ActionParam } from '@osdk/client.api';
|
|
1196
|
-
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
1197
|
-
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1198
|
-
${imports}
|
|
1199
|
-
|
|
1200
|
-
${createV1Object()}
|
|
1201
|
-
`));
|
|
1202
|
-
}));
|
|
1203
|
-
const indexFileRelPath = path16__namespace.default.join("ontology", "actions", `index.ts`);
|
|
1204
|
-
await fs2.writeFile(path16__namespace.default.join(rootOutDir, indexFileRelPath), await formatTs(`
|
|
1205
|
-
${Object.values(enhancedOntology.actionTypes).map((action) => {
|
|
1206
|
-
const exportConstLine = `export {${action.shortApiName} } from "${action.getImportPathRelTo(indexFileRelPath)}";`;
|
|
1207
|
-
`export type { ${action.paramsIdentifier} } from "${action.getImportPathRelTo(indexFileRelPath)}";`;
|
|
1208
|
-
return exportConstLine;
|
|
1209
|
-
}).join("\n")}
|
|
1210
|
-
${Object.keys(ontology.actionTypes).length === 0 ? "export {};" : ""}
|
|
1211
|
-
`));
|
|
1212
|
-
}
|
|
1213
|
-
function extractReferencedObjectsFromAction(actionType) {
|
|
1214
|
-
const referencedObjectsInParameters = Object.values(actionType.parameters).flatMap(({
|
|
1215
|
-
dataType
|
|
1216
|
-
}) => {
|
|
1217
|
-
const objectTypeReference = extractReferencedObjectsFromActionParameter(dataType);
|
|
1218
|
-
return objectTypeReference ? [objectTypeReference] : [];
|
|
1219
|
-
});
|
|
1220
|
-
const referenceObjectsInEdits = actionType.operations.flatMap((value) => {
|
|
1221
|
-
switch (value.type) {
|
|
1222
|
-
case "createObject":
|
|
1223
|
-
return [value.objectTypeApiName];
|
|
1224
|
-
case "modifyObject":
|
|
1225
|
-
return [value.objectTypeApiName];
|
|
1226
|
-
case "deleteObject":
|
|
1227
|
-
case "createLink":
|
|
1228
|
-
case "deleteLink":
|
|
1229
|
-
return [];
|
|
1230
|
-
}
|
|
1231
|
-
});
|
|
1232
|
-
return [...referenceObjectsInEdits, ...referencedObjectsInParameters];
|
|
1233
|
-
}
|
|
1234
|
-
function extractReferencedObjectsFromActionParameter(actionParameter) {
|
|
1235
|
-
switch (actionParameter.type) {
|
|
1236
|
-
case "objectSet":
|
|
1237
|
-
case "object":
|
|
1238
|
-
return actionParameter.objectTypeApiName;
|
|
1239
|
-
case "array":
|
|
1240
|
-
return extractReferencedObjectsFromActionParameter(actionParameter.subType);
|
|
1241
|
-
case "string":
|
|
1242
|
-
case "boolean":
|
|
1243
|
-
case "attachment":
|
|
1244
|
-
case "date":
|
|
1245
|
-
case "double":
|
|
1246
|
-
case "integer":
|
|
1247
|
-
case "long":
|
|
1248
|
-
case "timestamp":
|
|
1249
|
-
return void 0;
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
// src/util/stringify.ts
|
|
1254
|
-
var defaultCustomizer = (value, defaultValueFormatter, key, defaultKeyFormatter) => {
|
|
1255
|
-
return [defaultKeyFormatter(key), defaultValueFormatter(value)];
|
|
1256
|
-
};
|
|
1257
|
-
function stringify(obj, customizer = {}, separator = ",\n") {
|
|
1258
|
-
const defaultKeyFormatter = (key) => `${JSON.stringify(key)}`;
|
|
1259
|
-
const entries = [];
|
|
1260
|
-
const sortedKeys = Object.keys(obj).sort((a, b) => a.localeCompare(b));
|
|
1261
|
-
for (const key of sortedKeys) {
|
|
1262
|
-
const value = obj[key];
|
|
1263
|
-
const res = (customizer[key] ?? customizer["*"] ?? defaultCustomizer)(value, (value2) => JSON.stringify(value2, null, 2), key, defaultKeyFormatter);
|
|
1264
|
-
if (res) {
|
|
1265
|
-
if (typeof res === "string") {
|
|
1266
|
-
entries.push(`${defaultKeyFormatter(key)}: ${res}`);
|
|
1267
|
-
} else {
|
|
1268
|
-
entries.push(`${res[0]}: ${res[1]}`);
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
return entries.join(separator);
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
// src/v1.1/wireObjectTypeV2ToSdkObjectConstV1.ts
|
|
1276
|
-
function wireObjectTypeV2ToSdkObjectConstV1(wireObject, {
|
|
1277
|
-
ontology
|
|
1278
|
-
}, currentFilePath) {
|
|
1279
|
-
const object = ontology.requireObjectType(wireObject.objectType.apiName, true);
|
|
1280
|
-
const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map((a) => ontology.requireObjectType(a.objectTypeApiName, false)));
|
|
1281
|
-
const definition = deleteUndefineds(generatorConverters.wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object.og, false));
|
|
1282
|
-
const objectDefIdentifier = object.getDefinitionIdentifier(false);
|
|
1283
|
-
function getV1Types() {
|
|
1284
|
-
return `
|
|
1285
|
-
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.fullApiName}", ${object.uniqueImportName}> {
|
|
1286
|
-
${stringify(definition, {
|
|
1287
|
-
osdkMetadata: () => void 0,
|
|
1288
|
-
// not used in v1
|
|
1289
|
-
links: (_value) => `{
|
|
1290
|
-
${stringify(definition.links, {
|
|
1291
|
-
"*": (definition2) => `ObjectTypeLinkDefinition<${ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(false)}, ${definition2.multiplicity}>`
|
|
1292
|
-
})}
|
|
1293
|
-
}`
|
|
1294
|
-
})}
|
|
1295
|
-
}
|
|
1296
|
-
`;
|
|
1297
|
-
}
|
|
1298
|
-
const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, false);
|
|
1299
|
-
return `${imports}${getV1Types()}
|
|
1300
|
-
|
|
1301
|
-
export const ${object.shortApiName}: ${objectDefIdentifier} = {
|
|
1302
|
-
${stringify(definition, {
|
|
1303
|
-
osdkMetadata: (value) => void 0
|
|
1304
|
-
})}
|
|
1305
|
-
|
|
1306
|
-
};`;
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
// src/util/reservedKeywords.ts
|
|
1310
|
-
var reservedKeywords = /* @__PURE__ */ new Set(["break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", "enum", "export", "extends", "false", "finally", "for", "function", "if", "import", "in", "instanceof", "new", "null", "return", "super", "switch", "this", "throw", "true", "try", "typeof", "var", "void", "while", "with", "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"]);
|
|
1311
|
-
function isReservedKeyword(name) {
|
|
1312
|
-
return reservedKeywords.has(name);
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
// src/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.ts
|
|
1316
|
-
function wireObjectTypeV2ToObjectInterfaceStringV1(objectTypeWithLinks, importExt = "") {
|
|
1317
|
-
const uniqueLinkTargets = new Set(objectTypeWithLinks.linkTypes.map((a) => a.objectTypeApiName).filter((a) => a !== objectTypeWithLinks.objectType.apiName));
|
|
1318
|
-
return `import type { OntologyObject, LocalDate, Timestamp, GeoShape, GeoPoint, Attachment, TimeSeries, MultiLink, SingleLink, StringLong } from "@osdk/legacy-client";
|
|
1319
|
-
${Array.from(uniqueLinkTargets).map((linkTarget) => `import type { ${linkTarget} } from "./${linkTarget}${importExt}";`).join("\n")}
|
|
1320
|
-
|
|
1321
|
-
${getDescriptionIfPresent(objectTypeWithLinks.objectType.description)}
|
|
1322
|
-
export interface ${objectTypeWithLinks.objectType.apiName} extends OntologyObject {
|
|
1323
|
-
/** @deprecated please migrate to $apiName instead */
|
|
1324
|
-
readonly __apiName: "${objectTypeWithLinks.objectType.apiName}" & {${objectTypeWithLinks.linkTypes.map((linkType) => {
|
|
1325
|
-
return `/** @deprecated please migrate to pivotTo(${linkType.apiName}) instead */ searchAround${linkType.apiName.charAt(0).toUpperCase() + linkType.apiName.slice(1)}?: never`;
|
|
1326
|
-
})}};
|
|
1327
|
-
/** @deprecated please migrate to $primaryKey instead */
|
|
1328
|
-
readonly __primaryKey: ${wirePropertyTypeV2ToTypeScriptType(objectTypeWithLinks.objectType.properties[objectTypeWithLinks.objectType.primaryKey].dataType)};
|
|
1329
|
-
readonly $apiName: "${objectTypeWithLinks.objectType.apiName}";
|
|
1330
|
-
readonly $primaryKey: ${wirePropertyTypeV2ToTypeScriptType(objectTypeWithLinks.objectType.properties[objectTypeWithLinks.objectType.primaryKey].dataType)};
|
|
1331
|
-
${Object.entries(objectTypeWithLinks.objectType.properties).sort((a, b) => a[0].localeCompare(b[0])).flatMap(([propertyName, propertyDefinition]) => {
|
|
1332
|
-
const propertyType = wirePropertyTypeV2ToTypeScriptType(propertyDefinition.dataType);
|
|
1333
|
-
const entries = [`${getDescriptionIfPresent(propertyDefinition.description, true)}readonly ${propertyName}: ${propertyType} | undefined`];
|
|
1334
|
-
if (isReservedKeyword(propertyName)) {
|
|
1335
|
-
entries.push(`/** @deprecated please migrate to '${propertyName}' instead */
|
|
1336
|
-
readonly ${propertyName}_: ${propertyType} | undefined`);
|
|
1337
|
-
}
|
|
1338
|
-
return entries;
|
|
1339
|
-
}).join(";\n")}
|
|
1340
|
-
${objectTypeWithLinks.linkTypes.flatMap((linkType) => {
|
|
1341
|
-
const entries = [`readonly ${linkType.apiName}: ${linkType.cardinality === "MANY" ? "MultiLink" : "SingleLink"}<${linkType.objectTypeApiName}>`];
|
|
1342
|
-
return entries;
|
|
1343
|
-
}).join(";\n")}
|
|
1344
|
-
}
|
|
1345
|
-
`;
|
|
1346
|
-
}
|
|
1347
|
-
function wirePropertyTypeV2ToTypeScriptType(property) {
|
|
1348
|
-
switch (property.type) {
|
|
1349
|
-
case "string":
|
|
1350
|
-
return "string";
|
|
1351
|
-
case "boolean":
|
|
1352
|
-
return "boolean";
|
|
1353
|
-
case "array":
|
|
1354
|
-
return wirePropertyTypeV2ToTypeScriptType(property.subType) + "[]";
|
|
1355
|
-
case "integer":
|
|
1356
|
-
return "number";
|
|
1357
|
-
case "attachment":
|
|
1358
|
-
return "Attachment";
|
|
1359
|
-
case "byte":
|
|
1360
|
-
return "number";
|
|
1361
|
-
case "date":
|
|
1362
|
-
return "LocalDate";
|
|
1363
|
-
case "decimal":
|
|
1364
|
-
return "string";
|
|
1365
|
-
case "double":
|
|
1366
|
-
return "number";
|
|
1367
|
-
case "float":
|
|
1368
|
-
return "number";
|
|
1369
|
-
case "geopoint":
|
|
1370
|
-
return "GeoPoint";
|
|
1371
|
-
case "geoshape":
|
|
1372
|
-
return "GeoShape";
|
|
1373
|
-
case "long":
|
|
1374
|
-
return "StringLong";
|
|
1375
|
-
case "short":
|
|
1376
|
-
return "number";
|
|
1377
|
-
case "timestamp":
|
|
1378
|
-
return "Timestamp";
|
|
1379
|
-
case "timeseries":
|
|
1380
|
-
return property.itemType.type === "string" ? `TimeSeries<string>` : `TimeSeries<number>`;
|
|
1381
|
-
case "marking":
|
|
1382
|
-
return "string";
|
|
1383
|
-
default:
|
|
1384
|
-
throw new Error(`Unknown property type ${property}`);
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
function getDescriptionIfPresent(description, includeNewline) {
|
|
1388
|
-
if (description) {
|
|
1389
|
-
return `/**
|
|
1390
|
-
* ${description}
|
|
1391
|
-
*/${includeNewline ? "\n" : ""}`;
|
|
1392
|
-
}
|
|
1393
|
-
return "";
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
// src/v1.1/generatePerObjectInterfaceAndDataFiles.ts
|
|
1397
|
-
async function generatePerObjectInterfaceAndDataFiles(ontology, fs2, outDir, importExt = "") {
|
|
1398
|
-
await fs2.mkdir(outDir, {
|
|
1399
|
-
recursive: true
|
|
1400
|
-
});
|
|
1401
|
-
await Promise.all(Object.values(ontology.og.objectTypes).map(async (object) => {
|
|
1402
|
-
const relPath = path16__namespace.default.join(".", "ontology", `objects`, `${object.objectType.apiName}.ts`);
|
|
1403
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, `${object.objectType.apiName}.ts`), await formatTs(`
|
|
1404
|
-
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
|
|
1405
|
-
${wireObjectTypeV2ToObjectInterfaceStringV1(object, importExt)}
|
|
1406
|
-
|
|
1407
|
-
${wireObjectTypeV2ToSdkObjectConstV1(object, {
|
|
1408
|
-
ontology
|
|
1409
|
-
}, relPath)}
|
|
1410
|
-
`));
|
|
1411
|
-
}));
|
|
1412
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, "index.ts"), await formatTs(`
|
|
1413
|
-
${Object.keys(ontology.og.objectTypes).map((apiName) => `export * from "./${apiName}${importExt}";`).join("\n")}
|
|
1414
|
-
export type { ObjectSet } from "@osdk/legacy-client";
|
|
1415
|
-
|
|
1416
|
-
`));
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
// src/shared/getObjectTypesFromQueryDataType.ts
|
|
1420
|
-
function getObjectTypesFromQueryDataType(dataType, types) {
|
|
1421
|
-
switch (dataType.type) {
|
|
1422
|
-
case "array":
|
|
1423
|
-
case "set":
|
|
1424
|
-
getObjectTypesFromQueryDataType(dataType.subType, types);
|
|
1425
|
-
return;
|
|
1426
|
-
case "object":
|
|
1427
|
-
types.add(dataType.objectTypeApiName);
|
|
1428
|
-
return;
|
|
1429
|
-
case "objectSet":
|
|
1430
|
-
types.add(dataType.objectTypeApiName);
|
|
1431
|
-
return;
|
|
1432
|
-
case "struct":
|
|
1433
|
-
for (const prop of Object.values(dataType.fields)) {
|
|
1434
|
-
getObjectTypesFromQueryDataType(prop.fieldType, types);
|
|
1435
|
-
}
|
|
1436
|
-
return;
|
|
1437
|
-
case "union":
|
|
1438
|
-
for (const type of dataType.unionTypes) {
|
|
1439
|
-
getObjectTypesFromQueryDataType(type, types);
|
|
1440
|
-
}
|
|
1441
|
-
return;
|
|
1442
|
-
case "attachment":
|
|
1443
|
-
case "boolean":
|
|
1444
|
-
case "date":
|
|
1445
|
-
case "double":
|
|
1446
|
-
case "float":
|
|
1447
|
-
case "integer":
|
|
1448
|
-
case "long":
|
|
1449
|
-
case "null":
|
|
1450
|
-
case "string":
|
|
1451
|
-
case "threeDimensionalAggregation":
|
|
1452
|
-
case "timestamp":
|
|
1453
|
-
case "twoDimensionalAggregation":
|
|
1454
|
-
case "unsupported":
|
|
1455
|
-
return;
|
|
1456
|
-
default:
|
|
1457
|
-
throw new Error(`Cannot find object types from unsupported QueryDataType ${dataType.type}`);
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
// src/shared/getObjectTypeApiNamesFromQuery.ts
|
|
1462
|
-
function getObjectTypeApiNamesFromQuery(query) {
|
|
1463
|
-
const types = /* @__PURE__ */ new Set();
|
|
1464
|
-
for (const {
|
|
1465
|
-
dataType
|
|
1466
|
-
} of Object.values(query.parameters)) {
|
|
1467
|
-
getObjectTypesFromQueryDataType(dataType, types);
|
|
1468
|
-
}
|
|
1469
|
-
getObjectTypesFromQueryDataType(query.output, types);
|
|
1470
|
-
return Array.from(types);
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
// src/shared/isNullableQueryDataType.ts
|
|
1474
|
-
function isNullableQueryDataType(input) {
|
|
1475
|
-
if (input.type === "null") {
|
|
1476
|
-
return true;
|
|
1477
|
-
}
|
|
1478
|
-
if (input.type === "union") {
|
|
1479
|
-
return input.unionTypes.some((t) => isNullableQueryDataType(t));
|
|
1480
|
-
}
|
|
1481
|
-
return false;
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
// src/shared/wireQueryDataTypeToQueryDataTypeDefinition.ts
|
|
1485
|
-
function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
1486
|
-
switch (input.type) {
|
|
1487
|
-
case "double":
|
|
1488
|
-
case "float":
|
|
1489
|
-
case "integer":
|
|
1490
|
-
case "long":
|
|
1491
|
-
case "attachment":
|
|
1492
|
-
case "boolean":
|
|
1493
|
-
case "date":
|
|
1494
|
-
case "string":
|
|
1495
|
-
case "timestamp":
|
|
1496
|
-
return {
|
|
1497
|
-
type: input.type,
|
|
1498
|
-
nullable: false
|
|
1499
|
-
};
|
|
1500
|
-
case "object":
|
|
1501
|
-
return {
|
|
1502
|
-
type: "object",
|
|
1503
|
-
object: input.objectTypeApiName,
|
|
1504
|
-
nullable: false
|
|
1505
|
-
};
|
|
1506
|
-
case "objectSet":
|
|
1507
|
-
return {
|
|
1508
|
-
type: "objectSet",
|
|
1509
|
-
objectSet: input.objectTypeApiName,
|
|
1510
|
-
nullable: false
|
|
1511
|
-
};
|
|
1512
|
-
case "array":
|
|
1513
|
-
return {
|
|
1514
|
-
...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
|
|
1515
|
-
multiplicity: true
|
|
1516
|
-
};
|
|
1517
|
-
case "set":
|
|
1518
|
-
return {
|
|
1519
|
-
type: "set",
|
|
1520
|
-
set: wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
|
|
1521
|
-
nullable: false
|
|
1522
|
-
};
|
|
1523
|
-
case "union":
|
|
1524
|
-
const allowNulls = isNullableQueryDataType(input);
|
|
1525
|
-
if (allowNulls && input.unionTypes.length === 2) {
|
|
1526
|
-
const nonNull = input.unionTypes.find((t) => t.type != null);
|
|
1527
|
-
if (nonNull) {
|
|
1528
|
-
return {
|
|
1529
|
-
...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),
|
|
1530
|
-
nullable: true
|
|
1531
|
-
};
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
return {
|
|
1535
|
-
type: "union",
|
|
1536
|
-
union: input.unionTypes.reduce((acc, t) => {
|
|
1537
|
-
if (t.type === "null") {
|
|
1538
|
-
return acc;
|
|
1539
|
-
}
|
|
1540
|
-
acc.push(wireQueryDataTypeToQueryDataTypeDefinition(t));
|
|
1541
|
-
return acc;
|
|
1542
|
-
}, []),
|
|
1543
|
-
nullable: allowNulls
|
|
1544
|
-
};
|
|
1545
|
-
case "struct":
|
|
1546
|
-
return {
|
|
1547
|
-
type: "struct",
|
|
1548
|
-
struct: Object.fromEntries(input.fields.map((f) => [f.name, wireQueryDataTypeToQueryDataTypeDefinition(f.fieldType)])),
|
|
1549
|
-
nullable: false
|
|
1550
|
-
};
|
|
1551
|
-
case "twoDimensionalAggregation":
|
|
1552
|
-
return {
|
|
1553
|
-
type: "twoDimensionalAggregation",
|
|
1554
|
-
twoDimensionalAggregation: get2DQueryAggregationProps(input),
|
|
1555
|
-
nullable: false
|
|
1556
|
-
};
|
|
1557
|
-
case "threeDimensionalAggregation":
|
|
1558
|
-
return {
|
|
1559
|
-
type: "threeDimensionalAggregation",
|
|
1560
|
-
threeDimensionalAggregation: get3DQueryAggregationProps(input),
|
|
1561
|
-
nullable: false
|
|
1562
|
-
};
|
|
1563
|
-
case "null":
|
|
1564
|
-
case "unsupported":
|
|
1565
|
-
throw new Error(`Accidentally tried to handle QueryDataType.type ${input.type}`);
|
|
1566
|
-
default:
|
|
1567
|
-
throw new Error(`Unsupported QueryDataType.type ${input.type}`);
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
function get2DQueryAggregationProps(input) {
|
|
1571
|
-
if (input.keyType.type === "range") {
|
|
1572
|
-
return {
|
|
1573
|
-
keyType: input.keyType.type,
|
|
1574
|
-
keySubtype: input.keyType.subType.type,
|
|
1575
|
-
valueType: input.valueType.type
|
|
1576
|
-
};
|
|
1577
|
-
} else {
|
|
1578
|
-
if (guardInvalidKeyTypes(input.keyType)) {
|
|
1579
|
-
return {
|
|
1580
|
-
keyType: input.keyType.type,
|
|
1581
|
-
valueType: input.valueType.type
|
|
1582
|
-
};
|
|
1583
|
-
}
|
|
1584
|
-
throw new Error(`Cannot create 2D aggregation with ${input.keyType.type} as its type`);
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
function get3DQueryAggregationProps(input) {
|
|
1588
|
-
if (input.keyType.type === "range") {
|
|
1589
|
-
return {
|
|
1590
|
-
keyType: input.keyType.type,
|
|
1591
|
-
keySubtype: input.keyType.subType.type,
|
|
1592
|
-
valueType: get2DQueryAggregationProps(input.valueType)
|
|
1593
|
-
};
|
|
1594
|
-
} else {
|
|
1595
|
-
if (guardInvalidKeyTypes(input.keyType)) {
|
|
1596
|
-
return {
|
|
1597
|
-
keyType: input.keyType.type,
|
|
1598
|
-
valueType: get2DQueryAggregationProps(input.valueType)
|
|
1599
|
-
};
|
|
1600
|
-
}
|
|
1601
|
-
throw new Error(`Cannot create 3D aggregation with ${input.keyType.type} as its type`);
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1604
|
-
function guardInvalidKeyTypes(key) {
|
|
1605
|
-
return key.type === "string" || key.type === "boolean";
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
|
-
// src/shared/wireQueryTypeV2ToSdkQueryDefinition.ts
|
|
1609
|
-
function wireQueryTypeV2ToSdkQueryDefinition(input) {
|
|
1610
|
-
return {
|
|
1611
|
-
type: "query",
|
|
1612
|
-
apiName: input.apiName,
|
|
1613
|
-
description: input.description,
|
|
1614
|
-
displayName: input.displayName,
|
|
1615
|
-
version: input.version,
|
|
1616
|
-
parameters: Object.fromEntries(Object.entries(input.parameters).map(([name, parameter]) => [name, wireQueryParameterV2ToQueryParameterDefinition(parameter)])),
|
|
1617
|
-
output: wireQueryDataTypeToQueryDataTypeDefinition(input.output)
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
function wireQueryTypeV2ToSdkQueryDefinitionNoParams(input) {
|
|
1621
|
-
return {
|
|
1622
|
-
type: "query",
|
|
1623
|
-
apiName: input.apiName,
|
|
1624
|
-
description: input.description,
|
|
1625
|
-
displayName: input.displayName,
|
|
1626
|
-
version: input.version
|
|
1627
|
-
};
|
|
1628
|
-
}
|
|
1629
|
-
function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
1630
|
-
return {
|
|
1631
|
-
description: parameter.description,
|
|
1632
|
-
...wireQueryDataTypeToQueryDataTypeDefinition(parameter.dataType)
|
|
1633
|
-
};
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
// src/v1.1/generatePerQueryDataFiles.ts
|
|
1637
|
-
async function generatePerQueryDataFiles({
|
|
1638
|
-
fs: fs2,
|
|
1639
|
-
outDir: rootOutDir,
|
|
1640
|
-
ontology
|
|
1641
|
-
}, v2) {
|
|
1642
|
-
const relOutDir = path16__namespace.default.join(".", "ontology", "queries");
|
|
1643
|
-
const outDir = path16__namespace.default.join(rootOutDir, "ontology", "queries");
|
|
1644
|
-
await fs2.mkdir(outDir, {
|
|
1645
|
-
recursive: true
|
|
1646
|
-
});
|
|
1647
|
-
await Promise.all(Object.values(ontology.queryTypes).map(async (query) => {
|
|
1648
|
-
await generateV1QueryFile(fs2, outDir, query);
|
|
1649
|
-
}));
|
|
1650
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, "index.ts"), await formatTs(`
|
|
1651
|
-
${Object.values(ontology.queryTypes).map((query) => `export * from "${query.getImportPathRelTo(path16__namespace.default.join(relOutDir, "index.ts"))}";`).join("\n")}
|
|
1652
|
-
${Object.keys(ontology.queryTypes).length === 0 ? "export {};" : ""}
|
|
1653
|
-
`));
|
|
1654
|
-
}
|
|
1655
|
-
async function generateV1QueryFile(fs2, outDir, query) {
|
|
1656
|
-
const objectTypes = getObjectTypeApiNamesFromQuery(query);
|
|
1657
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
1658
|
-
import { QueryDefinition } from "@osdk/api";
|
|
1659
|
-
|
|
1660
|
-
export const ${query.shortApiName} = ${JSON.stringify(wireQueryTypeV2ToSdkQueryDefinition(query.og))} ${getQueryDefSatisfies(query.fullApiName, objectTypes)}`));
|
|
1661
|
-
}
|
|
1662
|
-
function getQueryDefSatisfies(apiName, objectTypes) {
|
|
1663
|
-
return `satisfies QueryDefinition<"${apiName}", ${objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never"}>;`;
|
|
1664
|
-
}
|
|
1665
|
-
async function generateQueries(ontology, fs2, outDir, importExt = "") {
|
|
1666
|
-
const importedObjects = /* @__PURE__ */ new Set();
|
|
1667
|
-
const signatures = [];
|
|
1668
|
-
for (const query of Object.values(ontology.queryTypes)) {
|
|
1669
|
-
const jsDocBlock = ["/**"];
|
|
1670
|
-
if (query.description) {
|
|
1671
|
-
jsDocBlock.push(`* ${query.description}`);
|
|
1672
|
-
}
|
|
1673
|
-
const outputType = handleQueryDataType(query.output, importedObjects, true);
|
|
1674
|
-
const paramEntries = [];
|
|
1675
|
-
for (const [name, parameter] of Object.entries(query.parameters)) {
|
|
1676
|
-
const nullable = isNullableQueryDataType(parameter.dataType);
|
|
1677
|
-
const type = handleQueryDataType(parameter.dataType, importedObjects, false);
|
|
1678
|
-
paramEntries.push(`"${name}"${nullable ? "?" : ""}: ${type}`);
|
|
1679
|
-
jsDocBlock.push(`* @param {${sanitizeDocTypeName(type)}} params.${name}${parameter.description ? ` - ${parameter.description}` : ""}`);
|
|
1680
|
-
}
|
|
1681
|
-
const param = paramEntries.length === 0 ? "" : `params: { ${paramEntries.join("; ")} }`;
|
|
1682
|
-
jsDocBlock.push(`* @returns ${sanitizeDocTypeName(outputType)}`, "*/");
|
|
1683
|
-
signatures.push(`
|
|
1684
|
-
${jsDocBlock.join("\n")}
|
|
1685
|
-
${query.apiName}(${param}): Promise<Result<QueryResponse<${outputType}>, QueryError>>;
|
|
1686
|
-
`);
|
|
1687
|
-
}
|
|
1688
|
-
await fs2.mkdir(outDir, {
|
|
1689
|
-
recursive: true
|
|
1690
|
-
});
|
|
1691
|
-
await fs2.writeFile(path16__namespace.default.join(outDir, "Queries.ts"), await formatTs(`
|
|
1692
|
-
import type { QueryResponse, QueryError, Result, Timestamp, LocalDate, Range, Attachment, ObjectSet, TwoDimensionalAggregation, ThreeDimensionalAggregation } from "@osdk/legacy-client";
|
|
1693
|
-
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
1694
|
-
|
|
1695
|
-
export interface Queries {
|
|
1696
|
-
${signatures.join("\n")}
|
|
1697
|
-
}
|
|
1698
|
-
`));
|
|
1699
|
-
}
|
|
1700
|
-
function handleQueryDataType(dataType, importedObjects, isReturnValue) {
|
|
1701
|
-
switch (dataType.type) {
|
|
1702
|
-
case "boolean":
|
|
1703
|
-
return "boolean";
|
|
1704
|
-
case "string":
|
|
1705
|
-
return "string";
|
|
1706
|
-
case "double":
|
|
1707
|
-
case "float":
|
|
1708
|
-
case "integer":
|
|
1709
|
-
return "number";
|
|
1710
|
-
case "long":
|
|
1711
|
-
return isReturnValue ? "string" : "string | number";
|
|
1712
|
-
case "date":
|
|
1713
|
-
return "LocalDate";
|
|
1714
|
-
case "timestamp":
|
|
1715
|
-
return "Timestamp";
|
|
1716
|
-
case "attachment":
|
|
1717
|
-
return "Attachment";
|
|
1718
|
-
case "array":
|
|
1719
|
-
return `Array<${handleQueryDataType(dataType.subType, importedObjects, isReturnValue)}>`;
|
|
1720
|
-
case "object": {
|
|
1721
|
-
const objectType = dataType.objectTypeApiName;
|
|
1722
|
-
importedObjects.add(objectType);
|
|
1723
|
-
return isReturnValue ? objectType : `${objectType} | ${objectType}["__primaryKey"]`;
|
|
1724
|
-
}
|
|
1725
|
-
case "objectSet": {
|
|
1726
|
-
const objectType = dataType.objectTypeApiName;
|
|
1727
|
-
importedObjects.add(objectType);
|
|
1728
|
-
return `ObjectSet<${objectType}>`;
|
|
1729
|
-
}
|
|
1730
|
-
case "set":
|
|
1731
|
-
return `Set<${handleQueryDataType(dataType.subType, importedObjects, isReturnValue)}>`;
|
|
1732
|
-
case "struct":
|
|
1733
|
-
const properties = dataType.fields.map((field) => {
|
|
1734
|
-
const isNullable = isNullableQueryDataType(field.fieldType);
|
|
1735
|
-
return `${field.name}${isNullable ? "?" : ""}: ${handleQueryDataType(field.fieldType, importedObjects, isReturnValue)}`;
|
|
1736
|
-
});
|
|
1737
|
-
return `{ ${properties.join(",\n")} }`;
|
|
1738
|
-
case "union":
|
|
1739
|
-
return dataType.unionTypes.map((type) => handleQueryDataType(type, importedObjects, isReturnValue)).filter((type) => type !== "null").join("|");
|
|
1740
|
-
case "twoDimensionalAggregation":
|
|
1741
|
-
dataType.valueType;
|
|
1742
|
-
return `TwoDimensionalAggregation<
|
|
1743
|
-
${aggregationKeyToTypescriptType(dataType.keyType)},
|
|
1744
|
-
${aggregationValueToTypescriptType(dataType.valueType)}
|
|
1745
|
-
>`;
|
|
1746
|
-
case "threeDimensionalAggregation":
|
|
1747
|
-
return `ThreeDimensionalAggregation<
|
|
1748
|
-
${aggregationKeyToTypescriptType(dataType.keyType)},
|
|
1749
|
-
${aggregationKeyToTypescriptType(dataType.valueType.keyType)},
|
|
1750
|
-
${aggregationValueToTypescriptType(dataType.valueType.valueType)}
|
|
1751
|
-
>`;
|
|
1752
|
-
case "null":
|
|
1753
|
-
return "null";
|
|
1754
|
-
case "unsupported":
|
|
1755
|
-
throw new Error("Cannot generate queries for unsupported type");
|
|
1756
|
-
default:
|
|
1757
|
-
throw new Error(`Cannot generate queries for type ${dataType.type}`);
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
function aggregationKeyToTypescriptType(keyType) {
|
|
1761
|
-
switch (keyType.type) {
|
|
1762
|
-
case "boolean":
|
|
1763
|
-
return "boolean";
|
|
1764
|
-
case "double":
|
|
1765
|
-
case "integer":
|
|
1766
|
-
return "number";
|
|
1767
|
-
case "string":
|
|
1768
|
-
return "string";
|
|
1769
|
-
case "date":
|
|
1770
|
-
return "LocalDate";
|
|
1771
|
-
case "timestamp":
|
|
1772
|
-
return "Timestamp";
|
|
1773
|
-
case "range":
|
|
1774
|
-
return `Range<${aggregationRangeToTypescriptType(keyType.subType)}>`;
|
|
1775
|
-
default:
|
|
1776
|
-
throw new Error(`Unknown TwoDimensionalAggregation keyType ${keyType.type}`);
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
function aggregationRangeToTypescriptType(subType) {
|
|
1780
|
-
switch (subType.type) {
|
|
1781
|
-
case "date":
|
|
1782
|
-
return "LocalDate";
|
|
1783
|
-
case "double":
|
|
1784
|
-
case "integer":
|
|
1785
|
-
return "number";
|
|
1786
|
-
case "timestamp":
|
|
1787
|
-
return "Timestamp";
|
|
1788
|
-
default:
|
|
1789
|
-
throw new Error(`Unsupported QueryAggregationRangeSubType ${subType.type}`);
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
function aggregationValueToTypescriptType(valueType) {
|
|
1793
|
-
switch (valueType.type) {
|
|
1794
|
-
case "date":
|
|
1795
|
-
return "LocalDate";
|
|
1796
|
-
case "double":
|
|
1797
|
-
return "number";
|
|
1798
|
-
case "timestamp":
|
|
1799
|
-
return "Timestamp";
|
|
1800
|
-
default:
|
|
1801
|
-
throw new Error(`Unsupported QueryAggregationValueType ${valueType.type}`);
|
|
433
|
+
function stringUnionFrom(values) {
|
|
434
|
+
if (values.length === 0) {
|
|
435
|
+
return "never";
|
|
436
|
+
} else {
|
|
437
|
+
return values.map((v) => `"${v}"`).join("|");
|
|
1802
438
|
}
|
|
1803
439
|
}
|
|
1804
|
-
function sanitizeDocTypeName(type) {
|
|
1805
|
-
return type.replace(/\s/g, "");
|
|
1806
|
-
}
|
|
1807
440
|
|
|
1808
|
-
// src/v1.1/
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
recursive: true
|
|
1817
|
-
});
|
|
1818
|
-
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
1819
|
-
const enhancedOntology = enhanceOntology(sanitizedOntology, void 0, /* @__PURE__ */ new Map(), importExt);
|
|
1820
|
-
await generateFoundryClientFile(fs2, outDir, importExt);
|
|
1821
|
-
await generateMetadataFile(sanitizedOntology, userAgent, fs2, outDir, importExt);
|
|
1822
|
-
await generateOntologyIndexFile(fs2, path16__namespace.join(outDir, "ontology"));
|
|
1823
|
-
await generateObjectsInterfaceFile(sanitizedOntology, fs2, objectsDir, importExt);
|
|
1824
|
-
await generateObjectsInterfaceSupportFiles(sanitizedOntology, fs2, path16__namespace.join(objectsDir, "objects-api"), importExt);
|
|
1825
|
-
await generatePerObjectInterfaceAndDataFiles(enhancedOntology, fs2, objectsDir, importExt);
|
|
1826
|
-
const common = {
|
|
1827
|
-
sanitizedOntology,
|
|
1828
|
-
fs: fs2,
|
|
1829
|
-
outDir,
|
|
1830
|
-
ontology: enhancedOntology
|
|
1831
|
-
};
|
|
1832
|
-
await generateActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1833
|
-
await generateBatchActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1834
|
-
await generateBulkActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1835
|
-
await generatePerActionDataFilesV1(common);
|
|
1836
|
-
await generateQueries(sanitizedOntology, fs2, queriesDir, importExt);
|
|
1837
|
-
await generatePerQueryDataFiles(common);
|
|
1838
|
-
await generateIndexFile(fs2, outDir, importExt);
|
|
1839
|
-
await generateBackCompatDeprecatedExports(fs2, outDir, importExt);
|
|
1840
|
-
}
|
|
1841
|
-
var ExpectedOsdkVersion = "0.22.0";
|
|
1842
|
-
async function generateOntologyMetadataFile({
|
|
1843
|
-
fs: fs2,
|
|
1844
|
-
outDir,
|
|
1845
|
-
ontology,
|
|
1846
|
-
ontologyApiNamespace
|
|
1847
|
-
}, userAgent) {
|
|
1848
|
-
fs2.writeFile(path16__namespace.default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
1849
|
-
export type $ExpectedClientVersion = "${ExpectedOsdkVersion}";
|
|
1850
|
-
export const $osdkMetadata = { extraUserAgent: "${userAgent}" };
|
|
1851
|
-
${ontologyApiNamespace == null ? `
|
|
1852
|
-
export const $ontologyRid = "${ontology.ontology.rid}";
|
|
1853
|
-
` : ""}
|
|
1854
|
-
`));
|
|
441
|
+
// src/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.ts
|
|
442
|
+
function getDescriptionIfPresent(description, includeNewline) {
|
|
443
|
+
if (description) {
|
|
444
|
+
return `/**
|
|
445
|
+
* ${description}
|
|
446
|
+
*/${""}`;
|
|
447
|
+
}
|
|
448
|
+
return "";
|
|
1855
449
|
}
|
|
1856
450
|
|
|
1857
451
|
// src/shared/propertyJsdoc.ts
|
|
@@ -1977,7 +571,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
1977
571
|
const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);
|
|
1978
572
|
return `${imports}${getV2Types()}
|
|
1979
573
|
|
|
1980
|
-
export const ${object.shortApiName}: ${objectDefIdentifier}
|
|
574
|
+
export const ${object.shortApiName}: ${objectDefIdentifier}
|
|
1981
575
|
= {
|
|
1982
576
|
osdkMetadata: $osdkMetadata,
|
|
1983
577
|
objectSet: undefined as any,
|
|
@@ -1996,7 +590,7 @@ function createOsdkObject(object, identifier, {
|
|
|
1996
590
|
osdkObjectStrictPropsIdentifier,
|
|
1997
591
|
osdkObjectLinksIdentifier
|
|
1998
592
|
}) {
|
|
1999
|
-
|
|
593
|
+
object.getCleanedUpDefinition(true);
|
|
2000
594
|
return `
|
|
2001
595
|
export type ${identifier}<
|
|
2002
596
|
OPTIONS extends never | "$notStrict" | "$rid" = never,
|
|
@@ -2006,23 +600,10 @@ function createOsdkObject(object, identifier, {
|
|
|
2006
600
|
= $Osdk<
|
|
2007
601
|
${objectDefIdentifier},
|
|
2008
602
|
K | OPTIONS
|
|
2009
|
-
>
|
|
2010
|
-
|
|
2011
|
-
? ${osdkObjectStrictPropsIdentifier} :
|
|
2012
|
-
OPTIONS extends "$notStrict" ? ${osdkObjectPropsIdentifier} : ${osdkObjectStrictPropsIdentifier}
|
|
2013
|
-
, K
|
|
2014
|
-
> & {
|
|
2015
|
-
readonly $link: ${osdkObjectLinksIdentifier};
|
|
2016
|
-
readonly $title: string | undefined; // FIXME
|
|
2017
|
-
readonly $primaryKey: ${"primaryKeyApiName" in definition ? `
|
|
2018
|
-
$OsdkObjectPropertyType<${JSON.stringify(definition.properties[definition.primaryKeyApiName])},${true}>` : "string | number"}
|
|
603
|
+
>
|
|
604
|
+
|
|
2019
605
|
;
|
|
2020
|
-
|
|
2021
|
-
readonly $as: <NEW_Q extends $ValidToFrom<${objectDefIdentifier}>>(type: NEW_Q | string) => $Osdk<
|
|
2022
|
-
NEW_Q,
|
|
2023
|
-
$ConvertProps<${objectDefIdentifier}, NEW_Q, K>
|
|
2024
|
-
>;
|
|
2025
|
-
} & $OsdkObject<"${object.fullApiName}">;`;
|
|
606
|
+
`;
|
|
2026
607
|
}
|
|
2027
608
|
function createObjectSet(object, {
|
|
2028
609
|
objectDefIdentifier,
|
|
@@ -2037,74 +618,7 @@ $ObjectSet<${objectDefIdentifier},
|
|
|
2037
618
|
${objectSetIdentifier}
|
|
2038
619
|
>
|
|
2039
620
|
{
|
|
2040
|
-
readonly aggregate: <const AO extends $AggregateOpts<${objectDefIdentifier}>>(
|
|
2041
|
-
req: $AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy<${objectDefIdentifier}, AO>,
|
|
2042
|
-
) => Promise<$AggregationsResults<${objectDefIdentifier}, AO>>;
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
readonly pivotTo: <const L extends $LinkNames<${objectDefIdentifier}>>(type: L) => $LinkedType<${objectDefIdentifier}, L>["objectSet"];
|
|
2046
|
-
${object instanceof EnhancedObjectType ? `
|
|
2047
|
-
readonly fetchOne: <
|
|
2048
|
-
const L extends ${propertyKeysIdentifier},
|
|
2049
|
-
const R extends boolean,
|
|
2050
|
-
const S extends false | "throw" = $NullabilityAdherenceDefault,
|
|
2051
|
-
>(
|
|
2052
|
-
primaryKey: $PropertyValueClientToWire[${objectDefIdentifier}["primaryKeyType"]],
|
|
2053
|
-
options?: $SelectArg<${objectDefIdentifier}, L, R, S>,
|
|
2054
|
-
) => Promise<
|
|
2055
|
-
${osdkObjectIdentifier}<
|
|
2056
|
-
(S extends false ? "$notStrict" : never) | ($DefaultToFalse<R> extends false? never: "$rid" ),
|
|
2057
|
-
$IsAny<L> extends true ? ${propertyKeysIdentifier} : L
|
|
2058
|
-
>>
|
|
2059
|
-
;
|
|
2060
621
|
|
|
2061
|
-
readonly fetchOneWithErrors: <
|
|
2062
|
-
const L extends ${propertyKeysIdentifier},
|
|
2063
|
-
const R extends boolean,
|
|
2064
|
-
const S extends false | "throw" = $NullabilityAdherenceDefault,
|
|
2065
|
-
>(
|
|
2066
|
-
primaryKey: $PropertyValueClientToWire[${objectDefIdentifier}["primaryKeyType"]],
|
|
2067
|
-
options?: $SelectArg<${objectDefIdentifier}, L, R, S>,
|
|
2068
|
-
) => Promise<$Result<
|
|
2069
|
-
${osdkObjectIdentifier}<
|
|
2070
|
-
(S extends false ? "$notStrict" : never) | ($DefaultToFalse<R> extends false?never: "$rid"),
|
|
2071
|
-
$IsAny<L> extends true ? ${propertyKeysIdentifier} : L
|
|
2072
|
-
>
|
|
2073
|
-
>>
|
|
2074
|
-
|
|
2075
|
-
;
|
|
2076
|
-
|
|
2077
|
-
` : ""}
|
|
2078
|
-
|
|
2079
|
-
readonly fetchPage: <
|
|
2080
|
-
const L extends ${propertyKeysIdentifier},
|
|
2081
|
-
const R extends boolean,
|
|
2082
|
-
const const A extends $Augments,
|
|
2083
|
-
const S extends $NullabilityAdherence = $NullabilityAdherenceDefault,
|
|
2084
|
-
>(
|
|
2085
|
-
args?: $FetchPageArgs<${objectDefIdentifier}, L, R, A, S>,
|
|
2086
|
-
) => Promise<
|
|
2087
|
-
$PageResult<${osdkObjectIdentifier}<
|
|
2088
|
-
(S extends false ? "$notStrict" : never) | ($DefaultToFalse<R> extends false? never: "$rid"),
|
|
2089
|
-
$IsAny<L> extends true ? ${propertyKeysIdentifier} : L
|
|
2090
|
-
>>
|
|
2091
|
-
>;
|
|
2092
|
-
|
|
2093
|
-
readonly fetchPageWithErrors: <
|
|
2094
|
-
const L extends ${propertyKeysIdentifier},
|
|
2095
|
-
const R extends boolean,
|
|
2096
|
-
const A extends $Augments,
|
|
2097
|
-
const S extends $NullabilityAdherence = $NullabilityAdherenceDefault,
|
|
2098
|
-
>(
|
|
2099
|
-
args?: $FetchPageArgs<${objectDefIdentifier}, L, R, A, S>,
|
|
2100
|
-
) => Promise<$Result<
|
|
2101
|
-
$PageResult<${osdkObjectIdentifier}<
|
|
2102
|
-
(S extends false ? "$notStrict" : never) | ($DefaultToFalse<R> extends false? never : "$rid"),
|
|
2103
|
-
$IsAny<L> extends true ? ${propertyKeysIdentifier} : L
|
|
2104
|
-
>>
|
|
2105
|
-
>>;
|
|
2106
|
-
|
|
2107
|
-
readonly asyncIter: () => AsyncIterableIterator<${osdkObjectIdentifier}>;
|
|
2108
622
|
}
|
|
2109
623
|
`;
|
|
2110
624
|
}
|
|
@@ -2136,7 +650,7 @@ function createDefinition(object, ontology, identifier, {
|
|
|
2136
650
|
}) {
|
|
2137
651
|
const definition = object.getCleanedUpDefinition(true);
|
|
2138
652
|
return `
|
|
2139
|
-
export interface ${identifier} extends ${object instanceof EnhancedObjectType ? `$ObjectTypeDefinition` : `$InterfaceDefinition`}<"${object.fullApiName}", ${objectDefIdentifier}
|
|
653
|
+
export interface ${identifier} extends ${object instanceof EnhancedObjectType ? `$ObjectTypeDefinition` : `$InterfaceDefinition`}<"${object.fullApiName}", ${objectDefIdentifier}> {
|
|
2140
654
|
osdkMetadata: typeof $osdkMetadata;
|
|
2141
655
|
objectSet: ${objectSetIdentifier};
|
|
2142
656
|
props: ${osdkObjectPropsIdentifier};
|
|
@@ -2190,15 +704,15 @@ async function generatePerActionDataFiles({
|
|
|
2190
704
|
importExt = "",
|
|
2191
705
|
ontology: enhancedOntology
|
|
2192
706
|
}) {
|
|
2193
|
-
const outDir =
|
|
707
|
+
const outDir = path5__namespace.default.join(rootOutDir, "ontology", "actions");
|
|
2194
708
|
await fs2.mkdir(outDir, {
|
|
2195
709
|
recursive: true
|
|
2196
710
|
});
|
|
2197
711
|
await Promise.all(Object.values(enhancedOntology.actionTypes).map(async (action) => {
|
|
2198
|
-
const currentFilePath = `${
|
|
2199
|
-
const uniqueApiNamesArray =
|
|
712
|
+
const currentFilePath = `${path5__namespace.default.join("ontology", "actions", `${action.shortApiName}.ts`)}`;
|
|
713
|
+
const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.og);
|
|
2200
714
|
const uniqueApiNames = new Set(uniqueApiNamesArray);
|
|
2201
|
-
const uniqueApiNamesString =
|
|
715
|
+
const uniqueApiNamesString = stringUnionFrom([...uniqueApiNames]);
|
|
2202
716
|
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action.og));
|
|
2203
717
|
const {
|
|
2204
718
|
parameters,
|
|
@@ -2321,7 +835,7 @@ async function generatePerActionDataFiles({
|
|
|
2321
835
|
}
|
|
2322
836
|
}
|
|
2323
837
|
const imports = getObjectImports(referencedObjectDefs, void 0, currentFilePath, true);
|
|
2324
|
-
await fs2.writeFile(
|
|
838
|
+
await fs2.writeFile(path5__namespace.default.join(rootOutDir, currentFilePath), await formatTs(`
|
|
2325
839
|
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound} from "@osdk/api";
|
|
2326
840
|
import type { ApplyActionOptions, ApplyBatchActionOptions, ActionReturnTypeForOptions, ActionParam } from '@osdk/client.api';
|
|
2327
841
|
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
@@ -2334,8 +848,8 @@ async function generatePerActionDataFiles({
|
|
|
2334
848
|
${createV2Object()}
|
|
2335
849
|
`));
|
|
2336
850
|
}));
|
|
2337
|
-
const indexFileRelPath =
|
|
2338
|
-
await fs2.writeFile(
|
|
851
|
+
const indexFileRelPath = path5__namespace.default.join("ontology", "actions.ts");
|
|
852
|
+
await fs2.writeFile(path5__namespace.default.join(rootOutDir, indexFileRelPath), await formatTs(`
|
|
2339
853
|
${Object.values(enhancedOntology.actionTypes).map((action) => {
|
|
2340
854
|
const exportConstLine = `export {${action.shortApiName} } from "${action.getImportPathRelTo(indexFileRelPath)}";`;
|
|
2341
855
|
return exportConstLine;
|
|
@@ -2343,11 +857,11 @@ async function generatePerActionDataFiles({
|
|
|
2343
857
|
${Object.keys(ontology.actionTypes).length === 0 ? "export {};" : ""}
|
|
2344
858
|
`));
|
|
2345
859
|
}
|
|
2346
|
-
function
|
|
860
|
+
function extractReferencedObjectsFromAction(actionType) {
|
|
2347
861
|
const referencedObjectsInParameters = Object.values(actionType.parameters).flatMap(({
|
|
2348
862
|
dataType
|
|
2349
863
|
}) => {
|
|
2350
|
-
const objectTypeReference =
|
|
864
|
+
const objectTypeReference = extractReferencedObjectsFromActionParameter(dataType);
|
|
2351
865
|
return objectTypeReference ? [objectTypeReference] : [];
|
|
2352
866
|
});
|
|
2353
867
|
const referenceObjectsInEdits = actionType.operations.flatMap((value) => {
|
|
@@ -2364,13 +878,13 @@ function extractReferencedObjectsFromAction2(actionType) {
|
|
|
2364
878
|
});
|
|
2365
879
|
return [...referenceObjectsInEdits, ...referencedObjectsInParameters];
|
|
2366
880
|
}
|
|
2367
|
-
function
|
|
881
|
+
function extractReferencedObjectsFromActionParameter(actionParameter) {
|
|
2368
882
|
switch (actionParameter.type) {
|
|
2369
883
|
case "objectSet":
|
|
2370
884
|
case "object":
|
|
2371
885
|
return actionParameter.objectTypeApiName;
|
|
2372
886
|
case "array":
|
|
2373
|
-
return
|
|
887
|
+
return extractReferencedObjectsFromActionParameter(actionParameter.subType);
|
|
2374
888
|
case "string":
|
|
2375
889
|
case "boolean":
|
|
2376
890
|
case "attachment":
|
|
@@ -2382,14 +896,222 @@ function extractReferencedObjectsFromActionParameter2(actionParameter) {
|
|
|
2382
896
|
return void 0;
|
|
2383
897
|
}
|
|
2384
898
|
}
|
|
899
|
+
|
|
900
|
+
// src/shared/getObjectTypesFromQueryDataType.ts
|
|
901
|
+
function getObjectTypesFromQueryDataType(dataType, types) {
|
|
902
|
+
switch (dataType.type) {
|
|
903
|
+
case "array":
|
|
904
|
+
case "set":
|
|
905
|
+
getObjectTypesFromQueryDataType(dataType.subType, types);
|
|
906
|
+
return;
|
|
907
|
+
case "object":
|
|
908
|
+
types.add(dataType.objectTypeApiName);
|
|
909
|
+
return;
|
|
910
|
+
case "objectSet":
|
|
911
|
+
types.add(dataType.objectTypeApiName);
|
|
912
|
+
return;
|
|
913
|
+
case "struct":
|
|
914
|
+
for (const prop of Object.values(dataType.fields)) {
|
|
915
|
+
getObjectTypesFromQueryDataType(prop.fieldType, types);
|
|
916
|
+
}
|
|
917
|
+
return;
|
|
918
|
+
case "union":
|
|
919
|
+
for (const type of dataType.unionTypes) {
|
|
920
|
+
getObjectTypesFromQueryDataType(type, types);
|
|
921
|
+
}
|
|
922
|
+
return;
|
|
923
|
+
case "attachment":
|
|
924
|
+
case "boolean":
|
|
925
|
+
case "date":
|
|
926
|
+
case "double":
|
|
927
|
+
case "float":
|
|
928
|
+
case "integer":
|
|
929
|
+
case "long":
|
|
930
|
+
case "null":
|
|
931
|
+
case "string":
|
|
932
|
+
case "threeDimensionalAggregation":
|
|
933
|
+
case "timestamp":
|
|
934
|
+
case "twoDimensionalAggregation":
|
|
935
|
+
case "unsupported":
|
|
936
|
+
return;
|
|
937
|
+
default:
|
|
938
|
+
throw new Error(`Cannot find object types from unsupported QueryDataType ${dataType.type}`);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// src/shared/getObjectTypeApiNamesFromQuery.ts
|
|
943
|
+
function getObjectTypeApiNamesFromQuery(query) {
|
|
944
|
+
const types = /* @__PURE__ */ new Set();
|
|
945
|
+
for (const {
|
|
946
|
+
dataType
|
|
947
|
+
} of Object.values(query.parameters)) {
|
|
948
|
+
getObjectTypesFromQueryDataType(dataType, types);
|
|
949
|
+
}
|
|
950
|
+
getObjectTypesFromQueryDataType(query.output, types);
|
|
951
|
+
return Array.from(types);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// src/shared/isNullableQueryDataType.ts
|
|
955
|
+
function isNullableQueryDataType(input) {
|
|
956
|
+
if (input.type === "null") {
|
|
957
|
+
return true;
|
|
958
|
+
}
|
|
959
|
+
if (input.type === "union") {
|
|
960
|
+
return input.unionTypes.some((t) => isNullableQueryDataType(t));
|
|
961
|
+
}
|
|
962
|
+
return false;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// src/shared/wireQueryDataTypeToQueryDataTypeDefinition.ts
|
|
966
|
+
function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
967
|
+
switch (input.type) {
|
|
968
|
+
case "double":
|
|
969
|
+
case "float":
|
|
970
|
+
case "integer":
|
|
971
|
+
case "long":
|
|
972
|
+
case "attachment":
|
|
973
|
+
case "boolean":
|
|
974
|
+
case "date":
|
|
975
|
+
case "string":
|
|
976
|
+
case "timestamp":
|
|
977
|
+
return {
|
|
978
|
+
type: input.type,
|
|
979
|
+
nullable: false
|
|
980
|
+
};
|
|
981
|
+
case "object":
|
|
982
|
+
return {
|
|
983
|
+
type: "object",
|
|
984
|
+
object: input.objectTypeApiName,
|
|
985
|
+
nullable: false
|
|
986
|
+
};
|
|
987
|
+
case "objectSet":
|
|
988
|
+
return {
|
|
989
|
+
type: "objectSet",
|
|
990
|
+
objectSet: input.objectTypeApiName,
|
|
991
|
+
nullable: false
|
|
992
|
+
};
|
|
993
|
+
case "array":
|
|
994
|
+
return {
|
|
995
|
+
...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
|
|
996
|
+
multiplicity: true
|
|
997
|
+
};
|
|
998
|
+
case "set":
|
|
999
|
+
return {
|
|
1000
|
+
type: "set",
|
|
1001
|
+
set: wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
|
|
1002
|
+
nullable: false
|
|
1003
|
+
};
|
|
1004
|
+
case "union":
|
|
1005
|
+
const allowNulls = isNullableQueryDataType(input);
|
|
1006
|
+
if (allowNulls && input.unionTypes.length === 2) {
|
|
1007
|
+
const nonNull = input.unionTypes.find((t) => t.type != null);
|
|
1008
|
+
if (nonNull) {
|
|
1009
|
+
return {
|
|
1010
|
+
...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),
|
|
1011
|
+
nullable: true
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
return {
|
|
1016
|
+
type: "union",
|
|
1017
|
+
union: input.unionTypes.reduce((acc, t) => {
|
|
1018
|
+
if (t.type === "null") {
|
|
1019
|
+
return acc;
|
|
1020
|
+
}
|
|
1021
|
+
acc.push(wireQueryDataTypeToQueryDataTypeDefinition(t));
|
|
1022
|
+
return acc;
|
|
1023
|
+
}, []),
|
|
1024
|
+
nullable: allowNulls
|
|
1025
|
+
};
|
|
1026
|
+
case "struct":
|
|
1027
|
+
return {
|
|
1028
|
+
type: "struct",
|
|
1029
|
+
struct: Object.fromEntries(input.fields.map((f) => [f.name, wireQueryDataTypeToQueryDataTypeDefinition(f.fieldType)])),
|
|
1030
|
+
nullable: false
|
|
1031
|
+
};
|
|
1032
|
+
case "twoDimensionalAggregation":
|
|
1033
|
+
return {
|
|
1034
|
+
type: "twoDimensionalAggregation",
|
|
1035
|
+
twoDimensionalAggregation: get2DQueryAggregationProps(input),
|
|
1036
|
+
nullable: false
|
|
1037
|
+
};
|
|
1038
|
+
case "threeDimensionalAggregation":
|
|
1039
|
+
return {
|
|
1040
|
+
type: "threeDimensionalAggregation",
|
|
1041
|
+
threeDimensionalAggregation: get3DQueryAggregationProps(input),
|
|
1042
|
+
nullable: false
|
|
1043
|
+
};
|
|
1044
|
+
case "null":
|
|
1045
|
+
case "unsupported":
|
|
1046
|
+
throw new Error(`Accidentally tried to handle QueryDataType.type ${input.type}`);
|
|
1047
|
+
default:
|
|
1048
|
+
throw new Error(`Unsupported QueryDataType.type ${input.type}`);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
function get2DQueryAggregationProps(input) {
|
|
1052
|
+
if (input.keyType.type === "range") {
|
|
1053
|
+
return {
|
|
1054
|
+
keyType: input.keyType.type,
|
|
1055
|
+
keySubtype: input.keyType.subType.type,
|
|
1056
|
+
valueType: input.valueType.type
|
|
1057
|
+
};
|
|
1058
|
+
} else {
|
|
1059
|
+
if (guardInvalidKeyTypes(input.keyType)) {
|
|
1060
|
+
return {
|
|
1061
|
+
keyType: input.keyType.type,
|
|
1062
|
+
valueType: input.valueType.type
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
throw new Error(`Cannot create 2D aggregation with ${input.keyType.type} as its type`);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
function get3DQueryAggregationProps(input) {
|
|
1069
|
+
if (input.keyType.type === "range") {
|
|
1070
|
+
return {
|
|
1071
|
+
keyType: input.keyType.type,
|
|
1072
|
+
keySubtype: input.keyType.subType.type,
|
|
1073
|
+
valueType: get2DQueryAggregationProps(input.valueType)
|
|
1074
|
+
};
|
|
1075
|
+
} else {
|
|
1076
|
+
if (guardInvalidKeyTypes(input.keyType)) {
|
|
1077
|
+
return {
|
|
1078
|
+
keyType: input.keyType.type,
|
|
1079
|
+
valueType: get2DQueryAggregationProps(input.valueType)
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
throw new Error(`Cannot create 3D aggregation with ${input.keyType.type} as its type`);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
function guardInvalidKeyTypes(key) {
|
|
1086
|
+
return key.type === "string" || key.type === "boolean";
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
// src/shared/wireQueryTypeV2ToSdkQueryDefinition.ts
|
|
1090
|
+
function wireQueryTypeV2ToSdkQueryDefinitionNoParams(input) {
|
|
1091
|
+
return {
|
|
1092
|
+
type: "query",
|
|
1093
|
+
apiName: input.apiName,
|
|
1094
|
+
description: input.description,
|
|
1095
|
+
displayName: input.displayName,
|
|
1096
|
+
version: input.version
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
1100
|
+
return {
|
|
1101
|
+
description: parameter.description,
|
|
1102
|
+
...wireQueryDataTypeToQueryDataTypeDefinition(parameter.dataType)
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
// src/v2.0/generatePerQueryDataFiles.ts
|
|
2385
1107
|
async function generatePerQueryDataFilesV2({
|
|
2386
1108
|
fs: fs2,
|
|
2387
1109
|
outDir: rootOutDir,
|
|
2388
1110
|
ontology,
|
|
2389
1111
|
importExt = ""
|
|
2390
1112
|
}, v2) {
|
|
2391
|
-
const relOutDir =
|
|
2392
|
-
const outDir =
|
|
1113
|
+
const relOutDir = path5__namespace.default.join(".", "ontology", "queries");
|
|
1114
|
+
const outDir = path5__namespace.default.join(rootOutDir, "ontology", "queries");
|
|
2393
1115
|
await fs2.mkdir(outDir, {
|
|
2394
1116
|
recursive: true
|
|
2395
1117
|
});
|
|
@@ -2403,13 +1125,13 @@ async function generatePerQueryDataFilesV2({
|
|
|
2403
1125
|
`));
|
|
2404
1126
|
}
|
|
2405
1127
|
async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ontology) {
|
|
2406
|
-
const relFilePath =
|
|
1128
|
+
const relFilePath = path5__namespace.default.join(relOutDir, `${query.shortApiName}.ts`);
|
|
2407
1129
|
const objectTypes = getObjectTypeApiNamesFromQuery(query);
|
|
2408
1130
|
const importObjects = getObjectImports2(ontology, objectTypes, relFilePath);
|
|
2409
1131
|
const baseProps = deleteUndefineds(wireQueryTypeV2ToSdkQueryDefinitionNoParams(query.og));
|
|
2410
1132
|
const outputBase = deleteUndefineds(wireQueryDataTypeToQueryDataTypeDefinition(query.output));
|
|
2411
1133
|
const referencedObjectTypes = objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never";
|
|
2412
|
-
await fs2.writeFile(
|
|
1134
|
+
await fs2.writeFile(path5__namespace.default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
2413
1135
|
import type { QueryDefinition , VersionBound} from "@osdk/api";
|
|
2414
1136
|
import type { QueryParam, QueryResult } from "@osdk/client.api";
|
|
2415
1137
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
@@ -2715,11 +1437,15 @@ async function generateRootIndexTsFile({
|
|
|
2715
1437
|
importExt,
|
|
2716
1438
|
ontologyApiNamespace
|
|
2717
1439
|
}) {
|
|
2718
|
-
fs2.writeFile(
|
|
1440
|
+
fs2.writeFile(path5__namespace.default.join(outDir, "index.ts"), await formatTs(`${ontologyApiNamespace == null ? `export { $ontologyRid } from "./OntologyMetadata${importExt}";` : ``}
|
|
2719
1441
|
export * from "./ontology/actions${importExt}";
|
|
1442
|
+
export * as $Actions from "./ontology/actions${importExt}";
|
|
2720
1443
|
export * from "./ontology/objects${importExt}";
|
|
1444
|
+
export * as $Objects from "./ontology/objects${importExt}";
|
|
2721
1445
|
export * from "./ontology/interfaces${importExt}";
|
|
1446
|
+
export * as $Interfaces from "./ontology/interfaces${importExt}";
|
|
2722
1447
|
export * from "./ontology/queries${importExt}";
|
|
1448
|
+
export * as $Queries from "./ontology/queries${importExt}";
|
|
2723
1449
|
`));
|
|
2724
1450
|
}
|
|
2725
1451
|
async function generateEachObjectFile(ctx) {
|
|
@@ -2729,12 +1455,12 @@ async function generateEachObjectFile(ctx) {
|
|
|
2729
1455
|
ontology,
|
|
2730
1456
|
importExt
|
|
2731
1457
|
} = ctx;
|
|
2732
|
-
await fs2.mkdir(
|
|
1458
|
+
await fs2.mkdir(path5__namespace.default.join(outDir, "ontology", "objects"), {
|
|
2733
1459
|
recursive: true
|
|
2734
1460
|
});
|
|
2735
1461
|
for (const obj of Object.values(ontology.objectTypes)) {
|
|
2736
|
-
const relPath =
|
|
2737
|
-
const outFilePath =
|
|
1462
|
+
const relPath = path5__namespace.default.join(".", "ontology", `objects`, `${obj.shortApiName}.ts`);
|
|
1463
|
+
const outFilePath = path5__namespace.default.join(outDir, relPath);
|
|
2738
1464
|
await fs2.writeFile(outFilePath, await formatTs(`
|
|
2739
1465
|
import type { VersionBound as $VersionBound, PropertyDef as $PropertyDef } from "@osdk/api";
|
|
2740
1466
|
import type { Osdk } from "@osdk/client.api";
|
|
@@ -2765,12 +1491,12 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
2765
1491
|
await generateOntologyMetadataFile(ctx, userAgent);
|
|
2766
1492
|
await generateEachObjectFile(ctx);
|
|
2767
1493
|
await generateOntologyInterfaces(ctx);
|
|
2768
|
-
const actionsDir =
|
|
1494
|
+
const actionsDir = path5__namespace.default.join(outDir, "ontology", "actions");
|
|
2769
1495
|
await fs2.mkdir(actionsDir, {
|
|
2770
1496
|
recursive: true
|
|
2771
1497
|
});
|
|
2772
1498
|
await generatePerActionDataFiles(ctx);
|
|
2773
|
-
await fs2.writeFile(
|
|
1499
|
+
await fs2.writeFile(path5__namespace.default.join(outDir, "ontology", "objects.ts"), await formatTs(`
|
|
2774
1500
|
${Object.values(enhancedOntology.objectTypes).map((objType) => `export * from "./objects/${objType.shortApiName}${importExt}";`).join("\n")}
|
|
2775
1501
|
${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
|
|
2776
1502
|
`));
|
|
@@ -2782,12 +1508,12 @@ async function generateOntologyInterfaces({
|
|
|
2782
1508
|
ontology,
|
|
2783
1509
|
importExt
|
|
2784
1510
|
}) {
|
|
2785
|
-
const interfacesDir =
|
|
1511
|
+
const interfacesDir = path5__namespace.default.join(outDir, "ontology", "interfaces");
|
|
2786
1512
|
await fs2.mkdir(interfacesDir, {
|
|
2787
1513
|
recursive: true
|
|
2788
1514
|
});
|
|
2789
1515
|
for (const obj of Object.values(ontology.interfaceTypes)) {
|
|
2790
|
-
await fs2.writeFile(
|
|
1516
|
+
await fs2.writeFile(path5__namespace.default.join(interfacesDir, `${obj.shortApiName}.ts`), await formatTs(`
|
|
2791
1517
|
|
|
2792
1518
|
import type { PropertyDef as $PropertyDef, VersionBound as $VersionBound } from "@osdk/api";
|
|
2793
1519
|
import { $osdkMetadata, $expectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
@@ -2803,26 +1529,29 @@ async function generateOntologyInterfaces({
|
|
|
2803
1529
|
|
|
2804
1530
|
// src/generateClientSdkPackage.ts
|
|
2805
1531
|
async function generateClientSdkPackage(packageName, packageVersion, sdkVersion, baseOutDir, ontology, minimalFs, dependencyVersions, cliVersion, ontologyApiNamespace, apiNamespacePackageMap) {
|
|
2806
|
-
if (!packageName) throw new Error("Package name is
|
|
1532
|
+
if (!packageName) throw new Error("Package name is required");
|
|
1533
|
+
if (sdkVersion === "1.1") {
|
|
1534
|
+
throw new Error("This generator version does not support generating v1 sdks");
|
|
1535
|
+
}
|
|
2807
1536
|
for (const packageType of ["module", "commonjs"]) {
|
|
2808
|
-
const outDir =
|
|
2809
|
-
|
|
1537
|
+
const outDir = path5__namespace.join(baseOutDir, "dist", packageType);
|
|
1538
|
+
generateClientSdkVersionTwoPointZero(ontology, `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`, minimalFs, outDir, packageType, ontologyApiNamespace, apiNamespacePackageMap);
|
|
2810
1539
|
await fs__namespace.promises.mkdir(outDir, {
|
|
2811
1540
|
recursive: true
|
|
2812
1541
|
});
|
|
2813
|
-
await writeJson(minimalFs,
|
|
1542
|
+
await writeJson(minimalFs, path5__namespace.join(outDir, "package.json"), {
|
|
2814
1543
|
type: packageType
|
|
2815
1544
|
});
|
|
2816
|
-
await writeJson(minimalFs,
|
|
1545
|
+
await writeJson(minimalFs, path5__namespace.join(outDir, `tsconfig.json`), {
|
|
2817
1546
|
compilerOptions: getTsCompilerOptions(packageType)
|
|
2818
1547
|
});
|
|
2819
1548
|
}
|
|
2820
|
-
await writeJson(minimalFs,
|
|
2821
|
-
await minimalFs.mkdir(
|
|
1549
|
+
await writeJson(minimalFs, path5__namespace.join(baseOutDir, "package.json"), await getPackageJsonContents(packageName, packageVersion, dependencyVersions));
|
|
1550
|
+
await minimalFs.mkdir(path5__namespace.join(baseOutDir, "ontology"), {
|
|
2822
1551
|
recursive: true
|
|
2823
1552
|
});
|
|
2824
|
-
await minimalFs.writeFile(
|
|
2825
|
-
await minimalFs.writeFile(
|
|
1553
|
+
await minimalFs.writeFile(path5__namespace.join(baseOutDir, "ontology", "objects.js"), `module.exports = require("../../dist/module/ontology/objects")`);
|
|
1554
|
+
await minimalFs.writeFile(path5__namespace.join(baseOutDir, "ontology", "objects.d.ts"), `export * from "../dist/module/ontology/objects"`);
|
|
2826
1555
|
}
|
|
2827
1556
|
function getTsCompilerOptions(packageType) {
|
|
2828
1557
|
const commonTsconfig = {
|
|
@@ -2845,39 +1574,30 @@ function getTsCompilerOptions(packageType) {
|
|
|
2845
1574
|
};
|
|
2846
1575
|
return compilerOptions;
|
|
2847
1576
|
}
|
|
2848
|
-
function getExpectedDependencies(
|
|
1577
|
+
function getExpectedDependencies({
|
|
2849
1578
|
osdkApiVersion,
|
|
2850
1579
|
osdkClientVersion,
|
|
2851
|
-
osdkClientApiVersion
|
|
2852
|
-
osdkLegacyClientVersion
|
|
1580
|
+
osdkClientApiVersion
|
|
2853
1581
|
}) {
|
|
2854
1582
|
return {
|
|
2855
1583
|
devDependencies: {
|
|
2856
1584
|
"@osdk/api": osdkApiVersion,
|
|
2857
|
-
|
|
2858
|
-
"@osdk/client.api": osdkClientApiVersion
|
|
2859
|
-
} : {
|
|
2860
|
-
"@osdk/legacy-client": osdkLegacyClientVersion
|
|
2861
|
-
}
|
|
1585
|
+
"@osdk/client.api": osdkClientApiVersion
|
|
2862
1586
|
},
|
|
2863
1587
|
peerDependencies: {
|
|
2864
1588
|
"@osdk/api": osdkApiVersion,
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
"@osdk/client": osdkClientVersion
|
|
2868
|
-
} : {
|
|
2869
|
-
"@osdk/legacy-client": osdkLegacyClientVersion
|
|
2870
|
-
}
|
|
1589
|
+
"@osdk/client.api": osdkClientApiVersion,
|
|
1590
|
+
"@osdk/client": osdkClientVersion
|
|
2871
1591
|
}
|
|
2872
1592
|
};
|
|
2873
1593
|
}
|
|
2874
|
-
function getExpectedDependenciesFull(
|
|
1594
|
+
function getExpectedDependenciesFull(dependencyVersions) {
|
|
2875
1595
|
const {
|
|
2876
1596
|
typescriptVersion,
|
|
2877
1597
|
tslibVersion,
|
|
2878
1598
|
areTheTypesWrongVersion
|
|
2879
1599
|
} = dependencyVersions;
|
|
2880
|
-
const base = getExpectedDependencies(
|
|
1600
|
+
const base = getExpectedDependencies(dependencyVersions);
|
|
2881
1601
|
return {
|
|
2882
1602
|
devDependencies: {
|
|
2883
1603
|
...base.devDependencies,
|
|
@@ -2890,7 +1610,7 @@ function getExpectedDependenciesFull(sdkVersion, dependencyVersions) {
|
|
|
2890
1610
|
}
|
|
2891
1611
|
};
|
|
2892
1612
|
}
|
|
2893
|
-
function getPackageJsonContents(name, version,
|
|
1613
|
+
function getPackageJsonContents(name, version, dependencyVersions) {
|
|
2894
1614
|
const esmPrefix = "./dist/module";
|
|
2895
1615
|
const commonjsPrefix = "./dist/commonjs";
|
|
2896
1616
|
return {
|
|
@@ -2902,17 +1622,13 @@ function getPackageJsonContents(name, version, sdkVersion, dependencyVersions) {
|
|
|
2902
1622
|
".": {
|
|
2903
1623
|
import: `${esmPrefix}/index.js`,
|
|
2904
1624
|
require: `${commonjsPrefix}/index.js`
|
|
2905
|
-
},
|
|
2906
|
-
"./ontology/objects": {
|
|
2907
|
-
import: `${esmPrefix}/ontology/objects${sdkVersion === "2.0" ? "" : "/index"}.js`,
|
|
2908
|
-
require: `${commonjsPrefix}/ontology/objects${sdkVersion === "2.0" ? "" : "/index"}.js`
|
|
2909
1625
|
}
|
|
2910
1626
|
},
|
|
2911
1627
|
scripts: {
|
|
2912
1628
|
prepack: `tsc -p ${esmPrefix}/tsconfig.json && tsc -p ${commonjsPrefix}/tsconfig.json`,
|
|
2913
1629
|
check: "npm exec attw $(npm pack)"
|
|
2914
1630
|
},
|
|
2915
|
-
...getExpectedDependenciesFull(
|
|
1631
|
+
...getExpectedDependenciesFull(dependencyVersions),
|
|
2916
1632
|
files: ["**/*.js", "**/*.d.ts", "dist/**/package.json"]
|
|
2917
1633
|
};
|
|
2918
1634
|
}
|
|
@@ -2921,7 +1637,6 @@ async function writeJson(minimalFs, filePath, body) {
|
|
|
2921
1637
|
}
|
|
2922
1638
|
|
|
2923
1639
|
exports.__UNSTABLE_generateClientSdkPackage = generateClientSdkPackage;
|
|
2924
|
-
exports.generateClientSdkVersionOneDotOne = generateClientSdkVersionOneDotOne;
|
|
2925
1640
|
exports.generateClientSdkVersionTwoPointZero = generateClientSdkVersionTwoPointZero;
|
|
2926
1641
|
exports.getExpectedDependencies = getExpectedDependencies;
|
|
2927
1642
|
//# sourceMappingURL=index.cjs.map
|