@osdk/generator 1.14.0-beta.4 → 2.0.0-beta.7
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 +31 -0
- package/build/browser/index.js +393 -1743
- package/build/browser/index.js.map +1 -1
- package/build/cjs/GenerateContext/EnhancedAction.d.cts +5 -5
- package/build/cjs/GenerateContext/EnhancedAction.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedBase.d.cts +2 -2
- package/build/cjs/GenerateContext/EnhancedBase.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedInterfaceType.d.cts +4 -4
- package/build/cjs/GenerateContext/EnhancedInterfaceType.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedObjectType.d.cts +3 -3
- package/build/cjs/GenerateContext/EnhancedObjectType.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedOntologyDefinition.d.cts +7 -7
- package/build/cjs/GenerateContext/EnhancedOntologyDefinition.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedQuery.d.cts +5 -5
- package/build/cjs/GenerateContext/EnhancedQuery.d.ts.map +1 -1
- package/build/cjs/GenerateContext/EnhancedSharedPropertyType.d.cts +3 -3
- package/build/cjs/GenerateContext/EnhancedSharedPropertyType.d.ts.map +1 -1
- package/build/cjs/WireOntologyDefinition.d.cts +2 -2
- package/build/cjs/WireOntologyDefinition.d.ts.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 +392 -1744
- 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/shared/getEditedEntities.d.cts +1 -1
- package/build/cjs/shared/getEditedEntities.d.ts.map +1 -1
- package/build/cjs/shared/getObjectImports.d.ts.map +1 -1
- package/build/cjs/shared/getObjectTypeApiNamesFromQuery.d.cts +1 -1
- package/build/cjs/shared/getObjectTypeApiNamesFromQuery.d.ts.map +1 -1
- package/build/cjs/shared/getObjectTypesFromQueryDataType.d.cts +1 -1
- package/build/cjs/shared/getObjectTypesFromQueryDataType.d.ts.map +1 -1
- package/build/cjs/shared/isNullableQueryDataType.d.cts +1 -1
- package/build/cjs/shared/isNullableQueryDataType.d.ts.map +1 -1
- package/build/cjs/shared/wireActionTypeV2ToSdkActionDefinition.d.cts +1 -1
- package/build/cjs/shared/wireActionTypeV2ToSdkActionDefinition.d.ts.map +1 -1
- package/build/cjs/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.cts +1 -1
- package/build/cjs/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map +1 -1
- package/build/cjs/shared/wireQueryTypeV2ToSdkQueryDefinition.d.cts +4 -4
- package/build/cjs/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts.map +1 -1
- package/build/cjs/util/test/TodoWireOntology.d.cts +14 -0
- package/build/cjs/util/test/TodoWireOntology.d.ts.map +1 -1
- package/build/cjs/util/test/formatTs.d.ts.map +1 -1
- package/build/cjs/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/cjs/v2.0/generatePerActionDataFiles.d.ts.map +1 -1
- package/build/cjs/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/cjs/v2.0/getDescriptionIfPresent.d.cts +2 -0
- package/build/cjs/v2.0/getDescriptionIfPresent.d.ts.map +1 -0
- package/build/cjs/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedAction.d.ts +5 -5
- package/build/esm/GenerateContext/EnhancedAction.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedBase.d.ts +2 -2
- package/build/esm/GenerateContext/EnhancedBase.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedInterfaceType.d.ts +4 -4
- package/build/esm/GenerateContext/EnhancedInterfaceType.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedObjectType.d.ts +3 -3
- package/build/esm/GenerateContext/EnhancedObjectType.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.d.ts +7 -7
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedQuery.d.ts +5 -5
- package/build/esm/GenerateContext/EnhancedQuery.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedSharedPropertyType.d.ts +3 -3
- package/build/esm/GenerateContext/EnhancedSharedPropertyType.d.ts.map +1 -1
- package/build/esm/WireOntologyDefinition.d.ts +2 -2
- package/build/esm/WireOntologyDefinition.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 +393 -1743
- package/build/esm/index.js.map +1 -1
- package/build/esm/shared/getEditedEntities.d.ts +1 -1
- package/build/esm/shared/getEditedEntities.d.ts.map +1 -1
- package/build/esm/shared/getObjectImports.d.ts.map +1 -1
- package/build/esm/shared/getObjectTypeApiNamesFromQuery.d.ts +1 -1
- package/build/esm/shared/getObjectTypeApiNamesFromQuery.d.ts.map +1 -1
- package/build/esm/shared/getObjectTypesFromQueryDataType.d.ts +1 -1
- package/build/esm/shared/getObjectTypesFromQueryDataType.d.ts.map +1 -1
- package/build/esm/shared/isNullableQueryDataType.d.ts +1 -1
- package/build/esm/shared/isNullableQueryDataType.d.ts.map +1 -1
- package/build/esm/shared/wireActionTypeV2ToSdkActionDefinition.d.ts +1 -1
- package/build/esm/shared/wireActionTypeV2ToSdkActionDefinition.d.ts.map +1 -1
- package/build/esm/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts +1 -1
- package/build/esm/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map +1 -1
- package/build/esm/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts +4 -4
- package/build/esm/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts.map +1 -1
- package/build/esm/util/test/TodoWireOntology.d.ts +14 -0
- package/build/esm/util/test/TodoWireOntology.d.ts.map +1 -1
- package/build/esm/util/test/formatTs.d.ts.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/esm/v2.0/generatePerActionDataFiles.d.ts.map +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/esm/v2.0/getDescriptionIfPresent.d.ts +2 -0
- package/build/esm/v2.0/getDescriptionIfPresent.d.ts.map +1 -0
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/package.json +6 -7
- 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.d.cts +0 -4
- package/build/cjs/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.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.d.ts +0 -4
- package/build/esm/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.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/esm/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
2
|
+
import * as path5 from 'path';
|
|
3
|
+
import path5__default from 'path';
|
|
4
4
|
import { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition, wireObjectTypeFullMetadataToSdkObjectTypeDefinition } from '@osdk/generator-converters';
|
|
5
5
|
import { format } from 'prettier';
|
|
6
|
-
import organizeImports from 'prettier-plugin-organize-imports';
|
|
7
6
|
import fastDeepEqual from 'fast-deep-equal';
|
|
8
7
|
import invariant from 'tiny-invariant';
|
|
9
8
|
|
|
@@ -29,7 +28,7 @@ var AbstractImportable = class {
|
|
|
29
28
|
}
|
|
30
29
|
getImportPathRelTo = (filePath) => {
|
|
31
30
|
if (this.importPath.startsWith(".")) {
|
|
32
|
-
const result =
|
|
31
|
+
const result = path5.relative(path5.dirname(filePath), this.importPath);
|
|
33
32
|
if (result.startsWith(".")) {
|
|
34
33
|
return result;
|
|
35
34
|
} else {
|
|
@@ -41,9 +40,9 @@ var AbstractImportable = class {
|
|
|
41
40
|
};
|
|
42
41
|
};
|
|
43
42
|
var EnhancedBase = class extends AbstractImportable {
|
|
44
|
-
constructor(common,
|
|
43
|
+
constructor(common, raw, fullApiName, basePath) {
|
|
45
44
|
super(common, fullApiName, basePath);
|
|
46
|
-
this.
|
|
45
|
+
this.raw = raw;
|
|
47
46
|
if (!this.isLocal && !this.sourcePackage) {
|
|
48
47
|
throw new Error(`Expected { ns:'${this.apiNamespace}', shortName: '${this.shortApiName}'} to be in namespace '${common.ontologyApiNamespace}' or in a provided package mapping`);
|
|
49
48
|
}
|
|
@@ -57,18 +56,18 @@ function extractNamespace(fqApiName) {
|
|
|
57
56
|
|
|
58
57
|
// src/GenerateContext/EnhancedAction.ts
|
|
59
58
|
var EnhancedAction = class extends EnhancedBase {
|
|
60
|
-
constructor(common,
|
|
61
|
-
super(common,
|
|
62
|
-
this.
|
|
59
|
+
constructor(common, raw) {
|
|
60
|
+
super(common, raw, raw.apiName, "./ontology/actions");
|
|
61
|
+
this.raw = raw;
|
|
63
62
|
}
|
|
64
63
|
get description() {
|
|
65
|
-
return this.
|
|
64
|
+
return this.raw.description;
|
|
66
65
|
}
|
|
67
66
|
get parameters() {
|
|
68
|
-
return this.
|
|
67
|
+
return this.raw.parameters;
|
|
69
68
|
}
|
|
70
69
|
get operations() {
|
|
71
|
-
return this.
|
|
70
|
+
return this.raw.operations;
|
|
72
71
|
}
|
|
73
72
|
get paramsIdentifier() {
|
|
74
73
|
return `${this.shortApiName}.Params`;
|
|
@@ -88,9 +87,9 @@ function deleteUndefineds(obj) {
|
|
|
88
87
|
|
|
89
88
|
// src/GenerateContext/EnhancedInterfaceType.ts
|
|
90
89
|
var EnhancedInterfaceType = class extends EnhancedBase {
|
|
91
|
-
constructor(common,
|
|
92
|
-
super(common,
|
|
93
|
-
this.
|
|
90
|
+
constructor(common, raw) {
|
|
91
|
+
super(common, raw, raw.apiName, "./ontology/interfaces");
|
|
92
|
+
this.raw = raw;
|
|
94
93
|
}
|
|
95
94
|
getDefinitionIdentifier(v2) {
|
|
96
95
|
return v2 ? this.shortApiName : `${this.shortApiName}Def`;
|
|
@@ -99,16 +98,16 @@ var EnhancedInterfaceType = class extends EnhancedBase {
|
|
|
99
98
|
return this.getDefinitionIdentifier(v2);
|
|
100
99
|
}
|
|
101
100
|
get properties() {
|
|
102
|
-
return this.
|
|
101
|
+
return this.raw.properties;
|
|
103
102
|
}
|
|
104
103
|
getCleanedUpDefinition(v2) {
|
|
105
|
-
return deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(this.
|
|
104
|
+
return deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(this.raw, v2));
|
|
106
105
|
}
|
|
107
106
|
};
|
|
108
107
|
var EnhancedObjectType = class extends EnhancedBase {
|
|
109
|
-
constructor(common,
|
|
110
|
-
super(common,
|
|
111
|
-
this.
|
|
108
|
+
constructor(common, raw) {
|
|
109
|
+
super(common, raw, raw.objectType.apiName, "./ontology/objects");
|
|
110
|
+
this.raw = raw;
|
|
112
111
|
}
|
|
113
112
|
getDefinitionIdentifier(v2) {
|
|
114
113
|
return v2 ? `${this.shortApiName}` : `${this.shortApiName}Def`;
|
|
@@ -117,24 +116,24 @@ var EnhancedObjectType = class extends EnhancedBase {
|
|
|
117
116
|
return this.getDefinitionIdentifier(v2);
|
|
118
117
|
}
|
|
119
118
|
getCleanedUpDefinition(v2) {
|
|
120
|
-
return deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(this.
|
|
119
|
+
return deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(this.raw, v2));
|
|
121
120
|
}
|
|
122
121
|
};
|
|
123
122
|
|
|
124
123
|
// src/GenerateContext/EnhancedQuery.ts
|
|
125
124
|
var EnhancedQuery = class extends EnhancedBase {
|
|
126
|
-
constructor(common,
|
|
127
|
-
super(common,
|
|
128
|
-
this.
|
|
125
|
+
constructor(common, raw) {
|
|
126
|
+
super(common, raw, raw.apiName, "./ontology/queries");
|
|
127
|
+
this.raw = raw;
|
|
129
128
|
}
|
|
130
129
|
get description() {
|
|
131
|
-
return this.
|
|
130
|
+
return this.raw.description;
|
|
132
131
|
}
|
|
133
132
|
get parameters() {
|
|
134
|
-
return this.
|
|
133
|
+
return this.raw.parameters;
|
|
135
134
|
}
|
|
136
135
|
get output() {
|
|
137
|
-
return this.
|
|
136
|
+
return this.raw.output;
|
|
138
137
|
}
|
|
139
138
|
get paramsIdentifier() {
|
|
140
139
|
return `${this.shortApiName}.Parameters`;
|
|
@@ -149,9 +148,9 @@ var EnhancedQuery = class extends EnhancedBase {
|
|
|
149
148
|
|
|
150
149
|
// src/GenerateContext/EnhancedSharedPropertyType.ts
|
|
151
150
|
var EnhancedSharedPropertyType = class extends EnhancedBase {
|
|
152
|
-
constructor(common,
|
|
153
|
-
super(common,
|
|
154
|
-
this.
|
|
151
|
+
constructor(common, raw) {
|
|
152
|
+
super(common, raw, raw.apiName, "./ontology/interfaces");
|
|
153
|
+
this.raw = raw;
|
|
155
154
|
}
|
|
156
155
|
};
|
|
157
156
|
|
|
@@ -176,20 +175,21 @@ var ForeignType = class extends AbstractImportable {
|
|
|
176
175
|
|
|
177
176
|
// src/GenerateContext/EnhancedOntologyDefinition.ts
|
|
178
177
|
var EnhancedOntologyDefinition = class {
|
|
179
|
-
|
|
178
|
+
#foreignTypes = {};
|
|
179
|
+
constructor(raw, ontologyApiNamespace, apiNamespacePackageMap, importExt) {
|
|
180
180
|
this.common = {
|
|
181
181
|
apiNamespacePackageMap,
|
|
182
182
|
enhancedOntology: this,
|
|
183
183
|
importExt,
|
|
184
184
|
ontologyApiNamespace
|
|
185
185
|
};
|
|
186
|
-
this.
|
|
187
|
-
this.ontology =
|
|
188
|
-
this.objectTypes = remap(
|
|
189
|
-
this.actionTypes = remap(
|
|
190
|
-
this.queryTypes = remap(
|
|
191
|
-
this.interfaceTypes = remap(
|
|
192
|
-
this.sharedPropertyTypes = remap(
|
|
186
|
+
this.raw = raw;
|
|
187
|
+
this.ontology = raw.ontology;
|
|
188
|
+
this.objectTypes = remap(raw.objectTypes, this.common, EnhancedObjectType);
|
|
189
|
+
this.actionTypes = remap(raw.actionTypes, this.common, EnhancedAction);
|
|
190
|
+
this.queryTypes = remap(raw.queryTypes, this.common, EnhancedQuery);
|
|
191
|
+
this.interfaceTypes = remap(raw.interfaceTypes, this.common, EnhancedInterfaceType);
|
|
192
|
+
this.sharedPropertyTypes = remap(raw.sharedPropertyTypes, this.common, EnhancedSharedPropertyType);
|
|
193
193
|
}
|
|
194
194
|
#createRequireType = (type) => {
|
|
195
195
|
return (fullApiName, localOnly) => {
|
|
@@ -202,7 +202,9 @@ var EnhancedOntologyDefinition = class {
|
|
|
202
202
|
if (!this.common.apiNamespacePackageMap.has(apiNamespace)) {
|
|
203
203
|
throw new Error(`Unable to find ${type}: Unknown namespace '${apiNamespace}'`);
|
|
204
204
|
}
|
|
205
|
-
|
|
205
|
+
const ret2 = this.#foreignTypes[fullApiName] ?? new ForeignType(this.common, type, apiNamespace, shortApiName);
|
|
206
|
+
this.#foreignTypes[fullApiName] = ret2;
|
|
207
|
+
return ret2;
|
|
206
208
|
}
|
|
207
209
|
return ret;
|
|
208
210
|
};
|
|
@@ -239,6 +241,21 @@ function sanitizeMetadata(ontology) {
|
|
|
239
241
|
function camelize(name) {
|
|
240
242
|
return name.replace(/-./g, (segment) => segment[1].toUpperCase());
|
|
241
243
|
}
|
|
244
|
+
function formatTs(contents) {
|
|
245
|
+
try {
|
|
246
|
+
return format(contents, {
|
|
247
|
+
parser: "typescript",
|
|
248
|
+
singleQuote: true,
|
|
249
|
+
trailingComma: "all",
|
|
250
|
+
tabWidth: 2,
|
|
251
|
+
printWidth: 120
|
|
252
|
+
});
|
|
253
|
+
} catch (e) {
|
|
254
|
+
console.error("Failed to format file", e);
|
|
255
|
+
console.log(contents);
|
|
256
|
+
return contents;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
242
259
|
|
|
243
260
|
// src/util/verifyOutDir.ts
|
|
244
261
|
async function verifyOutDir(outDir, fs2) {
|
|
@@ -253,6 +270,31 @@ async function verifyOutDir(outDir, fs2) {
|
|
|
253
270
|
}
|
|
254
271
|
}
|
|
255
272
|
}
|
|
273
|
+
var ExpectedOsdkVersion = "2.0.0";
|
|
274
|
+
async function generateOntologyMetadataFile({
|
|
275
|
+
fs: fs2,
|
|
276
|
+
outDir,
|
|
277
|
+
ontology,
|
|
278
|
+
ontologyApiNamespace
|
|
279
|
+
}, userAgent) {
|
|
280
|
+
fs2.writeFile(path5__default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
281
|
+
export type $ExpectedClientVersion = "${ExpectedOsdkVersion}";
|
|
282
|
+
export const $osdkMetadata = { extraUserAgent: "${userAgent}" };
|
|
283
|
+
${ontologyApiNamespace == null ? `
|
|
284
|
+
export const $ontologyRid = "${ontology.ontology.rid}";
|
|
285
|
+
` : ""}
|
|
286
|
+
`));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/shared/getObjectImports.ts
|
|
290
|
+
function getObjectImports(objects, curApiName, currentFilePath, v2) {
|
|
291
|
+
return Array.from(objects).filter((obj) => obj.fullApiName !== curApiName).map((obj) => {
|
|
292
|
+
const defId = obj.getDefinitionIdentifier(v2);
|
|
293
|
+
const importedId = obj.getImportedDefinitionIdentifier(v2);
|
|
294
|
+
const nameOrAlias = defId === importedId ? defId : `${defId} as ${importedId}`;
|
|
295
|
+
return `import type { ${nameOrAlias} } from "${obj.getImportPathRelTo("./" + currentFilePath)}";`;
|
|
296
|
+
}).join("\n");
|
|
297
|
+
}
|
|
256
298
|
|
|
257
299
|
// src/shared/getEditedEntities.ts
|
|
258
300
|
function getModifiedEntityTypes(action) {
|
|
@@ -273,777 +315,6 @@ function getModifiedEntityTypes(action) {
|
|
|
273
315
|
modifiedObjects
|
|
274
316
|
};
|
|
275
317
|
}
|
|
276
|
-
function formatTs(contents) {
|
|
277
|
-
try {
|
|
278
|
-
return format(contents, {
|
|
279
|
-
parser: "typescript",
|
|
280
|
-
singleQuote: true,
|
|
281
|
-
trailingComma: "all",
|
|
282
|
-
plugins: [organizeImports],
|
|
283
|
-
tabWidth: 2,
|
|
284
|
-
printWidth: 120
|
|
285
|
-
});
|
|
286
|
-
} catch (e) {
|
|
287
|
-
console.error("Failed to format file", e);
|
|
288
|
-
console.log(contents);
|
|
289
|
-
return contents;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// src/v1.1/generateActions.ts
|
|
294
|
-
async function generateActions(ontology, fs2, outDir, importExt = "") {
|
|
295
|
-
const importedObjects = /* @__PURE__ */ new Set();
|
|
296
|
-
let actionSignatures = [];
|
|
297
|
-
for (const action of Object.values(ontology.actionTypes)) {
|
|
298
|
-
const entries = Object.entries(action.parameters);
|
|
299
|
-
const modifiedEntityTypes = getModifiedEntityTypes(action);
|
|
300
|
-
const addedObjects = Array.from(modifiedEntityTypes.addedObjects);
|
|
301
|
-
const modifiedObjects = Array.from(modifiedEntityTypes.modifiedObjects);
|
|
302
|
-
addedObjects.forEach(importedObjects.add, importedObjects);
|
|
303
|
-
modifiedObjects.forEach(importedObjects.add, importedObjects);
|
|
304
|
-
let jsDocBlock = ["/**"];
|
|
305
|
-
if (action.description) {
|
|
306
|
-
jsDocBlock.push(`* ${action.description}`);
|
|
307
|
-
}
|
|
308
|
-
let parameterBlock = "";
|
|
309
|
-
if (entries.length > 0) {
|
|
310
|
-
parameterBlock = `params: {
|
|
311
|
-
`;
|
|
312
|
-
for (const [parameterName, parameterData] of entries) {
|
|
313
|
-
parameterBlock += `"${parameterName}"`;
|
|
314
|
-
parameterBlock += parameterData.required ? ": " : "?: ";
|
|
315
|
-
const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
|
|
316
|
-
parameterBlock += `${typeScriptType};
|
|
317
|
-
`;
|
|
318
|
-
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
319
|
-
}
|
|
320
|
-
parameterBlock += "}, ";
|
|
321
|
-
}
|
|
322
|
-
jsDocBlock.push(`*/`);
|
|
323
|
-
actionSignatures.push(`
|
|
324
|
-
${jsDocBlock.join("\n")}
|
|
325
|
-
${action.apiName}<O extends ActionExecutionOptions>(${parameterBlock}options?: O):
|
|
326
|
-
Promise<Result<ActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;`);
|
|
327
|
-
}
|
|
328
|
-
await fs2.mkdir(outDir, {
|
|
329
|
-
recursive: true
|
|
330
|
-
});
|
|
331
|
-
await fs2.writeFile(path16__default.join(outDir, "Actions.ts"), await formatTs(`
|
|
332
|
-
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, ActionError, Result, ActionResponseFromOptions } from "@osdk/legacy-client";
|
|
333
|
-
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
334
|
-
export interface Actions {
|
|
335
|
-
${actionSignatures.join("\n")}
|
|
336
|
-
}
|
|
337
|
-
`));
|
|
338
|
-
}
|
|
339
|
-
function getTypeScriptTypeFromDataType(actionParameter, importedObjects) {
|
|
340
|
-
switch (actionParameter.type) {
|
|
341
|
-
case "objectSet": {
|
|
342
|
-
const objectType = actionParameter.objectTypeApiName;
|
|
343
|
-
importedObjects.add(objectType);
|
|
344
|
-
return `ObjectSet<${objectType}>`;
|
|
345
|
-
}
|
|
346
|
-
case "object": {
|
|
347
|
-
const objectType = actionParameter.objectTypeApiName;
|
|
348
|
-
importedObjects.add(objectType);
|
|
349
|
-
return `${objectType} | ${objectType}["__primaryKey"]`;
|
|
350
|
-
}
|
|
351
|
-
case "array":
|
|
352
|
-
return `Array<${getTypeScriptTypeFromDataType(actionParameter.subType, importedObjects)}>`;
|
|
353
|
-
case "string":
|
|
354
|
-
return `string`;
|
|
355
|
-
case "boolean":
|
|
356
|
-
return `boolean`;
|
|
357
|
-
case "attachment":
|
|
358
|
-
return `Attachment`;
|
|
359
|
-
case "date":
|
|
360
|
-
return `LocalDate`;
|
|
361
|
-
case "double":
|
|
362
|
-
case "integer":
|
|
363
|
-
case "long":
|
|
364
|
-
return `number`;
|
|
365
|
-
case "timestamp":
|
|
366
|
-
return `Timestamp`;
|
|
367
|
-
case "marking":
|
|
368
|
-
return "string";
|
|
369
|
-
default:
|
|
370
|
-
throw new Error(`Unsupported action parameter type: ${actionParameter}`);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// src/v1.1/backcompat/util/reexportConsts.ts
|
|
375
|
-
function reexportConsts(typesToExport) {
|
|
376
|
-
return `
|
|
377
|
-
import { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
|
|
378
|
-
|
|
379
|
-
${typesToExport.map((q) => `
|
|
380
|
-
/** @deprecated submodule imports aren't public api **/
|
|
381
|
-
export const ${q} = OG_${q};
|
|
382
|
-
`).join("\n\n")}
|
|
383
|
-
`;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// src/v1.1/backcompat/internal-foundry-oauth-dist/generateConfidentialClientDir.ts
|
|
387
|
-
async function generateConfidentialClientDir(fs2, oauthDistDir, importExt = "") {
|
|
388
|
-
const confidentialClientDistDir = path16__default.join(oauthDistDir, "ConfidentialClient");
|
|
389
|
-
await fs2.mkdir(confidentialClientDistDir, {
|
|
390
|
-
recursive: true
|
|
391
|
-
});
|
|
392
|
-
await fs2.writeFile(path16__default.join(confidentialClientDistDir, "index.ts"), await formatTs(`
|
|
393
|
-
export * from "./ConfidentialClientAuth${importExt}";
|
|
394
|
-
`));
|
|
395
|
-
await fs2.writeFile(path16__default.join(confidentialClientDistDir, "ConfidentialClientAuth.ts"), await formatTs(`
|
|
396
|
-
${reexportConsts(["ConfidentialClientAuth"])}
|
|
397
|
-
`));
|
|
398
|
-
}
|
|
399
|
-
async function generatePublicClientDir(fs2, oauthDistDir, importExt = "") {
|
|
400
|
-
const publicClientDistDir = path16__default.join(oauthDistDir, "PublicClient");
|
|
401
|
-
await fs2.mkdir(publicClientDistDir, {
|
|
402
|
-
recursive: true
|
|
403
|
-
});
|
|
404
|
-
await fs2.writeFile(path16__default.join(publicClientDistDir, "index.ts"), await formatTs(`
|
|
405
|
-
export * from "./PublicClientAuth${importExt}";
|
|
406
|
-
`));
|
|
407
|
-
await fs2.writeFile(path16__default.join(publicClientDistDir, "PublicClientAuth.ts"), await formatTs(`
|
|
408
|
-
${reexportConsts(["PublicClientAuth"])}
|
|
409
|
-
`));
|
|
410
|
-
}
|
|
411
|
-
async function generateUserTokenDir(fs2, oauthDistDir, importExt = "") {
|
|
412
|
-
const userTokenDistDir = path16__default.join(oauthDistDir, "UserToken");
|
|
413
|
-
await fs2.mkdir(userTokenDistDir, {
|
|
414
|
-
recursive: true
|
|
415
|
-
});
|
|
416
|
-
await fs2.writeFile(path16__default.join(userTokenDistDir, "index.ts"), await formatTs(`
|
|
417
|
-
export * from "./UserTokenAuth${importExt}";
|
|
418
|
-
`));
|
|
419
|
-
await fs2.writeFile(path16__default.join(userTokenDistDir, "UserTokenAuth.ts"), await formatTs(`
|
|
420
|
-
${reexportConsts(["UserTokenAuth"])}
|
|
421
|
-
`));
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// src/v1.1/backcompat/util/reexportTypes.ts
|
|
425
|
-
function reexportTypes(typesToExport, genericArgsLeft = "", genericArgsRight = cleanup(genericArgsLeft)) {
|
|
426
|
-
return `
|
|
427
|
-
import type { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
|
|
428
|
-
|
|
429
|
-
${typesToExport.map((q) => `
|
|
430
|
-
/** @deprecated submodule imports aren't public api **/
|
|
431
|
-
export type ${q}${genericArgsLeft} = OG_${q}${genericArgsRight};
|
|
432
|
-
`).join("\n\n")}
|
|
433
|
-
`;
|
|
434
|
-
}
|
|
435
|
-
var captureInBracketsRegex = /<(.*?)>/;
|
|
436
|
-
var captureGenericParamNameRegex = /^\s?(.+?)( extends .*?)?( = .*?)?\s?$/;
|
|
437
|
-
function cleanup(s) {
|
|
438
|
-
if (s.length === 0) return "";
|
|
439
|
-
const genericParameterNames = captureInBracketsRegex.exec(s)?.[1]?.split(",")?.map((a) => {
|
|
440
|
-
return captureGenericParamNameRegex.exec(a)?.[1] ?? a;
|
|
441
|
-
});
|
|
442
|
-
return `<${genericParameterNames?.join(",")}>`;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
// src/v1.1/backcompat/generateOAuthDistDir.ts
|
|
446
|
-
async function generateOAuthClientDistDir(outDir, fs2, importExt = "") {
|
|
447
|
-
const oauthDistDir = path16.join(outDir, "internal", "@foundry", "oauth-client", "dist");
|
|
448
|
-
await fs2.mkdir(oauthDistDir, {
|
|
449
|
-
recursive: true
|
|
450
|
-
});
|
|
451
|
-
await fs2.writeFile(path16.join(oauthDistDir, "index.ts"), await formatTs(`
|
|
452
|
-
export * from "./Auth${importExt}";
|
|
453
|
-
export * from "./ConfidentialClient/index${importExt}";
|
|
454
|
-
export * from "./OAuthClient${importExt}";
|
|
455
|
-
export * from "./PublicClient/index${importExt}";
|
|
456
|
-
export * from "./Token${importExt}";
|
|
457
|
-
export * from "./UserToken/index${importExt}";
|
|
458
|
-
`));
|
|
459
|
-
await fs2.writeFile(path16.join(oauthDistDir, "Auth.ts"), await formatTs(reexportTypes(["Auth"])));
|
|
460
|
-
await fs2.writeFile(path16.join(oauthDistDir, "Token.ts"), await formatTs(reexportTypes(["Token", "TokenValue"])));
|
|
461
|
-
await fs2.writeFile(path16.join(oauthDistDir, "OAuthClient.ts"), await formatTs(reexportTypes(["AuthSubscription", "UnsubscribeFunction", "SignInResponse", "RefreshResponse", "SignOutResponse"])));
|
|
462
|
-
await fs2.writeFile(path16.join(oauthDistDir, "OAuthToken.ts"), await formatTs(reexportConsts(["OAuthToken"])));
|
|
463
|
-
await fs2.writeFile(path16.join(oauthDistDir, "Auth.ts"), await formatTs(reexportTypes(["Auth"])));
|
|
464
|
-
await generateConfidentialClientDir(fs2, oauthDistDir, importExt);
|
|
465
|
-
await generatePublicClientDir(fs2, oauthDistDir, importExt);
|
|
466
|
-
await generateUserTokenDir(fs2, oauthDistDir, importExt);
|
|
467
|
-
}
|
|
468
|
-
async function generateAggregationsAggregations(fs2, aggregationsDir) {
|
|
469
|
-
await fs2.writeFile(path16.join(aggregationsDir, "Aggregations.ts"), await formatTs(`
|
|
470
|
-
import { LocalDate, Timestamp } from "@osdk/legacy-client";
|
|
471
|
-
` + 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 = {}>")));
|
|
472
|
-
}
|
|
473
|
-
async function generateGroupBy(fs2, aggregationsDir, importExt = "") {
|
|
474
|
-
await fs2.mkdir(path16.join(aggregationsDir, "groupBy"), {
|
|
475
|
-
recursive: true
|
|
476
|
-
});
|
|
477
|
-
const groupBys = ["BooleanGroupBy", "LocalDateGroupBy", "NumericGroupBy", "StringGroupBy", "TimestampGroupBy"];
|
|
478
|
-
const reexportFiles = [...groupBys, "GroupKeyType"];
|
|
479
|
-
for (const key of reexportFiles) {
|
|
480
|
-
await fs2.writeFile(path16.join(aggregationsDir, "groupBy", `${key}.ts`), await formatTs(`export {${key}} from "./index${importExt}";`));
|
|
481
|
-
}
|
|
482
|
-
await fs2.writeFile(path16.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";
|
|
483
|
-
`));
|
|
484
|
-
}
|
|
485
|
-
async function generateMetrics(fs2, aggregationsDir, importExt = "") {
|
|
486
|
-
const metricsDir = path16.join(aggregationsDir, "metrics");
|
|
487
|
-
await fs2.mkdir(metricsDir, {
|
|
488
|
-
recursive: true
|
|
489
|
-
});
|
|
490
|
-
await fs2.writeFile(path16.join(metricsDir, "metrics.ts"), await formatTs(`export {MetricValueType} from "@osdk/legacy-client";`));
|
|
491
|
-
await fs2.writeFile(path16.join(metricsDir, "ApproximateDistinctCountAggregatableProperty.ts"), await formatTs(reexportConsts(["ApproximateDistinctCountAggregatableProperty"]) + reexportTypes(["ApproximateDistinctCountAggregatableProperty"])));
|
|
492
|
-
await fs2.writeFile(path16.join(metricsDir, "MultipleAggregatableProperty.ts"), await formatTs(`
|
|
493
|
-
import { Double, MetricValue, MultipleAggregationsOperations } from "../Aggregations${importExt}";
|
|
494
|
-
import { MetricValueType } from "./metrics/index${importExt}";
|
|
495
|
-
` + reexportConsts(["MultipleAggregatableProperty"]) + reexportTypes(["MultipleAggregatableProperty"], "<TResult extends MetricValue = Double>")));
|
|
496
|
-
for (const typeName of ["DefaultAggregatableProperty", "LocalDatePropertyMetric", "NumericPropertyMetric", "TimestampPropertyMetric"]) {
|
|
497
|
-
await fs2.writeFile(path16.join(metricsDir, `${typeName}.ts`), await formatTs(`
|
|
498
|
-
import { MultipleAggregatableProperty } from "./MultipleAggregatableProperty${importExt}";
|
|
499
|
-
` + reexportConsts([typeName])));
|
|
500
|
-
}
|
|
501
|
-
await fs2.writeFile(path16.join(metricsDir, "index.ts"), await formatTs(`
|
|
502
|
-
export * from "./ApproximateDistinctCountAggregatableProperty${importExt}";
|
|
503
|
-
export * from "./DefaultAggregatableProperty${importExt}";
|
|
504
|
-
export * from "./LocalDatePropertyMetric${importExt}";
|
|
505
|
-
export * from "./metrics${importExt}";
|
|
506
|
-
export * from "./MultipleAggregatableProperty${importExt}";
|
|
507
|
-
export * from "./NumericPropertyMetric${importExt}";
|
|
508
|
-
export * from "./TimestampPropertyMetric${importExt}";
|
|
509
|
-
`));
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// src/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateAggregationsDir.ts
|
|
513
|
-
async function generateAggregationsDir(fs2, runtimeDistDir, importExt = "") {
|
|
514
|
-
const aggregationsDir = path16.join(runtimeDistDir, "aggregations");
|
|
515
|
-
await fs2.mkdir(aggregationsDir, {
|
|
516
|
-
recursive: true
|
|
517
|
-
});
|
|
518
|
-
await generateGroupBy(fs2, aggregationsDir, importExt);
|
|
519
|
-
await generateAggregationsAggregations(fs2, aggregationsDir);
|
|
520
|
-
await generateMetrics(fs2, aggregationsDir, importExt);
|
|
521
|
-
await fs2.writeFile(path16.join(aggregationsDir, "index.ts"), await formatTs(`
|
|
522
|
-
${""}
|
|
523
|
-
${""}
|
|
524
|
-
|
|
525
|
-
export * from "./Aggregations${importExt}";
|
|
526
|
-
export * from "./ComputeStep${importExt}";
|
|
527
|
-
export * from "./CountOperation${importExt}";
|
|
528
|
-
export * from "./groupBy/index${importExt}";
|
|
529
|
-
export * from "./internalAggregationRequest${importExt}";
|
|
530
|
-
export * from "./metrics/index${importExt}";
|
|
531
|
-
`));
|
|
532
|
-
await fs2.writeFile(path16.join(aggregationsDir, "ComputeStep.ts"), await formatTs(`
|
|
533
|
-
import { ObjectSetDefinition } from "../baseTypes/index${importExt}";
|
|
534
|
-
import { FoundryClientOptions } from "../client/${importExt}";
|
|
535
|
-
import { AggregateObjectsError, OntologyMetadata, Result } from "../ontologyProvider/index${importExt}";
|
|
536
|
-
import { AggregationClause, AggregationResult, BucketGroup, BucketValue, InternalBucketing, Metrics, MetricValue } from "./Aggregations${importExt}";
|
|
537
|
-
` + reexportConsts(["ComputeStep"]) + reexportTypes(["ComputeStep"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue> ") + reexportTypes(["AggregationComputeStep"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue>") + `
|
|
538
|
-
|
|
539
|
-
`));
|
|
540
|
-
await fs2.writeFile(path16.join(aggregationsDir, "CountOperation.ts"), await formatTs(`` + reexportConsts(["CountOperation", "isCountOperation"]) + reexportTypes(["CountOperation"])));
|
|
541
|
-
await fs2.writeFile(path16.join(aggregationsDir, "internalAggregationRequest.ts"), await formatTs(reexportTypes(["InternalAggregationRequest"])));
|
|
542
|
-
}
|
|
543
|
-
async function generateAttachmentsDir(attachmentsDir, fs2, importExt = "") {
|
|
544
|
-
await fs2.mkdir(attachmentsDir, {
|
|
545
|
-
recursive: true
|
|
546
|
-
});
|
|
547
|
-
await fs2.writeFile(path16__default.join(attachmentsDir, "index.ts"), await formatTs(`export * from "./Attachment${importExt}";
|
|
548
|
-
export * from "./Attachments${importExt}";
|
|
549
|
-
`));
|
|
550
|
-
await fs2.writeFile(path16__default.join(attachmentsDir, "Attachment.ts"), await formatTs(reexportTypes(["Attachment", "AttachmentMetadata"])));
|
|
551
|
-
await fs2.writeFile(path16__default.join(attachmentsDir, "Attachments.ts"), await formatTs(reexportTypes(["Attachments"])));
|
|
552
|
-
}
|
|
553
|
-
async function generateGeoshapesDir(runtimeDistDir, fs2, importExt = "") {
|
|
554
|
-
await fs2.mkdir(runtimeDistDir, {
|
|
555
|
-
recursive: true
|
|
556
|
-
});
|
|
557
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "index.ts"), await formatTs(`export * from "./Distance${importExt}";
|
|
558
|
-
export * from "./GeoJson${importExt}";
|
|
559
|
-
export * from "./GeometryCollection${importExt}";
|
|
560
|
-
export * from "./GeoPoint${importExt}";
|
|
561
|
-
export * from "./GeoShape${importExt}";
|
|
562
|
-
export * from "./LineString${importExt}";
|
|
563
|
-
export * from "./MultiGeoPoint${importExt}";
|
|
564
|
-
export * from "./MultiLineString${importExt}";
|
|
565
|
-
export * from "./MultiPolygon${importExt}";
|
|
566
|
-
export * from "./Polygon${importExt}";`));
|
|
567
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "Distance.ts"), await formatTs(`` + reexportConsts(["Distance", "DistanceUnit"]) + reexportTypes(["Distance", "DistanceUnit"])));
|
|
568
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "GeoJson.ts"), await formatTs(reexportTypes(["GeoJsonPoint", "GeoJsonPolygon", "GeoJsonLineString", "GeoJsonMultiPoint", "GeoJsonMultiPolygon", "GeoJsonMultiLineString", "GeoJsonGeometryCollection", "GeoJsonGeometry", "GeoJson"])));
|
|
569
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "GeometryCollection.ts"), await formatTs(reexportConsts(["GeometryCollection"])));
|
|
570
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "GeoPoint.ts"), await formatTs(`` + reexportConsts(["isGeoPoint", "GeoPoint", "mapCoordinatesToGeoPoint"]) + reexportTypes(["GeoHash", "Coordinates", "GeoPoint"])));
|
|
571
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "GeoShape.ts"), await formatTs(reexportConsts(["GeoShape"]) + reexportTypes(["GeoShape"])));
|
|
572
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "LineString.ts"), await formatTs(reexportConsts(["LineString"]) + reexportTypes(["LineString"])));
|
|
573
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "MultiGeoPoint.ts"), await formatTs(reexportConsts(["MultiGeoPoint"]) + reexportTypes(["MultiGeoPoint"])));
|
|
574
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "MultiLineString.ts"), await formatTs(reexportConsts(["MultiLineString"]) + reexportTypes(["MultiLineString"])));
|
|
575
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "MultiPolygon.ts"), await formatTs(reexportConsts(["MultiPolygon"]) + reexportTypes(["MultiPolygon"])));
|
|
576
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "Polygon.ts"), await formatTs(reexportConsts(["Polygon"]) + reexportTypes(["LinearRing", "Polygon"])));
|
|
577
|
-
}
|
|
578
|
-
async function generateObjectSetDir(objectSetDir, fs2, importExt = "") {
|
|
579
|
-
await fs2.mkdir(objectSetDir, {
|
|
580
|
-
recursive: true
|
|
581
|
-
});
|
|
582
|
-
await fs2.writeFile(path16__default.join(objectSetDir, "index.ts"), await formatTs(`
|
|
583
|
-
export * from "./ObjectSetDefinition${importExt}";
|
|
584
|
-
export * from "./OntologyObjectSet${importExt}";
|
|
585
|
-
`));
|
|
586
|
-
await fs2.writeFile(path16__default.join(objectSetDir, "ObjectSetDefinition.ts"), await formatTs(reexportTypes(["BaseObjectSetDefinition", "ReferenceObjectSetDefinition", "StaticObjectSetDefinition", "IntersectObjectSetDefinition", "SubtractObjectSetDefinition", "SearchAroundObjectSetDefinition", "FilterObjectSetDefinition", "ObjectSetDefinition"])));
|
|
587
|
-
await fs2.writeFile(path16__default.join(objectSetDir, "OntologyObjectSet.ts"), await formatTs(reexportTypes(["OntologyObjectSet"])));
|
|
588
|
-
}
|
|
589
|
-
async function generateSharedObjectCodeDir(sharedObjectCodeDir, fs2, importExt = "") {
|
|
590
|
-
await fs2.mkdir(sharedObjectCodeDir, {
|
|
591
|
-
recursive: true
|
|
592
|
-
});
|
|
593
|
-
await fs2.writeFile(path16__default.join(sharedObjectCodeDir, "index.ts"), await formatTs(`
|
|
594
|
-
export * from "./FilteredPropertiesTerminalOperations${importExt}";
|
|
595
|
-
`));
|
|
596
|
-
await fs2.writeFile(path16__default.join(sharedObjectCodeDir, "FilteredPropertiesTerminalOperations.ts"), await formatTs(`import { OntologyObject } from "../OntologyObject${importExt}` + reexportTypes(["FilteredPropertiesTerminalOperations", "FilteredPropertiesTerminalOperationsWithGet"], "<T extends OntologyObject, V extends Array<keyof T>>")));
|
|
597
|
-
}
|
|
598
|
-
async function generateTimeSeriesDir(timeseriesDir, fs2, importExt = "") {
|
|
599
|
-
await fs2.mkdir(timeseriesDir, {
|
|
600
|
-
recursive: true
|
|
601
|
-
});
|
|
602
|
-
await fs2.writeFile(path16.join(timeseriesDir, "index.ts"), await formatTs(`
|
|
603
|
-
export * from "./TimeSeries${importExt}";
|
|
604
|
-
export * from "./TimeSeriesDuration${importExt}";
|
|
605
|
-
export * from "./TimeSeriesPoint${importExt}";
|
|
606
|
-
${""}
|
|
607
|
-
export * from "./TimeSeriesQuery${importExt}";
|
|
608
|
-
export * from "./TimeSeriesTerminalOperations${importExt}";
|
|
609
|
-
`));
|
|
610
|
-
await fs2.writeFile(path16.join(timeseriesDir, "TimeSeries.ts"), await formatTs(reexportTypes(["TimeSeries"], `<T extends number | string>`)));
|
|
611
|
-
await fs2.writeFile(path16.join(timeseriesDir, "TimeSeriesDuration.ts"), await formatTs(reexportTypes([`WhenUnit`, `DurationUnit`, `TimeSeriesDuration`])));
|
|
612
|
-
await fs2.writeFile(path16.join(timeseriesDir, "TimeSeriesPoint.ts"), await formatTs(reexportTypes(["TimeSeriesPoint"], `<T extends number | string>`)));
|
|
613
|
-
await fs2.writeFile(path16.join(timeseriesDir, "TimeSeriesQuery.ts"), await formatTs(reexportTypes(["TimeSeriesQuery"], `<T extends number | string>`)));
|
|
614
|
-
await fs2.writeFile(path16.join(timeseriesDir, "TimeSeriesTerminalOperations.ts"), await formatTs(reexportTypes(["TimeSeriesTerminalOperations", "TimeSeriesIterator"], `<T extends number | string>`)));
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
// src/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateBaseTypesDir.ts
|
|
618
|
-
async function generateBaseTypesDir(runtimeDistDir, fs2, importExt = "") {
|
|
619
|
-
const baseTypesDir = path16.join(runtimeDistDir, "baseTypes");
|
|
620
|
-
await fs2.mkdir(baseTypesDir, {
|
|
621
|
-
recursive: true
|
|
622
|
-
});
|
|
623
|
-
await fs2.writeFile(path16.join(baseTypesDir, "index.ts"), await formatTs(`export * from "./ActionType${importExt}";
|
|
624
|
-
export * from "./attachments/index${importExt}";
|
|
625
|
-
export * from "./geoshapes/index${importExt}";
|
|
626
|
-
export * from "./links${importExt}";
|
|
627
|
-
export * from "./localDate${importExt}";
|
|
628
|
-
export * from "./objectset/index${importExt}";
|
|
629
|
-
export * from "./ObjectType${importExt}";
|
|
630
|
-
export * from "./OntologyObject${importExt}";
|
|
631
|
-
export * from "./Queries${importExt}";
|
|
632
|
-
export * from "./timeseries/index${importExt}";
|
|
633
|
-
export * from "./timestamp${importExt}";`));
|
|
634
|
-
const geoshapesDir = path16.join(baseTypesDir, "geoshapes");
|
|
635
|
-
await generateGeoshapesDir(geoshapesDir, fs2, importExt);
|
|
636
|
-
const timeseriesDir = path16.join(baseTypesDir, "timeseries");
|
|
637
|
-
await generateTimeSeriesDir(timeseriesDir, fs2, importExt);
|
|
638
|
-
const attachmentsDir = path16.join(baseTypesDir, "attachments");
|
|
639
|
-
await generateAttachmentsDir(attachmentsDir, fs2, importExt);
|
|
640
|
-
const objectSetDir = path16.join(baseTypesDir, "objectset");
|
|
641
|
-
await generateObjectSetDir(objectSetDir, fs2, importExt);
|
|
642
|
-
const sharedObjectCodeDir = path16.join(baseTypesDir, "sharedObjectCode");
|
|
643
|
-
await generateSharedObjectCodeDir(sharedObjectCodeDir, fs2, importExt);
|
|
644
|
-
await fs2.writeFile(path16.join(baseTypesDir, "ActionType.ts"), await formatTs(`import { OntologyObject } from "./OntologyObject${importExt}";
|
|
645
|
-
` + 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>")));
|
|
646
|
-
await fs2.writeFile(path16.join(baseTypesDir, "OntologyObject.ts"), await formatTs(reexportTypes(["OntologyObject"]) + reexportConsts(["isOntologyObject"])));
|
|
647
|
-
await fs2.writeFile(path16.join(baseTypesDir, "links.ts"), await formatTs(`import { OntologyObject } from "./OntologyObject${importExt}` + reexportTypes(["SingleLink", "MultiLink"], "<T extends OntologyObject = OntologyObject>")));
|
|
648
|
-
await fs2.writeFile(path16.join(baseTypesDir, "localDate.ts"), await formatTs(reexportConsts(["LocalDate"]) + reexportTypes(["LocalDate"])));
|
|
649
|
-
await fs2.writeFile(path16.join(baseTypesDir, "timestamp.ts"), await formatTs(reexportConsts(["Timestamp"]) + reexportTypes(["Timestamp"])));
|
|
650
|
-
await fs2.writeFile(path16.join(baseTypesDir, "Queries.ts"), await formatTs(`import { BucketValue, Range, Rangeable } from "../aggregations/index${importExt}";
|
|
651
|
-
` + 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"])));
|
|
652
|
-
await fs2.writeFile(path16.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>")));
|
|
653
|
-
}
|
|
654
|
-
async function generateClientDir(runtimeDistDir, fs2, importExt = "") {
|
|
655
|
-
const pagingDir = path16__default.join(runtimeDistDir, "client");
|
|
656
|
-
await fs2.mkdir(pagingDir, {
|
|
657
|
-
recursive: true
|
|
658
|
-
});
|
|
659
|
-
await fs2.writeFile(path16__default.join(pagingDir, "index.ts"), await formatTs(`export * from "./clientOptions${importExt}";`));
|
|
660
|
-
await fs2.writeFile(path16__default.join(pagingDir, "clientOptions.ts"), await formatTs(`import {Auth} from "@osdk/legacy-client";` + reexportTypes(["FoundryClientOptions"], "<TAuth extends Auth = Auth>")));
|
|
661
|
-
}
|
|
662
|
-
async function generateFiltersDir(runtimeDistDir, fs2, importExt = "") {
|
|
663
|
-
const pagingDir = path16__default.join(runtimeDistDir, "filters");
|
|
664
|
-
await fs2.mkdir(pagingDir, {
|
|
665
|
-
recursive: true
|
|
666
|
-
});
|
|
667
|
-
await fs2.writeFile(path16__default.join(pagingDir, "index.ts"), await formatTs(`export * from "./ArrayFilter${importExt}";
|
|
668
|
-
export * from "./AttachmentFilter${importExt}";
|
|
669
|
-
export * from "./BooleanFilter${importExt}";
|
|
670
|
-
export * from "./DateTimeFilters${importExt}";
|
|
671
|
-
export * from "./Filters${importExt}";
|
|
672
|
-
export * from "./GeoPointFilter${importExt}";
|
|
673
|
-
export * from "./GeoShapeFilter${importExt}";
|
|
674
|
-
export * from "./NumericFilter${importExt}";
|
|
675
|
-
export * from "./Op${importExt}";
|
|
676
|
-
export * from "./OrderByOption${importExt}";
|
|
677
|
-
export * from "./StringFilter${importExt}";`));
|
|
678
|
-
await fs2.writeFile(path16__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>")));
|
|
679
|
-
await fs2.writeFile(path16__default.join(pagingDir, "AttachmentFilter.ts"), await formatTs(reexportConsts(["AttachmentFilter"]) + reexportTypes(["AttachmentFilter"])));
|
|
680
|
-
await fs2.writeFile(path16__default.join(pagingDir, "BooleanFilter.ts"), await formatTs(reexportConsts(["BooleanFilter"]) + reexportTypes(["BooleanFilter"])));
|
|
681
|
-
await fs2.writeFile(path16__default.join(pagingDir, "GeoPointFilter.ts"), await formatTs(reexportConsts(["GeoPointFilter"]) + reexportTypes(["GeoPointFilter", "BoundingBox"])));
|
|
682
|
-
await fs2.writeFile(path16__default.join(pagingDir, "DateTimeFilters.ts"), await formatTs(reexportConsts(["TimestampFilter", "LocalDateFilter"]) + reexportTypes(["TimestampFilter", "LocalDateFilter"])));
|
|
683
|
-
await fs2.writeFile(path16__default.join(pagingDir, "GeoShapeFilter.ts"), await formatTs(reexportConsts(["GeoShapeFilter"]) + reexportTypes(["GeoShapeFilter"])));
|
|
684
|
-
await fs2.writeFile(path16__default.join(pagingDir, "NumericFilter.ts"), await formatTs(reexportConsts(["NumericFilter"]) + reexportTypes(["NumericFilter"])));
|
|
685
|
-
await fs2.writeFile(path16__default.join(pagingDir, "Op.ts"), await formatTs(reexportConsts(["Op"])));
|
|
686
|
-
await fs2.writeFile(path16__default.join(pagingDir, "OrderByOption.ts"), await formatTs(reexportConsts(["OrderByOption"]) + reexportTypes(["OrderByOption"])));
|
|
687
|
-
await fs2.writeFile(path16__default.join(pagingDir, "StringFilter.ts"), await formatTs(reexportConsts(["StringFilter"]) + reexportTypes(["StringFilter"])));
|
|
688
|
-
await fs2.writeFile(path16__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>")));
|
|
689
|
-
}
|
|
690
|
-
async function generateErrors(fs2, ontologyProviderDir) {
|
|
691
|
-
await fs2.writeFile(path16.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"])));
|
|
692
|
-
}
|
|
693
|
-
async function generateOntologyMetadata(fs2, ontologyProviderDir) {
|
|
694
|
-
await fs2.writeFile(path16.join(ontologyProviderDir, "OntologyMetadata.ts"), await formatTs(reexportTypes(["OntologyMetadata"])));
|
|
695
|
-
}
|
|
696
|
-
async function generateResult(fs2, ontologyProviderDir) {
|
|
697
|
-
await fs2.writeFile(path16.join(ontologyProviderDir, "Result.ts"), await formatTs(`import {FoundryApiError} from "@osdk/legacy-client";
|
|
698
|
-
` + 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>")));
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
// src/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateOntologyProviderDir.ts
|
|
702
|
-
async function generateOntologyProviderDir(fs2, runtimeDistDir, importExt = "") {
|
|
703
|
-
const ontologyProviderDir = path16.join(runtimeDistDir, "ontologyProvider");
|
|
704
|
-
await fs2.mkdir(ontologyProviderDir, {
|
|
705
|
-
recursive: true
|
|
706
|
-
});
|
|
707
|
-
await generateErrors(fs2, ontologyProviderDir);
|
|
708
|
-
await generateOntologyMetadata(fs2, ontologyProviderDir);
|
|
709
|
-
await generateResult(fs2, ontologyProviderDir);
|
|
710
|
-
await fs2.writeFile(path16.join(ontologyProviderDir, "index.ts"), await formatTs(`
|
|
711
|
-
${""}
|
|
712
|
-
export * from "./Errors${importExt}";
|
|
713
|
-
export * from "./OntologyMetadata${importExt}";
|
|
714
|
-
${""}
|
|
715
|
-
${""}
|
|
716
|
-
// export * from "./Result${importExt}";
|
|
717
|
-
`));
|
|
718
|
-
}
|
|
719
|
-
async function generatePagingDir(runtimeDistDir, fs2, importExt = "") {
|
|
720
|
-
const pagingDir = path16.join(runtimeDistDir, "paging");
|
|
721
|
-
await fs2.mkdir(pagingDir, {
|
|
722
|
-
recursive: true
|
|
723
|
-
});
|
|
724
|
-
await fs2.writeFile(path16.join(pagingDir, "index.ts"), await formatTs(`export * from "./Page${importExt}";`));
|
|
725
|
-
await fs2.writeFile(path16.join(pagingDir, "Page.ts"), await formatTs(reexportTypes(["Page"], "<T>")));
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
// src/v1.1/backcompat/generateOntologyRuntimeDistDir.ts
|
|
729
|
-
async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
|
|
730
|
-
const runtimeDistDir = path16.join(outDir, "internal", "@foundry", "ontology-runtime", "dist");
|
|
731
|
-
await fs2.mkdir(runtimeDistDir, {
|
|
732
|
-
recursive: true
|
|
733
|
-
});
|
|
734
|
-
await generateOntologyProviderDir(fs2, runtimeDistDir, importExt);
|
|
735
|
-
await generateAggregationsDir(fs2, runtimeDistDir, importExt);
|
|
736
|
-
await generatePagingDir(runtimeDistDir, fs2, importExt);
|
|
737
|
-
await generateBaseTypesDir(runtimeDistDir, fs2, importExt);
|
|
738
|
-
await generateClientDir(runtimeDistDir, fs2, importExt);
|
|
739
|
-
await generateFiltersDir(runtimeDistDir, fs2, importExt);
|
|
740
|
-
await fs2.writeFile(path16.join(runtimeDistDir, "index.ts"), await formatTs(`
|
|
741
|
-
export * from "./aggregations/index${importExt}";
|
|
742
|
-
export * from "./baseTypes/index${importExt}";
|
|
743
|
-
${""}
|
|
744
|
-
// export * from "./filters/index${importExt}";
|
|
745
|
-
${""}
|
|
746
|
-
${""}
|
|
747
|
-
|
|
748
|
-
export * from "./ontologyProvider/index${importExt}";
|
|
749
|
-
export * from "./paging/index${importExt}";
|
|
750
|
-
`));
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
// src/v1.1/generateBackCompatDeprecatedExports.ts
|
|
754
|
-
async function generateBackCompatDeprecatedExports(fs2, outDir, importExt = "") {
|
|
755
|
-
await generateOntologyRuntimeDistDir(outDir, fs2, importExt);
|
|
756
|
-
await generateOAuthClientDistDir(outDir, fs2, importExt);
|
|
757
|
-
}
|
|
758
|
-
async function generateBatchActions(ontology, fs2, outDir, importExt = "") {
|
|
759
|
-
const importedObjects = /* @__PURE__ */ new Set();
|
|
760
|
-
let actionSignatures = [];
|
|
761
|
-
for (const action of Object.values(ontology.actionTypes)) {
|
|
762
|
-
const entries = Object.entries(action.parameters);
|
|
763
|
-
const modifiedEntityTypes = getModifiedEntityTypes(action);
|
|
764
|
-
const addedObjects = Array.from(modifiedEntityTypes.addedObjects);
|
|
765
|
-
const modifiedObjects = Array.from(modifiedEntityTypes.modifiedObjects);
|
|
766
|
-
addedObjects.forEach(importedObjects.add, importedObjects);
|
|
767
|
-
modifiedObjects.forEach(importedObjects.add, importedObjects);
|
|
768
|
-
let jsDocBlock = ["/**"];
|
|
769
|
-
if (action.description) {
|
|
770
|
-
jsDocBlock.push(`* ${action.description}`);
|
|
771
|
-
}
|
|
772
|
-
let parameterBlock = "";
|
|
773
|
-
if (entries.length > 0) {
|
|
774
|
-
parameterBlock = `params: {
|
|
775
|
-
`;
|
|
776
|
-
for (const [parameterName, parameterData] of entries) {
|
|
777
|
-
parameterBlock += `"${parameterName}"`;
|
|
778
|
-
parameterBlock += parameterData.required ? ": " : "?: ";
|
|
779
|
-
const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
|
|
780
|
-
parameterBlock += `${typeScriptType};
|
|
781
|
-
`;
|
|
782
|
-
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
783
|
-
}
|
|
784
|
-
parameterBlock += "}[], ";
|
|
785
|
-
} else {
|
|
786
|
-
parameterBlock = `params: Record<string,never>[], `;
|
|
787
|
-
}
|
|
788
|
-
jsDocBlock.push(`*/`);
|
|
789
|
-
actionSignatures.push(`
|
|
790
|
-
${jsDocBlock.join("\n")}
|
|
791
|
-
${action.apiName}<O extends BatchActionExecutionOptions>(${parameterBlock}options?: O):
|
|
792
|
-
Promise<Result<BatchActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;
|
|
793
|
-
`);
|
|
794
|
-
}
|
|
795
|
-
await fs2.mkdir(outDir, {
|
|
796
|
-
recursive: true
|
|
797
|
-
});
|
|
798
|
-
await fs2.writeFile(path16__default.join(outDir, "BatchActions.ts"), await formatTs(`
|
|
799
|
-
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, BatchActionExecutionOptions, ActionError, Result, ActionResponseFromOptions, BatchActionResponseFromOptions } from "@osdk/legacy-client";
|
|
800
|
-
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
801
|
-
export interface BatchActions {
|
|
802
|
-
${actionSignatures.join("\n")}
|
|
803
|
-
}
|
|
804
|
-
`));
|
|
805
|
-
}
|
|
806
|
-
async function generateBulkActions(ontology, fs2, outDir, importExt = "") {
|
|
807
|
-
const importedObjects = /* @__PURE__ */ new Set();
|
|
808
|
-
let actionSignatures = [];
|
|
809
|
-
for (const action of Object.values(ontology.actionTypes)) {
|
|
810
|
-
const entries = Object.entries(action.parameters);
|
|
811
|
-
const modifiedEntityTypes = getModifiedEntityTypes(action);
|
|
812
|
-
const addedObjects = Array.from(modifiedEntityTypes.addedObjects);
|
|
813
|
-
const modifiedObjects = Array.from(modifiedEntityTypes.modifiedObjects);
|
|
814
|
-
addedObjects.forEach(importedObjects.add, importedObjects);
|
|
815
|
-
modifiedObjects.forEach(importedObjects.add, importedObjects);
|
|
816
|
-
let jsDocBlock = ["/**"];
|
|
817
|
-
if (action.description) {
|
|
818
|
-
jsDocBlock.push(`* ${action.description}`);
|
|
819
|
-
}
|
|
820
|
-
let parameterBlock = "";
|
|
821
|
-
if (entries.length > 0) {
|
|
822
|
-
parameterBlock = `params: {
|
|
823
|
-
`;
|
|
824
|
-
for (const [parameterName, parameterData] of entries) {
|
|
825
|
-
parameterBlock += `"${parameterName}"`;
|
|
826
|
-
parameterBlock += parameterData.required ? ": " : "?: ";
|
|
827
|
-
const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
|
|
828
|
-
parameterBlock += `${typeScriptType};
|
|
829
|
-
`;
|
|
830
|
-
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
831
|
-
}
|
|
832
|
-
parameterBlock += "}[], ";
|
|
833
|
-
} else {
|
|
834
|
-
parameterBlock = `params: Record<string,never>[], `;
|
|
835
|
-
}
|
|
836
|
-
jsDocBlock.push(`*/`);
|
|
837
|
-
actionSignatures.push(`
|
|
838
|
-
${jsDocBlock.join("\n")}
|
|
839
|
-
${action.apiName}<O extends BulkActionExecutionOptions>(${parameterBlock}options?: O):
|
|
840
|
-
Promise<Result<BulkActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;
|
|
841
|
-
`);
|
|
842
|
-
}
|
|
843
|
-
await fs2.mkdir(outDir, {
|
|
844
|
-
recursive: true
|
|
845
|
-
});
|
|
846
|
-
await fs2.writeFile(path16__default.join(outDir, "BulkActions.ts"), await formatTs(`
|
|
847
|
-
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, BulkActionExecutionOptions, ActionError, Result, ActionResponseFromOptions, BulkActionResponseFromOptions } from "@osdk/legacy-client";
|
|
848
|
-
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
849
|
-
export interface BulkActions {
|
|
850
|
-
${actionSignatures.join("\n")}
|
|
851
|
-
}
|
|
852
|
-
`));
|
|
853
|
-
}
|
|
854
|
-
async function generateFoundryClientFile(fs2, outDir, importExt = "") {
|
|
855
|
-
await fs2.writeFile(path16__default.join(outDir, "FoundryClient.ts"), await formatTs(`
|
|
856
|
-
import { BaseFoundryClient } from "@osdk/legacy-client";
|
|
857
|
-
import type { Auth, FoundryClientOptions } from "@osdk/legacy-client";
|
|
858
|
-
import { Ontology } from "./Ontology${importExt}";
|
|
859
|
-
|
|
860
|
-
export class FoundryClient<TAuth extends Auth = Auth> extends BaseFoundryClient<typeof Ontology, TAuth> {
|
|
861
|
-
constructor(options: FoundryClientOptions<TAuth>) {
|
|
862
|
-
super(options, Ontology);
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
get ontology(): Ontology {
|
|
866
|
-
return super.ontology;
|
|
867
|
-
}
|
|
868
|
-
}`));
|
|
869
|
-
}
|
|
870
|
-
async function generateIndexFile(fs2, outDir, importExt) {
|
|
871
|
-
await fs2.mkdir(outDir, {
|
|
872
|
-
recursive: true
|
|
873
|
-
});
|
|
874
|
-
await fs2.writeFile(path16.join(outDir, "index.ts"), await formatTs(`
|
|
875
|
-
export * from "@osdk/legacy-client";
|
|
876
|
-
export type { Ontology } from "./Ontology${importExt}";
|
|
877
|
-
export { FoundryClient } from "./FoundryClient${importExt}";
|
|
878
|
-
`));
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
// src/util/commaSeparatedIdentifiers.ts
|
|
882
|
-
function commaSeparatedIdentifiers(identifiers, alternateNames) {
|
|
883
|
-
return identifiers.map((i) => {
|
|
884
|
-
const alt = alternateNames?.get(i);
|
|
885
|
-
if (alt) {
|
|
886
|
-
return `${i}: ${alt}`;
|
|
887
|
-
}
|
|
888
|
-
return i;
|
|
889
|
-
}).join(",");
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
// src/util/commaSeparatedTypeIdentifiers.ts
|
|
893
|
-
function commaSeparatedTypeIdentifiers(identifiers, altNames) {
|
|
894
|
-
return identifiers.map((i) => `${i}: typeof ${altNames?.get(i) ?? i}`).join(",");
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
// src/v1.1/generateMetadataFile.ts
|
|
898
|
-
async function generateMetadataFile(ontology, userAgent, fs2, outDir, importExt = "") {
|
|
899
|
-
const objectNames = Object.keys(ontology.objectTypes);
|
|
900
|
-
const actionNames = Object.keys(ontology.actionTypes);
|
|
901
|
-
const queryNames = Object.keys(ontology.queryTypes);
|
|
902
|
-
const actionAltNames = /* @__PURE__ */ new Map();
|
|
903
|
-
const queryAltNames = /* @__PURE__ */ new Map();
|
|
904
|
-
const seenIdentifiers = new Set(objectNames);
|
|
905
|
-
for (const actionName of actionNames) {
|
|
906
|
-
if (seenIdentifiers.has(actionName)) {
|
|
907
|
-
actionAltNames.set(actionName, `${actionName}Action`);
|
|
908
|
-
} else {
|
|
909
|
-
seenIdentifiers.add(actionName);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
for (const queryName of queryNames) {
|
|
913
|
-
if (seenIdentifiers.has(queryName)) {
|
|
914
|
-
queryAltNames.set(queryName, `${queryName}Query`);
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
const getImportClause = (name, altNames) => {
|
|
918
|
-
const alt = altNames.get(name);
|
|
919
|
-
if (alt) {
|
|
920
|
-
return `${name} as ${alt}`;
|
|
921
|
-
} else {
|
|
922
|
-
return name;
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
await fs2.writeFile(path16__default.join(outDir, "Ontology.ts"), await formatTs(`
|
|
926
|
-
import type { OntologyDefinition } from "@osdk/api";
|
|
927
|
-
import type { Ontology as ClientOntology } from "@osdk/legacy-client";
|
|
928
|
-
import type { Objects } from "./ontology/objects/Objects${importExt}";
|
|
929
|
-
import type { Actions } from "./ontology/actions/Actions${importExt}";
|
|
930
|
-
import type { Queries } from "./ontology/queries/Queries${importExt}";
|
|
931
|
-
import type { BatchActions } from "./ontology/actions/BatchActions${importExt}";
|
|
932
|
-
import type { BulkActions } from "./ontology/actions/BulkActions${importExt}";
|
|
933
|
-
${objectNames.map((name) => `import {${name}} from "./ontology/objects/${name}${importExt}";`).join("\n")}
|
|
934
|
-
${actionNames.map((name) => `import {${getImportClause(name, actionAltNames)}} from "./ontology/actions/${name}${importExt}";`).join("\n")}
|
|
935
|
-
${queryNames.map((name) => `import {${getImportClause(name, queryAltNames)}} from "./ontology/queries/${name}${importExt}";`).join("\n")}
|
|
936
|
-
|
|
937
|
-
export const Ontology : {
|
|
938
|
-
metadata: {
|
|
939
|
-
ontologyRid: "${ontology.ontology.rid}",
|
|
940
|
-
ontologyApiName: "${ontology.ontology.apiName}",
|
|
941
|
-
userAgent: "${userAgent}",
|
|
942
|
-
},
|
|
943
|
-
objects: {
|
|
944
|
-
${commaSeparatedTypeIdentifiers(objectNames)}
|
|
945
|
-
},
|
|
946
|
-
actions: {
|
|
947
|
-
${commaSeparatedTypeIdentifiers(actionNames, actionAltNames)}
|
|
948
|
-
},
|
|
949
|
-
queries: {
|
|
950
|
-
${commaSeparatedTypeIdentifiers(queryNames, queryAltNames)}
|
|
951
|
-
},
|
|
952
|
-
} = {
|
|
953
|
-
metadata: {
|
|
954
|
-
ontologyRid: "${ontology.ontology.rid}" as const,
|
|
955
|
-
ontologyApiName: "${ontology.ontology.apiName}" as const,
|
|
956
|
-
userAgent: "${userAgent}" as const,
|
|
957
|
-
},
|
|
958
|
-
objects: {
|
|
959
|
-
${commaSeparatedIdentifiers(objectNames)}
|
|
960
|
-
},
|
|
961
|
-
actions: {
|
|
962
|
-
${commaSeparatedIdentifiers(actionNames, actionAltNames)}
|
|
963
|
-
},
|
|
964
|
-
queries: {
|
|
965
|
-
${commaSeparatedIdentifiers(queryNames, queryAltNames)}
|
|
966
|
-
}
|
|
967
|
-
} satisfies OntologyDefinition<
|
|
968
|
-
${stringUnionFrom(objectNames)},
|
|
969
|
-
${stringUnionFrom(Object.values(ontology.actionTypes).map((actionType) => actionType.apiName))},
|
|
970
|
-
${stringUnionFrom(Object.values(ontology.queryTypes).map((queryType) => queryType.apiName))}>;
|
|
971
|
-
|
|
972
|
-
export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
973
|
-
objects: Objects;
|
|
974
|
-
actions: Actions;
|
|
975
|
-
/** @deprecated use batchActions */
|
|
976
|
-
bulkActions: BulkActions;
|
|
977
|
-
batchActions: BatchActions;
|
|
978
|
-
queries: Queries;
|
|
979
|
-
}`));
|
|
980
|
-
}
|
|
981
|
-
function stringUnionFrom(values) {
|
|
982
|
-
if (values.length === 0) {
|
|
983
|
-
return "never";
|
|
984
|
-
}
|
|
985
|
-
return values.map((n) => `"${n}"`).join("|");
|
|
986
|
-
}
|
|
987
|
-
async function generateObjectsInterfaceFile(ontology, fs2, outDir, importExt = "") {
|
|
988
|
-
await fs2.mkdir(outDir, {
|
|
989
|
-
recursive: true
|
|
990
|
-
});
|
|
991
|
-
await fs2.writeFile(path16__default.join(outDir, "Objects.ts"), await formatTs(`
|
|
992
|
-
import { BaseObjectSet } from "@osdk/legacy-client";
|
|
993
|
-
${Array.from(Object.keys(ontology.objectTypes)).map((importedObject) => `import type { ${importedObject} } from "./${importedObject}${importExt}";`).join("\n")}
|
|
994
|
-
|
|
995
|
-
export interface Objects {
|
|
996
|
-
${Object.keys(ontology.objectTypes).map((apiName) => `${apiName} : BaseObjectSet<${apiName}>;`).join("\n")}
|
|
997
|
-
}
|
|
998
|
-
;`));
|
|
999
|
-
}
|
|
1000
|
-
async function generateObjectsInterfaceSupportFiles(ontology, fs2, outDir, importExt = "") {
|
|
1001
|
-
await fs2.mkdir(outDir, {
|
|
1002
|
-
recursive: true
|
|
1003
|
-
});
|
|
1004
|
-
for (const {
|
|
1005
|
-
objectType: {
|
|
1006
|
-
apiName
|
|
1007
|
-
}
|
|
1008
|
-
} of Object.values(ontology.objectTypes)) {
|
|
1009
|
-
const fileName = join(outDir, `${apiName}.ts`);
|
|
1010
|
-
const localApiName = `OG_${apiName}`;
|
|
1011
|
-
const contents = [];
|
|
1012
|
-
contents.push(`import { ObjectSetAggregateArg, ObjectSetFilterArg, ObjectSetGroupByArg, ObjectSetMultipleAggregateArg, ObjectSetOrderByArg } from "@osdk/legacy-client";`);
|
|
1013
|
-
contents.push(`import { ${apiName} as ${localApiName} } from "../${apiName}${importExt}";`);
|
|
1014
|
-
contents.push("");
|
|
1015
|
-
contents.push(`/** @deprecated Use ${apiName} from ontology/objects instead */`, `export type ${apiName} = ${localApiName};`);
|
|
1016
|
-
contents.push(`/** @deprecated Use ObjectSetFilterArg<${apiName}> instead */`, `export type ${apiName}Filter = ObjectSetFilterArg<${localApiName}>;`);
|
|
1017
|
-
contents.push(`/** @deprecated Use ObjectSetOrderByArg<${apiName}> instead */`, `export type ${apiName}OrderBy = ObjectSetOrderByArg<${localApiName}>;`);
|
|
1018
|
-
contents.push(`/** @deprecated Use ObjectSetGroupByArg<${apiName}> instead */`, `export type ${apiName}GroupByProperties = ObjectSetGroupByArg<${localApiName}>;`);
|
|
1019
|
-
contents.push(`
|
|
1020
|
-
/**
|
|
1021
|
-
* Aggregation properties for ${apiName}
|
|
1022
|
-
* @deprecated Use ObjectSetAggregateArg<${apiName}> instead
|
|
1023
|
-
*/`, `export type ${apiName}AggregationProperties = ObjectSetAggregateArg<${localApiName}>;`);
|
|
1024
|
-
contents.push(`
|
|
1025
|
-
/**
|
|
1026
|
-
* Multiple aggregation properties for ${apiName}.
|
|
1027
|
-
* @deprecated Use ObjectSetMultipleAggregateArg<${apiName}> instead
|
|
1028
|
-
*/`, `export type ${apiName}MultipleAggregationProperties = ObjectSetMultipleAggregateArg<${localApiName}>;`);
|
|
1029
|
-
await fs2.writeFile(fileName, contents.join("\n"));
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
async function generateOntologyIndexFile(fs2, outDir) {
|
|
1033
|
-
await fs2.mkdir(outDir, {
|
|
1034
|
-
recursive: true
|
|
1035
|
-
});
|
|
1036
|
-
await fs2.writeFile(path16.join(outDir, "index.ts"), await formatTs(`
|
|
1037
|
-
export type { ObjectSet } from "@osdk/legacy-client";
|
|
1038
|
-
`));
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
// src/shared/getObjectImports.ts
|
|
1042
|
-
function getObjectImports(objects, curApiName, currentFilePath, v2) {
|
|
1043
|
-
return Array.from(objects).filter((obj) => obj.fullApiName !== curApiName).map((obj) => {
|
|
1044
|
-
return `import type { ${obj.getDefinitionIdentifier(v2)} as ${obj.getImportedDefinitionIdentifier(v2)} } from "${obj.getImportPathRelTo("./" + currentFilePath)}";`;
|
|
1045
|
-
}).join("\n");
|
|
1046
|
-
}
|
|
1047
318
|
|
|
1048
319
|
// src/shared/wireActionTypeV2ToSdkActionDefinition.ts
|
|
1049
320
|
function wireActionTypeV2ToSdkActionDefinition(input) {
|
|
@@ -1113,116 +384,6 @@ function createModifiedEntities(addedObjects, modifiedObjects) {
|
|
|
1113
384
|
return entities;
|
|
1114
385
|
}
|
|
1115
386
|
|
|
1116
|
-
// src/util/stringUnionFrom.ts
|
|
1117
|
-
function stringUnionFrom2(values) {
|
|
1118
|
-
if (values.length === 0) {
|
|
1119
|
-
return "never";
|
|
1120
|
-
} else {
|
|
1121
|
-
return values.map((v) => `"${v}"`).join("|");
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
// src/v1.1/generatePerActionDataFilesV1.ts
|
|
1126
|
-
async function generatePerActionDataFilesV1({
|
|
1127
|
-
sanitizedOntology: ontology,
|
|
1128
|
-
fs: fs2,
|
|
1129
|
-
outDir: rootOutDir,
|
|
1130
|
-
importExt = "",
|
|
1131
|
-
ontology: enhancedOntology
|
|
1132
|
-
}) {
|
|
1133
|
-
const outDir = path16__default.join(rootOutDir, "ontology", "actions");
|
|
1134
|
-
await fs2.mkdir(outDir, {
|
|
1135
|
-
recursive: true
|
|
1136
|
-
});
|
|
1137
|
-
await Promise.all(Object.values(enhancedOntology.actionTypes).map(async (action) => {
|
|
1138
|
-
const currentFilePath = `${path16__default.join("ontology", "actions", `${action.shortApiName}.ts`)}`;
|
|
1139
|
-
const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.og);
|
|
1140
|
-
const uniqueApiNames = new Set(uniqueApiNamesArray);
|
|
1141
|
-
const uniqueApiNamesString = stringUnionFrom2([...uniqueApiNames]);
|
|
1142
|
-
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action.og));
|
|
1143
|
-
function createV1Object() {
|
|
1144
|
-
return ` export const ${action.shortApiName} = ${JSON.stringify(fullActionDef, null, 2)} satisfies ActionDefinition<"${action.shortApiName}", ${uniqueApiNamesString}>;`;
|
|
1145
|
-
}
|
|
1146
|
-
const referencedObjectDefs = /* @__PURE__ */ new Set();
|
|
1147
|
-
for (const p of Object.values(action.parameters)) {
|
|
1148
|
-
if (p.dataType.type === "object" || p.dataType.type === "objectSet") {
|
|
1149
|
-
if (p.dataType.objectApiName) {
|
|
1150
|
-
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.objectApiName));
|
|
1151
|
-
}
|
|
1152
|
-
if (p.dataType.objectTypeApiName) {
|
|
1153
|
-
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.objectTypeApiName));
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
if (p.dataType.type === "array" && (p.dataType.subType.type === "object" || p.dataType.subType.type === "objectSet")) {
|
|
1157
|
-
if (p.dataType.subType.objectApiName) {
|
|
1158
|
-
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.subType.objectApiName));
|
|
1159
|
-
}
|
|
1160
|
-
if (p.dataType.subType.objectTypeApiName) {
|
|
1161
|
-
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.subType.objectTypeApiName));
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
const imports = getObjectImports(referencedObjectDefs, void 0, currentFilePath, false);
|
|
1166
|
-
await fs2.writeFile(path16__default.join(rootOutDir, currentFilePath), await formatTs(`
|
|
1167
|
-
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound} from "@osdk/api";
|
|
1168
|
-
import type { ApplyActionOptions, ApplyBatchActionOptions, ActionReturnTypeForOptions, ActionParam } from '@osdk/client.api';
|
|
1169
|
-
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
1170
|
-
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1171
|
-
${imports}
|
|
1172
|
-
|
|
1173
|
-
${createV1Object()}
|
|
1174
|
-
`));
|
|
1175
|
-
}));
|
|
1176
|
-
const indexFileRelPath = path16__default.join("ontology", "actions", `index.ts`);
|
|
1177
|
-
await fs2.writeFile(path16__default.join(rootOutDir, indexFileRelPath), await formatTs(`
|
|
1178
|
-
${Object.values(enhancedOntology.actionTypes).map((action) => {
|
|
1179
|
-
const exportConstLine = `export {${action.shortApiName} } from "${action.getImportPathRelTo(indexFileRelPath)}";`;
|
|
1180
|
-
`export type { ${action.paramsIdentifier} } from "${action.getImportPathRelTo(indexFileRelPath)}";`;
|
|
1181
|
-
return exportConstLine;
|
|
1182
|
-
}).join("\n")}
|
|
1183
|
-
${Object.keys(ontology.actionTypes).length === 0 ? "export {};" : ""}
|
|
1184
|
-
`));
|
|
1185
|
-
}
|
|
1186
|
-
function extractReferencedObjectsFromAction(actionType) {
|
|
1187
|
-
const referencedObjectsInParameters = Object.values(actionType.parameters).flatMap(({
|
|
1188
|
-
dataType
|
|
1189
|
-
}) => {
|
|
1190
|
-
const objectTypeReference = extractReferencedObjectsFromActionParameter(dataType);
|
|
1191
|
-
return objectTypeReference ? [objectTypeReference] : [];
|
|
1192
|
-
});
|
|
1193
|
-
const referenceObjectsInEdits = actionType.operations.flatMap((value) => {
|
|
1194
|
-
switch (value.type) {
|
|
1195
|
-
case "createObject":
|
|
1196
|
-
return [value.objectTypeApiName];
|
|
1197
|
-
case "modifyObject":
|
|
1198
|
-
return [value.objectTypeApiName];
|
|
1199
|
-
case "deleteObject":
|
|
1200
|
-
case "createLink":
|
|
1201
|
-
case "deleteLink":
|
|
1202
|
-
return [];
|
|
1203
|
-
}
|
|
1204
|
-
});
|
|
1205
|
-
return [...referenceObjectsInEdits, ...referencedObjectsInParameters];
|
|
1206
|
-
}
|
|
1207
|
-
function extractReferencedObjectsFromActionParameter(actionParameter) {
|
|
1208
|
-
switch (actionParameter.type) {
|
|
1209
|
-
case "objectSet":
|
|
1210
|
-
case "object":
|
|
1211
|
-
return actionParameter.objectTypeApiName;
|
|
1212
|
-
case "array":
|
|
1213
|
-
return extractReferencedObjectsFromActionParameter(actionParameter.subType);
|
|
1214
|
-
case "string":
|
|
1215
|
-
case "boolean":
|
|
1216
|
-
case "attachment":
|
|
1217
|
-
case "date":
|
|
1218
|
-
case "double":
|
|
1219
|
-
case "integer":
|
|
1220
|
-
case "long":
|
|
1221
|
-
case "timestamp":
|
|
1222
|
-
return void 0;
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
387
|
// src/util/stringify.ts
|
|
1227
388
|
var defaultCustomizer = (value, defaultValueFormatter, key, defaultKeyFormatter) => {
|
|
1228
389
|
return [defaultKeyFormatter(key), defaultValueFormatter(value)];
|
|
@@ -1245,586 +406,23 @@ function stringify(obj, customizer = {}, separator = ",\n") {
|
|
|
1245
406
|
return entries.join(separator);
|
|
1246
407
|
}
|
|
1247
408
|
|
|
1248
|
-
// src/
|
|
1249
|
-
function
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object.og, false));
|
|
1255
|
-
const objectDefIdentifier = object.getDefinitionIdentifier(false);
|
|
1256
|
-
function getV1Types() {
|
|
1257
|
-
return `
|
|
1258
|
-
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.fullApiName}", ${object.uniqueImportName}> {
|
|
1259
|
-
${stringify(definition, {
|
|
1260
|
-
osdkMetadata: () => void 0,
|
|
1261
|
-
// not used in v1
|
|
1262
|
-
links: (_value) => `{
|
|
1263
|
-
${stringify(definition.links, {
|
|
1264
|
-
"*": (definition2) => `ObjectTypeLinkDefinition<${ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(false)}, ${definition2.multiplicity}>`
|
|
1265
|
-
})}
|
|
1266
|
-
}`
|
|
1267
|
-
})}
|
|
1268
|
-
}
|
|
1269
|
-
`;
|
|
409
|
+
// src/util/stringUnionFrom.ts
|
|
410
|
+
function stringUnionFrom(values) {
|
|
411
|
+
if (values.length === 0) {
|
|
412
|
+
return "never";
|
|
413
|
+
} else {
|
|
414
|
+
return values.map((v) => `"${v}"`).join("|");
|
|
1270
415
|
}
|
|
1271
|
-
const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, false);
|
|
1272
|
-
return `${imports}${getV1Types()}
|
|
1273
|
-
|
|
1274
|
-
export const ${object.shortApiName}: ${objectDefIdentifier} = {
|
|
1275
|
-
${stringify(definition, {
|
|
1276
|
-
osdkMetadata: (value) => void 0
|
|
1277
|
-
})}
|
|
1278
|
-
|
|
1279
|
-
};`;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
// src/util/reservedKeywords.ts
|
|
1283
|
-
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"]);
|
|
1284
|
-
function isReservedKeyword(name) {
|
|
1285
|
-
return reservedKeywords.has(name);
|
|
1286
416
|
}
|
|
1287
417
|
|
|
1288
|
-
// src/
|
|
1289
|
-
function wireObjectTypeV2ToObjectInterfaceStringV1(objectTypeWithLinks, importExt = "") {
|
|
1290
|
-
const uniqueLinkTargets = new Set(objectTypeWithLinks.linkTypes.map((a) => a.objectTypeApiName).filter((a) => a !== objectTypeWithLinks.objectType.apiName));
|
|
1291
|
-
return `import type { OntologyObject, LocalDate, Timestamp, GeoShape, GeoPoint, Attachment, TimeSeries, MultiLink, SingleLink, StringLong } from "@osdk/legacy-client";
|
|
1292
|
-
${Array.from(uniqueLinkTargets).map((linkTarget) => `import type { ${linkTarget} } from "./${linkTarget}${importExt}";`).join("\n")}
|
|
1293
|
-
|
|
1294
|
-
${getDescriptionIfPresent(objectTypeWithLinks.objectType.description)}
|
|
1295
|
-
export interface ${objectTypeWithLinks.objectType.apiName} extends OntologyObject {
|
|
1296
|
-
/** @deprecated please migrate to $apiName instead */
|
|
1297
|
-
readonly __apiName: "${objectTypeWithLinks.objectType.apiName}" & {${objectTypeWithLinks.linkTypes.map((linkType) => {
|
|
1298
|
-
return `/** @deprecated please migrate to pivotTo(${linkType.apiName}) instead */ searchAround${linkType.apiName.charAt(0).toUpperCase() + linkType.apiName.slice(1)}?: never`;
|
|
1299
|
-
})}};
|
|
1300
|
-
/** @deprecated please migrate to $primaryKey instead */
|
|
1301
|
-
readonly __primaryKey: ${wirePropertyTypeV2ToTypeScriptType(objectTypeWithLinks.objectType.properties[objectTypeWithLinks.objectType.primaryKey].dataType)};
|
|
1302
|
-
readonly $apiName: "${objectTypeWithLinks.objectType.apiName}";
|
|
1303
|
-
readonly $primaryKey: ${wirePropertyTypeV2ToTypeScriptType(objectTypeWithLinks.objectType.properties[objectTypeWithLinks.objectType.primaryKey].dataType)};
|
|
1304
|
-
${Object.entries(objectTypeWithLinks.objectType.properties).sort((a, b) => a[0].localeCompare(b[0])).flatMap(([propertyName, propertyDefinition]) => {
|
|
1305
|
-
const propertyType = wirePropertyTypeV2ToTypeScriptType(propertyDefinition.dataType);
|
|
1306
|
-
const entries = [`${getDescriptionIfPresent(propertyDefinition.description, true)}readonly ${propertyName}: ${propertyType} | undefined`];
|
|
1307
|
-
if (isReservedKeyword(propertyName)) {
|
|
1308
|
-
entries.push(`/** @deprecated please migrate to '${propertyName}' instead */
|
|
1309
|
-
readonly ${propertyName}_: ${propertyType} | undefined`);
|
|
1310
|
-
}
|
|
1311
|
-
return entries;
|
|
1312
|
-
}).join(";\n")}
|
|
1313
|
-
${objectTypeWithLinks.linkTypes.flatMap((linkType) => {
|
|
1314
|
-
const entries = [`readonly ${linkType.apiName}: ${linkType.cardinality === "MANY" ? "MultiLink" : "SingleLink"}<${linkType.objectTypeApiName}>`];
|
|
1315
|
-
return entries;
|
|
1316
|
-
}).join(";\n")}
|
|
1317
|
-
}
|
|
1318
|
-
`;
|
|
1319
|
-
}
|
|
1320
|
-
function wirePropertyTypeV2ToTypeScriptType(property) {
|
|
1321
|
-
switch (property.type) {
|
|
1322
|
-
case "string":
|
|
1323
|
-
return "string";
|
|
1324
|
-
case "boolean":
|
|
1325
|
-
return "boolean";
|
|
1326
|
-
case "array":
|
|
1327
|
-
return wirePropertyTypeV2ToTypeScriptType(property.subType) + "[]";
|
|
1328
|
-
case "integer":
|
|
1329
|
-
return "number";
|
|
1330
|
-
case "attachment":
|
|
1331
|
-
return "Attachment";
|
|
1332
|
-
case "byte":
|
|
1333
|
-
return "number";
|
|
1334
|
-
case "date":
|
|
1335
|
-
return "LocalDate";
|
|
1336
|
-
case "decimal":
|
|
1337
|
-
return "string";
|
|
1338
|
-
case "double":
|
|
1339
|
-
return "number";
|
|
1340
|
-
case "float":
|
|
1341
|
-
return "number";
|
|
1342
|
-
case "geopoint":
|
|
1343
|
-
return "GeoPoint";
|
|
1344
|
-
case "geoshape":
|
|
1345
|
-
return "GeoShape";
|
|
1346
|
-
case "long":
|
|
1347
|
-
return "StringLong";
|
|
1348
|
-
case "short":
|
|
1349
|
-
return "number";
|
|
1350
|
-
case "timestamp":
|
|
1351
|
-
return "Timestamp";
|
|
1352
|
-
case "timeseries":
|
|
1353
|
-
return property.itemType.type === "string" ? `TimeSeries<string>` : `TimeSeries<number>`;
|
|
1354
|
-
case "marking":
|
|
1355
|
-
return "string";
|
|
1356
|
-
default:
|
|
1357
|
-
throw new Error(`Unknown property type ${property}`);
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
418
|
+
// src/v2.0/getDescriptionIfPresent.ts
|
|
1360
419
|
function getDescriptionIfPresent(description, includeNewline) {
|
|
1361
420
|
if (description) {
|
|
1362
421
|
return `/**
|
|
1363
422
|
* ${description}
|
|
1364
|
-
*/${
|
|
1365
|
-
}
|
|
1366
|
-
return "";
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
// src/v1.1/generatePerObjectInterfaceAndDataFiles.ts
|
|
1370
|
-
async function generatePerObjectInterfaceAndDataFiles(ontology, fs2, outDir, importExt = "") {
|
|
1371
|
-
await fs2.mkdir(outDir, {
|
|
1372
|
-
recursive: true
|
|
1373
|
-
});
|
|
1374
|
-
await Promise.all(Object.values(ontology.og.objectTypes).map(async (object) => {
|
|
1375
|
-
const relPath = path16__default.join(".", "ontology", `objects`, `${object.objectType.apiName}.ts`);
|
|
1376
|
-
await fs2.writeFile(path16__default.join(outDir, `${object.objectType.apiName}.ts`), await formatTs(`
|
|
1377
|
-
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
|
|
1378
|
-
${wireObjectTypeV2ToObjectInterfaceStringV1(object, importExt)}
|
|
1379
|
-
|
|
1380
|
-
${wireObjectTypeV2ToSdkObjectConstV1(object, {
|
|
1381
|
-
ontology
|
|
1382
|
-
}, relPath)}
|
|
1383
|
-
`));
|
|
1384
|
-
}));
|
|
1385
|
-
await fs2.writeFile(path16__default.join(outDir, "index.ts"), await formatTs(`
|
|
1386
|
-
${Object.keys(ontology.og.objectTypes).map((apiName) => `export * from "./${apiName}${importExt}";`).join("\n")}
|
|
1387
|
-
export type { ObjectSet } from "@osdk/legacy-client";
|
|
1388
|
-
|
|
1389
|
-
`));
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
// src/shared/getObjectTypesFromQueryDataType.ts
|
|
1393
|
-
function getObjectTypesFromQueryDataType(dataType, types) {
|
|
1394
|
-
switch (dataType.type) {
|
|
1395
|
-
case "array":
|
|
1396
|
-
case "set":
|
|
1397
|
-
getObjectTypesFromQueryDataType(dataType.subType, types);
|
|
1398
|
-
return;
|
|
1399
|
-
case "object":
|
|
1400
|
-
types.add(dataType.objectTypeApiName);
|
|
1401
|
-
return;
|
|
1402
|
-
case "objectSet":
|
|
1403
|
-
types.add(dataType.objectTypeApiName);
|
|
1404
|
-
return;
|
|
1405
|
-
case "struct":
|
|
1406
|
-
for (const prop of Object.values(dataType.fields)) {
|
|
1407
|
-
getObjectTypesFromQueryDataType(prop.fieldType, types);
|
|
1408
|
-
}
|
|
1409
|
-
return;
|
|
1410
|
-
case "union":
|
|
1411
|
-
for (const type of dataType.unionTypes) {
|
|
1412
|
-
getObjectTypesFromQueryDataType(type, types);
|
|
1413
|
-
}
|
|
1414
|
-
return;
|
|
1415
|
-
case "attachment":
|
|
1416
|
-
case "boolean":
|
|
1417
|
-
case "date":
|
|
1418
|
-
case "double":
|
|
1419
|
-
case "float":
|
|
1420
|
-
case "integer":
|
|
1421
|
-
case "long":
|
|
1422
|
-
case "null":
|
|
1423
|
-
case "string":
|
|
1424
|
-
case "threeDimensionalAggregation":
|
|
1425
|
-
case "timestamp":
|
|
1426
|
-
case "twoDimensionalAggregation":
|
|
1427
|
-
case "unsupported":
|
|
1428
|
-
return;
|
|
1429
|
-
default:
|
|
1430
|
-
throw new Error(`Cannot find object types from unsupported QueryDataType ${dataType.type}`);
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
// src/shared/getObjectTypeApiNamesFromQuery.ts
|
|
1435
|
-
function getObjectTypeApiNamesFromQuery(query) {
|
|
1436
|
-
const types = /* @__PURE__ */ new Set();
|
|
1437
|
-
for (const {
|
|
1438
|
-
dataType
|
|
1439
|
-
} of Object.values(query.parameters)) {
|
|
1440
|
-
getObjectTypesFromQueryDataType(dataType, types);
|
|
1441
|
-
}
|
|
1442
|
-
getObjectTypesFromQueryDataType(query.output, types);
|
|
1443
|
-
return Array.from(types);
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
// src/shared/isNullableQueryDataType.ts
|
|
1447
|
-
function isNullableQueryDataType(input) {
|
|
1448
|
-
if (input.type === "null") {
|
|
1449
|
-
return true;
|
|
1450
|
-
}
|
|
1451
|
-
if (input.type === "union") {
|
|
1452
|
-
return input.unionTypes.some((t) => isNullableQueryDataType(t));
|
|
1453
|
-
}
|
|
1454
|
-
return false;
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
// src/shared/wireQueryDataTypeToQueryDataTypeDefinition.ts
|
|
1458
|
-
function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
1459
|
-
switch (input.type) {
|
|
1460
|
-
case "double":
|
|
1461
|
-
case "float":
|
|
1462
|
-
case "integer":
|
|
1463
|
-
case "long":
|
|
1464
|
-
case "attachment":
|
|
1465
|
-
case "boolean":
|
|
1466
|
-
case "date":
|
|
1467
|
-
case "string":
|
|
1468
|
-
case "timestamp":
|
|
1469
|
-
return {
|
|
1470
|
-
type: input.type,
|
|
1471
|
-
nullable: false
|
|
1472
|
-
};
|
|
1473
|
-
case "object":
|
|
1474
|
-
return {
|
|
1475
|
-
type: "object",
|
|
1476
|
-
object: input.objectTypeApiName,
|
|
1477
|
-
nullable: false
|
|
1478
|
-
};
|
|
1479
|
-
case "objectSet":
|
|
1480
|
-
return {
|
|
1481
|
-
type: "objectSet",
|
|
1482
|
-
objectSet: input.objectTypeApiName,
|
|
1483
|
-
nullable: false
|
|
1484
|
-
};
|
|
1485
|
-
case "array":
|
|
1486
|
-
return {
|
|
1487
|
-
...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
|
|
1488
|
-
multiplicity: true
|
|
1489
|
-
};
|
|
1490
|
-
case "set":
|
|
1491
|
-
return {
|
|
1492
|
-
type: "set",
|
|
1493
|
-
set: wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
|
|
1494
|
-
nullable: false
|
|
1495
|
-
};
|
|
1496
|
-
case "union":
|
|
1497
|
-
const allowNulls = isNullableQueryDataType(input);
|
|
1498
|
-
if (allowNulls && input.unionTypes.length === 2) {
|
|
1499
|
-
const nonNull = input.unionTypes.find((t) => t.type != null);
|
|
1500
|
-
if (nonNull) {
|
|
1501
|
-
return {
|
|
1502
|
-
...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),
|
|
1503
|
-
nullable: true
|
|
1504
|
-
};
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
return {
|
|
1508
|
-
type: "union",
|
|
1509
|
-
union: input.unionTypes.reduce((acc, t) => {
|
|
1510
|
-
if (t.type === "null") {
|
|
1511
|
-
return acc;
|
|
1512
|
-
}
|
|
1513
|
-
acc.push(wireQueryDataTypeToQueryDataTypeDefinition(t));
|
|
1514
|
-
return acc;
|
|
1515
|
-
}, []),
|
|
1516
|
-
nullable: allowNulls
|
|
1517
|
-
};
|
|
1518
|
-
case "struct":
|
|
1519
|
-
return {
|
|
1520
|
-
type: "struct",
|
|
1521
|
-
struct: Object.fromEntries(input.fields.map((f) => [f.name, wireQueryDataTypeToQueryDataTypeDefinition(f.fieldType)])),
|
|
1522
|
-
nullable: false
|
|
1523
|
-
};
|
|
1524
|
-
case "twoDimensionalAggregation":
|
|
1525
|
-
return {
|
|
1526
|
-
type: "twoDimensionalAggregation",
|
|
1527
|
-
twoDimensionalAggregation: get2DQueryAggregationProps(input),
|
|
1528
|
-
nullable: false
|
|
1529
|
-
};
|
|
1530
|
-
case "threeDimensionalAggregation":
|
|
1531
|
-
return {
|
|
1532
|
-
type: "threeDimensionalAggregation",
|
|
1533
|
-
threeDimensionalAggregation: get3DQueryAggregationProps(input),
|
|
1534
|
-
nullable: false
|
|
1535
|
-
};
|
|
1536
|
-
case "null":
|
|
1537
|
-
case "unsupported":
|
|
1538
|
-
throw new Error(`Accidentally tried to handle QueryDataType.type ${input.type}`);
|
|
1539
|
-
default:
|
|
1540
|
-
throw new Error(`Unsupported QueryDataType.type ${input.type}`);
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
function get2DQueryAggregationProps(input) {
|
|
1544
|
-
if (input.keyType.type === "range") {
|
|
1545
|
-
return {
|
|
1546
|
-
keyType: input.keyType.type,
|
|
1547
|
-
keySubtype: input.keyType.subType.type,
|
|
1548
|
-
valueType: input.valueType.type
|
|
1549
|
-
};
|
|
1550
|
-
} else {
|
|
1551
|
-
if (guardInvalidKeyTypes(input.keyType)) {
|
|
1552
|
-
return {
|
|
1553
|
-
keyType: input.keyType.type,
|
|
1554
|
-
valueType: input.valueType.type
|
|
1555
|
-
};
|
|
1556
|
-
}
|
|
1557
|
-
throw new Error(`Cannot create 2D aggregation with ${input.keyType.type} as its type`);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
function get3DQueryAggregationProps(input) {
|
|
1561
|
-
if (input.keyType.type === "range") {
|
|
1562
|
-
return {
|
|
1563
|
-
keyType: input.keyType.type,
|
|
1564
|
-
keySubtype: input.keyType.subType.type,
|
|
1565
|
-
valueType: get2DQueryAggregationProps(input.valueType)
|
|
1566
|
-
};
|
|
1567
|
-
} else {
|
|
1568
|
-
if (guardInvalidKeyTypes(input.keyType)) {
|
|
1569
|
-
return {
|
|
1570
|
-
keyType: input.keyType.type,
|
|
1571
|
-
valueType: get2DQueryAggregationProps(input.valueType)
|
|
1572
|
-
};
|
|
1573
|
-
}
|
|
1574
|
-
throw new Error(`Cannot create 3D aggregation with ${input.keyType.type} as its type`);
|
|
1575
|
-
}
|
|
1576
|
-
}
|
|
1577
|
-
function guardInvalidKeyTypes(key) {
|
|
1578
|
-
return key.type === "string" || key.type === "boolean";
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
// src/shared/wireQueryTypeV2ToSdkQueryDefinition.ts
|
|
1582
|
-
function wireQueryTypeV2ToSdkQueryDefinition(input) {
|
|
1583
|
-
return {
|
|
1584
|
-
type: "query",
|
|
1585
|
-
apiName: input.apiName,
|
|
1586
|
-
description: input.description,
|
|
1587
|
-
displayName: input.displayName,
|
|
1588
|
-
version: input.version,
|
|
1589
|
-
parameters: Object.fromEntries(Object.entries(input.parameters).map(([name, parameter]) => [name, wireQueryParameterV2ToQueryParameterDefinition(parameter)])),
|
|
1590
|
-
output: wireQueryDataTypeToQueryDataTypeDefinition(input.output)
|
|
1591
|
-
};
|
|
1592
|
-
}
|
|
1593
|
-
function wireQueryTypeV2ToSdkQueryDefinitionNoParams(input) {
|
|
1594
|
-
return {
|
|
1595
|
-
type: "query",
|
|
1596
|
-
apiName: input.apiName,
|
|
1597
|
-
description: input.description,
|
|
1598
|
-
displayName: input.displayName,
|
|
1599
|
-
version: input.version
|
|
1600
|
-
};
|
|
1601
|
-
}
|
|
1602
|
-
function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
1603
|
-
return {
|
|
1604
|
-
description: parameter.description,
|
|
1605
|
-
...wireQueryDataTypeToQueryDataTypeDefinition(parameter.dataType)
|
|
1606
|
-
};
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
// src/v1.1/generatePerQueryDataFiles.ts
|
|
1610
|
-
async function generatePerQueryDataFiles({
|
|
1611
|
-
fs: fs2,
|
|
1612
|
-
outDir: rootOutDir,
|
|
1613
|
-
ontology
|
|
1614
|
-
}, v2) {
|
|
1615
|
-
const relOutDir = path16__default.join(".", "ontology", "queries");
|
|
1616
|
-
const outDir = path16__default.join(rootOutDir, "ontology", "queries");
|
|
1617
|
-
await fs2.mkdir(outDir, {
|
|
1618
|
-
recursive: true
|
|
1619
|
-
});
|
|
1620
|
-
await Promise.all(Object.values(ontology.queryTypes).map(async (query) => {
|
|
1621
|
-
await generateV1QueryFile(fs2, outDir, query);
|
|
1622
|
-
}));
|
|
1623
|
-
await fs2.writeFile(path16__default.join(outDir, "index.ts"), await formatTs(`
|
|
1624
|
-
${Object.values(ontology.queryTypes).map((query) => `export * from "${query.getImportPathRelTo(path16__default.join(relOutDir, "index.ts"))}";`).join("\n")}
|
|
1625
|
-
${Object.keys(ontology.queryTypes).length === 0 ? "export {};" : ""}
|
|
1626
|
-
`));
|
|
1627
|
-
}
|
|
1628
|
-
async function generateV1QueryFile(fs2, outDir, query) {
|
|
1629
|
-
const objectTypes = getObjectTypeApiNamesFromQuery(query);
|
|
1630
|
-
await fs2.writeFile(path16__default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
1631
|
-
import { QueryDefinition } from "@osdk/api";
|
|
1632
|
-
|
|
1633
|
-
export const ${query.shortApiName} = ${JSON.stringify(wireQueryTypeV2ToSdkQueryDefinition(query.og))} ${getQueryDefSatisfies(query.fullApiName, objectTypes)}`));
|
|
1634
|
-
}
|
|
1635
|
-
function getQueryDefSatisfies(apiName, objectTypes) {
|
|
1636
|
-
return `satisfies QueryDefinition<"${apiName}", ${objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never"}>;`;
|
|
1637
|
-
}
|
|
1638
|
-
async function generateQueries(ontology, fs2, outDir, importExt = "") {
|
|
1639
|
-
const importedObjects = /* @__PURE__ */ new Set();
|
|
1640
|
-
const signatures = [];
|
|
1641
|
-
for (const query of Object.values(ontology.queryTypes)) {
|
|
1642
|
-
const jsDocBlock = ["/**"];
|
|
1643
|
-
if (query.description) {
|
|
1644
|
-
jsDocBlock.push(`* ${query.description}`);
|
|
1645
|
-
}
|
|
1646
|
-
const outputType = handleQueryDataType(query.output, importedObjects, true);
|
|
1647
|
-
const paramEntries = [];
|
|
1648
|
-
for (const [name, parameter] of Object.entries(query.parameters)) {
|
|
1649
|
-
const nullable = isNullableQueryDataType(parameter.dataType);
|
|
1650
|
-
const type = handleQueryDataType(parameter.dataType, importedObjects, false);
|
|
1651
|
-
paramEntries.push(`"${name}"${nullable ? "?" : ""}: ${type}`);
|
|
1652
|
-
jsDocBlock.push(`* @param {${sanitizeDocTypeName(type)}} params.${name}${parameter.description ? ` - ${parameter.description}` : ""}`);
|
|
1653
|
-
}
|
|
1654
|
-
const param = paramEntries.length === 0 ? "" : `params: { ${paramEntries.join("; ")} }`;
|
|
1655
|
-
jsDocBlock.push(`* @returns ${sanitizeDocTypeName(outputType)}`, "*/");
|
|
1656
|
-
signatures.push(`
|
|
1657
|
-
${jsDocBlock.join("\n")}
|
|
1658
|
-
${query.apiName}(${param}): Promise<Result<QueryResponse<${outputType}>, QueryError>>;
|
|
1659
|
-
`);
|
|
1660
|
-
}
|
|
1661
|
-
await fs2.mkdir(outDir, {
|
|
1662
|
-
recursive: true
|
|
1663
|
-
});
|
|
1664
|
-
await fs2.writeFile(path16__default.join(outDir, "Queries.ts"), await formatTs(`
|
|
1665
|
-
import type { QueryResponse, QueryError, Result, Timestamp, LocalDate, Range, Attachment, ObjectSet, TwoDimensionalAggregation, ThreeDimensionalAggregation } from "@osdk/legacy-client";
|
|
1666
|
-
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
1667
|
-
|
|
1668
|
-
export interface Queries {
|
|
1669
|
-
${signatures.join("\n")}
|
|
1670
|
-
}
|
|
1671
|
-
`));
|
|
1672
|
-
}
|
|
1673
|
-
function handleQueryDataType(dataType, importedObjects, isReturnValue) {
|
|
1674
|
-
switch (dataType.type) {
|
|
1675
|
-
case "boolean":
|
|
1676
|
-
return "boolean";
|
|
1677
|
-
case "string":
|
|
1678
|
-
return "string";
|
|
1679
|
-
case "double":
|
|
1680
|
-
case "float":
|
|
1681
|
-
case "integer":
|
|
1682
|
-
return "number";
|
|
1683
|
-
case "long":
|
|
1684
|
-
return isReturnValue ? "string" : "string | number";
|
|
1685
|
-
case "date":
|
|
1686
|
-
return "LocalDate";
|
|
1687
|
-
case "timestamp":
|
|
1688
|
-
return "Timestamp";
|
|
1689
|
-
case "attachment":
|
|
1690
|
-
return "Attachment";
|
|
1691
|
-
case "array":
|
|
1692
|
-
return `Array<${handleQueryDataType(dataType.subType, importedObjects, isReturnValue)}>`;
|
|
1693
|
-
case "object": {
|
|
1694
|
-
const objectType = dataType.objectTypeApiName;
|
|
1695
|
-
importedObjects.add(objectType);
|
|
1696
|
-
return isReturnValue ? objectType : `${objectType} | ${objectType}["__primaryKey"]`;
|
|
1697
|
-
}
|
|
1698
|
-
case "objectSet": {
|
|
1699
|
-
const objectType = dataType.objectTypeApiName;
|
|
1700
|
-
importedObjects.add(objectType);
|
|
1701
|
-
return `ObjectSet<${objectType}>`;
|
|
1702
|
-
}
|
|
1703
|
-
case "set":
|
|
1704
|
-
return `Set<${handleQueryDataType(dataType.subType, importedObjects, isReturnValue)}>`;
|
|
1705
|
-
case "struct":
|
|
1706
|
-
const properties = dataType.fields.map((field) => {
|
|
1707
|
-
const isNullable = isNullableQueryDataType(field.fieldType);
|
|
1708
|
-
return `${field.name}${isNullable ? "?" : ""}: ${handleQueryDataType(field.fieldType, importedObjects, isReturnValue)}`;
|
|
1709
|
-
});
|
|
1710
|
-
return `{ ${properties.join(",\n")} }`;
|
|
1711
|
-
case "union":
|
|
1712
|
-
return dataType.unionTypes.map((type) => handleQueryDataType(type, importedObjects, isReturnValue)).filter((type) => type !== "null").join("|");
|
|
1713
|
-
case "twoDimensionalAggregation":
|
|
1714
|
-
dataType.valueType;
|
|
1715
|
-
return `TwoDimensionalAggregation<
|
|
1716
|
-
${aggregationKeyToTypescriptType(dataType.keyType)},
|
|
1717
|
-
${aggregationValueToTypescriptType(dataType.valueType)}
|
|
1718
|
-
>`;
|
|
1719
|
-
case "threeDimensionalAggregation":
|
|
1720
|
-
return `ThreeDimensionalAggregation<
|
|
1721
|
-
${aggregationKeyToTypescriptType(dataType.keyType)},
|
|
1722
|
-
${aggregationKeyToTypescriptType(dataType.valueType.keyType)},
|
|
1723
|
-
${aggregationValueToTypescriptType(dataType.valueType.valueType)}
|
|
1724
|
-
>`;
|
|
1725
|
-
case "null":
|
|
1726
|
-
return "null";
|
|
1727
|
-
case "unsupported":
|
|
1728
|
-
throw new Error("Cannot generate queries for unsupported type");
|
|
1729
|
-
default:
|
|
1730
|
-
throw new Error(`Cannot generate queries for type ${dataType.type}`);
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
function aggregationKeyToTypescriptType(keyType) {
|
|
1734
|
-
switch (keyType.type) {
|
|
1735
|
-
case "boolean":
|
|
1736
|
-
return "boolean";
|
|
1737
|
-
case "double":
|
|
1738
|
-
case "integer":
|
|
1739
|
-
return "number";
|
|
1740
|
-
case "string":
|
|
1741
|
-
return "string";
|
|
1742
|
-
case "date":
|
|
1743
|
-
return "LocalDate";
|
|
1744
|
-
case "timestamp":
|
|
1745
|
-
return "Timestamp";
|
|
1746
|
-
case "range":
|
|
1747
|
-
return `Range<${aggregationRangeToTypescriptType(keyType.subType)}>`;
|
|
1748
|
-
default:
|
|
1749
|
-
throw new Error(`Unknown TwoDimensionalAggregation keyType ${keyType.type}`);
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
function aggregationRangeToTypescriptType(subType) {
|
|
1753
|
-
switch (subType.type) {
|
|
1754
|
-
case "date":
|
|
1755
|
-
return "LocalDate";
|
|
1756
|
-
case "double":
|
|
1757
|
-
case "integer":
|
|
1758
|
-
return "number";
|
|
1759
|
-
case "timestamp":
|
|
1760
|
-
return "Timestamp";
|
|
1761
|
-
default:
|
|
1762
|
-
throw new Error(`Unsupported QueryAggregationRangeSubType ${subType.type}`);
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
function aggregationValueToTypescriptType(valueType) {
|
|
1766
|
-
switch (valueType.type) {
|
|
1767
|
-
case "date":
|
|
1768
|
-
return "LocalDate";
|
|
1769
|
-
case "double":
|
|
1770
|
-
return "number";
|
|
1771
|
-
case "timestamp":
|
|
1772
|
-
return "Timestamp";
|
|
1773
|
-
default:
|
|
1774
|
-
throw new Error(`Unsupported QueryAggregationValueType ${valueType.type}`);
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
function sanitizeDocTypeName(type) {
|
|
1778
|
-
return type.replace(/\s/g, "");
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
// src/v1.1/generateClientSdkVersionOneDotOne.ts
|
|
1782
|
-
async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDir, packageType = "commonjs") {
|
|
1783
|
-
const importExt = packageType === "module" ? ".js" : "";
|
|
1784
|
-
const objectsDir = path16.join(outDir, "ontology", "objects");
|
|
1785
|
-
const actionsDir = path16.join(outDir, "ontology", "actions");
|
|
1786
|
-
const queriesDir = path16.join(outDir, "ontology", "queries");
|
|
1787
|
-
await verifyOutDir(outDir, fs2);
|
|
1788
|
-
await fs2.mkdir(outDir, {
|
|
1789
|
-
recursive: true
|
|
1790
|
-
});
|
|
1791
|
-
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
1792
|
-
const enhancedOntology = enhanceOntology(sanitizedOntology, void 0, /* @__PURE__ */ new Map(), importExt);
|
|
1793
|
-
await generateFoundryClientFile(fs2, outDir, importExt);
|
|
1794
|
-
await generateMetadataFile(sanitizedOntology, userAgent, fs2, outDir, importExt);
|
|
1795
|
-
await generateOntologyIndexFile(fs2, path16.join(outDir, "ontology"));
|
|
1796
|
-
await generateObjectsInterfaceFile(sanitizedOntology, fs2, objectsDir, importExt);
|
|
1797
|
-
await generateObjectsInterfaceSupportFiles(sanitizedOntology, fs2, path16.join(objectsDir, "objects-api"), importExt);
|
|
1798
|
-
await generatePerObjectInterfaceAndDataFiles(enhancedOntology, fs2, objectsDir, importExt);
|
|
1799
|
-
const common = {
|
|
1800
|
-
sanitizedOntology,
|
|
1801
|
-
fs: fs2,
|
|
1802
|
-
outDir,
|
|
1803
|
-
ontology: enhancedOntology
|
|
1804
|
-
};
|
|
1805
|
-
await generateActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1806
|
-
await generateBatchActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1807
|
-
await generateBulkActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1808
|
-
await generatePerActionDataFilesV1(common);
|
|
1809
|
-
await generateQueries(sanitizedOntology, fs2, queriesDir, importExt);
|
|
1810
|
-
await generatePerQueryDataFiles(common);
|
|
1811
|
-
await generateIndexFile(fs2, outDir, importExt);
|
|
1812
|
-
await generateBackCompatDeprecatedExports(fs2, outDir, importExt);
|
|
1813
|
-
}
|
|
1814
|
-
var ExpectedOsdkVersion = "0.22.0";
|
|
1815
|
-
async function generateOntologyMetadataFile({
|
|
1816
|
-
fs: fs2,
|
|
1817
|
-
outDir,
|
|
1818
|
-
ontology,
|
|
1819
|
-
ontologyApiNamespace
|
|
1820
|
-
}, userAgent) {
|
|
1821
|
-
fs2.writeFile(path16__default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
1822
|
-
export type $ExpectedClientVersion = "${ExpectedOsdkVersion}";
|
|
1823
|
-
export const $osdkMetadata = { extraUserAgent: "${userAgent}" };
|
|
1824
|
-
${ontologyApiNamespace == null ? `
|
|
1825
|
-
export const $ontologyRid = "${ontology.ontology.rid}";
|
|
1826
|
-
` : ""}
|
|
1827
|
-
`));
|
|
423
|
+
*/${""}`;
|
|
424
|
+
}
|
|
425
|
+
return "";
|
|
1828
426
|
}
|
|
1829
427
|
|
|
1830
428
|
// src/shared/propertyJsdoc.ts
|
|
@@ -1866,7 +464,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
1866
464
|
}, currentFilePath) {
|
|
1867
465
|
const object = ontology.requireObjectType(wireObject.objectType.apiName, true);
|
|
1868
466
|
const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map((a) => ontology.requireObjectType(a.objectTypeApiName, false)));
|
|
1869
|
-
const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object.
|
|
467
|
+
const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object.raw, true));
|
|
1870
468
|
const objectDefIdentifier = object.getDefinitionIdentifier(true);
|
|
1871
469
|
const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;
|
|
1872
470
|
const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;
|
|
@@ -1875,7 +473,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
1875
473
|
const osdkObjectLinksIdentifier = `${object.shortApiName}.Links`;
|
|
1876
474
|
const osdkObjectIdentifier = `${object.shortApiName}.OsdkObject`;
|
|
1877
475
|
const identifiers = {
|
|
1878
|
-
objectDefIdentifier: `${object.shortApiName}
|
|
476
|
+
objectDefIdentifier: `${object.shortApiName}`,
|
|
1879
477
|
osdkObjectLinksIdentifier,
|
|
1880
478
|
osdkObjectPropsIdentifier,
|
|
1881
479
|
osdkObjectStrictPropsIdentifier,
|
|
@@ -1885,42 +483,18 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
1885
483
|
};
|
|
1886
484
|
function getV2Types() {
|
|
1887
485
|
return `import type {
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
DefaultToFalse as $DefaultToFalse,
|
|
1894
|
-
FetchPageArgs as $FetchPageArgs,
|
|
1895
|
-
FetchPageResult as $FetchPageResult,
|
|
1896
|
-
IsAny as $IsAny,
|
|
1897
|
-
LinkedType as $LinkedType,
|
|
1898
|
-
LinkNames as $LinkNames,
|
|
1899
|
-
NullabilityAdherence as $NullabilityAdherence,
|
|
1900
|
-
NullabilityAdherenceDefault as $NullabilityAdherenceDefault,
|
|
486
|
+
ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
|
|
487
|
+
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
488
|
+
ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
|
|
489
|
+
} from "@osdk/api";
|
|
490
|
+
import type {
|
|
1901
491
|
ObjectSet as $ObjectSet,
|
|
1902
492
|
Osdk as $Osdk,
|
|
1903
493
|
OsdkObject as $OsdkObject,
|
|
1904
|
-
OsdkObjectLinksEntry as $OsdkObjectLinksEntry,
|
|
1905
|
-
OsdkObjectLinksObject as $OsdkObjectLinksObject,
|
|
1906
|
-
OsdkObjectPropertyType as $OsdkObjectPropertyType,
|
|
1907
|
-
PageResult as $PageResult,
|
|
1908
|
-
PropertyValueClientToWire as $PropertyValueClientToWire,
|
|
1909
494
|
PropertyValueWireToClient as $PropType,
|
|
1910
|
-
Result as $Result,
|
|
1911
|
-
SelectArg as $SelectArg,
|
|
1912
495
|
SingleLinkAccessor as $SingleLinkAccessor,
|
|
1913
|
-
SingleLinkAccessor as $SingleLinkAccessor
|
|
1914
|
-
SingleOsdkResult as $SingleOsdkResult,
|
|
1915
|
-
ValidToFrom as $ValidToFrom,
|
|
1916
|
-
WhereClause as $WhereClause,
|
|
1917
496
|
} from "@osdk/client.api";
|
|
1918
|
-
|
|
1919
|
-
import type {
|
|
1920
|
-
ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
|
|
1921
|
-
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
1922
|
-
ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
|
|
1923
|
-
} from "@osdk/api";
|
|
497
|
+
|
|
1924
498
|
|
|
1925
499
|
export namespace ${object.shortApiName} {
|
|
1926
500
|
|
|
@@ -1933,16 +507,15 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
1933
507
|
${createProps(object, "StrictProps", true)}
|
|
1934
508
|
|
|
1935
509
|
${createObjectSet(object, identifiers)}
|
|
1936
|
-
|
|
1937
|
-
${createDefinition(object, ontology, "Definition", identifiers)}
|
|
510
|
+
|
|
1938
511
|
${createOsdkObject(object, "OsdkObject", identifiers)}
|
|
1939
512
|
}
|
|
1940
513
|
|
|
1941
514
|
|
|
1942
515
|
|
|
1943
|
-
|
|
516
|
+
${createDefinition(object, ontology, object.shortApiName, identifiers)}
|
|
517
|
+
|
|
1944
518
|
|
|
1945
|
-
export type ${objectDefIdentifier} = ${object.shortApiName}.Definition;
|
|
1946
519
|
|
|
1947
520
|
|
|
1948
521
|
`;
|
|
@@ -1950,7 +523,7 @@ function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
1950
523
|
const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);
|
|
1951
524
|
return `${imports}${getV2Types()}
|
|
1952
525
|
|
|
1953
|
-
export const ${object.shortApiName}: ${objectDefIdentifier}
|
|
526
|
+
export const ${object.shortApiName}: ${objectDefIdentifier}
|
|
1954
527
|
= {
|
|
1955
528
|
osdkMetadata: $osdkMetadata,
|
|
1956
529
|
objectSet: undefined as any,
|
|
@@ -1969,7 +542,7 @@ function createOsdkObject(object, identifier, {
|
|
|
1969
542
|
osdkObjectStrictPropsIdentifier,
|
|
1970
543
|
osdkObjectLinksIdentifier
|
|
1971
544
|
}) {
|
|
1972
|
-
|
|
545
|
+
object.getCleanedUpDefinition(true);
|
|
1973
546
|
return `
|
|
1974
547
|
export type ${identifier}<
|
|
1975
548
|
OPTIONS extends never | "$notStrict" | "$rid" = never,
|
|
@@ -1979,23 +552,10 @@ function createOsdkObject(object, identifier, {
|
|
|
1979
552
|
= $Osdk<
|
|
1980
553
|
${objectDefIdentifier},
|
|
1981
554
|
K | OPTIONS
|
|
1982
|
-
>
|
|
1983
|
-
|
|
1984
|
-
? ${osdkObjectStrictPropsIdentifier} :
|
|
1985
|
-
OPTIONS extends "$notStrict" ? ${osdkObjectPropsIdentifier} : ${osdkObjectStrictPropsIdentifier}
|
|
1986
|
-
, K
|
|
1987
|
-
> & {
|
|
1988
|
-
readonly $link: ${osdkObjectLinksIdentifier};
|
|
1989
|
-
readonly $title: string | undefined; // FIXME
|
|
1990
|
-
readonly $primaryKey: ${"primaryKeyApiName" in definition ? `
|
|
1991
|
-
$OsdkObjectPropertyType<${JSON.stringify(definition.properties[definition.primaryKeyApiName])},${true}>` : "string | number"}
|
|
555
|
+
>
|
|
556
|
+
|
|
1992
557
|
;
|
|
1993
|
-
|
|
1994
|
-
readonly $as: <NEW_Q extends $ValidToFrom<${objectDefIdentifier}>>(type: NEW_Q | string) => $Osdk<
|
|
1995
|
-
NEW_Q,
|
|
1996
|
-
$ConvertProps<${objectDefIdentifier}, NEW_Q, K>
|
|
1997
|
-
>;
|
|
1998
|
-
} & $OsdkObject<"${object.fullApiName}">;`;
|
|
558
|
+
`;
|
|
1999
559
|
}
|
|
2000
560
|
function createObjectSet(object, {
|
|
2001
561
|
objectDefIdentifier,
|
|
@@ -2010,74 +570,7 @@ $ObjectSet<${objectDefIdentifier},
|
|
|
2010
570
|
${objectSetIdentifier}
|
|
2011
571
|
>
|
|
2012
572
|
{
|
|
2013
|
-
readonly aggregate: <const AO extends $AggregateOpts<${objectDefIdentifier}>>(
|
|
2014
|
-
req: $AggregateOptsThatErrorsAndDisallowsOrderingWithMultipleGroupBy<${objectDefIdentifier}, AO>,
|
|
2015
|
-
) => Promise<$AggregationsResults<${objectDefIdentifier}, AO>>;
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
readonly pivotTo: <const L extends $LinkNames<${objectDefIdentifier}>>(type: L) => $LinkedType<${objectDefIdentifier}, L>["objectSet"];
|
|
2019
|
-
${object instanceof EnhancedObjectType ? `
|
|
2020
|
-
readonly fetchOne: <
|
|
2021
|
-
const L extends ${propertyKeysIdentifier},
|
|
2022
|
-
const R extends boolean,
|
|
2023
|
-
const S extends false | "throw" = $NullabilityAdherenceDefault,
|
|
2024
|
-
>(
|
|
2025
|
-
primaryKey: $PropertyValueClientToWire[${objectDefIdentifier}["primaryKeyType"]],
|
|
2026
|
-
options?: $SelectArg<${objectDefIdentifier}, L, R, S>,
|
|
2027
|
-
) => Promise<
|
|
2028
|
-
${osdkObjectIdentifier}<
|
|
2029
|
-
(S extends false ? "$notStrict" : never) | ($DefaultToFalse<R> extends false? never: "$rid" ),
|
|
2030
|
-
$IsAny<L> extends true ? ${propertyKeysIdentifier} : L
|
|
2031
|
-
>>
|
|
2032
|
-
;
|
|
2033
573
|
|
|
2034
|
-
readonly fetchOneWithErrors: <
|
|
2035
|
-
const L extends ${propertyKeysIdentifier},
|
|
2036
|
-
const R extends boolean,
|
|
2037
|
-
const S extends false | "throw" = $NullabilityAdherenceDefault,
|
|
2038
|
-
>(
|
|
2039
|
-
primaryKey: $PropertyValueClientToWire[${objectDefIdentifier}["primaryKeyType"]],
|
|
2040
|
-
options?: $SelectArg<${objectDefIdentifier}, L, R, S>,
|
|
2041
|
-
) => Promise<$Result<
|
|
2042
|
-
${osdkObjectIdentifier}<
|
|
2043
|
-
(S extends false ? "$notStrict" : never) | ($DefaultToFalse<R> extends false?never: "$rid"),
|
|
2044
|
-
$IsAny<L> extends true ? ${propertyKeysIdentifier} : L
|
|
2045
|
-
>
|
|
2046
|
-
>>
|
|
2047
|
-
|
|
2048
|
-
;
|
|
2049
|
-
|
|
2050
|
-
` : ""}
|
|
2051
|
-
|
|
2052
|
-
readonly fetchPage: <
|
|
2053
|
-
const L extends ${propertyKeysIdentifier},
|
|
2054
|
-
const R extends boolean,
|
|
2055
|
-
const const A extends $Augments,
|
|
2056
|
-
const S extends $NullabilityAdherence = $NullabilityAdherenceDefault,
|
|
2057
|
-
>(
|
|
2058
|
-
args?: $FetchPageArgs<${objectDefIdentifier}, L, R, A, S>,
|
|
2059
|
-
) => Promise<
|
|
2060
|
-
$PageResult<${osdkObjectIdentifier}<
|
|
2061
|
-
(S extends false ? "$notStrict" : never) | ($DefaultToFalse<R> extends false? never: "$rid"),
|
|
2062
|
-
$IsAny<L> extends true ? ${propertyKeysIdentifier} : L
|
|
2063
|
-
>>
|
|
2064
|
-
>;
|
|
2065
|
-
|
|
2066
|
-
readonly fetchPageWithErrors: <
|
|
2067
|
-
const L extends ${propertyKeysIdentifier},
|
|
2068
|
-
const R extends boolean,
|
|
2069
|
-
const A extends $Augments,
|
|
2070
|
-
const S extends $NullabilityAdherence = $NullabilityAdherenceDefault,
|
|
2071
|
-
>(
|
|
2072
|
-
args?: $FetchPageArgs<${objectDefIdentifier}, L, R, A, S>,
|
|
2073
|
-
) => Promise<$Result<
|
|
2074
|
-
$PageResult<${osdkObjectIdentifier}<
|
|
2075
|
-
(S extends false ? "$notStrict" : never) | ($DefaultToFalse<R> extends false? never : "$rid"),
|
|
2076
|
-
$IsAny<L> extends true ? ${propertyKeysIdentifier} : L
|
|
2077
|
-
>>
|
|
2078
|
-
>>;
|
|
2079
|
-
|
|
2080
|
-
readonly asyncIter: () => AsyncIterableIterator<${osdkObjectIdentifier}>;
|
|
2081
574
|
}
|
|
2082
575
|
`;
|
|
2083
576
|
}
|
|
@@ -2109,7 +602,7 @@ function createDefinition(object, ontology, identifier, {
|
|
|
2109
602
|
}) {
|
|
2110
603
|
const definition = object.getCleanedUpDefinition(true);
|
|
2111
604
|
return `
|
|
2112
|
-
export interface ${identifier} extends ${object instanceof EnhancedObjectType ? `$ObjectTypeDefinition` : `$InterfaceDefinition`}<"${object.fullApiName}", ${objectDefIdentifier}
|
|
605
|
+
export interface ${identifier} extends ${object instanceof EnhancedObjectType ? `$ObjectTypeDefinition` : `$InterfaceDefinition`}<"${object.fullApiName}", ${objectDefIdentifier}> {
|
|
2113
606
|
osdkMetadata: typeof $osdkMetadata;
|
|
2114
607
|
objectSet: ${objectSetIdentifier};
|
|
2115
608
|
props: ${osdkObjectPropsIdentifier};
|
|
@@ -2144,7 +637,7 @@ function createLinks(ontology, object, identifier) {
|
|
|
2144
637
|
${stringify(definition.links, {
|
|
2145
638
|
"*": (definition2, _, key) => {
|
|
2146
639
|
const linkTarget = ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(true);
|
|
2147
|
-
return [`readonly ${key}`, `${definition2.multiplicity ? `${linkTarget}.ObjectSet` : `$SingleLinkAccessor<${linkTarget}
|
|
640
|
+
return [`readonly ${key}`, `${definition2.multiplicity ? `${linkTarget}.ObjectSet` : `$SingleLinkAccessor<${linkTarget}>`}
|
|
2148
641
|
`];
|
|
2149
642
|
}
|
|
2150
643
|
})}
|
|
@@ -2163,16 +656,16 @@ async function generatePerActionDataFiles({
|
|
|
2163
656
|
importExt = "",
|
|
2164
657
|
ontology: enhancedOntology
|
|
2165
658
|
}) {
|
|
2166
|
-
const outDir =
|
|
659
|
+
const outDir = path5__default.join(rootOutDir, "ontology", "actions");
|
|
2167
660
|
await fs2.mkdir(outDir, {
|
|
2168
661
|
recursive: true
|
|
2169
662
|
});
|
|
2170
663
|
await Promise.all(Object.values(enhancedOntology.actionTypes).map(async (action) => {
|
|
2171
|
-
const currentFilePath = `${
|
|
2172
|
-
const uniqueApiNamesArray =
|
|
664
|
+
const currentFilePath = `${path5__default.join("ontology", "actions", `${action.shortApiName}.ts`)}`;
|
|
665
|
+
const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.raw);
|
|
2173
666
|
const uniqueApiNames = new Set(uniqueApiNamesArray);
|
|
2174
|
-
const uniqueApiNamesString =
|
|
2175
|
-
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action.
|
|
667
|
+
const uniqueApiNamesString = stringUnionFrom([...uniqueApiNames]);
|
|
668
|
+
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action.raw));
|
|
2176
669
|
const {
|
|
2177
670
|
parameters,
|
|
2178
671
|
...actionDefSansParameters
|
|
@@ -2196,9 +689,9 @@ async function generatePerActionDataFiles({
|
|
|
2196
689
|
return JSON.stringify(type);
|
|
2197
690
|
} else if (type.type === "object") {
|
|
2198
691
|
const obj = enhancedOntology.requireObjectType(type.object);
|
|
2199
|
-
return `ObjectActionDataType<"${obj.fullApiName}", ${obj.getImportedDefinitionIdentifier(true)}
|
|
692
|
+
return `ObjectActionDataType<"${obj.fullApiName}", ${obj.getImportedDefinitionIdentifier(true)}>`;
|
|
2200
693
|
} else if (type.type === "objectSet") {
|
|
2201
|
-
return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, true)}
|
|
694
|
+
return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, true)}>`;
|
|
2202
695
|
}
|
|
2203
696
|
return void 0;
|
|
2204
697
|
}
|
|
@@ -2211,13 +704,13 @@ async function generatePerActionDataFiles({
|
|
|
2211
704
|
if (typeof input === "string") {
|
|
2212
705
|
return `ActionParam.PrimitiveType<${JSON.stringify(input)}>`;
|
|
2213
706
|
} else if (input.type === "object") {
|
|
2214
|
-
return `ActionParam.ObjectType<${enhancedOntology.requireObjectType(input.object).getImportedDefinitionIdentifier(true)}
|
|
707
|
+
return `ActionParam.ObjectType<${enhancedOntology.requireObjectType(input.object).getImportedDefinitionIdentifier(true)}>`;
|
|
2215
708
|
} else if (input.type === "objectSet") {
|
|
2216
|
-
return `ActionParam.ObjectSetType<${enhancedOntology.requireObjectType(input.objectSet).getImportedDefinitionIdentifier(true)}
|
|
709
|
+
return `ActionParam.ObjectSetType<${enhancedOntology.requireObjectType(input.objectSet).getImportedDefinitionIdentifier(true)}>`;
|
|
2217
710
|
}
|
|
2218
711
|
}
|
|
2219
712
|
function createV2Types() {
|
|
2220
|
-
|
|
713
|
+
`${action.shortApiName}$Params`;
|
|
2221
714
|
return `
|
|
2222
715
|
|
|
2223
716
|
export namespace ${action.shortApiName}{
|
|
@@ -2234,8 +727,6 @@ async function generatePerActionDataFiles({
|
|
|
2234
727
|
}
|
|
2235
728
|
})}
|
|
2236
729
|
}
|
|
2237
|
-
/** @deprecated **/
|
|
2238
|
-
export type Parameters = Params;
|
|
2239
730
|
|
|
2240
731
|
|
|
2241
732
|
// Represents the definition of the action
|
|
@@ -2257,11 +748,6 @@ async function generatePerActionDataFiles({
|
|
|
2257
748
|
|
|
2258
749
|
}
|
|
2259
750
|
|
|
2260
|
-
/**
|
|
2261
|
-
* @deprecated Use \`${action.paramsIdentifier}\`
|
|
2262
|
-
*/
|
|
2263
|
-
export type ${oldParamsIdentifier} = ${action.paramsIdentifier} | ReadonlyArray<${action.paramsIdentifier}>;
|
|
2264
|
-
|
|
2265
751
|
/** @deprecated Use \`${action.definitionIdentifier}\` **/
|
|
2266
752
|
export type ${action.shortApiName} = ${action.shortApiName}.Signatures;
|
|
2267
753
|
`;
|
|
@@ -2294,11 +780,11 @@ async function generatePerActionDataFiles({
|
|
|
2294
780
|
}
|
|
2295
781
|
}
|
|
2296
782
|
const imports = getObjectImports(referencedObjectDefs, void 0, currentFilePath, true);
|
|
2297
|
-
await fs2.writeFile(
|
|
783
|
+
await fs2.writeFile(path5__default.join(rootOutDir, currentFilePath), await formatTs(`
|
|
2298
784
|
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound} from "@osdk/api";
|
|
2299
|
-
import type {
|
|
2300
|
-
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
785
|
+
import type { ActionParam, ActionReturnTypeForOptions, ApplyActionOptions, ApplyBatchActionOptions, } from '@osdk/client.api';
|
|
2301
786
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
787
|
+
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
2302
788
|
${imports}
|
|
2303
789
|
|
|
2304
790
|
|
|
@@ -2307,8 +793,8 @@ async function generatePerActionDataFiles({
|
|
|
2307
793
|
${createV2Object()}
|
|
2308
794
|
`));
|
|
2309
795
|
}));
|
|
2310
|
-
const indexFileRelPath =
|
|
2311
|
-
await fs2.writeFile(
|
|
796
|
+
const indexFileRelPath = path5__default.join("ontology", "actions.ts");
|
|
797
|
+
await fs2.writeFile(path5__default.join(rootOutDir, indexFileRelPath), await formatTs(`
|
|
2312
798
|
${Object.values(enhancedOntology.actionTypes).map((action) => {
|
|
2313
799
|
const exportConstLine = `export {${action.shortApiName} } from "${action.getImportPathRelTo(indexFileRelPath)}";`;
|
|
2314
800
|
return exportConstLine;
|
|
@@ -2316,11 +802,11 @@ async function generatePerActionDataFiles({
|
|
|
2316
802
|
${Object.keys(ontology.actionTypes).length === 0 ? "export {};" : ""}
|
|
2317
803
|
`));
|
|
2318
804
|
}
|
|
2319
|
-
function
|
|
805
|
+
function extractReferencedObjectsFromAction(actionType) {
|
|
2320
806
|
const referencedObjectsInParameters = Object.values(actionType.parameters).flatMap(({
|
|
2321
807
|
dataType
|
|
2322
808
|
}) => {
|
|
2323
|
-
const objectTypeReference =
|
|
809
|
+
const objectTypeReference = extractReferencedObjectsFromActionParameter(dataType);
|
|
2324
810
|
return objectTypeReference ? [objectTypeReference] : [];
|
|
2325
811
|
});
|
|
2326
812
|
const referenceObjectsInEdits = actionType.operations.flatMap((value) => {
|
|
@@ -2332,18 +818,19 @@ function extractReferencedObjectsFromAction2(actionType) {
|
|
|
2332
818
|
case "deleteObject":
|
|
2333
819
|
case "createLink":
|
|
2334
820
|
case "deleteLink":
|
|
821
|
+
default:
|
|
2335
822
|
return [];
|
|
2336
823
|
}
|
|
2337
824
|
});
|
|
2338
825
|
return [...referenceObjectsInEdits, ...referencedObjectsInParameters];
|
|
2339
826
|
}
|
|
2340
|
-
function
|
|
827
|
+
function extractReferencedObjectsFromActionParameter(actionParameter) {
|
|
2341
828
|
switch (actionParameter.type) {
|
|
2342
829
|
case "objectSet":
|
|
2343
830
|
case "object":
|
|
2344
831
|
return actionParameter.objectTypeApiName;
|
|
2345
832
|
case "array":
|
|
2346
|
-
return
|
|
833
|
+
return extractReferencedObjectsFromActionParameter(actionParameter.subType);
|
|
2347
834
|
case "string":
|
|
2348
835
|
case "boolean":
|
|
2349
836
|
case "attachment":
|
|
@@ -2355,14 +842,222 @@ function extractReferencedObjectsFromActionParameter2(actionParameter) {
|
|
|
2355
842
|
return void 0;
|
|
2356
843
|
}
|
|
2357
844
|
}
|
|
845
|
+
|
|
846
|
+
// src/shared/getObjectTypesFromQueryDataType.ts
|
|
847
|
+
function getObjectTypesFromQueryDataType(dataType, types) {
|
|
848
|
+
switch (dataType.type) {
|
|
849
|
+
case "array":
|
|
850
|
+
case "set":
|
|
851
|
+
getObjectTypesFromQueryDataType(dataType.subType, types);
|
|
852
|
+
return;
|
|
853
|
+
case "object":
|
|
854
|
+
types.add(dataType.objectTypeApiName);
|
|
855
|
+
return;
|
|
856
|
+
case "objectSet":
|
|
857
|
+
types.add(dataType.objectTypeApiName);
|
|
858
|
+
return;
|
|
859
|
+
case "struct":
|
|
860
|
+
for (const prop of Object.values(dataType.fields)) {
|
|
861
|
+
getObjectTypesFromQueryDataType(prop.fieldType, types);
|
|
862
|
+
}
|
|
863
|
+
return;
|
|
864
|
+
case "union":
|
|
865
|
+
for (const type of dataType.unionTypes) {
|
|
866
|
+
getObjectTypesFromQueryDataType(type, types);
|
|
867
|
+
}
|
|
868
|
+
return;
|
|
869
|
+
case "attachment":
|
|
870
|
+
case "boolean":
|
|
871
|
+
case "date":
|
|
872
|
+
case "double":
|
|
873
|
+
case "float":
|
|
874
|
+
case "integer":
|
|
875
|
+
case "long":
|
|
876
|
+
case "null":
|
|
877
|
+
case "string":
|
|
878
|
+
case "threeDimensionalAggregation":
|
|
879
|
+
case "timestamp":
|
|
880
|
+
case "twoDimensionalAggregation":
|
|
881
|
+
case "unsupported":
|
|
882
|
+
return;
|
|
883
|
+
default:
|
|
884
|
+
throw new Error(`Cannot find object types from unsupported QueryDataType ${dataType.type}`);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// src/shared/getObjectTypeApiNamesFromQuery.ts
|
|
889
|
+
function getObjectTypeApiNamesFromQuery(query) {
|
|
890
|
+
const types = /* @__PURE__ */ new Set();
|
|
891
|
+
for (const {
|
|
892
|
+
dataType
|
|
893
|
+
} of Object.values(query.parameters)) {
|
|
894
|
+
getObjectTypesFromQueryDataType(dataType, types);
|
|
895
|
+
}
|
|
896
|
+
getObjectTypesFromQueryDataType(query.output, types);
|
|
897
|
+
return Array.from(types);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// src/shared/isNullableQueryDataType.ts
|
|
901
|
+
function isNullableQueryDataType(input) {
|
|
902
|
+
if (input.type === "null") {
|
|
903
|
+
return true;
|
|
904
|
+
}
|
|
905
|
+
if (input.type === "union") {
|
|
906
|
+
return input.unionTypes.some((t) => isNullableQueryDataType(t));
|
|
907
|
+
}
|
|
908
|
+
return false;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
// src/shared/wireQueryDataTypeToQueryDataTypeDefinition.ts
|
|
912
|
+
function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
913
|
+
switch (input.type) {
|
|
914
|
+
case "double":
|
|
915
|
+
case "float":
|
|
916
|
+
case "integer":
|
|
917
|
+
case "long":
|
|
918
|
+
case "attachment":
|
|
919
|
+
case "boolean":
|
|
920
|
+
case "date":
|
|
921
|
+
case "string":
|
|
922
|
+
case "timestamp":
|
|
923
|
+
return {
|
|
924
|
+
type: input.type,
|
|
925
|
+
nullable: false
|
|
926
|
+
};
|
|
927
|
+
case "object":
|
|
928
|
+
return {
|
|
929
|
+
type: "object",
|
|
930
|
+
object: input.objectTypeApiName,
|
|
931
|
+
nullable: false
|
|
932
|
+
};
|
|
933
|
+
case "objectSet":
|
|
934
|
+
return {
|
|
935
|
+
type: "objectSet",
|
|
936
|
+
objectSet: input.objectTypeApiName,
|
|
937
|
+
nullable: false
|
|
938
|
+
};
|
|
939
|
+
case "array":
|
|
940
|
+
return {
|
|
941
|
+
...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
|
|
942
|
+
multiplicity: true
|
|
943
|
+
};
|
|
944
|
+
case "set":
|
|
945
|
+
return {
|
|
946
|
+
type: "set",
|
|
947
|
+
set: wireQueryDataTypeToQueryDataTypeDefinition(input.subType),
|
|
948
|
+
nullable: false
|
|
949
|
+
};
|
|
950
|
+
case "union":
|
|
951
|
+
const allowNulls = isNullableQueryDataType(input);
|
|
952
|
+
if (allowNulls && input.unionTypes.length === 2) {
|
|
953
|
+
const nonNull = input.unionTypes.find((t) => t.type != null);
|
|
954
|
+
if (nonNull) {
|
|
955
|
+
return {
|
|
956
|
+
...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),
|
|
957
|
+
nullable: true
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return {
|
|
962
|
+
type: "union",
|
|
963
|
+
union: input.unionTypes.reduce((acc, t) => {
|
|
964
|
+
if (t.type === "null") {
|
|
965
|
+
return acc;
|
|
966
|
+
}
|
|
967
|
+
acc.push(wireQueryDataTypeToQueryDataTypeDefinition(t));
|
|
968
|
+
return acc;
|
|
969
|
+
}, []),
|
|
970
|
+
nullable: allowNulls
|
|
971
|
+
};
|
|
972
|
+
case "struct":
|
|
973
|
+
return {
|
|
974
|
+
type: "struct",
|
|
975
|
+
struct: Object.fromEntries(input.fields.map((f) => [f.name, wireQueryDataTypeToQueryDataTypeDefinition(f.fieldType)])),
|
|
976
|
+
nullable: false
|
|
977
|
+
};
|
|
978
|
+
case "twoDimensionalAggregation":
|
|
979
|
+
return {
|
|
980
|
+
type: "twoDimensionalAggregation",
|
|
981
|
+
twoDimensionalAggregation: get2DQueryAggregationProps(input),
|
|
982
|
+
nullable: false
|
|
983
|
+
};
|
|
984
|
+
case "threeDimensionalAggregation":
|
|
985
|
+
return {
|
|
986
|
+
type: "threeDimensionalAggregation",
|
|
987
|
+
threeDimensionalAggregation: get3DQueryAggregationProps(input),
|
|
988
|
+
nullable: false
|
|
989
|
+
};
|
|
990
|
+
case "null":
|
|
991
|
+
case "unsupported":
|
|
992
|
+
throw new Error(`Accidentally tried to handle QueryDataType.type ${input.type}`);
|
|
993
|
+
default:
|
|
994
|
+
throw new Error(`Unsupported QueryDataType.type ${input.type}`);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
function get2DQueryAggregationProps(input) {
|
|
998
|
+
if (input.keyType.type === "range") {
|
|
999
|
+
return {
|
|
1000
|
+
keyType: input.keyType.type,
|
|
1001
|
+
keySubtype: input.keyType.subType.type,
|
|
1002
|
+
valueType: input.valueType.type
|
|
1003
|
+
};
|
|
1004
|
+
} else {
|
|
1005
|
+
if (guardInvalidKeyTypes(input.keyType)) {
|
|
1006
|
+
return {
|
|
1007
|
+
keyType: input.keyType.type,
|
|
1008
|
+
valueType: input.valueType.type
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
throw new Error(`Cannot create 2D aggregation with ${input.keyType.type} as its type`);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
function get3DQueryAggregationProps(input) {
|
|
1015
|
+
if (input.keyType.type === "range") {
|
|
1016
|
+
return {
|
|
1017
|
+
keyType: input.keyType.type,
|
|
1018
|
+
keySubtype: input.keyType.subType.type,
|
|
1019
|
+
valueType: get2DQueryAggregationProps(input.valueType)
|
|
1020
|
+
};
|
|
1021
|
+
} else {
|
|
1022
|
+
if (guardInvalidKeyTypes(input.keyType)) {
|
|
1023
|
+
return {
|
|
1024
|
+
keyType: input.keyType.type,
|
|
1025
|
+
valueType: get2DQueryAggregationProps(input.valueType)
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
throw new Error(`Cannot create 3D aggregation with ${input.keyType.type} as its type`);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
function guardInvalidKeyTypes(key) {
|
|
1032
|
+
return key.type === "string" || key.type === "boolean";
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// src/shared/wireQueryTypeV2ToSdkQueryDefinition.ts
|
|
1036
|
+
function wireQueryTypeV2ToSdkQueryDefinitionNoParams(input) {
|
|
1037
|
+
return {
|
|
1038
|
+
type: "query",
|
|
1039
|
+
apiName: input.apiName,
|
|
1040
|
+
description: input.description,
|
|
1041
|
+
displayName: input.displayName,
|
|
1042
|
+
version: input.version
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
1046
|
+
return {
|
|
1047
|
+
description: parameter.description,
|
|
1048
|
+
...wireQueryDataTypeToQueryDataTypeDefinition(parameter.dataType)
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
// src/v2.0/generatePerQueryDataFiles.ts
|
|
2358
1053
|
async function generatePerQueryDataFilesV2({
|
|
2359
1054
|
fs: fs2,
|
|
2360
1055
|
outDir: rootOutDir,
|
|
2361
1056
|
ontology,
|
|
2362
1057
|
importExt = ""
|
|
2363
1058
|
}, v2) {
|
|
2364
|
-
const relOutDir =
|
|
2365
|
-
const outDir =
|
|
1059
|
+
const relOutDir = path5__default.join(".", "ontology", "queries");
|
|
1060
|
+
const outDir = path5__default.join(rootOutDir, "ontology", "queries");
|
|
2366
1061
|
await fs2.mkdir(outDir, {
|
|
2367
1062
|
recursive: true
|
|
2368
1063
|
});
|
|
@@ -2376,13 +1071,14 @@ async function generatePerQueryDataFilesV2({
|
|
|
2376
1071
|
`));
|
|
2377
1072
|
}
|
|
2378
1073
|
async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ontology) {
|
|
2379
|
-
const relFilePath =
|
|
1074
|
+
const relFilePath = path5__default.join(relOutDir, `${query.shortApiName}.ts`);
|
|
2380
1075
|
const objectTypes = getObjectTypeApiNamesFromQuery(query);
|
|
2381
|
-
const
|
|
2382
|
-
const
|
|
1076
|
+
const objectTypeObjects = new Set(objectTypes.map((o) => ontology.requireObjectType(o)));
|
|
1077
|
+
const importObjects = getObjectImports(objectTypeObjects, "", relFilePath, true);
|
|
1078
|
+
const baseProps = deleteUndefineds(wireQueryTypeV2ToSdkQueryDefinitionNoParams(query.raw));
|
|
2383
1079
|
const outputBase = deleteUndefineds(wireQueryDataTypeToQueryDataTypeDefinition(query.output));
|
|
2384
1080
|
const referencedObjectTypes = objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never";
|
|
2385
|
-
await fs2.writeFile(
|
|
1081
|
+
await fs2.writeFile(path5__default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
2386
1082
|
import type { QueryDefinition , VersionBound} from "@osdk/api";
|
|
2387
1083
|
import type { QueryParam, QueryResult } from "@osdk/client.api";
|
|
2388
1084
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
@@ -2485,15 +1181,6 @@ function queryParamJsDoc(param, {
|
|
|
2485
1181
|
`;
|
|
2486
1182
|
return ret;
|
|
2487
1183
|
}
|
|
2488
|
-
function getObjectImports2(enhancedOntology, objectTypes, filePath) {
|
|
2489
|
-
let ret = "";
|
|
2490
|
-
for (const fqObjectApiName of objectTypes) {
|
|
2491
|
-
const obj = enhancedOntology.requireObjectType(fqObjectApiName);
|
|
2492
|
-
ret += `import type { ${obj.getDefinitionIdentifier(true)} as ${obj.getImportedDefinitionIdentifier(true)} } from "${obj.getImportPathRelTo(filePath)}";
|
|
2493
|
-
`;
|
|
2494
|
-
}
|
|
2495
|
-
return ret;
|
|
2496
|
-
}
|
|
2497
1184
|
function getQueryParamType(enhancedOntology, input, type) {
|
|
2498
1185
|
let inner = `unknown /* ${input.type} */`;
|
|
2499
1186
|
switch (input.type) {
|
|
@@ -2534,11 +1221,11 @@ function getQueryParamType(enhancedOntology, input, type) {
|
|
|
2534
1221
|
return inner;
|
|
2535
1222
|
}
|
|
2536
1223
|
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false) {
|
|
2537
|
-
const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef.
|
|
1224
|
+
const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef.raw, v2));
|
|
2538
1225
|
const objectDefIdentifier = interfaceDef.getDefinitionIdentifier(v2);
|
|
2539
1226
|
const parents = definition.implements?.map((p) => {
|
|
2540
1227
|
!(ontology.interfaceTypes[p] != null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Expected to find a parent interface named ${p} in the ontology and did not.`) : invariant(false) : void 0;
|
|
2541
|
-
const it = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.requireInterfaceType(p, true).
|
|
1228
|
+
const it = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.requireInterfaceType(p, true).raw, v2));
|
|
2542
1229
|
return it;
|
|
2543
1230
|
}) ?? [];
|
|
2544
1231
|
const mergedProperties = {
|
|
@@ -2579,43 +1266,15 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology,
|
|
|
2579
1266
|
propertyKeysIdentifier
|
|
2580
1267
|
};
|
|
2581
1268
|
function getV2Types() {
|
|
2582
|
-
return `import type {
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
Augments as $Augments,
|
|
2587
|
-
ConvertProps as $ConvertProps,
|
|
2588
|
-
DefaultToFalse as $DefaultToFalse,
|
|
2589
|
-
FetchPageArgs as $FetchPageArgs,
|
|
2590
|
-
FetchPageResult as $FetchPageResult,
|
|
2591
|
-
IsAny as $IsAny,
|
|
2592
|
-
LinkedType as $LinkedType,
|
|
2593
|
-
LinkNames as $LinkNames,
|
|
2594
|
-
NullabilityAdherence as $NullabilityAdherence,
|
|
2595
|
-
NullabilityAdherenceDefault as $NullabilityAdherenceDefault,
|
|
1269
|
+
return ` import type {
|
|
1270
|
+
InterfaceDefinition as $InterfaceDefinition,
|
|
1271
|
+
} from "@osdk/api";
|
|
1272
|
+
import type {
|
|
2596
1273
|
ObjectSet as $ObjectSet,
|
|
2597
1274
|
Osdk as $Osdk,
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
OsdkObjectPropertyType as $OsdkObjectPropertyType,
|
|
2602
|
-
PageResult as $PageResult,
|
|
2603
|
-
PropertyValueClientToWire as $PropertyValueClientToWire,
|
|
2604
|
-
PropertyValueWireToClient as $PropType,
|
|
2605
|
-
Result as $Result,
|
|
2606
|
-
SelectArg as $SelectArg,
|
|
2607
|
-
SingleLinkAccessor as $SingleLinkAccessor,
|
|
2608
|
-
SingleOsdkResult as $SingleOsdkResult,
|
|
2609
|
-
ValidToFrom as $ValidToFrom,
|
|
2610
|
-
WhereClause as $WhereClause,
|
|
2611
|
-
} from "@osdk/client.api";
|
|
2612
|
-
import type * as $clientApi from "@osdk/client.api";
|
|
2613
|
-
import type {
|
|
2614
|
-
ObjectOrInterfacePropertyKeysFrom2 as $ObjectOrInterfacePropertyKeysFrom2,
|
|
2615
|
-
ObjectTypeLinkDefinition as $ObjectTypeLinkDefinition,
|
|
2616
|
-
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
2617
|
-
InterfaceDefinition as $InterfaceDefinition,
|
|
2618
|
-
} from "@osdk/api";
|
|
1275
|
+
PropertyValueWireToClient as $PropType, } from "@osdk/client.api";
|
|
1276
|
+
|
|
1277
|
+
|
|
2619
1278
|
|
|
2620
1279
|
|
|
2621
1280
|
|
|
@@ -2688,11 +1347,15 @@ async function generateRootIndexTsFile({
|
|
|
2688
1347
|
importExt,
|
|
2689
1348
|
ontologyApiNamespace
|
|
2690
1349
|
}) {
|
|
2691
|
-
fs2.writeFile(
|
|
2692
|
-
export * from "./ontology/actions${importExt}";
|
|
2693
|
-
export * from "./ontology/objects${importExt}";
|
|
1350
|
+
fs2.writeFile(path5__default.join(outDir, "index.ts"), await formatTs(`export * from "./ontology/actions${importExt}";
|
|
1351
|
+
export * as $Actions from "./ontology/actions${importExt}";
|
|
2694
1352
|
export * from "./ontology/interfaces${importExt}";
|
|
1353
|
+
export * as $Interfaces from "./ontology/interfaces${importExt}";
|
|
1354
|
+
export * from "./ontology/objects${importExt}";
|
|
1355
|
+
export * as $Objects from "./ontology/objects${importExt}";
|
|
2695
1356
|
export * from "./ontology/queries${importExt}";
|
|
1357
|
+
export * as $Queries from "./ontology/queries${importExt}";
|
|
1358
|
+
${ontologyApiNamespace == null ? `export { $ontologyRid } from "./OntologyMetadata${importExt}";` : ``}
|
|
2696
1359
|
`));
|
|
2697
1360
|
}
|
|
2698
1361
|
async function generateEachObjectFile(ctx) {
|
|
@@ -2702,18 +1365,17 @@ async function generateEachObjectFile(ctx) {
|
|
|
2702
1365
|
ontology,
|
|
2703
1366
|
importExt
|
|
2704
1367
|
} = ctx;
|
|
2705
|
-
await fs2.mkdir(
|
|
1368
|
+
await fs2.mkdir(path5__default.join(outDir, "ontology", "objects"), {
|
|
2706
1369
|
recursive: true
|
|
2707
1370
|
});
|
|
2708
1371
|
for (const obj of Object.values(ontology.objectTypes)) {
|
|
2709
|
-
const relPath =
|
|
2710
|
-
const outFilePath =
|
|
1372
|
+
const relPath = path5__default.join(".", "ontology", `objects`, `${obj.shortApiName}.ts`);
|
|
1373
|
+
const outFilePath = path5__default.join(outDir, relPath);
|
|
2711
1374
|
await fs2.writeFile(outFilePath, await formatTs(`
|
|
2712
|
-
import type {
|
|
2713
|
-
import type { Osdk } from "@osdk/client.api";
|
|
1375
|
+
import type { PropertyDef as $PropertyDef } from "@osdk/api";
|
|
2714
1376
|
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
|
|
2715
1377
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
2716
|
-
${wireObjectTypeV2ToSdkObjectConstV2(obj.
|
|
1378
|
+
${wireObjectTypeV2ToSdkObjectConstV2(obj.raw, ctx, relPath)}
|
|
2717
1379
|
`));
|
|
2718
1380
|
}
|
|
2719
1381
|
}
|
|
@@ -2738,12 +1400,12 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
2738
1400
|
await generateOntologyMetadataFile(ctx, userAgent);
|
|
2739
1401
|
await generateEachObjectFile(ctx);
|
|
2740
1402
|
await generateOntologyInterfaces(ctx);
|
|
2741
|
-
const actionsDir =
|
|
1403
|
+
const actionsDir = path5__default.join(outDir, "ontology", "actions");
|
|
2742
1404
|
await fs2.mkdir(actionsDir, {
|
|
2743
1405
|
recursive: true
|
|
2744
1406
|
});
|
|
2745
1407
|
await generatePerActionDataFiles(ctx);
|
|
2746
|
-
await fs2.writeFile(
|
|
1408
|
+
await fs2.writeFile(path5__default.join(outDir, "ontology", "objects.ts"), await formatTs(`
|
|
2747
1409
|
${Object.values(enhancedOntology.objectTypes).map((objType) => `export * from "./objects/${objType.shortApiName}${importExt}";`).join("\n")}
|
|
2748
1410
|
${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
|
|
2749
1411
|
`));
|
|
@@ -2755,16 +1417,14 @@ async function generateOntologyInterfaces({
|
|
|
2755
1417
|
ontology,
|
|
2756
1418
|
importExt
|
|
2757
1419
|
}) {
|
|
2758
|
-
const interfacesDir =
|
|
1420
|
+
const interfacesDir = path5__default.join(outDir, "ontology", "interfaces");
|
|
2759
1421
|
await fs2.mkdir(interfacesDir, {
|
|
2760
1422
|
recursive: true
|
|
2761
1423
|
});
|
|
2762
1424
|
for (const obj of Object.values(ontology.interfaceTypes)) {
|
|
2763
|
-
await fs2.writeFile(
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
import { $osdkMetadata, $expectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
2767
|
-
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1425
|
+
await fs2.writeFile(path5__default.join(interfacesDir, `${obj.shortApiName}.ts`), await formatTs(`
|
|
1426
|
+
import type { PropertyDef as $PropertyDef } from "@osdk/api";
|
|
1427
|
+
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
|
|
2768
1428
|
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true)}
|
|
2769
1429
|
`));
|
|
2770
1430
|
}
|
|
@@ -2776,26 +1436,29 @@ async function generateOntologyInterfaces({
|
|
|
2776
1436
|
|
|
2777
1437
|
// src/generateClientSdkPackage.ts
|
|
2778
1438
|
async function generateClientSdkPackage(packageName, packageVersion, sdkVersion, baseOutDir, ontology, minimalFs, dependencyVersions, cliVersion, ontologyApiNamespace, apiNamespacePackageMap) {
|
|
2779
|
-
if (!packageName) throw new Error("Package name is
|
|
1439
|
+
if (!packageName) throw new Error("Package name is required");
|
|
1440
|
+
if (sdkVersion === "1.1") {
|
|
1441
|
+
throw new Error("This generator version does not support generating v1 sdks");
|
|
1442
|
+
}
|
|
2780
1443
|
for (const packageType of ["module", "commonjs"]) {
|
|
2781
|
-
const outDir =
|
|
2782
|
-
|
|
1444
|
+
const outDir = path5.join(baseOutDir, "dist", packageType);
|
|
1445
|
+
generateClientSdkVersionTwoPointZero(ontology, `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`, minimalFs, outDir, packageType, ontologyApiNamespace, apiNamespacePackageMap);
|
|
2783
1446
|
await fs.promises.mkdir(outDir, {
|
|
2784
1447
|
recursive: true
|
|
2785
1448
|
});
|
|
2786
|
-
await writeJson(minimalFs,
|
|
1449
|
+
await writeJson(minimalFs, path5.join(outDir, "package.json"), {
|
|
2787
1450
|
type: packageType
|
|
2788
1451
|
});
|
|
2789
|
-
await writeJson(minimalFs,
|
|
1452
|
+
await writeJson(minimalFs, path5.join(outDir, `tsconfig.json`), {
|
|
2790
1453
|
compilerOptions: getTsCompilerOptions(packageType)
|
|
2791
1454
|
});
|
|
2792
1455
|
}
|
|
2793
|
-
await writeJson(minimalFs,
|
|
2794
|
-
await minimalFs.mkdir(
|
|
1456
|
+
await writeJson(minimalFs, path5.join(baseOutDir, "package.json"), await getPackageJsonContents(packageName, packageVersion, dependencyVersions));
|
|
1457
|
+
await minimalFs.mkdir(path5.join(baseOutDir, "ontology"), {
|
|
2795
1458
|
recursive: true
|
|
2796
1459
|
});
|
|
2797
|
-
await minimalFs.writeFile(
|
|
2798
|
-
await minimalFs.writeFile(
|
|
1460
|
+
await minimalFs.writeFile(path5.join(baseOutDir, "ontology", "objects.js"), `module.exports = require("../../dist/module/ontology/objects")`);
|
|
1461
|
+
await minimalFs.writeFile(path5.join(baseOutDir, "ontology", "objects.d.ts"), `export * from "../dist/module/ontology/objects"`);
|
|
2799
1462
|
}
|
|
2800
1463
|
function getTsCompilerOptions(packageType) {
|
|
2801
1464
|
const commonTsconfig = {
|
|
@@ -2818,39 +1481,30 @@ function getTsCompilerOptions(packageType) {
|
|
|
2818
1481
|
};
|
|
2819
1482
|
return compilerOptions;
|
|
2820
1483
|
}
|
|
2821
|
-
function getExpectedDependencies(
|
|
1484
|
+
function getExpectedDependencies({
|
|
2822
1485
|
osdkApiVersion,
|
|
2823
1486
|
osdkClientVersion,
|
|
2824
|
-
osdkClientApiVersion
|
|
2825
|
-
osdkLegacyClientVersion
|
|
1487
|
+
osdkClientApiVersion
|
|
2826
1488
|
}) {
|
|
2827
1489
|
return {
|
|
2828
1490
|
devDependencies: {
|
|
2829
1491
|
"@osdk/api": osdkApiVersion,
|
|
2830
|
-
|
|
2831
|
-
"@osdk/client.api": osdkClientApiVersion
|
|
2832
|
-
} : {
|
|
2833
|
-
"@osdk/legacy-client": osdkLegacyClientVersion
|
|
2834
|
-
}
|
|
1492
|
+
"@osdk/client.api": osdkClientApiVersion
|
|
2835
1493
|
},
|
|
2836
1494
|
peerDependencies: {
|
|
2837
1495
|
"@osdk/api": osdkApiVersion,
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
"@osdk/client": osdkClientVersion
|
|
2841
|
-
} : {
|
|
2842
|
-
"@osdk/legacy-client": osdkLegacyClientVersion
|
|
2843
|
-
}
|
|
1496
|
+
"@osdk/client.api": osdkClientApiVersion,
|
|
1497
|
+
"@osdk/client": osdkClientVersion
|
|
2844
1498
|
}
|
|
2845
1499
|
};
|
|
2846
1500
|
}
|
|
2847
|
-
function getExpectedDependenciesFull(
|
|
1501
|
+
function getExpectedDependenciesFull(dependencyVersions) {
|
|
2848
1502
|
const {
|
|
2849
1503
|
typescriptVersion,
|
|
2850
1504
|
tslibVersion,
|
|
2851
1505
|
areTheTypesWrongVersion
|
|
2852
1506
|
} = dependencyVersions;
|
|
2853
|
-
const base = getExpectedDependencies(
|
|
1507
|
+
const base = getExpectedDependencies(dependencyVersions);
|
|
2854
1508
|
return {
|
|
2855
1509
|
devDependencies: {
|
|
2856
1510
|
...base.devDependencies,
|
|
@@ -2863,7 +1517,7 @@ function getExpectedDependenciesFull(sdkVersion, dependencyVersions) {
|
|
|
2863
1517
|
}
|
|
2864
1518
|
};
|
|
2865
1519
|
}
|
|
2866
|
-
function getPackageJsonContents(name, version,
|
|
1520
|
+
function getPackageJsonContents(name, version, dependencyVersions) {
|
|
2867
1521
|
const esmPrefix = "./dist/module";
|
|
2868
1522
|
const commonjsPrefix = "./dist/commonjs";
|
|
2869
1523
|
return {
|
|
@@ -2875,17 +1529,13 @@ function getPackageJsonContents(name, version, sdkVersion, dependencyVersions) {
|
|
|
2875
1529
|
".": {
|
|
2876
1530
|
import: `${esmPrefix}/index.js`,
|
|
2877
1531
|
require: `${commonjsPrefix}/index.js`
|
|
2878
|
-
},
|
|
2879
|
-
"./ontology/objects": {
|
|
2880
|
-
import: `${esmPrefix}/ontology/objects${sdkVersion === "2.0" ? "" : "/index"}.js`,
|
|
2881
|
-
require: `${commonjsPrefix}/ontology/objects${sdkVersion === "2.0" ? "" : "/index"}.js`
|
|
2882
1532
|
}
|
|
2883
1533
|
},
|
|
2884
1534
|
scripts: {
|
|
2885
1535
|
prepack: `tsc -p ${esmPrefix}/tsconfig.json && tsc -p ${commonjsPrefix}/tsconfig.json`,
|
|
2886
1536
|
check: "npm exec attw $(npm pack)"
|
|
2887
1537
|
},
|
|
2888
|
-
...getExpectedDependenciesFull(
|
|
1538
|
+
...getExpectedDependenciesFull(dependencyVersions),
|
|
2889
1539
|
files: ["**/*.js", "**/*.d.ts", "dist/**/package.json"]
|
|
2890
1540
|
};
|
|
2891
1541
|
}
|
|
@@ -2893,6 +1543,6 @@ async function writeJson(minimalFs, filePath, body) {
|
|
|
2893
1543
|
return await minimalFs.writeFile(filePath, JSON.stringify(body, void 0, 2) + "\n");
|
|
2894
1544
|
}
|
|
2895
1545
|
|
|
2896
|
-
export { generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage,
|
|
1546
|
+
export { generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, generateClientSdkVersionTwoPointZero, getExpectedDependencies };
|
|
2897
1547
|
//# sourceMappingURL=index.js.map
|
|
2898
1548
|
//# sourceMappingURL=index.js.map
|