@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,575 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
InterfaceDeclarationStructure,
|
|
6
|
+
Project,
|
|
7
|
+
PropertySignatureStructure,
|
|
8
|
+
SourceFile,
|
|
9
|
+
StructureKind
|
|
10
|
+
} from "ts-morph";
|
|
11
|
+
import * as path from "path";
|
|
12
|
+
import {
|
|
13
|
+
ObjectSchema,
|
|
14
|
+
ParameterMetadata,
|
|
15
|
+
ParameterMetadatas,
|
|
16
|
+
RLCModel,
|
|
17
|
+
Schema,
|
|
18
|
+
SchemaContext
|
|
19
|
+
} from "./interfaces.js";
|
|
20
|
+
import {
|
|
21
|
+
getImportModuleName,
|
|
22
|
+
getParameterBaseName,
|
|
23
|
+
getParameterTypeName
|
|
24
|
+
} from "./helpers/nameConstructors.js";
|
|
25
|
+
import { getImportSpecifier } from "./helpers/importsUtil.js";
|
|
26
|
+
import { getObjectInterfaceDeclaration } from "./buildObjectTypes.js";
|
|
27
|
+
import { getGeneratedWrapperTypes } from "./helpers/operationHelpers.js";
|
|
28
|
+
|
|
29
|
+
export function buildParameterTypes(model: RLCModel) {
|
|
30
|
+
const project = new Project();
|
|
31
|
+
const srcPath = model.srcPath;
|
|
32
|
+
const filePath = path.join(srcPath, `parameters.ts`);
|
|
33
|
+
const partialBodyTypeNames = new Set<string>();
|
|
34
|
+
const parametersFile = project.createSourceFile(filePath, undefined, {
|
|
35
|
+
overwrite: true
|
|
36
|
+
});
|
|
37
|
+
let hasHeaders = false;
|
|
38
|
+
|
|
39
|
+
if (!model.parameters) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
for (const requestParameter of model.parameters) {
|
|
43
|
+
const baseParameterName = getParameterBaseName(
|
|
44
|
+
requestParameter.operationGroup,
|
|
45
|
+
requestParameter.operationName
|
|
46
|
+
);
|
|
47
|
+
const requestCount = requestParameter?.parameters?.length ?? 0;
|
|
48
|
+
const topParamName = getParameterTypeName(baseParameterName);
|
|
49
|
+
const subParamNames: string[] = [];
|
|
50
|
+
|
|
51
|
+
// We need to loop the requests. An operation with multiple requests means that
|
|
52
|
+
// the operation can get different values for content-type and each value may
|
|
53
|
+
// have a different type associated to it.
|
|
54
|
+
for (let i = 0; i < requestCount; i++) {
|
|
55
|
+
const parameter = requestParameter.parameters[i];
|
|
56
|
+
if (!parameter) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const internalReferences = new Set<string>();
|
|
60
|
+
// In case we have more than one request to model we need to add a suffix to differentiate
|
|
61
|
+
const nameSuffix = i > 0 ? `${i}` : "";
|
|
62
|
+
const parameterInterfaceName =
|
|
63
|
+
requestCount > 1
|
|
64
|
+
? `${baseParameterName}RequestParameters${nameSuffix}`
|
|
65
|
+
: topParamName;
|
|
66
|
+
const queryParameterDefinitions = buildQueryParameterDefinition(
|
|
67
|
+
model,
|
|
68
|
+
parameter,
|
|
69
|
+
baseParameterName,
|
|
70
|
+
internalReferences,
|
|
71
|
+
i
|
|
72
|
+
);
|
|
73
|
+
const pathParameterDefinitions = buildPathParameterDefinitions(
|
|
74
|
+
model,
|
|
75
|
+
parameter,
|
|
76
|
+
baseParameterName,
|
|
77
|
+
parametersFile,
|
|
78
|
+
internalReferences,
|
|
79
|
+
i
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const headerParameterDefinitions = buildHeaderParameterDefinitions(
|
|
83
|
+
parameter,
|
|
84
|
+
baseParameterName,
|
|
85
|
+
parametersFile,
|
|
86
|
+
internalReferences,
|
|
87
|
+
i
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const contentTypeParameterDefinition =
|
|
91
|
+
buildContentTypeParametersDefinition(
|
|
92
|
+
parameter,
|
|
93
|
+
baseParameterName,
|
|
94
|
+
internalReferences,
|
|
95
|
+
i
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const bodyParameterDefinition = buildBodyParametersDefinition(
|
|
99
|
+
parameter,
|
|
100
|
+
baseParameterName,
|
|
101
|
+
internalReferences,
|
|
102
|
+
i
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const bodyTypeAlias = buildBodyTypeAlias(parameter, partialBodyTypeNames);
|
|
106
|
+
if (bodyTypeAlias) {
|
|
107
|
+
parametersFile.addTypeAlias(bodyTypeAlias);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Add interfaces for body and query parameters
|
|
111
|
+
parametersFile.addInterfaces([
|
|
112
|
+
...(bodyParameterDefinition ?? []),
|
|
113
|
+
...(queryParameterDefinitions ?? []),
|
|
114
|
+
...(pathParameterDefinitions ?? []),
|
|
115
|
+
...(headerParameterDefinitions ? [headerParameterDefinitions] : []),
|
|
116
|
+
...(contentTypeParameterDefinition
|
|
117
|
+
? [contentTypeParameterDefinition]
|
|
118
|
+
: [])
|
|
119
|
+
]);
|
|
120
|
+
|
|
121
|
+
// Add Operation parameters type alias which is composed of the types we generated above
|
|
122
|
+
// plus the common type RequestParameters
|
|
123
|
+
parametersFile.addTypeAlias({
|
|
124
|
+
name: parameterInterfaceName,
|
|
125
|
+
isExported: true,
|
|
126
|
+
type: [...internalReferences, "RequestParameters"].join(" & ")
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
subParamNames.push(parameterInterfaceName);
|
|
130
|
+
|
|
131
|
+
if (headerParameterDefinitions !== undefined) {
|
|
132
|
+
hasHeaders = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Add Operation parameters type alias which is composed of the types we generated above
|
|
136
|
+
// plus the common type RequestParameters
|
|
137
|
+
if (requestCount > 1) {
|
|
138
|
+
parametersFile.addTypeAlias({
|
|
139
|
+
name: topParamName,
|
|
140
|
+
isExported: true,
|
|
141
|
+
type: [...subParamNames].join(" | ")
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (hasHeaders) {
|
|
147
|
+
parametersFile.addImportDeclarations([
|
|
148
|
+
{
|
|
149
|
+
isTypeOnly: true,
|
|
150
|
+
namedImports: ["RawHttpHeadersInput"],
|
|
151
|
+
moduleSpecifier: getImportSpecifier(
|
|
152
|
+
"restPipeline",
|
|
153
|
+
model.importInfo.runtimeImports
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
158
|
+
parametersFile.addImportDeclarations([
|
|
159
|
+
{
|
|
160
|
+
isTypeOnly: true,
|
|
161
|
+
namedImports: ["RequestParameters"],
|
|
162
|
+
moduleSpecifier: getImportSpecifier(
|
|
163
|
+
"restClient",
|
|
164
|
+
model.importInfo.runtimeImports
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
]);
|
|
168
|
+
if (
|
|
169
|
+
(model.importInfo.internalImports?.parameter?.importsSet?.size ?? 0) > 0
|
|
170
|
+
) {
|
|
171
|
+
parametersFile.addImportDeclarations([
|
|
172
|
+
{
|
|
173
|
+
isTypeOnly: true,
|
|
174
|
+
namedImports: Array.from(
|
|
175
|
+
model.importInfo.internalImports.parameter.importsSet!
|
|
176
|
+
),
|
|
177
|
+
moduleSpecifier: getImportModuleName(
|
|
178
|
+
{
|
|
179
|
+
cjsName: `./models`,
|
|
180
|
+
esModulesName: `./models.js`
|
|
181
|
+
},
|
|
182
|
+
model
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
]);
|
|
186
|
+
}
|
|
187
|
+
return { path: filePath, content: parametersFile.getFullText() };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function buildQueryParameterDefinition(
|
|
191
|
+
model: RLCModel,
|
|
192
|
+
parameters: ParameterMetadatas,
|
|
193
|
+
baseName: string,
|
|
194
|
+
internalReferences: Set<string>,
|
|
195
|
+
requestIndex: number
|
|
196
|
+
): InterfaceDeclarationStructure[] | undefined {
|
|
197
|
+
const queryParameters = (parameters?.parameters || []).filter(
|
|
198
|
+
(p) => p.type === "query"
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
if (!queryParameters.length) {
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
|
|
206
|
+
const queryParameterInterfaceName = `${baseName}QueryParam${nameSuffix}`;
|
|
207
|
+
const queryParameterPropertiesName = `${baseName}QueryParamProperties`;
|
|
208
|
+
|
|
209
|
+
// Get the property signature for each query parameter
|
|
210
|
+
const propertiesDefinition = queryParameters.map((qp) =>
|
|
211
|
+
getPropertyFromSchema(qp.param)
|
|
212
|
+
);
|
|
213
|
+
// Get wrapper types for query parameters
|
|
214
|
+
const wrapperTypesDefinition = getGeneratedWrapperTypes(queryParameters).map(
|
|
215
|
+
(wrapObj) => {
|
|
216
|
+
return getObjectInterfaceDeclaration(
|
|
217
|
+
model,
|
|
218
|
+
wrapObj.name,
|
|
219
|
+
wrapObj,
|
|
220
|
+
[SchemaContext.Input],
|
|
221
|
+
new Set<string>()
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const hasRequiredParameters = propertiesDefinition.some(
|
|
227
|
+
(p) => !p.hasQuestionToken
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
const propertiesInterface: InterfaceDeclarationStructure = {
|
|
231
|
+
kind: StructureKind.Interface,
|
|
232
|
+
isExported: true,
|
|
233
|
+
name: queryParameterPropertiesName,
|
|
234
|
+
properties: propertiesDefinition
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const parameterInterface: InterfaceDeclarationStructure = {
|
|
238
|
+
kind: StructureKind.Interface,
|
|
239
|
+
isExported: true,
|
|
240
|
+
name: queryParameterInterfaceName,
|
|
241
|
+
properties: [
|
|
242
|
+
{
|
|
243
|
+
name: "queryParameters",
|
|
244
|
+
type: queryParameterPropertiesName,
|
|
245
|
+
// Mark as optional if there are no required parameters
|
|
246
|
+
hasQuestionToken: !hasRequiredParameters
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// Mark the queryParameter interface for importing
|
|
252
|
+
internalReferences.add(queryParameterInterfaceName);
|
|
253
|
+
|
|
254
|
+
return [...wrapperTypesDefinition, propertiesInterface, parameterInterface];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function getPropertyFromSchema(schema: Schema): PropertySignatureStructure {
|
|
258
|
+
const description = schema.description;
|
|
259
|
+
return {
|
|
260
|
+
name: schema.name,
|
|
261
|
+
...(description && { docs: [{ description }] }),
|
|
262
|
+
type: schema.type,
|
|
263
|
+
hasQuestionToken: !schema.required,
|
|
264
|
+
kind: StructureKind.PropertySignature
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function buildPathParameterDefinitions(
|
|
269
|
+
model: RLCModel,
|
|
270
|
+
parameters: ParameterMetadatas,
|
|
271
|
+
baseName: string,
|
|
272
|
+
parametersFile: SourceFile,
|
|
273
|
+
internalReferences: Set<string>,
|
|
274
|
+
requestIndex: number
|
|
275
|
+
): InterfaceDeclarationStructure[] | undefined {
|
|
276
|
+
const pathParameters = (parameters.parameters || []).filter(
|
|
277
|
+
(p) => p.type === "path"
|
|
278
|
+
);
|
|
279
|
+
if (!pathParameters.length) {
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
const allDefinitions: InterfaceDeclarationStructure[] = [];
|
|
283
|
+
|
|
284
|
+
buildClientPathParameters();
|
|
285
|
+
buildMethodWrapParameters();
|
|
286
|
+
return allDefinitions;
|
|
287
|
+
function buildClientPathParameters() {
|
|
288
|
+
// we only have client-level path parameters if the source is from swagger
|
|
289
|
+
if (model.options?.sourceFrom === "TypeSpec") {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const clientPathParams = pathParameters.length > 0 ? pathParameters : [];
|
|
293
|
+
const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
|
|
294
|
+
const pathParameterInterfaceName = `${baseName}PathParam${nameSuffix}`;
|
|
295
|
+
|
|
296
|
+
const pathInterface = getPathInterfaceDefinition(
|
|
297
|
+
clientPathParams,
|
|
298
|
+
baseName
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
if (pathInterface) {
|
|
302
|
+
parametersFile.addInterface(pathInterface);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
internalReferences.add(pathParameterInterfaceName);
|
|
306
|
+
|
|
307
|
+
allDefinitions.push({
|
|
308
|
+
isExported: true,
|
|
309
|
+
kind: StructureKind.Interface,
|
|
310
|
+
name: pathParameterInterfaceName,
|
|
311
|
+
properties: [
|
|
312
|
+
{
|
|
313
|
+
name: "pathParameters",
|
|
314
|
+
type: `${baseName}PathParameters`,
|
|
315
|
+
kind: StructureKind.PropertySignature
|
|
316
|
+
}
|
|
317
|
+
]
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function buildMethodWrapParameters() {
|
|
322
|
+
if (model.options?.sourceFrom === "Swagger") {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
// we only have method-level path parameters if the source is from typespec
|
|
326
|
+
const methodPathParams = pathParameters.length > 0 ? pathParameters : [];
|
|
327
|
+
|
|
328
|
+
// we only need to build the wrapper types if the path parameters are objects
|
|
329
|
+
const wrapperTypesDefinition = getGeneratedWrapperTypes(
|
|
330
|
+
methodPathParams
|
|
331
|
+
).map((wrap) => {
|
|
332
|
+
return getObjectInterfaceDeclaration(
|
|
333
|
+
model,
|
|
334
|
+
wrap.name,
|
|
335
|
+
wrap,
|
|
336
|
+
[SchemaContext.Input],
|
|
337
|
+
new Set<string>()
|
|
338
|
+
);
|
|
339
|
+
});
|
|
340
|
+
allDefinitions.push(...wrapperTypesDefinition);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function getPathInterfaceDefinition(
|
|
345
|
+
pathParameters: ParameterMetadata[],
|
|
346
|
+
baseName: string
|
|
347
|
+
): undefined | InterfaceDeclarationStructure {
|
|
348
|
+
const pathInterfaceName = `${baseName}PathParameters`;
|
|
349
|
+
return {
|
|
350
|
+
kind: StructureKind.Interface,
|
|
351
|
+
isExported: true,
|
|
352
|
+
name: pathInterfaceName,
|
|
353
|
+
properties: pathParameters.map((p: ParameterMetadata) =>
|
|
354
|
+
getPropertyFromSchema(p.param)
|
|
355
|
+
)
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function buildHeaderParameterDefinitions(
|
|
360
|
+
parameters: ParameterMetadatas,
|
|
361
|
+
baseName: string,
|
|
362
|
+
parametersFile: SourceFile,
|
|
363
|
+
internalReferences: Set<string>,
|
|
364
|
+
requestIndex: number
|
|
365
|
+
): InterfaceDeclarationStructure | undefined {
|
|
366
|
+
const headerParameters = (parameters.parameters || []).filter(
|
|
367
|
+
(p) => p.type === "header" && p.name !== "contentType"
|
|
368
|
+
);
|
|
369
|
+
if (!headerParameters.length) {
|
|
370
|
+
return undefined;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
|
|
374
|
+
const headerParameterInterfaceName = `${baseName}HeaderParam${nameSuffix}`;
|
|
375
|
+
|
|
376
|
+
const headersInterface = getRequestHeaderInterfaceDefinition(
|
|
377
|
+
headerParameters,
|
|
378
|
+
baseName
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
let isOptional = true;
|
|
382
|
+
if (headersInterface) {
|
|
383
|
+
parametersFile.addInterface(headersInterface);
|
|
384
|
+
isOptional = !(headersInterface.properties || []).some(
|
|
385
|
+
(prop) => prop.hasQuestionToken === false
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
internalReferences.add(headerParameterInterfaceName);
|
|
390
|
+
|
|
391
|
+
return {
|
|
392
|
+
isExported: true,
|
|
393
|
+
kind: StructureKind.Interface,
|
|
394
|
+
name: headerParameterInterfaceName,
|
|
395
|
+
properties: [
|
|
396
|
+
{
|
|
397
|
+
name: "headers",
|
|
398
|
+
type: `RawHttpHeadersInput & ${baseName}Headers`,
|
|
399
|
+
kind: StructureKind.PropertySignature,
|
|
400
|
+
hasQuestionToken: isOptional
|
|
401
|
+
}
|
|
402
|
+
]
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function getRequestHeaderInterfaceDefinition(
|
|
407
|
+
headerParameters: ParameterMetadata[],
|
|
408
|
+
baseName: string
|
|
409
|
+
): undefined | InterfaceDeclarationStructure {
|
|
410
|
+
const headersInterfaceName = `${baseName}Headers`;
|
|
411
|
+
return {
|
|
412
|
+
kind: StructureKind.Interface,
|
|
413
|
+
isExported: true,
|
|
414
|
+
name: headersInterfaceName,
|
|
415
|
+
properties: headerParameters.map((h: ParameterMetadata) =>
|
|
416
|
+
getPropertyFromSchema(h.param)
|
|
417
|
+
)
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function buildContentTypeParametersDefinition(
|
|
422
|
+
parameters: ParameterMetadatas,
|
|
423
|
+
baseName: string,
|
|
424
|
+
internalReferences: Set<string>,
|
|
425
|
+
requestIndex: number
|
|
426
|
+
): InterfaceDeclarationStructure | undefined {
|
|
427
|
+
const mediaTypeParameters = (parameters.parameters || []).filter(
|
|
428
|
+
(p) => p.type === "header" && p.name === "contentType"
|
|
429
|
+
);
|
|
430
|
+
if (!mediaTypeParameters.length) {
|
|
431
|
+
return undefined;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
|
|
435
|
+
const mediaTypesParameterInterfaceName = `${baseName}MediaTypesParam${nameSuffix}`;
|
|
436
|
+
|
|
437
|
+
// Mark the queryParameter interface for importing
|
|
438
|
+
internalReferences.add(mediaTypesParameterInterfaceName);
|
|
439
|
+
const firstMediaType = mediaTypeParameters[0];
|
|
440
|
+
if (!firstMediaType) {
|
|
441
|
+
return undefined;
|
|
442
|
+
}
|
|
443
|
+
const mediaParam = firstMediaType.param;
|
|
444
|
+
|
|
445
|
+
return {
|
|
446
|
+
isExported: true,
|
|
447
|
+
kind: StructureKind.Interface,
|
|
448
|
+
name: mediaTypesParameterInterfaceName,
|
|
449
|
+
properties: [getPropertyFromSchema(mediaParam)]
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function buildBodyParametersDefinition(
|
|
454
|
+
parameters: ParameterMetadatas,
|
|
455
|
+
baseName: string,
|
|
456
|
+
internalReferences: Set<string>,
|
|
457
|
+
requestIndex: number
|
|
458
|
+
): InterfaceDeclarationStructure[] {
|
|
459
|
+
const bodyParameters = parameters.body;
|
|
460
|
+
if (
|
|
461
|
+
!bodyParameters ||
|
|
462
|
+
!bodyParameters?.body ||
|
|
463
|
+
!bodyParameters?.body.length
|
|
464
|
+
) {
|
|
465
|
+
return [];
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
|
|
469
|
+
const bodyParameterInterfaceName = `${baseName}BodyParam${nameSuffix}`;
|
|
470
|
+
internalReferences.add(bodyParameterInterfaceName);
|
|
471
|
+
|
|
472
|
+
// In case of formData we'd get multiple properties in body marked as partialBody
|
|
473
|
+
if (bodyParameters.isPartialBody) {
|
|
474
|
+
let allOptionalParts = true;
|
|
475
|
+
const propertiesDefinitions: PropertySignatureStructure[] = [];
|
|
476
|
+
for (const param of bodyParameters.body) {
|
|
477
|
+
if (param.required) {
|
|
478
|
+
allOptionalParts = false;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
propertiesDefinitions.push(getPropertyFromSchema(param));
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const formBodyName = `${baseName}FormBody`;
|
|
485
|
+
const formBodyInterface: InterfaceDeclarationStructure = {
|
|
486
|
+
isExported: true,
|
|
487
|
+
kind: StructureKind.Interface,
|
|
488
|
+
name: formBodyName,
|
|
489
|
+
properties: propertiesDefinitions
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
return [
|
|
493
|
+
{
|
|
494
|
+
isExported: true,
|
|
495
|
+
kind: StructureKind.Interface,
|
|
496
|
+
name: bodyParameterInterfaceName,
|
|
497
|
+
properties: [
|
|
498
|
+
{
|
|
499
|
+
name: "body",
|
|
500
|
+
type: formBodyName,
|
|
501
|
+
hasQuestionToken: allOptionalParts
|
|
502
|
+
}
|
|
503
|
+
]
|
|
504
|
+
},
|
|
505
|
+
formBodyInterface
|
|
506
|
+
];
|
|
507
|
+
} else {
|
|
508
|
+
const firstBody = bodyParameters.body[0];
|
|
509
|
+
if (!firstBody) {
|
|
510
|
+
return [];
|
|
511
|
+
}
|
|
512
|
+
const bodySignature = getPropertyFromSchema(firstBody);
|
|
513
|
+
|
|
514
|
+
return [
|
|
515
|
+
{
|
|
516
|
+
isExported: true,
|
|
517
|
+
kind: StructureKind.Interface,
|
|
518
|
+
name: bodyParameterInterfaceName,
|
|
519
|
+
properties: [
|
|
520
|
+
{
|
|
521
|
+
docs: bodySignature.docs,
|
|
522
|
+
name: "body",
|
|
523
|
+
type: bodySignature.type,
|
|
524
|
+
hasQuestionToken: bodySignature.hasQuestionToken
|
|
525
|
+
}
|
|
526
|
+
]
|
|
527
|
+
}
|
|
528
|
+
];
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export function buildBodyTypeAlias(
|
|
533
|
+
parameters: ParameterMetadatas,
|
|
534
|
+
partialBodyTypeNames: Set<string>
|
|
535
|
+
) {
|
|
536
|
+
const bodyParameters = parameters.body;
|
|
537
|
+
if (
|
|
538
|
+
!bodyParameters ||
|
|
539
|
+
!bodyParameters?.body ||
|
|
540
|
+
!bodyParameters?.body.length
|
|
541
|
+
) {
|
|
542
|
+
return undefined;
|
|
543
|
+
}
|
|
544
|
+
const schema = bodyParameters.body[0] as ObjectSchema;
|
|
545
|
+
const headerParameters = (parameters.parameters || []).filter(
|
|
546
|
+
(p) => p.type === "header" && p.name === "contentType"
|
|
547
|
+
);
|
|
548
|
+
if (!headerParameters.length || headerParameters.length > 1) {
|
|
549
|
+
return undefined;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
const firstHeader = headerParameters[0];
|
|
553
|
+
if (!firstHeader) {
|
|
554
|
+
return undefined;
|
|
555
|
+
}
|
|
556
|
+
const contentType = firstHeader.param.type;
|
|
557
|
+
const description = `${schema.description}`;
|
|
558
|
+
const typeName = `${schema.typeName}ResourceMergeAndPatch`;
|
|
559
|
+
if (partialBodyTypeNames.has(typeName)) {
|
|
560
|
+
return null;
|
|
561
|
+
} else {
|
|
562
|
+
partialBodyTypeNames.add(typeName);
|
|
563
|
+
}
|
|
564
|
+
if (contentType.includes("application/merge-patch+json")) {
|
|
565
|
+
const type = `Partial<${schema.typeName}>`;
|
|
566
|
+
return {
|
|
567
|
+
// kind: StructureKind.TypeAlias,
|
|
568
|
+
...(description && { docs: [{ description }] }),
|
|
569
|
+
name: `${typeName}`,
|
|
570
|
+
type,
|
|
571
|
+
isExported: true
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
return undefined;
|
|
575
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { OPERATION_LRO_HIGH_PRIORITY, RLCModel } from "./interfaces.js";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
+
// @ts-ignore: to fix the handlebars issue
|
|
5
|
+
import hbs from "handlebars";
|
|
6
|
+
import { hasPollingOperations } from "./helpers/operationHelpers.js";
|
|
7
|
+
import { pollingContent } from "./static/pollingContent.js";
|
|
8
|
+
|
|
9
|
+
interface LroDetail {
|
|
10
|
+
clientOverload?: boolean;
|
|
11
|
+
overloadMap?: ResponseMap[];
|
|
12
|
+
importedResponses?: string[];
|
|
13
|
+
isEsm?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ResponseMap {
|
|
17
|
+
initialResponses: string;
|
|
18
|
+
finalResponses: string;
|
|
19
|
+
precedence?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function buildPollingHelper(model: RLCModel) {
|
|
23
|
+
if (!hasPollingOperations(model)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const lroDetail: LroDetail = buildLroHelperDetail(model);
|
|
28
|
+
const readmeFileContents = hbs.compile(pollingContent, { noEscape: true });
|
|
29
|
+
const { srcPath } = model;
|
|
30
|
+
return {
|
|
31
|
+
path: path.join(srcPath, "pollingHelper.ts"),
|
|
32
|
+
content: readmeFileContents(lroDetail)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function buildLroHelperDetail(model: RLCModel): LroDetail {
|
|
37
|
+
if (!model.helperDetails?.clientLroOverload) {
|
|
38
|
+
return {
|
|
39
|
+
clientOverload: false,
|
|
40
|
+
isEsm: model.options?.moduleKind === "esm"
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const mapDetail = [];
|
|
44
|
+
const pathDictionary = model.paths;
|
|
45
|
+
const responses = new Set<string>();
|
|
46
|
+
for (const details of Object.values(pathDictionary)) {
|
|
47
|
+
for (const methodDetails of Object.values(details.methods)) {
|
|
48
|
+
const firstMethod = methodDetails[0];
|
|
49
|
+
if (!firstMethod) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const lroDetail = firstMethod.operationHelperDetail?.lroDetails;
|
|
53
|
+
if (lroDetail?.isLongRunning) {
|
|
54
|
+
const initialResponses = firstMethod.responseTypes.success.concat(
|
|
55
|
+
firstMethod.responseTypes.error
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const finalResponse = lroDetail.logicalResponseTypes?.success.concat(
|
|
59
|
+
firstMethod.responseTypes.error
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if (initialResponses && finalResponse) {
|
|
63
|
+
initialResponses.forEach((n) => responses.add(n));
|
|
64
|
+
finalResponse.forEach((n) => responses.add(n));
|
|
65
|
+
mapDetail!.push({
|
|
66
|
+
initialResponses: initialResponses.join("|"),
|
|
67
|
+
finalResponses: finalResponse.join("|"),
|
|
68
|
+
precedence: lroDetail.precedence ?? OPERATION_LRO_HIGH_PRIORITY
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Sorted by the precedence
|
|
76
|
+
mapDetail.sort((d1, d2) => d1.precedence - d2.precedence);
|
|
77
|
+
return {
|
|
78
|
+
clientOverload: responses.size > 0 && mapDetail.length > 0,
|
|
79
|
+
importedResponses: Array.from(responses),
|
|
80
|
+
overloadMap: mapDetail,
|
|
81
|
+
isEsm: model.options?.moduleKind === "esm"
|
|
82
|
+
};
|
|
83
|
+
}
|