@azure-tools/typespec-ts 0.54.0 → 0.55.0-dev.6
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/README.md +0 -4
- package/dist/src/contextManager.d.ts +5 -5
- package/dist/src/contextManager.d.ts.map +1 -1
- package/dist/src/contextManager.js +3 -3
- 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 +31 -40
- 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 -12
- 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 +17 -31
- 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 +2 -2
- 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 +103 -92
- 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 +60 -74
- 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 +8 -10
- 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 +31 -38
- 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 +5 -6
- 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 +23 -25
- 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 +8 -11
- 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 +12 -13
- 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 +36 -50
- 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 -18
- 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 +4 -4
- 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 +81 -113
- 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 +7 -8
- 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 +69 -77
- 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 +13 -18
- 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 +59 -68
- 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 +31 -54
- 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 +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 +72 -84
- 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 +7 -10
- 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 +204 -288
- 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 +4 -6
- 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 +58 -67
- 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 +65 -75
- 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 +73 -90
- 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 +25 -33
- 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 -2
- 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 +10 -13
- 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 +2 -3
- 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 +5 -11
- 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 +67 -89
- 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 +28 -45
- 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 +59 -60
- 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 +37 -38
- 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 +4 -5
- 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 +4 -4
- 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 +57 -96
- 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 +71 -61
- 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 +9 -10
- 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 +23 -27
- 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 +6 -8
- 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 +32 -37
- 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 +2 -4
- 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 +17 -23
- 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 +16 -31
- package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/packageUtil.js +3 -6
- package/dist/src/rlc-common/helpers/packageUtil.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 +3 -7
- 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 +4 -9
- package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js +7 -11
- 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 +14 -15
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildChangelogFile.js +2 -3
- package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildESLintConfig.js +5 -8
- 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 +33 -37
- 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 +31 -39
- 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 +4 -6
- 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 +3 -5
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTestConfig.js +11 -12
- package/dist/src/rlc-common/metadata/buildTestConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTsConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildTsConfig.js +28 -28
- 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 -5
- 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 +4 -5
- 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 +14 -14
- 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 +24 -29
- 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 +28 -31
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -1
- package/dist/src/rlc-common/metadata/utils.js +1 -2
- package/dist/src/rlc-common/metadata/utils.js.map +1 -1
- package/dist/src/rlc-common/test/buildKarmaConfig.js +1 -1
- package/dist/src/rlc-common/test/buildRecordedClient.js +4 -5
- package/dist/src/rlc-common/test/buildRecordedClient.js.map +1 -1
- package/dist/src/rlc-common/test/buildSampleTest.d.ts.map +1 -1
- package/dist/src/rlc-common/test/buildSampleTest.js +3 -4
- 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 +7 -10
- 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 +41 -45
- 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 +28 -27
- 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 +12 -14
- 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 +11 -14
- 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 +32 -45
- 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 +19 -23
- 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 +21 -25
- 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 +21 -32
- 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 +28 -39
- 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 +15 -23
- 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 +4 -5
- 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 +11 -15
- 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 +5 -7
- package/dist/src/utils/emitUtil.js.map +1 -1
- package/dist/src/utils/fileSystemUtils.d.ts +2 -0
- package/dist/src/utils/fileSystemUtils.d.ts.map +1 -1
- package/dist/src/utils/fileSystemUtils.js +26 -7
- 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 +3 -6
- 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 +168 -257
- 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 +6 -7
- 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 +60 -81
- 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 +26 -33
- 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 +38 -45
- 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 +145 -185
- 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 -160
- 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 +92 -180
- 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 +99 -215
- 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 -22
- 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 +44 -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 -116
- 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 +30 -8
- 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 +16 -29
- 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-browser.mts +3 -1
- package/static/static-helpers/serialization/get-binary-response.ts +2 -2
- package/static/static-helpers/serialization/get-binary-stream-response-browser.mts +1 -3
- 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 +42 -90
- package/static/static-helpers/simplePollerHelpers.ts +10 -19
- 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,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getClientOptions, isHttpMetadata, isReadOnly, } from "@azure-tools/typespec-client-generator-core";
|
|
2
2
|
import { NoTarget } from "@typespec/compiler";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { AzurePollingDependencies } from "../external-dependencies.js";
|
|
10
|
-
import { NameType, normalizeName } from "../../rlc-common/index.js";
|
|
11
|
-
import { buildModelDeserializer, buildPropertyDeserializer } from "../serialization/buildDeserializerFunction.js";
|
|
12
|
-
import { buildModelSerializer, buildPropertySerializer } from "../serialization/buildSerializerFunction.js";
|
|
13
|
-
import { buildXmlModelSerializer, buildXmlModelDeserializer, hasXmlSerialization } from "../serialization/buildXmlSerializerFunction.js";
|
|
3
|
+
import { isHeader, isMetadata } from "@typespec/http";
|
|
4
|
+
import { StructureKind, } from "ts-morph";
|
|
5
|
+
import { useContext } from "../../contextManager.js";
|
|
6
|
+
import { useSdkTypes } from "../../framework/hooks/sdkTypes.js";
|
|
7
|
+
import { useDependencies } from "../../framework/hooks/useDependencies.js";
|
|
8
|
+
import { resolveReference } from "../../framework/reference.js";
|
|
14
9
|
import { refkey } from "../../framework/refkey.js";
|
|
15
10
|
import { reportDiagnostic } from "../../lib.js";
|
|
16
|
-
import {
|
|
17
|
-
import { useDependencies } from "../../framework/hooks/useDependencies.js";
|
|
18
|
-
import { useSdkTypes } from "../../framework/hooks/sdkTypes.js";
|
|
11
|
+
import { NameType, normalizeName } from "../../rlc-common/index.js";
|
|
19
12
|
import { isAzureCoreErrorType } from "../../utils/modelUtils.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
13
|
+
import { getCollectionFormatFromArrayEncoding, getCollectionFormatHelper, getCollectionFormatParseHelper, hasCollectionFormatInfo, hasDualFormatSupport, isBinaryPayload, isMultipartPayload, isXmlPayload, KnownCollectionFormat, } from "../../utils/operationUtil.js";
|
|
14
|
+
import { AzurePollingDependencies } from "../external-dependencies.js";
|
|
15
|
+
import { buildModelDeserializer, buildPropertyDeserializer, } from "../serialization/buildDeserializerFunction.js";
|
|
16
|
+
import { buildModelSerializer, buildPropertySerializer, } from "../serialization/buildSerializerFunction.js";
|
|
17
|
+
import { buildXmlModelDeserializer, buildXmlModelSerializer, hasXmlSerialization, } from "../serialization/buildXmlSerializerFunction.js";
|
|
18
|
+
import { getPropertyWithOverrides, isNormalUnion, isSpecialHandledUnion, } from "../serialization/serializeUtils.js";
|
|
19
|
+
import { PagingHelpers, PlatformTypeHelpers, PollingHelpers, SerializationHelpers, StorageCompatHelpers, UrlTemplateHelpers, XmlHelpers, } from "../static-helpers-metadata.js";
|
|
26
20
|
import { isExtensibleEnum } from "../type-expressions/get-enum-expression.js";
|
|
27
21
|
import { emitInlineModel } from "../type-expressions/get-model-expression.js";
|
|
22
|
+
import { getTypeExpression, normalizeModelPropertyName, } from "../type-expressions/get-type-expression.js";
|
|
23
|
+
import { getClientParameterName } from "./clientHelpers.js";
|
|
24
|
+
import { getHeaderClientOptions, getRestErrorCodeHeader } from "./clientOptionHelpers.js";
|
|
25
|
+
import { getDocsFromDescription, getFixmeForMultilineDocs } from "./docsHelpers.js";
|
|
26
|
+
import { generateLocallyUniqueName, getClassicalLayerPrefix, getOperationName, } from "./namingHelpers.js";
|
|
27
|
+
import { getNullableValidType, isSpreadBodyParameter, isTypeNullable } from "./typeHelpers.js";
|
|
28
28
|
/**
|
|
29
29
|
* Checks whether a header should be skipped during serialization/deserialization.
|
|
30
30
|
* A header is skipped when it has the "headerCollectionPrefix" client option set,
|
|
@@ -43,7 +43,7 @@ export function getSendPrivateFunction(dpgContext, method, clientType, client) {
|
|
|
43
43
|
isExported: true,
|
|
44
44
|
name: `_${name}Send`,
|
|
45
45
|
parameters,
|
|
46
|
-
returnType: resolveReference(dependencies.StreamableMethod)
|
|
46
|
+
returnType: resolveReference(dependencies.StreamableMethod),
|
|
47
47
|
};
|
|
48
48
|
const operationPath = operation.operation.path;
|
|
49
49
|
const operationMethod = operation.operation.verb.toLowerCase();
|
|
@@ -52,15 +52,13 @@ export function getSendPrivateFunction(dpgContext, method, clientType, client) {
|
|
|
52
52
|
let pathStr = `"${operationPath}"`;
|
|
53
53
|
const urlTemplateParams = [
|
|
54
54
|
...getPathParameters(operation),
|
|
55
|
-
...getQueryParameters(dpgContext, operation)
|
|
55
|
+
...getQueryParameters(dpgContext, operation),
|
|
56
56
|
];
|
|
57
57
|
if (urlTemplateParams.length > 0) {
|
|
58
58
|
// Generate a unique local variable name that doesn't conflict with parameter names
|
|
59
59
|
const paramNames = new Set(parameters.map((p) => p.name));
|
|
60
60
|
const pathVarName = generateLocallyUniqueName("path", paramNames);
|
|
61
|
-
const includeRootSlash = client
|
|
62
|
-
? getClientOptions(client, "includeRootSlash") !== false
|
|
63
|
-
: true;
|
|
61
|
+
const includeRootSlash = client ? getClientOptions(client, "includeRootSlash") !== false : true;
|
|
64
62
|
const uriTemplate = includeRootSlash
|
|
65
63
|
? operation.operation.uriTemplate
|
|
66
64
|
: operation.operation.uriTemplate.replace(/^\//, "");
|
|
@@ -74,11 +72,10 @@ export function getSendPrivateFunction(dpgContext, method, clientType, client) {
|
|
|
74
72
|
statements.push(`return context.path(${pathStr}).${operationMethod}({...${resolveReference(dependencies.operationOptionsToRequestParameters)}(${optionalParamName}), ${getHeaderAndBodyParameters(dpgContext, operation, optionalParamName)}});`);
|
|
75
73
|
return {
|
|
76
74
|
...functionStatement,
|
|
77
|
-
statements
|
|
75
|
+
statements,
|
|
78
76
|
};
|
|
79
77
|
}
|
|
80
78
|
export function getDeserializePrivateFunction(context, method) {
|
|
81
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
82
79
|
const operation = method[1];
|
|
83
80
|
const { name } = getOperationName(operation);
|
|
84
81
|
const dependencies = useDependencies();
|
|
@@ -101,26 +98,26 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
101
98
|
// For LRO-only operations with non-model final result, wrap in a response type alias
|
|
102
99
|
returnType = {
|
|
103
100
|
name: getOperationResponseTypeName(method),
|
|
104
|
-
type: resolveReference(refkey(operation, "response"))
|
|
101
|
+
type: resolveReference(refkey(operation, "response")),
|
|
105
102
|
};
|
|
106
103
|
}
|
|
107
104
|
else {
|
|
108
105
|
returnType = buildLroReturnType(context, operation);
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
|
-
else if (isPagingOnly &&
|
|
108
|
+
else if (isPagingOnly && restResponse?.type) {
|
|
112
109
|
// For paging operations, use the full response model (e.g., _OperationListResult)
|
|
113
110
|
// instead of just the array element type
|
|
114
111
|
returnType = {
|
|
115
|
-
name:
|
|
116
|
-
type: getTypeExpression(context, restResponse.type)
|
|
112
|
+
name: restResponse.name ?? "",
|
|
113
|
+
type: getTypeExpression(context, restResponse.type),
|
|
117
114
|
};
|
|
118
115
|
}
|
|
119
116
|
else if (shouldWrap) {
|
|
120
117
|
// Use the wrapper response type name (resolved via binder for cross-file imports)
|
|
121
118
|
returnType = {
|
|
122
119
|
name: getOperationResponseTypeName(method),
|
|
123
|
-
type: resolveReference(refkey(operation, "response"))
|
|
120
|
+
type: resolveReference(refkey(operation, "response")),
|
|
124
121
|
};
|
|
125
122
|
}
|
|
126
123
|
else if (response.type) {
|
|
@@ -128,8 +125,8 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
128
125
|
// the return type must include undefined to reflect that possibility.
|
|
129
126
|
const baseType = getTypeExpression(context, response.type);
|
|
130
127
|
returnType = {
|
|
131
|
-
name:
|
|
132
|
-
type: response.optional ? `${baseType} | undefined` : baseType
|
|
128
|
+
name: response.name ?? "",
|
|
129
|
+
type: response.optional ? `${baseType} | undefined` : baseType,
|
|
133
130
|
};
|
|
134
131
|
}
|
|
135
132
|
else if (isHeadAsBooleanOperation(operation)) {
|
|
@@ -145,27 +142,27 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
145
142
|
const parameters = [
|
|
146
143
|
{
|
|
147
144
|
name: resultParamName,
|
|
148
|
-
type: resultParamType
|
|
149
|
-
}
|
|
145
|
+
type: resultParamType,
|
|
146
|
+
},
|
|
150
147
|
];
|
|
151
148
|
const functionStatement = {
|
|
152
149
|
isAsync: true,
|
|
153
150
|
isExported: true,
|
|
154
151
|
name: `_${name}Deserialize`,
|
|
155
152
|
parameters,
|
|
156
|
-
returnType: `Promise<${returnType.type}
|
|
153
|
+
returnType: `Promise<${returnType.type}>`,
|
|
157
154
|
};
|
|
158
155
|
const statements = [];
|
|
159
156
|
const createRestErrorReference = resolveReference(dependencies.createRestError);
|
|
160
157
|
statements.push(`const expectedStatuses = ${getExpectedStatuses(operation)};`);
|
|
161
158
|
statements.push(`if(!expectedStatuses.includes(result.status)){`, `${getExceptionThrowStatement(context, operation)}`, "}");
|
|
162
159
|
const deserializedType = isLroOnly || isLroAndPaging
|
|
163
|
-
?
|
|
164
|
-
: isPagingOnly &&
|
|
160
|
+
? operation?.lroMetadata?.finalResponse?.result
|
|
161
|
+
: isPagingOnly && restResponse?.type
|
|
165
162
|
? restResponse.type
|
|
166
163
|
: response.type;
|
|
167
164
|
const lroSubSegments = isLroOnly
|
|
168
|
-
?
|
|
165
|
+
? operation?.lroMetadata?.finalResponse?.resultSegments
|
|
169
166
|
: undefined;
|
|
170
167
|
let lroSubPath;
|
|
171
168
|
if (lroSubSegments && lroSubSegments.length > 0) {
|
|
@@ -189,13 +186,11 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
189
186
|
// This only applies to non-LRO, non-paging operations where the deserialized type
|
|
190
187
|
// comes from response.type (not from LRO metadata or paging).
|
|
191
188
|
const needsBodyGuard = response.optional && !isLroOnly && !isLroAndPaging && !isPagingOnly;
|
|
192
|
-
const contentTypes =
|
|
189
|
+
const contentTypes = operation.operation.responses[0]?.contentTypes ?? [];
|
|
193
190
|
const isXml = isXmlPayload(contentTypes);
|
|
194
191
|
const isDualFormat = hasDualFormatSupport(contentTypes);
|
|
195
192
|
const isMultipart = isMultipartPayload(contentTypes);
|
|
196
|
-
const useXmlDeserialization = isXml &&
|
|
197
|
-
deserializedType.kind === "model" &&
|
|
198
|
-
hasXmlSerialization(deserializedType);
|
|
193
|
+
const useXmlDeserialization = isXml && deserializedType.kind === "model" && hasXmlSerialization(deserializedType);
|
|
199
194
|
// Workaround for multipart response: cast return value as any due to lack of multipart response handling in core
|
|
200
195
|
const multipartCastSuffix = isMultipart ? " as any" : "";
|
|
201
196
|
// For dual-format responses, check content-type header at runtime
|
|
@@ -209,11 +204,11 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
209
204
|
}
|
|
210
205
|
const xmlDeserializerName = buildXmlModelDeserializer(context, deserializedType, {
|
|
211
206
|
nameOnly: true,
|
|
212
|
-
skipDiscriminatedUnionSuffix: false
|
|
207
|
+
skipDiscriminatedUnionSuffix: false,
|
|
213
208
|
});
|
|
214
209
|
const jsonDeserializerName = buildModelDeserializer(context, deserializedType, {
|
|
215
210
|
nameOnly: true,
|
|
216
|
-
skipDiscriminatedUnionSuffix: false
|
|
211
|
+
skipDiscriminatedUnionSuffix: false,
|
|
217
212
|
});
|
|
218
213
|
if (xmlDeserializerName && jsonDeserializerName) {
|
|
219
214
|
const isXmlContentTypeRef = resolveReference(XmlHelpers.isXmlContentType);
|
|
@@ -227,7 +222,7 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
227
222
|
// Fall back to JSON deserializer
|
|
228
223
|
const deserializeFunctionName = buildModelDeserializer(context, deserializedType, {
|
|
229
224
|
nameOnly: true,
|
|
230
|
-
skipDiscriminatedUnionSuffix: false
|
|
225
|
+
skipDiscriminatedUnionSuffix: false,
|
|
231
226
|
});
|
|
232
227
|
if (deserializeFunctionName) {
|
|
233
228
|
statements.push(`return ${deserializeFunctionName}(${deserializedRoot})`);
|
|
@@ -243,7 +238,7 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
243
238
|
}
|
|
244
239
|
const xmlDeserializerName = buildXmlModelDeserializer(context, deserializedType, {
|
|
245
240
|
nameOnly: true,
|
|
246
|
-
skipDiscriminatedUnionSuffix: false
|
|
241
|
+
skipDiscriminatedUnionSuffix: false,
|
|
247
242
|
});
|
|
248
243
|
if (xmlDeserializerName) {
|
|
249
244
|
statements.push(`return ${xmlDeserializerName}(${deserializedRoot})`);
|
|
@@ -252,7 +247,7 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
252
247
|
// Fall back to JSON deserializer if XML deserializer is not available
|
|
253
248
|
const deserializeFunctionName = buildModelDeserializer(context, deserializedType, {
|
|
254
249
|
nameOnly: true,
|
|
255
|
-
skipDiscriminatedUnionSuffix: false
|
|
250
|
+
skipDiscriminatedUnionSuffix: false,
|
|
256
251
|
});
|
|
257
252
|
if (deserializeFunctionName) {
|
|
258
253
|
statements.push(`return ${deserializeFunctionName}(${deserializedRoot})`);
|
|
@@ -266,7 +261,7 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
266
261
|
// JSON response (default) - also handles multipart responses
|
|
267
262
|
const deserializeFunctionName = buildModelDeserializer(context, deserializedType, {
|
|
268
263
|
nameOnly: true,
|
|
269
|
-
skipDiscriminatedUnionSuffix: false
|
|
264
|
+
skipDiscriminatedUnionSuffix: false,
|
|
270
265
|
});
|
|
271
266
|
// Handle wrap-non-model-return for non-LRO, non-paging and LRO-only operations
|
|
272
267
|
if (shouldWrap) {
|
|
@@ -289,7 +284,7 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
289
284
|
}
|
|
290
285
|
return {
|
|
291
286
|
...functionStatement,
|
|
292
|
-
statements
|
|
287
|
+
statements,
|
|
293
288
|
};
|
|
294
289
|
}
|
|
295
290
|
if (deserializeFunctionName) {
|
|
@@ -328,7 +323,7 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
328
323
|
}
|
|
329
324
|
return {
|
|
330
325
|
...functionStatement,
|
|
331
|
-
statements
|
|
326
|
+
statements,
|
|
332
327
|
};
|
|
333
328
|
}
|
|
334
329
|
/**
|
|
@@ -337,13 +332,11 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
337
332
|
* or enable-storage-compat is enabled.
|
|
338
333
|
*/
|
|
339
334
|
export function getDeserializeHeadersPrivateFunction(context, operation) {
|
|
340
|
-
var _a, _b;
|
|
341
335
|
const responseHeaders = getResponseHeaders(operation.operation.responses);
|
|
342
|
-
const isResponseHeadersEnabled =
|
|
343
|
-
const isStorageCompatEnabled =
|
|
336
|
+
const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
|
|
337
|
+
const isStorageCompatEnabled = context.rlcOptions?.enableStorageCompat === true;
|
|
344
338
|
// Only generate if headers exist and a relevant feature is enabled
|
|
345
|
-
if (responseHeaders.length === 0 ||
|
|
346
|
-
(!isResponseHeadersEnabled && !isStorageCompatEnabled)) {
|
|
339
|
+
if (responseHeaders.length === 0 || (!isResponseHeadersEnabled && !isStorageCompatEnabled)) {
|
|
347
340
|
return undefined;
|
|
348
341
|
}
|
|
349
342
|
const { name } = getOperationName(operation);
|
|
@@ -352,8 +345,8 @@ export function getDeserializeHeadersPrivateFunction(context, operation) {
|
|
|
352
345
|
const parameters = [
|
|
353
346
|
{
|
|
354
347
|
name: "result",
|
|
355
|
-
type: PathUncheckedResponseReference
|
|
356
|
-
}
|
|
348
|
+
type: PathUncheckedResponseReference,
|
|
349
|
+
},
|
|
357
350
|
];
|
|
358
351
|
const returnType = buildHeaderOnlyResponseType(context, responseHeaders);
|
|
359
352
|
const functionStatement = {
|
|
@@ -361,17 +354,16 @@ export function getDeserializeHeadersPrivateFunction(context, operation) {
|
|
|
361
354
|
isExported: true,
|
|
362
355
|
name: `_${name}DeserializeHeaders`,
|
|
363
356
|
parameters,
|
|
364
|
-
returnType
|
|
357
|
+
returnType,
|
|
365
358
|
};
|
|
366
359
|
const statements = [];
|
|
367
360
|
statements.push(`return ${buildHeaderOnlyResponseValue(context, responseHeaders)};`);
|
|
368
361
|
return {
|
|
369
362
|
...functionStatement,
|
|
370
|
-
statements
|
|
363
|
+
statements,
|
|
371
364
|
};
|
|
372
365
|
}
|
|
373
366
|
function getExceptionDetails(context, operation) {
|
|
374
|
-
var _a;
|
|
375
367
|
const customized = [];
|
|
376
368
|
let defaultDeserializer;
|
|
377
369
|
let defaultXmlDeserializer;
|
|
@@ -383,15 +375,14 @@ function getExceptionDetails(context, operation) {
|
|
|
383
375
|
const statusCode = exception.statusCodes;
|
|
384
376
|
const deserializeFunctionName = buildModelDeserializer(context, exception.type, {
|
|
385
377
|
nameOnly: true,
|
|
386
|
-
skipDiscriminatedUnionSuffix: false
|
|
378
|
+
skipDiscriminatedUnionSuffix: false,
|
|
387
379
|
});
|
|
388
|
-
if (!deserializeFunctionName ||
|
|
389
|
-
typeof deserializeFunctionName !== "string") {
|
|
380
|
+
if (!deserializeFunctionName || typeof deserializeFunctionName !== "string") {
|
|
390
381
|
continue;
|
|
391
382
|
}
|
|
392
383
|
// Check if the exception type has XML serialization support
|
|
393
384
|
// Use exception contentTypes when available, otherwise check the type itself
|
|
394
|
-
const exceptionContentTypes =
|
|
385
|
+
const exceptionContentTypes = exception.contentTypes ?? [];
|
|
395
386
|
const exceptionIsXml = isXmlPayload(exceptionContentTypes);
|
|
396
387
|
const exceptionIsDualFormat = hasDualFormatSupport(exceptionContentTypes);
|
|
397
388
|
const typeHasXml = exception.type.kind === "model" && hasXmlSerialization(exception.type);
|
|
@@ -399,16 +390,14 @@ function getExceptionDetails(context, operation) {
|
|
|
399
390
|
if (exception.type.kind === "model" && (typeHasXml || exceptionIsXml)) {
|
|
400
391
|
const xmlName = buildXmlModelDeserializer(context, exception.type, {
|
|
401
392
|
nameOnly: true,
|
|
402
|
-
skipDiscriminatedUnionSuffix: false
|
|
393
|
+
skipDiscriminatedUnionSuffix: false,
|
|
403
394
|
});
|
|
404
395
|
if (typeof xmlName === "string") {
|
|
405
396
|
xmlDeserializerName = xmlName;
|
|
406
397
|
}
|
|
407
398
|
}
|
|
408
399
|
// XML-only when all content types are XML (no JSON support)
|
|
409
|
-
const isXmlOnly = xmlDeserializerName !== undefined &&
|
|
410
|
-
exceptionIsXml &&
|
|
411
|
-
!exceptionIsDualFormat;
|
|
400
|
+
const isXmlOnly = xmlDeserializerName !== undefined && exceptionIsXml && !exceptionIsDualFormat;
|
|
412
401
|
if (statusCode === "*") {
|
|
413
402
|
defaultDeserializer = deserializeFunctionName;
|
|
414
403
|
defaultXmlDeserializer = xmlDeserializerName;
|
|
@@ -419,7 +408,7 @@ function getExceptionDetails(context, operation) {
|
|
|
419
408
|
start: statusCode,
|
|
420
409
|
deserializer: deserializeFunctionName,
|
|
421
410
|
xmlDeserializer: xmlDeserializerName,
|
|
422
|
-
isXmlOnly
|
|
411
|
+
isXmlOnly,
|
|
423
412
|
});
|
|
424
413
|
}
|
|
425
414
|
else {
|
|
@@ -428,7 +417,7 @@ function getExceptionDetails(context, operation) {
|
|
|
428
417
|
end: statusCode.end,
|
|
429
418
|
deserializer: deserializeFunctionName,
|
|
430
419
|
xmlDeserializer: xmlDeserializerName,
|
|
431
|
-
isXmlOnly
|
|
420
|
+
isXmlOnly,
|
|
432
421
|
});
|
|
433
422
|
}
|
|
434
423
|
}
|
|
@@ -436,20 +425,19 @@ function getExceptionDetails(context, operation) {
|
|
|
436
425
|
customized,
|
|
437
426
|
defaultDeserializer,
|
|
438
427
|
defaultXmlDeserializer,
|
|
439
|
-
defaultIsXmlOnly
|
|
428
|
+
defaultIsXmlOnly,
|
|
440
429
|
};
|
|
441
430
|
}
|
|
442
431
|
/**
|
|
443
432
|
* Collects and deduplicates all response headers from operation exceptions.
|
|
444
433
|
*/
|
|
445
434
|
function getExceptionResponseHeaders(exceptions) {
|
|
446
|
-
var _a, _b;
|
|
447
435
|
const headerMap = new Map();
|
|
448
|
-
for (const exception of exceptions
|
|
449
|
-
for (const header of
|
|
436
|
+
for (const exception of exceptions ?? []) {
|
|
437
|
+
for (const header of exception.headers ?? []) {
|
|
450
438
|
if (shouldSkipHeaderSerialization(header))
|
|
451
439
|
continue;
|
|
452
|
-
const key =
|
|
440
|
+
const key = header.serializedName ?? header.name;
|
|
453
441
|
if (!headerMap.has(key)) {
|
|
454
442
|
headerMap.set(key, header);
|
|
455
443
|
}
|
|
@@ -462,8 +450,7 @@ function getExceptionResponseHeaders(exceptions) {
|
|
|
462
450
|
* Only generated when exception headers are present and include-headers-in-response is enabled.
|
|
463
451
|
*/
|
|
464
452
|
export function getDeserializeExceptionHeadersPrivateFunction(context, operation) {
|
|
465
|
-
|
|
466
|
-
const isResponseHeadersEnabled = ((_a = context.rlcOptions) === null || _a === void 0 ? void 0 : _a.includeHeadersInResponse) === true;
|
|
453
|
+
const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
|
|
467
454
|
if (!isResponseHeadersEnabled) {
|
|
468
455
|
return undefined;
|
|
469
456
|
}
|
|
@@ -477,8 +464,8 @@ export function getDeserializeExceptionHeadersPrivateFunction(context, operation
|
|
|
477
464
|
const parameters = [
|
|
478
465
|
{
|
|
479
466
|
name: "result",
|
|
480
|
-
type: PathUncheckedResponseReference
|
|
481
|
-
}
|
|
467
|
+
type: PathUncheckedResponseReference,
|
|
468
|
+
},
|
|
482
469
|
];
|
|
483
470
|
const returnType = buildHeaderOnlyResponseType(context, exceptionHeaders);
|
|
484
471
|
const functionStatement = {
|
|
@@ -486,13 +473,13 @@ export function getDeserializeExceptionHeadersPrivateFunction(context, operation
|
|
|
486
473
|
isExported: true,
|
|
487
474
|
name: `_${name}DeserializeExceptionHeaders`,
|
|
488
475
|
parameters,
|
|
489
|
-
returnType
|
|
476
|
+
returnType,
|
|
490
477
|
};
|
|
491
478
|
const statements = [];
|
|
492
479
|
statements.push(`return ${buildHeaderOnlyResponseValue(context, exceptionHeaders)};`);
|
|
493
480
|
return {
|
|
494
481
|
...functionStatement,
|
|
495
|
-
statements
|
|
482
|
+
statements,
|
|
496
483
|
};
|
|
497
484
|
}
|
|
498
485
|
function getExceptionDeserializeExpr(exception) {
|
|
@@ -505,11 +492,10 @@ function getExceptionDeserializeExpr(exception) {
|
|
|
505
492
|
return `isXml ? ${exception.xmlDeserializer}(result.body) : ${exception.deserializer}(result.body)`;
|
|
506
493
|
}
|
|
507
494
|
function getExceptionThrowStatement(context, operation) {
|
|
508
|
-
var _a;
|
|
509
495
|
const statements = [];
|
|
510
496
|
const createRestErrorReference = resolveReference(useDependencies().createRestError);
|
|
511
497
|
const { customized, defaultDeserializer, defaultXmlDeserializer, defaultIsXmlOnly } = getExceptionDetails(context, operation);
|
|
512
|
-
const isResponseHeadersEnabled =
|
|
498
|
+
const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
|
|
513
499
|
// Check if exception headers function exists and build the call
|
|
514
500
|
const exceptionHeaders = getExceptionResponseHeaders(operation.operation.exceptions);
|
|
515
501
|
const hasExceptionHeaders = isResponseHeadersEnabled && exceptionHeaders.length > 0;
|
|
@@ -521,11 +507,7 @@ function getExceptionThrowStatement(context, operation) {
|
|
|
521
507
|
const clientOptionHeadersCall = buildClientOptionHeadersCall(operation.operation.exceptions);
|
|
522
508
|
// Build @clientOption("restErrorCodeHeader", ...) code to set error.code from a header
|
|
523
509
|
const restErrorCodeAssignment = buildRestErrorCodeAssignment(operation.operation.exceptions);
|
|
524
|
-
const allHeaderCalls = [
|
|
525
|
-
exceptionHeadersCall,
|
|
526
|
-
clientOptionHeadersCall,
|
|
527
|
-
restErrorCodeAssignment
|
|
528
|
-
]
|
|
510
|
+
const allHeaderCalls = [exceptionHeadersCall, clientOptionHeadersCall, restErrorCodeAssignment]
|
|
529
511
|
.filter(Boolean)
|
|
530
512
|
.join("\n");
|
|
531
513
|
// Check if any exception has XML deserialization support that requires runtime content-type check
|
|
@@ -605,7 +587,7 @@ function getExceptionThrowStatement(context, operation) {
|
|
|
605
587
|
function buildClientOptionHeadersCall(exceptions) {
|
|
606
588
|
const seenProperties = new Set();
|
|
607
589
|
const assignments = [];
|
|
608
|
-
for (const exception of exceptions
|
|
590
|
+
for (const exception of exceptions ?? []) {
|
|
609
591
|
if (!exception.type || exception.type.kind !== "model") {
|
|
610
592
|
continue;
|
|
611
593
|
}
|
|
@@ -628,7 +610,7 @@ function buildClientOptionHeadersCall(exceptions) {
|
|
|
628
610
|
* based on @clientOption("restErrorCodeHeader", ...) on exception model types.
|
|
629
611
|
*/
|
|
630
612
|
function buildRestErrorCodeAssignment(exceptions) {
|
|
631
|
-
for (const exception of exceptions
|
|
613
|
+
for (const exception of exceptions ?? []) {
|
|
632
614
|
if (!exception.type || exception.type.kind !== "model") {
|
|
633
615
|
continue;
|
|
634
616
|
}
|
|
@@ -641,34 +623,28 @@ if (restErrorCodeValue !== undefined) { error.code = restErrorCodeValue; }`;
|
|
|
641
623
|
return undefined;
|
|
642
624
|
}
|
|
643
625
|
function getOptionalParamsName(parameters) {
|
|
644
|
-
|
|
645
|
-
|
|
626
|
+
return (parameters.filter((p) => p.type?.toString().endsWith("operationOptions__"))[0]?.name ??
|
|
627
|
+
"options");
|
|
646
628
|
}
|
|
647
629
|
function getOperationSignatureParameters(context, method, clientType) {
|
|
648
630
|
const operation = method[1];
|
|
649
631
|
const optionsType = resolveReference(refkey(method[1], "operationOptions"));
|
|
650
632
|
const parameters = new Map();
|
|
651
633
|
operation.parameters
|
|
652
|
-
.filter((p) =>
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
!p.optional &&
|
|
663
|
-
!(p.isGeneratedName &&
|
|
664
|
-
(p.name === "contentType" || p.name === "accept")) && // skip tcgc generated contentType and accept header parameter
|
|
665
|
-
getClientOptions(p, "headerCollectionPrefix") === undefined;
|
|
666
|
-
} // skip headers with collection prefix
|
|
667
|
-
)
|
|
634
|
+
.filter((p) => p.onClient === false &&
|
|
635
|
+
p.type.kind !== "constant" &&
|
|
636
|
+
operation.operation.parameters.filter((param) => {
|
|
637
|
+
return (param.methodParameterSegments.length === 1 &&
|
|
638
|
+
param.methodParameterSegments[0]?.length === 1 &&
|
|
639
|
+
param.methodParameterSegments[0]?.[0] === p);
|
|
640
|
+
})[0]?.kind !== "cookie" &&
|
|
641
|
+
!p.optional &&
|
|
642
|
+
!(p.isGeneratedName && (p.name === "contentType" || p.name === "accept")) && // skip tcgc generated contentType and accept header parameter
|
|
643
|
+
getClientOptions(p, "headerCollectionPrefix") === undefined)
|
|
668
644
|
.map((p) => {
|
|
669
645
|
return {
|
|
670
646
|
name: p.name,
|
|
671
|
-
type: getTypeExpression(context, p.type)
|
|
647
|
+
type: getTypeExpression(context, p.type),
|
|
672
648
|
};
|
|
673
649
|
})
|
|
674
650
|
.forEach((p) => {
|
|
@@ -680,7 +656,7 @@ function getOperationSignatureParameters(context, method, clientType) {
|
|
|
680
656
|
const optionsParam = {
|
|
681
657
|
name: parameters.has("options") ? "optionalParams" : "options",
|
|
682
658
|
type: optionsType,
|
|
683
|
-
initializer: "{ requestOptions: {} }"
|
|
659
|
+
initializer: "{ requestOptions: {} }",
|
|
684
660
|
};
|
|
685
661
|
const finalParameters = [contextParam, ...parameters.values(), optionsParam];
|
|
686
662
|
return finalParameters;
|
|
@@ -689,7 +665,6 @@ function getOperationSignatureParameters(context, method, clientType) {
|
|
|
689
665
|
* This operation builds and returns the function declaration for an operation.
|
|
690
666
|
*/
|
|
691
667
|
export function getOperationFunction(context, method, clientType) {
|
|
692
|
-
var _a, _b, _c, _d, _e;
|
|
693
668
|
const operation = method[1];
|
|
694
669
|
// Extract required parameters
|
|
695
670
|
const parameters = getOperationSignatureParameters(context, method, clientType);
|
|
@@ -710,8 +685,8 @@ export function getOperationFunction(context, method, clientType) {
|
|
|
710
685
|
const response = operation.response;
|
|
711
686
|
const responseHeaders = getResponseHeaders(operation.operation.responses);
|
|
712
687
|
const hasHeaderOnlyResponse = !response.type && responseHeaders.length > 0;
|
|
713
|
-
const isResponseHeadersEnabled =
|
|
714
|
-
const isStorageCompatEnabled =
|
|
688
|
+
const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
|
|
689
|
+
const isStorageCompatEnabled = context.rlcOptions?.enableStorageCompat === true;
|
|
715
690
|
// Track the raw body type separately for storage-compat (before header merging)
|
|
716
691
|
const hasResponseBody = !!response.type;
|
|
717
692
|
let bodyType = "void";
|
|
@@ -725,30 +700,26 @@ export function getOperationFunction(context, method, clientType) {
|
|
|
725
700
|
// Use the wrapper response type name (resolved via binder for cross-file imports)
|
|
726
701
|
returnType = {
|
|
727
702
|
name: getOperationResponseTypeName(method),
|
|
728
|
-
type: resolveReference(refkey(operation, "response"))
|
|
703
|
+
type: resolveReference(refkey(operation, "response")),
|
|
729
704
|
};
|
|
730
705
|
bodyType = returnType.type;
|
|
731
706
|
}
|
|
732
707
|
else if (response.type) {
|
|
733
708
|
const type = response.type;
|
|
734
709
|
// If feature flag enabled, we'll append the response headers to the operation response type.
|
|
735
|
-
if (type.kind === "model" &&
|
|
736
|
-
responseHeaders.length > 0 &&
|
|
737
|
-
isResponseHeadersEnabled) {
|
|
710
|
+
if (type.kind === "model" && responseHeaders.length > 0 && isResponseHeadersEnabled) {
|
|
738
711
|
// Build a composite type that includes both model and additional header properties
|
|
739
712
|
const baseCompositeType = buildCompositeResponseType(context, type, responseHeaders);
|
|
740
713
|
returnType = {
|
|
741
|
-
name:
|
|
742
|
-
type: response.optional
|
|
743
|
-
? `${baseCompositeType} | undefined`
|
|
744
|
-
: baseCompositeType
|
|
714
|
+
name: type.name ?? "",
|
|
715
|
+
type: response.optional ? `${baseCompositeType} | undefined` : baseCompositeType,
|
|
745
716
|
};
|
|
746
717
|
}
|
|
747
718
|
else {
|
|
748
719
|
const baseType = getTypeExpression(context, type);
|
|
749
720
|
returnType = {
|
|
750
|
-
name:
|
|
751
|
-
type: response.optional ? `${baseType} | undefined` : baseType
|
|
721
|
+
name: type.name ?? "",
|
|
722
|
+
type: response.optional ? `${baseType} | undefined` : baseType,
|
|
752
723
|
};
|
|
753
724
|
}
|
|
754
725
|
}
|
|
@@ -756,7 +727,7 @@ export function getOperationFunction(context, method, clientType) {
|
|
|
756
727
|
// Here we handle returning headers when the operation return type is void
|
|
757
728
|
returnType = {
|
|
758
729
|
name: "",
|
|
759
|
-
type: `${buildHeaderOnlyResponseType(context, responseHeaders)}
|
|
730
|
+
type: `${buildHeaderOnlyResponseType(context, responseHeaders)}`,
|
|
760
731
|
};
|
|
761
732
|
}
|
|
762
733
|
else if (isHeadAsBooleanOperation(operation)) {
|
|
@@ -794,16 +765,13 @@ export function getOperationFunction(context, method, clientType) {
|
|
|
794
765
|
const { name, fixme = [] } = getOperationName(operation, context);
|
|
795
766
|
const functionStatement = {
|
|
796
767
|
kind: StructureKind.Function,
|
|
797
|
-
docs: [
|
|
798
|
-
...getDocsFromDescription(operation.doc),
|
|
799
|
-
...getFixmeForMultilineDocs(fixme)
|
|
800
|
-
],
|
|
768
|
+
docs: [...getDocsFromDescription(operation.doc), ...getFixmeForMultilineDocs(fixme)],
|
|
801
769
|
isAsync: true,
|
|
802
770
|
isExported: true,
|
|
803
771
|
name,
|
|
804
772
|
propertyName: normalizeName(operation.name, NameType.Property),
|
|
805
773
|
parameters,
|
|
806
|
-
returnType: `Promise<${finalReturnType}
|
|
774
|
+
returnType: `Promise<${finalReturnType}>`,
|
|
807
775
|
};
|
|
808
776
|
const statements = [];
|
|
809
777
|
// Generate unique local variable names that don't conflict with parameter names
|
|
@@ -824,7 +792,7 @@ export function getOperationFunction(context, method, clientType) {
|
|
|
824
792
|
// doing a UTF-8 decode on the raw bytes.
|
|
825
793
|
// For binary wrap, use getBinaryStreamResponse which preserves blobBody/readableStreamBody properties.
|
|
826
794
|
// For non-wrapped binary, use getBinaryResponse which buffers the body into Uint8Array.
|
|
827
|
-
if (
|
|
795
|
+
if (response?.type?.kind === "bytes" && response.type.encode === "bytes") {
|
|
828
796
|
const streamableMethodVarName = generateLocallyUniqueName("streamableMethod", paramNames);
|
|
829
797
|
statements.push(`const ${streamableMethodVarName} = _${name}Send(${sendParameterList});`);
|
|
830
798
|
const binaryHelper = wrapReturn && wrapReturnIsBinary
|
|
@@ -876,7 +844,7 @@ export function getOperationFunction(context, method, clientType) {
|
|
|
876
844
|
}
|
|
877
845
|
return {
|
|
878
846
|
...functionStatement,
|
|
879
|
-
statements
|
|
847
|
+
statements,
|
|
880
848
|
};
|
|
881
849
|
}
|
|
882
850
|
function getLroOnlyOperationFunction(context, method, clientType, optionalParamName = "options") {
|
|
@@ -898,10 +866,7 @@ function getLroOnlyOperationFunction(context, method, clientType, optionalParamN
|
|
|
898
866
|
: returnType.type;
|
|
899
867
|
const functionStatement = {
|
|
900
868
|
kind: StructureKind.Function,
|
|
901
|
-
docs: [
|
|
902
|
-
...getDocsFromDescription(operation.doc),
|
|
903
|
-
...getFixmeForMultilineDocs(fixme)
|
|
904
|
-
],
|
|
869
|
+
docs: [...getDocsFromDescription(operation.doc), ...getFixmeForMultilineDocs(fixme)],
|
|
905
870
|
isAsync: false,
|
|
906
871
|
isExported: true,
|
|
907
872
|
name,
|
|
@@ -909,21 +874,18 @@ function getLroOnlyOperationFunction(context, method, clientType, optionalParamN
|
|
|
909
874
|
isLro: true,
|
|
910
875
|
lroFinalReturnType: effectiveReturnTypeName,
|
|
911
876
|
parameters,
|
|
912
|
-
returnType: `${pollerLikeReference}<${operationStateReference}<${effectiveReturnTypeStr}>, ${effectiveReturnTypeStr}
|
|
877
|
+
returnType: `${pollerLikeReference}<${operationStateReference}<${effectiveReturnTypeStr}>, ${effectiveReturnTypeStr}>`,
|
|
913
878
|
};
|
|
914
879
|
const getLongRunningPollerReference = resolveReference(PollingHelpers.GetLongRunningPoller);
|
|
915
|
-
const lroMetadata = operation.kind === "lro" || operation.kind === "lropaging"
|
|
916
|
-
? operation.lroMetadata
|
|
917
|
-
: undefined;
|
|
880
|
+
const lroMetadata = operation.kind === "lro" || operation.kind === "lropaging" ? operation.lroMetadata : undefined;
|
|
918
881
|
const allowedFinalLocation = [
|
|
919
882
|
"azure-async-operation",
|
|
920
883
|
"location",
|
|
921
884
|
"original-uri",
|
|
922
|
-
"operation-location"
|
|
885
|
+
"operation-location",
|
|
923
886
|
];
|
|
924
|
-
const resourceLocationConfig =
|
|
925
|
-
|
|
926
|
-
? `resourceLocationConfig: "${lroMetadata === null || lroMetadata === void 0 ? void 0 : lroMetadata.finalStateVia}",`
|
|
887
|
+
const resourceLocationConfig = lroMetadata?.finalStateVia && allowedFinalLocation.includes(lroMetadata?.finalStateVia)
|
|
888
|
+
? `resourceLocationConfig: "${lroMetadata?.finalStateVia}",`
|
|
927
889
|
: "";
|
|
928
890
|
const apiVersion = getApiVersionExpression(context, operation);
|
|
929
891
|
const statements = [];
|
|
@@ -932,20 +894,17 @@ function getLroOnlyOperationFunction(context, method, clientType, optionalParamN
|
|
|
932
894
|
return ${getLongRunningPollerReference}(context, _${name}Deserialize, ${getExpectedStatuses(operation)}, {
|
|
933
895
|
updateIntervalInMs: ${optionalParamName}?.updateIntervalInMs,
|
|
934
896
|
abortSignal: ${optionalParamName}?.abortSignal,
|
|
935
|
-
getInitialResponse: () => _${name}Send(${parameters
|
|
936
|
-
.map((p) => p.name)
|
|
937
|
-
.join(", ")}),
|
|
897
|
+
getInitialResponse: () => _${name}Send(${parameters.map((p) => p.name).join(", ")}),
|
|
938
898
|
${resourceLocationConfig}
|
|
939
899
|
${apiVersion ? `apiVersion: ${apiVersion}` : ""}
|
|
940
900
|
}) as ${pollerLikeReference}<${operationStateReference}<${effectiveReturnTypeStr}>, ${effectiveReturnTypeStr}>;
|
|
941
901
|
`);
|
|
942
902
|
return {
|
|
943
903
|
...functionStatement,
|
|
944
|
-
statements
|
|
904
|
+
statements,
|
|
945
905
|
};
|
|
946
906
|
}
|
|
947
907
|
function getLroAndPagingOperationFunction(context, method, clientType, optionalParamName = "options") {
|
|
948
|
-
var _a;
|
|
949
908
|
const operation = method[1];
|
|
950
909
|
const parameters = getOperationSignatureParameters(context, method, clientType);
|
|
951
910
|
const { name, fixme = [] } = getOperationName(operation, context);
|
|
@@ -960,16 +919,16 @@ function getLroAndPagingOperationFunction(context, method, clientType, optionalP
|
|
|
960
919
|
`nextLinkName: "${operation.pagingMetadata.nextLinkSegments.map((p) => p.name).join(".")}"`,
|
|
961
920
|
operation.pagingMetadata.nextLinkVerb !== "GET" &&
|
|
962
921
|
`nextLinkMethod: "${operation.pagingMetadata.nextLinkVerb}"`,
|
|
963
|
-
apiVersion && `apiVersion: ${apiVersion}
|
|
922
|
+
apiVersion && `apiVersion: ${apiVersion}`,
|
|
964
923
|
].filter(Boolean);
|
|
965
924
|
// Build LRO resource location config
|
|
966
925
|
const allowedLocations = [
|
|
967
926
|
"azure-async-operation",
|
|
968
927
|
"location",
|
|
969
928
|
"original-uri",
|
|
970
|
-
"operation-location"
|
|
929
|
+
"operation-location",
|
|
971
930
|
];
|
|
972
|
-
const resourceLocationConfig =
|
|
931
|
+
const resourceLocationConfig = operation.lroMetadata?.finalStateVia &&
|
|
973
932
|
allowedLocations.includes(operation.lroMetadata.finalStateVia)
|
|
974
933
|
? `resourceLocationConfig: "${operation.lroMetadata.finalStateVia}",`
|
|
975
934
|
: "";
|
|
@@ -980,17 +939,14 @@ function getLroAndPagingOperationFunction(context, method, clientType, optionalP
|
|
|
980
939
|
getLroPoller: resolveReference(PollingHelpers.GetLongRunningPoller),
|
|
981
940
|
pollerLike: resolveReference(AzurePollingDependencies.PollerLike),
|
|
982
941
|
operationState: resolveReference(AzurePollingDependencies.OperationState),
|
|
983
|
-
pathResponse: resolveReference(useDependencies().PathUncheckedResponse)
|
|
942
|
+
pathResponse: resolveReference(useDependencies().PathUncheckedResponse),
|
|
984
943
|
};
|
|
985
944
|
const expectedStatuses = getExpectedStatuses(operation);
|
|
986
945
|
const paramList = parameters.map((p) => p.name).join(", ");
|
|
987
946
|
const pagingOptionsStr = pagingOptions.length > 0 ? `,\n {${pagingOptions.join(", ")}}` : "";
|
|
988
947
|
return {
|
|
989
948
|
kind: StructureKind.Function,
|
|
990
|
-
docs: [
|
|
991
|
-
...getDocsFromDescription(operation.doc),
|
|
992
|
-
...getFixmeForMultilineDocs(fixme)
|
|
993
|
-
],
|
|
949
|
+
docs: [...getDocsFromDescription(operation.doc), ...getFixmeForMultilineDocs(fixme)],
|
|
994
950
|
isAsync: false,
|
|
995
951
|
isExported: true,
|
|
996
952
|
isLroPaging: true,
|
|
@@ -1017,8 +973,8 @@ function getLroAndPagingOperationFunction(context, method, clientType, optionalP
|
|
|
1017
973
|
_${name}Deserialize,
|
|
1018
974
|
${expectedStatuses}${pagingOptionsStr}
|
|
1019
975
|
);
|
|
1020
|
-
|
|
1021
|
-
]
|
|
976
|
+
`,
|
|
977
|
+
],
|
|
1022
978
|
};
|
|
1023
979
|
}
|
|
1024
980
|
function buildLroReturnType(context, operation) {
|
|
@@ -1027,23 +983,21 @@ function buildLroReturnType(context, operation) {
|
|
|
1027
983
|
const type = metadata.finalResponse.result;
|
|
1028
984
|
return {
|
|
1029
985
|
name: type.name,
|
|
1030
|
-
type: getTypeExpression(context, type)
|
|
986
|
+
type: getTypeExpression(context, type),
|
|
1031
987
|
};
|
|
1032
988
|
}
|
|
1033
989
|
return { name: "", type: "void" };
|
|
1034
990
|
}
|
|
1035
991
|
function buildLroPagingReturnType(context, operation) {
|
|
1036
|
-
|
|
1037
|
-
if (((_a = operation.response.type) === null || _a === void 0 ? void 0 : _a.kind) === "array") {
|
|
992
|
+
if (operation.response.type?.kind === "array") {
|
|
1038
993
|
return {
|
|
1039
|
-
name:
|
|
1040
|
-
type: getTypeExpression(context, operation.response.type.valueType)
|
|
994
|
+
name: operation.response.type.valueType.name ?? "",
|
|
995
|
+
type: getTypeExpression(context, operation.response.type.valueType),
|
|
1041
996
|
};
|
|
1042
997
|
}
|
|
1043
998
|
return { name: "", type: "void" };
|
|
1044
999
|
}
|
|
1045
1000
|
function getPagingOnlyOperationFunction(context, method, clientType) {
|
|
1046
|
-
var _a;
|
|
1047
1001
|
const operation = method[1];
|
|
1048
1002
|
// Extract required parameters
|
|
1049
1003
|
const parameters = getOperationSignatureParameters(context, method, clientType);
|
|
@@ -1053,8 +1007,8 @@ function getPagingOnlyOperationFunction(context, method, clientType) {
|
|
|
1053
1007
|
if (response.type && response.type.kind === "array") {
|
|
1054
1008
|
const type = response.type;
|
|
1055
1009
|
returnType = {
|
|
1056
|
-
name:
|
|
1057
|
-
type: getTypeExpression(context, type.valueType)
|
|
1010
|
+
name: type.valueType.name ?? "",
|
|
1011
|
+
type: getTypeExpression(context, type.valueType),
|
|
1058
1012
|
};
|
|
1059
1013
|
}
|
|
1060
1014
|
const { name, fixme = [] } = getOperationName(operation, context);
|
|
@@ -1062,28 +1016,29 @@ function getPagingOnlyOperationFunction(context, method, clientType) {
|
|
|
1062
1016
|
const buildPagedAsyncIteratorReference = resolveReference(PagingHelpers.BuildPagedAsyncIterator);
|
|
1063
1017
|
const functionStatement = {
|
|
1064
1018
|
kind: StructureKind.Function,
|
|
1065
|
-
docs: [
|
|
1066
|
-
...getDocsFromDescription(operation.doc),
|
|
1067
|
-
...getFixmeForMultilineDocs(fixme)
|
|
1068
|
-
],
|
|
1019
|
+
docs: [...getDocsFromDescription(operation.doc), ...getFixmeForMultilineDocs(fixme)],
|
|
1069
1020
|
isAsync: false,
|
|
1070
1021
|
isExported: true,
|
|
1071
1022
|
name,
|
|
1072
1023
|
propertyName: normalizeName(operation.name, NameType.Property),
|
|
1073
1024
|
parameters,
|
|
1074
|
-
returnType: `${pagedAsyncIterableIteratorReference}<${returnType.type}
|
|
1025
|
+
returnType: `${pagedAsyncIterableIteratorReference}<${returnType.type}>`,
|
|
1075
1026
|
};
|
|
1076
1027
|
const statements = [];
|
|
1077
1028
|
const options = [];
|
|
1078
1029
|
// TODO: follow up on https://github.com/Azure/typespec-azure/issues/2103
|
|
1079
1030
|
const nextLinkSegments = operation.pagingMetadata.nextLinkSegments;
|
|
1080
|
-
const nextLinkName = nextLinkSegments
|
|
1031
|
+
const nextLinkName = nextLinkSegments
|
|
1032
|
+
?.map((property) => {
|
|
1081
1033
|
return property.name;
|
|
1082
|
-
})
|
|
1034
|
+
})
|
|
1035
|
+
.join(".");
|
|
1083
1036
|
const itemSegments = operation.response.resultSegments;
|
|
1084
|
-
const itemName = itemSegments
|
|
1037
|
+
const itemName = itemSegments
|
|
1038
|
+
?.map((property) => {
|
|
1085
1039
|
return property.name;
|
|
1086
|
-
})
|
|
1040
|
+
})
|
|
1041
|
+
.join(".");
|
|
1087
1042
|
// Check for nextLinkVerb from TCGC pagingMetadata (supports @Legacy.nextLinkVerb decorator)
|
|
1088
1043
|
const nextLinkMethod = operation.pagingMetadata.nextLinkVerb;
|
|
1089
1044
|
const apiVersion = getApiVersionExpression(context, operation);
|
|
@@ -1107,7 +1062,7 @@ function getPagingOnlyOperationFunction(context, method, clientType) {
|
|
|
1107
1062
|
);`);
|
|
1108
1063
|
return {
|
|
1109
1064
|
...functionStatement,
|
|
1110
|
-
statements
|
|
1065
|
+
statements,
|
|
1111
1066
|
};
|
|
1112
1067
|
}
|
|
1113
1068
|
export function getOperationOptionsName(method, includeGroupName = false) {
|
|
@@ -1132,7 +1087,7 @@ function getHeaderAndBodyParameters(dpgContext, operation, optionalParamName = "
|
|
|
1132
1087
|
const contentTypeParameter = operation.operation.parameters.find(isContentType);
|
|
1133
1088
|
const parametersImplementation = {
|
|
1134
1089
|
header: [],
|
|
1135
|
-
body: []
|
|
1090
|
+
body: [],
|
|
1136
1091
|
};
|
|
1137
1092
|
for (const param of operationParameters) {
|
|
1138
1093
|
if (param.kind === "header") {
|
|
@@ -1147,13 +1102,12 @@ function getHeaderAndBodyParameters(dpgContext, operation, optionalParamName = "
|
|
|
1147
1102
|
continue;
|
|
1148
1103
|
}
|
|
1149
1104
|
// Check if this parameter still exists in the corresponding method params (after override)
|
|
1150
|
-
if (param.methodParameterSegments &&
|
|
1151
|
-
param.methodParameterSegments.length > 0) {
|
|
1105
|
+
if (param.methodParameterSegments && param.methodParameterSegments.length > 0) {
|
|
1152
1106
|
const paramAccessor = getParamAccessor(param, optionalParamName);
|
|
1153
1107
|
parametersImplementation[param.kind].push({
|
|
1154
1108
|
paramMap: getParameterMap(dpgContext, param, paramAccessor),
|
|
1155
1109
|
param,
|
|
1156
|
-
paramAccessor
|
|
1110
|
+
paramAccessor,
|
|
1157
1111
|
});
|
|
1158
1112
|
}
|
|
1159
1113
|
}
|
|
@@ -1167,8 +1121,7 @@ function getHeaderAndBodyParameters(dpgContext, operation, optionalParamName = "
|
|
|
1167
1121
|
.map((i) => buildHeaderParameter(dpgContext.program, i.paramMap, i.param, i.paramAccessor))
|
|
1168
1122
|
.join(",\n")}, ...${optionalParamName}.requestOptions?.headers },`;
|
|
1169
1123
|
}
|
|
1170
|
-
if (operation.operation.bodyParam === undefined &&
|
|
1171
|
-
parametersImplementation.body.length) {
|
|
1124
|
+
if (operation.operation.bodyParam === undefined && parametersImplementation.body.length) {
|
|
1172
1125
|
paramStr = `${paramStr}\nbody: {${parametersImplementation.body
|
|
1173
1126
|
.map((i) => i.paramMap)
|
|
1174
1127
|
.join(",\n")}}`;
|
|
@@ -1184,7 +1137,7 @@ function buildHeaderParameter(program, paramMap, param, paramAccessor) {
|
|
|
1184
1137
|
if (!effectiveOptional && isTypeNullable(param.type) === true) {
|
|
1185
1138
|
reportDiagnostic(program, {
|
|
1186
1139
|
code: "nullable-required-header",
|
|
1187
|
-
target: NoTarget
|
|
1140
|
+
target: NoTarget,
|
|
1188
1141
|
});
|
|
1189
1142
|
return paramMap;
|
|
1190
1143
|
}
|
|
@@ -1199,9 +1152,7 @@ function buildHeaderParameter(program, paramMap, param, paramAccessor) {
|
|
|
1199
1152
|
if (isTypeNullable(param.type) === true) {
|
|
1200
1153
|
conditions.push(`${paramAccessor} !== null`);
|
|
1201
1154
|
}
|
|
1202
|
-
return conditions.length > 0
|
|
1203
|
-
? `...(${conditions.join(" && ")} ? {${paramMap}} : {})`
|
|
1204
|
-
: paramMap;
|
|
1155
|
+
return conditions.length > 0 ? `...(${conditions.join(" && ")} ? {${paramMap}} : {})` : paramMap;
|
|
1205
1156
|
}
|
|
1206
1157
|
function buildBodyParameter(context, bodyParameter, optionalParamName = "options") {
|
|
1207
1158
|
if (!bodyParameter || !bodyParameter.type) {
|
|
@@ -1218,14 +1169,14 @@ function buildBodyParameter(context, bodyParameter, optionalParamName = "options
|
|
|
1218
1169
|
// Use XML serializer
|
|
1219
1170
|
serializerFunctionName = buildXmlModelSerializer(context, bodyType, {
|
|
1220
1171
|
nameOnly: true,
|
|
1221
|
-
skipDiscriminatedUnionSuffix: false
|
|
1172
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1222
1173
|
});
|
|
1223
1174
|
}
|
|
1224
1175
|
else {
|
|
1225
1176
|
// Use JSON serializer (default)
|
|
1226
1177
|
serializerFunctionName = buildModelSerializer(context, bodyType, {
|
|
1227
1178
|
nameOnly: true,
|
|
1228
|
-
skipDiscriminatedUnionSuffix: false
|
|
1179
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1229
1180
|
});
|
|
1230
1181
|
}
|
|
1231
1182
|
let bodyNameExpression = getParamAccessor(bodyParameter, optionalParamName);
|
|
@@ -1247,16 +1198,14 @@ function buildBodyParameter(context, bodyParameter, optionalParamName = "options
|
|
|
1247
1198
|
? `!${bodyNameExpression}? ${bodyNameExpression}:`
|
|
1248
1199
|
: "";
|
|
1249
1200
|
// For dual-format operations, check the contentType option at runtime
|
|
1250
|
-
if (isDualFormat &&
|
|
1251
|
-
bodyType.kind === "model" &&
|
|
1252
|
-
hasXmlSerialization(bodyType)) {
|
|
1201
|
+
if (isDualFormat && bodyType.kind === "model" && hasXmlSerialization(bodyType)) {
|
|
1253
1202
|
const xmlSerializerName = buildXmlModelSerializer(context, bodyType, {
|
|
1254
1203
|
nameOnly: true,
|
|
1255
|
-
skipDiscriminatedUnionSuffix: false
|
|
1204
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1256
1205
|
});
|
|
1257
1206
|
const jsonSerializerName = buildModelSerializer(context, bodyType, {
|
|
1258
1207
|
nameOnly: true,
|
|
1259
|
-
skipDiscriminatedUnionSuffix: false
|
|
1208
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1260
1209
|
});
|
|
1261
1210
|
if (xmlSerializerName && jsonSerializerName) {
|
|
1262
1211
|
const isXmlContentTypeRef = resolveReference(XmlHelpers.isXmlContentType);
|
|
@@ -1276,9 +1225,8 @@ function buildBodyParameter(context, bodyParameter, optionalParamName = "options
|
|
|
1276
1225
|
return `\nbody: ${serializedBody.startsWith(nullOrUndefinedPrefix) ? "" : nullOrUndefinedPrefix}${serializedBody},`;
|
|
1277
1226
|
}
|
|
1278
1227
|
function getEncodingFormat(type) {
|
|
1279
|
-
var _a;
|
|
1280
1228
|
const supportedFormats = ["base64url", "base64", "byte"];
|
|
1281
|
-
if (!supportedFormats.includes(
|
|
1229
|
+
if (!supportedFormats.includes(type.format ?? "")) {
|
|
1282
1230
|
return "base64";
|
|
1283
1231
|
}
|
|
1284
1232
|
return type.format;
|
|
@@ -1287,18 +1235,15 @@ function getEncodingFormat(type) {
|
|
|
1287
1235
|
* This function helps with renames, translating client names to rest api names
|
|
1288
1236
|
*/
|
|
1289
1237
|
export function getParameterMap(context, param, paramAccessor) {
|
|
1290
|
-
var _a;
|
|
1291
1238
|
// Use lowercase for header names since HTTP headers are case-insensitive
|
|
1292
|
-
const serializedName = param.kind === "header"
|
|
1293
|
-
? getHeaderSerializedName(param)
|
|
1294
|
-
: getPropertySerializedName(param);
|
|
1239
|
+
const serializedName = param.kind === "header" ? getHeaderSerializedName(param) : getPropertySerializedName(param);
|
|
1295
1240
|
if (isConstant(param.type) && !isOptional(param)) {
|
|
1296
1241
|
return `"${serializedName}": ${getConstantValue(param.type)}`;
|
|
1297
1242
|
}
|
|
1298
1243
|
// Special case for api-version parameters with default values
|
|
1299
1244
|
if (param.isApiVersionParam && param.clientDefaultValue) {
|
|
1300
1245
|
// For multi-service, use only the default value (don't reference context.apiVersion)
|
|
1301
|
-
if (
|
|
1246
|
+
if (context.rlcOptions?.isMultiService) {
|
|
1302
1247
|
return `"${serializedName}": "${param.clientDefaultValue}"`;
|
|
1303
1248
|
}
|
|
1304
1249
|
return `"${serializedName}": ${param.onClient ? "context." : ""}${param.name} ?? "${param.clientDefaultValue}"`;
|
|
@@ -1317,9 +1262,9 @@ export function getParameterMap(context, param, paramAccessor) {
|
|
|
1317
1262
|
code: "unsupported-parameter-type",
|
|
1318
1263
|
format: {
|
|
1319
1264
|
paramName: param.name,
|
|
1320
|
-
paramKind: param.kind
|
|
1265
|
+
paramKind: param.kind,
|
|
1321
1266
|
},
|
|
1322
|
-
target: param.__raw || NoTarget
|
|
1267
|
+
target: param.__raw || NoTarget,
|
|
1323
1268
|
});
|
|
1324
1269
|
// Return a fallback value to allow the emitter to continue
|
|
1325
1270
|
return `"${param.name}": undefined`;
|
|
@@ -1329,8 +1274,7 @@ function getCollectionFormatForParam(context, param, paramAccessor, serializedNa
|
|
|
1329
1274
|
return `"${serializedName}": ${serializeRequestValue(context, param.type, paramAccessor, !param.optional, format, serializedName, true)}`;
|
|
1330
1275
|
}
|
|
1331
1276
|
function isContentType(param) {
|
|
1332
|
-
return
|
|
1333
|
-
param.serializedName.toLowerCase() === "content-type");
|
|
1277
|
+
return param.kind === "header" && param.serializedName.toLowerCase() === "content-type";
|
|
1334
1278
|
}
|
|
1335
1279
|
function getContentTypeValue(param, optionalParamName = "options") {
|
|
1336
1280
|
const defaultValue = param.clientDefaultValue;
|
|
@@ -1355,15 +1299,14 @@ function getContentTypeValue(param, optionalParamName = "options") {
|
|
|
1355
1299
|
* For client-level parameters (onClient), preserve the HTTP parameter's own flag.
|
|
1356
1300
|
*/
|
|
1357
1301
|
function getEffectiveOptional(param) {
|
|
1358
|
-
var _a, _b;
|
|
1359
1302
|
// For client-level parameters, the HTTP parameter's optional flag is authoritative
|
|
1360
1303
|
if (param.onClient) {
|
|
1361
1304
|
return Boolean(param.optional);
|
|
1362
1305
|
}
|
|
1363
1306
|
// For method-level parameters with a direct mapping to a single method param,
|
|
1364
1307
|
// use the method parameter's optional flag (correctly reflects @@override changes)
|
|
1365
|
-
if (
|
|
1366
|
-
|
|
1308
|
+
if (param.methodParameterSegments?.length === 1 &&
|
|
1309
|
+
param.methodParameterSegments[0]?.length === 1) {
|
|
1367
1310
|
const methodParam = param.methodParameterSegments[0][0];
|
|
1368
1311
|
if (methodParam) {
|
|
1369
1312
|
return Boolean(methodParam.optional);
|
|
@@ -1428,14 +1371,13 @@ function getDefaultValue(param) {
|
|
|
1428
1371
|
* Extracts the path parameters
|
|
1429
1372
|
*/
|
|
1430
1373
|
function getPathParameters(operation, optionalParamName = "options") {
|
|
1431
|
-
var _a;
|
|
1432
1374
|
if (!operation.operation.parameters) {
|
|
1433
1375
|
return [];
|
|
1434
1376
|
}
|
|
1435
1377
|
const pathParams = [];
|
|
1436
1378
|
for (const param of operation.operation.parameters) {
|
|
1437
1379
|
if (param.kind === "path") {
|
|
1438
|
-
const methodParam =
|
|
1380
|
+
const methodParam = param.methodParameterSegments[0]?.[0];
|
|
1439
1381
|
if (methodParam) {
|
|
1440
1382
|
pathParams.push(`"${param.serializedName}": ${getPathParamExpr(param, getDefaultValue(param), optionalParamName)}`);
|
|
1441
1383
|
}
|
|
@@ -1452,22 +1394,21 @@ function getQueryParameters(dpgContext, operation) {
|
|
|
1452
1394
|
}
|
|
1453
1395
|
const operationParameters = operation.operation.parameters.filter((p) => !isContentType(p));
|
|
1454
1396
|
const parametersImplementation = {
|
|
1455
|
-
query: []
|
|
1397
|
+
query: [],
|
|
1456
1398
|
};
|
|
1457
1399
|
for (const param of operationParameters) {
|
|
1458
1400
|
if (param.kind === "query") {
|
|
1459
1401
|
// Check if this parameter still exists in the corresponding method params (after override)
|
|
1460
|
-
if (param.methodParameterSegments &&
|
|
1461
|
-
param.methodParameterSegments.length > 0) {
|
|
1402
|
+
if (param.methodParameterSegments && param.methodParameterSegments.length > 0) {
|
|
1462
1403
|
const paramAccessor = getParamAccessor(param);
|
|
1463
1404
|
parametersImplementation[param.kind].push({
|
|
1464
1405
|
paramMap: getParameterMap(dpgContext, {
|
|
1465
1406
|
...param,
|
|
1466
1407
|
// TODO: remember to remove this hack once compiler gives us a name
|
|
1467
1408
|
// https://github.com/microsoft/typespec/issues/6743
|
|
1468
|
-
serializedName: getUriTemplateQueryParamName(param.serializedName)
|
|
1409
|
+
serializedName: getUriTemplateQueryParamName(param.serializedName),
|
|
1469
1410
|
}, paramAccessor),
|
|
1470
|
-
param
|
|
1411
|
+
param,
|
|
1471
1412
|
});
|
|
1472
1413
|
}
|
|
1473
1414
|
}
|
|
@@ -1497,9 +1438,7 @@ function getParamAccessor(param, optionalParamName = "options") {
|
|
|
1497
1438
|
const methodParamExpr = getMethodParamExpr(param, optionalParamName);
|
|
1498
1439
|
const clientPrefix = "context.";
|
|
1499
1440
|
if (methodParamExpr) {
|
|
1500
|
-
return param.onClient
|
|
1501
|
-
? `${clientPrefix}${methodParamExpr}`
|
|
1502
|
-
: methodParamExpr;
|
|
1441
|
+
return param.onClient ? `${clientPrefix}${methodParamExpr}` : methodParamExpr;
|
|
1503
1442
|
}
|
|
1504
1443
|
if (param.onClient) {
|
|
1505
1444
|
return `${clientPrefix}${getClientParameterName(param)}`;
|
|
@@ -1578,15 +1517,14 @@ function getEncodeForModelProperty(context, property) {
|
|
|
1578
1517
|
code: "un-supported-array-encoding",
|
|
1579
1518
|
format: {
|
|
1580
1519
|
arrayName: property.name,
|
|
1581
|
-
arrayType: property.type.valueType.kind
|
|
1520
|
+
arrayType: property.type.valueType.kind,
|
|
1582
1521
|
},
|
|
1583
|
-
target: NoTarget
|
|
1522
|
+
target: NoTarget,
|
|
1584
1523
|
});
|
|
1585
1524
|
return getEncodeForType(property.type);
|
|
1586
1525
|
}
|
|
1587
1526
|
const collectionFormat = getCollectionFormatFromArrayEncoding(property.encode);
|
|
1588
|
-
if (collectionFormat &&
|
|
1589
|
-
hasCollectionFormatInfo(property.kind, collectionFormat)) {
|
|
1527
|
+
if (collectionFormat && hasCollectionFormatInfo(property.kind, collectionFormat)) {
|
|
1590
1528
|
return collectionFormat;
|
|
1591
1529
|
}
|
|
1592
1530
|
}
|
|
@@ -1602,8 +1540,7 @@ function isStringEncodableArrayValueType(valueType) {
|
|
|
1602
1540
|
return true;
|
|
1603
1541
|
}
|
|
1604
1542
|
// String-based enum type
|
|
1605
|
-
if (valueType.kind === "enum" &&
|
|
1606
|
-
valueType.valueType.kind === "string") {
|
|
1543
|
+
if (valueType.kind === "enum" && valueType.valueType.kind === "string") {
|
|
1607
1544
|
return true;
|
|
1608
1545
|
}
|
|
1609
1546
|
return false;
|
|
@@ -1611,14 +1548,12 @@ function isStringEncodableArrayValueType(valueType) {
|
|
|
1611
1548
|
function getSerializationExpressionForFlatten(context, property, propertyPath) {
|
|
1612
1549
|
const serializeFunctionName = buildPropertySerializer(context, property, {
|
|
1613
1550
|
nameOnly: true,
|
|
1614
|
-
skipDiscriminatedUnionSuffix: false
|
|
1551
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1615
1552
|
});
|
|
1616
1553
|
if (!serializeFunctionName) {
|
|
1617
1554
|
return property.optional ? `undefined` : `{}`;
|
|
1618
1555
|
}
|
|
1619
|
-
const validProps = getAllProperties(context, property.type, getAllAncestors(property.type)).filter((p) => p.kind === "property" &&
|
|
1620
|
-
!isReadOnly(p) &&
|
|
1621
|
-
!isMetadata(context.program, p.__raw));
|
|
1556
|
+
const validProps = getAllProperties(context, property.type, getAllAncestors(property.type)).filter((p) => p.kind === "property" && !isReadOnly(p) && !isMetadata(context.program, p.__raw));
|
|
1622
1557
|
const optionalPrefix = property.optional
|
|
1623
1558
|
? `${resolveReference(SerializationHelpers.areAllPropsUndefined)}(${propertyPath}, [${validProps
|
|
1624
1559
|
.map((p) => `"${p.name}"`)
|
|
@@ -1636,7 +1571,7 @@ export function getSerializationExpression(context, property, propertyPath, enab
|
|
|
1636
1571
|
const propertyFullName = getPropertyFullName(context, property, propertyPathWithDot);
|
|
1637
1572
|
const serializeFunctionName = buildModelSerializer(context, getNullableValidType(property.type), {
|
|
1638
1573
|
nameOnly: true,
|
|
1639
|
-
skipDiscriminatedUnionSuffix: false
|
|
1574
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1640
1575
|
});
|
|
1641
1576
|
// Apply clientDefaultValue for model properties that have one
|
|
1642
1577
|
const defaultValueSuffix = hasEffectiveClientDefaultValue(property)
|
|
@@ -1654,10 +1589,9 @@ export function getSerializationExpression(context, property, propertyPath, enab
|
|
|
1654
1589
|
}
|
|
1655
1590
|
}
|
|
1656
1591
|
export function getRequestModelProperties(context, modelPropertyType, propertyPath = "body", overrides, enableFlatten = true) {
|
|
1657
|
-
var _a;
|
|
1658
1592
|
const props = [];
|
|
1659
1593
|
const allParents = getAllAncestors(modelPropertyType);
|
|
1660
|
-
const properties =
|
|
1594
|
+
const properties = getAllProperties(context, modelPropertyType, allParents) ?? [];
|
|
1661
1595
|
if (properties.length <= 0) {
|
|
1662
1596
|
return [];
|
|
1663
1597
|
}
|
|
@@ -1671,7 +1605,7 @@ export function getRequestModelProperties(context, modelPropertyType, propertyPa
|
|
|
1671
1605
|
const property = getPropertyWithOverrides(prop, overrides);
|
|
1672
1606
|
props.push([
|
|
1673
1607
|
getPropertySerializedName(property),
|
|
1674
|
-
getSerializationExpression(context, property, propertyPath, enableFlatten)
|
|
1608
|
+
getSerializationExpression(context, property, propertyPath, enableFlatten),
|
|
1675
1609
|
]);
|
|
1676
1610
|
}
|
|
1677
1611
|
return props;
|
|
@@ -1685,10 +1619,9 @@ export function getRequestModelMapping(context, modelPropertyType, propertyPath
|
|
|
1685
1619
|
return getRequestModelProperties(context, modelPropertyType, propertyPath, overrides, enableFlatten).map(([name, value]) => `"${name}": ${value}`);
|
|
1686
1620
|
}
|
|
1687
1621
|
export function getPropertySerializedName(property) {
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
: property.serializedName)) !== null && _b !== void 0 ? _b : property.name);
|
|
1622
|
+
return ((property.kind === "property"
|
|
1623
|
+
? property.serializationOptions.json?.name
|
|
1624
|
+
: property.serializedName) ?? property.name);
|
|
1692
1625
|
}
|
|
1693
1626
|
/**
|
|
1694
1627
|
* Get the serialized name for a header parameter, normalized to lowercase.
|
|
@@ -1713,19 +1646,17 @@ export function getResponseMapping(context, type, propertyPath = "result.body",
|
|
|
1713
1646
|
const dot = propertyPath.endsWith("?") ? "." : "";
|
|
1714
1647
|
const serializedName = getPropertySerializedName(property);
|
|
1715
1648
|
const restValue = `${propertyPath ? `${propertyPath}${dot}` : `${dot}`}["${serializedName}"]`;
|
|
1716
|
-
const nullOrUndefinedPrefix = property.optional || isTypeNullable(property.type)
|
|
1717
|
-
? `!${restValue}? ${restValue}: `
|
|
1718
|
-
: "";
|
|
1649
|
+
const nullOrUndefinedPrefix = property.optional || isTypeNullable(property.type) ? `!${restValue}? ${restValue}: ` : "";
|
|
1719
1650
|
const flattenContext = useContext("sdkTypes").flattenProperties.get(property);
|
|
1720
1651
|
const isSupportedFlatten = flattenContext && enableFlatten;
|
|
1721
1652
|
const deserializeFunctionName = isSupportedFlatten
|
|
1722
1653
|
? buildPropertyDeserializer(context, property, {
|
|
1723
1654
|
nameOnly: true,
|
|
1724
|
-
skipDiscriminatedUnionSuffix: false
|
|
1655
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1725
1656
|
})
|
|
1726
1657
|
: buildModelDeserializer(context, getNullableValidType(property.type), {
|
|
1727
1658
|
nameOnly: true,
|
|
1728
|
-
skipDiscriminatedUnionSuffix: false
|
|
1659
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1729
1660
|
});
|
|
1730
1661
|
const propertyName = normalizeModelPropertyName(context, property);
|
|
1731
1662
|
if (deserializeFunctionName) {
|
|
@@ -1750,7 +1681,6 @@ export function getResponseMapping(context, type, propertyPath = "result.body",
|
|
|
1750
1681
|
* Converts JavaScript values to their serialized wire format for HTTP requests.
|
|
1751
1682
|
*/
|
|
1752
1683
|
export function serializeRequestValue(context, type, clientValue, required, format, serializedName, isTopLevel = false) {
|
|
1753
|
-
var _a, _b, _c, _d, _e;
|
|
1754
1684
|
const getSdkType = useSdkTypes();
|
|
1755
1685
|
const dependencies = useDependencies();
|
|
1756
1686
|
const nullOrUndefinedPrefix = isTypeNullable(type) || getOptionalForType(type) || !required
|
|
@@ -1761,7 +1691,7 @@ export function serializeRequestValue(context, type, clientValue, required, form
|
|
|
1761
1691
|
// plainDate always uses ISO8601 format (YYYY-MM-DD)
|
|
1762
1692
|
return `${nullOrUndefinedPrefix}${clientValue}.toISOString().split('T')[0]`;
|
|
1763
1693
|
case "utcDateTime":
|
|
1764
|
-
switch (
|
|
1694
|
+
switch (type.encode ?? format) {
|
|
1765
1695
|
case "rfc7231":
|
|
1766
1696
|
return `${nullOrUndefinedPrefix}${clientValue}.toUTCString()`;
|
|
1767
1697
|
case "unixTimestamp":
|
|
@@ -1773,12 +1703,10 @@ export function serializeRequestValue(context, type, clientValue, required, form
|
|
|
1773
1703
|
case "array": {
|
|
1774
1704
|
if (type.valueType) {
|
|
1775
1705
|
const prefix = nullOrUndefinedPrefix + clientValue;
|
|
1776
|
-
const elementNullOrUndefinedPrefix = isTypeNullable(type.valueType) || getOptionalForType(type.valueType)
|
|
1777
|
-
? "!p ? p : "
|
|
1778
|
-
: "";
|
|
1706
|
+
const elementNullOrUndefinedPrefix = isTypeNullable(type.valueType) || getOptionalForType(type.valueType) ? "!p ? p : " : "";
|
|
1779
1707
|
const serializeFunctionName = buildModelSerializer(context, getNullableValidType(type.valueType), {
|
|
1780
1708
|
nameOnly: true,
|
|
1781
|
-
skipDiscriminatedUnionSuffix: false
|
|
1709
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1782
1710
|
});
|
|
1783
1711
|
if (serializeFunctionName) {
|
|
1784
1712
|
return `${prefix}.map((p: any) => { return ${elementNullOrUndefinedPrefix}${serializeFunctionName}(p)})`;
|
|
@@ -1791,7 +1719,7 @@ export function serializeRequestValue(context, type, clientValue, required, form
|
|
|
1791
1719
|
if (format) {
|
|
1792
1720
|
const formatHelper = getCollectionFormatHelper(format);
|
|
1793
1721
|
if (formatHelper) {
|
|
1794
|
-
if (
|
|
1722
|
+
if (format?.toLowerCase() === KnownCollectionFormat.Multi) {
|
|
1795
1723
|
return `${nullOrUndefinedPrefix}${formatHelper}(${serializedValue}, "${serializedName}")`;
|
|
1796
1724
|
}
|
|
1797
1725
|
return `${nullOrUndefinedPrefix}${formatHelper}(${serializedValue})`;
|
|
@@ -1807,8 +1735,8 @@ export function serializeRequestValue(context, type, clientValue, required, form
|
|
|
1807
1735
|
if (format !== "binary" && format !== "bytes") {
|
|
1808
1736
|
const uint8ArrayToStringReference = resolveReference(dependencies.uint8ArrayToString);
|
|
1809
1737
|
return required
|
|
1810
|
-
? `${getNullableCheck(clientValue, type)} ${uint8ArrayToStringReference}(${clientValue}, "${
|
|
1811
|
-
: `${nullOrUndefinedPrefix} ${uint8ArrayToStringReference}(${clientValue}, "${
|
|
1738
|
+
? `${getNullableCheck(clientValue, type)} ${uint8ArrayToStringReference}(${clientValue}, "${getEncodingFormat({ format }) ?? "base64"}")`
|
|
1739
|
+
: `${nullOrUndefinedPrefix} ${uint8ArrayToStringReference}(${clientValue}, "${getEncodingFormat({ format }) ?? "base64"}")`;
|
|
1812
1740
|
}
|
|
1813
1741
|
return clientValue;
|
|
1814
1742
|
case "union":
|
|
@@ -1817,7 +1745,7 @@ export function serializeRequestValue(context, type, clientValue, required, form
|
|
|
1817
1745
|
}
|
|
1818
1746
|
else if (isSpecialHandledUnion({
|
|
1819
1747
|
...type,
|
|
1820
|
-
isNonExhaustive:
|
|
1748
|
+
isNonExhaustive: context.rlcOptions?.experimentalExtensibleEnums ?? false,
|
|
1821
1749
|
})) {
|
|
1822
1750
|
const sdkType = getSdkType(type.__raw);
|
|
1823
1751
|
const serializerRefkey = refkey(sdkType, "serializer");
|
|
@@ -1881,7 +1809,7 @@ export function deserializeResponseHeadersValue(context, type, restValue, requir
|
|
|
1881
1809
|
const deserializeFunctionName = type
|
|
1882
1810
|
? buildModelDeserializer(context, getNullableValidType(type), {
|
|
1883
1811
|
nameOnly: true,
|
|
1884
|
-
skipDiscriminatedUnionSuffix: false
|
|
1812
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1885
1813
|
})
|
|
1886
1814
|
: undefined;
|
|
1887
1815
|
if (deserializeFunctionName) {
|
|
@@ -1928,14 +1856,13 @@ export function deserializeResponseValue(context, type, restValue, required, for
|
|
|
1928
1856
|
const deserializeFunctionName = type.valueType
|
|
1929
1857
|
? buildModelDeserializer(context, getNullableValidType(type.valueType), {
|
|
1930
1858
|
nameOnly: true,
|
|
1931
|
-
skipDiscriminatedUnionSuffix: false
|
|
1859
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1932
1860
|
})
|
|
1933
1861
|
: undefined;
|
|
1934
1862
|
if (deserializeFunctionName) {
|
|
1935
1863
|
return `${prefix}.map((${varName}: any) => { return ${elementNullOrUndefinedPrefix}${deserializeFunctionName}(${varName})})`;
|
|
1936
1864
|
}
|
|
1937
|
-
else if (type.valueType &&
|
|
1938
|
-
isAzureCoreErrorType(context.program, type.valueType.__raw)) {
|
|
1865
|
+
else if (type.valueType && isAzureCoreErrorType(context.program, type.valueType.__raw)) {
|
|
1939
1866
|
return `${prefix}.map((${varName}: any) => { return ${elementNullOrUndefinedPrefix}${varName}})`;
|
|
1940
1867
|
}
|
|
1941
1868
|
else if (type.valueType) {
|
|
@@ -1946,8 +1873,7 @@ export function deserializeResponseValue(context, type, restValue, required, for
|
|
|
1946
1873
|
const optionalPrefixForString = isTypeNullable(type) || getOptionalForType(type) || !required
|
|
1947
1874
|
? `${restValue} === null || ${restValue} === undefined ? ${restValue}: `
|
|
1948
1875
|
: "";
|
|
1949
|
-
if (type.valueType.kind === "enum" &&
|
|
1950
|
-
!isExtensibleEnum(context, type.valueType)) {
|
|
1876
|
+
if (type.valueType.kind === "enum" && !isExtensibleEnum(context, type.valueType)) {
|
|
1951
1877
|
// Special handling for non-extensible enums to cast the result to the correct type
|
|
1952
1878
|
return `${optionalPrefixForString}${parseHelper}(${restValue}) as ${getTypeExpression(context, type)}`;
|
|
1953
1879
|
}
|
|
@@ -1973,14 +1899,13 @@ export function deserializeResponseValue(context, type, restValue, required, for
|
|
|
1973
1899
|
const deserializeFunctionName = type.valueType
|
|
1974
1900
|
? buildModelDeserializer(context, getNullableValidType(type.valueType), {
|
|
1975
1901
|
nameOnly: true,
|
|
1976
|
-
skipDiscriminatedUnionSuffix: false
|
|
1902
|
+
skipDiscriminatedUnionSuffix: false,
|
|
1977
1903
|
})
|
|
1978
1904
|
: undefined;
|
|
1979
1905
|
if (deserializeFunctionName) {
|
|
1980
1906
|
return `${nullOrUndefinedPrefix}Object.fromEntries(Object.entries(${restValue}).map(([${keyVar}, ${valueVar}]: [string, any]) => [${keyVar}, ${elementNullOrUndefinedPrefix}${deserializeFunctionName}(${valueVar})]))`;
|
|
1981
1907
|
}
|
|
1982
|
-
else if (type.valueType &&
|
|
1983
|
-
isAzureCoreErrorType(context.program, type.valueType.__raw)) {
|
|
1908
|
+
else if (type.valueType && isAzureCoreErrorType(context.program, type.valueType.__raw)) {
|
|
1984
1909
|
return `${nullOrUndefinedPrefix}Object.fromEntries(Object.entries(${restValue}).map(([${keyVar}, ${valueVar}]: [string, any]) => [${keyVar}, ${elementNullOrUndefinedPrefix}${valueVar}]))`;
|
|
1985
1910
|
}
|
|
1986
1911
|
else if (type.valueType) {
|
|
@@ -1993,7 +1918,7 @@ export function deserializeResponseValue(context, type, restValue, required, for
|
|
|
1993
1918
|
case "bytes":
|
|
1994
1919
|
if (format !== "binary" && format !== "bytes") {
|
|
1995
1920
|
return `${nullOrUndefinedPrefix}typeof ${restValue} === 'string'
|
|
1996
|
-
? ${stringToUint8ArrayReference}(${restValue}, "${format
|
|
1921
|
+
? ${stringToUint8ArrayReference}(${restValue}, "${format ?? "base64"}")
|
|
1997
1922
|
: ${restValue}`;
|
|
1998
1923
|
}
|
|
1999
1924
|
return restValue;
|
|
@@ -2005,7 +1930,7 @@ export function deserializeResponseValue(context, type, restValue, required, for
|
|
|
2005
1930
|
const deserializeFunctionName = type
|
|
2006
1931
|
? buildModelDeserializer(context, getNullableValidType(type), {
|
|
2007
1932
|
nameOnly: true,
|
|
2008
|
-
skipDiscriminatedUnionSuffix: false
|
|
1933
|
+
skipDiscriminatedUnionSuffix: false,
|
|
2009
1934
|
})
|
|
2010
1935
|
: undefined;
|
|
2011
1936
|
if (deserializeFunctionName) {
|
|
@@ -2040,7 +1965,7 @@ export function getAllProperties(context, type, parents) {
|
|
|
2040
1965
|
if (!type) {
|
|
2041
1966
|
return [];
|
|
2042
1967
|
}
|
|
2043
|
-
parents
|
|
1968
|
+
parents?.forEach((p) => {
|
|
2044
1969
|
getAllProperties(context, p).forEach((prop) => {
|
|
2045
1970
|
propertiesMap.set(prop.name, prop);
|
|
2046
1971
|
});
|
|
@@ -2120,9 +2045,7 @@ export function getPropertySerializationPrefix(context, property, propertyPath)
|
|
|
2120
2045
|
export function getPropertyFullName(context, property, propertyPath) {
|
|
2121
2046
|
const normalizedPropertyName = propertyPath === ""
|
|
2122
2047
|
? normalizeName(property.name, NameType.Parameter, true)
|
|
2123
|
-
: normalizeModelPropertyName(context, property)
|
|
2124
|
-
.replace(/^"/g, "")
|
|
2125
|
-
.replace(/"$/g, "");
|
|
2048
|
+
: normalizeModelPropertyName(context, property).replace(/^"/g, "").replace(/"$/g, "");
|
|
2126
2049
|
let fullName = normalizedPropertyName;
|
|
2127
2050
|
if (propertyPath === "" && property.optional) {
|
|
2128
2051
|
fullName = `options?.${normalizedPropertyName}`;
|
|
@@ -2165,13 +2088,12 @@ export function getExpectedStatuses(operation) {
|
|
|
2165
2088
|
* @returns The apiVersion expression string, or undefined if no apiVersion query param exists
|
|
2166
2089
|
*/
|
|
2167
2090
|
function getApiVersionExpression(dpgContext, operation) {
|
|
2168
|
-
var _a;
|
|
2169
2091
|
const queryApiVersionParam = operation.operation.parameters.find((p) => p.kind === "query" && p.isApiVersionParam);
|
|
2170
2092
|
if (!queryApiVersionParam) {
|
|
2171
2093
|
return undefined;
|
|
2172
2094
|
}
|
|
2173
2095
|
// For multi-service, use only the default value (don't reference context.apiVersion)
|
|
2174
|
-
if (
|
|
2096
|
+
if (dpgContext.rlcOptions?.isMultiService) {
|
|
2175
2097
|
return queryApiVersionParam.clientDefaultValue
|
|
2176
2098
|
? `"${queryApiVersionParam.clientDefaultValue}"`
|
|
2177
2099
|
: undefined;
|
|
@@ -2188,13 +2110,12 @@ function getApiVersionExpression(dpgContext, operation) {
|
|
|
2188
2110
|
* @returns Array of unique response headers
|
|
2189
2111
|
*/
|
|
2190
2112
|
export function getResponseHeaders(responses) {
|
|
2191
|
-
var _a, _b;
|
|
2192
2113
|
const headerMap = new Map();
|
|
2193
|
-
for (const response of responses
|
|
2194
|
-
for (const header of
|
|
2114
|
+
for (const response of responses ?? []) {
|
|
2115
|
+
for (const header of response.headers ?? []) {
|
|
2195
2116
|
if (shouldSkipHeaderSerialization(header))
|
|
2196
2117
|
continue;
|
|
2197
|
-
const key =
|
|
2118
|
+
const key = header.serializedName ?? header.name;
|
|
2198
2119
|
if (!headerMap.has(key)) {
|
|
2199
2120
|
headerMap.set(key, header);
|
|
2200
2121
|
}
|
|
@@ -2262,8 +2183,7 @@ function buildHeaderOnlyResponseType(context, headers) {
|
|
|
2262
2183
|
*/
|
|
2263
2184
|
function buildHeaderOnlyResponseValue(context, headers) {
|
|
2264
2185
|
const props = headers.map((header) => {
|
|
2265
|
-
|
|
2266
|
-
const headerName = ((_a = header.serializedName) !== null && _a !== void 0 ? _a : header.name).toLowerCase();
|
|
2186
|
+
const headerName = (header.serializedName ?? header.name).toLowerCase();
|
|
2267
2187
|
const key = normalizeModelPropertyName(context, header);
|
|
2268
2188
|
const value = deserializeResponseHeadersValue(context, header.type, `result.headers[${JSON.stringify(headerName)}]`, !header.optional, getEncodeForType(header.type), 0);
|
|
2269
2189
|
return `${key}: ${value}`;
|
|
@@ -2302,12 +2222,11 @@ export function getOperationResponseTypeName(method) {
|
|
|
2302
2222
|
* - any / unknown (no treatAsRecord) → HLC PropertyKind.Primitive
|
|
2303
2223
|
*/
|
|
2304
2224
|
function isWrappableType(context, type) {
|
|
2305
|
-
var _a;
|
|
2306
2225
|
if (type.kind === "array" && type.valueType.kind === "model")
|
|
2307
2226
|
return false;
|
|
2308
2227
|
if (type.kind === "dict" || type.kind === "model")
|
|
2309
2228
|
return false;
|
|
2310
|
-
if (type.kind === "unknown" &&
|
|
2229
|
+
if (type.kind === "unknown" && context.rlcOptions?.treatUnknownAsRecord)
|
|
2311
2230
|
return false;
|
|
2312
2231
|
return true;
|
|
2313
2232
|
}
|
|
@@ -2318,11 +2237,10 @@ function isHeadOperation(operation) {
|
|
|
2318
2237
|
return operation.operation.verb.toLowerCase() === "head";
|
|
2319
2238
|
}
|
|
2320
2239
|
function isHeadAsBooleanOperation(operation) {
|
|
2321
|
-
var _a;
|
|
2322
2240
|
if (!isHeadOperation(operation))
|
|
2323
2241
|
return false;
|
|
2324
2242
|
// @responseAsBool: TCGC promotes response.type to SdkBuiltInType { kind: "boolean" }
|
|
2325
|
-
if (
|
|
2243
|
+
if (operation.response.type?.kind === "boolean")
|
|
2326
2244
|
return true;
|
|
2327
2245
|
return false;
|
|
2328
2246
|
}
|
|
@@ -2331,25 +2249,24 @@ function isHeadAsBooleanOperation(operation) {
|
|
|
2331
2249
|
* Returns an object with `shouldWrap` (whether to wrap) and `isBinary` (whether it's a binary response).
|
|
2332
2250
|
*/
|
|
2333
2251
|
export function checkWrapNonModelReturn(context, operation) {
|
|
2334
|
-
var _a, _b, _c, _d, _e;
|
|
2335
2252
|
const noWrap = { shouldWrap: false, isBinary: false };
|
|
2336
2253
|
// LRO+paging and paging-only operations are not wrapped
|
|
2337
2254
|
if (isLroAndPagingOperation(operation) || isPagingOnlyOperation(operation)) {
|
|
2338
2255
|
return noWrap;
|
|
2339
2256
|
}
|
|
2340
2257
|
// Only if the feature flag is enabled
|
|
2341
|
-
if (!
|
|
2258
|
+
if (!context.rlcOptions?.wrapNonModelReturn) {
|
|
2342
2259
|
return noWrap;
|
|
2343
2260
|
}
|
|
2344
2261
|
// For LRO-only operations, check the final result type from LRO metadata
|
|
2345
2262
|
if (isLroOnlyOperation(operation)) {
|
|
2346
|
-
const lroResultType =
|
|
2263
|
+
const lroResultType = operation.lroMetadata?.finalResponse?.result;
|
|
2347
2264
|
if (!lroResultType) {
|
|
2348
2265
|
return noWrap; // void LRO - no wrap needed
|
|
2349
2266
|
}
|
|
2350
2267
|
return {
|
|
2351
2268
|
shouldWrap: isWrappableType(context, lroResultType),
|
|
2352
|
-
isBinary: false
|
|
2269
|
+
isBinary: false,
|
|
2353
2270
|
};
|
|
2354
2271
|
}
|
|
2355
2272
|
const { type } = operation.response;
|
|
@@ -2360,11 +2277,10 @@ export function checkWrapNonModelReturn(context, operation) {
|
|
|
2360
2277
|
}
|
|
2361
2278
|
return noWrap; // void return type - no wrap needed
|
|
2362
2279
|
}
|
|
2363
|
-
const contentTypes =
|
|
2280
|
+
const contentTypes = operation.operation.responses[0]?.contentTypes ?? [];
|
|
2364
2281
|
// bytes with binary content type → binary wrap (isBinary=true)
|
|
2365
2282
|
// HLC: bytes → binary payload → separate binary handling
|
|
2366
|
-
if (type.__raw &&
|
|
2367
|
-
isBinaryPayload(context, type.__raw, contentTypes, getEncodeForType(type))) {
|
|
2283
|
+
if (type.__raw && isBinaryPayload(context, type.__raw, contentTypes, getEncodeForType(type))) {
|
|
2368
2284
|
return { shouldWrap: true, isBinary: true };
|
|
2369
2285
|
}
|
|
2370
2286
|
return { shouldWrap: isWrappableType(context, type), isBinary: false };
|
|
@@ -2406,7 +2322,7 @@ export function buildNonModelResponseTypeDeclaration(context, method, isBinary)
|
|
|
2406
2322
|
name: typeName,
|
|
2407
2323
|
type: typeBody,
|
|
2408
2324
|
isExported: true,
|
|
2409
|
-
leadingTrivia: "\n"
|
|
2325
|
+
leadingTrivia: "\n",
|
|
2410
2326
|
};
|
|
2411
2327
|
}
|
|
2412
2328
|
//# sourceMappingURL=operationHelpers.js.map
|