@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,203 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
InterfaceDeclarationStructure,
|
|
6
|
+
OptionalKind,
|
|
7
|
+
Project,
|
|
8
|
+
PropertySignatureStructure,
|
|
9
|
+
StructureKind
|
|
10
|
+
} from "ts-morph";
|
|
11
|
+
import {
|
|
12
|
+
ResponseHeaderSchema,
|
|
13
|
+
ResponseMetadata,
|
|
14
|
+
RLCModel
|
|
15
|
+
} from "./interfaces.js";
|
|
16
|
+
import * as path from "path";
|
|
17
|
+
import {
|
|
18
|
+
getImportModuleName,
|
|
19
|
+
getResponseBaseName,
|
|
20
|
+
getResponseTypeName
|
|
21
|
+
} from "./helpers/nameConstructors.js";
|
|
22
|
+
import { getImportSpecifier } from "./helpers/importsUtil.js";
|
|
23
|
+
|
|
24
|
+
let hasErrorResponse = false;
|
|
25
|
+
export function buildResponseTypes(model: RLCModel) {
|
|
26
|
+
const project = new Project();
|
|
27
|
+
const srcPath = model.srcPath;
|
|
28
|
+
const filePath = path.join(srcPath, `responses.ts`);
|
|
29
|
+
hasErrorResponse = false;
|
|
30
|
+
const responsesFile = project.createSourceFile(filePath, undefined, {
|
|
31
|
+
overwrite: true
|
|
32
|
+
});
|
|
33
|
+
// Set used to track down which models need to be imported
|
|
34
|
+
// Track if we need to import RawHttpHeaders
|
|
35
|
+
let hasHeaders = false;
|
|
36
|
+
if (!model.responses) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
for (const operationResponse of model.responses) {
|
|
40
|
+
for (const response of operationResponse.responses) {
|
|
41
|
+
// Building the response type base name
|
|
42
|
+
const baseResponseName = getResponseBaseName(
|
|
43
|
+
operationResponse.operationGroup,
|
|
44
|
+
operationResponse.operationName,
|
|
45
|
+
response.statusCode
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// Build the response header
|
|
49
|
+
const headersInterface: InterfaceDeclarationStructure | undefined =
|
|
50
|
+
getResponseHeaderInterfaceDefinition(response, baseResponseName);
|
|
51
|
+
if (headersInterface) {
|
|
52
|
+
hasHeaders = true;
|
|
53
|
+
responsesFile.addInterface(headersInterface);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Get the information to build the Response Interface
|
|
57
|
+
const responseTypeName =
|
|
58
|
+
response.predefinedName ?? getResponseTypeName(baseResponseName);
|
|
59
|
+
const responseProperties = getResponseInterfaceProperties(
|
|
60
|
+
response,
|
|
61
|
+
headersInterface?.name
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const responseInterfaceDefinition: OptionalKind<InterfaceDeclarationStructure> =
|
|
65
|
+
{
|
|
66
|
+
name: responseTypeName,
|
|
67
|
+
properties: responseProperties,
|
|
68
|
+
isExported: true,
|
|
69
|
+
extends: ["HttpResponse"]
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Only add a description if one was provided in the Swagger
|
|
73
|
+
// otherwise skip to avoid having empty TSDoc lines
|
|
74
|
+
if (response.description) {
|
|
75
|
+
responseInterfaceDefinition.docs = [
|
|
76
|
+
{ description: response.description }
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Add the response interface to the responses file
|
|
81
|
+
responsesFile.addInterface(responseInterfaceDefinition);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (hasHeaders) {
|
|
86
|
+
responsesFile.addImportDeclarations([
|
|
87
|
+
{
|
|
88
|
+
isTypeOnly: true,
|
|
89
|
+
namedImports: ["RawHttpHeaders"],
|
|
90
|
+
moduleSpecifier: getImportSpecifier(
|
|
91
|
+
"restPipeline",
|
|
92
|
+
model.importInfo.runtimeImports
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
const namedImports = ["HttpResponse"];
|
|
98
|
+
if (hasErrorResponse) {
|
|
99
|
+
namedImports.push("ErrorResponse");
|
|
100
|
+
}
|
|
101
|
+
responsesFile.addImportDeclarations([
|
|
102
|
+
{
|
|
103
|
+
isTypeOnly: true,
|
|
104
|
+
namedImports,
|
|
105
|
+
moduleSpecifier: getImportSpecifier(
|
|
106
|
+
"restClient",
|
|
107
|
+
model.importInfo.runtimeImports
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
if ((model.importInfo.internalImports.response?.importsSet?.size ?? 0) > 0) {
|
|
113
|
+
const modelNamedImports = Array.from(
|
|
114
|
+
model.importInfo.internalImports.response!.importsSet!
|
|
115
|
+
).filter((modelName) => {
|
|
116
|
+
return !(modelName === "ErrorResponseOutput" && hasErrorResponse);
|
|
117
|
+
});
|
|
118
|
+
responsesFile.addImportDeclarations([
|
|
119
|
+
{
|
|
120
|
+
isTypeOnly: true,
|
|
121
|
+
namedImports: modelNamedImports,
|
|
122
|
+
moduleSpecifier: getImportModuleName(
|
|
123
|
+
{
|
|
124
|
+
cjsName: `./outputModels`,
|
|
125
|
+
esModulesName: `./outputModels.js`
|
|
126
|
+
},
|
|
127
|
+
model
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
132
|
+
return { path: filePath, content: responsesFile.getFullText() };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function getResponseHeaderInterfaceDefinition(
|
|
136
|
+
response: ResponseMetadata,
|
|
137
|
+
baseName: string
|
|
138
|
+
): undefined | InterfaceDeclarationStructure {
|
|
139
|
+
// Check if there are any required headers
|
|
140
|
+
if (!response.headers) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const headersInterfaceName = `${baseName}Headers`;
|
|
144
|
+
return {
|
|
145
|
+
kind: StructureKind.Interface,
|
|
146
|
+
isExported: true,
|
|
147
|
+
name: headersInterfaceName,
|
|
148
|
+
properties: response?.headers.map((h: ResponseHeaderSchema) => {
|
|
149
|
+
const description = h.description;
|
|
150
|
+
return {
|
|
151
|
+
name: h.name,
|
|
152
|
+
...(description && { docs: [{ description }] }),
|
|
153
|
+
type: h.type,
|
|
154
|
+
hasQuestionToken: !h.required
|
|
155
|
+
};
|
|
156
|
+
})
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Gets the properties that need to be part of the response interface
|
|
162
|
+
*/
|
|
163
|
+
function getResponseInterfaceProperties(
|
|
164
|
+
response: ResponseMetadata,
|
|
165
|
+
headersInterfaceName?: string
|
|
166
|
+
) {
|
|
167
|
+
const statusCode = response.statusCode;
|
|
168
|
+
const responseProperties: PropertySignatureStructure[] = [
|
|
169
|
+
{
|
|
170
|
+
name: "status",
|
|
171
|
+
type: statusCode === "default" ? `string` : `"${statusCode}"`,
|
|
172
|
+
kind: StructureKind.PropertySignature
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
if (response.body) {
|
|
177
|
+
const description = response.body.description;
|
|
178
|
+
let type = response.body.type;
|
|
179
|
+
if (
|
|
180
|
+
response.body.type === "ErrorResponseOutput" &&
|
|
181
|
+
response.body.fromCore
|
|
182
|
+
) {
|
|
183
|
+
type = "ErrorResponse";
|
|
184
|
+
hasErrorResponse = true;
|
|
185
|
+
}
|
|
186
|
+
responseProperties.push({
|
|
187
|
+
name: "body",
|
|
188
|
+
type,
|
|
189
|
+
kind: StructureKind.PropertySignature,
|
|
190
|
+
...(description && { docs: [{ description }] })
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (headersInterfaceName) {
|
|
195
|
+
responseProperties.push({
|
|
196
|
+
name: "headers",
|
|
197
|
+
type: `RawHttpHeaders & ${headersInterfaceName}`,
|
|
198
|
+
kind: StructureKind.PropertySignature
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return responseProperties;
|
|
203
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import { RLCModel, RLCSampleGroup, File as RLCFile } from "./interfaces.js";
|
|
5
|
+
import { sampleTemplate } from "./static/sampleTemplate.js";
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7
|
+
// @ts-ignore: to fix the handlebars issue
|
|
8
|
+
import hbs from "handlebars";
|
|
9
|
+
import * as path from "path";
|
|
10
|
+
|
|
11
|
+
// Build sample files for the model based on the sample groups
|
|
12
|
+
export function buildSamples(model: RLCModel) {
|
|
13
|
+
if (!model.options || !model.options.packageDetails) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const sampleGroups: RLCSampleGroup[] | undefined = model.sampleGroups;
|
|
17
|
+
if (!sampleGroups || sampleGroups.length === 0) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const sampleFiles: RLCFile[] = [];
|
|
21
|
+
for (const sampleGroup of sampleGroups) {
|
|
22
|
+
const sampleGroupFileContents = hbs.compile(sampleTemplate, {
|
|
23
|
+
noEscape: true
|
|
24
|
+
});
|
|
25
|
+
const filePath = path.join("samples-dev", `${sampleGroup.filename}.ts`);
|
|
26
|
+
sampleFiles.push({
|
|
27
|
+
path: filePath,
|
|
28
|
+
content: sampleGroupFileContents(sampleGroup)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return sampleFiles;
|
|
32
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import { Project } from "ts-morph";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
import {
|
|
7
|
+
buildObjectAliases,
|
|
8
|
+
buildObjectInterfaces,
|
|
9
|
+
buildPolymorphicAliases
|
|
10
|
+
} from "./buildObjectTypes.js";
|
|
11
|
+
import { RLCModel, SchemaContext } from "./interfaces.js";
|
|
12
|
+
import { getImportSpecifier } from "./helpers/importsUtil.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Generates types to represent schema definitions in the swagger
|
|
16
|
+
*/
|
|
17
|
+
export function buildSchemaTypes(model: RLCModel) {
|
|
18
|
+
const { srcPath } = model;
|
|
19
|
+
const project = new Project();
|
|
20
|
+
let filePath = path.join(srcPath, `models.ts`);
|
|
21
|
+
const inputModelFile = generateModelFiles(model, project, filePath, [
|
|
22
|
+
SchemaContext.Input
|
|
23
|
+
]);
|
|
24
|
+
filePath = path.join(srcPath, `outputModels.ts`);
|
|
25
|
+
const outputModelFile = generateModelFiles(model, project, filePath, [
|
|
26
|
+
SchemaContext.Output,
|
|
27
|
+
SchemaContext.Exception
|
|
28
|
+
]);
|
|
29
|
+
return { inputModelFile, outputModelFile };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function generateModelFiles(
|
|
33
|
+
model: RLCModel,
|
|
34
|
+
project: Project,
|
|
35
|
+
filePath: string,
|
|
36
|
+
schemaContext: SchemaContext[]
|
|
37
|
+
) {
|
|
38
|
+
// Track models that need to be imported
|
|
39
|
+
const importedModels = new Set<string>();
|
|
40
|
+
const objectsDefinitions = buildObjectInterfaces(
|
|
41
|
+
model,
|
|
42
|
+
importedModels,
|
|
43
|
+
schemaContext
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const objectTypeAliases = buildPolymorphicAliases(model, schemaContext);
|
|
47
|
+
|
|
48
|
+
const objectAliases = buildObjectAliases(
|
|
49
|
+
model,
|
|
50
|
+
importedModels,
|
|
51
|
+
schemaContext
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
objectTypeAliases.length ||
|
|
56
|
+
objectsDefinitions.length ||
|
|
57
|
+
objectAliases.length
|
|
58
|
+
) {
|
|
59
|
+
const modelsFile = project.createSourceFile(filePath, undefined, {
|
|
60
|
+
overwrite: true
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
modelsFile.addInterfaces(objectsDefinitions);
|
|
64
|
+
modelsFile.addTypeAliases(objectTypeAliases);
|
|
65
|
+
modelsFile.addTypeAliases(objectAliases);
|
|
66
|
+
if (importedModels.size > 0) {
|
|
67
|
+
modelsFile.addImportDeclarations([
|
|
68
|
+
{
|
|
69
|
+
isTypeOnly: true,
|
|
70
|
+
namedImports: [...Array.from(importedModels || [])],
|
|
71
|
+
moduleSpecifier: getImportSpecifier(
|
|
72
|
+
"restClient",
|
|
73
|
+
model.importInfo.runtimeImports
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
return { path: filePath, content: modelsFile.getFullText() };
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { 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 {
|
|
7
|
+
hasCsvCollection,
|
|
8
|
+
hasMultiCollection,
|
|
9
|
+
hasPipeCollection,
|
|
10
|
+
hasSsvCollection,
|
|
11
|
+
hasTsvCollection
|
|
12
|
+
} from "./helpers/operationHelpers.js";
|
|
13
|
+
import {
|
|
14
|
+
buildCsvCollectionContent,
|
|
15
|
+
buildMultiCollectionContent,
|
|
16
|
+
buildPipeCollectionContent,
|
|
17
|
+
buildSsvCollectionContent,
|
|
18
|
+
buildTsvCollectionContent
|
|
19
|
+
} from "./static/serializeHelper.js";
|
|
20
|
+
|
|
21
|
+
export function buildSerializeHelper(model: RLCModel) {
|
|
22
|
+
let serializeHelperContent = "";
|
|
23
|
+
if (hasMultiCollection(model)) {
|
|
24
|
+
serializeHelperContent += "\n" + buildMultiCollectionContent;
|
|
25
|
+
}
|
|
26
|
+
if (hasPipeCollection(model)) {
|
|
27
|
+
serializeHelperContent += "\n" + buildPipeCollectionContent;
|
|
28
|
+
}
|
|
29
|
+
if (hasSsvCollection(model)) {
|
|
30
|
+
serializeHelperContent += "\n" + buildSsvCollectionContent;
|
|
31
|
+
}
|
|
32
|
+
if (hasTsvCollection(model)) {
|
|
33
|
+
serializeHelperContent += "\n" + buildTsvCollectionContent;
|
|
34
|
+
}
|
|
35
|
+
if (hasCsvCollection(model)) {
|
|
36
|
+
serializeHelperContent += "\n" + buildCsvCollectionContent;
|
|
37
|
+
}
|
|
38
|
+
if (serializeHelperContent !== "") {
|
|
39
|
+
const readmeFileContents = hbs.compile(serializeHelperContent, {
|
|
40
|
+
noEscape: true
|
|
41
|
+
});
|
|
42
|
+
const { srcPath } = model;
|
|
43
|
+
return {
|
|
44
|
+
path: path.join(srcPath, "serializeHelper.ts"),
|
|
45
|
+
content: readmeFileContents({})
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import { NameType, normalizeName } from "./helpers/nameUtils.js";
|
|
5
|
+
import { RLCModel } from "./interfaces.js";
|
|
6
|
+
import { Project } from "ts-morph";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
import { getRelativePartFromSrcPath } from "./helpers/pathUtils.js";
|
|
9
|
+
import { getImportModuleName } from "./helpers/nameConstructors.js";
|
|
10
|
+
|
|
11
|
+
const batchOutputFolder: [string, string, string][] = [];
|
|
12
|
+
|
|
13
|
+
export function buildTopLevelIndex(model: RLCModel) {
|
|
14
|
+
if (!model.options) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const project = new Project();
|
|
18
|
+
const { srcPath } = model;
|
|
19
|
+
const { multiClient } = model.options;
|
|
20
|
+
const batch = model.options.batch;
|
|
21
|
+
if (srcPath) {
|
|
22
|
+
const clientName = model.libraryName;
|
|
23
|
+
const moduleName = normalizeName(clientName, NameType.File);
|
|
24
|
+
const relativePath =
|
|
25
|
+
"./" +
|
|
26
|
+
getRelativePartFromSrcPath(srcPath, model.options.isModularLibrary);
|
|
27
|
+
batchOutputFolder.push([relativePath, clientName, moduleName]);
|
|
28
|
+
}
|
|
29
|
+
if (
|
|
30
|
+
multiClient &&
|
|
31
|
+
batch &&
|
|
32
|
+
batch.length > 1 &&
|
|
33
|
+
batchOutputFolder.length === batch.length
|
|
34
|
+
) {
|
|
35
|
+
const indexFile = project.createSourceFile("index.ts", undefined, {
|
|
36
|
+
overwrite: true
|
|
37
|
+
});
|
|
38
|
+
const allModules: string[] = [];
|
|
39
|
+
batchOutputFolder.forEach((item) => {
|
|
40
|
+
indexFile.addImportDeclaration({
|
|
41
|
+
isTypeOnly: true,
|
|
42
|
+
namespaceImport: item[1],
|
|
43
|
+
moduleSpecifier: getImportModuleName(
|
|
44
|
+
{
|
|
45
|
+
cjsName: `${item[0]}`,
|
|
46
|
+
esModulesName: `${item[0]}/index.js`
|
|
47
|
+
},
|
|
48
|
+
model
|
|
49
|
+
)
|
|
50
|
+
});
|
|
51
|
+
allModules.push(item[1]);
|
|
52
|
+
});
|
|
53
|
+
indexFile.addExportDeclaration({
|
|
54
|
+
namedExports: [...allModules]
|
|
55
|
+
});
|
|
56
|
+
const content = indexFile.getFullText();
|
|
57
|
+
const filePath = path.join(
|
|
58
|
+
srcPath.substring(0, srcPath.lastIndexOf("src") + 4),
|
|
59
|
+
model.options.isModularLibrary ? "rest" : "",
|
|
60
|
+
`index.ts`
|
|
61
|
+
);
|
|
62
|
+
return { path: filePath, content };
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ApiVersionInfo, ApiVersionPosition, UrlInfo } from "../interfaces.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extract the path api-version detail from UrlInfo, return undefined if no valid api-version parameter
|
|
5
|
+
* @param urlInfo UrlInfo detail
|
|
6
|
+
* @returns path api-version detail
|
|
7
|
+
*/
|
|
8
|
+
export function extractPathApiVersion(
|
|
9
|
+
urlInfo?: UrlInfo
|
|
10
|
+
): ApiVersionInfo | undefined {
|
|
11
|
+
if (!urlInfo) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const param = urlInfo.urlParameters?.filter(
|
|
15
|
+
(p) =>
|
|
16
|
+
p.name.toLowerCase() === "api-version" ||
|
|
17
|
+
p.name.toLowerCase() === "apiversion"
|
|
18
|
+
);
|
|
19
|
+
if (!param || param?.length < 1) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const detail: ApiVersionInfo = {
|
|
23
|
+
definedPosition: "path",
|
|
24
|
+
isCrossedVersion: Boolean(param?.length > 1),
|
|
25
|
+
defaultValue:
|
|
26
|
+
param.length === 1 ? (param[0]?.value as string | undefined) : undefined,
|
|
27
|
+
required: true
|
|
28
|
+
};
|
|
29
|
+
return detail;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Extract the final position value from api-version in query and path defined.
|
|
34
|
+
* it could be in either the url or the operation level,
|
|
35
|
+
* and in operation level, it could be either path or query.
|
|
36
|
+
* @param operationApiVersion api-version detail in both query and path
|
|
37
|
+
* @param urlVersionDetail api-version detail in parameterized host
|
|
38
|
+
* @returns calculated combined position info
|
|
39
|
+
*/
|
|
40
|
+
export function extractDefinedPosition(
|
|
41
|
+
operationApiVersion?: ApiVersionInfo,
|
|
42
|
+
urlVersionDetail?: ApiVersionInfo
|
|
43
|
+
): ApiVersionPosition {
|
|
44
|
+
let pos: ApiVersionPosition = "none";
|
|
45
|
+
if (operationApiVersion && urlVersionDetail) {
|
|
46
|
+
pos = "duplicate";
|
|
47
|
+
} else if (operationApiVersion?.definedPosition) {
|
|
48
|
+
pos = operationApiVersion.definedPosition!;
|
|
49
|
+
} else if (urlVersionDetail) {
|
|
50
|
+
pos = "baseurl";
|
|
51
|
+
}
|
|
52
|
+
return pos;
|
|
53
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { SourceFile } from "ts-morph";
|
|
2
|
+
import { ImportType, Imports, PackageFlavor } from "../interfaces.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Build the common imports for generated SDK
|
|
6
|
+
* @param flavor flavor of SDK to generate, if any. When set to "azure", Azure Core packages will be used. When unset, the generic `ts-http-runtime` package will be used.
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export function buildRuntimeImports(flavor?: PackageFlavor): Imports {
|
|
10
|
+
if (flavor === "azure") {
|
|
11
|
+
return {
|
|
12
|
+
restClient: {
|
|
13
|
+
type: "restClient",
|
|
14
|
+
specifier: "@azure-rest/core-client",
|
|
15
|
+
version: "^2.0.0"
|
|
16
|
+
},
|
|
17
|
+
coreAuth: {
|
|
18
|
+
type: "coreAuth",
|
|
19
|
+
specifier: "@azure/core-auth",
|
|
20
|
+
version: "^1.6.0"
|
|
21
|
+
},
|
|
22
|
+
restPipeline: {
|
|
23
|
+
type: "restPipeline",
|
|
24
|
+
specifier: "@azure/core-rest-pipeline",
|
|
25
|
+
version: "^1.14.0"
|
|
26
|
+
},
|
|
27
|
+
coreUtil: {
|
|
28
|
+
type: "coreUtil",
|
|
29
|
+
specifier: "@azure/core-util",
|
|
30
|
+
version: "^1.4.0"
|
|
31
|
+
},
|
|
32
|
+
coreLogger: {
|
|
33
|
+
type: "coreLogger",
|
|
34
|
+
specifier: "@azure/logger",
|
|
35
|
+
version: "^1.0.4"
|
|
36
|
+
},
|
|
37
|
+
azureEslintPlugin: {
|
|
38
|
+
type: "azureEslintPlugin",
|
|
39
|
+
specifier: "@azure/eslint-plugin-azure-sdk",
|
|
40
|
+
version: "^3.0.0"
|
|
41
|
+
},
|
|
42
|
+
azureTestRecorder: {
|
|
43
|
+
type: "azureTestRecorder",
|
|
44
|
+
specifier: "@azure-tools/test-recorder",
|
|
45
|
+
version: "^3.0.0"
|
|
46
|
+
},
|
|
47
|
+
azureCoreLro: {
|
|
48
|
+
type: "azureCoreLro",
|
|
49
|
+
specifier: "@azure/core-lro"
|
|
50
|
+
}
|
|
51
|
+
} as Imports;
|
|
52
|
+
} else {
|
|
53
|
+
// In non-azure branded scope we only have one dependency that is ts-http-runtime
|
|
54
|
+
return {
|
|
55
|
+
commonFallback: {
|
|
56
|
+
type: "commonFallback",
|
|
57
|
+
specifier: "@typespec/ts-http-runtime",
|
|
58
|
+
version: "0.1.0"
|
|
59
|
+
}
|
|
60
|
+
} as Imports;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Initialize the inner imports for parameter and response, the import set would be used for referred models
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
export function initInternalImports(): Imports {
|
|
69
|
+
return {
|
|
70
|
+
parameter: {
|
|
71
|
+
type: "parameter",
|
|
72
|
+
importsSet: new Set<string>()
|
|
73
|
+
},
|
|
74
|
+
response: {
|
|
75
|
+
type: "response",
|
|
76
|
+
importsSet: new Set<string>()
|
|
77
|
+
},
|
|
78
|
+
rlcIndex: {
|
|
79
|
+
type: "rlcIndex",
|
|
80
|
+
importsSet: new Set<string>()
|
|
81
|
+
},
|
|
82
|
+
modularModel: {
|
|
83
|
+
type: "modularModel",
|
|
84
|
+
importsSet: new Set<string>()
|
|
85
|
+
},
|
|
86
|
+
rlcClientFactory: {
|
|
87
|
+
type: "rlcClientFactory",
|
|
88
|
+
importsSet: new Set<string>()
|
|
89
|
+
},
|
|
90
|
+
rlcClientDefinition: {
|
|
91
|
+
type: "rlcClientDefinition",
|
|
92
|
+
importsSet: new Set<string>()
|
|
93
|
+
},
|
|
94
|
+
serializerHelpers: {
|
|
95
|
+
type: "serializerHelpers",
|
|
96
|
+
importsSet: new Set<string>()
|
|
97
|
+
}
|
|
98
|
+
} as Imports;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function getImportSpecifier(
|
|
102
|
+
importType: ImportType,
|
|
103
|
+
imports?: Imports,
|
|
104
|
+
includeFallback = true
|
|
105
|
+
): string {
|
|
106
|
+
imports = imports ?? ({} as Imports);
|
|
107
|
+
const defaultPackageMap: Record<ImportType, string> = {
|
|
108
|
+
restClient: "@azure-rest/core-client",
|
|
109
|
+
coreAuth: "@azure/core-auth",
|
|
110
|
+
restPipeline: "@azure/core-rest-pipeline",
|
|
111
|
+
coreUtil: "@azure/core-util",
|
|
112
|
+
coreLogger: "@azure/logger",
|
|
113
|
+
azureCoreLro: "@azure/core-lro"
|
|
114
|
+
} as any;
|
|
115
|
+
if (!includeFallback) {
|
|
116
|
+
return imports[importType]?.specifier ?? "";
|
|
117
|
+
}
|
|
118
|
+
return (
|
|
119
|
+
(imports[importType] ?? imports.commonFallback)?.specifier ??
|
|
120
|
+
defaultPackageMap[importType] ??
|
|
121
|
+
""
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function addImportToSpecifier(
|
|
126
|
+
importType: ImportType,
|
|
127
|
+
runtimeImports: Imports,
|
|
128
|
+
importedName: string
|
|
129
|
+
): void {
|
|
130
|
+
const specifier = getImportSpecifier(importType, runtimeImports);
|
|
131
|
+
const importSet = runtimeImports[importType]?.importsSet;
|
|
132
|
+
if (!importSet) {
|
|
133
|
+
runtimeImports[importType] = {
|
|
134
|
+
type: importType,
|
|
135
|
+
specifier,
|
|
136
|
+
importsSet: new Set<string>().add(importedName)
|
|
137
|
+
};
|
|
138
|
+
} else {
|
|
139
|
+
importSet.add(importedName);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function clearImportSets(runtimeImports: Imports): void {
|
|
144
|
+
for (const importType of Object.values(runtimeImports)) {
|
|
145
|
+
importType.importsSet?.clear();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function addImportsToFiles(
|
|
150
|
+
runtimeImports: Imports,
|
|
151
|
+
file: SourceFile,
|
|
152
|
+
internalSpecifierMap?: Record<string, string>
|
|
153
|
+
): void {
|
|
154
|
+
Object.values(runtimeImports)
|
|
155
|
+
.filter((importType) => {
|
|
156
|
+
return importType.importsSet?.size;
|
|
157
|
+
})
|
|
158
|
+
.forEach((importType) => {
|
|
159
|
+
const specifier =
|
|
160
|
+
internalSpecifierMap?.[importType.type] ?? importType.specifier!;
|
|
161
|
+
let hasModifier = false;
|
|
162
|
+
if (!specifier) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
file
|
|
166
|
+
.getImportDeclarations()
|
|
167
|
+
.filter((importDeclaration) => {
|
|
168
|
+
return importDeclaration.getModuleSpecifierValue() === specifier;
|
|
169
|
+
})
|
|
170
|
+
.forEach((importDeclaration) => {
|
|
171
|
+
hasModifier = true;
|
|
172
|
+
importDeclaration.addNamedImports([
|
|
173
|
+
...importType.importsSet!.values()
|
|
174
|
+
]);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
if (!hasModifier) {
|
|
178
|
+
file.addImportDeclaration({
|
|
179
|
+
isTypeOnly: true,
|
|
180
|
+
moduleSpecifier: specifier,
|
|
181
|
+
namedImports: [...importType.importsSet!.values()]
|
|
182
|
+
});
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
clearImportSets(runtimeImports);
|
|
187
|
+
}
|