@azure-tools/typespec-ts 0.54.0 → 0.55.0-dev.1
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 +25 -10
- package/README.md +0 -4
- package/dist/src/contextManager.d.ts +5 -5
- package/dist/src/contextManager.d.ts.map +1 -1
- package/dist/src/contextManager.js +3 -3
- package/dist/src/contextManager.js.map +1 -1
- package/dist/src/framework/declaration.d.ts +1 -1
- package/dist/src/framework/declaration.d.ts.map +1 -1
- package/dist/src/framework/declaration.js +2 -4
- package/dist/src/framework/declaration.js.map +1 -1
- package/dist/src/framework/dependency.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.d.ts +1 -1
- package/dist/src/framework/hooks/binder.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.js +31 -40
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/sdkTypes.d.ts +1 -1
- package/dist/src/framework/hooks/sdkTypes.d.ts.map +1 -1
- package/dist/src/framework/hooks/sdkTypes.js +8 -12
- package/dist/src/framework/hooks/sdkTypes.js.map +1 -1
- package/dist/src/framework/hooks/useDependencies.d.ts.map +1 -1
- package/dist/src/framework/hooks/useDependencies.js +1 -1
- package/dist/src/framework/hooks/useDependencies.js.map +1 -1
- package/dist/src/framework/load-static-helpers.d.ts +1 -1
- package/dist/src/framework/load-static-helpers.d.ts.map +1 -1
- package/dist/src/framework/load-static-helpers.js +17 -31
- package/dist/src/framework/load-static-helpers.js.map +1 -1
- package/dist/src/framework/reference.d.ts.map +1 -1
- package/dist/src/framework/reference.js +2 -2
- package/dist/src/framework/reference.js.map +1 -1
- package/dist/src/framework/sample.js +8 -8
- package/dist/src/framework/sample.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +103 -92
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +1 -1
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +140 -140
- package/dist/src/lib.js.map +1 -1
- package/dist/src/metaTree.d.ts +1 -1
- package/dist/src/metaTree.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +60 -74
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.d.ts +2 -2
- package/dist/src/modular/buildClassicalOperationGroups.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js +8 -10
- package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
- package/dist/src/modular/buildClientContext.d.ts +2 -2
- package/dist/src/modular/buildClientContext.d.ts.map +1 -1
- package/dist/src/modular/buildClientContext.js +31 -38
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildModularOptions.d.ts +1 -1
- package/dist/src/modular/buildModularOptions.d.ts.map +1 -1
- package/dist/src/modular/buildModularOptions.js +5 -6
- package/dist/src/modular/buildModularOptions.js.map +1 -1
- package/dist/src/modular/buildOperations.d.ts +3 -3
- package/dist/src/modular/buildOperations.d.ts.map +1 -1
- package/dist/src/modular/buildOperations.js +23 -25
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildProjectFiles.d.ts +1 -1
- package/dist/src/modular/buildProjectFiles.d.ts.map +1 -1
- package/dist/src/modular/buildProjectFiles.js +8 -11
- package/dist/src/modular/buildProjectFiles.js.map +1 -1
- package/dist/src/modular/buildRestorePoller.d.ts +1 -1
- package/dist/src/modular/buildRestorePoller.d.ts.map +1 -1
- package/dist/src/modular/buildRestorePoller.js +12 -13
- package/dist/src/modular/buildRestorePoller.js.map +1 -1
- package/dist/src/modular/buildRootIndex.d.ts +2 -2
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
- package/dist/src/modular/buildRootIndex.js +36 -50
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/buildSubpathIndex.d.ts.map +1 -1
- package/dist/src/modular/buildSubpathIndex.js +9 -18
- package/dist/src/modular/buildSubpathIndex.js.map +1 -1
- package/dist/src/modular/emitLoggerFile.d.ts.map +1 -1
- package/dist/src/modular/emitLoggerFile.js +4 -4
- package/dist/src/modular/emitLoggerFile.js.map +1 -1
- package/dist/src/modular/emitModels.d.ts +1 -1
- package/dist/src/modular/emitModels.d.ts.map +1 -1
- package/dist/src/modular/emitModels.js +81 -113
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/emitModelsOptions.d.ts +1 -1
- package/dist/src/modular/emitModelsOptions.d.ts.map +1 -1
- package/dist/src/modular/emitModelsOptions.js +7 -8
- package/dist/src/modular/emitModelsOptions.js.map +1 -1
- package/dist/src/modular/emitSamples.d.ts.map +1 -1
- package/dist/src/modular/emitSamples.js +69 -77
- package/dist/src/modular/emitSamples.js.map +1 -1
- package/dist/src/modular/emitTests.d.ts.map +1 -1
- package/dist/src/modular/emitTests.js +13 -18
- package/dist/src/modular/emitTests.js.map +1 -1
- package/dist/src/modular/external-dependencies.js +54 -54
- package/dist/src/modular/helpers/classicalOperationHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.js +59 -68
- package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.d.ts +2 -2
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +31 -54
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.js +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.js.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.d.ts +2 -2
- package/dist/src/modular/helpers/exampleValueHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.js +72 -84
- package/dist/src/modular/helpers/exampleValueHelpers.js.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.js +7 -10
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +2 -2
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +204 -288
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +4 -6
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.d.ts +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.js +58 -67
- package/dist/src/modular/serialization/buildDeserializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.d.ts +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js +65 -75
- package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.d.ts +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js +73 -90
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/serializeUtils.d.ts.map +1 -1
- package/dist/src/modular/serialization/serializeUtils.js +25 -33
- package/dist/src/modular/serialization/serializeUtils.js.map +1 -1
- package/dist/src/modular/static-helpers-metadata.js +60 -60
- package/dist/src/modular/type-expressions/get-credential-expression.js +1 -1
- package/dist/src/modular/type-expressions/get-credential-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.d.ts +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.js +1 -2
- package/dist/src/modular/type-expressions/get-enum-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-model-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-model-expression.js +10 -13
- package/dist/src/modular/type-expressions/get-model-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.d.ts +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.js +2 -3
- package/dist/src/modular/type-expressions/get-nullable-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.js +5 -11
- package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-union-expression.d.ts +1 -1
- package/dist/src/modular/type-expressions/get-union-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-union-expression.js.map +1 -1
- package/dist/src/rlc-common/buildClient.d.ts +1 -1
- package/dist/src/rlc-common/buildClient.d.ts.map +1 -1
- package/dist/src/rlc-common/buildClient.js +67 -89
- package/dist/src/rlc-common/buildClient.js.map +1 -1
- package/dist/src/rlc-common/buildClientDefinitions.d.ts.map +1 -1
- package/dist/src/rlc-common/buildClientDefinitions.js +28 -45
- package/dist/src/rlc-common/buildClientDefinitions.js.map +1 -1
- package/dist/src/rlc-common/buildIndexFile.d.ts.map +1 -1
- package/dist/src/rlc-common/buildIndexFile.js +59 -60
- package/dist/src/rlc-common/buildIndexFile.js.map +1 -1
- package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js +37 -38
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +1 -1
- package/dist/src/rlc-common/buildLogger.d.ts.map +1 -1
- package/dist/src/rlc-common/buildLogger.js +4 -5
- package/dist/src/rlc-common/buildLogger.js.map +1 -1
- package/dist/src/rlc-common/buildMethodShortcuts.d.ts.map +1 -1
- package/dist/src/rlc-common/buildMethodShortcuts.js +4 -4
- package/dist/src/rlc-common/buildMethodShortcuts.js.map +1 -1
- package/dist/src/rlc-common/buildObjectTypes.d.ts.map +1 -1
- package/dist/src/rlc-common/buildObjectTypes.js +57 -96
- package/dist/src/rlc-common/buildObjectTypes.js.map +1 -1
- package/dist/src/rlc-common/buildPaginateHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildPaginateHelper.js +2 -2
- package/dist/src/rlc-common/buildPaginateHelper.js.map +1 -1
- package/dist/src/rlc-common/buildParameterTypes.d.ts.map +1 -1
- package/dist/src/rlc-common/buildParameterTypes.js +71 -61
- package/dist/src/rlc-common/buildParameterTypes.js.map +1 -1
- package/dist/src/rlc-common/buildPollingHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildPollingHelper.js +9 -10
- package/dist/src/rlc-common/buildPollingHelper.js.map +1 -1
- package/dist/src/rlc-common/buildResponseTypes.d.ts.map +1 -1
- package/dist/src/rlc-common/buildResponseTypes.js +23 -27
- package/dist/src/rlc-common/buildResponseTypes.js.map +1 -1
- package/dist/src/rlc-common/buildSamples.d.ts +1 -1
- package/dist/src/rlc-common/buildSamples.d.ts.map +1 -1
- package/dist/src/rlc-common/buildSamples.js +2 -2
- package/dist/src/rlc-common/buildSchemaType.d.ts.map +1 -1
- package/dist/src/rlc-common/buildSchemaType.js +31 -13
- package/dist/src/rlc-common/buildSchemaType.js.map +1 -1
- package/dist/src/rlc-common/buildSerializeHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildSerializeHelper.js +4 -4
- package/dist/src/rlc-common/buildSerializeHelper.js.map +1 -1
- package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts.map +1 -1
- package/dist/src/rlc-common/buildTopLevelIndexFile.js +9 -13
- package/dist/src/rlc-common/buildTopLevelIndexFile.js.map +1 -1
- package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/apiVersionUtil.js +6 -8
- package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/importsUtil.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/importsUtil.js +32 -37
- package/dist/src/rlc-common/helpers/importsUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/nameConstructors.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/nameConstructors.js +2 -4
- package/dist/src/rlc-common/helpers/nameConstructors.js.map +1 -1
- package/dist/src/rlc-common/helpers/nameUtils.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/nameUtils.js +17 -23
- package/dist/src/rlc-common/helpers/nameUtils.js.map +1 -1
- package/dist/src/rlc-common/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/operationHelpers.js +16 -31
- package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/packageUtil.js +3 -6
- package/dist/src/rlc-common/helpers/packageUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/pathUtils.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/pathUtils.js +1 -3
- package/dist/src/rlc-common/helpers/pathUtils.js.map +1 -1
- package/dist/src/rlc-common/helpers/schemaHelpers.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/schemaHelpers.js +3 -7
- package/dist/src/rlc-common/helpers/schemaHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/shortcutMethods.d.ts +1 -1
- package/dist/src/rlc-common/helpers/shortcutMethods.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/shortcutMethods.js +2 -2
- package/dist/src/rlc-common/helpers/shortcutMethods.js.map +1 -1
- package/dist/src/rlc-common/helpers/typeUtil.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/typeUtil.js +4 -9
- package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js +7 -11
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +1 -1
- package/dist/src/rlc-common/index.d.ts +28 -28
- package/dist/src/rlc-common/index.d.ts.map +1 -1
- package/dist/src/rlc-common/index.js +28 -28
- package/dist/src/rlc-common/index.js.map +1 -1
- package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
- package/dist/src/rlc-common/interfaces.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +14 -15
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildChangelogFile.js +2 -3
- package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildESLintConfig.js +5 -8
- package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildLicenseFile.js +1 -1
- package/dist/src/rlc-common/metadata/buildPackageFile.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildPackageFile.js +33 -37
- package/dist/src/rlc-common/metadata/buildPackageFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildReadmeFile.js +31 -39
- package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildRollupConfig.js +4 -6
- package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +3 -5
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTestConfig.js +11 -12
- package/dist/src/rlc-common/metadata/buildTestConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTsConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildTsConfig.js +28 -28
- package/dist/src/rlc-common/metadata/buildTsConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildVitestConfig.js +3 -5
- package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildWarpConfig.js +4 -5
- package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +14 -14
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +24 -29
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js +15 -16
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js +8 -8
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +28 -31
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -1
- package/dist/src/rlc-common/metadata/utils.js +1 -2
- package/dist/src/rlc-common/metadata/utils.js.map +1 -1
- package/dist/src/rlc-common/test/buildKarmaConfig.js +1 -1
- package/dist/src/rlc-common/test/buildRecordedClient.js +4 -5
- package/dist/src/rlc-common/test/buildRecordedClient.js.map +1 -1
- package/dist/src/rlc-common/test/buildSampleTest.d.ts.map +1 -1
- package/dist/src/rlc-common/test/buildSampleTest.js +3 -4
- package/dist/src/rlc-common/test/buildSampleTest.js.map +1 -1
- package/dist/src/rlc-common/test/buildSnippets.d.ts.map +1 -1
- package/dist/src/rlc-common/test/buildSnippets.js +7 -10
- package/dist/src/rlc-common/test/buildSnippets.js.map +1 -1
- package/dist/src/rlc-common/transformSampleGroups.d.ts.map +1 -1
- package/dist/src/rlc-common/transformSampleGroups.js +41 -45
- package/dist/src/rlc-common/transformSampleGroups.js.map +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +1 -1
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/transform/transform.d.ts +1 -1
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/transform/transform.js +28 -27
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +12 -14
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js +11 -14
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
- package/dist/src/transform/transformParameters.d.ts +2 -2
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +32 -45
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.d.ts +1 -1
- package/dist/src/transform/transformPaths.d.ts.map +1 -1
- package/dist/src/transform/transformPaths.js +19 -23
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.d.ts +1 -1
- package/dist/src/transform/transformResponses.d.ts.map +1 -1
- package/dist/src/transform/transformResponses.js +21 -25
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.d.ts.map +1 -1
- package/dist/src/transform/transformSchemas.js +21 -32
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/src/transform/transformTelemetryInfo.d.ts +1 -1
- package/dist/src/transform/transformTelemetryInfo.d.ts.map +1 -1
- package/dist/src/transform/transformTelemetryInfo.js +3 -3
- package/dist/src/transform/transformTelemetryInfo.js.map +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +28 -39
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/clientUtils.d.ts +1 -1
- package/dist/src/utils/clientUtils.d.ts.map +1 -1
- package/dist/src/utils/clientUtils.js +15 -23
- package/dist/src/utils/clientUtils.js.map +1 -1
- package/dist/src/utils/credentialUtils.d.ts +1 -1
- package/dist/src/utils/credentialUtils.d.ts.map +1 -1
- package/dist/src/utils/credentialUtils.js +4 -5
- package/dist/src/utils/credentialUtils.js.map +1 -1
- package/dist/src/utils/crossLanguageDef.d.ts.map +1 -1
- package/dist/src/utils/crossLanguageDef.js +11 -15
- package/dist/src/utils/crossLanguageDef.js.map +1 -1
- package/dist/src/utils/emitUtil.d.ts +1 -1
- package/dist/src/utils/emitUtil.d.ts.map +1 -1
- package/dist/src/utils/emitUtil.js +5 -7
- package/dist/src/utils/emitUtil.js.map +1 -1
- package/dist/src/utils/fileSystemUtils.d.ts +2 -0
- package/dist/src/utils/fileSystemUtils.d.ts.map +1 -1
- package/dist/src/utils/fileSystemUtils.js +26 -7
- package/dist/src/utils/fileSystemUtils.js.map +1 -1
- package/dist/src/utils/importHelper.d.ts.map +1 -1
- package/dist/src/utils/importHelper.js +3 -6
- package/dist/src/utils/importHelper.js.map +1 -1
- package/dist/src/utils/interfaces.d.ts +1 -1
- package/dist/src/utils/interfaces.d.ts.map +1 -1
- package/dist/src/utils/mediaTypes.d.ts.map +1 -1
- package/dist/src/utils/mediaTypes.js +7 -19
- package/dist/src/utils/mediaTypes.js.map +1 -1
- package/dist/src/utils/modelUtils.d.ts +5 -5
- package/dist/src/utils/modelUtils.d.ts.map +1 -1
- package/dist/src/utils/modelUtils.js +168 -257
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/namespaceUtils.d.ts.map +1 -1
- package/dist/src/utils/namespaceUtils.js +6 -7
- package/dist/src/utils/namespaceUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.d.ts +1 -1
- package/dist/src/utils/operationUtil.d.ts.map +1 -1
- package/dist/src/utils/operationUtil.js +60 -81
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/src/utils/parameterUtils.d.ts +1 -1
- package/dist/src/utils/parameterUtils.d.ts.map +1 -1
- package/dist/src/utils/parameterUtils.js +26 -33
- package/dist/src/utils/parameterUtils.js.map +1 -1
- package/dist/src/utils/resolve-project-root.js +2 -2
- package/dist/src/utils/resolve-project-root.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +38 -45
- package/src/contextManager.ts +6 -9
- package/src/framework/declaration.ts +18 -28
- package/src/framework/dependency.ts +1 -2
- package/src/framework/hooks/binder.ts +47 -120
- package/src/framework/hooks/sdkTypes.ts +27 -54
- package/src/framework/hooks/useDependencies.ts +2 -4
- package/src/framework/load-static-helpers.ts +28 -51
- package/src/framework/reference.ts +2 -5
- package/src/framework/sample.ts +9 -9
- package/src/index.ts +145 -185
- package/src/lib.ts +143 -158
- package/src/metaTree.ts +1 -1
- package/src/modular/buildClassicalClient.ts +83 -160
- package/src/modular/buildClassicalOperationGroups.ts +14 -39
- package/src/modular/buildClientContext.ts +54 -83
- package/src/modular/buildModularOptions.ts +4 -5
- package/src/modular/buildOperations.ts +46 -73
- package/src/modular/buildProjectFiles.ts +18 -47
- package/src/modular/buildRestorePoller.ts +27 -46
- package/src/modular/buildRootIndex.ts +86 -160
- package/src/modular/buildSubpathIndex.ts +35 -58
- package/src/modular/emitLoggerFile.ts +4 -9
- package/src/modular/emitModels.ts +136 -266
- package/src/modular/emitModelsOptions.ts +10 -16
- package/src/modular/emitSamples.ts +92 -180
- package/src/modular/emitTests.ts +28 -61
- package/src/modular/external-dependencies.ts +54 -54
- package/src/modular/helpers/classicalOperationHelpers.ts +73 -126
- package/src/modular/helpers/clientHelpers.ts +41 -88
- package/src/modular/helpers/clientOptionHelpers.ts +4 -11
- package/src/modular/helpers/exampleValueHelpers.ts +99 -215
- package/src/modular/helpers/namingHelpers.ts +12 -28
- package/src/modular/helpers/operationHelpers.ts +430 -757
- package/src/modular/helpers/typeHelpers.ts +11 -22
- package/src/modular/serialization/buildDeserializerFunction.ts +88 -122
- package/src/modular/serialization/buildSerializerFunction.ts +91 -129
- package/src/modular/serialization/buildXmlSerializerFunction.ts +104 -183
- package/src/modular/serialization/serializeUtils.ts +12 -22
- package/src/modular/static/rollup.test.config.js +11 -14
- package/src/modular/static/scripts/renameOutput.mjs +2 -2
- package/src/modular/static-helpers-metadata.ts +60 -60
- package/src/modular/type-expressions/get-credential-expression.ts +1 -1
- package/src/modular/type-expressions/get-enum-expression.ts +5 -10
- package/src/modular/type-expressions/get-model-expression.ts +13 -17
- package/src/modular/type-expressions/get-nullable-expression.ts +4 -5
- package/src/modular/type-expressions/get-type-expression.ts +8 -12
- package/src/modular/type-expressions/get-union-expression.ts +4 -4
- package/src/modular/type-expressions/utils.ts +1 -1
- package/src/rlc-common/buildClient.ts +70 -141
- package/src/rlc-common/buildClientDefinitions.ts +44 -87
- package/src/rlc-common/buildIndexFile.ts +78 -78
- package/src/rlc-common/buildIsUnexpectedHelper.ts +34 -41
- package/src/rlc-common/buildLogger.ts +7 -7
- package/src/rlc-common/buildMethodShortcuts.ts +9 -21
- package/src/rlc-common/buildObjectTypes.ts +79 -156
- package/src/rlc-common/buildPaginateHelper.ts +9 -12
- package/src/rlc-common/buildParameterTypes.ts +116 -137
- package/src/rlc-common/buildPollingHelper.ts +7 -7
- package/src/rlc-common/buildResponseTypes.ts +34 -57
- package/src/rlc-common/buildSamples.ts +3 -3
- package/src/rlc-common/buildSchemaType.ts +37 -29
- package/src/rlc-common/buildSerializeHelper.ts +5 -5
- package/src/rlc-common/buildTopLevelIndexFile.ts +12 -19
- package/src/rlc-common/helpers/apiVersionUtil.ts +5 -10
- package/src/rlc-common/helpers/importsUtil.ts +27 -30
- package/src/rlc-common/helpers/nameConstructors.ts +16 -50
- package/src/rlc-common/helpers/nameUtils.ts +19 -42
- package/src/rlc-common/helpers/operationHelpers.ts +14 -31
- package/src/rlc-common/helpers/pathUtils.ts +2 -7
- package/src/rlc-common/helpers/schemaHelpers.ts +4 -15
- package/src/rlc-common/helpers/shortcutMethods.ts +6 -15
- package/src/rlc-common/helpers/typeUtil.ts +4 -11
- package/src/rlc-common/helpers/valueGenerationUtil.ts +16 -39
- package/src/rlc-common/index.ts +28 -28
- package/src/rlc-common/interfaces.ts +3 -11
- package/src/rlc-common/metadata/buildApiExtractorConfig.ts +17 -24
- package/src/rlc-common/metadata/buildChangelogFile.ts +1 -1
- package/src/rlc-common/metadata/buildESLintConfig.ts +3 -5
- package/src/rlc-common/metadata/buildLicenseFile.ts +1 -1
- package/src/rlc-common/metadata/buildPackageFile.ts +27 -35
- package/src/rlc-common/metadata/buildReadmeFile.ts +16 -29
- package/src/rlc-common/metadata/buildRollupConfig.ts +5 -8
- package/src/rlc-common/metadata/buildSampleEnvFile.ts +2 -3
- package/src/rlc-common/metadata/buildTestConfig.ts +10 -10
- package/src/rlc-common/metadata/buildTsConfig.ts +32 -35
- package/src/rlc-common/metadata/buildVitestConfig.ts +4 -10
- package/src/rlc-common/metadata/buildWarpConfig.ts +3 -6
- package/src/rlc-common/metadata/packageJson/azurePackageCommon.ts +16 -25
- package/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.ts +29 -50
- package/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.ts +20 -31
- package/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.ts +11 -13
- package/src/rlc-common/metadata/packageJson/packageCommon.ts +32 -52
- package/src/rlc-common/test/buildKarmaConfig.ts +1 -1
- package/src/rlc-common/test/buildRecordedClient.ts +3 -3
- package/src/rlc-common/test/buildSampleTest.ts +3 -3
- package/src/rlc-common/test/buildSnippets.ts +6 -12
- package/src/rlc-common/transformSampleGroups.ts +54 -105
- package/src/testing/index.ts +2 -5
- package/src/transform/transform.ts +22 -34
- package/src/transform/transformApiVersionInfo.ts +17 -30
- package/src/transform/transformHelperFunctionDetails.ts +14 -26
- package/src/transform/transformParameters.ts +55 -105
- package/src/transform/transformPaths.ts +26 -43
- package/src/transform/transformResponses.ts +26 -33
- package/src/transform/transformSchemas.ts +15 -33
- package/src/transform/transformTelemetryInfo.ts +8 -14
- package/src/transform/transfromRLCOptions.ts +53 -116
- package/src/utils/clientUtils.ts +22 -41
- package/src/utils/credentialUtils.ts +8 -19
- package/src/utils/crossLanguageDef.ts +15 -34
- package/src/utils/emitUtil.ts +11 -17
- package/src/utils/fileSystemUtils.ts +30 -8
- package/src/utils/importHelper.ts +5 -10
- package/src/utils/interfaces.ts +1 -1
- package/src/utils/mediaTypes.ts +13 -34
- package/src/utils/modelUtils.ts +175 -384
- package/src/utils/namespaceUtils.ts +8 -24
- package/src/utils/operationUtil.ts +98 -190
- package/src/utils/parameterUtils.ts +31 -54
- package/src/utils/resolve-project-root.ts +3 -3
- package/static/static-helpers/cloudSettingHelpers.ts +4 -6
- package/static/static-helpers/multipartHelpers.ts +3 -3
- package/static/static-helpers/pagingHelpers.ts +28 -63
- package/static/static-helpers/pollingHelpers.ts +16 -29
- package/static/static-helpers/serialization/build-multi-collection.ts +1 -4
- package/static/static-helpers/serialization/check-prop-undefined.ts +1 -4
- package/static/static-helpers/serialization/get-binary-response-browser.mts +3 -1
- package/static/static-helpers/serialization/get-binary-response.ts +2 -2
- package/static/static-helpers/serialization/get-binary-stream-response-browser.mts +1 -3
- package/static/static-helpers/serialization/get-binary-stream-response.ts +2 -4
- package/static/static-helpers/serialization/serialize-record.ts +1 -1
- package/static/static-helpers/serialization/serializers.ts +4 -7
- package/static/static-helpers/serialization/xml-helpers.ts +42 -90
- package/static/static-helpers/simplePollerHelpers.ts +10 -19
- package/static/static-helpers/storageCompatResponse.ts +10 -27
- package/static/static-helpers/urlTemplate.ts +4 -7
- package/static/test-helpers/recordedClient.ts +5 -10
package/src/utils/modelUtils.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
|
+
import { getUnionAsEnum } from "@azure-tools/typespec-azure-core";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Schema,
|
|
10
|
-
SchemaContext,
|
|
11
|
-
isArraySchema,
|
|
12
|
-
normalizeName
|
|
13
|
-
} from "../rlc-common/index.js";
|
|
6
|
+
getDefaultApiVersion,
|
|
7
|
+
getWireName,
|
|
8
|
+
isApiVersion,
|
|
9
|
+
} from "@azure-tools/typespec-client-generator-core";
|
|
14
10
|
import {
|
|
15
11
|
Discriminator,
|
|
16
12
|
EncodeData,
|
|
@@ -51,9 +47,8 @@ import {
|
|
|
51
47
|
isStringType,
|
|
52
48
|
isTemplateDeclaration,
|
|
53
49
|
isUnknownType,
|
|
54
|
-
listServices
|
|
50
|
+
listServices,
|
|
55
51
|
} from "@typespec/compiler";
|
|
56
|
-
import { GetSchemaOptions, SdkContext } from "./interfaces.js";
|
|
57
52
|
import {
|
|
58
53
|
HttpOperation,
|
|
59
54
|
HttpOperationHeaderParameter,
|
|
@@ -67,32 +62,31 @@ import {
|
|
|
67
62
|
getPathParamName,
|
|
68
63
|
getQueryParamName,
|
|
69
64
|
isBody,
|
|
70
|
-
isStatusCode
|
|
65
|
+
isStatusCode,
|
|
71
66
|
} from "@typespec/http";
|
|
72
67
|
import {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} from "
|
|
82
|
-
import {
|
|
68
|
+
ArraySchema,
|
|
69
|
+
DictionarySchema,
|
|
70
|
+
NameType,
|
|
71
|
+
ObjectSchema,
|
|
72
|
+
Schema,
|
|
73
|
+
SchemaContext,
|
|
74
|
+
isArraySchema,
|
|
75
|
+
normalizeName,
|
|
76
|
+
} from "../rlc-common/index.js";
|
|
77
|
+
import { GetSchemaOptions, SdkContext } from "./interfaces.js";
|
|
78
|
+
import { KnownMediaType, hasMediaType, isMediaTypeMultipartFormData } from "./mediaTypes.js";
|
|
83
79
|
|
|
84
|
-
import { getModelNamespaceName } from "./namespaceUtils.js";
|
|
85
80
|
import { reportDiagnostic } from "../lib.js";
|
|
81
|
+
import { getModelNamespaceName } from "./namespaceUtils.js";
|
|
86
82
|
|
|
87
83
|
export const BINARY_TYPE_UNION =
|
|
88
|
-
"string | Uint8Array | ReadableStream<Uint8Array> |
|
|
84
|
+
"string | Uint8Array | ReadableStream<Uint8Array> | NodeReadableStream";
|
|
89
85
|
|
|
90
86
|
export const BINARY_AND_FILE_TYPE_UNION = `${BINARY_TYPE_UNION} | File`;
|
|
91
87
|
|
|
92
88
|
export function getBinaryType(usage: SchemaContext[]) {
|
|
93
|
-
return usage.includes(SchemaContext.Output)
|
|
94
|
-
? "Uint8Array"
|
|
95
|
-
: BINARY_TYPE_UNION;
|
|
89
|
+
return usage.includes(SchemaContext.Output) ? "Uint8Array" : BINARY_TYPE_UNION;
|
|
96
90
|
}
|
|
97
91
|
|
|
98
92
|
export function isByteOrByteUnion(dpgContext: SdkContext, type: Type) {
|
|
@@ -101,10 +95,7 @@ export function isByteOrByteUnion(dpgContext: SdkContext, type: Type) {
|
|
|
101
95
|
}
|
|
102
96
|
|
|
103
97
|
function isBytesType(schema: any) {
|
|
104
|
-
return (
|
|
105
|
-
schema.type === "string" &&
|
|
106
|
-
(schema.format === "bytes" || schema.format === "binary")
|
|
107
|
-
);
|
|
98
|
+
return schema.type === "string" && (schema.format === "bytes" || schema.format === "binary");
|
|
108
99
|
}
|
|
109
100
|
|
|
110
101
|
function isBytesUnion(schema: any) {
|
|
@@ -120,10 +111,7 @@ function isBytesUnion(schema: any) {
|
|
|
120
111
|
}
|
|
121
112
|
|
|
122
113
|
function refineByteType(schema: any) {
|
|
123
|
-
schema.typeName = getBinaryType([
|
|
124
|
-
SchemaContext.Input,
|
|
125
|
-
SchemaContext.Exception
|
|
126
|
-
]);
|
|
114
|
+
schema.typeName = getBinaryType([SchemaContext.Input, SchemaContext.Exception]);
|
|
127
115
|
schema.outputTypeName = getBinaryType([SchemaContext.Output]);
|
|
128
116
|
return schema;
|
|
129
117
|
}
|
|
@@ -151,7 +139,7 @@ export function enrichBinaryTypeInBody(schema: any) {
|
|
|
151
139
|
export function getSchemaForType(
|
|
152
140
|
dpgContext: SdkContext,
|
|
153
141
|
typeInput: Type,
|
|
154
|
-
options?: GetSchemaOptions
|
|
142
|
+
options?: GetSchemaOptions,
|
|
155
143
|
): any {
|
|
156
144
|
const program = dpgContext.program;
|
|
157
145
|
const { usage } = options ?? {};
|
|
@@ -176,31 +164,25 @@ export function getSchemaForType(
|
|
|
176
164
|
if (httpPart) {
|
|
177
165
|
const fileModel = getHttpFileModel(program, httpPart.type);
|
|
178
166
|
if (fileModel) {
|
|
179
|
-
const schema: any = getSchemaForType(
|
|
180
|
-
dpgContext,
|
|
181
|
-
fileModel.contents,
|
|
182
|
-
options
|
|
183
|
-
);
|
|
167
|
+
const schema: any = getSchemaForType(dpgContext, fileModel.contents, options);
|
|
184
168
|
return {
|
|
185
169
|
...schema,
|
|
186
170
|
multipartOptions: {
|
|
187
171
|
filenameSchema: {
|
|
188
172
|
required: !fileModel.filename.optional,
|
|
189
|
-
...getSchemaForType(dpgContext, fileModel.filename, options)
|
|
173
|
+
...getSchemaForType(dpgContext, fileModel.filename, options),
|
|
190
174
|
},
|
|
191
175
|
contentTypeSchema: {
|
|
192
176
|
required: !fileModel.contentType.optional,
|
|
193
|
-
...getSchemaForType(dpgContext, fileModel.contentType, options)
|
|
194
|
-
}
|
|
195
|
-
}
|
|
177
|
+
...getSchemaForType(dpgContext, fileModel.contentType, options),
|
|
178
|
+
},
|
|
179
|
+
},
|
|
196
180
|
};
|
|
197
181
|
} else {
|
|
198
182
|
// extract body if required
|
|
199
183
|
const body =
|
|
200
184
|
(httpPart.type.kind === "Model" &&
|
|
201
|
-
[...httpPart.type.properties.values()].find((x) =>
|
|
202
|
-
isBody(program, x)
|
|
203
|
-
)) ||
|
|
185
|
+
[...httpPart.type.properties.values()].find((x) => isBody(program, x))) ||
|
|
204
186
|
httpPart.type;
|
|
205
187
|
return getSchemaForType(dpgContext, body, options);
|
|
206
188
|
}
|
|
@@ -210,25 +192,22 @@ export function getSchemaForType(
|
|
|
210
192
|
if (isAnonymousObjectSchema(schema)) {
|
|
211
193
|
if (Object.keys(schema.properties ?? {}).length === 0) {
|
|
212
194
|
// Handle empty anonymous model as Record
|
|
213
|
-
schema.typeName =
|
|
214
|
-
schema.type === "object" ? "Record<string, unknown>" : "unknown";
|
|
195
|
+
schema.typeName = schema.type === "object" ? "Record<string, unknown>" : "unknown";
|
|
215
196
|
if (usage && usage.includes(SchemaContext.Output)) {
|
|
216
|
-
schema.outputTypeName =
|
|
217
|
-
schema.type === "object" ? "Record<string, any>" : "any";
|
|
197
|
+
schema.outputTypeName = schema.type === "object" ? "Record<string, any>" : "any";
|
|
218
198
|
}
|
|
219
199
|
schema.type = "unknown";
|
|
220
200
|
} else {
|
|
221
201
|
// Handle non-empty anonymous model as inline model
|
|
222
202
|
if (usage && usage.includes(SchemaContext.Output)) {
|
|
223
203
|
schema.outputTypeName = getModelInlineSigniture(schema, {
|
|
224
|
-
usage: [SchemaContext.Output]
|
|
204
|
+
usage: [SchemaContext.Output],
|
|
225
205
|
});
|
|
226
206
|
}
|
|
227
207
|
schema.typeName = getModelInlineSigniture(schema, {
|
|
228
208
|
usage: [SchemaContext.Input],
|
|
229
209
|
multipart:
|
|
230
|
-
options?.isRequestBody &&
|
|
231
|
-
isMediaTypeMultipartFormData(options?.mediaTypes ?? [])
|
|
210
|
+
options?.isRequestBody && isMediaTypeMultipartFormData(options?.mediaTypes ?? []),
|
|
232
211
|
});
|
|
233
212
|
schema.type = "object";
|
|
234
213
|
}
|
|
@@ -272,23 +251,20 @@ export function getSchemaForType(
|
|
|
272
251
|
code: "invalid-schema",
|
|
273
252
|
format: {
|
|
274
253
|
type: type.kind,
|
|
275
|
-
property: options?.relevantProperty?.name ?? ""
|
|
254
|
+
property: options?.relevantProperty?.name ?? "",
|
|
276
255
|
},
|
|
277
|
-
target: type
|
|
256
|
+
target: type,
|
|
278
257
|
});
|
|
279
258
|
return undefined;
|
|
280
259
|
}
|
|
281
|
-
export function getEffectiveModelFromType(
|
|
282
|
-
context: SdkContext,
|
|
283
|
-
type: Type
|
|
284
|
-
): Type {
|
|
260
|
+
export function getEffectiveModelFromType(context: SdkContext, type: Type): Type {
|
|
285
261
|
/**
|
|
286
262
|
* If type is an anonymous model, tries to find a named model that has the same
|
|
287
263
|
* set of properties when non-schema properties are excluded.
|
|
288
264
|
*/
|
|
289
265
|
if (type.kind === "Model" && type.name === "") {
|
|
290
266
|
const effective = getEffectiveModelType(context.program, type, (property) =>
|
|
291
|
-
isSchemaProperty(context.program, property)
|
|
267
|
+
isSchemaProperty(context.program, property),
|
|
292
268
|
);
|
|
293
269
|
if (effective.name) {
|
|
294
270
|
return effective;
|
|
@@ -296,10 +272,7 @@ export function getEffectiveModelFromType(
|
|
|
296
272
|
}
|
|
297
273
|
return type;
|
|
298
274
|
}
|
|
299
|
-
export function includeDerivedModel(
|
|
300
|
-
model: Model,
|
|
301
|
-
needRef: boolean = false
|
|
302
|
-
): boolean {
|
|
275
|
+
export function includeDerivedModel(model: Model, needRef: boolean = false): boolean {
|
|
303
276
|
return (
|
|
304
277
|
!needRef &&
|
|
305
278
|
!isTemplateDeclaration(model) &&
|
|
@@ -313,7 +286,7 @@ export function includeDerivedModel(
|
|
|
313
286
|
function applyEncoding(
|
|
314
287
|
dpgContext: SdkContext,
|
|
315
288
|
typespecType: Scalar | ModelProperty,
|
|
316
|
-
target: any = {}
|
|
289
|
+
target: any = {},
|
|
317
290
|
) {
|
|
318
291
|
const encodeData = getEncode(dpgContext.program, typespecType);
|
|
319
292
|
if (encodeData) {
|
|
@@ -326,7 +299,7 @@ function applyEncoding(
|
|
|
326
299
|
newTarget["format"] = mergeFormatAndEncoding(
|
|
327
300
|
newTarget.format,
|
|
328
301
|
encodeData.encoding,
|
|
329
|
-
newType["format"]
|
|
302
|
+
newType["format"],
|
|
330
303
|
);
|
|
331
304
|
return newTarget;
|
|
332
305
|
}
|
|
@@ -336,7 +309,7 @@ function applyEncoding(
|
|
|
336
309
|
function mergeFormatAndEncoding(
|
|
337
310
|
format: string | undefined,
|
|
338
311
|
encoding: string | undefined,
|
|
339
|
-
encodeAsFormat: string | undefined
|
|
312
|
+
encodeAsFormat: string | undefined,
|
|
340
313
|
): string | undefined {
|
|
341
314
|
switch (format) {
|
|
342
315
|
case undefined:
|
|
@@ -349,22 +322,18 @@ function mergeFormatAndEncoding(
|
|
|
349
322
|
}
|
|
350
323
|
}
|
|
351
324
|
|
|
352
|
-
function getSchemaForScalar(
|
|
353
|
-
dpgContext: SdkContext,
|
|
354
|
-
scalar: Scalar,
|
|
355
|
-
options?: GetSchemaOptions
|
|
356
|
-
) {
|
|
325
|
+
function getSchemaForScalar(dpgContext: SdkContext, scalar: Scalar, options?: GetSchemaOptions) {
|
|
357
326
|
let result = {} as any;
|
|
358
327
|
const isStd = dpgContext.program.checker.isStdType(scalar);
|
|
359
328
|
const {
|
|
360
329
|
relevantProperty,
|
|
361
330
|
isRequestBody,
|
|
362
331
|
isParentRequestBody,
|
|
363
|
-
mediaTypes: contentTypes
|
|
332
|
+
mediaTypes: contentTypes,
|
|
364
333
|
} = options ?? {};
|
|
365
334
|
if (isStd) {
|
|
366
335
|
result = getSchemaForStdScalar(dpgContext.program, scalar, {
|
|
367
|
-
relevantProperty
|
|
336
|
+
relevantProperty,
|
|
368
337
|
});
|
|
369
338
|
} else if (scalar.baseScalar) {
|
|
370
339
|
result = getSchemaForScalar(dpgContext, scalar.baseScalar);
|
|
@@ -385,14 +354,9 @@ function getSchemaForScalar(
|
|
|
385
354
|
const withDecorators = applyEncoding(
|
|
386
355
|
dpgContext,
|
|
387
356
|
scalar,
|
|
388
|
-
result
|
|
389
|
-
? applyIntrinsicDecorators(dpgContext.program, scalar, result)
|
|
390
|
-
: undefined
|
|
357
|
+
result ? applyIntrinsicDecorators(dpgContext.program, scalar, result) : undefined,
|
|
391
358
|
);
|
|
392
|
-
if (
|
|
393
|
-
withDecorators.type === "string" &&
|
|
394
|
-
withDecorators.format === "binary"
|
|
395
|
-
) {
|
|
359
|
+
if (withDecorators.type === "string" && withDecorators.format === "binary") {
|
|
396
360
|
withDecorators.typeName = BINARY_TYPE_UNION;
|
|
397
361
|
withDecorators.outputTypeName = "Uint8Array";
|
|
398
362
|
}
|
|
@@ -401,9 +365,7 @@ function getSchemaForScalar(
|
|
|
401
365
|
|
|
402
366
|
function isBinaryAsRequestBody() {
|
|
403
367
|
return (
|
|
404
|
-
hasMediaType(KnownMediaType.Binary, contentTypes) &&
|
|
405
|
-
isRequestBody &&
|
|
406
|
-
isBytesType(result)
|
|
368
|
+
hasMediaType(KnownMediaType.Binary, contentTypes) && isRequestBody && isBytesType(result)
|
|
407
369
|
);
|
|
408
370
|
}
|
|
409
371
|
|
|
@@ -416,11 +378,7 @@ function getSchemaForScalar(
|
|
|
416
378
|
}
|
|
417
379
|
}
|
|
418
380
|
|
|
419
|
-
function getSchemaForUnion(
|
|
420
|
-
dpgContext: SdkContext,
|
|
421
|
-
union: Union,
|
|
422
|
-
options?: GetSchemaOptions
|
|
423
|
-
) {
|
|
381
|
+
function getSchemaForUnion(dpgContext: SdkContext, union: Union, options?: GetSchemaOptions) {
|
|
424
382
|
const [asEnum, _] = getUnionAsEnum(union);
|
|
425
383
|
const variants = Array.from(union.variants.values());
|
|
426
384
|
|
|
@@ -432,7 +390,7 @@ function getSchemaForUnion(
|
|
|
432
390
|
for (const [_, member] of asEnum.members.entries()) {
|
|
433
391
|
const memberType = getSchemaForType(dpgContext, member.type, {
|
|
434
392
|
...options,
|
|
435
|
-
needRef: options?.needRef ?? false
|
|
393
|
+
needRef: options?.needRef ?? false,
|
|
436
394
|
});
|
|
437
395
|
values.push(memberType);
|
|
438
396
|
if (memberType.name) {
|
|
@@ -444,7 +402,7 @@ function getSchemaForUnion(
|
|
|
444
402
|
// We already know it's not a model type
|
|
445
403
|
const variantType = getSchemaForType(dpgContext, variant.type, {
|
|
446
404
|
...options,
|
|
447
|
-
needRef: isAnonymousModelType(variant.type) ? false : true
|
|
405
|
+
needRef: isAnonymousModelType(variant.type) ? false : true,
|
|
448
406
|
});
|
|
449
407
|
values.push(variantType);
|
|
450
408
|
if (variantType.typeName) {
|
|
@@ -460,26 +418,16 @@ function getSchemaForUnion(
|
|
|
460
418
|
const unionAlias =
|
|
461
419
|
asEnum?.open && asEnum?.kind && !namedUnionMember
|
|
462
420
|
? asEnum.kind + (asEnum.nullable ? " | null" : "")
|
|
463
|
-
: values
|
|
464
|
-
.map(
|
|
465
|
-
(item) => `${getTypeName(item, [SchemaContext.Input]) ?? item}`
|
|
466
|
-
)
|
|
467
|
-
.join(" | ");
|
|
421
|
+
: values.map((item) => `${getTypeName(item, [SchemaContext.Input]) ?? item}`).join(" | ");
|
|
468
422
|
const outputUnionAlias =
|
|
469
423
|
asEnum?.open && asEnum?.kind && !namedUnionMember
|
|
470
424
|
? asEnum.kind + (asEnum.nullable ? " | null" : "")
|
|
471
|
-
: values
|
|
472
|
-
.map(
|
|
473
|
-
(item) => `${getTypeName(item, [SchemaContext.Output]) ?? item}`
|
|
474
|
-
)
|
|
475
|
-
.join(" | ");
|
|
425
|
+
: values.map((item) => `${getTypeName(item, [SchemaContext.Output]) ?? item}`).join(" | ");
|
|
476
426
|
schema.alias = unionAlias;
|
|
477
427
|
schema.outputAlias = outputUnionAlias;
|
|
478
428
|
}
|
|
479
429
|
if (!union.expression) {
|
|
480
|
-
const unionName = union.name
|
|
481
|
-
? normalizeName(union.name, NameType.Interface)
|
|
482
|
-
: undefined;
|
|
430
|
+
const unionName = union.name ? normalizeName(union.name, NameType.Interface) : undefined;
|
|
483
431
|
schema.name = unionName;
|
|
484
432
|
schema.type = "object";
|
|
485
433
|
schema.typeName = unionName;
|
|
@@ -493,9 +441,7 @@ function getSchemaForUnion(
|
|
|
493
441
|
} else {
|
|
494
442
|
schema.type = "union";
|
|
495
443
|
schema.typeName = union.name ?? schema.alias;
|
|
496
|
-
schema.outputTypeName = union.name
|
|
497
|
-
? union.name + "Output"
|
|
498
|
-
: schema.outputAlias;
|
|
444
|
+
schema.outputTypeName = union.name ? union.name + "Output" : schema.outputAlias;
|
|
499
445
|
delete schema.alias;
|
|
500
446
|
delete schema.outputAlias;
|
|
501
447
|
}
|
|
@@ -506,7 +452,7 @@ function getSchemaForUnion(
|
|
|
506
452
|
function getSchemaForUnionVariant(
|
|
507
453
|
dpgContext: SdkContext,
|
|
508
454
|
variant: UnionVariant,
|
|
509
|
-
options?: GetSchemaOptions
|
|
455
|
+
options?: GetSchemaOptions,
|
|
510
456
|
): Schema {
|
|
511
457
|
return getSchemaForType(dpgContext, variant.type, options);
|
|
512
458
|
}
|
|
@@ -546,8 +492,7 @@ function isStringLiteral(type: Type): boolean {
|
|
|
546
492
|
}
|
|
547
493
|
return (
|
|
548
494
|
type.kind === "String" ||
|
|
549
|
-
(type.kind === "EnumMember" &&
|
|
550
|
-
typeof (type.value ?? type.name) === "string") ||
|
|
495
|
+
(type.kind === "EnumMember" && typeof (type.value ?? type.name) === "string") ||
|
|
551
496
|
(type.kind === "UnionVariant" && type.type.kind === "String")
|
|
552
497
|
);
|
|
553
498
|
}
|
|
@@ -572,7 +517,7 @@ function getStringValues(type: Type): string[] {
|
|
|
572
517
|
function validateDiscriminator(
|
|
573
518
|
program: Program,
|
|
574
519
|
discriminator: Discriminator,
|
|
575
|
-
derivedModels: readonly Model[]
|
|
520
|
+
derivedModels: readonly Model[],
|
|
576
521
|
): boolean {
|
|
577
522
|
const { propertyName } = discriminator;
|
|
578
523
|
const retVals = derivedModels.map((t) => {
|
|
@@ -581,20 +526,16 @@ function validateDiscriminator(
|
|
|
581
526
|
reportDiagnostic(program, {
|
|
582
527
|
code: "discriminator",
|
|
583
528
|
messageId: "missing",
|
|
584
|
-
target: t
|
|
529
|
+
target: t,
|
|
585
530
|
});
|
|
586
531
|
return false;
|
|
587
532
|
}
|
|
588
533
|
let retval = true;
|
|
589
|
-
if (
|
|
590
|
-
!isOasString(prop.type) &&
|
|
591
|
-
prop.type.kind !== "EnumMember" &&
|
|
592
|
-
prop.type.kind !== "Enum"
|
|
593
|
-
) {
|
|
534
|
+
if (!isOasString(prop.type) && prop.type.kind !== "EnumMember" && prop.type.kind !== "Enum") {
|
|
594
535
|
reportDiagnostic(program, {
|
|
595
536
|
code: "discriminator",
|
|
596
537
|
messageId: "type",
|
|
597
|
-
target: prop
|
|
538
|
+
target: prop,
|
|
598
539
|
});
|
|
599
540
|
retval = false;
|
|
600
541
|
}
|
|
@@ -602,7 +543,7 @@ function validateDiscriminator(
|
|
|
602
543
|
reportDiagnostic(program, {
|
|
603
544
|
code: "discriminator",
|
|
604
545
|
messageId: "required",
|
|
605
|
-
target: prop
|
|
546
|
+
target: prop,
|
|
606
547
|
});
|
|
607
548
|
retval = false;
|
|
608
549
|
}
|
|
@@ -618,7 +559,7 @@ function validateDiscriminator(
|
|
|
618
559
|
reportDiagnostic(program, {
|
|
619
560
|
code: "discriminator-value",
|
|
620
561
|
messageId: "literal",
|
|
621
|
-
target: prop || t
|
|
562
|
+
target: prop || t,
|
|
622
563
|
});
|
|
623
564
|
}
|
|
624
565
|
if (prop) {
|
|
@@ -631,9 +572,9 @@ function validateDiscriminator(
|
|
|
631
572
|
format: {
|
|
632
573
|
val: val,
|
|
633
574
|
model1: discriminatorValues.get(val)!,
|
|
634
|
-
model2: t.name
|
|
575
|
+
model2: t.name,
|
|
635
576
|
},
|
|
636
|
-
target: prop
|
|
577
|
+
target: prop,
|
|
637
578
|
});
|
|
638
579
|
retVals.push(false);
|
|
639
580
|
} else {
|
|
@@ -645,17 +586,8 @@ function validateDiscriminator(
|
|
|
645
586
|
return retVals.every((v) => v);
|
|
646
587
|
}
|
|
647
588
|
|
|
648
|
-
function getSchemaForModel(
|
|
649
|
-
|
|
650
|
-
model: Model,
|
|
651
|
-
options?: GetSchemaOptions
|
|
652
|
-
) {
|
|
653
|
-
const {
|
|
654
|
-
usage,
|
|
655
|
-
needRef,
|
|
656
|
-
isRequestBody,
|
|
657
|
-
mediaTypes: contentTypes
|
|
658
|
-
} = options ?? {};
|
|
589
|
+
function getSchemaForModel(dpgContext: SdkContext, model: Model, options?: GetSchemaOptions) {
|
|
590
|
+
const { usage, needRef, isRequestBody, mediaTypes: contentTypes } = options ?? {};
|
|
659
591
|
if (isArrayModelType(model)) {
|
|
660
592
|
return getSchemaForArrayModel(dpgContext, model, options);
|
|
661
593
|
}
|
|
@@ -668,14 +600,10 @@ function getSchemaForModel(
|
|
|
668
600
|
type: "object",
|
|
669
601
|
isMultipartBody,
|
|
670
602
|
description: getDoc(program, model) ?? "",
|
|
671
|
-
fromCore: isCoreModel
|
|
603
|
+
fromCore: isCoreModel,
|
|
672
604
|
};
|
|
673
605
|
// normalized the output name
|
|
674
|
-
modelSchema.name = normalizeName(
|
|
675
|
-
modelSchema.name,
|
|
676
|
-
NameType.Interface,
|
|
677
|
-
true /** shouldGuard */
|
|
678
|
-
);
|
|
606
|
+
modelSchema.name = normalizeName(modelSchema.name, NameType.Interface, true /** shouldGuard */);
|
|
679
607
|
|
|
680
608
|
if (model.name === "Record" && isRecordModelType(model)) {
|
|
681
609
|
return getSchemaForRecordModel(dpgContext, model, { usage });
|
|
@@ -696,20 +624,20 @@ function getSchemaForModel(
|
|
|
696
624
|
if (derivedModels.length > 0) {
|
|
697
625
|
modelSchema.children = {
|
|
698
626
|
all: [],
|
|
699
|
-
immediate: []
|
|
627
|
+
immediate: [],
|
|
700
628
|
};
|
|
701
629
|
}
|
|
702
630
|
for (const child of derivedModels) {
|
|
703
631
|
const childSchema = getSchemaForType(dpgContext, child, {
|
|
704
632
|
usage,
|
|
705
|
-
needRef: true
|
|
633
|
+
needRef: true,
|
|
706
634
|
});
|
|
707
635
|
for (const [name, prop] of child.properties) {
|
|
708
636
|
if (name === discriminator?.propertyName) {
|
|
709
637
|
const propSchema = getSchemaForType(dpgContext, prop.type, {
|
|
710
638
|
usage,
|
|
711
639
|
needRef: !isAnonymousModelType(prop.type),
|
|
712
|
-
relevantProperty: prop
|
|
640
|
+
relevantProperty: prop,
|
|
713
641
|
});
|
|
714
642
|
childSchema.discriminatorValue = propSchema.type.replace(/"/g, "");
|
|
715
643
|
break;
|
|
@@ -735,7 +663,7 @@ function getSchemaForModel(
|
|
|
735
663
|
modelSchema.discriminator = {
|
|
736
664
|
name: propertyName,
|
|
737
665
|
type: "string",
|
|
738
|
-
description: `Discriminator property for ${model.name}
|
|
666
|
+
description: `Discriminator property for ${model.name}.`,
|
|
739
667
|
};
|
|
740
668
|
modelSchema.discriminatorValue = propertyName;
|
|
741
669
|
modelSchema.isPolyParent = true;
|
|
@@ -748,7 +676,7 @@ function getSchemaForModel(
|
|
|
748
676
|
if (isRecordModelType(model)) {
|
|
749
677
|
modelSchema.parents = {
|
|
750
678
|
all: [getSchemaForRecordModel(dpgContext, model, { usage })],
|
|
751
|
-
immediate: [getSchemaForRecordModel(dpgContext, model, { usage })]
|
|
679
|
+
immediate: [getSchemaForRecordModel(dpgContext, model, { usage })],
|
|
752
680
|
};
|
|
753
681
|
}
|
|
754
682
|
for (const [propName, prop] of model.properties) {
|
|
@@ -764,7 +692,7 @@ function getSchemaForModel(
|
|
|
764
692
|
relevantProperty: prop,
|
|
765
693
|
isParentRequestBody: isRequestBody,
|
|
766
694
|
isRequestBody: false,
|
|
767
|
-
mediaTypes: contentTypes
|
|
695
|
+
mediaTypes: contentTypes,
|
|
768
696
|
});
|
|
769
697
|
|
|
770
698
|
if (propSchema === undefined) {
|
|
@@ -773,29 +701,21 @@ function getSchemaForModel(
|
|
|
773
701
|
if (!prop.optional) {
|
|
774
702
|
propSchema.required = true;
|
|
775
703
|
}
|
|
776
|
-
const propertyDescription = getFormattedPropertyDoc(
|
|
777
|
-
program,
|
|
778
|
-
prop,
|
|
779
|
-
propSchema
|
|
780
|
-
);
|
|
704
|
+
const propertyDescription = getFormattedPropertyDoc(program, prop, propSchema);
|
|
781
705
|
propSchema.usage = usage;
|
|
782
706
|
// Use the description from ModelProperty not derived from Model Type
|
|
783
707
|
propSchema.description = propertyDescription;
|
|
784
708
|
modelSchema.properties[name] = propSchema;
|
|
785
709
|
// if this property is a discriminator property, remove it to keep autorest validation happy
|
|
786
710
|
const { propertyName } = getDiscriminator(program, model) || {};
|
|
787
|
-
if (
|
|
788
|
-
propertyName &&
|
|
789
|
-
name === `"${propertyName}"` &&
|
|
790
|
-
modelSchema.discriminator
|
|
791
|
-
) {
|
|
711
|
+
if (propertyName && name === `"${propertyName}"` && modelSchema.discriminator) {
|
|
792
712
|
modelSchema.discriminator = {
|
|
793
713
|
...modelSchema.discriminator,
|
|
794
714
|
...{
|
|
795
715
|
type: propSchema.typeName ?? propSchema.type,
|
|
796
716
|
typeName: propSchema.typeName,
|
|
797
|
-
outputTypeName: propSchema.outputTypeName
|
|
798
|
-
}
|
|
717
|
+
outputTypeName: propSchema.outputTypeName,
|
|
718
|
+
},
|
|
799
719
|
};
|
|
800
720
|
continue;
|
|
801
721
|
}
|
|
@@ -834,61 +754,43 @@ function getSchemaForModel(
|
|
|
834
754
|
if (modelSchema.parents === undefined) {
|
|
835
755
|
modelSchema.parents = {
|
|
836
756
|
all: [],
|
|
837
|
-
immediate: []
|
|
757
|
+
immediate: [],
|
|
838
758
|
};
|
|
839
759
|
}
|
|
840
760
|
modelSchema.parents.all?.push(
|
|
841
761
|
getSchemaForType(dpgContext, model.baseModel, {
|
|
842
762
|
usage,
|
|
843
|
-
needRef: true
|
|
844
|
-
})
|
|
763
|
+
needRef: true,
|
|
764
|
+
}),
|
|
845
765
|
);
|
|
846
766
|
modelSchema.parents.immediate?.push(
|
|
847
767
|
getSchemaForType(dpgContext, model.baseModel, {
|
|
848
768
|
usage,
|
|
849
|
-
needRef: true
|
|
850
|
-
})
|
|
769
|
+
needRef: true,
|
|
770
|
+
}),
|
|
851
771
|
);
|
|
852
772
|
}
|
|
853
773
|
return modelSchema;
|
|
854
774
|
}
|
|
855
775
|
|
|
856
|
-
function getSdkVisibility(
|
|
857
|
-
program: Program,
|
|
858
|
-
type: ModelProperty
|
|
859
|
-
): Visibility[] | undefined {
|
|
776
|
+
function getSdkVisibility(program: Program, type: ModelProperty): Visibility[] | undefined {
|
|
860
777
|
const lifecycle = getLifecycleVisibilityEnum(program);
|
|
861
778
|
const visibility = getVisibilityForClass(program, type, lifecycle);
|
|
862
779
|
if (visibility) {
|
|
863
780
|
const result: Visibility[] = [];
|
|
864
|
-
if (
|
|
865
|
-
lifecycle.members.get("Read") &&
|
|
866
|
-
visibility.has(lifecycle.members.get("Read")!)
|
|
867
|
-
) {
|
|
781
|
+
if (lifecycle.members.get("Read") && visibility.has(lifecycle.members.get("Read")!)) {
|
|
868
782
|
result.push(Visibility.Read);
|
|
869
783
|
}
|
|
870
|
-
if (
|
|
871
|
-
lifecycle.members.get("Create") &&
|
|
872
|
-
visibility.has(lifecycle.members.get("Create")!)
|
|
873
|
-
) {
|
|
784
|
+
if (lifecycle.members.get("Create") && visibility.has(lifecycle.members.get("Create")!)) {
|
|
874
785
|
result.push(Visibility.Create);
|
|
875
786
|
}
|
|
876
|
-
if (
|
|
877
|
-
lifecycle.members.get("Update") &&
|
|
878
|
-
visibility.has(lifecycle.members.get("Update")!)
|
|
879
|
-
) {
|
|
787
|
+
if (lifecycle.members.get("Update") && visibility.has(lifecycle.members.get("Update")!)) {
|
|
880
788
|
result.push(Visibility.Update);
|
|
881
789
|
}
|
|
882
|
-
if (
|
|
883
|
-
lifecycle.members.get("Delete") &&
|
|
884
|
-
visibility.has(lifecycle.members.get("Delete")!)
|
|
885
|
-
) {
|
|
790
|
+
if (lifecycle.members.get("Delete") && visibility.has(lifecycle.members.get("Delete")!)) {
|
|
886
791
|
result.push(Visibility.Delete);
|
|
887
792
|
}
|
|
888
|
-
if (
|
|
889
|
-
lifecycle.members.get("Query") &&
|
|
890
|
-
visibility.has(lifecycle.members.get("Query")!)
|
|
891
|
-
) {
|
|
793
|
+
if (lifecycle.members.get("Query") && visibility.has(lifecycle.members.get("Query")!)) {
|
|
892
794
|
result.push(Visibility.Query);
|
|
893
795
|
}
|
|
894
796
|
return result;
|
|
@@ -957,9 +859,7 @@ function getModelName(dpgContext: SdkContext, model: Model) {
|
|
|
957
859
|
fullNamespacePrefix = "";
|
|
958
860
|
}
|
|
959
861
|
// 5. check if this model should be namespaced
|
|
960
|
-
return dpgContext.rlcOptions?.enableModelNamespace
|
|
961
|
-
? `${fullNamespacePrefix}${name}`
|
|
962
|
-
: name;
|
|
862
|
+
return dpgContext.rlcOptions?.enableModelNamespace ? `${fullNamespacePrefix}${name}` : name;
|
|
963
863
|
}
|
|
964
864
|
|
|
965
865
|
// Map an typespec type to an OA schema. Returns undefined when the resulting
|
|
@@ -985,7 +885,7 @@ function getSchemaForLiteral(type: Type): any {
|
|
|
985
885
|
function applyIntrinsicDecorators(
|
|
986
886
|
program: Program,
|
|
987
887
|
type: Scalar | ModelProperty,
|
|
988
|
-
target: any
|
|
888
|
+
target: any,
|
|
989
889
|
): any {
|
|
990
890
|
const newTarget = { ...target };
|
|
991
891
|
const docStr = getDoc(program, type);
|
|
@@ -1056,7 +956,7 @@ function getSchemaForEnum(dpgContext: SdkContext, e: Enum) {
|
|
|
1056
956
|
if (type !== enumMemberType(option)) {
|
|
1057
957
|
reportDiagnostic(dpgContext.program, {
|
|
1058
958
|
code: "union-unsupported",
|
|
1059
|
-
target: e
|
|
959
|
+
target: e,
|
|
1060
960
|
});
|
|
1061
961
|
continue;
|
|
1062
962
|
}
|
|
@@ -1070,7 +970,7 @@ function getSchemaForEnum(dpgContext: SdkContext, e: Enum) {
|
|
|
1070
970
|
typeName: normalizeName(e.name, NameType.Interface),
|
|
1071
971
|
outputTypeName: normalizeName(e.name, NameType.Interface) + "Output",
|
|
1072
972
|
description: getDoc(dpgContext.program, e),
|
|
1073
|
-
memberType: type
|
|
973
|
+
memberType: type,
|
|
1074
974
|
};
|
|
1075
975
|
|
|
1076
976
|
if (values.length > 0) {
|
|
@@ -1094,18 +994,10 @@ function enumMemberType(member: EnumMember) {
|
|
|
1094
994
|
/**
|
|
1095
995
|
* Map TypeSpec intrinsic models to open api definitions
|
|
1096
996
|
*/
|
|
1097
|
-
function getSchemaForArrayModel(
|
|
1098
|
-
dpgContext: SdkContext,
|
|
1099
|
-
type: Model,
|
|
1100
|
-
options?: GetSchemaOptions
|
|
1101
|
-
) {
|
|
997
|
+
function getSchemaForArrayModel(dpgContext: SdkContext, type: Model, options?: GetSchemaOptions) {
|
|
1102
998
|
const { program } = dpgContext;
|
|
1103
999
|
const { indexer } = type;
|
|
1104
|
-
const {
|
|
1105
|
-
usage,
|
|
1106
|
-
isParentRequestBody,
|
|
1107
|
-
mediaTypes: contentTypes
|
|
1108
|
-
} = options ?? {};
|
|
1000
|
+
const { usage, isParentRequestBody, mediaTypes: contentTypes } = options ?? {};
|
|
1109
1001
|
let schema: any = {};
|
|
1110
1002
|
if (!indexer) {
|
|
1111
1003
|
return schema;
|
|
@@ -1118,15 +1010,12 @@ function getSchemaForArrayModel(
|
|
|
1118
1010
|
isRequestBody: false,
|
|
1119
1011
|
mediaTypes: contentTypes,
|
|
1120
1012
|
// special handling for array in formdata
|
|
1121
|
-
isParentRequestBody: hasMediaType(
|
|
1122
|
-
KnownMediaType.MultipartFormData,
|
|
1123
|
-
contentTypes
|
|
1124
|
-
)
|
|
1013
|
+
isParentRequestBody: hasMediaType(KnownMediaType.MultipartFormData, contentTypes)
|
|
1125
1014
|
? isParentRequestBody
|
|
1126
1015
|
: false,
|
|
1127
|
-
needRef: !isAnonymousModelType(indexer.value!)
|
|
1016
|
+
needRef: !isAnonymousModelType(indexer.value!),
|
|
1128
1017
|
}),
|
|
1129
|
-
description: getDoc(program, type)
|
|
1018
|
+
description: getDoc(program, type),
|
|
1130
1019
|
};
|
|
1131
1020
|
if (
|
|
1132
1021
|
!program.checker.isStdType(indexer.value) &&
|
|
@@ -1171,11 +1060,7 @@ function getSchemaForArrayModel(
|
|
|
1171
1060
|
return `${typeName}[]`;
|
|
1172
1061
|
})
|
|
1173
1062
|
.join(" | ");
|
|
1174
|
-
if (
|
|
1175
|
-
schema.items.outputTypeName &&
|
|
1176
|
-
usage &&
|
|
1177
|
-
usage.includes(SchemaContext.Output)
|
|
1178
|
-
) {
|
|
1063
|
+
if (schema.items.outputTypeName && usage && usage.includes(SchemaContext.Output)) {
|
|
1179
1064
|
schema.outputTypeName = schema.items.outputTypeName
|
|
1180
1065
|
.split("|")
|
|
1181
1066
|
.map((typeName: string) => {
|
|
@@ -1195,11 +1080,7 @@ function getSchemaForArrayModel(
|
|
|
1195
1080
|
}
|
|
1196
1081
|
}
|
|
1197
1082
|
|
|
1198
|
-
function getSchemaForRecordModel(
|
|
1199
|
-
dpgContext: SdkContext,
|
|
1200
|
-
type: Model,
|
|
1201
|
-
options?: GetSchemaOptions
|
|
1202
|
-
) {
|
|
1083
|
+
function getSchemaForRecordModel(dpgContext: SdkContext, type: Model, options?: GetSchemaOptions) {
|
|
1203
1084
|
const { program } = dpgContext;
|
|
1204
1085
|
const { indexer } = type;
|
|
1205
1086
|
const { usage } = options ?? {};
|
|
@@ -1210,12 +1091,12 @@ function getSchemaForRecordModel(
|
|
|
1210
1091
|
if (isRecordModelType(type)) {
|
|
1211
1092
|
const valueType = getSchemaForType(dpgContext, indexer?.value, {
|
|
1212
1093
|
usage,
|
|
1213
|
-
needRef: !isAnonymousModelType(indexer.value)
|
|
1094
|
+
needRef: !isAnonymousModelType(indexer.value),
|
|
1214
1095
|
});
|
|
1215
1096
|
schema = {
|
|
1216
1097
|
type: "dictionary",
|
|
1217
1098
|
additionalProperties: valueType,
|
|
1218
|
-
description: getDoc(program, type)
|
|
1099
|
+
description: getDoc(program, type),
|
|
1219
1100
|
};
|
|
1220
1101
|
if (
|
|
1221
1102
|
!program.checker.isStdType(indexer.value) &&
|
|
@@ -1229,21 +1110,13 @@ function getSchemaForRecordModel(
|
|
|
1229
1110
|
schema.outputValueTypeName = `${valueType.outputTypeName}`;
|
|
1230
1111
|
}
|
|
1231
1112
|
} else if (isUnknownType(indexer.value!)) {
|
|
1232
|
-
schema.typeName = `Record<string, ${
|
|
1233
|
-
valueType.typeName ?? valueType.type
|
|
1234
|
-
}>`;
|
|
1113
|
+
schema.typeName = `Record<string, ${valueType.typeName ?? valueType.type}>`;
|
|
1235
1114
|
if (usage && usage.includes(SchemaContext.Output)) {
|
|
1236
|
-
schema.outputTypeName = `Record<string, ${
|
|
1237
|
-
valueType.outputTypeName ?? valueType.type
|
|
1238
|
-
}>`;
|
|
1115
|
+
schema.outputTypeName = `Record<string, ${valueType.outputTypeName ?? valueType.type}>`;
|
|
1239
1116
|
}
|
|
1240
1117
|
} else {
|
|
1241
|
-
schema.typeName = `Record<string, ${getTypeName(valueType, [
|
|
1242
|
-
|
|
1243
|
-
])}>`;
|
|
1244
|
-
schema.outputTypeName = `Record<string, ${getTypeName(valueType, [
|
|
1245
|
-
SchemaContext.Output
|
|
1246
|
-
])}>`;
|
|
1118
|
+
schema.typeName = `Record<string, ${getTypeName(valueType, [SchemaContext.Input])}>`;
|
|
1119
|
+
schema.outputTypeName = `Record<string, ${getTypeName(valueType, [SchemaContext.Output])}>`;
|
|
1247
1120
|
}
|
|
1248
1121
|
schema.usage = usage;
|
|
1249
1122
|
return schema;
|
|
@@ -1256,8 +1129,7 @@ function isUnionType(type: Type) {
|
|
|
1256
1129
|
|
|
1257
1130
|
export function isObjectOrDictType(schema: Schema) {
|
|
1258
1131
|
return (
|
|
1259
|
-
(schema.type === "object" &&
|
|
1260
|
-
(schema as ObjectSchema).properties !== undefined) ||
|
|
1132
|
+
(schema.type === "object" && (schema as ObjectSchema).properties !== undefined) ||
|
|
1261
1133
|
schema.type === "dictionary"
|
|
1262
1134
|
);
|
|
1263
1135
|
}
|
|
@@ -1266,11 +1138,7 @@ export function isArrayType(schema: Schema) {
|
|
|
1266
1138
|
return schema.type === "array";
|
|
1267
1139
|
}
|
|
1268
1140
|
|
|
1269
|
-
function getSchemaForStdScalar(
|
|
1270
|
-
program: Program,
|
|
1271
|
-
type: Scalar,
|
|
1272
|
-
options?: GetSchemaOptions
|
|
1273
|
-
) {
|
|
1141
|
+
function getSchemaForStdScalar(program: Program, type: Scalar, options?: GetSchemaOptions) {
|
|
1274
1142
|
const { relevantProperty } = options ?? {};
|
|
1275
1143
|
if (!program.checker.isStdType(type)) {
|
|
1276
1144
|
return undefined;
|
|
@@ -1296,97 +1164,97 @@ function getSchemaForStdScalar(
|
|
|
1296
1164
|
return { type: "string", format: "bytes", description };
|
|
1297
1165
|
case "integer":
|
|
1298
1166
|
return applyIntrinsicDecorators(program, type, {
|
|
1299
|
-
type: "number"
|
|
1167
|
+
type: "number",
|
|
1300
1168
|
});
|
|
1301
1169
|
case "int8":
|
|
1302
1170
|
return applyIntrinsicDecorators(program, type, {
|
|
1303
1171
|
type: "number",
|
|
1304
|
-
format: "int8"
|
|
1172
|
+
format: "int8",
|
|
1305
1173
|
});
|
|
1306
1174
|
case "int16":
|
|
1307
1175
|
return applyIntrinsicDecorators(program, type, {
|
|
1308
1176
|
type: "number",
|
|
1309
|
-
format: "int16"
|
|
1177
|
+
format: "int16",
|
|
1310
1178
|
});
|
|
1311
1179
|
case "int32":
|
|
1312
1180
|
return applyIntrinsicDecorators(program, type, {
|
|
1313
1181
|
type: "number",
|
|
1314
|
-
format: "int32"
|
|
1182
|
+
format: "int32",
|
|
1315
1183
|
});
|
|
1316
1184
|
case "int64":
|
|
1317
1185
|
return applyIntrinsicDecorators(program, type, {
|
|
1318
1186
|
type: "number",
|
|
1319
|
-
format: "int64"
|
|
1187
|
+
format: "int64",
|
|
1320
1188
|
});
|
|
1321
1189
|
case "safeint":
|
|
1322
1190
|
return applyIntrinsicDecorators(program, type, {
|
|
1323
1191
|
type: "number",
|
|
1324
|
-
format: "safeint"
|
|
1192
|
+
format: "safeint",
|
|
1325
1193
|
});
|
|
1326
1194
|
case "numeric":
|
|
1327
1195
|
return applyIntrinsicDecorators(program, type, {
|
|
1328
|
-
type: "number"
|
|
1196
|
+
type: "number",
|
|
1329
1197
|
});
|
|
1330
1198
|
case "uint8":
|
|
1331
1199
|
return applyIntrinsicDecorators(program, type, {
|
|
1332
1200
|
type: "number",
|
|
1333
|
-
format: "uint8"
|
|
1201
|
+
format: "uint8",
|
|
1334
1202
|
});
|
|
1335
1203
|
case "uint16":
|
|
1336
1204
|
return applyIntrinsicDecorators(program, type, {
|
|
1337
1205
|
type: "number",
|
|
1338
|
-
format: "uint16"
|
|
1206
|
+
format: "uint16",
|
|
1339
1207
|
});
|
|
1340
1208
|
case "uint32":
|
|
1341
1209
|
return applyIntrinsicDecorators(program, type, {
|
|
1342
1210
|
type: "number",
|
|
1343
|
-
format: "uint32"
|
|
1211
|
+
format: "uint32",
|
|
1344
1212
|
});
|
|
1345
1213
|
case "uint64":
|
|
1346
1214
|
return applyIntrinsicDecorators(program, type, {
|
|
1347
1215
|
type: "number",
|
|
1348
|
-
format: "uint64"
|
|
1216
|
+
format: "uint64",
|
|
1349
1217
|
});
|
|
1350
1218
|
case "float64":
|
|
1351
1219
|
return applyIntrinsicDecorators(program, type, {
|
|
1352
1220
|
type: "number",
|
|
1353
|
-
format: "float64"
|
|
1221
|
+
format: "float64",
|
|
1354
1222
|
});
|
|
1355
1223
|
case "float32":
|
|
1356
1224
|
return applyIntrinsicDecorators(program, type, {
|
|
1357
1225
|
type: "number",
|
|
1358
|
-
format: "float32"
|
|
1226
|
+
format: "float32",
|
|
1359
1227
|
});
|
|
1360
1228
|
case "float":
|
|
1361
1229
|
return applyIntrinsicDecorators(program, type, {
|
|
1362
1230
|
type: "number",
|
|
1363
|
-
format: "float"
|
|
1231
|
+
format: "float",
|
|
1364
1232
|
});
|
|
1365
1233
|
case "decimal":
|
|
1366
1234
|
reportDiagnostic(program, {
|
|
1367
1235
|
code: "decimal-to-number",
|
|
1368
1236
|
format: {
|
|
1369
|
-
propertyName: relevantProperty?.name ?? ""
|
|
1237
|
+
propertyName: relevantProperty?.name ?? "",
|
|
1370
1238
|
},
|
|
1371
|
-
target: relevantProperty ?? NoTarget
|
|
1239
|
+
target: relevantProperty ?? NoTarget,
|
|
1372
1240
|
});
|
|
1373
1241
|
return applyIntrinsicDecorators(program, type, {
|
|
1374
1242
|
type: "number",
|
|
1375
1243
|
format: "decimal",
|
|
1376
|
-
description: "decimal"
|
|
1244
|
+
description: "decimal",
|
|
1377
1245
|
});
|
|
1378
1246
|
case "decimal128":
|
|
1379
1247
|
reportDiagnostic(program, {
|
|
1380
1248
|
code: "decimal-to-number",
|
|
1381
1249
|
format: {
|
|
1382
|
-
propertyName: relevantProperty?.name ?? ""
|
|
1250
|
+
propertyName: relevantProperty?.name ?? "",
|
|
1383
1251
|
},
|
|
1384
|
-
target: relevantProperty ?? NoTarget
|
|
1252
|
+
target: relevantProperty ?? NoTarget,
|
|
1385
1253
|
});
|
|
1386
1254
|
return applyIntrinsicDecorators(program, type, {
|
|
1387
1255
|
type: "number",
|
|
1388
1256
|
format: "decimal128",
|
|
1389
|
-
description: "decimal128"
|
|
1257
|
+
description: "decimal128",
|
|
1390
1258
|
});
|
|
1391
1259
|
case "string":
|
|
1392
1260
|
if (format === "binary") {
|
|
@@ -1395,11 +1263,11 @@ function getSchemaForStdScalar(
|
|
|
1395
1263
|
format: "binary",
|
|
1396
1264
|
description,
|
|
1397
1265
|
typeName: BINARY_TYPE_UNION,
|
|
1398
|
-
outputTypeName: "Uint8Array"
|
|
1266
|
+
outputTypeName: "Uint8Array",
|
|
1399
1267
|
};
|
|
1400
1268
|
}
|
|
1401
1269
|
return applyIntrinsicDecorators(program, type, {
|
|
1402
|
-
type: "string"
|
|
1270
|
+
type: "string",
|
|
1403
1271
|
});
|
|
1404
1272
|
case "boolean":
|
|
1405
1273
|
return { type: "boolean", description };
|
|
@@ -1409,7 +1277,7 @@ function getSchemaForStdScalar(
|
|
|
1409
1277
|
format,
|
|
1410
1278
|
description,
|
|
1411
1279
|
typeName: "string",
|
|
1412
|
-
outputTypeName: "string"
|
|
1280
|
+
outputTypeName: "string",
|
|
1413
1281
|
};
|
|
1414
1282
|
case "utcDateTime":
|
|
1415
1283
|
return {
|
|
@@ -1417,7 +1285,7 @@ function getSchemaForStdScalar(
|
|
|
1417
1285
|
format,
|
|
1418
1286
|
description,
|
|
1419
1287
|
typeName: "Date | string",
|
|
1420
|
-
outputTypeName: "string"
|
|
1288
|
+
outputTypeName: "string",
|
|
1421
1289
|
};
|
|
1422
1290
|
case "offsetDateTime":
|
|
1423
1291
|
return {
|
|
@@ -1425,7 +1293,7 @@ function getSchemaForStdScalar(
|
|
|
1425
1293
|
format: "date-time",
|
|
1426
1294
|
description,
|
|
1427
1295
|
typeName: "string",
|
|
1428
|
-
outputTypeName: "string"
|
|
1296
|
+
outputTypeName: "string",
|
|
1429
1297
|
};
|
|
1430
1298
|
case "plainTime":
|
|
1431
1299
|
return {
|
|
@@ -1433,7 +1301,7 @@ function getSchemaForStdScalar(
|
|
|
1433
1301
|
format: "time",
|
|
1434
1302
|
description,
|
|
1435
1303
|
typeName: "string",
|
|
1436
|
-
outputTypeName: "string"
|
|
1304
|
+
outputTypeName: "string",
|
|
1437
1305
|
};
|
|
1438
1306
|
case "duration":
|
|
1439
1307
|
return { type: "string", format, description };
|
|
@@ -1442,23 +1310,12 @@ function getSchemaForStdScalar(
|
|
|
1442
1310
|
}
|
|
1443
1311
|
}
|
|
1444
1312
|
|
|
1445
|
-
function isEncodeTypeEffective(
|
|
1446
|
-
type: Scalar,
|
|
1447
|
-
encodeData: EncodeData | undefined
|
|
1448
|
-
) {
|
|
1313
|
+
function isEncodeTypeEffective(type: Scalar, encodeData: EncodeData | undefined) {
|
|
1449
1314
|
if (!encodeData) {
|
|
1450
1315
|
return false;
|
|
1451
1316
|
}
|
|
1452
|
-
const datetimeTypes = [
|
|
1453
|
-
|
|
1454
|
-
"utcdatetime",
|
|
1455
|
-
"offsetdatetime",
|
|
1456
|
-
"plaintime"
|
|
1457
|
-
];
|
|
1458
|
-
if (
|
|
1459
|
-
datetimeTypes.includes(type.name.toLowerCase()) &&
|
|
1460
|
-
encodeData.type.name === "string"
|
|
1461
|
-
) {
|
|
1317
|
+
const datetimeTypes = ["plaindate", "utcdatetime", "offsetdatetime", "plaintime"];
|
|
1318
|
+
if (datetimeTypes.includes(type.name.toLowerCase()) && encodeData.type.name === "string") {
|
|
1462
1319
|
return false;
|
|
1463
1320
|
}
|
|
1464
1321
|
return true;
|
|
@@ -1469,18 +1326,13 @@ export function getTypeName(schema: Schema, usage?: SchemaContext[]): string {
|
|
|
1469
1326
|
return getPriorityName(schema, usage) ?? schema.type ?? "any";
|
|
1470
1327
|
}
|
|
1471
1328
|
|
|
1472
|
-
export function getImportedModelName(
|
|
1473
|
-
schema: Schema,
|
|
1474
|
-
usage?: SchemaContext[]
|
|
1475
|
-
): string[] {
|
|
1329
|
+
export function getImportedModelName(schema: Schema, usage?: SchemaContext[]): string[] {
|
|
1476
1330
|
switch (schema.type) {
|
|
1477
1331
|
case "array": {
|
|
1478
1332
|
const ret = new Set<string>();
|
|
1479
1333
|
[(schema as ArraySchema).items]
|
|
1480
1334
|
.filter((i?: Schema) => !!i)
|
|
1481
|
-
.forEach((i?: Schema) =>
|
|
1482
|
-
getImportedModelName(i!, usage).forEach((it) => ret.add(it))
|
|
1483
|
-
);
|
|
1335
|
+
.forEach((i?: Schema) => getImportedModelName(i!, usage).forEach((it) => ret.add(it)));
|
|
1484
1336
|
return [...ret];
|
|
1485
1337
|
}
|
|
1486
1338
|
case "object": {
|
|
@@ -1491,23 +1343,17 @@ export function getImportedModelName(
|
|
|
1491
1343
|
if (!properties[name]) {
|
|
1492
1344
|
continue;
|
|
1493
1345
|
}
|
|
1494
|
-
getImportedModelName(properties[name]!, usage).forEach((it) =>
|
|
1495
|
-
ret.add(it)
|
|
1496
|
-
);
|
|
1346
|
+
getImportedModelName(properties[name]!, usage).forEach((it) => ret.add(it));
|
|
1497
1347
|
}
|
|
1498
1348
|
return [...ret];
|
|
1499
1349
|
}
|
|
1500
|
-
return getPriorityName(schema, usage)
|
|
1501
|
-
? [getPriorityName(schema, usage)]
|
|
1502
|
-
: [];
|
|
1350
|
+
return getPriorityName(schema, usage) ? [getPriorityName(schema, usage)] : [];
|
|
1503
1351
|
}
|
|
1504
1352
|
case "dictionary": {
|
|
1505
1353
|
const ret = new Set<string>();
|
|
1506
1354
|
[(schema as DictionarySchema).additionalProperties]
|
|
1507
1355
|
.filter((i?: Schema) => !!i)
|
|
1508
|
-
.forEach((i?: Schema) =>
|
|
1509
|
-
getImportedModelName(i!, usage).forEach((it) => ret.add(it))
|
|
1510
|
-
);
|
|
1356
|
+
.forEach((i?: Schema) => getImportedModelName(i!, usage).forEach((it) => ret.add(it)));
|
|
1511
1357
|
|
|
1512
1358
|
return [...ret];
|
|
1513
1359
|
}
|
|
@@ -1515,9 +1361,7 @@ export function getImportedModelName(
|
|
|
1515
1361
|
const ret = new Set<string>();
|
|
1516
1362
|
((schema as Schema).enum ?? [])
|
|
1517
1363
|
.filter((i?: Schema) => !!i)
|
|
1518
|
-
.forEach((i?: Schema) =>
|
|
1519
|
-
getImportedModelName(i!, usage).forEach((it) => ret.add(it))
|
|
1520
|
-
);
|
|
1364
|
+
.forEach((i?: Schema) => getImportedModelName(i!, usage).forEach((it) => ret.add(it)));
|
|
1521
1365
|
|
|
1522
1366
|
return [...ret];
|
|
1523
1367
|
}
|
|
@@ -1527,9 +1371,7 @@ export function getImportedModelName(
|
|
|
1527
1371
|
}
|
|
1528
1372
|
|
|
1529
1373
|
function getPriorityName(schema: Schema, usage?: SchemaContext[]): string {
|
|
1530
|
-
return usage &&
|
|
1531
|
-
usage.includes(SchemaContext.Input) &&
|
|
1532
|
-
!usage.includes(SchemaContext.Output)
|
|
1374
|
+
return usage && usage.includes(SchemaContext.Input) && !usage.includes(SchemaContext.Output)
|
|
1533
1375
|
? (schema.typeName ?? schema.name)
|
|
1534
1376
|
: (schema.outputTypeName ?? schema.typeName ?? schema.name);
|
|
1535
1377
|
}
|
|
@@ -1562,10 +1404,7 @@ function getBinaryDescription(type: any) {
|
|
|
1562
1404
|
}
|
|
1563
1405
|
|
|
1564
1406
|
function getDecimalDescription(type: any) {
|
|
1565
|
-
if (
|
|
1566
|
-
(type.format === "decimal" || type.format === "decimal128") &&
|
|
1567
|
-
type.type === "number"
|
|
1568
|
-
) {
|
|
1407
|
+
if ((type.format === "decimal" || type.format === "decimal128") && type.type === "number") {
|
|
1569
1408
|
return `NOTE: This property is represented as a 'number' in JavaScript, but it corresponds to a 'decimal' type in other languages.
|
|
1570
1409
|
Due to the inherent limitations of floating-point arithmetic in JavaScript, precision issues may arise when performing arithmetic operations.
|
|
1571
1410
|
If your application requires high precision for arithmetic operations or when round-tripping data back to other languages, consider using a library like decimal.js, which provides an arbitrary-precision Decimal type.
|
|
@@ -1580,7 +1419,7 @@ export function getFormattedPropertyDoc(
|
|
|
1580
1419
|
program: Program,
|
|
1581
1420
|
type: ModelProperty | Type,
|
|
1582
1421
|
schemaType: any,
|
|
1583
|
-
sperator: string = "\n\n"
|
|
1422
|
+
sperator: string = "\n\n",
|
|
1584
1423
|
) {
|
|
1585
1424
|
const propertyDoc = getDoc(program, type);
|
|
1586
1425
|
const enhancedDocFromType =
|
|
@@ -1599,7 +1438,7 @@ export function getBodyType(route: HttpOperation): Type | undefined {
|
|
|
1599
1438
|
}
|
|
1600
1439
|
|
|
1601
1440
|
export function getValueTypeValue(
|
|
1602
|
-
value: Value
|
|
1441
|
+
value: Value,
|
|
1603
1442
|
): string | boolean | null | number | Array<unknown> | object | undefined {
|
|
1604
1443
|
switch (value.valueKind) {
|
|
1605
1444
|
case "ArrayValue":
|
|
@@ -1616,8 +1455,8 @@ export function getValueTypeValue(
|
|
|
1616
1455
|
return Object.fromEntries(
|
|
1617
1456
|
[...value.properties.keys()].map((x) => [
|
|
1618
1457
|
x,
|
|
1619
|
-
getValueTypeValue(value.properties.get(x)!.value)
|
|
1620
|
-
])
|
|
1458
|
+
getValueTypeValue(value.properties.get(x)!.value),
|
|
1459
|
+
]),
|
|
1621
1460
|
);
|
|
1622
1461
|
default:
|
|
1623
1462
|
// TODO: handle scalar value
|
|
@@ -1634,25 +1473,20 @@ export function getValueTypeValue(
|
|
|
1634
1473
|
* @param param The param to predict
|
|
1635
1474
|
* @returns
|
|
1636
1475
|
*/
|
|
1637
|
-
export function predictDefaultValue(
|
|
1638
|
-
dpgContext: SdkContext,
|
|
1639
|
-
param?: ModelProperty
|
|
1640
|
-
) {
|
|
1476
|
+
export function predictDefaultValue(dpgContext: SdkContext, param?: ModelProperty) {
|
|
1641
1477
|
if (!param) {
|
|
1642
1478
|
return;
|
|
1643
1479
|
}
|
|
1644
1480
|
const program = dpgContext.program;
|
|
1645
|
-
const specificDefault = param.defaultValue
|
|
1646
|
-
? getValueTypeValue(param.defaultValue)
|
|
1647
|
-
: undefined;
|
|
1481
|
+
const specificDefault = param.defaultValue ? getValueTypeValue(param.defaultValue) : undefined;
|
|
1648
1482
|
if (specificDefault) {
|
|
1649
1483
|
if (typeof specificDefault === "object") {
|
|
1650
1484
|
reportDiagnostic(program, {
|
|
1651
1485
|
code: "default-value-object",
|
|
1652
1486
|
format: {
|
|
1653
|
-
propertyName: param.name
|
|
1487
|
+
propertyName: param.name,
|
|
1654
1488
|
},
|
|
1655
|
-
target: param
|
|
1489
|
+
target: param,
|
|
1656
1490
|
});
|
|
1657
1491
|
return specificDefault.toString();
|
|
1658
1492
|
}
|
|
@@ -1660,7 +1494,7 @@ export function predictDefaultValue(
|
|
|
1660
1494
|
}
|
|
1661
1495
|
const serviceNamespace = getDefaultService(
|
|
1662
1496
|
program,
|
|
1663
|
-
dpgContext.rlcOptions?.isModularLibrary
|
|
1497
|
+
dpgContext.rlcOptions?.isModularLibrary,
|
|
1664
1498
|
)?.type;
|
|
1665
1499
|
if (!serviceNamespace) {
|
|
1666
1500
|
return;
|
|
@@ -1674,19 +1508,19 @@ export function predictDefaultValue(
|
|
|
1674
1508
|
|
|
1675
1509
|
export function getDefaultService(
|
|
1676
1510
|
program: Program,
|
|
1677
|
-
isModularLibrary: boolean = true
|
|
1511
|
+
isModularLibrary: boolean = true,
|
|
1678
1512
|
): Service | undefined {
|
|
1679
1513
|
const services = listServices(program);
|
|
1680
1514
|
if (!services || services.length === 0) {
|
|
1681
1515
|
reportDiagnostic(program, {
|
|
1682
1516
|
code: "no-service-defined",
|
|
1683
|
-
target: NoTarget
|
|
1517
|
+
target: NoTarget,
|
|
1684
1518
|
});
|
|
1685
1519
|
}
|
|
1686
1520
|
if (services.length > 1 && !isModularLibrary) {
|
|
1687
1521
|
reportDiagnostic(program, {
|
|
1688
1522
|
code: "more-than-one-service",
|
|
1689
|
-
target: NoTarget
|
|
1523
|
+
target: NoTarget,
|
|
1690
1524
|
});
|
|
1691
1525
|
}
|
|
1692
1526
|
return services[0];
|
|
@@ -1694,16 +1528,11 @@ export function getDefaultService(
|
|
|
1694
1528
|
/**
|
|
1695
1529
|
* Return the default api version from the program; undefined if no default
|
|
1696
1530
|
*/
|
|
1697
|
-
export function getDefaultApiVersionString(
|
|
1698
|
-
dpgContext: SdkContext
|
|
1699
|
-
): string | undefined {
|
|
1531
|
+
export function getDefaultApiVersionString(dpgContext: SdkContext): string | undefined {
|
|
1700
1532
|
const program = dpgContext.program;
|
|
1701
1533
|
const isModularLibrary = dpgContext.rlcOptions?.isModularLibrary;
|
|
1702
1534
|
return getDefaultService(program, isModularLibrary)
|
|
1703
|
-
? getDefaultApiVersion(
|
|
1704
|
-
dpgContext,
|
|
1705
|
-
getDefaultService(program, isModularLibrary)!.type
|
|
1706
|
-
)?.value
|
|
1535
|
+
? getDefaultApiVersion(dpgContext, getDefaultService(program, isModularLibrary)!.type)?.value
|
|
1707
1536
|
: undefined;
|
|
1708
1537
|
}
|
|
1709
1538
|
|
|
@@ -1727,29 +1556,17 @@ export function isAzureCoreErrorType(program: Program, t?: Type): boolean {
|
|
|
1727
1556
|
return false;
|
|
1728
1557
|
}
|
|
1729
1558
|
const effective = getEffectiveSchemaType(program, t);
|
|
1730
|
-
if (
|
|
1731
|
-
!["error", "errorresponse", "innererror"].includes(
|
|
1732
|
-
effective.name.toLowerCase()
|
|
1733
|
-
)
|
|
1734
|
-
) {
|
|
1559
|
+
if (!["error", "errorresponse", "innererror"].includes(effective.name.toLowerCase())) {
|
|
1735
1560
|
return false;
|
|
1736
1561
|
}
|
|
1737
1562
|
return isAzureCoreFoundationsNamespace(effective);
|
|
1738
1563
|
}
|
|
1739
1564
|
|
|
1740
|
-
function isAzureCoreFoundationsNamespace(
|
|
1741
|
-
|
|
1742
|
-
skipFoundation: boolean = false
|
|
1743
|
-
): boolean {
|
|
1744
|
-
const namespaces = (
|
|
1745
|
-
skipFoundation ? ".Azure.Core" : ".Azure.Core.Foundations"
|
|
1746
|
-
).split(".");
|
|
1565
|
+
function isAzureCoreFoundationsNamespace(t?: Type, skipFoundation: boolean = false): boolean {
|
|
1566
|
+
const namespaces = (skipFoundation ? ".Azure.Core" : ".Azure.Core.Foundations").split(".");
|
|
1747
1567
|
while (
|
|
1748
1568
|
namespaces.length > 0 &&
|
|
1749
|
-
(t?.kind === "Model" ||
|
|
1750
|
-
t?.kind === "Enum" ||
|
|
1751
|
-
t?.kind === "Union" ||
|
|
1752
|
-
t?.kind === "Namespace") &&
|
|
1569
|
+
(t?.kind === "Model" || t?.kind === "Enum" || t?.kind === "Union" || t?.kind === "Namespace") &&
|
|
1753
1570
|
t.namespace?.name === namespaces.pop()
|
|
1754
1571
|
) {
|
|
1755
1572
|
t = t.namespace;
|
|
@@ -1782,14 +1599,10 @@ export function getModelInlineSigniture(
|
|
|
1782
1599
|
importedModels?: Set<string>;
|
|
1783
1600
|
usage?: SchemaContext[];
|
|
1784
1601
|
multipart?: boolean;
|
|
1785
|
-
} = {}
|
|
1602
|
+
} = {},
|
|
1786
1603
|
) {
|
|
1787
1604
|
if (options.multipart) {
|
|
1788
|
-
return getMultipartInlineSignature(
|
|
1789
|
-
schema,
|
|
1790
|
-
options.importedModels,
|
|
1791
|
-
options.usage
|
|
1792
|
-
);
|
|
1605
|
+
return getMultipartInlineSignature(schema, options.importedModels, options.usage);
|
|
1793
1606
|
}
|
|
1794
1607
|
|
|
1795
1608
|
let schemaSignature = `{`;
|
|
@@ -1802,10 +1615,7 @@ export function getModelInlineSigniture(
|
|
|
1802
1615
|
if (options.importedModels) {
|
|
1803
1616
|
const importNames = getImportedModelName(propType);
|
|
1804
1617
|
if (importNames) {
|
|
1805
|
-
importNames!.forEach(
|
|
1806
|
-
options.importedModels.add,
|
|
1807
|
-
options.importedModels
|
|
1808
|
-
);
|
|
1618
|
+
importNames!.forEach(options.importedModels.add, options.importedModels);
|
|
1809
1619
|
}
|
|
1810
1620
|
}
|
|
1811
1621
|
const isOptional = propType.required ? "" : "?";
|
|
@@ -1819,7 +1629,7 @@ export function getModelInlineSigniture(
|
|
|
1819
1629
|
function getMultipartInlineSignature(
|
|
1820
1630
|
schema: ObjectSchema,
|
|
1821
1631
|
importedModels?: Set<string>,
|
|
1822
|
-
usage?: SchemaContext[]
|
|
1632
|
+
usage?: SchemaContext[],
|
|
1823
1633
|
): string {
|
|
1824
1634
|
const types = Object.entries(schema.properties ?? {})
|
|
1825
1635
|
.map(([propertyName, property]) => {
|
|
@@ -1864,30 +1674,16 @@ function getMultipartInlineSignature(
|
|
|
1864
1674
|
* Headers, parameters, status codes are not schema properties even they are
|
|
1865
1675
|
* represented as properties in typespec.
|
|
1866
1676
|
*/
|
|
1867
|
-
export function isSchemaProperty(
|
|
1868
|
-
program: Program,
|
|
1869
|
-
property: ModelProperty
|
|
1870
|
-
): boolean {
|
|
1677
|
+
export function isSchemaProperty(program: Program, property: ModelProperty): boolean {
|
|
1871
1678
|
const headerInfo = getHeaderFieldName(program, property);
|
|
1872
1679
|
const queryInfo = getQueryParamName(program, property);
|
|
1873
1680
|
const pathInfo = getPathParamName(program, property);
|
|
1874
1681
|
const statusCodeInfo = isStatusCode(program, property);
|
|
1875
|
-
const isNonVisibility = getSdkVisibility(program, property)?.includes(
|
|
1876
|
-
|
|
1877
|
-
);
|
|
1878
|
-
return !(
|
|
1879
|
-
headerInfo ||
|
|
1880
|
-
queryInfo ||
|
|
1881
|
-
pathInfo ||
|
|
1882
|
-
statusCodeInfo ||
|
|
1883
|
-
isNonVisibility
|
|
1884
|
-
);
|
|
1682
|
+
const isNonVisibility = getSdkVisibility(program, property)?.includes(Visibility.None);
|
|
1683
|
+
return !(headerInfo || queryInfo || pathInfo || statusCodeInfo || isNonVisibility);
|
|
1885
1684
|
}
|
|
1886
1685
|
|
|
1887
|
-
export function getEffectiveSchemaType(
|
|
1888
|
-
program: Program,
|
|
1889
|
-
type: Model | Union
|
|
1890
|
-
): Model {
|
|
1686
|
+
export function getEffectiveSchemaType(program: Program, type: Model | Union): Model {
|
|
1891
1687
|
// If type is an anonymous model, tries to find a named model that has the same properties
|
|
1892
1688
|
let effective: Model | undefined = undefined;
|
|
1893
1689
|
if (type.kind === "Union") {
|
|
@@ -1904,7 +1700,7 @@ export function getEffectiveSchemaType(
|
|
|
1904
1700
|
return type as any;
|
|
1905
1701
|
} else if (type.name === "") {
|
|
1906
1702
|
effective = getEffectiveModelType(program, type, (property) =>
|
|
1907
|
-
isSchemaProperty(program, property)
|
|
1703
|
+
isSchemaProperty(program, property),
|
|
1908
1704
|
);
|
|
1909
1705
|
}
|
|
1910
1706
|
|
|
@@ -1915,17 +1711,12 @@ export function getEffectiveSchemaType(
|
|
|
1915
1711
|
}
|
|
1916
1712
|
|
|
1917
1713
|
export function isBodyRequired(parameter: HttpOperationParameters) {
|
|
1918
|
-
return parameter.body?.type && parameter.body?.property?.optional !== true
|
|
1919
|
-
? true
|
|
1920
|
-
: false;
|
|
1714
|
+
return parameter.body?.type && parameter.body?.property?.optional !== true ? true : false;
|
|
1921
1715
|
}
|
|
1922
1716
|
|
|
1923
1717
|
export function getCollectionFormat(
|
|
1924
1718
|
context: SdkContext,
|
|
1925
|
-
param:
|
|
1926
|
-
| HttpOperationPathParameter
|
|
1927
|
-
| HttpOperationQueryParameter
|
|
1928
|
-
| HttpOperationHeaderParameter
|
|
1719
|
+
param: HttpOperationPathParameter | HttpOperationQueryParameter | HttpOperationHeaderParameter,
|
|
1929
1720
|
): string | undefined {
|
|
1930
1721
|
const type = param.param;
|
|
1931
1722
|
const encode = getEncode(context.program, param.param);
|