@osdk/generator 2.1.0-beta.3 → 2.1.0-beta.30
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 +293 -0
- package/build/browser/GenerateContext/EnhanceCommon.js +0 -15
- package/build/browser/GenerateContext/EnhanceCommon.js.map +1 -1
- package/build/browser/GenerateContext/EnhancedAction.js +1 -1
- package/build/browser/GenerateContext/EnhancedAction.js.map +1 -1
- package/build/browser/GenerateContext/EnhancedBase.js +2 -7
- package/build/browser/GenerateContext/EnhancedBase.js.map +1 -1
- package/build/browser/GenerateContext/EnhancedInterfaceType.js +1 -1
- package/build/browser/GenerateContext/EnhancedInterfaceType.js.map +1 -1
- package/build/browser/GenerateContext/EnhancedObjectType.js +1 -1
- package/build/browser/GenerateContext/EnhancedObjectType.js.map +1 -1
- package/build/browser/GenerateContext/EnhancedOntologyDefinition.js +1 -8
- package/build/browser/GenerateContext/EnhancedOntologyDefinition.js.map +1 -1
- package/build/browser/GenerateContext/EnhancedQuery.js +1 -1
- package/build/browser/GenerateContext/EnhancedQuery.js.map +1 -1
- package/build/browser/GenerateContext/EnhancedSharedPropertyType.js +1 -1
- package/build/browser/GenerateContext/EnhancedSharedPropertyType.js.map +1 -1
- package/build/browser/GenerateContext/ForeignType.js +1 -1
- package/build/browser/GenerateContext/ForeignType.js.map +1 -1
- package/build/browser/GenerateContext/GenerateContext.js +0 -15
- package/build/browser/GenerateContext/GenerateContext.js.map +1 -1
- package/build/browser/GenerateContext/enhanceOntology.js +1 -0
- package/build/browser/GenerateContext/enhanceOntology.js.map +1 -1
- package/build/browser/MinimalFs.js +0 -15
- package/build/browser/MinimalFs.js.map +1 -1
- package/build/browser/WireOntologyDefinition.js +0 -15
- package/build/browser/WireOntologyDefinition.js.map +1 -1
- package/build/browser/generateClientSdkPackage.js +5 -3
- package/build/browser/generateClientSdkPackage.js.map +1 -1
- package/build/browser/generateClientSdkPackage.test.js +3 -2
- package/build/browser/generateClientSdkPackage.test.js.map +1 -1
- package/build/browser/index.js +1 -0
- package/build/browser/index.js.map +1 -1
- package/build/browser/shared/apiNamespaces/startsWithApiNamespace.js +1 -0
- package/build/browser/shared/apiNamespaces/startsWithApiNamespace.js.map +1 -1
- package/build/browser/shared/apiNamespaces/startsWithApiNamespace.test.js +1 -0
- package/build/browser/shared/apiNamespaces/startsWithApiNamespace.test.js.map +1 -1
- package/build/browser/shared/getObjectImports.js +1 -0
- package/build/browser/shared/getObjectImports.js.map +1 -1
- package/build/browser/shared/getObjectTypeApiNamesFromQuery.js +1 -0
- package/build/browser/shared/getObjectTypeApiNamesFromQuery.js.map +1 -1
- package/build/browser/shared/getObjectTypesFromQueryDataType.js +1 -0
- package/build/browser/shared/getObjectTypesFromQueryDataType.js.map +1 -1
- package/build/browser/shared/propertyJsdoc.js +1 -0
- package/build/browser/shared/propertyJsdoc.js.map +1 -1
- package/build/browser/shared/sanitizeMetadata.js +9 -0
- package/build/browser/shared/sanitizeMetadata.js.map +1 -1
- package/build/browser/shared/sanitizeMetadata.test.js +1 -0
- package/build/browser/shared/sanitizeMetadata.test.js.map +1 -1
- package/build/browser/util/InMemoryFs.js +1 -0
- package/build/browser/util/InMemoryFs.js.map +1 -1
- package/build/browser/util/commaSeparatedIdentifiers.js +1 -0
- package/build/browser/util/commaSeparatedIdentifiers.js.map +1 -1
- package/build/browser/util/commaSeparatedTypeIdentifiers.js +1 -0
- package/build/browser/util/commaSeparatedTypeIdentifiers.js.map +1 -1
- package/build/browser/util/deleteUndefineds.js +1 -0
- package/build/browser/util/deleteUndefineds.js.map +1 -1
- package/build/browser/util/reservedKeywords.js +1 -0
- package/build/browser/util/reservedKeywords.js.map +1 -1
- package/build/browser/util/stringUnionFrom.js +1 -0
- package/build/browser/util/stringUnionFrom.js.map +1 -1
- package/build/browser/util/stringify.js +16 -0
- package/build/browser/util/stringify.js.map +1 -1
- package/build/browser/util/test/TodoWireOntology.js +24 -5
- package/build/browser/util/test/TodoWireOntology.js.map +1 -1
- package/build/browser/util/test/compileThis.js +1 -0
- package/build/browser/util/test/compileThis.js.map +1 -1
- package/build/browser/util/test/createMockMinimalFiles.js +1 -0
- package/build/browser/util/test/createMockMinimalFiles.js.map +1 -1
- package/build/browser/util/test/formatTs.js +1 -0
- package/build/browser/util/test/formatTs.js.map +1 -1
- package/build/browser/util/verifyOutDir.js +1 -0
- package/build/browser/util/verifyOutDir.js.map +1 -1
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +8 -6
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +22 -20
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js +7 -3
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js +572 -557
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
- package/build/browser/v2.0/generateMetadata.js +4 -1
- package/build/browser/v2.0/generateMetadata.js.map +1 -1
- package/build/browser/v2.0/generatePerActionDataFiles.js +33 -10
- package/build/browser/v2.0/generatePerActionDataFiles.js.map +1 -1
- package/build/browser/v2.0/generatePerActionDataFiles.test.js +1 -0
- package/build/browser/v2.0/generatePerActionDataFiles.test.js.map +1 -1
- package/build/browser/v2.0/generatePerInterfaceDataFiles.js +6 -3
- package/build/browser/v2.0/generatePerInterfaceDataFiles.js.map +1 -1
- package/build/browser/v2.0/generatePerObjectDataFiles.js +2 -1
- package/build/browser/v2.0/generatePerObjectDataFiles.js.map +1 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.js +6 -5
- package/build/browser/v2.0/generatePerQueryDataFiles.js.map +1 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.test.js +9 -8
- package/build/browser/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
- package/build/browser/v2.0/generateRootIndexTsFile.js +3 -1
- package/build/browser/v2.0/generateRootIndexTsFile.js.map +1 -1
- package/build/browser/v2.0/getDescriptionIfPresent.js +1 -0
- package/build/browser/v2.0/getDescriptionIfPresent.js.map +1 -1
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +23 -10
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
- package/build/browser/validateWireOntologyAssumptions.js +3 -2
- package/build/browser/validateWireOntologyAssumptions.js.map +1 -1
- package/build/cjs/index.cjs +1384 -0
- package/build/cjs/index.cjs.map +1 -0
- package/build/cjs/index.d.cts +31 -0
- package/build/esm/GenerateContext/EnhanceCommon.js +0 -15
- package/build/esm/GenerateContext/EnhanceCommon.js.map +1 -1
- package/build/esm/GenerateContext/EnhancedAction.js +1 -1
- package/build/esm/GenerateContext/EnhancedAction.js.map +1 -1
- package/build/esm/GenerateContext/EnhancedBase.js +2 -7
- package/build/esm/GenerateContext/EnhancedBase.js.map +1 -1
- package/build/esm/GenerateContext/EnhancedInterfaceType.js +1 -1
- package/build/esm/GenerateContext/EnhancedInterfaceType.js.map +1 -1
- package/build/esm/GenerateContext/EnhancedObjectType.js +1 -1
- package/build/esm/GenerateContext/EnhancedObjectType.js.map +1 -1
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.js +1 -8
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.js.map +1 -1
- package/build/esm/GenerateContext/EnhancedQuery.js +1 -1
- package/build/esm/GenerateContext/EnhancedQuery.js.map +1 -1
- package/build/esm/GenerateContext/EnhancedSharedPropertyType.js +1 -1
- package/build/esm/GenerateContext/EnhancedSharedPropertyType.js.map +1 -1
- package/build/esm/GenerateContext/ForeignType.js +1 -1
- package/build/esm/GenerateContext/ForeignType.js.map +1 -1
- package/build/esm/GenerateContext/GenerateContext.js +0 -15
- package/build/esm/GenerateContext/GenerateContext.js.map +1 -1
- package/build/esm/GenerateContext/enhanceOntology.js +1 -0
- package/build/esm/GenerateContext/enhanceOntology.js.map +1 -1
- package/build/esm/MinimalFs.js +0 -15
- package/build/esm/MinimalFs.js.map +1 -1
- package/build/esm/WireOntologyDefinition.js +0 -15
- package/build/esm/WireOntologyDefinition.js.map +1 -1
- package/build/esm/generateClientSdkPackage.js +5 -3
- package/build/esm/generateClientSdkPackage.js.map +1 -1
- package/build/esm/generateClientSdkPackage.test.js +3 -2
- package/build/esm/generateClientSdkPackage.test.js.map +1 -1
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/shared/apiNamespaces/startsWithApiNamespace.js +1 -0
- package/build/esm/shared/apiNamespaces/startsWithApiNamespace.js.map +1 -1
- package/build/esm/shared/apiNamespaces/startsWithApiNamespace.test.js +1 -0
- package/build/esm/shared/apiNamespaces/startsWithApiNamespace.test.js.map +1 -1
- package/build/esm/shared/getObjectImports.js +1 -0
- package/build/esm/shared/getObjectImports.js.map +1 -1
- package/build/esm/shared/getObjectTypeApiNamesFromQuery.js +1 -0
- package/build/esm/shared/getObjectTypeApiNamesFromQuery.js.map +1 -1
- package/build/esm/shared/getObjectTypesFromQueryDataType.js +1 -0
- package/build/esm/shared/getObjectTypesFromQueryDataType.js.map +1 -1
- package/build/esm/shared/propertyJsdoc.js +1 -0
- package/build/esm/shared/propertyJsdoc.js.map +1 -1
- package/build/esm/shared/sanitizeMetadata.js +9 -0
- package/build/esm/shared/sanitizeMetadata.js.map +1 -1
- package/build/esm/shared/sanitizeMetadata.test.js +1 -0
- package/build/esm/shared/sanitizeMetadata.test.js.map +1 -1
- package/build/esm/util/InMemoryFs.js +1 -0
- package/build/esm/util/InMemoryFs.js.map +1 -1
- package/build/esm/util/commaSeparatedIdentifiers.js +1 -0
- package/build/esm/util/commaSeparatedIdentifiers.js.map +1 -1
- package/build/esm/util/commaSeparatedTypeIdentifiers.js +1 -0
- package/build/esm/util/commaSeparatedTypeIdentifiers.js.map +1 -1
- package/build/esm/util/deleteUndefineds.js +1 -0
- package/build/esm/util/deleteUndefineds.js.map +1 -1
- package/build/esm/util/reservedKeywords.js +1 -0
- package/build/esm/util/reservedKeywords.js.map +1 -1
- package/build/esm/util/stringUnionFrom.js +1 -0
- package/build/esm/util/stringUnionFrom.js.map +1 -1
- package/build/esm/util/stringify.js +16 -0
- package/build/esm/util/stringify.js.map +1 -1
- package/build/esm/util/test/TodoWireOntology.js +24 -5
- package/build/esm/util/test/TodoWireOntology.js.map +1 -1
- package/build/esm/util/test/compileThis.js +1 -0
- package/build/esm/util/test/compileThis.js.map +1 -1
- package/build/esm/util/test/createMockMinimalFiles.js +1 -0
- package/build/esm/util/test/createMockMinimalFiles.js.map +1 -1
- package/build/esm/util/test/formatTs.js +1 -0
- package/build/esm/util/test/formatTs.js.map +1 -1
- package/build/esm/util/verifyOutDir.js +1 -0
- package/build/esm/util/verifyOutDir.js.map +1 -1
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +8 -6
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +22 -20
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js +7 -3
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js +572 -557
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
- package/build/esm/v2.0/generateMetadata.js +4 -1
- package/build/esm/v2.0/generateMetadata.js.map +1 -1
- package/build/esm/v2.0/generatePerActionDataFiles.js +33 -10
- package/build/esm/v2.0/generatePerActionDataFiles.js.map +1 -1
- package/build/esm/v2.0/generatePerActionDataFiles.test.js +1 -0
- package/build/esm/v2.0/generatePerActionDataFiles.test.js.map +1 -1
- package/build/esm/v2.0/generatePerInterfaceDataFiles.js +6 -3
- package/build/esm/v2.0/generatePerInterfaceDataFiles.js.map +1 -1
- package/build/esm/v2.0/generatePerObjectDataFiles.js +2 -1
- package/build/esm/v2.0/generatePerObjectDataFiles.js.map +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.js +6 -5
- package/build/esm/v2.0/generatePerQueryDataFiles.js.map +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.test.js +9 -8
- package/build/esm/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
- package/build/esm/v2.0/generateRootIndexTsFile.js +3 -1
- package/build/esm/v2.0/generateRootIndexTsFile.js.map +1 -1
- package/build/esm/v2.0/getDescriptionIfPresent.js +1 -0
- package/build/esm/v2.0/getDescriptionIfPresent.js.map +1 -1
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +23 -10
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
- package/build/esm/validateWireOntologyAssumptions.js +3 -2
- package/build/esm/validateWireOntologyAssumptions.js.map +1 -1
- package/build/types/GenerateContext/EnhanceCommon.d.ts +6 -0
- package/build/types/GenerateContext/EnhancedAction.d.ts +13 -0
- package/build/types/GenerateContext/EnhancedBase.d.ts +20 -0
- package/build/types/GenerateContext/EnhancedInterfaceType.d.ts +12 -0
- package/build/{esm → types}/GenerateContext/EnhancedObjectType.d.ts +5 -6
- package/build/types/GenerateContext/EnhancedOntologyDefinition.d.ts +28 -0
- package/build/types/GenerateContext/EnhancedQuery.d.ts +13 -0
- package/build/{browser → types}/GenerateContext/EnhancedSharedPropertyType.d.ts +2 -3
- package/build/types/GenerateContext/ForeignType.d.ts +8 -0
- package/build/types/GenerateContext/GenerateContext.d.ts +13 -0
- package/build/types/GenerateContext/enhanceOntology.d.ts +9 -0
- package/build/types/MinimalFs.d.ts +7 -0
- package/build/{browser → types}/WireOntologyDefinition.d.ts +1 -3
- package/build/types/generateClientSdkPackage.d.ts +31 -0
- package/build/types/generateClientSdkPackage.test.d.ts +1 -0
- package/build/types/index.d.ts +4 -0
- package/build/{browser → types}/shared/apiNamespaces/startsWithApiNamespace.d.ts +0 -1
- package/build/types/shared/apiNamespaces/startsWithApiNamespace.test.d.ts +1 -0
- package/build/{browser → types}/shared/getObjectImports.d.ts +2 -2
- package/build/{browser → types}/shared/getObjectTypeApiNamesFromQuery.d.ts +0 -1
- package/build/{browser → types}/shared/getObjectTypesFromQueryDataType.d.ts +0 -1
- package/build/{browser → types}/shared/propertyJsdoc.d.ts +2 -3
- package/build/types/shared/sanitizeMetadata.d.ts +1 -0
- package/build/types/shared/sanitizeMetadata.test.d.ts +1 -0
- package/build/{browser → types}/util/InMemoryFs.d.ts +2 -3
- package/build/{browser → types}/util/commaSeparatedIdentifiers.d.ts +0 -1
- package/build/{browser → types}/util/commaSeparatedTypeIdentifiers.d.ts +0 -1
- package/build/{browser → types}/util/deleteUndefineds.d.ts +0 -1
- package/build/{browser → types}/util/reservedKeywords.d.ts +0 -1
- package/build/{browser → types}/util/stringUnionFrom.d.ts +0 -1
- package/build/types/util/stringify.d.ts +20 -0
- package/build/types/util/test/TodoWireOntology.d.ts +2 -0
- package/build/{browser → types}/util/test/compileThis.d.ts +0 -1
- package/build/types/util/test/createMockMinimalFiles.d.ts +10 -0
- package/build/{browser → types}/util/test/formatTs.d.ts +0 -1
- package/build/types/util/verifyOutDir.d.ts +8 -0
- package/build/types/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts +1 -0
- package/build/types/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts +1 -0
- package/build/{esm → types}/v2.0/generateClientSdkVersionTwoPointZero.d.ts +1 -2
- package/build/types/v2.0/generateClientSdkVersionTwoPointZero.test.d.ts +1 -0
- package/build/{browser → types}/v2.0/generateMetadata.d.ts +0 -1
- package/build/{esm → types}/v2.0/generatePerActionDataFiles.d.ts +1 -2
- package/build/types/v2.0/generatePerActionDataFiles.test.d.ts +1 -0
- package/build/types/v2.0/generatePerInterfaceDataFiles.d.ts +1 -0
- package/build/{esm → types}/v2.0/generatePerObjectDataFiles.d.ts +0 -1
- package/build/{browser → types}/v2.0/generatePerQueryDataFiles.d.ts +2 -5
- package/build/types/v2.0/generatePerQueryDataFiles.test.d.ts +1 -0
- package/build/{esm → types}/v2.0/generateRootIndexTsFile.d.ts +0 -1
- package/build/{browser → types}/v2.0/getDescriptionIfPresent.d.ts +0 -1
- package/build/{browser → types}/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts +4 -6
- package/build/{browser → types}/validateWireOntologyAssumptions.d.ts +0 -1
- package/package.json +29 -13
- package/build/browser/GenerateContext/EnhanceCommon.d.ts +0 -7
- package/build/browser/GenerateContext/EnhanceCommon.d.ts.map +0 -1
- package/build/browser/GenerateContext/EnhancedAction.d.ts +0 -14
- package/build/browser/GenerateContext/EnhancedAction.d.ts.map +0 -1
- package/build/browser/GenerateContext/EnhancedBase.d.ts +0 -21
- package/build/browser/GenerateContext/EnhancedBase.d.ts.map +0 -1
- package/build/browser/GenerateContext/EnhancedInterfaceType.d.ts +0 -13
- package/build/browser/GenerateContext/EnhancedInterfaceType.d.ts.map +0 -1
- package/build/browser/GenerateContext/EnhancedObjectType.d.ts +0 -12
- package/build/browser/GenerateContext/EnhancedObjectType.d.ts.map +0 -1
- package/build/browser/GenerateContext/EnhancedOntologyDefinition.d.ts +0 -27
- package/build/browser/GenerateContext/EnhancedOntologyDefinition.d.ts.map +0 -1
- package/build/browser/GenerateContext/EnhancedQuery.d.ts +0 -14
- package/build/browser/GenerateContext/EnhancedQuery.d.ts.map +0 -1
- package/build/browser/GenerateContext/EnhancedSharedPropertyType.d.ts.map +0 -1
- package/build/browser/GenerateContext/ForeignType.d.ts +0 -9
- package/build/browser/GenerateContext/ForeignType.d.ts.map +0 -1
- package/build/browser/GenerateContext/GenerateContext.d.ts +0 -13
- package/build/browser/GenerateContext/GenerateContext.d.ts.map +0 -1
- package/build/browser/GenerateContext/enhanceOntology.d.ts +0 -10
- package/build/browser/GenerateContext/enhanceOntology.d.ts.map +0 -1
- package/build/browser/MinimalFs.d.ts +0 -10
- package/build/browser/MinimalFs.d.ts.map +0 -1
- package/build/browser/WireOntologyDefinition.d.ts.map +0 -1
- package/build/browser/generateClientSdkPackage.d.ts +0 -47
- package/build/browser/generateClientSdkPackage.d.ts.map +0 -1
- package/build/browser/generateClientSdkPackage.test.d.ts +0 -2
- package/build/browser/generateClientSdkPackage.test.d.ts.map +0 -1
- package/build/browser/index.d.ts +0 -5
- package/build/browser/index.d.ts.map +0 -1
- package/build/browser/shared/apiNamespaces/startsWithApiNamespace.d.ts.map +0 -1
- package/build/browser/shared/apiNamespaces/startsWithApiNamespace.test.d.ts +0 -2
- package/build/browser/shared/apiNamespaces/startsWithApiNamespace.test.d.ts.map +0 -1
- package/build/browser/shared/getObjectImports.d.ts.map +0 -1
- package/build/browser/shared/getObjectTypeApiNamesFromQuery.d.ts.map +0 -1
- package/build/browser/shared/getObjectTypesFromQueryDataType.d.ts.map +0 -1
- package/build/browser/shared/propertyJsdoc.d.ts.map +0 -1
- package/build/browser/shared/sanitizeMetadata.d.ts +0 -2
- package/build/browser/shared/sanitizeMetadata.d.ts.map +0 -1
- package/build/browser/shared/sanitizeMetadata.test.d.ts +0 -2
- package/build/browser/shared/sanitizeMetadata.test.d.ts.map +0 -1
- package/build/browser/util/InMemoryFs.d.ts.map +0 -1
- package/build/browser/util/commaSeparatedIdentifiers.d.ts.map +0 -1
- package/build/browser/util/commaSeparatedTypeIdentifiers.d.ts.map +0 -1
- package/build/browser/util/deleteUndefineds.d.ts.map +0 -1
- package/build/browser/util/reservedKeywords.d.ts.map +0 -1
- package/build/browser/util/stringUnionFrom.d.ts.map +0 -1
- package/build/browser/util/stringify.d.ts +0 -20
- package/build/browser/util/stringify.d.ts.map +0 -1
- package/build/browser/util/test/TodoWireOntology.d.ts +0 -217
- package/build/browser/util/test/TodoWireOntology.d.ts.map +0 -1
- package/build/browser/util/test/compileThis.d.ts.map +0 -1
- package/build/browser/util/test/createMockMinimalFiles.d.ts +0 -13
- package/build/browser/util/test/createMockMinimalFiles.d.ts.map +0 -1
- package/build/browser/util/test/formatTs.d.ts.map +0 -1
- package/build/browser/util/verifyOutDir.d.ts +0 -9
- package/build/browser/util/verifyOutDir.d.ts.map +0 -1
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts +0 -2
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts.map +0 -1
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts +0 -2
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts.map +0 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.d.ts +0 -4
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +0 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.d.ts +0 -2
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.d.ts.map +0 -1
- package/build/browser/v2.0/generateMetadata.d.ts.map +0 -1
- package/build/browser/v2.0/generatePerActionDataFiles.d.ts +0 -3
- package/build/browser/v2.0/generatePerActionDataFiles.d.ts.map +0 -1
- package/build/browser/v2.0/generatePerActionDataFiles.test.d.ts +0 -2
- package/build/browser/v2.0/generatePerActionDataFiles.test.d.ts.map +0 -1
- package/build/browser/v2.0/generatePerInterfaceDataFiles.d.ts +0 -2
- package/build/browser/v2.0/generatePerInterfaceDataFiles.d.ts.map +0 -1
- package/build/browser/v2.0/generatePerObjectDataFiles.d.ts +0 -3
- package/build/browser/v2.0/generatePerObjectDataFiles.d.ts.map +0 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.d.ts.map +0 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.test.d.ts +0 -2
- package/build/browser/v2.0/generatePerQueryDataFiles.test.d.ts.map +0 -1
- package/build/browser/v2.0/generateRootIndexTsFile.d.ts +0 -3
- package/build/browser/v2.0/generateRootIndexTsFile.d.ts.map +0 -1
- package/build/browser/v2.0/getDescriptionIfPresent.d.ts.map +0 -1
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +0 -1
- package/build/browser/validateWireOntologyAssumptions.d.ts.map +0 -1
- package/build/esm/GenerateContext/EnhanceCommon.d.ts +0 -7
- package/build/esm/GenerateContext/EnhanceCommon.d.ts.map +0 -1
- package/build/esm/GenerateContext/EnhancedAction.d.ts +0 -14
- package/build/esm/GenerateContext/EnhancedAction.d.ts.map +0 -1
- package/build/esm/GenerateContext/EnhancedBase.d.ts +0 -21
- package/build/esm/GenerateContext/EnhancedBase.d.ts.map +0 -1
- package/build/esm/GenerateContext/EnhancedInterfaceType.d.ts +0 -13
- package/build/esm/GenerateContext/EnhancedInterfaceType.d.ts.map +0 -1
- package/build/esm/GenerateContext/EnhancedObjectType.d.ts.map +0 -1
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.d.ts +0 -27
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.d.ts.map +0 -1
- package/build/esm/GenerateContext/EnhancedQuery.d.ts +0 -14
- package/build/esm/GenerateContext/EnhancedQuery.d.ts.map +0 -1
- package/build/esm/GenerateContext/EnhancedSharedPropertyType.d.ts +0 -8
- package/build/esm/GenerateContext/EnhancedSharedPropertyType.d.ts.map +0 -1
- package/build/esm/GenerateContext/ForeignType.d.ts +0 -9
- package/build/esm/GenerateContext/ForeignType.d.ts.map +0 -1
- package/build/esm/GenerateContext/GenerateContext.d.ts +0 -13
- package/build/esm/GenerateContext/GenerateContext.d.ts.map +0 -1
- package/build/esm/GenerateContext/enhanceOntology.d.ts +0 -10
- package/build/esm/GenerateContext/enhanceOntology.d.ts.map +0 -1
- package/build/esm/MinimalFs.d.ts +0 -10
- package/build/esm/MinimalFs.d.ts.map +0 -1
- package/build/esm/WireOntologyDefinition.d.ts +0 -4
- package/build/esm/WireOntologyDefinition.d.ts.map +0 -1
- package/build/esm/generateClientSdkPackage.d.ts +0 -47
- package/build/esm/generateClientSdkPackage.d.ts.map +0 -1
- package/build/esm/generateClientSdkPackage.test.d.ts +0 -2
- package/build/esm/generateClientSdkPackage.test.d.ts.map +0 -1
- package/build/esm/index.d.ts +0 -5
- package/build/esm/index.d.ts.map +0 -1
- package/build/esm/shared/apiNamespaces/startsWithApiNamespace.d.ts +0 -2
- package/build/esm/shared/apiNamespaces/startsWithApiNamespace.d.ts.map +0 -1
- package/build/esm/shared/apiNamespaces/startsWithApiNamespace.test.d.ts +0 -2
- package/build/esm/shared/apiNamespaces/startsWithApiNamespace.test.d.ts.map +0 -1
- package/build/esm/shared/getObjectImports.d.ts +0 -4
- package/build/esm/shared/getObjectImports.d.ts.map +0 -1
- package/build/esm/shared/getObjectTypeApiNamesFromQuery.d.ts +0 -4
- package/build/esm/shared/getObjectTypeApiNamesFromQuery.d.ts.map +0 -1
- package/build/esm/shared/getObjectTypesFromQueryDataType.d.ts +0 -3
- package/build/esm/shared/getObjectTypesFromQueryDataType.d.ts.map +0 -1
- package/build/esm/shared/propertyJsdoc.d.ts +0 -6
- package/build/esm/shared/propertyJsdoc.d.ts.map +0 -1
- package/build/esm/shared/sanitizeMetadata.d.ts +0 -2
- package/build/esm/shared/sanitizeMetadata.d.ts.map +0 -1
- package/build/esm/shared/sanitizeMetadata.test.d.ts +0 -2
- package/build/esm/shared/sanitizeMetadata.test.d.ts.map +0 -1
- package/build/esm/util/InMemoryFs.d.ts +0 -7
- package/build/esm/util/InMemoryFs.d.ts.map +0 -1
- package/build/esm/util/commaSeparatedIdentifiers.d.ts +0 -2
- package/build/esm/util/commaSeparatedIdentifiers.d.ts.map +0 -1
- package/build/esm/util/commaSeparatedTypeIdentifiers.d.ts +0 -2
- package/build/esm/util/commaSeparatedTypeIdentifiers.d.ts.map +0 -1
- package/build/esm/util/deleteUndefineds.d.ts +0 -2
- package/build/esm/util/deleteUndefineds.d.ts.map +0 -1
- package/build/esm/util/reservedKeywords.d.ts +0 -2
- package/build/esm/util/reservedKeywords.d.ts.map +0 -1
- package/build/esm/util/stringUnionFrom.d.ts +0 -2
- package/build/esm/util/stringUnionFrom.d.ts.map +0 -1
- package/build/esm/util/stringify.d.ts +0 -20
- package/build/esm/util/stringify.d.ts.map +0 -1
- package/build/esm/util/test/TodoWireOntology.d.ts +0 -217
- package/build/esm/util/test/TodoWireOntology.d.ts.map +0 -1
- package/build/esm/util/test/compileThis.d.ts +0 -3
- package/build/esm/util/test/compileThis.d.ts.map +0 -1
- package/build/esm/util/test/createMockMinimalFiles.d.ts +0 -13
- package/build/esm/util/test/createMockMinimalFiles.d.ts.map +0 -1
- package/build/esm/util/test/formatTs.d.ts +0 -2
- package/build/esm/util/test/formatTs.d.ts.map +0 -1
- package/build/esm/util/verifyOutDir.d.ts +0 -9
- package/build/esm/util/verifyOutDir.d.ts.map +0 -1
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts +0 -2
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts.map +0 -1
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts +0 -2
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts.map +0 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +0 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.d.ts +0 -2
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.d.ts.map +0 -1
- package/build/esm/v2.0/generateMetadata.d.ts +0 -3
- package/build/esm/v2.0/generateMetadata.d.ts.map +0 -1
- package/build/esm/v2.0/generatePerActionDataFiles.d.ts.map +0 -1
- package/build/esm/v2.0/generatePerActionDataFiles.test.d.ts +0 -2
- package/build/esm/v2.0/generatePerActionDataFiles.test.d.ts.map +0 -1
- package/build/esm/v2.0/generatePerInterfaceDataFiles.d.ts +0 -2
- package/build/esm/v2.0/generatePerInterfaceDataFiles.d.ts.map +0 -1
- package/build/esm/v2.0/generatePerObjectDataFiles.d.ts.map +0 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.d.ts +0 -9
- package/build/esm/v2.0/generatePerQueryDataFiles.d.ts.map +0 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.test.d.ts +0 -2
- package/build/esm/v2.0/generatePerQueryDataFiles.test.d.ts.map +0 -1
- package/build/esm/v2.0/generateRootIndexTsFile.d.ts.map +0 -1
- package/build/esm/v2.0/getDescriptionIfPresent.d.ts +0 -2
- package/build/esm/v2.0/getDescriptionIfPresent.d.ts.map +0 -1
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts +0 -12
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +0 -1
- package/build/esm/validateWireOntologyAssumptions.d.ts +0 -3
- package/build/esm/validateWireOntologyAssumptions.d.ts.map +0 -1
|
@@ -0,0 +1,1384 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var path8 = require('path');
|
|
5
|
+
var generatorConverters = require('@osdk/generator-converters');
|
|
6
|
+
var prettier = require('prettier');
|
|
7
|
+
var fastDeepEqual = require('fast-deep-equal');
|
|
8
|
+
var invariant = require('tiny-invariant');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
31
|
+
var path8__namespace = /*#__PURE__*/_interopNamespace(path8);
|
|
32
|
+
var fastDeepEqual__default = /*#__PURE__*/_interopDefault(fastDeepEqual);
|
|
33
|
+
var invariant__default = /*#__PURE__*/_interopDefault(invariant);
|
|
34
|
+
|
|
35
|
+
// src/generateClientSdkPackage.ts
|
|
36
|
+
var AbstractImportable = class {
|
|
37
|
+
/**
|
|
38
|
+
* Either a path relative to the ourDir (e.g. "./ontology/objects/foo.js") or a normal
|
|
39
|
+
* module import (e.g. "@something/foo")/
|
|
40
|
+
*/
|
|
41
|
+
constructor(common, fullApiName, basePath, isLocal = true) {
|
|
42
|
+
this._common = common;
|
|
43
|
+
this.fullApiName = fullApiName;
|
|
44
|
+
[this.apiNamespace, this.shortApiName] = extractNamespace(this.fullApiName);
|
|
45
|
+
const {
|
|
46
|
+
importExt
|
|
47
|
+
} = common;
|
|
48
|
+
this.importPath = isLocal ? `${basePath}/${this.shortApiName}${importExt}` : basePath;
|
|
49
|
+
this.uniqueImportName = this.shortApiName;
|
|
50
|
+
}
|
|
51
|
+
getImportPathRelTo = (filePath) => {
|
|
52
|
+
if (this.importPath.startsWith(".")) {
|
|
53
|
+
const result = path8__namespace.relative(path8__namespace.dirname(filePath), this.importPath).split(path8__namespace.sep).join("/");
|
|
54
|
+
if (result.startsWith(".")) {
|
|
55
|
+
return result;
|
|
56
|
+
} else {
|
|
57
|
+
return `./${result}`;
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
return this.importPath;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
var EnhancedBase = class extends AbstractImportable {
|
|
65
|
+
constructor(common, raw, fullApiName, basePath) {
|
|
66
|
+
super(common, fullApiName, basePath);
|
|
67
|
+
this.raw = raw;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function extractNamespace(fqApiName) {
|
|
71
|
+
const last = fqApiName.lastIndexOf(".");
|
|
72
|
+
if (last === -1) return [undefined, fqApiName];
|
|
73
|
+
return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/GenerateContext/EnhancedAction.ts
|
|
77
|
+
var EnhancedAction = class extends EnhancedBase {
|
|
78
|
+
constructor(common, raw) {
|
|
79
|
+
super(common, raw, raw.apiName, "./ontology/actions");
|
|
80
|
+
this.raw = raw;
|
|
81
|
+
}
|
|
82
|
+
get description() {
|
|
83
|
+
return this.raw.description;
|
|
84
|
+
}
|
|
85
|
+
get parameters() {
|
|
86
|
+
return this.raw.parameters;
|
|
87
|
+
}
|
|
88
|
+
get operations() {
|
|
89
|
+
return this.raw.operations;
|
|
90
|
+
}
|
|
91
|
+
get paramsIdentifier() {
|
|
92
|
+
return `${this.shortApiName}.Params`;
|
|
93
|
+
}
|
|
94
|
+
get definitionIdentifier() {
|
|
95
|
+
return `${this.shortApiName}.Definition`;
|
|
96
|
+
}
|
|
97
|
+
get definitionParamsIdentifier() {
|
|
98
|
+
return `${this.shortApiName}.ParamsDefinition`;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/util/deleteUndefineds.ts
|
|
103
|
+
function deleteUndefineds(obj) {
|
|
104
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/GenerateContext/EnhancedInterfaceType.ts
|
|
108
|
+
var EnhancedInterfaceType = class extends EnhancedBase {
|
|
109
|
+
constructor(common, raw) {
|
|
110
|
+
super(common, raw, raw.apiName, "./ontology/interfaces");
|
|
111
|
+
this.raw = raw;
|
|
112
|
+
}
|
|
113
|
+
getDefinitionIdentifier(v2) {
|
|
114
|
+
return v2 ? this.shortApiName : `${this.shortApiName}Def`;
|
|
115
|
+
}
|
|
116
|
+
getImportedDefinitionIdentifier(v2) {
|
|
117
|
+
return this.getDefinitionIdentifier(v2);
|
|
118
|
+
}
|
|
119
|
+
get properties() {
|
|
120
|
+
return this.raw.properties;
|
|
121
|
+
}
|
|
122
|
+
getCleanedUpDefinition(v2) {
|
|
123
|
+
return deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(this.raw, v2));
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var EnhancedObjectType = class extends EnhancedBase {
|
|
127
|
+
constructor(common, raw) {
|
|
128
|
+
super(common, raw, raw.objectType.apiName, "./ontology/objects");
|
|
129
|
+
this.raw = raw;
|
|
130
|
+
}
|
|
131
|
+
getDefinitionIdentifier(v2) {
|
|
132
|
+
return v2 ? `${this.shortApiName}` : `${this.shortApiName}Def`;
|
|
133
|
+
}
|
|
134
|
+
getImportedDefinitionIdentifier(v2) {
|
|
135
|
+
return this.getDefinitionIdentifier(v2);
|
|
136
|
+
}
|
|
137
|
+
getCleanedUpDefinition(v2) {
|
|
138
|
+
return deleteUndefineds(generatorConverters.wireObjectTypeFullMetadataToSdkObjectMetadata(this.raw, v2));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// src/GenerateContext/EnhancedQuery.ts
|
|
143
|
+
var EnhancedQuery = class extends EnhancedBase {
|
|
144
|
+
constructor(common, raw) {
|
|
145
|
+
super(common, raw, raw.apiName, "./ontology/queries");
|
|
146
|
+
this.raw = raw;
|
|
147
|
+
}
|
|
148
|
+
get description() {
|
|
149
|
+
return this.raw.description;
|
|
150
|
+
}
|
|
151
|
+
get parameters() {
|
|
152
|
+
return this.raw.parameters;
|
|
153
|
+
}
|
|
154
|
+
get output() {
|
|
155
|
+
return this.raw.output;
|
|
156
|
+
}
|
|
157
|
+
get paramsIdentifier() {
|
|
158
|
+
return `${this.shortApiName}.Parameters`;
|
|
159
|
+
}
|
|
160
|
+
get definitionIdentifier() {
|
|
161
|
+
return `${this.shortApiName}`;
|
|
162
|
+
}
|
|
163
|
+
get definitionParamsIdentifier() {
|
|
164
|
+
return `${this.definitionIdentifier}$Params`;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/GenerateContext/EnhancedSharedPropertyType.ts
|
|
169
|
+
var EnhancedSharedPropertyType = class extends EnhancedBase {
|
|
170
|
+
constructor(common, raw) {
|
|
171
|
+
super(common, raw, raw.apiName, "./ontology/interfaces");
|
|
172
|
+
this.raw = raw;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/GenerateContext/ForeignType.ts
|
|
177
|
+
var ForeignType = class extends AbstractImportable {
|
|
178
|
+
constructor(_common, apiNamespace, shortApiName, destinationPackage) {
|
|
179
|
+
super(_common, apiNamespace ? `${apiNamespace}.${shortApiName}` : shortApiName, destinationPackage, false);
|
|
180
|
+
this._common = _common;
|
|
181
|
+
}
|
|
182
|
+
getImportedDefinitionIdentifier(v2) {
|
|
183
|
+
return `$Imported$${this.apiNamespace?.replace(/\./g, "$")}$${this.shortApiName}`;
|
|
184
|
+
}
|
|
185
|
+
getDefinitionIdentifier(v2) {
|
|
186
|
+
return this.uniqueImportName;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// src/GenerateContext/EnhancedOntologyDefinition.ts
|
|
191
|
+
var EnhancedOntologyDefinition = class {
|
|
192
|
+
#foreignTypes = {};
|
|
193
|
+
constructor(raw, importExt, externalObjects, externalInterfaces, externalSpts) {
|
|
194
|
+
this.common = {
|
|
195
|
+
enhancedOntology: this,
|
|
196
|
+
importExt
|
|
197
|
+
};
|
|
198
|
+
this.raw = raw;
|
|
199
|
+
this.ontology = raw.ontology;
|
|
200
|
+
this.objectTypes = remap(raw.objectTypes, this.common, EnhancedObjectType, externalObjects);
|
|
201
|
+
this.actionTypes = remap(raw.actionTypes, this.common, EnhancedAction);
|
|
202
|
+
this.queryTypes = remap(raw.queryTypes, this.common, EnhancedQuery);
|
|
203
|
+
this.interfaceTypes = remap(raw.interfaceTypes, this.common, EnhancedInterfaceType, externalInterfaces);
|
|
204
|
+
this.sharedPropertyTypes = remap(raw.sharedPropertyTypes, this.common, EnhancedSharedPropertyType, externalSpts);
|
|
205
|
+
}
|
|
206
|
+
#createRequireType = (type) => {
|
|
207
|
+
return (fullApiName, localOnly) => {
|
|
208
|
+
const ret = this[type][fullApiName];
|
|
209
|
+
if (!ret) {
|
|
210
|
+
extractNamespace(fullApiName);
|
|
211
|
+
throw new Error(`Unable to find ${type}: No entry for '${fullApiName}`);
|
|
212
|
+
}
|
|
213
|
+
return ret;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
requireObjectType = this.#createRequireType("objectTypes");
|
|
217
|
+
requireInterfaceType = this.#createRequireType("interfaceTypes");
|
|
218
|
+
requireActionType = this.#createRequireType("actionTypes");
|
|
219
|
+
requireQueryType = this.#createRequireType("queryTypes");
|
|
220
|
+
requireSharedPropertyType = this.#createRequireType("sharedPropertyTypes");
|
|
221
|
+
};
|
|
222
|
+
function remap(r, common, Constructor, externalMap) {
|
|
223
|
+
const entries = [];
|
|
224
|
+
for (const [fullApiName, v] of Object.entries(r ?? {})) {
|
|
225
|
+
if (externalMap?.has(fullApiName)) ; else {
|
|
226
|
+
entries.push([fullApiName, new Constructor(common, v)]);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (externalMap) {
|
|
230
|
+
for (const [fullApiName, destPackage] of externalMap) {
|
|
231
|
+
const [apiNamespace, shortApiName] = extractNamespace(fullApiName);
|
|
232
|
+
entries.push([fullApiName, new ForeignType(common, apiNamespace, shortApiName, destPackage)]);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return Object.fromEntries(entries.sort((a, b) => a[0].localeCompare(b[0])));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/GenerateContext/enhanceOntology.ts
|
|
239
|
+
function enhanceOntology({
|
|
240
|
+
sanitized,
|
|
241
|
+
importExt,
|
|
242
|
+
externalObjects,
|
|
243
|
+
externalInterfaces,
|
|
244
|
+
externalSpts
|
|
245
|
+
}) {
|
|
246
|
+
return new EnhancedOntologyDefinition(sanitized, importExt, externalObjects, externalInterfaces, externalSpts);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/shared/sanitizeMetadata.ts
|
|
250
|
+
function sanitizeMetadata(ontology) {
|
|
251
|
+
return {
|
|
252
|
+
...ontology,
|
|
253
|
+
actionTypes: Object.fromEntries(Object.values(ontology.actionTypes).map((actionType) => {
|
|
254
|
+
return [camelize(actionType.apiName), {
|
|
255
|
+
...actionType,
|
|
256
|
+
apiName: camelize(actionType.apiName)
|
|
257
|
+
}];
|
|
258
|
+
}))
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function camelize(name) {
|
|
262
|
+
return name.replace(/-./g, (segment) => segment[1].toUpperCase());
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/util/verifyOutDir.ts
|
|
266
|
+
async function verifyOutDir(outDir, fs2) {
|
|
267
|
+
try {
|
|
268
|
+
const contents = await fs2.readdir(outDir);
|
|
269
|
+
if (contents.length !== 0) {
|
|
270
|
+
throw new Error(`outDir ${outDir} is not empty, please delete its contents and try again`);
|
|
271
|
+
}
|
|
272
|
+
} catch (e) {
|
|
273
|
+
if (e.code === "ENOENT") ; else {
|
|
274
|
+
throw e;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function formatTs(contents) {
|
|
279
|
+
try {
|
|
280
|
+
return prettier.format(contents, {
|
|
281
|
+
parser: "typescript",
|
|
282
|
+
singleQuote: true,
|
|
283
|
+
trailingComma: "all",
|
|
284
|
+
tabWidth: 2,
|
|
285
|
+
printWidth: 120
|
|
286
|
+
});
|
|
287
|
+
} catch (e) {
|
|
288
|
+
console.error("Failed to format file", e);
|
|
289
|
+
console.log(contents);
|
|
290
|
+
return contents;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/v2.0/generateMetadata.ts
|
|
295
|
+
var ExpectedOsdkVersion = "2.1.0";
|
|
296
|
+
async function generateOntologyMetadataFile({
|
|
297
|
+
fs: fs2,
|
|
298
|
+
outDir,
|
|
299
|
+
ontology,
|
|
300
|
+
ontologyApiNamespace
|
|
301
|
+
}, userAgent) {
|
|
302
|
+
await fs2.writeFile(path8__namespace.default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
303
|
+
export type $ExpectedClientVersion = "${ExpectedOsdkVersion}";
|
|
304
|
+
export const $osdkMetadata = { extraUserAgent: "${userAgent}" };
|
|
305
|
+
${ontologyApiNamespace == null ? `
|
|
306
|
+
export const $ontologyRid = "${ontology.ontology.rid}";
|
|
307
|
+
` : ""}
|
|
308
|
+
`));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// src/shared/getObjectImports.ts
|
|
312
|
+
function getObjectImports(objects, curApiName, currentFilePath, v2) {
|
|
313
|
+
return Array.from(objects).filter((obj) => obj.fullApiName !== curApiName).map((obj) => {
|
|
314
|
+
const defId = obj.getDefinitionIdentifier(v2);
|
|
315
|
+
const importedId = obj.getImportedDefinitionIdentifier(v2);
|
|
316
|
+
const nameOrAlias = defId === importedId ? defId : `${defId} as ${importedId}`;
|
|
317
|
+
return `import type { ${nameOrAlias} } from "${obj.getImportPathRelTo("./" + currentFilePath)}";`;
|
|
318
|
+
}).join("\n");
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// src/util/stringify.ts
|
|
322
|
+
var defaultCustomizer = (value, defaultValueFormatter, key, defaultKeyFormatter) => {
|
|
323
|
+
return [defaultKeyFormatter(key), defaultValueFormatter(value)];
|
|
324
|
+
};
|
|
325
|
+
function stringify(obj, customizer = {}, separator = ",\n") {
|
|
326
|
+
const defaultKeyFormatter = (key) => `${JSON.stringify(key)}`;
|
|
327
|
+
const entries = [];
|
|
328
|
+
const sortedKeys = Object.keys(obj).sort((a, b) => a.localeCompare(b));
|
|
329
|
+
for (const key of sortedKeys) {
|
|
330
|
+
const value = obj[key];
|
|
331
|
+
const res = (customizer[key] ?? customizer["*"] ?? defaultCustomizer)(value, (value2) => JSON.stringify(value2, null, 2), key, defaultKeyFormatter);
|
|
332
|
+
if (res) {
|
|
333
|
+
if (typeof res === "string") {
|
|
334
|
+
entries.push(`${defaultKeyFormatter(key)}: ${res}`);
|
|
335
|
+
} else {
|
|
336
|
+
entries.push(`${res[0]}: ${res[1]}`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return entries.join(separator);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// src/util/stringUnionFrom.ts
|
|
344
|
+
function stringUnionFrom(values) {
|
|
345
|
+
if (values.length === 0) {
|
|
346
|
+
return "never";
|
|
347
|
+
} else {
|
|
348
|
+
return values.map((v) => `"${v}"`).join("|");
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// src/v2.0/getDescriptionIfPresent.ts
|
|
353
|
+
function getDescriptionIfPresent(description, includeNewline) {
|
|
354
|
+
if (description) {
|
|
355
|
+
return `/**
|
|
356
|
+
* ${description}
|
|
357
|
+
*/${""}`;
|
|
358
|
+
}
|
|
359
|
+
return "";
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// src/v2.0/generatePerActionDataFiles.ts
|
|
363
|
+
async function generatePerActionDataFiles({
|
|
364
|
+
sanitizedOntology: ontology,
|
|
365
|
+
fs: fs2,
|
|
366
|
+
outDir: rootOutDir,
|
|
367
|
+
importExt = "",
|
|
368
|
+
ontology: enhancedOntology,
|
|
369
|
+
forInternalUse = false
|
|
370
|
+
}) {
|
|
371
|
+
const outDir = path8__namespace.default.join(rootOutDir, "ontology", "actions");
|
|
372
|
+
await fs2.mkdir(outDir, {
|
|
373
|
+
recursive: true
|
|
374
|
+
});
|
|
375
|
+
await Promise.all(Object.values(enhancedOntology.actionTypes).map(async (action) => {
|
|
376
|
+
const currentFilePath = path8__namespace.default.join("ontology", "actions", `${action.shortApiName}.ts`);
|
|
377
|
+
const uniqueApiNamesArray = extractReferencedObjectsFromAction(action.raw);
|
|
378
|
+
const uniqueApiNames = new Set(uniqueApiNamesArray);
|
|
379
|
+
stringUnionFrom([...uniqueApiNames]);
|
|
380
|
+
const fullActionDef = deleteUndefineds(generatorConverters.wireActionTypeV2ToSdkActionMetadata(action.raw));
|
|
381
|
+
function createParamsDef() {
|
|
382
|
+
const entries = Object.entries(fullActionDef.parameters ?? {});
|
|
383
|
+
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
|
384
|
+
if (entries.length === 0) {
|
|
385
|
+
return `// Represents the definition of the parameters for the action
|
|
386
|
+
export type ParamsDefinition = Record<string, never>;`;
|
|
387
|
+
}
|
|
388
|
+
return `// Represents the definition of the parameters for the action
|
|
389
|
+
export type ParamsDefinition = {
|
|
390
|
+
${entries.map(([key, value]) => {
|
|
391
|
+
return `"${key}": {
|
|
392
|
+
${stringify(value, {
|
|
393
|
+
description: (value2, d) => value2 ? d(value2) : undefined,
|
|
394
|
+
// trick to remove undefineds
|
|
395
|
+
type: (type) => {
|
|
396
|
+
if (typeof type === "string") {
|
|
397
|
+
return JSON.stringify(type);
|
|
398
|
+
} else if (type.type === "object") {
|
|
399
|
+
const obj = enhancedOntology.requireObjectType(type.object);
|
|
400
|
+
return `ActionMetadata.DataType.Object<${obj.getImportedDefinitionIdentifier(true)}>`;
|
|
401
|
+
} else if (type.type === "objectSet") {
|
|
402
|
+
const obj = enhancedOntology.requireObjectType(type.objectSet);
|
|
403
|
+
return `ActionMetadata.DataType.ObjectSet<${obj.getImportedDefinitionIdentifier(true)}>`;
|
|
404
|
+
} else if (type.type === "interface") {
|
|
405
|
+
const obj = enhancedOntology.requireInterfaceType(type.interface);
|
|
406
|
+
return `ActionMetadata.DataType.Interface<${obj.getImportedDefinitionIdentifier(true)}>`;
|
|
407
|
+
} else if (type.type === "struct") {
|
|
408
|
+
return `ActionMetadata.DataType.Struct<${JSON.stringify(type.struct)}>`;
|
|
409
|
+
}
|
|
410
|
+
return undefined;
|
|
411
|
+
}
|
|
412
|
+
})}
|
|
413
|
+
}`;
|
|
414
|
+
}).join(";\n")}
|
|
415
|
+
}`;
|
|
416
|
+
}
|
|
417
|
+
function getActionParamType(input) {
|
|
418
|
+
if (typeof input === "string") {
|
|
419
|
+
return `ActionParam.PrimitiveType<${JSON.stringify(input)}>`;
|
|
420
|
+
} else if (input.type === "object") {
|
|
421
|
+
return `ActionParam.ObjectType<${enhancedOntology.requireObjectType(input.object).getImportedDefinitionIdentifier(true)}>`;
|
|
422
|
+
} else if (input.type === "objectSet") {
|
|
423
|
+
return `ActionParam.ObjectSetType<${enhancedOntology.requireObjectType(input.objectSet).getImportedDefinitionIdentifier(true)}>`;
|
|
424
|
+
} else if (input.type === "interface") {
|
|
425
|
+
return `ActionParam.InterfaceType<${enhancedOntology.requireInterfaceType(input.interface).getImportedDefinitionIdentifier(true)}>`;
|
|
426
|
+
} else if (input.type === "struct") {
|
|
427
|
+
return `ActionParam.StructType<${JSON.stringify(input.struct)}>`;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function createV2Types() {
|
|
431
|
+
`${action.shortApiName}$Params`;
|
|
432
|
+
const jsDocBlock = ["/**"];
|
|
433
|
+
if (action.description != null) {
|
|
434
|
+
jsDocBlock.push(`* ${action.description}`);
|
|
435
|
+
}
|
|
436
|
+
return `
|
|
437
|
+
|
|
438
|
+
export namespace ${action.shortApiName}{
|
|
439
|
+
${createParamsDef()}
|
|
440
|
+
|
|
441
|
+
${getDescriptionIfPresent(action.description)}
|
|
442
|
+
export interface Params {
|
|
443
|
+
${stringify(fullActionDef.parameters, {
|
|
444
|
+
"*": (ogValue, _, ogKey) => {
|
|
445
|
+
const key = `${getDescriptionIfPresent(ogValue.description)}
|
|
446
|
+
readonly "${ogKey}"${ogValue.nullable ? "?" : ""}`;
|
|
447
|
+
const value = ogValue.multiplicity ? `ReadonlyArray<${getActionParamType(ogValue.type)}>` : `${getActionParamType(ogValue.type)}`;
|
|
448
|
+
jsDocBlock.push(`* @param {${getActionParamType(ogValue.type)}} ${ogValue.nullable ? `[${ogKey}]` : ogKey} ${ogValue.description ?? ""} `);
|
|
449
|
+
return [key, value];
|
|
450
|
+
}
|
|
451
|
+
})}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Represents a fqn of the action
|
|
455
|
+
export interface Signatures {
|
|
456
|
+
${getDescriptionIfPresent(action.description)}
|
|
457
|
+
applyAction<P extends ${action.paramsIdentifier}, OP extends ApplyActionOptions>(args: P, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;
|
|
458
|
+
|
|
459
|
+
batchApplyAction<P extends ReadonlyArray<${action.paramsIdentifier}>, OP extends ApplyBatchActionOptions>(args: P, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
${jsDocBlock.join("\n")}
|
|
466
|
+
*/
|
|
467
|
+
export interface ${action.shortApiName} extends ActionDefinition<${action.shortApiName}.Signatures> {
|
|
468
|
+
__DefinitionMetadata?: {
|
|
469
|
+
${stringify(fullActionDef, {
|
|
470
|
+
"parameters": () => action.definitionParamsIdentifier
|
|
471
|
+
})}
|
|
472
|
+
|
|
473
|
+
signatures: ${action.shortApiName}.Signatures;
|
|
474
|
+
},
|
|
475
|
+
${stringify(fullActionDef, {
|
|
476
|
+
"description": () => undefined,
|
|
477
|
+
"displayName": () => undefined,
|
|
478
|
+
"modifiedEntities": () => undefined,
|
|
479
|
+
"parameters": () => undefined,
|
|
480
|
+
"rid": () => undefined,
|
|
481
|
+
"status": () => undefined
|
|
482
|
+
})}
|
|
483
|
+
osdkMetadata: typeof $osdkMetadata;
|
|
484
|
+
}
|
|
485
|
+
`;
|
|
486
|
+
}
|
|
487
|
+
function createV2Object() {
|
|
488
|
+
return ` export const ${action.shortApiName}: ${action.shortApiName} =
|
|
489
|
+
{
|
|
490
|
+
${stringify(fullActionDef, {
|
|
491
|
+
"description": () => undefined,
|
|
492
|
+
"displayName": () => undefined,
|
|
493
|
+
"modifiedEntities": () => undefined,
|
|
494
|
+
"parameters": () => undefined,
|
|
495
|
+
"rid": () => undefined,
|
|
496
|
+
"status": () => undefined
|
|
497
|
+
})},
|
|
498
|
+
osdkMetadata: $osdkMetadata
|
|
499
|
+
}
|
|
500
|
+
`;
|
|
501
|
+
}
|
|
502
|
+
const referencedObjectDefs = /* @__PURE__ */ new Set();
|
|
503
|
+
for (const p of Object.values(action.parameters)) {
|
|
504
|
+
if (p.dataType.type === "object" || p.dataType.type === "objectSet") {
|
|
505
|
+
if (p.dataType.objectApiName) {
|
|
506
|
+
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.objectApiName));
|
|
507
|
+
}
|
|
508
|
+
if (p.dataType.objectTypeApiName) {
|
|
509
|
+
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.objectTypeApiName));
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (p.dataType.type === "interfaceObject") {
|
|
513
|
+
if (p.dataType.interfaceTypeApiName) {
|
|
514
|
+
referencedObjectDefs.add(enhancedOntology.requireInterfaceType(p.dataType.interfaceTypeApiName));
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (p.dataType.type === "array") {
|
|
518
|
+
if (p.dataType.subType.type === "object" || p.dataType.subType.type === "objectSet") {
|
|
519
|
+
if (p.dataType.subType.objectApiName) {
|
|
520
|
+
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.subType.objectApiName));
|
|
521
|
+
}
|
|
522
|
+
if (p.dataType.subType.objectTypeApiName) {
|
|
523
|
+
referencedObjectDefs.add(enhancedOntology.requireObjectType(p.dataType.subType.objectTypeApiName));
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
if (p.dataType.subType.type === "interfaceObject") {
|
|
527
|
+
if (p.dataType.subType.interfaceTypeApiName) {
|
|
528
|
+
referencedObjectDefs.add(enhancedOntology.requireInterfaceType(p.dataType.subType.interfaceTypeApiName));
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
const imports = getObjectImports(referencedObjectDefs, undefined, currentFilePath, true);
|
|
534
|
+
await fs2.writeFile(path8__namespace.default.join(rootOutDir, currentFilePath), await formatTs(`
|
|
535
|
+
import type {
|
|
536
|
+
ActionDefinition,
|
|
537
|
+
ActionMetadata,
|
|
538
|
+
ActionParam,
|
|
539
|
+
ActionReturnTypeForOptions,
|
|
540
|
+
ApplyActionOptions,
|
|
541
|
+
ApplyBatchActionOptions,
|
|
542
|
+
} from "${forInternalUse ? "@osdk/api" : "@osdk/client"}";
|
|
543
|
+
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
544
|
+
${imports}
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
${createV2Types()}
|
|
548
|
+
|
|
549
|
+
${createV2Object()}
|
|
550
|
+
`));
|
|
551
|
+
}));
|
|
552
|
+
const indexFileRelPath = path8__namespace.default.join("ontology", "actions.ts");
|
|
553
|
+
await fs2.writeFile(path8__namespace.default.join(rootOutDir, indexFileRelPath), await formatTs(`
|
|
554
|
+
${Object.values(enhancedOntology.actionTypes).map((action) => {
|
|
555
|
+
const exportConstLine = `export {${action.shortApiName} } from "${action.getImportPathRelTo(indexFileRelPath)}";`;
|
|
556
|
+
return exportConstLine;
|
|
557
|
+
}).join("\n")}
|
|
558
|
+
${Object.keys(ontology.actionTypes).length === 0 ? "export {};" : ""}
|
|
559
|
+
`));
|
|
560
|
+
}
|
|
561
|
+
function extractReferencedObjectsFromAction(actionType) {
|
|
562
|
+
const referencedObjectsInParameters = Object.values(actionType.parameters).flatMap(({
|
|
563
|
+
dataType
|
|
564
|
+
}) => {
|
|
565
|
+
const objectTypeReference = extractReferencedObjectsFromActionParameter(dataType);
|
|
566
|
+
return objectTypeReference ? [objectTypeReference] : [];
|
|
567
|
+
});
|
|
568
|
+
const referenceObjectsInEdits = actionType.operations.flatMap((value) => {
|
|
569
|
+
switch (value.type) {
|
|
570
|
+
case "createObject":
|
|
571
|
+
return [value.objectTypeApiName];
|
|
572
|
+
case "modifyObject":
|
|
573
|
+
return [value.objectTypeApiName];
|
|
574
|
+
case "deleteObject":
|
|
575
|
+
case "createLink":
|
|
576
|
+
case "deleteLink":
|
|
577
|
+
default:
|
|
578
|
+
return [];
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
return [...referenceObjectsInEdits, ...referencedObjectsInParameters];
|
|
582
|
+
}
|
|
583
|
+
function extractReferencedObjectsFromActionParameter(actionParameter) {
|
|
584
|
+
switch (actionParameter.type) {
|
|
585
|
+
case "objectSet":
|
|
586
|
+
case "object":
|
|
587
|
+
return actionParameter.objectTypeApiName;
|
|
588
|
+
case "array":
|
|
589
|
+
return extractReferencedObjectsFromActionParameter(actionParameter.subType);
|
|
590
|
+
case "string":
|
|
591
|
+
case "boolean":
|
|
592
|
+
case "attachment":
|
|
593
|
+
case "date":
|
|
594
|
+
case "double":
|
|
595
|
+
case "integer":
|
|
596
|
+
case "long":
|
|
597
|
+
case "timestamp":
|
|
598
|
+
return undefined;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// src/shared/propertyJsdoc.ts
|
|
603
|
+
function propertyJsdoc(property, {
|
|
604
|
+
isInherited,
|
|
605
|
+
apiName
|
|
606
|
+
}) {
|
|
607
|
+
let ret = `/**
|
|
608
|
+
`;
|
|
609
|
+
const renderDisplayName = property.displayName && property.displayName !== apiName;
|
|
610
|
+
if (isInherited || renderDisplayName || property.description) {
|
|
611
|
+
if (isInherited) {
|
|
612
|
+
ret += ` * (inherited from parent)
|
|
613
|
+
`;
|
|
614
|
+
}
|
|
615
|
+
if (renderDisplayName) {
|
|
616
|
+
ret += ` * display name: '${property.displayName}'${property.description ? "," : ""}
|
|
617
|
+
`;
|
|
618
|
+
}
|
|
619
|
+
if (property.description) {
|
|
620
|
+
ret += ` * description: ${property.description}
|
|
621
|
+
`;
|
|
622
|
+
}
|
|
623
|
+
} else {
|
|
624
|
+
ret += ` * (no ontology metadata)
|
|
625
|
+
`;
|
|
626
|
+
}
|
|
627
|
+
ret += ` */
|
|
628
|
+
`;
|
|
629
|
+
return ret;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts
|
|
633
|
+
function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
634
|
+
ontology,
|
|
635
|
+
forInternalUse
|
|
636
|
+
}, currentFilePath) {
|
|
637
|
+
const object = ontology.requireObjectType(wireObject.objectType.apiName, true);
|
|
638
|
+
if (object instanceof ForeignType) {
|
|
639
|
+
throw new Error("Should not be generating types for an external type");
|
|
640
|
+
}
|
|
641
|
+
const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map((a) => ontology.requireObjectType(a.objectTypeApiName, false)));
|
|
642
|
+
const definition = deleteUndefineds(generatorConverters.wireObjectTypeFullMetadataToSdkObjectMetadata(object.raw, true));
|
|
643
|
+
const objectDefIdentifier = object.getDefinitionIdentifier(true);
|
|
644
|
+
const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;
|
|
645
|
+
const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;
|
|
646
|
+
const osdkObjectPropsIdentifier = `${object.shortApiName}.Props`;
|
|
647
|
+
const osdkObjectStrictPropsIdentifier = `${object.shortApiName}.StrictProps`;
|
|
648
|
+
const osdkObjectLinksIdentifier = `${object.shortApiName}.Links`;
|
|
649
|
+
const osdkObjectIdentifier = `${object.shortApiName}.OsdkObject`;
|
|
650
|
+
const identifiers = {
|
|
651
|
+
objectDefIdentifier: `${object.shortApiName}`,
|
|
652
|
+
osdkObjectLinksIdentifier,
|
|
653
|
+
osdkObjectPropsIdentifier,
|
|
654
|
+
osdkObjectStrictPropsIdentifier,
|
|
655
|
+
objectSetIdentifier,
|
|
656
|
+
osdkObjectIdentifier,
|
|
657
|
+
propertyKeysIdentifier
|
|
658
|
+
};
|
|
659
|
+
function getV2Types(object2, forInternalUse2 = false) {
|
|
660
|
+
return `import type {
|
|
661
|
+
PropertyKeys as $PropertyKeys,
|
|
662
|
+
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
663
|
+
ObjectMetadata as $ObjectMetadata,
|
|
664
|
+
} from "${forInternalUse2 ? "@osdk/api" : "@osdk/client"}";
|
|
665
|
+
import type {
|
|
666
|
+
ObjectSet as $ObjectSet,
|
|
667
|
+
Osdk as $Osdk,
|
|
668
|
+
OsdkObject as $OsdkObject,
|
|
669
|
+
PropertyValueWireToClient as $PropType,
|
|
670
|
+
SingleLinkAccessor as $SingleLinkAccessor,
|
|
671
|
+
} from "${forInternalUse2 ? "@osdk/api" : "@osdk/client"}";
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
export namespace ${object2.shortApiName} {
|
|
675
|
+
|
|
676
|
+
${createPropertyKeys(object2)}
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
${createLinks(ontology, object2, "Links")}
|
|
680
|
+
|
|
681
|
+
${createProps(object2, "Props", false)}
|
|
682
|
+
${createProps(object2, "StrictProps", true)}
|
|
683
|
+
|
|
684
|
+
${createObjectSet(object2, identifiers)}
|
|
685
|
+
|
|
686
|
+
${createOsdkObject(object2, "OsdkInstance", identifiers)}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
${createDefinition(object2, ontology, object2.shortApiName, identifiers)}
|
|
692
|
+
`;
|
|
693
|
+
}
|
|
694
|
+
const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);
|
|
695
|
+
return `${imports}${getV2Types(object, forInternalUse)}
|
|
696
|
+
|
|
697
|
+
export const ${object.shortApiName}: ${objectDefIdentifier}
|
|
698
|
+
= {
|
|
699
|
+
type: "${object instanceof EnhancedObjectType ? "object" : "interface"}",
|
|
700
|
+
apiName: "${object.fullApiName}",
|
|
701
|
+
osdkMetadata: $osdkMetadata,
|
|
702
|
+
};`;
|
|
703
|
+
}
|
|
704
|
+
function createOsdkObject(object, identifier, {
|
|
705
|
+
osdkObjectPropsIdentifier,
|
|
706
|
+
objectDefIdentifier,
|
|
707
|
+
osdkObjectStrictPropsIdentifier,
|
|
708
|
+
osdkObjectLinksIdentifier
|
|
709
|
+
}) {
|
|
710
|
+
object.getCleanedUpDefinition(true);
|
|
711
|
+
return `
|
|
712
|
+
export type ${identifier}<
|
|
713
|
+
OPTIONS extends never | "$rid" = never,
|
|
714
|
+
K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},
|
|
715
|
+
>
|
|
716
|
+
= $Osdk.Instance<
|
|
717
|
+
${objectDefIdentifier},
|
|
718
|
+
OPTIONS,
|
|
719
|
+
K
|
|
720
|
+
>;
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
/** @deprecated use ${identifier} */
|
|
724
|
+
export type OsdkObject<
|
|
725
|
+
OPTIONS extends never | "$rid" = never,
|
|
726
|
+
K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},
|
|
727
|
+
> = ${identifier}<OPTIONS, K>;
|
|
728
|
+
;
|
|
729
|
+
`;
|
|
730
|
+
}
|
|
731
|
+
function createObjectSet(object, {
|
|
732
|
+
objectDefIdentifier,
|
|
733
|
+
objectSetIdentifier,
|
|
734
|
+
propertyKeysIdentifier,
|
|
735
|
+
osdkObjectIdentifier
|
|
736
|
+
}) {
|
|
737
|
+
return `
|
|
738
|
+
export interface ObjectSet extends
|
|
739
|
+
$ObjectSet<${objectDefIdentifier},
|
|
740
|
+
|
|
741
|
+
${objectSetIdentifier}
|
|
742
|
+
>
|
|
743
|
+
{
|
|
744
|
+
|
|
745
|
+
}
|
|
746
|
+
`;
|
|
747
|
+
}
|
|
748
|
+
function maybeStripNamespace(type, q) {
|
|
749
|
+
if (type.apiNamespace && q.startsWith(`${type.apiNamespace}.`)) {
|
|
750
|
+
return q.slice(type.apiNamespace.length + 1);
|
|
751
|
+
} else {
|
|
752
|
+
return q;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
function createProps(type, identifier, strict) {
|
|
756
|
+
if (identifier === "StrictProps") {
|
|
757
|
+
return `export type StrictProps = Props`;
|
|
758
|
+
}
|
|
759
|
+
const definition = type.getCleanedUpDefinition(true);
|
|
760
|
+
return `export interface ${identifier} {
|
|
761
|
+
${stringify(definition.properties, {
|
|
762
|
+
"*": (propertyDefinition, _, apiName) => {
|
|
763
|
+
return [`readonly "${maybeStripNamespace(type, apiName)}"${// after we convert everything over we can do this:
|
|
764
|
+
// !strict || propertyDefinition.nullable ? "?" : ""
|
|
765
|
+
""}`, (typeof propertyDefinition.type === "object" ? `${remapStructType(propertyDefinition.type)}` : `$PropType[${JSON.stringify(propertyDefinition.type)}]`) + `${propertyDefinition.multiplicity ? "[]" : ""}${propertyDefinition.nullable || !strict && !(definition.type === "object" && definition.primaryKeyApiName === apiName) ? `| undefined` : ""}`];
|
|
766
|
+
}
|
|
767
|
+
})}
|
|
768
|
+
}`;
|
|
769
|
+
}
|
|
770
|
+
function createDefinition(object, ontology, identifier, {
|
|
771
|
+
objectDefIdentifier,
|
|
772
|
+
objectSetIdentifier,
|
|
773
|
+
osdkObjectPropsIdentifier,
|
|
774
|
+
osdkObjectStrictPropsIdentifier,
|
|
775
|
+
osdkObjectLinksIdentifier
|
|
776
|
+
}) {
|
|
777
|
+
const definition = object.getCleanedUpDefinition(true);
|
|
778
|
+
return `
|
|
779
|
+
export interface ${identifier} extends ${object instanceof EnhancedObjectType ? `$ObjectTypeDefinition` : `$InterfaceDefinition`} {
|
|
780
|
+
osdkMetadata: typeof $osdkMetadata;
|
|
781
|
+
type: "${object instanceof EnhancedObjectType ? "object" : "interface"}";
|
|
782
|
+
apiName: "${object.fullApiName}";
|
|
783
|
+
__DefinitionMetadata?: {
|
|
784
|
+
objectSet: ${objectSetIdentifier};
|
|
785
|
+
props: ${osdkObjectPropsIdentifier};
|
|
786
|
+
linksType: ${osdkObjectLinksIdentifier};
|
|
787
|
+
strictProps: ${osdkObjectStrictPropsIdentifier};
|
|
788
|
+
${stringify(definition, {
|
|
789
|
+
links: (_value) => `{
|
|
790
|
+
${stringify(definition.links, {
|
|
791
|
+
"*": (definition2) => `$ObjectMetadata.Link<${ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(true)}, ${definition2.multiplicity}>`
|
|
792
|
+
})}
|
|
793
|
+
}`,
|
|
794
|
+
properties: (_value) => `{
|
|
795
|
+
${stringify(definition.properties, {
|
|
796
|
+
"*": (propertyDefinition, _, apiName) => [`${propertyJsdoc(propertyDefinition, {
|
|
797
|
+
apiName
|
|
798
|
+
})}"${maybeStripNamespace(object, apiName)}"`, `$PropertyDef<${JSON.stringify(propertyDefinition.type)}, "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`]
|
|
799
|
+
})}
|
|
800
|
+
}`
|
|
801
|
+
})}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
`;
|
|
805
|
+
}
|
|
806
|
+
function createLinks(ontology, object, identifier) {
|
|
807
|
+
const definition = object.getCleanedUpDefinition(true);
|
|
808
|
+
return `
|
|
809
|
+
${Object.keys(definition.links).length === 0 ? `export type ${identifier} = {};` : `
|
|
810
|
+
export interface ${identifier} {
|
|
811
|
+
${stringify(definition.links, {
|
|
812
|
+
"*": (definition2, _, key) => {
|
|
813
|
+
const linkTarget = ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(true);
|
|
814
|
+
return [`readonly ${key}`, `${definition2.multiplicity ? `${linkTarget}.ObjectSet` : `$SingleLinkAccessor<${linkTarget}>`}
|
|
815
|
+
`];
|
|
816
|
+
}
|
|
817
|
+
})}
|
|
818
|
+
}
|
|
819
|
+
`}`;
|
|
820
|
+
}
|
|
821
|
+
function createPropertyKeys(type) {
|
|
822
|
+
const properties = Object.keys(type.getCleanedUpDefinition(true).properties);
|
|
823
|
+
return `export type PropertyKeys = ${properties.length === 0 ? "never" : properties.map((a) => maybeStripNamespace(type, a)).map((a) => `"${a}"`).join("|")};`;
|
|
824
|
+
}
|
|
825
|
+
function remapStructType(structType) {
|
|
826
|
+
let output = `{`;
|
|
827
|
+
Object.entries(structType).map(([key, value]) => output += `${key}:$PropType[${JSON.stringify(value)}]|undefined;`);
|
|
828
|
+
output += "}";
|
|
829
|
+
return output;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// src/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.ts
|
|
833
|
+
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false, forInternalUse = false) {
|
|
834
|
+
const definition = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef.raw, v2));
|
|
835
|
+
const objectDefIdentifier = interfaceDef.getDefinitionIdentifier(v2);
|
|
836
|
+
const parents = definition.implements?.map((p) => {
|
|
837
|
+
const parent = ontology.requireInterfaceType(p, true);
|
|
838
|
+
if (parent instanceof EnhancedInterfaceType) {
|
|
839
|
+
const it = deleteUndefineds(generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(parent.raw, v2));
|
|
840
|
+
return it;
|
|
841
|
+
}
|
|
842
|
+
}) ?? [];
|
|
843
|
+
const mergedProperties = {
|
|
844
|
+
...definition.properties
|
|
845
|
+
};
|
|
846
|
+
for (const parent of parents) {
|
|
847
|
+
if (parent == null) {
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
for (const apiName of Object.keys(parent.properties)) {
|
|
851
|
+
if (definition.properties[apiName] != null) {
|
|
852
|
+
!fastDeepEqual__default.default(definition.properties[apiName], parent.properties[apiName]) ? process.env.NODE_ENV !== "production" ? invariant__default.default(false, `Interface ${definition.apiName} redefines property '${apiName}' from parent '${parent.apiName}' but the properties do not match`) : invariant__default.default(false) : undefined;
|
|
853
|
+
} else if (mergedProperties[apiName] != null) {
|
|
854
|
+
!fastDeepEqual__default.default(mergedProperties[apiName], parent.properties[apiName]) ? process.env.NODE_ENV !== "production" ? invariant__default.default(false, `Some interface defines a conflicting property '${apiName}' that does not match property from parent '${parent.apiName}'`) : invariant__default.default(false) : undefined;
|
|
855
|
+
}
|
|
856
|
+
mergedProperties[apiName] = parent.properties[apiName];
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
definition.properties = mergedProperties;
|
|
860
|
+
const objectSetIdentifier = `${interfaceDef.shortApiName}.ObjectSet`;
|
|
861
|
+
const propertyKeysIdentifier = `${interfaceDef.shortApiName}.PropertyKeys`;
|
|
862
|
+
const osdkObjectPropsIdentifier = `${interfaceDef.shortApiName}.Props`;
|
|
863
|
+
const osdkObjectStrictPropsIdentifier = `${interfaceDef.shortApiName}.StrictProps`;
|
|
864
|
+
const osdkObjectLinksIdentifier = `OsdkObjectLinks$${objectDefIdentifier}`;
|
|
865
|
+
const osdkObjectIdentifier = `${interfaceDef.shortApiName}.OsdkObject`;
|
|
866
|
+
const ids = {
|
|
867
|
+
objectDefIdentifier: interfaceDef.shortApiName,
|
|
868
|
+
osdkObjectLinksIdentifier,
|
|
869
|
+
osdkObjectPropsIdentifier,
|
|
870
|
+
osdkObjectStrictPropsIdentifier,
|
|
871
|
+
objectSetIdentifier,
|
|
872
|
+
osdkObjectIdentifier,
|
|
873
|
+
propertyKeysIdentifier
|
|
874
|
+
};
|
|
875
|
+
if (interfaceDef.apiNamespace) {
|
|
876
|
+
const badProperties = Object.keys(definition.properties).filter((apiName) => extractNamespace(apiName)[0] == null);
|
|
877
|
+
if (badProperties.length > 0) {
|
|
878
|
+
throw new Error(`Interfaces with fully qualified api names MUST NOT have any properties with an unqualified api name. Interface: ${interfaceDef.fullApiName}, properties: ${badProperties.join(", ")}`);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
function getV2Types(forInternalUse2 = false) {
|
|
882
|
+
return `import type {
|
|
883
|
+
InterfaceDefinition as $InterfaceDefinition,
|
|
884
|
+
ObjectSet as $ObjectSet,
|
|
885
|
+
Osdk as $Osdk,
|
|
886
|
+
PropertyValueWireToClient as $PropType,
|
|
887
|
+
} from "${forInternalUse2 ? "@osdk/api" : "@osdk/client"}";
|
|
888
|
+
|
|
889
|
+
${Object.keys(definition.links).length === 0 ? `export type ${osdkObjectLinksIdentifier} = {};` : `
|
|
890
|
+
export interface ${osdkObjectLinksIdentifier} {
|
|
891
|
+
${stringify(definition.links, {
|
|
892
|
+
"*": (definition2) => {
|
|
893
|
+
const linkTarget = ontology.requireObjectType(definition2.targetType).getImportedDefinitionIdentifier(v2);
|
|
894
|
+
return `${definition2.multiplicity ? `${linkTarget}["objectSet"]` : `SingleLinkAccessor<${linkTarget}>`}
|
|
895
|
+
`;
|
|
896
|
+
}
|
|
897
|
+
})}
|
|
898
|
+
}
|
|
899
|
+
`}
|
|
900
|
+
|
|
901
|
+
export namespace ${interfaceDef.shortApiName} {
|
|
902
|
+
|
|
903
|
+
${createPropertyKeys(interfaceDef)}
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
${createProps(interfaceDef, "Props", false)}
|
|
907
|
+
${createProps(interfaceDef, "StrictProps", true)}
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
${createObjectSet(interfaceDef, ids)}
|
|
911
|
+
|
|
912
|
+
${createOsdkObject(interfaceDef, "OsdkInstance", ids)}
|
|
913
|
+
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
${createDefinition(interfaceDef, ontology, interfaceDef.shortApiName, ids)}
|
|
917
|
+
|
|
918
|
+
`;
|
|
919
|
+
}
|
|
920
|
+
const imports = [];
|
|
921
|
+
return `${imports.join("\n")}
|
|
922
|
+
${v2 ? getV2Types(forInternalUse) : ""}
|
|
923
|
+
|
|
924
|
+
export const ${interfaceDef.shortApiName}: ${interfaceDef.shortApiName} = {
|
|
925
|
+
type: "interface",
|
|
926
|
+
apiName: "${interfaceDef.fullApiName}",
|
|
927
|
+
osdkMetadata: $osdkMetadata,
|
|
928
|
+
};`;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
// src/v2.0/generatePerInterfaceDataFiles.ts
|
|
932
|
+
async function generatePerInterfaceDataFiles({
|
|
933
|
+
fs: fs2,
|
|
934
|
+
outDir,
|
|
935
|
+
ontology,
|
|
936
|
+
importExt,
|
|
937
|
+
forInternalUse
|
|
938
|
+
}) {
|
|
939
|
+
const interfacesDir = path8__namespace.default.join(outDir, "ontology", "interfaces");
|
|
940
|
+
await fs2.mkdir(interfacesDir, {
|
|
941
|
+
recursive: true
|
|
942
|
+
});
|
|
943
|
+
for (const obj of Object.values(ontology.interfaceTypes)) {
|
|
944
|
+
if (obj instanceof ForeignType) continue;
|
|
945
|
+
await fs2.writeFile(path8__namespace.default.join(interfacesDir, `${obj.shortApiName}.ts`), await formatTs(`
|
|
946
|
+
import type { PropertyDef as $PropertyDef } from "${forInternalUse ? "@osdk/api" : "@osdk/client"}";
|
|
947
|
+
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
|
|
948
|
+
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true, forInternalUse)}
|
|
949
|
+
`));
|
|
950
|
+
}
|
|
951
|
+
await fs2.writeFile(interfacesDir + ".ts", await formatTs(`
|
|
952
|
+
${Object.values(ontology.interfaceTypes).filter((i) => i instanceof EnhancedInterfaceType).map((interfaceType) => `export {${interfaceType.shortApiName}} from "./interfaces/${interfaceType.shortApiName}${importExt}";`).join("\n")}
|
|
953
|
+
${Object.keys(ontology.interfaceTypes).length === 0 ? "export {}" : ""}
|
|
954
|
+
`));
|
|
955
|
+
}
|
|
956
|
+
async function generatePerObjectDataFiles(ctx) {
|
|
957
|
+
const {
|
|
958
|
+
fs: fs2,
|
|
959
|
+
outDir,
|
|
960
|
+
ontology,
|
|
961
|
+
importExt
|
|
962
|
+
} = ctx;
|
|
963
|
+
await fs2.mkdir(path8__namespace.default.join(outDir, "ontology", "objects"), {
|
|
964
|
+
recursive: true
|
|
965
|
+
});
|
|
966
|
+
for (const obj of Object.values(ontology.objectTypes)) {
|
|
967
|
+
if (obj instanceof ForeignType) continue;
|
|
968
|
+
const relPath = path8__namespace.default.join(".", "ontology", `objects`, `${obj.shortApiName}.ts`);
|
|
969
|
+
const outFilePath = path8__namespace.default.join(outDir, relPath);
|
|
970
|
+
await fs2.writeFile(outFilePath, await formatTs(`
|
|
971
|
+
import type { PropertyDef as $PropertyDef } from "${ctx.forInternalUse ? "@osdk/api" : "@osdk/client"}";
|
|
972
|
+
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
|
|
973
|
+
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
974
|
+
${wireObjectTypeV2ToSdkObjectConstV2(obj.raw, ctx, relPath)}
|
|
975
|
+
`));
|
|
976
|
+
}
|
|
977
|
+
await fs2.writeFile(path8__namespace.default.join(outDir, "ontology", "objects.ts"), await formatTs(`
|
|
978
|
+
${Object.values(ctx.ontology.objectTypes).filter((o) => o instanceof EnhancedObjectType).map((objType) => `export {${objType.shortApiName}} from "./objects/${objType.shortApiName}${importExt}";`).join("\n")}
|
|
979
|
+
${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
|
|
980
|
+
`));
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// src/shared/getObjectTypesFromQueryDataType.ts
|
|
984
|
+
function getObjectTypesFromQueryDataType(dataType, types) {
|
|
985
|
+
switch (dataType.type) {
|
|
986
|
+
case "array":
|
|
987
|
+
case "set":
|
|
988
|
+
getObjectTypesFromQueryDataType(dataType.subType, types);
|
|
989
|
+
return;
|
|
990
|
+
case "object":
|
|
991
|
+
types.add(dataType.objectTypeApiName);
|
|
992
|
+
return;
|
|
993
|
+
case "objectSet":
|
|
994
|
+
types.add(dataType.objectTypeApiName);
|
|
995
|
+
return;
|
|
996
|
+
case "struct":
|
|
997
|
+
for (const prop of Object.values(dataType.fields)) {
|
|
998
|
+
getObjectTypesFromQueryDataType(prop.fieldType, types);
|
|
999
|
+
}
|
|
1000
|
+
return;
|
|
1001
|
+
case "union":
|
|
1002
|
+
for (const type of dataType.unionTypes) {
|
|
1003
|
+
getObjectTypesFromQueryDataType(type, types);
|
|
1004
|
+
}
|
|
1005
|
+
return;
|
|
1006
|
+
case "attachment":
|
|
1007
|
+
case "boolean":
|
|
1008
|
+
case "date":
|
|
1009
|
+
case "double":
|
|
1010
|
+
case "float":
|
|
1011
|
+
case "integer":
|
|
1012
|
+
case "long":
|
|
1013
|
+
case "null":
|
|
1014
|
+
case "string":
|
|
1015
|
+
case "threeDimensionalAggregation":
|
|
1016
|
+
case "timestamp":
|
|
1017
|
+
case "twoDimensionalAggregation":
|
|
1018
|
+
case "unsupported":
|
|
1019
|
+
return;
|
|
1020
|
+
default:
|
|
1021
|
+
throw new Error(`Cannot find object types from unsupported QueryDataType ${dataType.type}`);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// src/shared/getObjectTypeApiNamesFromQuery.ts
|
|
1026
|
+
function getObjectTypeApiNamesFromQuery(query) {
|
|
1027
|
+
const types = /* @__PURE__ */ new Set();
|
|
1028
|
+
for (const {
|
|
1029
|
+
dataType
|
|
1030
|
+
} of Object.values(query.parameters)) {
|
|
1031
|
+
getObjectTypesFromQueryDataType(dataType, types);
|
|
1032
|
+
}
|
|
1033
|
+
getObjectTypesFromQueryDataType(query.output, types);
|
|
1034
|
+
return Array.from(types);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
// src/v2.0/generatePerQueryDataFiles.ts
|
|
1038
|
+
async function generatePerQueryDataFilesV2({
|
|
1039
|
+
fs: fs2,
|
|
1040
|
+
outDir: rootOutDir,
|
|
1041
|
+
ontology,
|
|
1042
|
+
importExt = "",
|
|
1043
|
+
forInternalUse = false
|
|
1044
|
+
}, v2) {
|
|
1045
|
+
const relOutDir = path8__namespace.default.join(".", "ontology", "queries");
|
|
1046
|
+
const outDir = path8__namespace.default.join(rootOutDir, "ontology", "queries");
|
|
1047
|
+
await fs2.mkdir(outDir, {
|
|
1048
|
+
recursive: true
|
|
1049
|
+
});
|
|
1050
|
+
await Promise.all(Object.values(ontology.queryTypes).map(async (query) => {
|
|
1051
|
+
await generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ontology, forInternalUse);
|
|
1052
|
+
}));
|
|
1053
|
+
const indexFilePath = `${outDir}.ts`;
|
|
1054
|
+
await fs2.writeFile(indexFilePath, await formatTs(`
|
|
1055
|
+
${Object.values(ontology.queryTypes).map((query) => `export {${query.shortApiName}} from "${query.getImportPathRelTo(relOutDir)}";`).join("\n")}
|
|
1056
|
+
${Object.keys(ontology.queryTypes).length === 0 ? "export {};" : ""}
|
|
1057
|
+
`));
|
|
1058
|
+
}
|
|
1059
|
+
async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ontology, forInternalUse) {
|
|
1060
|
+
const relFilePath = path8__namespace.default.join(relOutDir, `${query.shortApiName}.ts`);
|
|
1061
|
+
const objectTypes = getObjectTypeApiNamesFromQuery(query);
|
|
1062
|
+
const objectTypeObjects = new Set(objectTypes.map((o) => ontology.requireObjectType(o)));
|
|
1063
|
+
const importObjects = getObjectImports(objectTypeObjects, "", relFilePath, true);
|
|
1064
|
+
const baseProps = deleteUndefineds(generatorConverters.wireQueryTypeV2ToSdkQueryDefinitionNoParams(query.raw));
|
|
1065
|
+
const outputBase = deleteUndefineds(generatorConverters.wireQueryDataTypeToQueryDataTypeDefinition(query.output));
|
|
1066
|
+
objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never";
|
|
1067
|
+
await fs2.writeFile(path8__namespace.default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
1068
|
+
import type { QueryDefinition , QueryParam, QueryResult, VersionBound} from "${forInternalUse ? "@osdk/api" : "@osdk/client"}";
|
|
1069
|
+
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1070
|
+
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
1071
|
+
${importObjects}
|
|
1072
|
+
|
|
1073
|
+
export namespace ${query.shortApiName} {
|
|
1074
|
+
export interface Signature {
|
|
1075
|
+
${getDescriptionIfPresent(query.description)}
|
|
1076
|
+
(${Object.keys(query.parameters).length > 0 ? `query: ${query.paramsIdentifier}` : ""}): Promise<${query.shortApiName}.ReturnType>
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
${Object.keys(query.parameters).length > 0 ? `
|
|
1080
|
+
export interface Parameters {
|
|
1081
|
+
${stringify(query.parameters, {
|
|
1082
|
+
"*": (parameter, formatter, apiName) => {
|
|
1083
|
+
const q = generatorConverters.wireQueryParameterV2ToQueryParameterDefinition(parameter);
|
|
1084
|
+
return [`
|
|
1085
|
+
${queryParamJsDoc(generatorConverters.wireQueryParameterV2ToQueryParameterDefinition(parameter), {
|
|
1086
|
+
apiName
|
|
1087
|
+
})}readonly "${apiName}"${q.nullable ? "?" : ""}`, `${getQueryParamType(ontology, q, "Param")}`];
|
|
1088
|
+
}
|
|
1089
|
+
})}
|
|
1090
|
+
}` : ""}
|
|
1091
|
+
|
|
1092
|
+
${query.output.type === "struct" ? `
|
|
1093
|
+
export interface ReturnType
|
|
1094
|
+
${getQueryParamType(ontology, generatorConverters.wireQueryParameterV2ToQueryParameterDefinition({
|
|
1095
|
+
dataType: query.output
|
|
1096
|
+
}), "Result")}
|
|
1097
|
+
` : `
|
|
1098
|
+
export type ReturnType = ${getQueryParamType(ontology, generatorConverters.wireQueryParameterV2ToQueryParameterDefinition({
|
|
1099
|
+
dataType: query.output
|
|
1100
|
+
}), "Result")}
|
|
1101
|
+
`}
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
|
|
1105
|
+
export interface ${query.shortApiName} extends QueryDefinition<
|
|
1106
|
+
${query.shortApiName}.Signature
|
|
1107
|
+
>, VersionBound<$ExpectedClientVersion>{
|
|
1108
|
+
__DefinitionMetadata?: {
|
|
1109
|
+
${stringify(baseProps)}
|
|
1110
|
+
parameters: {
|
|
1111
|
+
${parameterDefsForType(ontology, query)}
|
|
1112
|
+
};
|
|
1113
|
+
output: {
|
|
1114
|
+
${stringify(outputBase)},
|
|
1115
|
+
${getLineFor__OsdkTargetType(ontology, query.output)}
|
|
1116
|
+
};
|
|
1117
|
+
signature: ${query.shortApiName}.Signature;
|
|
1118
|
+
},
|
|
1119
|
+
${stringify(baseProps, {
|
|
1120
|
+
"description": () => undefined,
|
|
1121
|
+
"displayName": () => undefined,
|
|
1122
|
+
"rid": () => undefined
|
|
1123
|
+
})},
|
|
1124
|
+
osdkMetadata: typeof $osdkMetadata;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
export const ${query.shortApiName}: ${query.definitionIdentifier} = {
|
|
1129
|
+
${stringify(baseProps, {
|
|
1130
|
+
"description": () => undefined,
|
|
1131
|
+
"displayName": () => undefined,
|
|
1132
|
+
"rid": () => undefined
|
|
1133
|
+
})},
|
|
1134
|
+
osdkMetadata: $osdkMetadata
|
|
1135
|
+
};
|
|
1136
|
+
`));
|
|
1137
|
+
}
|
|
1138
|
+
function parameterDefsForType(ontology, query) {
|
|
1139
|
+
return stringify(query.parameters, {
|
|
1140
|
+
"*": (parameter, valueFormatter, apiName) => [`${queryParamJsDoc(generatorConverters.wireQueryParameterV2ToQueryParameterDefinition(parameter), {
|
|
1141
|
+
apiName
|
|
1142
|
+
})} ${apiName}`, ` {
|
|
1143
|
+
${stringify(deleteUndefineds(generatorConverters.wireQueryParameterV2ToQueryParameterDefinition(parameter)))},
|
|
1144
|
+
${getLineFor__OsdkTargetType(ontology, parameter.dataType)}
|
|
1145
|
+
}`]
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
function getLineFor__OsdkTargetType(ontology, qdt) {
|
|
1149
|
+
if (qdt.type === "object" || qdt.type === "objectSet") {
|
|
1150
|
+
return `__OsdkTargetType?: ${ontology.requireObjectType(qdt.objectTypeApiName).getImportedDefinitionIdentifier(true)}`;
|
|
1151
|
+
}
|
|
1152
|
+
return "";
|
|
1153
|
+
}
|
|
1154
|
+
function queryParamJsDoc(param, {
|
|
1155
|
+
apiName
|
|
1156
|
+
}) {
|
|
1157
|
+
let ret = `/**
|
|
1158
|
+
`;
|
|
1159
|
+
if (param.description) {
|
|
1160
|
+
if (param.description) {
|
|
1161
|
+
ret += ` * description: ${param.description}
|
|
1162
|
+
`;
|
|
1163
|
+
}
|
|
1164
|
+
} else {
|
|
1165
|
+
ret += ` * (no ontology metadata)
|
|
1166
|
+
`;
|
|
1167
|
+
}
|
|
1168
|
+
ret += ` */
|
|
1169
|
+
`;
|
|
1170
|
+
return ret;
|
|
1171
|
+
}
|
|
1172
|
+
function getQueryParamType(enhancedOntology, input, type) {
|
|
1173
|
+
let inner = `unknown /* ${input.type} */`;
|
|
1174
|
+
switch (input.type) {
|
|
1175
|
+
case "date":
|
|
1176
|
+
inner = `Query${type}.PrimitiveType<${JSON.stringify("datetime")}>`;
|
|
1177
|
+
break;
|
|
1178
|
+
case "attachment":
|
|
1179
|
+
case "boolean":
|
|
1180
|
+
case "double":
|
|
1181
|
+
case "float":
|
|
1182
|
+
case "integer":
|
|
1183
|
+
case "long":
|
|
1184
|
+
case "string":
|
|
1185
|
+
case "threeDimensionalAggregation":
|
|
1186
|
+
case "timestamp":
|
|
1187
|
+
case "twoDimensionalAggregation":
|
|
1188
|
+
inner = `Query${type}.PrimitiveType<${JSON.stringify(input.type)}>`;
|
|
1189
|
+
break;
|
|
1190
|
+
case "struct":
|
|
1191
|
+
inner = `{
|
|
1192
|
+
${stringify(input.struct, {
|
|
1193
|
+
"*": (p, formatter, apiName) => {
|
|
1194
|
+
return [`
|
|
1195
|
+
${type === "Param" ? "readonly " : ""}"${apiName}"${p.nullable ? "?" : ""}`, `${getQueryParamType(enhancedOntology, p, type)}`];
|
|
1196
|
+
}
|
|
1197
|
+
})}
|
|
1198
|
+
}`;
|
|
1199
|
+
break;
|
|
1200
|
+
case "object":
|
|
1201
|
+
inner = `Query${type}.ObjectType<${enhancedOntology.requireObjectType(input.object).getImportedDefinitionIdentifier(true)}>`;
|
|
1202
|
+
break;
|
|
1203
|
+
case "objectSet":
|
|
1204
|
+
inner = `Query${type}.ObjectSetType<${enhancedOntology.requireObjectType(input.objectSet).getImportedDefinitionIdentifier(true)}>`;
|
|
1205
|
+
break;
|
|
1206
|
+
case "set":
|
|
1207
|
+
inner = `${type === "Param" ? "Readonly" : ""}Set<${getQueryParamType(enhancedOntology, input.set, type)}>`;
|
|
1208
|
+
break;
|
|
1209
|
+
case "union":
|
|
1210
|
+
inner = input.union.map((u) => getQueryParamType(enhancedOntology, u, type)).join(" | ");
|
|
1211
|
+
break;
|
|
1212
|
+
}
|
|
1213
|
+
if (input.multiplicity && type === "Param") {
|
|
1214
|
+
return `ReadonlyArray<${inner}>`;
|
|
1215
|
+
} else if (input.multiplicity) {
|
|
1216
|
+
return `Array<${inner}>`;
|
|
1217
|
+
}
|
|
1218
|
+
return inner;
|
|
1219
|
+
}
|
|
1220
|
+
async function generateRootIndexTsFile({
|
|
1221
|
+
fs: fs2,
|
|
1222
|
+
outDir,
|
|
1223
|
+
importExt,
|
|
1224
|
+
ontologyApiNamespace,
|
|
1225
|
+
ontology
|
|
1226
|
+
}) {
|
|
1227
|
+
await fs2.writeFile(path8__namespace.default.join(outDir, "index.ts"), await formatTs(`export {${helper(ontology.actionTypes)}} from "./ontology/actions${importExt}";
|
|
1228
|
+
export * as $Actions from "./ontology/actions${importExt}";
|
|
1229
|
+
export {${helper(ontology.interfaceTypes)}} from "./ontology/interfaces${importExt}";
|
|
1230
|
+
export * as $Interfaces from "./ontology/interfaces${importExt}";
|
|
1231
|
+
export {${helper(ontology.objectTypes)}} from "./ontology/objects${importExt}";
|
|
1232
|
+
export * as $Objects from "./ontology/objects${importExt}";
|
|
1233
|
+
export {${helper(ontology.queryTypes)}} from "./ontology/queries${importExt}";
|
|
1234
|
+
export * as $Queries from "./ontology/queries${importExt}";
|
|
1235
|
+
export { $osdkMetadata } from "./OntologyMetadata${importExt}";
|
|
1236
|
+
${ontologyApiNamespace == null ? `export { $ontologyRid } from "./OntologyMetadata${importExt}";` : ``}
|
|
1237
|
+
`));
|
|
1238
|
+
}
|
|
1239
|
+
function helper(x) {
|
|
1240
|
+
return Object.values(x).filter((x2) => !(x2 instanceof ForeignType)).map((a) => a.shortApiName).join(", ");
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
// src/v2.0/generateClientSdkVersionTwoPointZero.ts
|
|
1244
|
+
async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, outDir, packageType = "commonjs", externalObjects = /* @__PURE__ */ new Map(), externalInterfaces = /* @__PURE__ */ new Map(), externalSpts = /* @__PURE__ */ new Map(), forInternalUse = false) {
|
|
1245
|
+
const importExt = ".js";
|
|
1246
|
+
await verifyOutDir(outDir, fs2);
|
|
1247
|
+
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
1248
|
+
await fs2.mkdir(outDir, {
|
|
1249
|
+
recursive: true
|
|
1250
|
+
});
|
|
1251
|
+
const enhancedOntology = enhanceOntology({
|
|
1252
|
+
sanitized: sanitizedOntology,
|
|
1253
|
+
importExt,
|
|
1254
|
+
externalObjects,
|
|
1255
|
+
externalInterfaces,
|
|
1256
|
+
externalSpts
|
|
1257
|
+
});
|
|
1258
|
+
const ctx = {
|
|
1259
|
+
sanitizedOntology,
|
|
1260
|
+
ontology: enhancedOntology,
|
|
1261
|
+
importExt,
|
|
1262
|
+
fs: fs2,
|
|
1263
|
+
outDir,
|
|
1264
|
+
forInternalUse
|
|
1265
|
+
};
|
|
1266
|
+
await generateRootIndexTsFile(ctx);
|
|
1267
|
+
await generateOntologyMetadataFile(ctx, userAgent);
|
|
1268
|
+
await generatePerObjectDataFiles(ctx);
|
|
1269
|
+
await generatePerInterfaceDataFiles(ctx);
|
|
1270
|
+
await generatePerActionDataFiles(ctx);
|
|
1271
|
+
await generatePerQueryDataFilesV2(ctx);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
// src/generateClientSdkPackage.ts
|
|
1275
|
+
async function generateClientSdkPackage(packageName, packageVersion, sdkVersion, baseOutDir, ontology, minimalFs, dependencyVersions, cliVersion, externalObjects = /* @__PURE__ */ new Map(), externalInterfaces = /* @__PURE__ */ new Map()) {
|
|
1276
|
+
if (!packageName) throw new Error("Package name is required");
|
|
1277
|
+
if (sdkVersion === "1.1") {
|
|
1278
|
+
throw new Error("This generator version does not support generating v1 sdks");
|
|
1279
|
+
}
|
|
1280
|
+
for (const packageType of ["module", "commonjs"]) {
|
|
1281
|
+
const outDir = path8__namespace.join(baseOutDir, "dist", packageType);
|
|
1282
|
+
await generateClientSdkVersionTwoPointZero(ontology, `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`, minimalFs, outDir, packageType, externalObjects, externalInterfaces);
|
|
1283
|
+
await fs__namespace.promises.mkdir(outDir, {
|
|
1284
|
+
recursive: true
|
|
1285
|
+
});
|
|
1286
|
+
await writeJson(minimalFs, path8__namespace.join(outDir, "package.json"), {
|
|
1287
|
+
type: packageType
|
|
1288
|
+
});
|
|
1289
|
+
await writeJson(minimalFs, path8__namespace.join(outDir, `tsconfig.json`), {
|
|
1290
|
+
compilerOptions: getTsCompilerOptions(packageType)
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
await writeJson(minimalFs, path8__namespace.join(baseOutDir, "package.json"), getPackageJsonContents(packageName, packageVersion, dependencyVersions));
|
|
1294
|
+
await minimalFs.mkdir(path8__namespace.join(baseOutDir, "ontology"), {
|
|
1295
|
+
recursive: true
|
|
1296
|
+
});
|
|
1297
|
+
await minimalFs.writeFile(path8__namespace.join(baseOutDir, "ontology", "objects.js"), `module.exports = require("../../dist/module/ontology/objects")`);
|
|
1298
|
+
await minimalFs.writeFile(path8__namespace.join(baseOutDir, "ontology", "objects.d.ts"), `export * from "../dist/module/ontology/objects"`);
|
|
1299
|
+
}
|
|
1300
|
+
function getTsCompilerOptions(packageType) {
|
|
1301
|
+
const commonTsconfig = {
|
|
1302
|
+
importHelpers: true,
|
|
1303
|
+
declaration: true,
|
|
1304
|
+
isolatedModules: true,
|
|
1305
|
+
esModuleInterop: true,
|
|
1306
|
+
forceConsistentCasingInFileNames: true,
|
|
1307
|
+
strict: true,
|
|
1308
|
+
skipLibCheck: true
|
|
1309
|
+
};
|
|
1310
|
+
const compilerOptions = packageType === "commonjs" ? {
|
|
1311
|
+
...commonTsconfig,
|
|
1312
|
+
module: "commonjs",
|
|
1313
|
+
target: "es2018"
|
|
1314
|
+
} : {
|
|
1315
|
+
...commonTsconfig,
|
|
1316
|
+
module: "NodeNext",
|
|
1317
|
+
target: "ES2020"
|
|
1318
|
+
};
|
|
1319
|
+
return compilerOptions;
|
|
1320
|
+
}
|
|
1321
|
+
function getExpectedDependencies({
|
|
1322
|
+
osdkApiVersion,
|
|
1323
|
+
osdkClientVersion
|
|
1324
|
+
}) {
|
|
1325
|
+
return {
|
|
1326
|
+
devDependencies: {
|
|
1327
|
+
"@osdk/api": osdkApiVersion
|
|
1328
|
+
},
|
|
1329
|
+
peerDependencies: {
|
|
1330
|
+
"@osdk/api": osdkApiVersion,
|
|
1331
|
+
"@osdk/client": osdkClientVersion
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
function getExpectedDependenciesFull(dependencyVersions) {
|
|
1336
|
+
const {
|
|
1337
|
+
typescriptVersion,
|
|
1338
|
+
tslibVersion,
|
|
1339
|
+
areTheTypesWrongVersion
|
|
1340
|
+
} = dependencyVersions;
|
|
1341
|
+
const base = getExpectedDependencies(dependencyVersions);
|
|
1342
|
+
return {
|
|
1343
|
+
devDependencies: {
|
|
1344
|
+
...base.devDependencies,
|
|
1345
|
+
"typescript": typescriptVersion,
|
|
1346
|
+
"tslib": tslibVersion,
|
|
1347
|
+
"@arethetypeswrong/cli": areTheTypesWrongVersion
|
|
1348
|
+
},
|
|
1349
|
+
peerDependencies: {
|
|
1350
|
+
...base.peerDependencies
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
function getPackageJsonContents(name, version, dependencyVersions) {
|
|
1355
|
+
const esmPrefix = "./dist/module";
|
|
1356
|
+
const commonjsPrefix = "./dist/commonjs";
|
|
1357
|
+
return {
|
|
1358
|
+
name,
|
|
1359
|
+
version,
|
|
1360
|
+
main: `${commonjsPrefix}/index.js`,
|
|
1361
|
+
module: `${esmPrefix}/index.js`,
|
|
1362
|
+
exports: {
|
|
1363
|
+
".": {
|
|
1364
|
+
import: `${esmPrefix}/index.js`,
|
|
1365
|
+
require: `${commonjsPrefix}/index.js`
|
|
1366
|
+
}
|
|
1367
|
+
},
|
|
1368
|
+
scripts: {
|
|
1369
|
+
prepack: `tsc -p ${esmPrefix}/tsconfig.json && tsc -p ${commonjsPrefix}/tsconfig.json`,
|
|
1370
|
+
check: "npm exec attw $(npm pack)"
|
|
1371
|
+
},
|
|
1372
|
+
...getExpectedDependenciesFull(dependencyVersions),
|
|
1373
|
+
files: ["**/*.js", "**/*.d.ts", "dist/**/package.json"]
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
async function writeJson(minimalFs, filePath, body) {
|
|
1377
|
+
return void await minimalFs.writeFile(filePath, JSON.stringify(body, undefined, 2) + "\n");
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
exports.__UNSTABLE_generateClientSdkPackage = generateClientSdkPackage;
|
|
1381
|
+
exports.generateClientSdkVersionTwoPointZero = generateClientSdkVersionTwoPointZero;
|
|
1382
|
+
exports.getExpectedDependencies = getExpectedDependencies;
|
|
1383
|
+
//# sourceMappingURL=index.cjs.map
|
|
1384
|
+
//# sourceMappingURL=index.cjs.map
|