@azure-tools/typespec-ts 0.54.0-dev.6 → 0.54.0-dev.8
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/dist/src/contextManager.d.ts +5 -5
- package/dist/src/contextManager.d.ts.map +1 -1
- package/dist/src/contextManager.js.map +1 -1
- package/dist/src/framework/declaration.d.ts +1 -1
- package/dist/src/framework/declaration.d.ts.map +1 -1
- package/dist/src/framework/declaration.js +2 -4
- package/dist/src/framework/declaration.js.map +1 -1
- package/dist/src/framework/dependency.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.d.ts +1 -1
- package/dist/src/framework/hooks/binder.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.js +12 -20
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/sdkTypes.d.ts +1 -1
- package/dist/src/framework/hooks/sdkTypes.d.ts.map +1 -1
- package/dist/src/framework/hooks/sdkTypes.js +8 -11
- package/dist/src/framework/hooks/sdkTypes.js.map +1 -1
- package/dist/src/framework/hooks/useDependencies.d.ts.map +1 -1
- package/dist/src/framework/hooks/useDependencies.js +1 -1
- package/dist/src/framework/hooks/useDependencies.js.map +1 -1
- package/dist/src/framework/load-static-helpers.d.ts +1 -1
- package/dist/src/framework/load-static-helpers.d.ts.map +1 -1
- package/dist/src/framework/load-static-helpers.js +12 -25
- package/dist/src/framework/load-static-helpers.js.map +1 -1
- package/dist/src/framework/reference.d.ts.map +1 -1
- package/dist/src/framework/reference.js +1 -1
- package/dist/src/framework/reference.js.map +1 -1
- package/dist/src/framework/sample.js +8 -8
- package/dist/src/framework/sample.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +70 -48
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +1 -1
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +140 -140
- package/dist/src/lib.js.map +1 -1
- package/dist/src/metaTree.d.ts +1 -1
- package/dist/src/metaTree.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +49 -62
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.d.ts +2 -2
- package/dist/src/modular/buildClassicalOperationGroups.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js +4 -7
- package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
- package/dist/src/modular/buildClientContext.d.ts +2 -2
- package/dist/src/modular/buildClientContext.d.ts.map +1 -1
- package/dist/src/modular/buildClientContext.js +30 -36
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildModularOptions.d.ts +1 -1
- package/dist/src/modular/buildModularOptions.d.ts.map +1 -1
- package/dist/src/modular/buildModularOptions.js +2 -2
- package/dist/src/modular/buildModularOptions.js.map +1 -1
- package/dist/src/modular/buildOperations.d.ts +3 -3
- package/dist/src/modular/buildOperations.d.ts.map +1 -1
- package/dist/src/modular/buildOperations.js +22 -23
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildProjectFiles.d.ts +1 -1
- package/dist/src/modular/buildProjectFiles.d.ts.map +1 -1
- package/dist/src/modular/buildProjectFiles.js +7 -9
- package/dist/src/modular/buildProjectFiles.js.map +1 -1
- package/dist/src/modular/buildRestorePoller.d.ts +1 -1
- package/dist/src/modular/buildRestorePoller.d.ts.map +1 -1
- package/dist/src/modular/buildRestorePoller.js +11 -11
- package/dist/src/modular/buildRestorePoller.js.map +1 -1
- package/dist/src/modular/buildRootIndex.d.ts +2 -2
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
- package/dist/src/modular/buildRootIndex.js +30 -39
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/buildSubpathIndex.d.ts.map +1 -1
- package/dist/src/modular/buildSubpathIndex.js +9 -17
- package/dist/src/modular/buildSubpathIndex.js.map +1 -1
- package/dist/src/modular/emitLoggerFile.d.ts.map +1 -1
- package/dist/src/modular/emitLoggerFile.js +2 -2
- package/dist/src/modular/emitLoggerFile.js.map +1 -1
- package/dist/src/modular/emitModels.d.ts +1 -1
- package/dist/src/modular/emitModels.d.ts.map +1 -1
- package/dist/src/modular/emitModels.js +54 -72
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/emitModelsOptions.d.ts +1 -1
- package/dist/src/modular/emitModelsOptions.d.ts.map +1 -1
- package/dist/src/modular/emitModelsOptions.js +6 -7
- package/dist/src/modular/emitModelsOptions.js.map +1 -1
- package/dist/src/modular/emitSamples.d.ts.map +1 -1
- package/dist/src/modular/emitSamples.js +40 -52
- package/dist/src/modular/emitSamples.js.map +1 -1
- package/dist/src/modular/emitTests.d.ts.map +1 -1
- package/dist/src/modular/emitTests.js +9 -12
- package/dist/src/modular/emitTests.js.map +1 -1
- package/dist/src/modular/external-dependencies.js +54 -54
- package/dist/src/modular/helpers/classicalOperationHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.js +27 -36
- package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.d.ts +2 -2
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +20 -38
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.js.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.d.ts +2 -2
- package/dist/src/modular/helpers/exampleValueHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.js +39 -58
- package/dist/src/modular/helpers/exampleValueHelpers.js.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.js +4 -5
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +2 -2
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +136 -196
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +1 -1
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.d.ts +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.js +50 -56
- package/dist/src/modular/serialization/buildDeserializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.d.ts +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js +52 -59
- package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.d.ts +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js +43 -51
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/serializeUtils.d.ts.map +1 -1
- package/dist/src/modular/serialization/serializeUtils.js +4 -11
- package/dist/src/modular/serialization/serializeUtils.js.map +1 -1
- package/dist/src/modular/static-helpers-metadata.js +60 -60
- package/dist/src/modular/type-expressions/get-credential-expression.js +1 -1
- package/dist/src/modular/type-expressions/get-credential-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.d.ts +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.js +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-model-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-model-expression.js +7 -9
- package/dist/src/modular/type-expressions/get-model-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.d.ts +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.js +4 -8
- package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-union-expression.d.ts +1 -1
- package/dist/src/modular/type-expressions/get-union-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-union-expression.js.map +1 -1
- package/dist/src/rlc-common/buildClient.d.ts +1 -1
- package/dist/src/rlc-common/buildClient.d.ts.map +1 -1
- package/dist/src/rlc-common/buildClient.js +48 -66
- package/dist/src/rlc-common/buildClient.js.map +1 -1
- package/dist/src/rlc-common/buildClientDefinitions.d.ts.map +1 -1
- package/dist/src/rlc-common/buildClientDefinitions.js +24 -42
- package/dist/src/rlc-common/buildClientDefinitions.js.map +1 -1
- package/dist/src/rlc-common/buildIndexFile.d.ts.map +1 -1
- package/dist/src/rlc-common/buildIndexFile.js +57 -57
- package/dist/src/rlc-common/buildIndexFile.js.map +1 -1
- package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js +32 -35
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +1 -1
- package/dist/src/rlc-common/buildLogger.d.ts.map +1 -1
- package/dist/src/rlc-common/buildLogger.js +3 -3
- package/dist/src/rlc-common/buildLogger.js.map +1 -1
- package/dist/src/rlc-common/buildMethodShortcuts.d.ts.map +1 -1
- package/dist/src/rlc-common/buildMethodShortcuts.js +3 -3
- package/dist/src/rlc-common/buildMethodShortcuts.js.map +1 -1
- package/dist/src/rlc-common/buildObjectTypes.d.ts.map +1 -1
- package/dist/src/rlc-common/buildObjectTypes.js +31 -48
- package/dist/src/rlc-common/buildObjectTypes.js.map +1 -1
- package/dist/src/rlc-common/buildPaginateHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildPaginateHelper.js +2 -2
- package/dist/src/rlc-common/buildPaginateHelper.js.map +1 -1
- package/dist/src/rlc-common/buildParameterTypes.d.ts.map +1 -1
- package/dist/src/rlc-common/buildParameterTypes.js +63 -50
- package/dist/src/rlc-common/buildParameterTypes.js.map +1 -1
- package/dist/src/rlc-common/buildPollingHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildPollingHelper.js +5 -5
- package/dist/src/rlc-common/buildPollingHelper.js.map +1 -1
- package/dist/src/rlc-common/buildResponseTypes.d.ts.map +1 -1
- package/dist/src/rlc-common/buildResponseTypes.js +19 -22
- package/dist/src/rlc-common/buildResponseTypes.js.map +1 -1
- package/dist/src/rlc-common/buildSamples.d.ts +1 -1
- package/dist/src/rlc-common/buildSamples.d.ts.map +1 -1
- package/dist/src/rlc-common/buildSamples.js +2 -2
- package/dist/src/rlc-common/buildSchemaType.d.ts.map +1 -1
- package/dist/src/rlc-common/buildSchemaType.js +31 -13
- package/dist/src/rlc-common/buildSchemaType.js.map +1 -1
- package/dist/src/rlc-common/buildSerializeHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildSerializeHelper.js +4 -4
- package/dist/src/rlc-common/buildSerializeHelper.js.map +1 -1
- package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts.map +1 -1
- package/dist/src/rlc-common/buildTopLevelIndexFile.js +9 -13
- package/dist/src/rlc-common/buildTopLevelIndexFile.js.map +1 -1
- package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/apiVersionUtil.js +2 -3
- package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/importsUtil.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/importsUtil.js +23 -25
- package/dist/src/rlc-common/helpers/importsUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/nameConstructors.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/nameConstructors.js.map +1 -1
- package/dist/src/rlc-common/helpers/nameUtils.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/nameUtils.js +8 -13
- package/dist/src/rlc-common/helpers/nameUtils.js.map +1 -1
- package/dist/src/rlc-common/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/operationHelpers.js +8 -12
- package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/pathUtils.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/pathUtils.js +1 -3
- package/dist/src/rlc-common/helpers/pathUtils.js.map +1 -1
- package/dist/src/rlc-common/helpers/schemaHelpers.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/schemaHelpers.js +1 -1
- package/dist/src/rlc-common/helpers/schemaHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/shortcutMethods.d.ts +1 -1
- package/dist/src/rlc-common/helpers/shortcutMethods.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/shortcutMethods.js +2 -2
- package/dist/src/rlc-common/helpers/shortcutMethods.js.map +1 -1
- package/dist/src/rlc-common/helpers/typeUtil.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/typeUtil.js +1 -2
- package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js +3 -4
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +1 -1
- package/dist/src/rlc-common/index.d.ts +28 -28
- package/dist/src/rlc-common/index.d.ts.map +1 -1
- package/dist/src/rlc-common/index.js +28 -28
- package/dist/src/rlc-common/index.js.map +1 -1
- package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
- package/dist/src/rlc-common/interfaces.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +13 -13
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildChangelogFile.js +1 -1
- package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildESLintConfig.js +3 -5
- package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildLicenseFile.js +1 -1
- package/dist/src/rlc-common/metadata/buildPackageFile.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildPackageFile.js +16 -16
- package/dist/src/rlc-common/metadata/buildPackageFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildReadmeFile.js +10 -18
- package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildRollupConfig.js +3 -4
- package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +2 -3
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTestConfig.js +8 -8
- package/dist/src/rlc-common/metadata/buildTsConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildTsConfig.js +23 -21
- package/dist/src/rlc-common/metadata/buildTsConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildVitestConfig.js +3 -4
- package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildWarpConfig.js +2 -2
- package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +13 -13
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +22 -26
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js +15 -16
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js +8 -8
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +26 -29
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -1
- package/dist/src/rlc-common/test/buildKarmaConfig.js +1 -1
- package/dist/src/rlc-common/test/buildRecordedClient.js +3 -3
- package/dist/src/rlc-common/test/buildSampleTest.d.ts.map +1 -1
- package/dist/src/rlc-common/test/buildSampleTest.js +2 -2
- package/dist/src/rlc-common/test/buildSampleTest.js.map +1 -1
- package/dist/src/rlc-common/test/buildSnippets.d.ts.map +1 -1
- package/dist/src/rlc-common/test/buildSnippets.js +4 -6
- package/dist/src/rlc-common/test/buildSnippets.js.map +1 -1
- package/dist/src/rlc-common/transformSampleGroups.d.ts.map +1 -1
- package/dist/src/rlc-common/transformSampleGroups.js +19 -23
- package/dist/src/rlc-common/transformSampleGroups.js.map +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +1 -1
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/transform/transform.d.ts +1 -1
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/transform/transform.js +10 -11
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +8 -10
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js +9 -11
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
- package/dist/src/transform/transformParameters.d.ts +2 -2
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +22 -28
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.d.ts +1 -1
- package/dist/src/transform/transformPaths.d.ts.map +1 -1
- package/dist/src/transform/transformPaths.js +11 -12
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.d.ts +1 -1
- package/dist/src/transform/transformResponses.d.ts.map +1 -1
- package/dist/src/transform/transformResponses.js +12 -12
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.d.ts.map +1 -1
- package/dist/src/transform/transformSchemas.js +9 -15
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/src/transform/transformTelemetryInfo.d.ts +1 -1
- package/dist/src/transform/transformTelemetryInfo.d.ts.map +1 -1
- package/dist/src/transform/transformTelemetryInfo.js +3 -3
- package/dist/src/transform/transformTelemetryInfo.js.map +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +14 -26
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/clientUtils.d.ts +1 -1
- package/dist/src/utils/clientUtils.d.ts.map +1 -1
- package/dist/src/utils/clientUtils.js +11 -14
- package/dist/src/utils/clientUtils.js.map +1 -1
- package/dist/src/utils/credentialUtils.d.ts +1 -1
- package/dist/src/utils/credentialUtils.d.ts.map +1 -1
- package/dist/src/utils/credentialUtils.js +3 -3
- package/dist/src/utils/credentialUtils.js.map +1 -1
- package/dist/src/utils/crossLanguageDef.d.ts.map +1 -1
- package/dist/src/utils/crossLanguageDef.js +8 -12
- package/dist/src/utils/crossLanguageDef.js.map +1 -1
- package/dist/src/utils/emitUtil.d.ts +1 -1
- package/dist/src/utils/emitUtil.d.ts.map +1 -1
- package/dist/src/utils/emitUtil.js +4 -6
- package/dist/src/utils/emitUtil.js.map +1 -1
- package/dist/src/utils/fileSystemUtils.d.ts.map +1 -1
- package/dist/src/utils/fileSystemUtils.js +2 -2
- package/dist/src/utils/fileSystemUtils.js.map +1 -1
- package/dist/src/utils/importHelper.d.ts.map +1 -1
- package/dist/src/utils/importHelper.js +2 -4
- package/dist/src/utils/importHelper.js.map +1 -1
- package/dist/src/utils/interfaces.d.ts +1 -1
- package/dist/src/utils/interfaces.d.ts.map +1 -1
- package/dist/src/utils/mediaTypes.d.ts.map +1 -1
- package/dist/src/utils/mediaTypes.js +7 -19
- package/dist/src/utils/mediaTypes.js.map +1 -1
- package/dist/src/utils/modelUtils.d.ts +5 -5
- package/dist/src/utils/modelUtils.d.ts.map +1 -1
- package/dist/src/utils/modelUtils.js +108 -171
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/namespaceUtils.d.ts.map +1 -1
- package/dist/src/utils/namespaceUtils.js +2 -2
- package/dist/src/utils/namespaceUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.d.ts +1 -1
- package/dist/src/utils/operationUtil.d.ts.map +1 -1
- package/dist/src/utils/operationUtil.js +29 -42
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/src/utils/parameterUtils.d.ts +1 -1
- package/dist/src/utils/parameterUtils.d.ts.map +1 -1
- package/dist/src/utils/parameterUtils.js +19 -22
- package/dist/src/utils/parameterUtils.js.map +1 -1
- package/dist/src/utils/resolve-project-root.js +2 -2
- package/dist/src/utils/resolve-project-root.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -3
- package/src/contextManager.ts +6 -9
- package/src/framework/declaration.ts +18 -28
- package/src/framework/dependency.ts +1 -2
- package/src/framework/hooks/binder.ts +47 -120
- package/src/framework/hooks/sdkTypes.ts +27 -54
- package/src/framework/hooks/useDependencies.ts +2 -4
- package/src/framework/load-static-helpers.ts +28 -51
- package/src/framework/reference.ts +2 -5
- package/src/framework/sample.ts +9 -9
- package/src/index.ts +139 -180
- package/src/lib.ts +143 -158
- package/src/metaTree.ts +1 -1
- package/src/modular/buildClassicalClient.ts +83 -160
- package/src/modular/buildClassicalOperationGroups.ts +14 -39
- package/src/modular/buildClientContext.ts +54 -83
- package/src/modular/buildModularOptions.ts +4 -5
- package/src/modular/buildOperations.ts +46 -73
- package/src/modular/buildProjectFiles.ts +18 -47
- package/src/modular/buildRestorePoller.ts +27 -46
- package/src/modular/buildRootIndex.ts +86 -159
- package/src/modular/buildSubpathIndex.ts +35 -58
- package/src/modular/emitLoggerFile.ts +4 -9
- package/src/modular/emitModels.ts +136 -266
- package/src/modular/emitModelsOptions.ts +10 -16
- package/src/modular/emitSamples.ts +91 -177
- package/src/modular/emitTests.ts +28 -61
- package/src/modular/external-dependencies.ts +54 -54
- package/src/modular/helpers/classicalOperationHelpers.ts +73 -126
- package/src/modular/helpers/clientHelpers.ts +41 -88
- package/src/modular/helpers/clientOptionHelpers.ts +4 -11
- package/src/modular/helpers/exampleValueHelpers.ts +97 -209
- package/src/modular/helpers/namingHelpers.ts +12 -28
- package/src/modular/helpers/operationHelpers.ts +430 -757
- package/src/modular/helpers/typeHelpers.ts +11 -22
- package/src/modular/serialization/buildDeserializerFunction.ts +88 -122
- package/src/modular/serialization/buildSerializerFunction.ts +91 -129
- package/src/modular/serialization/buildXmlSerializerFunction.ts +104 -183
- package/src/modular/serialization/serializeUtils.ts +12 -21
- package/src/modular/static/rollup.test.config.js +11 -14
- package/src/modular/static/scripts/renameOutput.mjs +2 -2
- package/src/modular/static-helpers-metadata.ts +60 -60
- package/src/modular/type-expressions/get-credential-expression.ts +1 -1
- package/src/modular/type-expressions/get-enum-expression.ts +5 -10
- package/src/modular/type-expressions/get-model-expression.ts +13 -17
- package/src/modular/type-expressions/get-nullable-expression.ts +4 -5
- package/src/modular/type-expressions/get-type-expression.ts +8 -12
- package/src/modular/type-expressions/get-union-expression.ts +4 -4
- package/src/modular/type-expressions/utils.ts +1 -1
- package/src/rlc-common/buildClient.ts +70 -141
- package/src/rlc-common/buildClientDefinitions.ts +43 -87
- package/src/rlc-common/buildIndexFile.ts +78 -78
- package/src/rlc-common/buildIsUnexpectedHelper.ts +34 -41
- package/src/rlc-common/buildLogger.ts +7 -7
- package/src/rlc-common/buildMethodShortcuts.ts +9 -21
- package/src/rlc-common/buildObjectTypes.ts +79 -156
- package/src/rlc-common/buildPaginateHelper.ts +9 -12
- package/src/rlc-common/buildParameterTypes.ts +116 -137
- package/src/rlc-common/buildPollingHelper.ts +7 -7
- package/src/rlc-common/buildResponseTypes.ts +34 -57
- package/src/rlc-common/buildSamples.ts +3 -3
- package/src/rlc-common/buildSchemaType.ts +37 -29
- package/src/rlc-common/buildSerializeHelper.ts +5 -5
- package/src/rlc-common/buildTopLevelIndexFile.ts +12 -19
- package/src/rlc-common/helpers/apiVersionUtil.ts +5 -10
- package/src/rlc-common/helpers/importsUtil.ts +27 -30
- package/src/rlc-common/helpers/nameConstructors.ts +16 -50
- package/src/rlc-common/helpers/nameUtils.ts +19 -42
- package/src/rlc-common/helpers/operationHelpers.ts +14 -31
- package/src/rlc-common/helpers/pathUtils.ts +2 -7
- package/src/rlc-common/helpers/schemaHelpers.ts +4 -15
- package/src/rlc-common/helpers/shortcutMethods.ts +6 -15
- package/src/rlc-common/helpers/typeUtil.ts +4 -11
- package/src/rlc-common/helpers/valueGenerationUtil.ts +16 -39
- package/src/rlc-common/index.ts +28 -28
- package/src/rlc-common/interfaces.ts +3 -11
- package/src/rlc-common/metadata/buildApiExtractorConfig.ts +17 -24
- package/src/rlc-common/metadata/buildChangelogFile.ts +1 -1
- package/src/rlc-common/metadata/buildESLintConfig.ts +3 -5
- package/src/rlc-common/metadata/buildLicenseFile.ts +1 -1
- package/src/rlc-common/metadata/buildPackageFile.ts +27 -35
- package/src/rlc-common/metadata/buildReadmeFile.ts +16 -29
- package/src/rlc-common/metadata/buildRollupConfig.ts +5 -8
- package/src/rlc-common/metadata/buildSampleEnvFile.ts +2 -3
- package/src/rlc-common/metadata/buildTestConfig.ts +10 -10
- package/src/rlc-common/metadata/buildTsConfig.ts +32 -35
- package/src/rlc-common/metadata/buildVitestConfig.ts +4 -10
- package/src/rlc-common/metadata/buildWarpConfig.ts +3 -6
- package/src/rlc-common/metadata/packageJson/azurePackageCommon.ts +16 -25
- package/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.ts +29 -50
- package/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.ts +20 -31
- package/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.ts +11 -13
- package/src/rlc-common/metadata/packageJson/packageCommon.ts +32 -52
- package/src/rlc-common/test/buildKarmaConfig.ts +1 -1
- package/src/rlc-common/test/buildRecordedClient.ts +3 -3
- package/src/rlc-common/test/buildSampleTest.ts +3 -3
- package/src/rlc-common/test/buildSnippets.ts +6 -12
- package/src/rlc-common/transformSampleGroups.ts +54 -105
- package/src/testing/index.ts +2 -5
- package/src/transform/transform.ts +22 -34
- package/src/transform/transformApiVersionInfo.ts +17 -30
- package/src/transform/transformHelperFunctionDetails.ts +14 -26
- package/src/transform/transformParameters.ts +55 -105
- package/src/transform/transformPaths.ts +26 -43
- package/src/transform/transformResponses.ts +26 -33
- package/src/transform/transformSchemas.ts +15 -33
- package/src/transform/transformTelemetryInfo.ts +8 -14
- package/src/transform/transfromRLCOptions.ts +53 -115
- package/src/utils/clientUtils.ts +22 -41
- package/src/utils/credentialUtils.ts +8 -19
- package/src/utils/crossLanguageDef.ts +15 -34
- package/src/utils/emitUtil.ts +11 -17
- package/src/utils/fileSystemUtils.ts +4 -6
- package/src/utils/importHelper.ts +5 -10
- package/src/utils/interfaces.ts +1 -1
- package/src/utils/mediaTypes.ts +13 -34
- package/src/utils/modelUtils.ts +175 -384
- package/src/utils/namespaceUtils.ts +8 -24
- package/src/utils/operationUtil.ts +98 -190
- package/src/utils/parameterUtils.ts +31 -54
- package/src/utils/resolve-project-root.ts +3 -3
- package/static/static-helpers/cloudSettingHelpers.ts +4 -6
- package/static/static-helpers/multipartHelpers.ts +3 -3
- package/static/static-helpers/pagingHelpers.ts +28 -63
- package/static/static-helpers/pollingHelpers.ts +15 -28
- package/static/static-helpers/serialization/build-multi-collection.ts +1 -4
- package/static/static-helpers/serialization/check-prop-undefined.ts +1 -4
- package/static/static-helpers/serialization/get-binary-response.ts +2 -2
- package/static/static-helpers/serialization/get-binary-stream-response.ts +2 -4
- package/static/static-helpers/serialization/serialize-record.ts +1 -1
- package/static/static-helpers/serialization/serializers.ts +4 -7
- package/static/static-helpers/serialization/xml-helpers.ts +41 -89
- package/static/static-helpers/simplePollerHelpers.ts +9 -18
- package/static/static-helpers/storageCompatResponse.ts +10 -27
- package/static/static-helpers/urlTemplate.ts +4 -7
- package/static/test-helpers/recordedClient.ts +5 -10
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
OptionalKind,
|
|
6
|
-
PropertySignatureStructure,
|
|
7
|
-
SourceFile,
|
|
8
|
-
StructureKind,
|
|
9
|
-
TypeAliasDeclarationStructure
|
|
10
|
-
} from "ts-morph";
|
|
11
|
-
import {
|
|
12
|
-
fixLeadingNumber,
|
|
13
|
-
NameType,
|
|
14
|
-
normalizeName
|
|
15
|
-
} from "../rlc-common/index.js";
|
|
16
|
-
import {
|
|
2
|
+
isPagedResultModel,
|
|
3
|
+
isReadOnly,
|
|
4
|
+
listAllServiceNamespaces,
|
|
17
5
|
SdkArrayType,
|
|
18
|
-
SdkModelPropertyType,
|
|
19
6
|
SdkClientType,
|
|
20
7
|
SdkDictionaryType,
|
|
21
8
|
SdkEnumType,
|
|
22
9
|
SdkEnumValueType,
|
|
23
10
|
SdkHttpOperation,
|
|
24
11
|
SdkMethod,
|
|
12
|
+
SdkModelPropertyType,
|
|
25
13
|
SdkModelType,
|
|
26
14
|
SdkNullableType,
|
|
27
15
|
SdkServiceMethod,
|
|
@@ -29,67 +17,75 @@ import {
|
|
|
29
17
|
SdkType,
|
|
30
18
|
SdkUnionType,
|
|
31
19
|
UsageFlags,
|
|
32
|
-
isPagedResultModel,
|
|
33
|
-
isReadOnly,
|
|
34
|
-
listAllServiceNamespaces
|
|
35
20
|
} from "@azure-tools/typespec-client-generator-core";
|
|
21
|
+
import {
|
|
22
|
+
EnumDeclarationStructure,
|
|
23
|
+
EnumMemberStructure,
|
|
24
|
+
InterfaceDeclarationStructure,
|
|
25
|
+
OptionalKind,
|
|
26
|
+
PropertySignatureStructure,
|
|
27
|
+
SourceFile,
|
|
28
|
+
StructureKind,
|
|
29
|
+
TypeAliasDeclarationStructure,
|
|
30
|
+
} from "ts-morph";
|
|
31
|
+
import { fixLeadingNumber, NameType, normalizeName } from "../rlc-common/index.js";
|
|
36
32
|
// import { isKey } from "@typespec/compiler";
|
|
37
33
|
import {
|
|
38
34
|
getExternalModel,
|
|
39
35
|
getModelExpression,
|
|
40
|
-
getMultipartFileTypeExpression
|
|
36
|
+
getMultipartFileTypeExpression,
|
|
41
37
|
} from "./type-expressions/get-model-expression.js";
|
|
42
38
|
|
|
43
|
-
import {
|
|
39
|
+
import { getNamespaceFullName, NoTarget } from "@typespec/compiler";
|
|
40
|
+
import { isMetadata, isOrExtendsHttpFile, Visibility } from "@typespec/http";
|
|
41
|
+
import path from "path";
|
|
42
|
+
import { useContext } from "../contextManager.js";
|
|
44
43
|
import { addDeclaration } from "../framework/declaration.js";
|
|
44
|
+
import {
|
|
45
|
+
emitQueue,
|
|
46
|
+
flattenPropertyModelMap,
|
|
47
|
+
getAllOperationsFromClient,
|
|
48
|
+
pagedModelsUsedInNonPagingOps,
|
|
49
|
+
} from "../framework/hooks/sdkTypes.js";
|
|
50
|
+
import { refkey } from "../framework/refkey.js";
|
|
51
|
+
import { reportDiagnostic } from "../lib.js";
|
|
52
|
+
import { getClientHierarchyMap } from "../utils/clientUtils.js";
|
|
53
|
+
import { SdkContext } from "../utils/interfaces.js";
|
|
54
|
+
import { isAzureCoreErrorType } from "../utils/modelUtils.js";
|
|
55
|
+
import { getMethodHierarchiesMap } from "../utils/operationUtil.js";
|
|
56
|
+
import { getHeaderClientOptions } from "./helpers/clientOptionHelpers.js";
|
|
57
|
+
import {
|
|
58
|
+
buildNonModelResponseTypeDeclaration,
|
|
59
|
+
checkWrapNonModelReturn,
|
|
60
|
+
getAllAncestors,
|
|
61
|
+
getAllProperties,
|
|
62
|
+
} from "./helpers/operationHelpers.js";
|
|
63
|
+
import { getDirectSubtypes } from "./helpers/typeHelpers.js";
|
|
45
64
|
import {
|
|
46
65
|
buildModelDeserializer,
|
|
47
|
-
buildPropertyDeserializer
|
|
66
|
+
buildPropertyDeserializer,
|
|
48
67
|
} from "./serialization/buildDeserializerFunction.js";
|
|
49
68
|
import {
|
|
50
69
|
buildModelSerializer,
|
|
51
|
-
buildPropertySerializer
|
|
70
|
+
buildPropertySerializer,
|
|
52
71
|
} from "./serialization/buildSerializerFunction.js";
|
|
53
72
|
import {
|
|
54
|
-
buildXmlModelSerializer,
|
|
55
73
|
buildXmlModelDeserializer,
|
|
56
|
-
|
|
74
|
+
buildXmlModelSerializer,
|
|
57
75
|
buildXmlObjectModelDeserializer,
|
|
58
|
-
|
|
76
|
+
buildXmlObjectModelSerializer,
|
|
77
|
+
hasXmlSerialization,
|
|
59
78
|
} from "./serialization/buildXmlSerializerFunction.js";
|
|
60
|
-
import path from "path";
|
|
61
|
-
import { refkey } from "../framework/refkey.js";
|
|
62
|
-
import { useContext } from "../contextManager.js";
|
|
63
|
-
import { isMetadata, isOrExtendsHttpFile, Visibility } from "@typespec/http";
|
|
64
|
-
import { isAzureCoreErrorType } from "../utils/modelUtils.js";
|
|
65
|
-
import { getHeaderClientOptions } from "./helpers/clientOptionHelpers.js";
|
|
66
|
-
import { isExtensibleEnum } from "./type-expressions/get-enum-expression.js";
|
|
67
79
|
import {
|
|
68
80
|
getAllDiscriminatedValues,
|
|
69
81
|
getPropertyWithOverrides,
|
|
70
|
-
isDiscriminatedUnion
|
|
82
|
+
isDiscriminatedUnion,
|
|
71
83
|
} from "./serialization/serializeUtils.js";
|
|
72
|
-
import {
|
|
73
|
-
import { getNamespaceFullName, NoTarget } from "@typespec/compiler";
|
|
84
|
+
import { isExtensibleEnum } from "./type-expressions/get-enum-expression.js";
|
|
74
85
|
import {
|
|
75
86
|
getTypeExpression,
|
|
76
|
-
normalizeModelPropertyName
|
|
87
|
+
normalizeModelPropertyName,
|
|
77
88
|
} from "./type-expressions/get-type-expression.js";
|
|
78
|
-
import {
|
|
79
|
-
emitQueue,
|
|
80
|
-
flattenPropertyModelMap,
|
|
81
|
-
getAllOperationsFromClient,
|
|
82
|
-
pagedModelsUsedInNonPagingOps
|
|
83
|
-
} from "../framework/hooks/sdkTypes.js";
|
|
84
|
-
import {
|
|
85
|
-
getAllAncestors,
|
|
86
|
-
getAllProperties,
|
|
87
|
-
buildNonModelResponseTypeDeclaration,
|
|
88
|
-
checkWrapNonModelReturn
|
|
89
|
-
} from "./helpers/operationHelpers.js";
|
|
90
|
-
import { getDirectSubtypes } from "./helpers/typeHelpers.js";
|
|
91
|
-
import { getClientHierarchyMap } from "../utils/clientUtils.js";
|
|
92
|
-
import { getMethodHierarchiesMap } from "../utils/operationUtil.js";
|
|
93
89
|
|
|
94
90
|
type InterfaceStructure = OptionalKind<InterfaceDeclarationStructure> & {
|
|
95
91
|
extends?: string[];
|
|
@@ -97,7 +93,7 @@ type InterfaceStructure = OptionalKind<InterfaceDeclarationStructure> & {
|
|
|
97
93
|
};
|
|
98
94
|
|
|
99
95
|
function isGenerableType(
|
|
100
|
-
type: SdkType
|
|
96
|
+
type: SdkType,
|
|
101
97
|
): type is
|
|
102
98
|
| SdkModelType
|
|
103
99
|
| SdkEnumType
|
|
@@ -117,10 +113,7 @@ function isGenerableType(
|
|
|
117
113
|
!type.isGeneratedName)
|
|
118
114
|
);
|
|
119
115
|
}
|
|
120
|
-
export function emitTypes(
|
|
121
|
-
context: SdkContext,
|
|
122
|
-
{ sourceRoot }: { sourceRoot: string }
|
|
123
|
-
) {
|
|
116
|
+
export function emitTypes(context: SdkContext, { sourceRoot }: { sourceRoot: string }) {
|
|
124
117
|
const outputProject = useContext("outputProject");
|
|
125
118
|
|
|
126
119
|
let sourceFile;
|
|
@@ -153,9 +146,7 @@ export function emitTypes(
|
|
|
153
146
|
addSerializationFunctions(context, property, sourceFile!);
|
|
154
147
|
}
|
|
155
148
|
|
|
156
|
-
const modelFiles = outputProject.getSourceFiles(
|
|
157
|
-
sourceRoot + "/models/**/*.ts"
|
|
158
|
-
);
|
|
149
|
+
const modelFiles = outputProject.getSourceFiles(sourceRoot + "/models/**/*.ts");
|
|
159
150
|
const result = [];
|
|
160
151
|
for (const modelFile of modelFiles) {
|
|
161
152
|
if (
|
|
@@ -179,7 +170,7 @@ export function emitTypes(
|
|
|
179
170
|
*/
|
|
180
171
|
export function emitNonModelResponseTypes(
|
|
181
172
|
context: SdkContext,
|
|
182
|
-
{ sourceRoot }: { sourceRoot: string }
|
|
173
|
+
{ sourceRoot }: { sourceRoot: string },
|
|
183
174
|
) {
|
|
184
175
|
const outputProject = useContext("outputProject");
|
|
185
176
|
const clientMap = getClientHierarchyMap(context);
|
|
@@ -200,11 +191,7 @@ export function emitNonModelResponseTypes(
|
|
|
200
191
|
modelsFile = outputProject.createSourceFile(filepath);
|
|
201
192
|
}
|
|
202
193
|
const method: [string[], typeof op] = [prefixes, op];
|
|
203
|
-
const typeAlias = buildNonModelResponseTypeDeclaration(
|
|
204
|
-
context,
|
|
205
|
-
method,
|
|
206
|
-
isBinary
|
|
207
|
-
);
|
|
194
|
+
const typeAlias = buildNonModelResponseTypeDeclaration(context, method, isBinary);
|
|
208
195
|
addDeclaration(modelsFile, typeAlias, refkey(op, "response"));
|
|
209
196
|
}
|
|
210
197
|
}
|
|
@@ -237,14 +224,11 @@ function emitType(context: SdkContext, type: SdkType, sourceFile: SourceFile) {
|
|
|
237
224
|
if (type.discriminatorProperty) {
|
|
238
225
|
modelInterface.properties
|
|
239
226
|
?.filter((p) => {
|
|
240
|
-
return (
|
|
241
|
-
p.name ===
|
|
242
|
-
normalizeModelPropertyName(context, type.discriminatorProperty!)
|
|
243
|
-
);
|
|
227
|
+
return p.name === normalizeModelPropertyName(context, type.discriminatorProperty!);
|
|
244
228
|
})
|
|
245
229
|
.map((p) => {
|
|
246
230
|
p.docs?.push(
|
|
247
|
-
`The discriminator possible values: ${Object.keys(type.discriminatedSubtypes ?? {}).join(", ")}
|
|
231
|
+
`The discriminator possible values: ${Object.keys(type.discriminatedSubtypes ?? {}).join(", ")}`,
|
|
248
232
|
);
|
|
249
233
|
return p;
|
|
250
234
|
});
|
|
@@ -253,11 +237,7 @@ function emitType(context: SdkContext, type: SdkType, sourceFile: SourceFile) {
|
|
|
253
237
|
const modelPolymorphicType = buildModelPolymorphicType(context, type);
|
|
254
238
|
if (modelPolymorphicType) {
|
|
255
239
|
addSerializationFunctions(context, type, sourceFile, true);
|
|
256
|
-
addDeclaration(
|
|
257
|
-
sourceFile,
|
|
258
|
-
modelPolymorphicType,
|
|
259
|
-
refkey(type, "polymorphicType")
|
|
260
|
-
);
|
|
240
|
+
addDeclaration(sourceFile, modelPolymorphicType, refkey(type, "polymorphicType"));
|
|
261
241
|
}
|
|
262
242
|
addSerializationFunctions(context, type, sourceFile);
|
|
263
243
|
} else if (type.kind === "enum") {
|
|
@@ -271,15 +251,14 @@ function emitType(context: SdkContext, type: SdkType, sourceFile: SourceFile) {
|
|
|
271
251
|
}
|
|
272
252
|
const inputUsage = (type.usage & UsageFlags.Input) === UsageFlags.Input;
|
|
273
253
|
const outputUsage = (type.usage & UsageFlags.Output) === UsageFlags.Output;
|
|
274
|
-
const exceptionUsage =
|
|
275
|
-
(type.usage & UsageFlags.Exception) === UsageFlags.Exception;
|
|
254
|
+
const exceptionUsage = (type.usage & UsageFlags.Exception) === UsageFlags.Exception;
|
|
276
255
|
if (!(inputUsage || outputUsage || apiVersionEnumOnly || exceptionUsage)) {
|
|
277
256
|
return;
|
|
278
257
|
}
|
|
279
258
|
const [enumType, knownValuesEnum] = buildEnumTypes(
|
|
280
259
|
context,
|
|
281
260
|
type,
|
|
282
|
-
isExtensibleEnum(context, type)
|
|
261
|
+
isExtensibleEnum(context, type),
|
|
283
262
|
);
|
|
284
263
|
if (enumType.name.startsWith("_")) {
|
|
285
264
|
// skip enum generation for internal enums
|
|
@@ -287,18 +266,10 @@ function emitType(context: SdkContext, type: SdkType, sourceFile: SourceFile) {
|
|
|
287
266
|
}
|
|
288
267
|
if (apiVersionEnumOnly) {
|
|
289
268
|
// generate known values enum only for api version enums
|
|
290
|
-
addDeclaration(
|
|
291
|
-
sourceFile,
|
|
292
|
-
knownValuesEnum,
|
|
293
|
-
refkey(knownValuesEnum.name, "knownValues")
|
|
294
|
-
);
|
|
269
|
+
addDeclaration(sourceFile, knownValuesEnum, refkey(knownValuesEnum.name, "knownValues"));
|
|
295
270
|
} else {
|
|
296
271
|
if (isExtensibleEnum(context, type)) {
|
|
297
|
-
addDeclaration(
|
|
298
|
-
sourceFile,
|
|
299
|
-
knownValuesEnum,
|
|
300
|
-
refkey(type, "knownValues")
|
|
301
|
-
);
|
|
272
|
+
addDeclaration(sourceFile, knownValuesEnum, refkey(type, "knownValues"));
|
|
302
273
|
}
|
|
303
274
|
addDeclaration(sourceFile, enumType, type);
|
|
304
275
|
}
|
|
@@ -324,7 +295,7 @@ export function getApiVersionEnum(context: SdkContext) {
|
|
|
324
295
|
return;
|
|
325
296
|
}
|
|
326
297
|
const apiVersionEnum = context.sdkPackage.enums.find(
|
|
327
|
-
(e) => e.usage === UsageFlags.ApiVersionEnum
|
|
298
|
+
(e) => e.usage === UsageFlags.ApiVersionEnum,
|
|
328
299
|
);
|
|
329
300
|
if (!apiVersionEnum) {
|
|
330
301
|
return;
|
|
@@ -332,35 +303,23 @@ export function getApiVersionEnum(context: SdkContext) {
|
|
|
332
303
|
return apiVersionEnum;
|
|
333
304
|
}
|
|
334
305
|
|
|
335
|
-
export function getModelsPath(
|
|
336
|
-
sourceRoot: string,
|
|
337
|
-
modelNamespace: string[] = []
|
|
338
|
-
): string {
|
|
306
|
+
export function getModelsPath(sourceRoot: string, modelNamespace: string[] = []): string {
|
|
339
307
|
return path.join(
|
|
340
308
|
...[
|
|
341
309
|
sourceRoot,
|
|
342
310
|
"models",
|
|
343
311
|
...modelNamespace.map((n) => normalizeName(n, NameType.File)),
|
|
344
|
-
`models.ts
|
|
345
|
-
]
|
|
312
|
+
`models.ts`,
|
|
313
|
+
],
|
|
346
314
|
);
|
|
347
315
|
}
|
|
348
316
|
|
|
349
|
-
export function getModelNamespaces(
|
|
350
|
-
|
|
351
|
-
model: SdkType
|
|
352
|
-
): string[] {
|
|
353
|
-
if (
|
|
354
|
-
model.kind === "model" ||
|
|
355
|
-
model.kind === "enum" ||
|
|
356
|
-
model.kind === "union"
|
|
357
|
-
) {
|
|
317
|
+
export function getModelNamespaces(context: SdkContext, model: SdkType): string[] {
|
|
318
|
+
if (model.kind === "model" || model.kind === "enum" || model.kind === "union") {
|
|
358
319
|
if (
|
|
359
320
|
(model.namespace ?? "").startsWith("Azure.ResourceManager") ||
|
|
360
321
|
(model.namespace ?? "").startsWith("Azure.Core") ||
|
|
361
|
-
(model.crossLanguageDefinitionId ?? "").startsWith(
|
|
362
|
-
"TypeSpec.Rest.Resource"
|
|
363
|
-
) ||
|
|
322
|
+
(model.crossLanguageDefinitionId ?? "").startsWith("TypeSpec.Rest.Resource") ||
|
|
364
323
|
(model.crossLanguageDefinitionId ?? "") === "TypeSpec.Http.File" // filter out the TypeSpec.Http.File model similar like what java does here https://github.com/microsoft/typespec/blob/main/packages/http-client-java/emitter/src/code-model-builder.ts#L2589
|
|
365
324
|
) {
|
|
366
325
|
return [];
|
|
@@ -371,8 +330,7 @@ export function getModelNamespaces(
|
|
|
371
330
|
return segments;
|
|
372
331
|
}
|
|
373
332
|
|
|
374
|
-
const allServiceNamespaces =
|
|
375
|
-
context.allServiceNamespaces ?? listAllServiceNamespaces(context);
|
|
333
|
+
const allServiceNamespaces = context.allServiceNamespaces ?? listAllServiceNamespaces(context);
|
|
376
334
|
const deepestNamespace = getNamespaceFullName(allServiceNamespaces[0]!);
|
|
377
335
|
const rootNamespace = deepestNamespace.split(".") ?? [];
|
|
378
336
|
if (segments.length > rootNamespace.length) {
|
|
@@ -425,9 +383,7 @@ function isNestedInXmlModel(targetModel: SdkModelType): boolean {
|
|
|
425
383
|
/**
|
|
426
384
|
* Gets all properties from a model and its ancestors (base models).
|
|
427
385
|
*/
|
|
428
|
-
function getModelAndAncestorProperties(
|
|
429
|
-
type: SdkModelType
|
|
430
|
-
): SdkModelPropertyType[] {
|
|
386
|
+
function getModelAndAncestorProperties(type: SdkModelType): SdkModelPropertyType[] {
|
|
431
387
|
const properties: SdkModelPropertyType[] = [];
|
|
432
388
|
let current: SdkModelType | undefined = type;
|
|
433
389
|
while (current) {
|
|
@@ -445,11 +401,11 @@ function addSerializationFunctions(
|
|
|
445
401
|
context: SdkContext,
|
|
446
402
|
typeOrProperty: SdkType | SdkModelPropertyType,
|
|
447
403
|
sourceFile: SourceFile,
|
|
448
|
-
skipDiscriminatedUnionSuffix = false
|
|
404
|
+
skipDiscriminatedUnionSuffix = false,
|
|
449
405
|
) {
|
|
450
406
|
const options = {
|
|
451
407
|
nameOnly: false,
|
|
452
|
-
skipDiscriminatedUnionSuffix
|
|
408
|
+
skipDiscriminatedUnionSuffix,
|
|
453
409
|
};
|
|
454
410
|
|
|
455
411
|
// Add JSON serializers
|
|
@@ -484,11 +440,7 @@ function addSerializationFunctions(
|
|
|
484
440
|
const xmlSerializerRefKey = refkey(typeOrProperty, "xmlSerializer");
|
|
485
441
|
const xmlDeserializerRefKey = refkey(typeOrProperty, "xmlDeserializer");
|
|
486
442
|
|
|
487
|
-
const xmlSerializationFunction = buildXmlModelSerializer(
|
|
488
|
-
context,
|
|
489
|
-
typeOrProperty,
|
|
490
|
-
options
|
|
491
|
-
);
|
|
443
|
+
const xmlSerializationFunction = buildXmlModelSerializer(context, typeOrProperty, options);
|
|
492
444
|
if (
|
|
493
445
|
xmlSerializationFunction &&
|
|
494
446
|
typeof xmlSerializationFunction !== "string" &&
|
|
@@ -497,83 +449,56 @@ function addSerializationFunctions(
|
|
|
497
449
|
addDeclaration(sourceFile, xmlSerializationFunction, xmlSerializerRefKey);
|
|
498
450
|
}
|
|
499
451
|
|
|
500
|
-
const xmlDeserializationFunction = buildXmlModelDeserializer(
|
|
501
|
-
context,
|
|
502
|
-
typeOrProperty,
|
|
503
|
-
options
|
|
504
|
-
);
|
|
452
|
+
const xmlDeserializationFunction = buildXmlModelDeserializer(context, typeOrProperty, options);
|
|
505
453
|
if (
|
|
506
454
|
xmlDeserializationFunction &&
|
|
507
455
|
typeof xmlDeserializationFunction !== "string" &&
|
|
508
456
|
xmlDeserializationFunction.name
|
|
509
457
|
) {
|
|
510
|
-
addDeclaration(
|
|
511
|
-
sourceFile,
|
|
512
|
-
xmlDeserializationFunction,
|
|
513
|
-
xmlDeserializerRefKey
|
|
514
|
-
);
|
|
458
|
+
addDeclaration(sourceFile, xmlDeserializationFunction, xmlDeserializerRefKey);
|
|
515
459
|
}
|
|
516
460
|
|
|
517
461
|
// Only generate XML object serializer/deserializer for models that are
|
|
518
462
|
// actually nested as properties inside other XML models
|
|
519
463
|
if (isNestedInXmlModel(typeOrProperty)) {
|
|
520
|
-
const xmlObjectSerializerRefKey = refkey(
|
|
521
|
-
|
|
522
|
-
"xmlObjectSerializer"
|
|
523
|
-
);
|
|
524
|
-
const xmlObjectDeserializerRefKey = refkey(
|
|
525
|
-
typeOrProperty,
|
|
526
|
-
"xmlObjectDeserializer"
|
|
527
|
-
);
|
|
464
|
+
const xmlObjectSerializerRefKey = refkey(typeOrProperty, "xmlObjectSerializer");
|
|
465
|
+
const xmlObjectDeserializerRefKey = refkey(typeOrProperty, "xmlObjectDeserializer");
|
|
528
466
|
|
|
529
467
|
const xmlObjectSerializationFunction = buildXmlObjectModelSerializer(
|
|
530
468
|
context,
|
|
531
469
|
typeOrProperty,
|
|
532
|
-
options
|
|
470
|
+
options,
|
|
533
471
|
);
|
|
534
472
|
if (
|
|
535
473
|
xmlObjectSerializationFunction &&
|
|
536
474
|
typeof xmlObjectSerializationFunction !== "string" &&
|
|
537
475
|
xmlObjectSerializationFunction.name
|
|
538
476
|
) {
|
|
539
|
-
addDeclaration(
|
|
540
|
-
sourceFile,
|
|
541
|
-
xmlObjectSerializationFunction,
|
|
542
|
-
xmlObjectSerializerRefKey
|
|
543
|
-
);
|
|
477
|
+
addDeclaration(sourceFile, xmlObjectSerializationFunction, xmlObjectSerializerRefKey);
|
|
544
478
|
}
|
|
545
479
|
|
|
546
480
|
const xmlObjectDeserializationFunction = buildXmlObjectModelDeserializer(
|
|
547
481
|
context,
|
|
548
482
|
typeOrProperty,
|
|
549
|
-
options
|
|
483
|
+
options,
|
|
550
484
|
);
|
|
551
485
|
if (
|
|
552
486
|
xmlObjectDeserializationFunction &&
|
|
553
487
|
typeof xmlObjectDeserializationFunction !== "string" &&
|
|
554
488
|
xmlObjectDeserializationFunction.name
|
|
555
489
|
) {
|
|
556
|
-
addDeclaration(
|
|
557
|
-
sourceFile,
|
|
558
|
-
xmlObjectDeserializationFunction,
|
|
559
|
-
xmlObjectDeserializerRefKey
|
|
560
|
-
);
|
|
490
|
+
addDeclaration(sourceFile, xmlObjectDeserializationFunction, xmlObjectDeserializerRefKey);
|
|
561
491
|
}
|
|
562
492
|
}
|
|
563
493
|
}
|
|
564
494
|
}
|
|
565
495
|
|
|
566
|
-
function buildUnionType(
|
|
567
|
-
context: SdkContext,
|
|
568
|
-
type: SdkUnionType
|
|
569
|
-
): TypeAliasDeclarationStructure {
|
|
496
|
+
function buildUnionType(context: SdkContext, type: SdkUnionType): TypeAliasDeclarationStructure {
|
|
570
497
|
const unionDeclaration: TypeAliasDeclarationStructure = {
|
|
571
498
|
kind: StructureKind.TypeAlias,
|
|
572
499
|
name: normalizeModelName(context, type),
|
|
573
500
|
isExported: true,
|
|
574
|
-
type: type.variantTypes
|
|
575
|
-
.map((v) => getTypeExpression(context, v))
|
|
576
|
-
.join(" | ")
|
|
501
|
+
type: type.variantTypes.map((v) => getTypeExpression(context, v)).join(" | "),
|
|
577
502
|
};
|
|
578
503
|
|
|
579
504
|
unionDeclaration.docs = [type.doc ?? `Alias for ${unionDeclaration.name}`];
|
|
@@ -586,27 +511,25 @@ function buildNullableType(context: SdkContext, type: SdkNullableType) {
|
|
|
586
511
|
kind: StructureKind.TypeAlias,
|
|
587
512
|
name: normalizeModelName(context, type),
|
|
588
513
|
isExported: true,
|
|
589
|
-
type: getTypeExpression(context, type.type) + " | null"
|
|
514
|
+
type: getTypeExpression(context, type.type) + " | null",
|
|
590
515
|
};
|
|
591
|
-
nullableDeclaration.docs = [
|
|
592
|
-
type.doc ?? `Alias for ${nullableDeclaration.name}`
|
|
593
|
-
];
|
|
516
|
+
nullableDeclaration.docs = [type.doc ?? `Alias for ${nullableDeclaration.name}`];
|
|
594
517
|
return nullableDeclaration;
|
|
595
518
|
}
|
|
596
519
|
|
|
597
520
|
export function buildEnumTypes(
|
|
598
521
|
context: SdkContext,
|
|
599
522
|
type: SdkEnumType,
|
|
600
|
-
reportMemberNameDiagnostic = false // if reportMemberNameDiagnostic is true, it will report diagnostic for enum member name
|
|
523
|
+
reportMemberNameDiagnostic = false, // if reportMemberNameDiagnostic is true, it will report diagnostic for enum member name
|
|
601
524
|
): [TypeAliasDeclarationStructure, EnumDeclarationStructure] {
|
|
602
525
|
const rawMembers = type.values.map((value) =>
|
|
603
|
-
emitEnumMember(context, value, reportMemberNameDiagnostic)
|
|
526
|
+
emitEnumMember(context, value, reportMemberNameDiagnostic),
|
|
604
527
|
);
|
|
605
528
|
const enumDeclaration: EnumDeclarationStructure = {
|
|
606
529
|
kind: StructureKind.Enum,
|
|
607
530
|
name: `Known${normalizeModelName(context, type)}`,
|
|
608
531
|
isExported: true,
|
|
609
|
-
members: deduplicateEnumMemberNames(rawMembers)
|
|
532
|
+
members: deduplicateEnumMemberNames(rawMembers),
|
|
610
533
|
};
|
|
611
534
|
|
|
612
535
|
const enumAsUnion: TypeAliasDeclarationStructure = {
|
|
@@ -615,7 +538,7 @@ export function buildEnumTypes(
|
|
|
615
538
|
isExported: true,
|
|
616
539
|
type: !isExtensibleEnum(context, type)
|
|
617
540
|
? type.values.map((v) => getTypeExpression(context, v)).join(" | ")
|
|
618
|
-
: getTypeExpression(context, type.valueType)
|
|
541
|
+
: getTypeExpression(context, type.valueType),
|
|
619
542
|
};
|
|
620
543
|
|
|
621
544
|
const docs = type.doc ? type.doc : "Type of " + enumAsUnion.name;
|
|
@@ -630,10 +553,7 @@ export function buildEnumTypes(
|
|
|
630
553
|
return [enumAsUnion, enumDeclaration];
|
|
631
554
|
}
|
|
632
555
|
|
|
633
|
-
function getExtensibleEnumDescription(
|
|
634
|
-
context: SdkContext,
|
|
635
|
-
model: SdkEnumType
|
|
636
|
-
): string | undefined {
|
|
556
|
+
function getExtensibleEnumDescription(context: SdkContext, model: SdkEnumType): string | undefined {
|
|
637
557
|
if (model.isFixed && model.name && model.values) {
|
|
638
558
|
return;
|
|
639
559
|
}
|
|
@@ -649,7 +569,7 @@ function getExtensibleEnumDescription(
|
|
|
649
569
|
`${model.doc} \\`,
|
|
650
570
|
enumLink,
|
|
651
571
|
`### Known values supported by the service`,
|
|
652
|
-
valueDescriptions
|
|
572
|
+
valueDescriptions,
|
|
653
573
|
].join(" \n");
|
|
654
574
|
}
|
|
655
575
|
|
|
@@ -659,9 +579,7 @@ function getExtensibleEnumDescription(
|
|
|
659
579
|
* This handles cases where different values (e.g. "10" and "1.0") normalize
|
|
660
580
|
* to the same identifier.
|
|
661
581
|
*/
|
|
662
|
-
function deduplicateEnumMemberNames(
|
|
663
|
-
members: EnumMemberStructure[]
|
|
664
|
-
): EnumMemberStructure[] {
|
|
582
|
+
function deduplicateEnumMemberNames(members: EnumMemberStructure[]): EnumMemberStructure[] {
|
|
665
583
|
const nameCount = new Map<string, number>();
|
|
666
584
|
for (const member of members) {
|
|
667
585
|
const name = member.name as string;
|
|
@@ -682,14 +600,10 @@ function deduplicateEnumMemberNames(
|
|
|
682
600
|
function emitEnumMember(
|
|
683
601
|
context: SdkContext,
|
|
684
602
|
member: SdkEnumValueType,
|
|
685
|
-
reportMemberNameDiagnostic = false // if reportMemberNameDiagnostic is true, it will report diagnostic for enum member name
|
|
603
|
+
reportMemberNameDiagnostic = false, // if reportMemberNameDiagnostic is true, it will report diagnostic for enum member name
|
|
686
604
|
): EnumMemberStructure {
|
|
687
605
|
const shouldNormalizeName = !member.name.startsWith("$DO_NOT_NORMALIZE$");
|
|
688
|
-
const enumTypeName = normalizeName(
|
|
689
|
-
member.enumType.name,
|
|
690
|
-
NameType.Interface,
|
|
691
|
-
true
|
|
692
|
-
);
|
|
606
|
+
const enumTypeName = normalizeName(member.enumType.name, NameType.Interface, true);
|
|
693
607
|
let normalizedMemberName = context.rlcOptions?.ignoreEnumMemberNameNormalize
|
|
694
608
|
? fixLeadingNumber(member.name, NameType.EnumMemberName) // need to fix the leading number also for enum member
|
|
695
609
|
: normalizeName(member.name, NameType.EnumMemberName, true);
|
|
@@ -701,8 +615,7 @@ function emitEnumMember(
|
|
|
701
615
|
!member.name.toLowerCase().startsWith("_")
|
|
702
616
|
) {
|
|
703
617
|
const isApiVersionEnum =
|
|
704
|
-
(member.enumType.usage & UsageFlags.ApiVersionEnum) ===
|
|
705
|
-
UsageFlags.ApiVersionEnum;
|
|
618
|
+
(member.enumType.usage & UsageFlags.ApiVersionEnum) === UsageFlags.ApiVersionEnum;
|
|
706
619
|
const prefix = isApiVersionEnum ? "V" : enumTypeName;
|
|
707
620
|
normalizedMemberName = prefix + normalizedMemberName.slice(1);
|
|
708
621
|
if (reportMemberNameDiagnostic) {
|
|
@@ -711,16 +624,16 @@ function emitEnumMember(
|
|
|
711
624
|
format: {
|
|
712
625
|
memberName: member.name,
|
|
713
626
|
normalizedName: normalizedMemberName,
|
|
714
|
-
enumTypeName
|
|
627
|
+
enumTypeName,
|
|
715
628
|
},
|
|
716
|
-
target: NoTarget
|
|
629
|
+
target: NoTarget,
|
|
717
630
|
});
|
|
718
631
|
}
|
|
719
632
|
}
|
|
720
633
|
const memberStructure: EnumMemberStructure = {
|
|
721
634
|
kind: StructureKind.EnumMember,
|
|
722
635
|
name: normalizedMemberName,
|
|
723
|
-
value: member.value
|
|
636
|
+
value: member.value,
|
|
724
637
|
};
|
|
725
638
|
|
|
726
639
|
if (member.doc) {
|
|
@@ -735,7 +648,7 @@ function emitEnumMember(
|
|
|
735
648
|
|
|
736
649
|
function buildModelInterface(
|
|
737
650
|
context: SdkContext,
|
|
738
|
-
type: SdkModelType
|
|
651
|
+
type: SdkModelType,
|
|
739
652
|
): InterfaceDeclarationStructure {
|
|
740
653
|
const flattenPropertySet = new Set<SdkModelPropertyType>();
|
|
741
654
|
// For non-input models (output-only, exception, etc.), filter out metadata
|
|
@@ -773,25 +686,20 @@ function buildModelInterface(
|
|
|
773
686
|
})
|
|
774
687
|
.map((p) => {
|
|
775
688
|
return buildModelProperty(context, p, type);
|
|
776
|
-
})
|
|
689
|
+
}),
|
|
777
690
|
} as InterfaceStructure;
|
|
778
691
|
for (const flatten of flattenPropertySet.keys()) {
|
|
779
|
-
const conflictMap =
|
|
780
|
-
|
|
781
|
-
const allProperties = getAllProperties(
|
|
782
|
-
context,
|
|
783
|
-
flatten.type,
|
|
784
|
-
getAllAncestors(flatten.type)
|
|
785
|
-
);
|
|
692
|
+
const conflictMap = useContext("sdkTypes").flattenProperties.get(flatten)?.conflictMap;
|
|
693
|
+
const allProperties = getAllProperties(context, flatten.type, getAllAncestors(flatten.type));
|
|
786
694
|
interfaceStructure.properties!.push(
|
|
787
695
|
...allProperties.map((p) => {
|
|
788
696
|
// when the flattened property is optional, all its child properties should be optional too
|
|
789
697
|
const property = getPropertyWithOverrides(p, {
|
|
790
698
|
allOptional: flatten.optional,
|
|
791
|
-
propertyRenames: conflictMap
|
|
699
|
+
propertyRenames: conflictMap,
|
|
792
700
|
});
|
|
793
701
|
return buildModelProperty(context, property, type);
|
|
794
|
-
})
|
|
702
|
+
}),
|
|
795
703
|
);
|
|
796
704
|
}
|
|
797
705
|
|
|
@@ -799,9 +707,7 @@ function buildModelInterface(
|
|
|
799
707
|
const headerOptions = getHeaderClientOptions(type);
|
|
800
708
|
if (headerOptions.length > 0) {
|
|
801
709
|
const existingNames = new Set(
|
|
802
|
-
interfaceStructure.properties!.map(
|
|
803
|
-
(p: OptionalKind<PropertySignatureStructure>) => p.name
|
|
804
|
-
)
|
|
710
|
+
interfaceStructure.properties!.map((p: OptionalKind<PropertySignatureStructure>) => p.name),
|
|
805
711
|
);
|
|
806
712
|
for (const opt of headerOptions) {
|
|
807
713
|
if (!existingNames.has(opt.propertyName)) {
|
|
@@ -809,7 +715,7 @@ function buildModelInterface(
|
|
|
809
715
|
kind: StructureKind.PropertySignature,
|
|
810
716
|
name: opt.propertyName,
|
|
811
717
|
type: "string",
|
|
812
|
-
hasQuestionToken: true
|
|
718
|
+
hasQuestionToken: true,
|
|
813
719
|
});
|
|
814
720
|
}
|
|
815
721
|
}
|
|
@@ -817,7 +723,7 @@ function buildModelInterface(
|
|
|
817
723
|
|
|
818
724
|
if (type.baseModel) {
|
|
819
725
|
const parentReference = getModelExpression(context, type.baseModel, {
|
|
820
|
-
skipPolymorphicUnion: true
|
|
726
|
+
skipPolymorphicUnion: true,
|
|
821
727
|
});
|
|
822
728
|
interfaceStructure.extends = [parentReference];
|
|
823
729
|
}
|
|
@@ -826,9 +732,7 @@ function buildModelInterface(
|
|
|
826
732
|
addExtendedDictInfo(context, type, interfaceStructure);
|
|
827
733
|
}
|
|
828
734
|
|
|
829
|
-
interfaceStructure.docs = [
|
|
830
|
-
type.doc ?? "model interface " + interfaceStructure.name
|
|
831
|
-
];
|
|
735
|
+
interfaceStructure.docs = [type.doc ?? "model interface " + interfaceStructure.name];
|
|
832
736
|
|
|
833
737
|
return interfaceStructure;
|
|
834
738
|
}
|
|
@@ -836,7 +740,7 @@ function buildModelInterface(
|
|
|
836
740
|
function addExtendedDictInfo(
|
|
837
741
|
context: SdkContext,
|
|
838
742
|
model: SdkModelType,
|
|
839
|
-
modelInterface: InterfaceStructure
|
|
743
|
+
modelInterface: InterfaceStructure,
|
|
840
744
|
) {
|
|
841
745
|
const additionalPropertiesType = model.additionalProperties
|
|
842
746
|
? getTypeExpression(context, model.additionalProperties)
|
|
@@ -854,17 +758,13 @@ function addExtendedDictInfo(
|
|
|
854
758
|
} else {
|
|
855
759
|
// case 3: if additionalProperties is defined and model.properties is not empty, we should check if all properties are compatible with additionalProperties type
|
|
856
760
|
anyType = !properties.every((p) => {
|
|
857
|
-
return additionalPropertiesType?.includes(
|
|
858
|
-
getTypeExpression(context, p.type)
|
|
859
|
-
);
|
|
761
|
+
return additionalPropertiesType?.includes(getTypeExpression(context, p.type));
|
|
860
762
|
});
|
|
861
763
|
}
|
|
862
764
|
if (!modelInterface.extends) {
|
|
863
765
|
modelInterface.extends = [];
|
|
864
766
|
}
|
|
865
|
-
modelInterface.extends.push(
|
|
866
|
-
`Record<string, ${anyType ? "any" : additionalPropertiesType}>`
|
|
867
|
-
);
|
|
767
|
+
modelInterface.extends.push(`Record<string, ${anyType ? "any" : additionalPropertiesType}>`);
|
|
868
768
|
} else {
|
|
869
769
|
const additionalPropertiesType = model.additionalProperties
|
|
870
770
|
? getTypeExpression(context, model.additionalProperties)
|
|
@@ -875,9 +775,9 @@ function addExtendedDictInfo(
|
|
|
875
775
|
reportDiagnostic(context.program, {
|
|
876
776
|
code: "property-name-conflict",
|
|
877
777
|
format: {
|
|
878
|
-
propertyName: "additionalProperties"
|
|
778
|
+
propertyName: "additionalProperties",
|
|
879
779
|
},
|
|
880
|
-
target: NoTarget
|
|
780
|
+
target: NoTarget,
|
|
881
781
|
});
|
|
882
782
|
}
|
|
883
783
|
if (!modelInterface.properties) {
|
|
@@ -888,20 +788,15 @@ function addExtendedDictInfo(
|
|
|
888
788
|
docs: ["Additional properties"],
|
|
889
789
|
hasQuestionToken: true,
|
|
890
790
|
isReadonly: false,
|
|
891
|
-
type: `Record<string, ${additionalPropertiesType ?? "any"}
|
|
791
|
+
type: `Record<string, ${additionalPropertiesType ?? "any"}>`,
|
|
892
792
|
});
|
|
893
793
|
}
|
|
894
794
|
}
|
|
895
795
|
|
|
896
|
-
export function getAdditionalPropertiesName(
|
|
897
|
-
context: SdkContext,
|
|
898
|
-
model: SdkModelType
|
|
899
|
-
): string {
|
|
796
|
+
export function getAdditionalPropertiesName(context: SdkContext, model: SdkModelType): string {
|
|
900
797
|
const ancestors = getAllAncestors(model);
|
|
901
798
|
const properties = getAllProperties(context, model, ancestors);
|
|
902
|
-
const nameConflict = properties.find(
|
|
903
|
-
(p) => p.name === "additionalProperties"
|
|
904
|
-
);
|
|
799
|
+
const nameConflict = properties.find((p) => p.name === "additionalProperties");
|
|
905
800
|
return nameConflict ? "additionalPropertiesBag" : "additionalProperties";
|
|
906
801
|
}
|
|
907
802
|
|
|
@@ -916,7 +811,7 @@ export function normalizeModelName(
|
|
|
916
811
|
| SdkNullableType,
|
|
917
812
|
nameType: NameType = NameType.Interface,
|
|
918
813
|
skipPolymorphicUnionSuffix = false,
|
|
919
|
-
rawModelName?: boolean
|
|
814
|
+
rawModelName?: boolean,
|
|
920
815
|
): string {
|
|
921
816
|
if (type.kind === "array") {
|
|
922
817
|
if (rawModelName) {
|
|
@@ -927,11 +822,7 @@ export function normalizeModelName(
|
|
|
927
822
|
if (rawModelName) {
|
|
928
823
|
return `${normalizeModelName(context, type.valueType as any, nameType, skipPolymorphicUnionSuffix, rawModelName)}Record`;
|
|
929
824
|
}
|
|
930
|
-
return `Record<string, ${normalizeModelName(
|
|
931
|
-
context,
|
|
932
|
-
type.valueType as any,
|
|
933
|
-
nameType
|
|
934
|
-
)}>`;
|
|
825
|
+
return `Record<string, ${normalizeModelName(context, type.valueType as any, nameType)}>`;
|
|
935
826
|
}
|
|
936
827
|
if (
|
|
937
828
|
type.kind !== "model" &&
|
|
@@ -949,12 +840,9 @@ export function normalizeModelName(
|
|
|
949
840
|
unionSuffix = "Union";
|
|
950
841
|
}
|
|
951
842
|
}
|
|
952
|
-
const namespacePrefix = context.rlcOptions?.enableModelNamespace
|
|
953
|
-
? segments.join("")
|
|
954
|
-
: "";
|
|
843
|
+
const namespacePrefix = context.rlcOptions?.enableModelNamespace ? segments.join("") : "";
|
|
955
844
|
const internalModelPrefix =
|
|
956
|
-
(isPagedResultModel(context, type) &&
|
|
957
|
-
!pagedModelsUsedInNonPagingOps.has(type)) ||
|
|
845
|
+
(isPagedResultModel(context, type) && !pagedModelsUsedInNonPagingOps.has(type)) ||
|
|
958
846
|
type.isGeneratedName
|
|
959
847
|
? "_"
|
|
960
848
|
: "";
|
|
@@ -980,12 +868,12 @@ function buildModelPolymorphicType(context: SdkContext, type: SdkModelType) {
|
|
|
980
868
|
);
|
|
981
869
|
})
|
|
982
870
|
.map((t) => getTypeExpression(context, t))
|
|
983
|
-
.join(" | ")
|
|
871
|
+
.join(" | "),
|
|
984
872
|
};
|
|
985
873
|
typeDeclaration.docs = [`Alias for ${typeDeclaration.name}`];
|
|
986
874
|
|
|
987
875
|
typeDeclaration.type += ` | ${getModelExpression(context, type, {
|
|
988
|
-
skipPolymorphicUnion: true
|
|
876
|
+
skipPolymorphicUnion: true,
|
|
989
877
|
})}`;
|
|
990
878
|
return typeDeclaration;
|
|
991
879
|
}
|
|
@@ -993,7 +881,7 @@ function buildModelPolymorphicType(context: SdkContext, type: SdkModelType) {
|
|
|
993
881
|
function buildModelProperty(
|
|
994
882
|
context: SdkContext,
|
|
995
883
|
property: SdkModelPropertyType,
|
|
996
|
-
model: SdkModelType
|
|
884
|
+
model: SdkModelType,
|
|
997
885
|
): PropertySignatureStructure {
|
|
998
886
|
const normalizedPropName = normalizeModelPropertyName(context, property);
|
|
999
887
|
if (
|
|
@@ -1004,9 +892,9 @@ function buildModelProperty(
|
|
|
1004
892
|
code: "property-name-normalized",
|
|
1005
893
|
format: {
|
|
1006
894
|
propertyName: property.name,
|
|
1007
|
-
normalizedName: normalizedPropName
|
|
895
|
+
normalizedName: normalizedPropName,
|
|
1008
896
|
},
|
|
1009
|
-
target: NoTarget
|
|
897
|
+
target: NoTarget,
|
|
1010
898
|
});
|
|
1011
899
|
}
|
|
1012
900
|
|
|
@@ -1017,17 +905,12 @@ function buildModelProperty(
|
|
|
1017
905
|
// 1. it is discriminated union
|
|
1018
906
|
// 2. it has other discriminator values except itself
|
|
1019
907
|
if (isDiscriminatedUnion(model) && allDiscriminatorValues.length > 1) {
|
|
1020
|
-
typeExpression = allDiscriminatorValues
|
|
1021
|
-
|
|
1022
|
-
.join(" | ");
|
|
1023
|
-
} else if (
|
|
1024
|
-
property.kind === "property" &&
|
|
1025
|
-
property.serializationOptions.multipart?.isFilePart
|
|
1026
|
-
) {
|
|
908
|
+
typeExpression = allDiscriminatorValues.map((value) => `"${value}"`).join(" | ");
|
|
909
|
+
} else if (property.kind === "property" && property.serializationOptions.multipart?.isFilePart) {
|
|
1027
910
|
typeExpression = getMultipartFileTypeExpression(context, property);
|
|
1028
911
|
} else {
|
|
1029
912
|
typeExpression = getTypeExpression(context, property.type, {
|
|
1030
|
-
isOptional: property.optional
|
|
913
|
+
isOptional: property.optional,
|
|
1031
914
|
});
|
|
1032
915
|
}
|
|
1033
916
|
|
|
@@ -1036,7 +919,7 @@ function buildModelProperty(
|
|
|
1036
919
|
name: normalizedPropName,
|
|
1037
920
|
type: typeExpression,
|
|
1038
921
|
hasQuestionToken: property.optional,
|
|
1039
|
-
isReadonly: isReadOnly(property as SdkModelPropertyType)
|
|
922
|
+
isReadonly: isReadOnly(property as SdkModelPropertyType),
|
|
1040
923
|
};
|
|
1041
924
|
|
|
1042
925
|
if (property.doc) {
|
|
@@ -1072,22 +955,14 @@ export function visitPackageTypes(context: SdkContext) {
|
|
|
1072
955
|
}
|
|
1073
956
|
}
|
|
1074
957
|
|
|
1075
|
-
function visitClient(
|
|
1076
|
-
context: SdkContext,
|
|
1077
|
-
client: SdkClientType<SdkServiceOperation>
|
|
1078
|
-
) {
|
|
958
|
+
function visitClient(context: SdkContext, client: SdkClientType<SdkServiceOperation>) {
|
|
1079
959
|
// TODO: include the client parameters
|
|
1080
960
|
// https://github.com/Azure/autorest.typescript/issues/3148
|
|
1081
961
|
// Comment this out for now, as client initialization is not used in the generated code
|
|
1082
|
-
getAllOperationsFromClient(client).forEach((method) =>
|
|
1083
|
-
visitClientMethod(context, method)
|
|
1084
|
-
);
|
|
962
|
+
getAllOperationsFromClient(client).forEach((method) => visitClientMethod(context, method));
|
|
1085
963
|
}
|
|
1086
964
|
|
|
1087
|
-
function visitClientMethod(
|
|
1088
|
-
context: SdkContext,
|
|
1089
|
-
method: SdkMethod<SdkHttpOperation>
|
|
1090
|
-
) {
|
|
965
|
+
function visitClientMethod(context: SdkContext, method: SdkMethod<SdkHttpOperation>) {
|
|
1091
966
|
switch (method.kind) {
|
|
1092
967
|
case "lro":
|
|
1093
968
|
case "paging":
|
|
@@ -1100,9 +975,9 @@ function visitClientMethod(
|
|
|
1100
975
|
reportDiagnostic(context.program, {
|
|
1101
976
|
code: "unknown-sdk-method-kind",
|
|
1102
977
|
format: {
|
|
1103
|
-
methodKind: (method as any).kind
|
|
978
|
+
methodKind: (method as any).kind,
|
|
1104
979
|
},
|
|
1105
|
-
target: NoTarget
|
|
980
|
+
target: NoTarget,
|
|
1106
981
|
});
|
|
1107
982
|
return; // Skip processing this method but continue with others
|
|
1108
983
|
}
|
|
@@ -1112,9 +987,7 @@ function visitOperation(context: SdkContext, operation: SdkHttpOperation) {
|
|
|
1112
987
|
// Visit the request
|
|
1113
988
|
visitType(context, operation.bodyParam?.type);
|
|
1114
989
|
// Visit the response
|
|
1115
|
-
operation.exceptions.forEach((exception) =>
|
|
1116
|
-
visitType(context, exception.type)
|
|
1117
|
-
);
|
|
990
|
+
operation.exceptions.forEach((exception) => visitType(context, exception.type));
|
|
1118
991
|
|
|
1119
992
|
operation.parameters.forEach((parameter) => {
|
|
1120
993
|
visitType(context, parameter.type);
|
|
@@ -1123,10 +996,7 @@ function visitOperation(context: SdkContext, operation: SdkHttpOperation) {
|
|
|
1123
996
|
operation.responses.forEach((response) => visitType(context, response.type));
|
|
1124
997
|
}
|
|
1125
998
|
|
|
1126
|
-
function visitMethod(
|
|
1127
|
-
context: SdkContext,
|
|
1128
|
-
method: SdkServiceMethod<SdkHttpOperation>
|
|
1129
|
-
) {
|
|
999
|
+
function visitMethod(context: SdkContext, method: SdkServiceMethod<SdkHttpOperation>) {
|
|
1130
1000
|
// Visit the request
|
|
1131
1001
|
method.parameters.forEach((parameter) => {
|
|
1132
1002
|
visitType(context, parameter.type);
|
|
@@ -1141,7 +1011,7 @@ function visitMethod(
|
|
|
1141
1011
|
*/
|
|
1142
1012
|
function trackPagedModelInNonPagingMethod(
|
|
1143
1013
|
context: SdkContext,
|
|
1144
|
-
method: SdkServiceMethod<SdkHttpOperation
|
|
1014
|
+
method: SdkServiceMethod<SdkHttpOperation>,
|
|
1145
1015
|
): void {
|
|
1146
1016
|
if (method.kind !== "basic" && method.kind !== "lro") return;
|
|
1147
1017
|
const respType = method.response.type;
|