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