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