@azure-tools/typespec-ts 0.53.3 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/src/framework/hooks/binder.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.js +102 -44
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/sdkTypes.js +1 -1
- package/dist/src/framework/hooks/sdkTypes.js.map +1 -1
- package/dist/src/framework/load-static-helpers.js +1 -1
- package/dist/src/framework/load-static-helpers.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +1 -10
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +0 -5
- 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.js +1 -1
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
- package/dist/src/modular/buildClientContext.js +1 -1
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildOperations.js +1 -1
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildProjectFiles.js +1 -1
- package/dist/src/modular/buildProjectFiles.js.map +1 -1
- package/dist/src/modular/buildRestorePoller.js +1 -1
- package/dist/src/modular/buildRestorePoller.js.map +1 -1
- package/dist/src/modular/buildRootIndex.js +1 -1
- package/dist/src/modular/buildRootIndex.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 +1 -1
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/emitModelsOptions.js +1 -1
- package/dist/src/modular/emitModelsOptions.js.map +1 -1
- package/dist/src/modular/emitSamples.js +1 -1
- package/dist/src/modular/emitSamples.js.map +1 -1
- package/dist/src/modular/emitTests.js +1 -1
- package/dist/src/modular/emitTests.js.map +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.js +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +1 -1
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.js +1 -1
- 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 +1 -1
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +53 -34
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +1 -1
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/interfaces.d.ts +1 -1
- package/dist/src/modular/interfaces.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.js +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.js +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
- package/dist/src/rlc-common/buildClient.d.ts +9 -0
- package/dist/src/rlc-common/buildClient.d.ts.map +1 -0
- package/dist/src/rlc-common/buildClient.js +413 -0
- package/dist/src/rlc-common/buildClient.js.map +1 -0
- package/dist/src/rlc-common/buildClientDefinitions.d.ts +6 -0
- package/dist/src/rlc-common/buildClientDefinitions.d.ts.map +1 -0
- package/dist/src/rlc-common/buildClientDefinitions.js +174 -0
- package/dist/src/rlc-common/buildClientDefinitions.js.map +1 -0
- package/dist/src/rlc-common/buildIndexFile.d.ts +6 -0
- package/dist/src/rlc-common/buildIndexFile.d.ts.map +1 -0
- package/dist/src/rlc-common/buildIndexFile.js +242 -0
- package/dist/src/rlc-common/buildIndexFile.js.map +1 -0
- package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts +6 -0
- package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts.map +1 -0
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js +224 -0
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +1 -0
- package/dist/src/rlc-common/buildLogger.d.ts +6 -0
- package/dist/src/rlc-common/buildLogger.d.ts.map +1 -0
- package/dist/src/rlc-common/buildLogger.js +32 -0
- package/dist/src/rlc-common/buildLogger.js.map +1 -0
- package/dist/src/rlc-common/buildMethodShortcuts.d.ts +5 -0
- package/dist/src/rlc-common/buildMethodShortcuts.d.ts.map +1 -0
- package/dist/src/rlc-common/buildMethodShortcuts.js +54 -0
- package/dist/src/rlc-common/buildMethodShortcuts.js.map +1 -0
- package/dist/src/rlc-common/buildObjectTypes.d.ts +29 -0
- package/dist/src/rlc-common/buildObjectTypes.d.ts.map +1 -0
- package/dist/src/rlc-common/buildObjectTypes.js +451 -0
- package/dist/src/rlc-common/buildObjectTypes.js.map +1 -0
- package/dist/src/rlc-common/buildPaginateHelper.d.ts +6 -0
- package/dist/src/rlc-common/buildPaginateHelper.d.ts.map +1 -0
- package/dist/src/rlc-common/buildPaginateHelper.js +27 -0
- package/dist/src/rlc-common/buildPaginateHelper.js.map +1 -0
- package/dist/src/rlc-common/buildParameterTypes.d.ts +14 -0
- package/dist/src/rlc-common/buildParameterTypes.d.ts.map +1 -0
- package/dist/src/rlc-common/buildParameterTypes.js +381 -0
- package/dist/src/rlc-common/buildParameterTypes.js.map +1 -0
- package/dist/src/rlc-common/buildPollingHelper.d.ts +6 -0
- package/dist/src/rlc-common/buildPollingHelper.d.ts.map +1 -0
- package/dist/src/rlc-common/buildPollingHelper.js +62 -0
- package/dist/src/rlc-common/buildPollingHelper.js.map +1 -0
- package/dist/src/rlc-common/buildResponseTypes.d.ts +6 -0
- package/dist/src/rlc-common/buildResponseTypes.d.ts.map +1 -0
- package/dist/src/rlc-common/buildResponseTypes.js +147 -0
- package/dist/src/rlc-common/buildResponseTypes.js.map +1 -0
- package/dist/src/rlc-common/buildSamples.d.ts +3 -0
- package/dist/src/rlc-common/buildSamples.d.ts.map +1 -0
- package/dist/src/rlc-common/buildSamples.js +30 -0
- package/dist/src/rlc-common/buildSamples.js.map +1 -0
- package/dist/src/rlc-common/buildSchemaType.d.ts +20 -0
- package/dist/src/rlc-common/buildSchemaType.d.ts.map +1 -0
- package/dist/src/rlc-common/buildSchemaType.js +53 -0
- package/dist/src/rlc-common/buildSchemaType.js.map +1 -0
- package/dist/src/rlc-common/buildSerializeHelper.d.ts +6 -0
- package/dist/src/rlc-common/buildSerializeHelper.d.ts.map +1 -0
- package/dist/src/rlc-common/buildSerializeHelper.js +36 -0
- package/dist/src/rlc-common/buildSerializeHelper.js.map +1 -0
- package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts +6 -0
- package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts.map +1 -0
- package/dist/src/rlc-common/buildTopLevelIndexFile.js +52 -0
- package/dist/src/rlc-common/buildTopLevelIndexFile.js.map +1 -0
- package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts +17 -0
- package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/apiVersionUtil.js +45 -0
- package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +1 -0
- package/dist/src/rlc-common/helpers/importsUtil.d.ts +18 -0
- package/dist/src/rlc-common/helpers/importsUtil.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/importsUtil.js +169 -0
- package/dist/src/rlc-common/helpers/importsUtil.js.map +1 -0
- package/dist/src/rlc-common/helpers/nameConstructors.d.ts +42 -0
- package/dist/src/rlc-common/helpers/nameConstructors.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/nameConstructors.js +63 -0
- package/dist/src/rlc-common/helpers/nameConstructors.js.map +1 -0
- package/dist/src/rlc-common/helpers/nameUtils.d.ts +37 -0
- package/dist/src/rlc-common/helpers/nameUtils.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/nameUtils.js +246 -0
- package/dist/src/rlc-common/helpers/nameUtils.js.map +1 -0
- package/dist/src/rlc-common/helpers/operationHelpers.d.ts +16 -0
- package/dist/src/rlc-common/helpers/operationHelpers.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/operationHelpers.js +119 -0
- package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -0
- package/dist/src/rlc-common/helpers/packageUtil.d.ts +7 -0
- package/dist/src/rlc-common/helpers/packageUtil.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/packageUtil.js +13 -0
- package/dist/src/rlc-common/helpers/packageUtil.js.map +1 -0
- package/dist/src/rlc-common/helpers/pathUtils.d.ts +2 -0
- package/dist/src/rlc-common/helpers/pathUtils.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/pathUtils.js +12 -0
- package/dist/src/rlc-common/helpers/pathUtils.js.map +1 -0
- package/dist/src/rlc-common/helpers/schemaHelpers.d.ts +10 -0
- package/dist/src/rlc-common/helpers/schemaHelpers.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/schemaHelpers.js +41 -0
- package/dist/src/rlc-common/helpers/schemaHelpers.js.map +1 -0
- package/dist/src/rlc-common/helpers/shortcutMethods.d.ts +4 -0
- package/dist/src/rlc-common/helpers/shortcutMethods.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/shortcutMethods.js +49 -0
- package/dist/src/rlc-common/helpers/shortcutMethods.js.map +1 -0
- package/dist/src/rlc-common/helpers/typeUtil.d.ts +32 -0
- package/dist/src/rlc-common/helpers/typeUtil.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/typeUtil.js +167 -0
- package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -0
- package/dist/src/rlc-common/helpers/valueGenerationUtil.d.ts +12 -0
- package/dist/src/rlc-common/helpers/valueGenerationUtil.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js +165 -0
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +1 -0
- package/dist/src/rlc-common/index.d.ts +41 -0
- package/dist/src/rlc-common/index.d.ts.map +1 -0
- package/dist/src/rlc-common/index.js +43 -0
- package/dist/src/rlc-common/index.js.map +1 -0
- package/dist/src/rlc-common/interfaces.d.ts +369 -0
- package/dist/src/rlc-common/interfaces.d.ts.map +1 -0
- package/dist/src/rlc-common/interfaces.js +11 -0
- package/dist/src/rlc-common/interfaces.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +56 -0
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildChangelogFile.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildChangelogFile.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildChangelogFile.js +26 -0
- package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildESLintConfig.js +82 -0
- package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildLicenseFile.d.ts +5 -0
- package/dist/src/rlc-common/metadata/buildLicenseFile.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildLicenseFile.js +32 -0
- package/dist/src/rlc-common/metadata/buildLicenseFile.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildPackageFile.d.ts +25 -0
- package/dist/src/rlc-common/metadata/buildPackageFile.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildPackageFile.js +201 -0
- package/dist/src/rlc-common/metadata/buildPackageFile.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts +11 -0
- package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildReadmeFile.js +426 -0
- package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildRollupConfig.js +142 -0
- package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +17 -0
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildTestConfig.d.ts +16 -0
- package/dist/src/rlc-common/metadata/buildTestConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildTestConfig.js +55 -0
- package/dist/src/rlc-common/metadata/buildTestConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildTsConfig.d.ts +61 -0
- package/dist/src/rlc-common/metadata/buildTsConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildTsConfig.js +170 -0
- package/dist/src/rlc-common/metadata/buildTsConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildVitestConfig.js +28 -0
- package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts +20 -0
- package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildWarpConfig.js +77 -0
- package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts +51 -0
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +121 -0
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts +242 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +176 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts +8 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js +102 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.d.ts +57 -0
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js +53 -0
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts +64 -0
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +183 -0
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -0
- package/dist/src/rlc-common/metadata/utils.d.ts +3 -0
- package/dist/src/rlc-common/metadata/utils.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/utils.js +7 -0
- package/dist/src/rlc-common/metadata/utils.js.map +1 -0
- package/dist/src/rlc-common/static/paginateContent.d.ts +2 -0
- package/dist/src/rlc-common/static/paginateContent.d.ts.map +1 -0
- package/dist/src/rlc-common/static/paginateContent.js +345 -0
- package/dist/src/rlc-common/static/paginateContent.js.map +1 -0
- package/dist/src/rlc-common/static/pollingContent.d.ts +2 -0
- package/dist/src/rlc-common/static/pollingContent.d.ts.map +1 -0
- package/dist/src/rlc-common/static/pollingContent.js +225 -0
- package/dist/src/rlc-common/static/pollingContent.js.map +1 -0
- package/dist/src/rlc-common/static/sampleTemplate.d.ts +2 -0
- package/dist/src/rlc-common/static/sampleTemplate.d.ts.map +1 -0
- package/dist/src/rlc-common/static/sampleTemplate.js +56 -0
- package/dist/src/rlc-common/static/sampleTemplate.js.map +1 -0
- package/dist/src/rlc-common/static/serializeHelper.d.ts +6 -0
- package/dist/src/rlc-common/static/serializeHelper.d.ts.map +1 -0
- package/dist/src/rlc-common/static/serializeHelper.js +31 -0
- package/dist/src/rlc-common/static/serializeHelper.js.map +1 -0
- package/dist/src/rlc-common/test/buildKarmaConfig.d.ts +6 -0
- package/dist/src/rlc-common/test/buildKarmaConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/test/buildKarmaConfig.js +11 -0
- package/dist/src/rlc-common/test/buildKarmaConfig.js.map +1 -0
- package/dist/src/rlc-common/test/buildRecordedClient.d.ts +6 -0
- package/dist/src/rlc-common/test/buildRecordedClient.d.ts.map +1 -0
- package/dist/src/rlc-common/test/buildRecordedClient.js +18 -0
- package/dist/src/rlc-common/test/buildRecordedClient.js.map +1 -0
- package/dist/src/rlc-common/test/buildSampleTest.d.ts +6 -0
- package/dist/src/rlc-common/test/buildSampleTest.d.ts.map +1 -0
- package/dist/src/rlc-common/test/buildSampleTest.js +15 -0
- package/dist/src/rlc-common/test/buildSampleTest.js.map +1 -0
- package/dist/src/rlc-common/test/buildSnippets.d.ts +6 -0
- package/dist/src/rlc-common/test/buildSnippets.d.ts.map +1 -0
- package/dist/src/rlc-common/test/buildSnippets.js +29 -0
- package/dist/src/rlc-common/test/buildSnippets.js.map +1 -0
- package/dist/src/rlc-common/test/template.d.ts +5 -0
- package/dist/src/rlc-common/test/template.d.ts.map +1 -0
- package/dist/src/rlc-common/test/template.js +261 -0
- package/dist/src/rlc-common/test/template.js.map +1 -0
- package/dist/src/rlc-common/transformSampleGroups.d.ts +9 -0
- package/dist/src/rlc-common/transformSampleGroups.d.ts.map +1 -0
- package/dist/src/rlc-common/transformSampleGroups.js +317 -0
- package/dist/src/rlc-common/transformSampleGroups.js.map +1 -0
- 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 +1 -1
- 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 +1 -1
- 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/transformParameters.d.ts +1 -1
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.js +1 -1
- 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/transfromRLCOptions.d.ts +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +1 -3
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/clientUtils.js +1 -1
- package/dist/src/utils/clientUtils.js.map +1 -1
- package/dist/src/utils/crossLanguageDef.js +1 -1
- 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 +1 -1
- package/dist/src/utils/emitUtil.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/modelUtils.d.ts +1 -1
- package/dist/src/utils/modelUtils.d.ts.map +1 -1
- package/dist/src/utils/modelUtils.js +1 -1
- package/dist/src/utils/modelUtils.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 +1 -1
- 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 +1 -1
- package/dist/src/utils/parameterUtils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/framework/hooks/binder.ts +142 -51
- package/src/framework/hooks/sdkTypes.ts +1 -1
- package/src/framework/load-static-helpers.ts +1 -1
- package/src/index.ts +5 -1
- package/src/lib.ts +1 -16
- package/src/metaTree.ts +1 -1
- package/src/modular/buildClassicalClient.ts +1 -1
- package/src/modular/buildClassicalOperationGroups.ts +1 -1
- package/src/modular/buildClientContext.ts +1 -1
- package/src/modular/buildOperations.ts +1 -1
- package/src/modular/buildProjectFiles.ts +1 -1
- package/src/modular/buildRestorePoller.ts +1 -1
- package/src/modular/buildRootIndex.ts +1 -1
- package/src/modular/emitModels.ts +1 -1
- package/src/modular/emitModelsOptions.ts +1 -1
- package/src/modular/emitSamples.ts +1 -1
- package/src/modular/emitTests.ts +1 -1
- package/src/modular/helpers/classicalOperationHelpers.ts +1 -1
- package/src/modular/helpers/clientHelpers.ts +1 -1
- package/src/modular/helpers/exampleValueHelpers.ts +1 -1
- package/src/modular/helpers/namingHelpers.ts +1 -1
- package/src/modular/helpers/operationHelpers.ts +65 -42
- package/src/modular/helpers/typeHelpers.ts +1 -1
- package/src/modular/interfaces.ts +1 -1
- package/src/modular/serialization/buildDeserializerFunction.ts +1 -1
- package/src/modular/serialization/buildSerializerFunction.ts +1 -1
- package/src/modular/serialization/buildXmlSerializerFunction.ts +1 -1
- package/src/modular/type-expressions/get-type-expression.ts +1 -1
- package/src/rlc-common/buildClient.ts +561 -0
- package/src/rlc-common/buildClientDefinitions.ts +278 -0
- package/src/rlc-common/buildIndexFile.ts +344 -0
- package/src/rlc-common/buildIsUnexpectedHelper.ts +255 -0
- package/src/rlc-common/buildLogger.ts +43 -0
- package/src/rlc-common/buildMethodShortcuts.ts +83 -0
- package/src/rlc-common/buildObjectTypes.ts +680 -0
- package/src/rlc-common/buildPaginateHelper.ts +34 -0
- package/src/rlc-common/buildParameterTypes.ts +575 -0
- package/src/rlc-common/buildPollingHelper.ts +83 -0
- package/src/rlc-common/buildResponseTypes.ts +203 -0
- package/src/rlc-common/buildSamples.ts +32 -0
- package/src/rlc-common/buildSchemaType.ts +81 -0
- package/src/rlc-common/buildSerializeHelper.ts +49 -0
- package/src/rlc-common/buildTopLevelIndexFile.ts +65 -0
- package/src/rlc-common/helpers/apiVersionUtil.ts +53 -0
- package/src/rlc-common/helpers/importsUtil.ts +187 -0
- package/src/rlc-common/helpers/nameConstructors.ts +144 -0
- package/src/rlc-common/helpers/nameUtils.ts +319 -0
- package/src/rlc-common/helpers/operationHelpers.ts +155 -0
- package/src/rlc-common/helpers/packageUtil.ts +13 -0
- package/src/rlc-common/helpers/pathUtils.ts +15 -0
- package/src/rlc-common/helpers/schemaHelpers.ts +61 -0
- package/src/rlc-common/helpers/shortcutMethods.ts +67 -0
- package/src/rlc-common/helpers/typeUtil.ts +173 -0
- package/src/rlc-common/helpers/valueGenerationUtil.ts +257 -0
- package/src/rlc-common/index.ts +43 -0
- package/src/rlc-common/interfaces.ts +441 -0
- package/src/rlc-common/metadata/buildApiExtractorConfig.ts +71 -0
- package/src/rlc-common/metadata/buildChangelogFile.ts +29 -0
- package/src/rlc-common/metadata/buildESLintConfig.ts +86 -0
- package/src/rlc-common/metadata/buildLicenseFile.ts +33 -0
- package/src/rlc-common/metadata/buildPackageFile.ts +250 -0
- package/src/rlc-common/metadata/buildReadmeFile.ts +528 -0
- package/src/rlc-common/metadata/buildRollupConfig.ts +150 -0
- package/src/rlc-common/metadata/buildSampleEnvFile.ts +22 -0
- package/src/rlc-common/metadata/buildTestConfig.ts +72 -0
- package/src/rlc-common/metadata/buildTsConfig.ts +222 -0
- package/src/rlc-common/metadata/buildVitestConfig.ts +36 -0
- package/src/rlc-common/metadata/buildWarpConfig.ts +94 -0
- package/src/rlc-common/metadata/packageJson/azurePackageCommon.ts +161 -0
- package/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.ts +220 -0
- package/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.ts +134 -0
- package/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.ts +70 -0
- package/src/rlc-common/metadata/packageJson/packageCommon.ts +255 -0
- package/src/rlc-common/metadata/utils.ts +8 -0
- package/src/rlc-common/static/paginateContent.ts +345 -0
- package/src/rlc-common/static/pollingContent.ts +225 -0
- package/src/rlc-common/static/sampleTemplate.ts +56 -0
- package/src/rlc-common/static/serializeHelper.ts +34 -0
- package/src/rlc-common/test/buildKarmaConfig.ts +12 -0
- package/src/rlc-common/test/buildRecordedClient.ts +18 -0
- package/src/rlc-common/test/buildSampleTest.ts +15 -0
- package/src/rlc-common/test/buildSnippets.ts +35 -0
- package/src/rlc-common/test/template.ts +263 -0
- package/src/rlc-common/transformSampleGroups.ts +458 -0
- package/src/transform/transform.ts +1 -1
- package/src/transform/transformApiVersionInfo.ts +1 -1
- package/src/transform/transformHelperFunctionDetails.ts +1 -1
- package/src/transform/transformParameters.ts +1 -1
- package/src/transform/transformPaths.ts +1 -1
- package/src/transform/transformResponses.ts +1 -1
- package/src/transform/transformSchemas.ts +1 -1
- package/src/transform/transformTelemetryInfo.ts +1 -1
- package/src/transform/transfromRLCOptions.ts +1 -3
- package/src/utils/clientUtils.ts +1 -1
- package/src/utils/crossLanguageDef.ts +1 -1
- package/src/utils/emitUtil.ts +1 -1
- package/src/utils/interfaces.ts +1 -1
- package/src/utils/modelUtils.ts +1 -1
- package/src/utils/operationUtil.ts +1 -1
- package/src/utils/parameterUtils.ts +1 -1
- package/LICENSE +0 -21
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
InterfaceDeclarationStructure,
|
|
6
|
+
OptionalKind,
|
|
7
|
+
Project,
|
|
8
|
+
StatementStructures,
|
|
9
|
+
StructureKind,
|
|
10
|
+
VariableDeclarationKind,
|
|
11
|
+
VariableStatementStructure,
|
|
12
|
+
WriterFunction
|
|
13
|
+
} from "ts-morph";
|
|
14
|
+
import * as path from "path";
|
|
15
|
+
import { NameType, normalizeName } from "./helpers/nameUtils.js";
|
|
16
|
+
import { buildMethodShortcutImplementation } from "./buildMethodShortcuts.js";
|
|
17
|
+
import { RLCModel, File, PathParameter } from "./interfaces.js";
|
|
18
|
+
import {
|
|
19
|
+
getClientName,
|
|
20
|
+
getImportModuleName
|
|
21
|
+
} from "./helpers/nameConstructors.js";
|
|
22
|
+
import { getImportSpecifier } from "./helpers/importsUtil.js";
|
|
23
|
+
import { isAzurePackage } from "./helpers/packageUtil.js";
|
|
24
|
+
|
|
25
|
+
function getClientOptionsInterface(
|
|
26
|
+
model: RLCModel,
|
|
27
|
+
clientName: string,
|
|
28
|
+
optionalUrlParameters?: PathParameter[]
|
|
29
|
+
): OptionalKind<InterfaceDeclarationStructure> | undefined {
|
|
30
|
+
if (
|
|
31
|
+
(!optionalUrlParameters || optionalUrlParameters.length === 0) &&
|
|
32
|
+
!model.apiVersionInfo
|
|
33
|
+
) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const properties =
|
|
38
|
+
optionalUrlParameters?.map((param) => {
|
|
39
|
+
return {
|
|
40
|
+
name: param.name,
|
|
41
|
+
type: param.type,
|
|
42
|
+
hasQuestionToken: true,
|
|
43
|
+
docs: [
|
|
44
|
+
param.description ?? "client level optional parameter " + param.name
|
|
45
|
+
]
|
|
46
|
+
};
|
|
47
|
+
}) ?? [];
|
|
48
|
+
|
|
49
|
+
if (
|
|
50
|
+
model.apiVersionInfo?.isCrossedVersion === false &&
|
|
51
|
+
!model.urlInfo?.urlParameters?.find((p) => p.name === "apiVersion") &&
|
|
52
|
+
(model.apiVersionInfo.defaultValue || !model.apiVersionInfo?.required)
|
|
53
|
+
) {
|
|
54
|
+
properties.push({
|
|
55
|
+
name: "apiVersion",
|
|
56
|
+
type: "string",
|
|
57
|
+
hasQuestionToken: true,
|
|
58
|
+
docs: ["The api version option of the client"]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
name: `${clientName}Options`,
|
|
63
|
+
extends: ["ClientOptions"],
|
|
64
|
+
isExported: true,
|
|
65
|
+
properties,
|
|
66
|
+
docs: ["The optional parameters for the client"]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function buildClient(model: RLCModel): File | undefined {
|
|
71
|
+
const name = normalizeName(model.libraryName, NameType.File);
|
|
72
|
+
const { srcPath } = model;
|
|
73
|
+
const project = new Project();
|
|
74
|
+
const filePath = path.join(srcPath, `${name}.ts`);
|
|
75
|
+
const clientFile = project.createSourceFile(filePath, undefined, {
|
|
76
|
+
overwrite: true
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Get all paths
|
|
80
|
+
const clientInterfaceName = getClientName(model);
|
|
81
|
+
|
|
82
|
+
normalizeUrlInfo(model);
|
|
83
|
+
const urlParameters = model?.urlInfo?.urlParameters?.filter(
|
|
84
|
+
// Do not include parameters with constant values in the signature, these should go in the options bag
|
|
85
|
+
(p) => p.value === undefined
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const optionalUrlParameters = model?.urlInfo?.urlParameters?.filter(
|
|
89
|
+
// Do not include parameters with constant values in the signature, these should go in the options bag
|
|
90
|
+
(p) => Boolean(p.value)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const clientOptionsInterface = getClientOptionsInterface(
|
|
94
|
+
model,
|
|
95
|
+
clientInterfaceName,
|
|
96
|
+
optionalUrlParameters
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
if (clientOptionsInterface) {
|
|
100
|
+
clientFile.addInterface(clientOptionsInterface);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!model.options) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
const { multiClient, batch } = model.options;
|
|
107
|
+
const {
|
|
108
|
+
addCredentials,
|
|
109
|
+
credentialScopes,
|
|
110
|
+
credentialKeyHeaderName,
|
|
111
|
+
customHttpAuthHeaderName,
|
|
112
|
+
customHttpAuthSharedKeyPrefix
|
|
113
|
+
} = model.options;
|
|
114
|
+
const credentialTypes = credentialScopes ? ["TokenCredential"] : [];
|
|
115
|
+
|
|
116
|
+
if (credentialKeyHeaderName || customHttpAuthHeaderName) {
|
|
117
|
+
credentialTypes.push("KeyCredential");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const commonClientParams = [
|
|
121
|
+
...(urlParameters ?? []),
|
|
122
|
+
...(addCredentials === false ||
|
|
123
|
+
!isSecurityInfoDefined(
|
|
124
|
+
credentialScopes,
|
|
125
|
+
credentialKeyHeaderName,
|
|
126
|
+
customHttpAuthHeaderName
|
|
127
|
+
)
|
|
128
|
+
? []
|
|
129
|
+
: [
|
|
130
|
+
{
|
|
131
|
+
name: "credentials",
|
|
132
|
+
type: credentialTypes.join(" | "),
|
|
133
|
+
description: `uniquely identify client credential`
|
|
134
|
+
}
|
|
135
|
+
])
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
let apiVersionStatement: string = "";
|
|
139
|
+
// Set the default api-version when we have a default AND its position is query
|
|
140
|
+
if (
|
|
141
|
+
model.apiVersionInfo?.isCrossedVersion === false &&
|
|
142
|
+
!!model.apiVersionInfo?.defaultValue
|
|
143
|
+
) {
|
|
144
|
+
apiVersionStatement = `
|
|
145
|
+
apiVersion = "${model.apiVersionInfo?.defaultValue}"`;
|
|
146
|
+
} else if (
|
|
147
|
+
model.apiVersionInfo?.isCrossedVersion === false &&
|
|
148
|
+
!model.apiVersionInfo.required
|
|
149
|
+
) {
|
|
150
|
+
apiVersionStatement = `
|
|
151
|
+
apiVersion`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const allClientParams = [
|
|
155
|
+
...commonClientParams,
|
|
156
|
+
{
|
|
157
|
+
name:
|
|
158
|
+
apiVersionStatement === ""
|
|
159
|
+
? "options"
|
|
160
|
+
: `{${apiVersionStatement}, ...options}`,
|
|
161
|
+
documentName: "options",
|
|
162
|
+
type: `${clientOptionsInterface?.name ?? "ClientOptions"} = {}`,
|
|
163
|
+
description: "the parameter for all optional parameters"
|
|
164
|
+
}
|
|
165
|
+
];
|
|
166
|
+
const functionStatement = {
|
|
167
|
+
isExported: true,
|
|
168
|
+
name: `createClient`,
|
|
169
|
+
parameters: allClientParams,
|
|
170
|
+
docs: [
|
|
171
|
+
{
|
|
172
|
+
description:
|
|
173
|
+
`Initialize a new instance of \`${clientInterfaceName}\`\n` +
|
|
174
|
+
allClientParams
|
|
175
|
+
.map((param) => {
|
|
176
|
+
return `@param ${param.documentName ?? param.name} - ${
|
|
177
|
+
param.description ?? "The parameter " + param.name
|
|
178
|
+
}`;
|
|
179
|
+
})
|
|
180
|
+
.join("\n")
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
returnType: clientInterfaceName,
|
|
184
|
+
isDefaultExport: false,
|
|
185
|
+
statements: getClientFactoryBody(model, clientInterfaceName, {
|
|
186
|
+
isMultipleCredential: credentialTypes.length > 1
|
|
187
|
+
})
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
if (!multiClient || !batch || batch.length === 1) {
|
|
191
|
+
functionStatement.isDefaultExport = true;
|
|
192
|
+
}
|
|
193
|
+
clientFile.addFunction(functionStatement);
|
|
194
|
+
|
|
195
|
+
const paths = srcPath.replace(/\//g, path.sep).split(path.sep);
|
|
196
|
+
while (paths.length > 0 && paths[paths.length - 1] === "") {
|
|
197
|
+
paths.pop();
|
|
198
|
+
}
|
|
199
|
+
const parentPath =
|
|
200
|
+
paths.lastIndexOf("src") > -1
|
|
201
|
+
? paths.length - 1 - paths.lastIndexOf("src")
|
|
202
|
+
: 0;
|
|
203
|
+
|
|
204
|
+
const loggerPath = `${
|
|
205
|
+
parentPath > 0 ? "../".repeat(parentPath) : "./"
|
|
206
|
+
}logger`;
|
|
207
|
+
clientFile.addImportDeclarations([
|
|
208
|
+
{
|
|
209
|
+
isTypeOnly: true,
|
|
210
|
+
namedImports: ["ClientOptions"],
|
|
211
|
+
moduleSpecifier: getImportSpecifier(
|
|
212
|
+
"restClient",
|
|
213
|
+
model.importInfo.runtimeImports
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
]);
|
|
217
|
+
clientFile.addImportDeclarations([
|
|
218
|
+
{
|
|
219
|
+
namedImports: ["getClient"],
|
|
220
|
+
moduleSpecifier: getImportSpecifier(
|
|
221
|
+
"restClient",
|
|
222
|
+
model.importInfo.runtimeImports
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
]);
|
|
226
|
+
if (isAzurePackage(model)) {
|
|
227
|
+
clientFile.addImportDeclarations([
|
|
228
|
+
{
|
|
229
|
+
namedImports: ["logger"],
|
|
230
|
+
moduleSpecifier: getImportModuleName(
|
|
231
|
+
{
|
|
232
|
+
cjsName: loggerPath,
|
|
233
|
+
esModulesName: `${loggerPath}.js`
|
|
234
|
+
},
|
|
235
|
+
model
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
]);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const includeKeyCredentialHelper =
|
|
242
|
+
customHttpAuthHeaderName &&
|
|
243
|
+
customHttpAuthSharedKeyPrefix &&
|
|
244
|
+
credentialTypes.length > 1 &&
|
|
245
|
+
credentialTypes.includes("KeyCredential");
|
|
246
|
+
if (
|
|
247
|
+
addCredentials &&
|
|
248
|
+
isSecurityInfoDefined(
|
|
249
|
+
credentialScopes,
|
|
250
|
+
credentialKeyHeaderName,
|
|
251
|
+
customHttpAuthHeaderName
|
|
252
|
+
)
|
|
253
|
+
) {
|
|
254
|
+
clientFile.addImportDeclarations([
|
|
255
|
+
{
|
|
256
|
+
isTypeOnly: true,
|
|
257
|
+
namedImports: credentialTypes,
|
|
258
|
+
moduleSpecifier: getImportSpecifier(
|
|
259
|
+
"coreAuth",
|
|
260
|
+
model.importInfo.runtimeImports
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
]);
|
|
264
|
+
if (includeKeyCredentialHelper) {
|
|
265
|
+
clientFile.addImportDeclarations([
|
|
266
|
+
{
|
|
267
|
+
namedImports: ["isKeyCredential"],
|
|
268
|
+
moduleSpecifier: getImportSpecifier(
|
|
269
|
+
"coreAuth",
|
|
270
|
+
model.importInfo.runtimeImports
|
|
271
|
+
)
|
|
272
|
+
}
|
|
273
|
+
]);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
clientFile.addImportDeclarations([
|
|
277
|
+
{
|
|
278
|
+
isTypeOnly: true,
|
|
279
|
+
namedImports: [`${clientInterfaceName}`],
|
|
280
|
+
moduleSpecifier: getImportModuleName(
|
|
281
|
+
{
|
|
282
|
+
cjsName: "./clientDefinitions",
|
|
283
|
+
esModulesName: "./clientDefinitions.js"
|
|
284
|
+
},
|
|
285
|
+
model
|
|
286
|
+
)
|
|
287
|
+
}
|
|
288
|
+
]);
|
|
289
|
+
if (
|
|
290
|
+
(model.importInfo.internalImports?.rlcClientFactory?.importsSet?.size ??
|
|
291
|
+
0) > 0
|
|
292
|
+
) {
|
|
293
|
+
clientFile.addImportDeclarations([
|
|
294
|
+
{
|
|
295
|
+
isTypeOnly: true,
|
|
296
|
+
namedImports: Array.from(
|
|
297
|
+
model.importInfo.internalImports.rlcClientFactory.importsSet!
|
|
298
|
+
),
|
|
299
|
+
moduleSpecifier: getImportModuleName(
|
|
300
|
+
{
|
|
301
|
+
cjsName: `./models`,
|
|
302
|
+
esModulesName: `./models.js`
|
|
303
|
+
},
|
|
304
|
+
model
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
]);
|
|
308
|
+
}
|
|
309
|
+
return { path: filePath, content: clientFile.getFullText() };
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function isSecurityInfoDefined(
|
|
313
|
+
credentialScopes?: string[],
|
|
314
|
+
credentialKeyHeaderName?: string,
|
|
315
|
+
customHttpAuthHeaderName?: string
|
|
316
|
+
) {
|
|
317
|
+
return (
|
|
318
|
+
credentialScopes || credentialKeyHeaderName || customHttpAuthHeaderName
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
interface GetClientFactoryOptions {
|
|
323
|
+
isMultipleCredential: boolean;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export function getClientFactoryBody(
|
|
327
|
+
model: RLCModel,
|
|
328
|
+
clientTypeName: string,
|
|
329
|
+
options: GetClientFactoryOptions = { isMultipleCredential: false }
|
|
330
|
+
): string | WriterFunction | (string | WriterFunction | StatementStructures)[] {
|
|
331
|
+
if (!model.options || !model.options.packageDetails || !model.urlInfo) {
|
|
332
|
+
return "";
|
|
333
|
+
}
|
|
334
|
+
const { includeShortcuts, packageDetails, addCredentials } = model.options;
|
|
335
|
+
let clientPackageName =
|
|
336
|
+
packageDetails!.nameWithoutScope ?? packageDetails?.name ?? "";
|
|
337
|
+
const packageVersion = packageDetails.version;
|
|
338
|
+
const { endpoint, urlParameters } = model.urlInfo;
|
|
339
|
+
|
|
340
|
+
const optionalUrlParameters: string[] = [];
|
|
341
|
+
|
|
342
|
+
for (const param of urlParameters ?? []) {
|
|
343
|
+
if (param.name === "apiVersion") {
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (param.value) {
|
|
347
|
+
const value =
|
|
348
|
+
typeof param.value === "string" ? `"${param.value}"` : param.value;
|
|
349
|
+
optionalUrlParameters.push(
|
|
350
|
+
`const ${param.name} = options.${param.name} ?? ${value};`
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
let endpointUrl: string;
|
|
356
|
+
if (urlParameters && endpoint) {
|
|
357
|
+
let parsedEndpoint = endpoint;
|
|
358
|
+
urlParameters.forEach((urlParameter) => {
|
|
359
|
+
parsedEndpoint = parsedEndpoint.replace(
|
|
360
|
+
`{${urlParameter.name}}`,
|
|
361
|
+
`\${${urlParameter.name}}`
|
|
362
|
+
);
|
|
363
|
+
});
|
|
364
|
+
endpointUrl = `options.endpoint ?? \`${parsedEndpoint}\``;
|
|
365
|
+
} else {
|
|
366
|
+
endpointUrl = `options.endpoint ?? "${endpoint}"`;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (!model.options.isModularLibrary && !clientPackageName.endsWith("-rest")) {
|
|
370
|
+
clientPackageName += "-rest";
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const userAgentInfoStatement =
|
|
374
|
+
"const userAgentInfo = `azsdk-js-" +
|
|
375
|
+
clientPackageName +
|
|
376
|
+
"/" +
|
|
377
|
+
packageVersion +
|
|
378
|
+
"`;";
|
|
379
|
+
const userAgentPrefix =
|
|
380
|
+
"options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`: `${userAgentInfo}`;";
|
|
381
|
+
const userAgentStatement: VariableStatementStructure = {
|
|
382
|
+
kind: StructureKind.VariableStatement,
|
|
383
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
384
|
+
declarations: [{ name: "userAgentPrefix", initializer: userAgentPrefix }]
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
const customHeaderOptions = model.telemetryOptions?.customRequestIdHeaderName
|
|
388
|
+
? `,
|
|
389
|
+
telemetryOptions: {
|
|
390
|
+
clientRequestIdHeaderName:
|
|
391
|
+
options.telemetryOptions?.clientRequestIdHeaderName ??
|
|
392
|
+
"${model.telemetryOptions?.customRequestIdHeaderName}"
|
|
393
|
+
}`
|
|
394
|
+
: "";
|
|
395
|
+
|
|
396
|
+
const endpointUrlStatement: VariableStatementStructure = {
|
|
397
|
+
kind: StructureKind.VariableStatement,
|
|
398
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
399
|
+
declarations: [{ name: "endpointUrl", initializer: endpointUrl }]
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
const { credentialScopes, credentialKeyHeaderName } = model.options;
|
|
403
|
+
const scopesString = credentialScopes
|
|
404
|
+
? credentialScopes.map((cs) => `"${cs}"`).join(", ") ||
|
|
405
|
+
"`${endpointUrl}/.default`"
|
|
406
|
+
: "";
|
|
407
|
+
const scopes = scopesString
|
|
408
|
+
? `scopes: options.credentials?.scopes ?? [${scopesString}],`
|
|
409
|
+
: "";
|
|
410
|
+
|
|
411
|
+
const apiKeyHeaderName = credentialKeyHeaderName
|
|
412
|
+
? `apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "${credentialKeyHeaderName}",`
|
|
413
|
+
: "";
|
|
414
|
+
const loggerOptions = isAzurePackage(model)
|
|
415
|
+
? `,
|
|
416
|
+
loggingOptions: {
|
|
417
|
+
logger: options.loggingOptions?.logger ?? logger.info
|
|
418
|
+
}`
|
|
419
|
+
: "";
|
|
420
|
+
|
|
421
|
+
const credentialsOptions =
|
|
422
|
+
(scopes || apiKeyHeaderName) && addCredentials
|
|
423
|
+
? `,
|
|
424
|
+
credentials: {
|
|
425
|
+
${scopes}
|
|
426
|
+
${apiKeyHeaderName}
|
|
427
|
+
}`
|
|
428
|
+
: "";
|
|
429
|
+
const overrideOptionsStatement = `options = {
|
|
430
|
+
...options,
|
|
431
|
+
userAgentOptions: {
|
|
432
|
+
userAgentPrefix
|
|
433
|
+
}${loggerOptions}${customHeaderOptions}${credentialsOptions}
|
|
434
|
+
};`;
|
|
435
|
+
const getClient = `const client = getClient(
|
|
436
|
+
endpointUrl, ${credentialsOptions ? "credentials," : ""} options
|
|
437
|
+
) as ${clientTypeName};
|
|
438
|
+
`;
|
|
439
|
+
const { customHttpAuthHeaderName, customHttpAuthSharedKeyPrefix } =
|
|
440
|
+
model.options;
|
|
441
|
+
let customHttpAuthStatement = "";
|
|
442
|
+
if (customHttpAuthHeaderName && customHttpAuthSharedKeyPrefix) {
|
|
443
|
+
if (options.isMultipleCredential) {
|
|
444
|
+
customHttpAuthStatement = `if (isKeyCredential(credentials)) {
|
|
445
|
+
client.pipeline.addPolicy({
|
|
446
|
+
name: "customKeyCredentialPolicy",
|
|
447
|
+
async sendRequest(request, next) {
|
|
448
|
+
request.headers.set("Authorization", "Bearer " + credentials.key);
|
|
449
|
+
return next(request);
|
|
450
|
+
},
|
|
451
|
+
});
|
|
452
|
+
}`;
|
|
453
|
+
} else {
|
|
454
|
+
customHttpAuthStatement = `
|
|
455
|
+
client.pipeline.addPolicy({
|
|
456
|
+
name: "customKeyCredentialPolicy",
|
|
457
|
+
async sendRequest(request, next) {
|
|
458
|
+
request.headers.set("${customHttpAuthHeaderName}", "${customHttpAuthSharedKeyPrefix} " + credentials.key);
|
|
459
|
+
return next(request);
|
|
460
|
+
}
|
|
461
|
+
});`;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
let apiVersionPolicyStatement = `client.pipeline.removePolicy({ name: "ApiVersionPolicy" });`;
|
|
466
|
+
if (
|
|
467
|
+
isAzurePackage(model) &&
|
|
468
|
+
model.apiVersionInfo?.isCrossedVersion !== false
|
|
469
|
+
) {
|
|
470
|
+
apiVersionPolicyStatement += `
|
|
471
|
+
if (options.apiVersion) {
|
|
472
|
+
logger.warning("This client does not support client api-version, please change it at the operation level");
|
|
473
|
+
}`;
|
|
474
|
+
} else if (
|
|
475
|
+
isAzurePackage(model) &&
|
|
476
|
+
!model.apiVersionInfo?.defaultValue &&
|
|
477
|
+
model.apiVersionInfo?.required
|
|
478
|
+
) {
|
|
479
|
+
apiVersionPolicyStatement += `
|
|
480
|
+
if (options.apiVersion) {
|
|
481
|
+
logger.warning("This client does not support to set api-version in options, please change it at positional argument");
|
|
482
|
+
}`;
|
|
483
|
+
}
|
|
484
|
+
if (
|
|
485
|
+
model.apiVersionInfo?.isCrossedVersion === false &&
|
|
486
|
+
model.apiVersionInfo?.definedPosition === "query"
|
|
487
|
+
) {
|
|
488
|
+
apiVersionPolicyStatement += `
|
|
489
|
+
client.pipeline.addPolicy({
|
|
490
|
+
name: 'ClientApiVersionPolicy',
|
|
491
|
+
sendRequest: (req, next) => {
|
|
492
|
+
// Use the apiVersion defined in request url directly
|
|
493
|
+
// Append one if there is no apiVersion and we have one at client options
|
|
494
|
+
const url = new URL(req.url);
|
|
495
|
+
if (!url.searchParams.get("api-version") && apiVersion) {
|
|
496
|
+
req.url = \`\${req.url}\${
|
|
497
|
+
Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"
|
|
498
|
+
}api-version=\${apiVersion}\`;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
return next(req);
|
|
502
|
+
},
|
|
503
|
+
});`;
|
|
504
|
+
}
|
|
505
|
+
let returnStatement = `return client;`;
|
|
506
|
+
|
|
507
|
+
if (includeShortcuts) {
|
|
508
|
+
const shortcutImplementations = buildMethodShortcutImplementation(
|
|
509
|
+
model.paths
|
|
510
|
+
);
|
|
511
|
+
const shortcutBody = Object.keys(shortcutImplementations).map((key) => {
|
|
512
|
+
// If the operation group has an empty name, it means its operations are client
|
|
513
|
+
// level operations so we need to spread the definitions. Otherwise they are
|
|
514
|
+
// within an operation group so we add them as key: value
|
|
515
|
+
const shortcuts = shortcutImplementations[key];
|
|
516
|
+
return `${
|
|
517
|
+
key && key !== "client" ? `"${key}":` : "..."
|
|
518
|
+
} {${shortcuts ? shortcuts.join() : ""}}`;
|
|
519
|
+
});
|
|
520
|
+
returnStatement = `return { ...client, ${shortcutBody.join()} };`;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return [
|
|
524
|
+
...optionalUrlParameters,
|
|
525
|
+
endpointUrlStatement,
|
|
526
|
+
userAgentInfoStatement,
|
|
527
|
+
userAgentStatement,
|
|
528
|
+
overrideOptionsStatement,
|
|
529
|
+
getClient,
|
|
530
|
+
apiVersionPolicyStatement,
|
|
531
|
+
customHttpAuthStatement,
|
|
532
|
+
returnStatement
|
|
533
|
+
];
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function normalizeUrlInfo(model: RLCModel) {
|
|
537
|
+
if (
|
|
538
|
+
!model ||
|
|
539
|
+
!model.urlInfo ||
|
|
540
|
+
!model.urlInfo.endpoint ||
|
|
541
|
+
!model.urlInfo.urlParameters ||
|
|
542
|
+
model.urlInfo.urlParameters.length === 0
|
|
543
|
+
) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
let parsedEndpoint = model.urlInfo.endpoint;
|
|
548
|
+
const urlParameters = model.urlInfo.urlParameters;
|
|
549
|
+
urlParameters.forEach((urlParameter) => {
|
|
550
|
+
const name = urlParameter.name;
|
|
551
|
+
const normalizedName = normalizeName(name, NameType.Parameter);
|
|
552
|
+
if (name !== normalizedName) {
|
|
553
|
+
urlParameter.name = normalizedName;
|
|
554
|
+
parsedEndpoint = parsedEndpoint.replace(
|
|
555
|
+
`{${name}}`,
|
|
556
|
+
`{${normalizedName}}`
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
model.urlInfo.endpoint = parsedEndpoint;
|
|
561
|
+
}
|