@azure-tools/typespec-ts 0.54.0 → 0.55.0-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/dist/src/contextManager.d.ts +5 -5
- package/dist/src/contextManager.d.ts.map +1 -1
- package/dist/src/contextManager.js +3 -3
- package/dist/src/contextManager.js.map +1 -1
- package/dist/src/framework/declaration.d.ts +1 -1
- package/dist/src/framework/declaration.d.ts.map +1 -1
- package/dist/src/framework/declaration.js +2 -4
- package/dist/src/framework/declaration.js.map +1 -1
- package/dist/src/framework/dependency.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.d.ts +1 -1
- package/dist/src/framework/hooks/binder.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.js +31 -40
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/sdkTypes.d.ts +1 -1
- package/dist/src/framework/hooks/sdkTypes.d.ts.map +1 -1
- package/dist/src/framework/hooks/sdkTypes.js +8 -12
- package/dist/src/framework/hooks/sdkTypes.js.map +1 -1
- package/dist/src/framework/hooks/useDependencies.d.ts.map +1 -1
- package/dist/src/framework/hooks/useDependencies.js +1 -1
- package/dist/src/framework/hooks/useDependencies.js.map +1 -1
- package/dist/src/framework/load-static-helpers.d.ts +1 -1
- package/dist/src/framework/load-static-helpers.d.ts.map +1 -1
- package/dist/src/framework/load-static-helpers.js +17 -31
- package/dist/src/framework/load-static-helpers.js.map +1 -1
- package/dist/src/framework/reference.d.ts.map +1 -1
- package/dist/src/framework/reference.js +2 -2
- package/dist/src/framework/reference.js.map +1 -1
- package/dist/src/framework/sample.js +8 -8
- package/dist/src/framework/sample.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +103 -92
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +1 -1
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +140 -140
- package/dist/src/lib.js.map +1 -1
- package/dist/src/metaTree.d.ts +1 -1
- package/dist/src/metaTree.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +60 -74
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.d.ts +2 -2
- package/dist/src/modular/buildClassicalOperationGroups.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js +8 -10
- package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
- package/dist/src/modular/buildClientContext.d.ts +2 -2
- package/dist/src/modular/buildClientContext.d.ts.map +1 -1
- package/dist/src/modular/buildClientContext.js +31 -38
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildModularOptions.d.ts +1 -1
- package/dist/src/modular/buildModularOptions.d.ts.map +1 -1
- package/dist/src/modular/buildModularOptions.js +5 -6
- package/dist/src/modular/buildModularOptions.js.map +1 -1
- package/dist/src/modular/buildOperations.d.ts +3 -3
- package/dist/src/modular/buildOperations.d.ts.map +1 -1
- package/dist/src/modular/buildOperations.js +23 -25
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildProjectFiles.d.ts +1 -1
- package/dist/src/modular/buildProjectFiles.d.ts.map +1 -1
- package/dist/src/modular/buildProjectFiles.js +8 -11
- package/dist/src/modular/buildProjectFiles.js.map +1 -1
- package/dist/src/modular/buildRestorePoller.d.ts +1 -1
- package/dist/src/modular/buildRestorePoller.d.ts.map +1 -1
- package/dist/src/modular/buildRestorePoller.js +12 -13
- package/dist/src/modular/buildRestorePoller.js.map +1 -1
- package/dist/src/modular/buildRootIndex.d.ts +2 -2
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
- package/dist/src/modular/buildRootIndex.js +36 -50
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/buildSubpathIndex.d.ts.map +1 -1
- package/dist/src/modular/buildSubpathIndex.js +9 -18
- package/dist/src/modular/buildSubpathIndex.js.map +1 -1
- package/dist/src/modular/emitLoggerFile.d.ts.map +1 -1
- package/dist/src/modular/emitLoggerFile.js +4 -4
- package/dist/src/modular/emitLoggerFile.js.map +1 -1
- package/dist/src/modular/emitModels.d.ts +1 -1
- package/dist/src/modular/emitModels.d.ts.map +1 -1
- package/dist/src/modular/emitModels.js +81 -113
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/emitModelsOptions.d.ts +1 -1
- package/dist/src/modular/emitModelsOptions.d.ts.map +1 -1
- package/dist/src/modular/emitModelsOptions.js +7 -8
- package/dist/src/modular/emitModelsOptions.js.map +1 -1
- package/dist/src/modular/emitSamples.d.ts.map +1 -1
- package/dist/src/modular/emitSamples.js +69 -77
- package/dist/src/modular/emitSamples.js.map +1 -1
- package/dist/src/modular/emitTests.d.ts.map +1 -1
- package/dist/src/modular/emitTests.js +13 -18
- package/dist/src/modular/emitTests.js.map +1 -1
- package/dist/src/modular/external-dependencies.js +54 -54
- package/dist/src/modular/helpers/classicalOperationHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.js +59 -68
- package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.d.ts +2 -2
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +31 -54
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.js +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.js.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.d.ts +2 -2
- package/dist/src/modular/helpers/exampleValueHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.js +72 -84
- package/dist/src/modular/helpers/exampleValueHelpers.js.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.js +7 -10
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +2 -2
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +204 -288
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +4 -6
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.d.ts +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.js +58 -67
- package/dist/src/modular/serialization/buildDeserializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.d.ts +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js +65 -75
- package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.d.ts +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js +73 -90
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/serializeUtils.d.ts.map +1 -1
- package/dist/src/modular/serialization/serializeUtils.js +25 -33
- package/dist/src/modular/serialization/serializeUtils.js.map +1 -1
- package/dist/src/modular/static-helpers-metadata.js +60 -60
- package/dist/src/modular/type-expressions/get-credential-expression.js +1 -1
- package/dist/src/modular/type-expressions/get-credential-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.d.ts +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.js +1 -2
- package/dist/src/modular/type-expressions/get-enum-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-model-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-model-expression.js +10 -13
- package/dist/src/modular/type-expressions/get-model-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.d.ts +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.js +2 -3
- package/dist/src/modular/type-expressions/get-nullable-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.js +5 -11
- package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-union-expression.d.ts +1 -1
- package/dist/src/modular/type-expressions/get-union-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-union-expression.js.map +1 -1
- package/dist/src/rlc-common/buildClient.d.ts +1 -1
- package/dist/src/rlc-common/buildClient.d.ts.map +1 -1
- package/dist/src/rlc-common/buildClient.js +67 -89
- package/dist/src/rlc-common/buildClient.js.map +1 -1
- package/dist/src/rlc-common/buildClientDefinitions.d.ts.map +1 -1
- package/dist/src/rlc-common/buildClientDefinitions.js +28 -45
- package/dist/src/rlc-common/buildClientDefinitions.js.map +1 -1
- package/dist/src/rlc-common/buildIndexFile.d.ts.map +1 -1
- package/dist/src/rlc-common/buildIndexFile.js +59 -60
- package/dist/src/rlc-common/buildIndexFile.js.map +1 -1
- package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js +37 -38
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +1 -1
- package/dist/src/rlc-common/buildLogger.d.ts.map +1 -1
- package/dist/src/rlc-common/buildLogger.js +4 -5
- package/dist/src/rlc-common/buildLogger.js.map +1 -1
- package/dist/src/rlc-common/buildMethodShortcuts.d.ts.map +1 -1
- package/dist/src/rlc-common/buildMethodShortcuts.js +4 -4
- package/dist/src/rlc-common/buildMethodShortcuts.js.map +1 -1
- package/dist/src/rlc-common/buildObjectTypes.d.ts.map +1 -1
- package/dist/src/rlc-common/buildObjectTypes.js +57 -96
- package/dist/src/rlc-common/buildObjectTypes.js.map +1 -1
- package/dist/src/rlc-common/buildPaginateHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildPaginateHelper.js +2 -2
- package/dist/src/rlc-common/buildPaginateHelper.js.map +1 -1
- package/dist/src/rlc-common/buildParameterTypes.d.ts.map +1 -1
- package/dist/src/rlc-common/buildParameterTypes.js +71 -61
- package/dist/src/rlc-common/buildParameterTypes.js.map +1 -1
- package/dist/src/rlc-common/buildPollingHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildPollingHelper.js +9 -10
- package/dist/src/rlc-common/buildPollingHelper.js.map +1 -1
- package/dist/src/rlc-common/buildResponseTypes.d.ts.map +1 -1
- package/dist/src/rlc-common/buildResponseTypes.js +23 -27
- package/dist/src/rlc-common/buildResponseTypes.js.map +1 -1
- package/dist/src/rlc-common/buildSamples.d.ts +1 -1
- package/dist/src/rlc-common/buildSamples.d.ts.map +1 -1
- package/dist/src/rlc-common/buildSamples.js +2 -2
- package/dist/src/rlc-common/buildSchemaType.d.ts.map +1 -1
- package/dist/src/rlc-common/buildSchemaType.js +31 -13
- package/dist/src/rlc-common/buildSchemaType.js.map +1 -1
- package/dist/src/rlc-common/buildSerializeHelper.d.ts.map +1 -1
- package/dist/src/rlc-common/buildSerializeHelper.js +4 -4
- package/dist/src/rlc-common/buildSerializeHelper.js.map +1 -1
- package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts.map +1 -1
- package/dist/src/rlc-common/buildTopLevelIndexFile.js +9 -13
- package/dist/src/rlc-common/buildTopLevelIndexFile.js.map +1 -1
- package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/apiVersionUtil.js +6 -8
- package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/importsUtil.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/importsUtil.js +32 -37
- package/dist/src/rlc-common/helpers/importsUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/nameConstructors.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/nameConstructors.js +2 -4
- package/dist/src/rlc-common/helpers/nameConstructors.js.map +1 -1
- package/dist/src/rlc-common/helpers/nameUtils.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/nameUtils.js +17 -23
- package/dist/src/rlc-common/helpers/nameUtils.js.map +1 -1
- package/dist/src/rlc-common/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/operationHelpers.js +16 -31
- package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/packageUtil.js +3 -6
- package/dist/src/rlc-common/helpers/packageUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/pathUtils.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/pathUtils.js +1 -3
- package/dist/src/rlc-common/helpers/pathUtils.js.map +1 -1
- package/dist/src/rlc-common/helpers/schemaHelpers.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/schemaHelpers.js +3 -7
- package/dist/src/rlc-common/helpers/schemaHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/shortcutMethods.d.ts +1 -1
- package/dist/src/rlc-common/helpers/shortcutMethods.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/shortcutMethods.js +2 -2
- package/dist/src/rlc-common/helpers/shortcutMethods.js.map +1 -1
- package/dist/src/rlc-common/helpers/typeUtil.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/typeUtil.js +4 -9
- package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js +7 -11
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +1 -1
- package/dist/src/rlc-common/index.d.ts +28 -28
- package/dist/src/rlc-common/index.d.ts.map +1 -1
- package/dist/src/rlc-common/index.js +28 -28
- package/dist/src/rlc-common/index.js.map +1 -1
- package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
- package/dist/src/rlc-common/interfaces.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +14 -15
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildChangelogFile.js +2 -3
- package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildESLintConfig.js +5 -8
- package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildLicenseFile.js +1 -1
- package/dist/src/rlc-common/metadata/buildPackageFile.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildPackageFile.js +33 -37
- package/dist/src/rlc-common/metadata/buildPackageFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildReadmeFile.js +31 -39
- package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildRollupConfig.js +4 -6
- package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +3 -5
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTestConfig.js +11 -12
- package/dist/src/rlc-common/metadata/buildTestConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTsConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildTsConfig.js +28 -28
- package/dist/src/rlc-common/metadata/buildTsConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildVitestConfig.js +3 -5
- package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/buildWarpConfig.js +4 -5
- package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +14 -14
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +24 -29
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js +15 -16
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js +8 -8
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +28 -31
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -1
- package/dist/src/rlc-common/metadata/utils.js +1 -2
- package/dist/src/rlc-common/metadata/utils.js.map +1 -1
- package/dist/src/rlc-common/test/buildKarmaConfig.js +1 -1
- package/dist/src/rlc-common/test/buildRecordedClient.js +4 -5
- package/dist/src/rlc-common/test/buildRecordedClient.js.map +1 -1
- package/dist/src/rlc-common/test/buildSampleTest.d.ts.map +1 -1
- package/dist/src/rlc-common/test/buildSampleTest.js +3 -4
- package/dist/src/rlc-common/test/buildSampleTest.js.map +1 -1
- package/dist/src/rlc-common/test/buildSnippets.d.ts.map +1 -1
- package/dist/src/rlc-common/test/buildSnippets.js +7 -10
- package/dist/src/rlc-common/test/buildSnippets.js.map +1 -1
- package/dist/src/rlc-common/transformSampleGroups.d.ts.map +1 -1
- package/dist/src/rlc-common/transformSampleGroups.js +41 -45
- package/dist/src/rlc-common/transformSampleGroups.js.map +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +1 -1
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/transform/transform.d.ts +1 -1
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/transform/transform.js +28 -27
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +12 -14
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js +11 -14
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
- package/dist/src/transform/transformParameters.d.ts +2 -2
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +32 -45
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.d.ts +1 -1
- package/dist/src/transform/transformPaths.d.ts.map +1 -1
- package/dist/src/transform/transformPaths.js +19 -23
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.d.ts +1 -1
- package/dist/src/transform/transformResponses.d.ts.map +1 -1
- package/dist/src/transform/transformResponses.js +21 -25
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.d.ts.map +1 -1
- package/dist/src/transform/transformSchemas.js +21 -32
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/src/transform/transformTelemetryInfo.d.ts +1 -1
- package/dist/src/transform/transformTelemetryInfo.d.ts.map +1 -1
- package/dist/src/transform/transformTelemetryInfo.js +3 -3
- package/dist/src/transform/transformTelemetryInfo.js.map +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +28 -39
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/clientUtils.d.ts +1 -1
- package/dist/src/utils/clientUtils.d.ts.map +1 -1
- package/dist/src/utils/clientUtils.js +15 -23
- package/dist/src/utils/clientUtils.js.map +1 -1
- package/dist/src/utils/credentialUtils.d.ts +1 -1
- package/dist/src/utils/credentialUtils.d.ts.map +1 -1
- package/dist/src/utils/credentialUtils.js +4 -5
- package/dist/src/utils/credentialUtils.js.map +1 -1
- package/dist/src/utils/crossLanguageDef.d.ts.map +1 -1
- package/dist/src/utils/crossLanguageDef.js +11 -15
- package/dist/src/utils/crossLanguageDef.js.map +1 -1
- package/dist/src/utils/emitUtil.d.ts +1 -1
- package/dist/src/utils/emitUtil.d.ts.map +1 -1
- package/dist/src/utils/emitUtil.js +5 -7
- package/dist/src/utils/emitUtil.js.map +1 -1
- package/dist/src/utils/fileSystemUtils.d.ts +2 -0
- package/dist/src/utils/fileSystemUtils.d.ts.map +1 -1
- package/dist/src/utils/fileSystemUtils.js +26 -7
- package/dist/src/utils/fileSystemUtils.js.map +1 -1
- package/dist/src/utils/importHelper.d.ts.map +1 -1
- package/dist/src/utils/importHelper.js +3 -6
- package/dist/src/utils/importHelper.js.map +1 -1
- package/dist/src/utils/interfaces.d.ts +1 -1
- package/dist/src/utils/interfaces.d.ts.map +1 -1
- package/dist/src/utils/mediaTypes.d.ts.map +1 -1
- package/dist/src/utils/mediaTypes.js +7 -19
- package/dist/src/utils/mediaTypes.js.map +1 -1
- package/dist/src/utils/modelUtils.d.ts +5 -5
- package/dist/src/utils/modelUtils.d.ts.map +1 -1
- package/dist/src/utils/modelUtils.js +168 -257
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/namespaceUtils.d.ts.map +1 -1
- package/dist/src/utils/namespaceUtils.js +6 -7
- package/dist/src/utils/namespaceUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.d.ts +1 -1
- package/dist/src/utils/operationUtil.d.ts.map +1 -1
- package/dist/src/utils/operationUtil.js +60 -81
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/src/utils/parameterUtils.d.ts +1 -1
- package/dist/src/utils/parameterUtils.d.ts.map +1 -1
- package/dist/src/utils/parameterUtils.js +26 -33
- package/dist/src/utils/parameterUtils.js.map +1 -1
- package/dist/src/utils/resolve-project-root.js +2 -2
- package/dist/src/utils/resolve-project-root.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +38 -45
- package/src/contextManager.ts +6 -9
- package/src/framework/declaration.ts +18 -28
- package/src/framework/dependency.ts +1 -2
- package/src/framework/hooks/binder.ts +47 -120
- package/src/framework/hooks/sdkTypes.ts +27 -54
- package/src/framework/hooks/useDependencies.ts +2 -4
- package/src/framework/load-static-helpers.ts +28 -51
- package/src/framework/reference.ts +2 -5
- package/src/framework/sample.ts +9 -9
- package/src/index.ts +145 -185
- package/src/lib.ts +143 -158
- package/src/metaTree.ts +1 -1
- package/src/modular/buildClassicalClient.ts +83 -160
- package/src/modular/buildClassicalOperationGroups.ts +14 -39
- package/src/modular/buildClientContext.ts +54 -83
- package/src/modular/buildModularOptions.ts +4 -5
- package/src/modular/buildOperations.ts +46 -73
- package/src/modular/buildProjectFiles.ts +18 -47
- package/src/modular/buildRestorePoller.ts +27 -46
- package/src/modular/buildRootIndex.ts +86 -160
- package/src/modular/buildSubpathIndex.ts +35 -58
- package/src/modular/emitLoggerFile.ts +4 -9
- package/src/modular/emitModels.ts +136 -266
- package/src/modular/emitModelsOptions.ts +10 -16
- package/src/modular/emitSamples.ts +92 -180
- package/src/modular/emitTests.ts +28 -61
- package/src/modular/external-dependencies.ts +54 -54
- package/src/modular/helpers/classicalOperationHelpers.ts +73 -126
- package/src/modular/helpers/clientHelpers.ts +41 -88
- package/src/modular/helpers/clientOptionHelpers.ts +4 -11
- package/src/modular/helpers/exampleValueHelpers.ts +99 -215
- package/src/modular/helpers/namingHelpers.ts +12 -28
- package/src/modular/helpers/operationHelpers.ts +430 -757
- package/src/modular/helpers/typeHelpers.ts +11 -22
- package/src/modular/serialization/buildDeserializerFunction.ts +88 -122
- package/src/modular/serialization/buildSerializerFunction.ts +91 -129
- package/src/modular/serialization/buildXmlSerializerFunction.ts +104 -183
- package/src/modular/serialization/serializeUtils.ts +12 -22
- package/src/modular/static/rollup.test.config.js +11 -14
- package/src/modular/static/scripts/renameOutput.mjs +2 -2
- package/src/modular/static-helpers-metadata.ts +60 -60
- package/src/modular/type-expressions/get-credential-expression.ts +1 -1
- package/src/modular/type-expressions/get-enum-expression.ts +5 -10
- package/src/modular/type-expressions/get-model-expression.ts +13 -17
- package/src/modular/type-expressions/get-nullable-expression.ts +4 -5
- package/src/modular/type-expressions/get-type-expression.ts +8 -12
- package/src/modular/type-expressions/get-union-expression.ts +4 -4
- package/src/modular/type-expressions/utils.ts +1 -1
- package/src/rlc-common/buildClient.ts +70 -141
- package/src/rlc-common/buildClientDefinitions.ts +44 -87
- package/src/rlc-common/buildIndexFile.ts +78 -78
- package/src/rlc-common/buildIsUnexpectedHelper.ts +34 -41
- package/src/rlc-common/buildLogger.ts +7 -7
- package/src/rlc-common/buildMethodShortcuts.ts +9 -21
- package/src/rlc-common/buildObjectTypes.ts +79 -156
- package/src/rlc-common/buildPaginateHelper.ts +9 -12
- package/src/rlc-common/buildParameterTypes.ts +116 -137
- package/src/rlc-common/buildPollingHelper.ts +7 -7
- package/src/rlc-common/buildResponseTypes.ts +34 -57
- package/src/rlc-common/buildSamples.ts +3 -3
- package/src/rlc-common/buildSchemaType.ts +37 -29
- package/src/rlc-common/buildSerializeHelper.ts +5 -5
- package/src/rlc-common/buildTopLevelIndexFile.ts +12 -19
- package/src/rlc-common/helpers/apiVersionUtil.ts +5 -10
- package/src/rlc-common/helpers/importsUtil.ts +27 -30
- package/src/rlc-common/helpers/nameConstructors.ts +16 -50
- package/src/rlc-common/helpers/nameUtils.ts +19 -42
- package/src/rlc-common/helpers/operationHelpers.ts +14 -31
- package/src/rlc-common/helpers/pathUtils.ts +2 -7
- package/src/rlc-common/helpers/schemaHelpers.ts +4 -15
- package/src/rlc-common/helpers/shortcutMethods.ts +6 -15
- package/src/rlc-common/helpers/typeUtil.ts +4 -11
- package/src/rlc-common/helpers/valueGenerationUtil.ts +16 -39
- package/src/rlc-common/index.ts +28 -28
- package/src/rlc-common/interfaces.ts +3 -11
- package/src/rlc-common/metadata/buildApiExtractorConfig.ts +17 -24
- package/src/rlc-common/metadata/buildChangelogFile.ts +1 -1
- package/src/rlc-common/metadata/buildESLintConfig.ts +3 -5
- package/src/rlc-common/metadata/buildLicenseFile.ts +1 -1
- package/src/rlc-common/metadata/buildPackageFile.ts +27 -35
- package/src/rlc-common/metadata/buildReadmeFile.ts +16 -29
- package/src/rlc-common/metadata/buildRollupConfig.ts +5 -8
- package/src/rlc-common/metadata/buildSampleEnvFile.ts +2 -3
- package/src/rlc-common/metadata/buildTestConfig.ts +10 -10
- package/src/rlc-common/metadata/buildTsConfig.ts +32 -35
- package/src/rlc-common/metadata/buildVitestConfig.ts +4 -10
- package/src/rlc-common/metadata/buildWarpConfig.ts +3 -6
- package/src/rlc-common/metadata/packageJson/azurePackageCommon.ts +16 -25
- package/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.ts +29 -50
- package/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.ts +20 -31
- package/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.ts +11 -13
- package/src/rlc-common/metadata/packageJson/packageCommon.ts +32 -52
- package/src/rlc-common/test/buildKarmaConfig.ts +1 -1
- package/src/rlc-common/test/buildRecordedClient.ts +3 -3
- package/src/rlc-common/test/buildSampleTest.ts +3 -3
- package/src/rlc-common/test/buildSnippets.ts +6 -12
- package/src/rlc-common/transformSampleGroups.ts +54 -105
- package/src/testing/index.ts +2 -5
- package/src/transform/transform.ts +22 -34
- package/src/transform/transformApiVersionInfo.ts +17 -30
- package/src/transform/transformHelperFunctionDetails.ts +14 -26
- package/src/transform/transformParameters.ts +55 -105
- package/src/transform/transformPaths.ts +26 -43
- package/src/transform/transformResponses.ts +26 -33
- package/src/transform/transformSchemas.ts +15 -33
- package/src/transform/transformTelemetryInfo.ts +8 -14
- package/src/transform/transfromRLCOptions.ts +53 -116
- package/src/utils/clientUtils.ts +22 -41
- package/src/utils/credentialUtils.ts +8 -19
- package/src/utils/crossLanguageDef.ts +15 -34
- package/src/utils/emitUtil.ts +11 -17
- package/src/utils/fileSystemUtils.ts +30 -8
- package/src/utils/importHelper.ts +5 -10
- package/src/utils/interfaces.ts +1 -1
- package/src/utils/mediaTypes.ts +13 -34
- package/src/utils/modelUtils.ts +175 -384
- package/src/utils/namespaceUtils.ts +8 -24
- package/src/utils/operationUtil.ts +98 -190
- package/src/utils/parameterUtils.ts +31 -54
- package/src/utils/resolve-project-root.ts +3 -3
- package/static/static-helpers/cloudSettingHelpers.ts +4 -6
- package/static/static-helpers/multipartHelpers.ts +3 -3
- package/static/static-helpers/pagingHelpers.ts +28 -63
- package/static/static-helpers/pollingHelpers.ts +16 -29
- package/static/static-helpers/serialization/build-multi-collection.ts +1 -4
- package/static/static-helpers/serialization/check-prop-undefined.ts +1 -4
- package/static/static-helpers/serialization/get-binary-response-browser.mts +3 -1
- package/static/static-helpers/serialization/get-binary-response.ts +2 -2
- package/static/static-helpers/serialization/get-binary-stream-response-browser.mts +1 -3
- package/static/static-helpers/serialization/get-binary-stream-response.ts +2 -4
- package/static/static-helpers/serialization/serialize-record.ts +1 -1
- package/static/static-helpers/serialization/serializers.ts +4 -7
- package/static/static-helpers/serialization/xml-helpers.ts +42 -90
- package/static/static-helpers/simplePollerHelpers.ts +10 -19
- package/static/static-helpers/storageCompatResponse.ts +10 -27
- package/static/static-helpers/urlTemplate.ts +4 -7
- package/static/test-helpers/recordedClient.ts +5 -10
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { NameType, SchemaContext, isArraySchema, normalizeName } from "../rlc-common/index.js";
|
|
4
|
-
import { NoTarget, getDiscriminator, getDoc, getEffectiveModelType, getEncode, getFormat, getFriendlyName, getLifecycleVisibilityEnum, getMaxLength, getMaxValue, getMinLength, getMinValue, getPattern, getProperty, getPropertyType, getSummary, getVisibilityForClass, isArrayModelType, isNeverType, isNullType, isNumericType, isRecordModelType, isSecret, isStringType, isTemplateDeclaration, isUnknownType, listServices } from "@typespec/compiler";
|
|
5
|
-
import { Visibility, getHeaderFieldName, getHttpFileModel, getHttpPart, getPathParamName, getQueryParamName, isBody, isStatusCode } from "@typespec/http";
|
|
6
|
-
import { KnownMediaType, hasMediaType, isMediaTypeMultipartFormData } from "./mediaTypes.js";
|
|
7
|
-
import { getDefaultApiVersion, getWireName, isApiVersion } from "@azure-tools/typespec-client-generator-core";
|
|
8
3
|
import { getUnionAsEnum } from "@azure-tools/typespec-azure-core";
|
|
9
|
-
import {
|
|
4
|
+
import { getDefaultApiVersion, getWireName, isApiVersion, } from "@azure-tools/typespec-client-generator-core";
|
|
5
|
+
import { NoTarget, getDiscriminator, getDoc, getEffectiveModelType, getEncode, getFormat, getFriendlyName, getLifecycleVisibilityEnum, getMaxLength, getMaxValue, getMinLength, getMinValue, getPattern, getProperty, getPropertyType, getSummary, getVisibilityForClass, isArrayModelType, isNeverType, isNullType, isNumericType, isRecordModelType, isSecret, isStringType, isTemplateDeclaration, isUnknownType, listServices, } from "@typespec/compiler";
|
|
6
|
+
import { Visibility, getHeaderFieldName, getHttpFileModel, getHttpPart, getPathParamName, getQueryParamName, isBody, isStatusCode, } from "@typespec/http";
|
|
7
|
+
import { NameType, SchemaContext, isArraySchema, normalizeName, } from "../rlc-common/index.js";
|
|
8
|
+
import { KnownMediaType, hasMediaType, isMediaTypeMultipartFormData } from "./mediaTypes.js";
|
|
10
9
|
import { reportDiagnostic } from "../lib.js";
|
|
11
|
-
|
|
10
|
+
import { getModelNamespaceName } from "./namespaceUtils.js";
|
|
11
|
+
export const BINARY_TYPE_UNION = "string | Uint8Array | ReadableStream<Uint8Array> | NodeReadableStream";
|
|
12
12
|
export const BINARY_AND_FILE_TYPE_UNION = `${BINARY_TYPE_UNION} | File`;
|
|
13
13
|
export function getBinaryType(usage) {
|
|
14
|
-
return usage.includes(SchemaContext.Output)
|
|
15
|
-
? "Uint8Array"
|
|
16
|
-
: BINARY_TYPE_UNION;
|
|
14
|
+
return usage.includes(SchemaContext.Output) ? "Uint8Array" : BINARY_TYPE_UNION;
|
|
17
15
|
}
|
|
18
16
|
export function isByteOrByteUnion(dpgContext, type) {
|
|
19
17
|
const schema = getSchemaForType(dpgContext, type);
|
|
20
18
|
return isBytesType(schema) || isBytesUnion(schema);
|
|
21
19
|
}
|
|
22
20
|
function isBytesType(schema) {
|
|
23
|
-
return
|
|
24
|
-
(schema.format === "bytes" || schema.format === "binary"));
|
|
21
|
+
return schema.type === "string" && (schema.format === "bytes" || schema.format === "binary");
|
|
25
22
|
}
|
|
26
23
|
function isBytesUnion(schema) {
|
|
27
24
|
if (!Array.isArray(schema.enum)) {
|
|
@@ -35,10 +32,7 @@ function isBytesUnion(schema) {
|
|
|
35
32
|
return false;
|
|
36
33
|
}
|
|
37
34
|
function refineByteType(schema) {
|
|
38
|
-
schema.typeName = getBinaryType([
|
|
39
|
-
SchemaContext.Input,
|
|
40
|
-
SchemaContext.Exception
|
|
41
|
-
]);
|
|
35
|
+
schema.typeName = getBinaryType([SchemaContext.Input, SchemaContext.Exception]);
|
|
42
36
|
schema.outputTypeName = getBinaryType([SchemaContext.Output]);
|
|
43
37
|
return schema;
|
|
44
38
|
}
|
|
@@ -63,9 +57,8 @@ export function enrichBinaryTypeInBody(schema) {
|
|
|
63
57
|
return schema;
|
|
64
58
|
}
|
|
65
59
|
export function getSchemaForType(dpgContext, typeInput, options) {
|
|
66
|
-
var _a, _b, _c, _d;
|
|
67
60
|
const program = dpgContext.program;
|
|
68
|
-
const { usage } = options
|
|
61
|
+
const { usage } = options ?? {};
|
|
69
62
|
const type = getEffectiveModelFromType(dpgContext, typeInput);
|
|
70
63
|
const builtinType = getSchemaForLiteral(type);
|
|
71
64
|
if (builtinType !== undefined) {
|
|
@@ -90,13 +83,13 @@ export function getSchemaForType(dpgContext, typeInput, options) {
|
|
|
90
83
|
multipartOptions: {
|
|
91
84
|
filenameSchema: {
|
|
92
85
|
required: !fileModel.filename.optional,
|
|
93
|
-
...getSchemaForType(dpgContext, fileModel.filename, options)
|
|
86
|
+
...getSchemaForType(dpgContext, fileModel.filename, options),
|
|
94
87
|
},
|
|
95
88
|
contentTypeSchema: {
|
|
96
89
|
required: !fileModel.contentType.optional,
|
|
97
|
-
...getSchemaForType(dpgContext, fileModel.contentType, options)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
90
|
+
...getSchemaForType(dpgContext, fileModel.contentType, options),
|
|
91
|
+
},
|
|
92
|
+
},
|
|
100
93
|
};
|
|
101
94
|
}
|
|
102
95
|
else {
|
|
@@ -109,13 +102,11 @@ export function getSchemaForType(dpgContext, typeInput, options) {
|
|
|
109
102
|
}
|
|
110
103
|
const schema = getSchemaForModel(dpgContext, type, options);
|
|
111
104
|
if (isAnonymousObjectSchema(schema)) {
|
|
112
|
-
if (Object.keys(
|
|
105
|
+
if (Object.keys(schema.properties ?? {}).length === 0) {
|
|
113
106
|
// Handle empty anonymous model as Record
|
|
114
|
-
schema.typeName =
|
|
115
|
-
schema.type === "object" ? "Record<string, unknown>" : "unknown";
|
|
107
|
+
schema.typeName = schema.type === "object" ? "Record<string, unknown>" : "unknown";
|
|
116
108
|
if (usage && usage.includes(SchemaContext.Output)) {
|
|
117
|
-
schema.outputTypeName =
|
|
118
|
-
schema.type === "object" ? "Record<string, any>" : "any";
|
|
109
|
+
schema.outputTypeName = schema.type === "object" ? "Record<string, any>" : "any";
|
|
119
110
|
}
|
|
120
111
|
schema.type = "unknown";
|
|
121
112
|
}
|
|
@@ -123,13 +114,12 @@ export function getSchemaForType(dpgContext, typeInput, options) {
|
|
|
123
114
|
// Handle non-empty anonymous model as inline model
|
|
124
115
|
if (usage && usage.includes(SchemaContext.Output)) {
|
|
125
116
|
schema.outputTypeName = getModelInlineSigniture(schema, {
|
|
126
|
-
usage: [SchemaContext.Output]
|
|
117
|
+
usage: [SchemaContext.Output],
|
|
127
118
|
});
|
|
128
119
|
}
|
|
129
120
|
schema.typeName = getModelInlineSigniture(schema, {
|
|
130
121
|
usage: [SchemaContext.Input],
|
|
131
|
-
multipart:
|
|
132
|
-
isMediaTypeMultipartFormData((_b = options === null || options === void 0 ? void 0 : options.mediaTypes) !== null && _b !== void 0 ? _b : [])
|
|
122
|
+
multipart: options?.isRequestBody && isMediaTypeMultipartFormData(options?.mediaTypes ?? []),
|
|
133
123
|
});
|
|
134
124
|
schema.type = "object";
|
|
135
125
|
}
|
|
@@ -179,9 +169,9 @@ export function getSchemaForType(dpgContext, typeInput, options) {
|
|
|
179
169
|
code: "invalid-schema",
|
|
180
170
|
format: {
|
|
181
171
|
type: type.kind,
|
|
182
|
-
property:
|
|
172
|
+
property: options?.relevantProperty?.name ?? "",
|
|
183
173
|
},
|
|
184
|
-
target: type
|
|
174
|
+
target: type,
|
|
185
175
|
});
|
|
186
176
|
return undefined;
|
|
187
177
|
}
|
|
@@ -199,12 +189,11 @@ export function getEffectiveModelFromType(context, type) {
|
|
|
199
189
|
return type;
|
|
200
190
|
}
|
|
201
191
|
export function includeDerivedModel(model, needRef = false) {
|
|
202
|
-
var _a;
|
|
203
192
|
return (!needRef &&
|
|
204
193
|
!isTemplateDeclaration(model) &&
|
|
205
194
|
(!model.templateMapper ||
|
|
206
195
|
!model.templateMapper.args ||
|
|
207
|
-
|
|
196
|
+
model.templateMapper.args?.length === 0 ||
|
|
208
197
|
model.derivedModels.length > 0));
|
|
209
198
|
}
|
|
210
199
|
function applyEncoding(dpgContext, typespecType, target = {}) {
|
|
@@ -222,24 +211,23 @@ function applyEncoding(dpgContext, typespecType, target = {}) {
|
|
|
222
211
|
return target;
|
|
223
212
|
}
|
|
224
213
|
function mergeFormatAndEncoding(format, encoding, encodeAsFormat) {
|
|
225
|
-
var _a, _b;
|
|
226
214
|
switch (format) {
|
|
227
215
|
case undefined:
|
|
228
|
-
return
|
|
216
|
+
return encodeAsFormat ?? encoding ?? format;
|
|
229
217
|
case "date-time":
|
|
230
218
|
return encoding;
|
|
231
219
|
case "duration":
|
|
232
220
|
default:
|
|
233
|
-
return
|
|
221
|
+
return encodeAsFormat ?? encoding ?? format;
|
|
234
222
|
}
|
|
235
223
|
}
|
|
236
224
|
function getSchemaForScalar(dpgContext, scalar, options) {
|
|
237
225
|
let result = {};
|
|
238
226
|
const isStd = dpgContext.program.checker.isStdType(scalar);
|
|
239
|
-
const { relevantProperty, isRequestBody, isParentRequestBody, mediaTypes: contentTypes } = options
|
|
227
|
+
const { relevantProperty, isRequestBody, isParentRequestBody, mediaTypes: contentTypes, } = options ?? {};
|
|
240
228
|
if (isStd) {
|
|
241
229
|
result = getSchemaForStdScalar(dpgContext.program, scalar, {
|
|
242
|
-
relevantProperty
|
|
230
|
+
relevantProperty,
|
|
243
231
|
});
|
|
244
232
|
}
|
|
245
233
|
else if (scalar.baseScalar) {
|
|
@@ -259,20 +247,15 @@ function getSchemaForScalar(dpgContext, scalar, options) {
|
|
|
259
247
|
}
|
|
260
248
|
else {
|
|
261
249
|
// for other cases we would trust the @encode decorator if not present we would treat it as string
|
|
262
|
-
const withDecorators = applyEncoding(dpgContext, scalar, result
|
|
263
|
-
|
|
264
|
-
: undefined);
|
|
265
|
-
if (withDecorators.type === "string" &&
|
|
266
|
-
withDecorators.format === "binary") {
|
|
250
|
+
const withDecorators = applyEncoding(dpgContext, scalar, result ? applyIntrinsicDecorators(dpgContext.program, scalar, result) : undefined);
|
|
251
|
+
if (withDecorators.type === "string" && withDecorators.format === "binary") {
|
|
267
252
|
withDecorators.typeName = BINARY_TYPE_UNION;
|
|
268
253
|
withDecorators.outputTypeName = "Uint8Array";
|
|
269
254
|
}
|
|
270
255
|
return withDecorators;
|
|
271
256
|
}
|
|
272
257
|
function isBinaryAsRequestBody() {
|
|
273
|
-
return (hasMediaType(KnownMediaType.Binary, contentTypes) &&
|
|
274
|
-
isRequestBody &&
|
|
275
|
-
isBytesType(result));
|
|
258
|
+
return (hasMediaType(KnownMediaType.Binary, contentTypes) && isRequestBody && isBytesType(result));
|
|
276
259
|
}
|
|
277
260
|
function isFormDataBytesInRequestBody() {
|
|
278
261
|
return (hasMediaType(KnownMediaType.MultipartFormData, contentTypes) &&
|
|
@@ -281,17 +264,16 @@ function getSchemaForScalar(dpgContext, scalar, options) {
|
|
|
281
264
|
}
|
|
282
265
|
}
|
|
283
266
|
function getSchemaForUnion(dpgContext, union, options) {
|
|
284
|
-
var _a, _b;
|
|
285
267
|
const [asEnum, _] = getUnionAsEnum(union);
|
|
286
268
|
const variants = Array.from(union.variants.values());
|
|
287
269
|
const values = [];
|
|
288
270
|
let namedUnionMember = false;
|
|
289
|
-
if (!(
|
|
290
|
-
if (
|
|
271
|
+
if (!(options?.needRef && union.name && !asEnum)) {
|
|
272
|
+
if (asEnum?.open && asEnum.members.size > 0) {
|
|
291
273
|
for (const [_, member] of asEnum.members.entries()) {
|
|
292
274
|
const memberType = getSchemaForType(dpgContext, member.type, {
|
|
293
275
|
...options,
|
|
294
|
-
needRef:
|
|
276
|
+
needRef: options?.needRef ?? false,
|
|
295
277
|
});
|
|
296
278
|
values.push(memberType);
|
|
297
279
|
if (memberType.name) {
|
|
@@ -304,7 +286,7 @@ function getSchemaForUnion(dpgContext, union, options) {
|
|
|
304
286
|
// We already know it's not a model type
|
|
305
287
|
const variantType = getSchemaForType(dpgContext, variant.type, {
|
|
306
288
|
...options,
|
|
307
|
-
needRef: isAnonymousModelType(variant.type) ? false : true
|
|
289
|
+
needRef: isAnonymousModelType(variant.type) ? false : true,
|
|
308
290
|
});
|
|
309
291
|
values.push(variantType);
|
|
310
292
|
if (variantType.typeName) {
|
|
@@ -316,23 +298,17 @@ function getSchemaForUnion(dpgContext, union, options) {
|
|
|
316
298
|
const schema = {};
|
|
317
299
|
if (values.length > 0) {
|
|
318
300
|
schema.enum = values;
|
|
319
|
-
const unionAlias =
|
|
301
|
+
const unionAlias = asEnum?.open && asEnum?.kind && !namedUnionMember
|
|
320
302
|
? asEnum.kind + (asEnum.nullable ? " | null" : "")
|
|
321
|
-
: values
|
|
322
|
-
|
|
323
|
-
.join(" | ");
|
|
324
|
-
const outputUnionAlias = (asEnum === null || asEnum === void 0 ? void 0 : asEnum.open) && (asEnum === null || asEnum === void 0 ? void 0 : asEnum.kind) && !namedUnionMember
|
|
303
|
+
: values.map((item) => `${getTypeName(item, [SchemaContext.Input]) ?? item}`).join(" | ");
|
|
304
|
+
const outputUnionAlias = asEnum?.open && asEnum?.kind && !namedUnionMember
|
|
325
305
|
? asEnum.kind + (asEnum.nullable ? " | null" : "")
|
|
326
|
-
: values
|
|
327
|
-
.map((item) => { var _a; return `${(_a = getTypeName(item, [SchemaContext.Output])) !== null && _a !== void 0 ? _a : item}`; })
|
|
328
|
-
.join(" | ");
|
|
306
|
+
: values.map((item) => `${getTypeName(item, [SchemaContext.Output]) ?? item}`).join(" | ");
|
|
329
307
|
schema.alias = unionAlias;
|
|
330
308
|
schema.outputAlias = outputUnionAlias;
|
|
331
309
|
}
|
|
332
310
|
if (!union.expression) {
|
|
333
|
-
const unionName = union.name
|
|
334
|
-
? normalizeName(union.name, NameType.Interface)
|
|
335
|
-
: undefined;
|
|
311
|
+
const unionName = union.name ? normalizeName(union.name, NameType.Interface) : undefined;
|
|
336
312
|
schema.name = unionName;
|
|
337
313
|
schema.type = "object";
|
|
338
314
|
schema.typeName = unionName;
|
|
@@ -347,10 +323,8 @@ function getSchemaForUnion(dpgContext, union, options) {
|
|
|
347
323
|
}
|
|
348
324
|
else {
|
|
349
325
|
schema.type = "union";
|
|
350
|
-
schema.typeName =
|
|
351
|
-
schema.outputTypeName = union.name
|
|
352
|
-
? union.name + "Output"
|
|
353
|
-
: schema.outputAlias;
|
|
326
|
+
schema.typeName = union.name ?? schema.alias;
|
|
327
|
+
schema.outputTypeName = union.name ? union.name + "Output" : schema.outputAlias;
|
|
354
328
|
delete schema.alias;
|
|
355
329
|
delete schema.outputAlias;
|
|
356
330
|
}
|
|
@@ -385,7 +359,6 @@ function isOasString(type) {
|
|
|
385
359
|
return false;
|
|
386
360
|
}
|
|
387
361
|
function isStringLiteral(type) {
|
|
388
|
-
var _a;
|
|
389
362
|
if (type.kind === "Union") {
|
|
390
363
|
// A union where all variants are an OasString
|
|
391
364
|
for (const variant of type.variants) {
|
|
@@ -396,13 +369,11 @@ function isStringLiteral(type) {
|
|
|
396
369
|
return true;
|
|
397
370
|
}
|
|
398
371
|
return (type.kind === "String" ||
|
|
399
|
-
(type.kind === "EnumMember" &&
|
|
400
|
-
typeof ((_a = type.value) !== null && _a !== void 0 ? _a : type.name) === "string") ||
|
|
372
|
+
(type.kind === "EnumMember" && typeof (type.value ?? type.name) === "string") ||
|
|
401
373
|
(type.kind === "UnionVariant" && type.type.kind === "String"));
|
|
402
374
|
}
|
|
403
375
|
// Return any string literal values for type
|
|
404
376
|
function getStringValues(type) {
|
|
405
|
-
var _a;
|
|
406
377
|
switch (type.kind) {
|
|
407
378
|
case "String":
|
|
408
379
|
return [type.value];
|
|
@@ -411,7 +382,7 @@ function getStringValues(type) {
|
|
|
411
382
|
.flatMap((x) => getStringValues(x.type))
|
|
412
383
|
.filter((x) => x !== undefined);
|
|
413
384
|
case "EnumMember":
|
|
414
|
-
return typeof type.value !== "number" ? [
|
|
385
|
+
return typeof type.value !== "number" ? [type.value ?? type.name] : [];
|
|
415
386
|
case "UnionVariant":
|
|
416
387
|
return getStringValues(type.type);
|
|
417
388
|
default:
|
|
@@ -419,7 +390,6 @@ function getStringValues(type) {
|
|
|
419
390
|
}
|
|
420
391
|
}
|
|
421
392
|
function validateDiscriminator(program, discriminator, derivedModels) {
|
|
422
|
-
var _a;
|
|
423
393
|
const { propertyName } = discriminator;
|
|
424
394
|
const retVals = derivedModels.map((t) => {
|
|
425
395
|
const prop = getProperty(t, propertyName);
|
|
@@ -427,18 +397,16 @@ function validateDiscriminator(program, discriminator, derivedModels) {
|
|
|
427
397
|
reportDiagnostic(program, {
|
|
428
398
|
code: "discriminator",
|
|
429
399
|
messageId: "missing",
|
|
430
|
-
target: t
|
|
400
|
+
target: t,
|
|
431
401
|
});
|
|
432
402
|
return false;
|
|
433
403
|
}
|
|
434
404
|
let retval = true;
|
|
435
|
-
if (!isOasString(prop.type) &&
|
|
436
|
-
prop.type.kind !== "EnumMember" &&
|
|
437
|
-
prop.type.kind !== "Enum") {
|
|
405
|
+
if (!isOasString(prop.type) && prop.type.kind !== "EnumMember" && prop.type.kind !== "Enum") {
|
|
438
406
|
reportDiagnostic(program, {
|
|
439
407
|
code: "discriminator",
|
|
440
408
|
messageId: "type",
|
|
441
|
-
target: prop
|
|
409
|
+
target: prop,
|
|
442
410
|
});
|
|
443
411
|
retval = false;
|
|
444
412
|
}
|
|
@@ -446,7 +414,7 @@ function validateDiscriminator(program, discriminator, derivedModels) {
|
|
|
446
414
|
reportDiagnostic(program, {
|
|
447
415
|
code: "discriminator",
|
|
448
416
|
messageId: "required",
|
|
449
|
-
target: prop
|
|
417
|
+
target: prop,
|
|
450
418
|
});
|
|
451
419
|
retval = false;
|
|
452
420
|
}
|
|
@@ -456,13 +424,13 @@ function validateDiscriminator(program, discriminator, derivedModels) {
|
|
|
456
424
|
const discriminatorValues = new Map();
|
|
457
425
|
for (const t of derivedModels) {
|
|
458
426
|
// Get the discriminator property directly in the child model
|
|
459
|
-
const prop =
|
|
427
|
+
const prop = t.properties?.get(propertyName);
|
|
460
428
|
// Issue warning diagnostic if discriminator property missing or is not a string literal
|
|
461
429
|
if (!prop || !isStringLiteral(prop.type)) {
|
|
462
430
|
reportDiagnostic(program, {
|
|
463
431
|
code: "discriminator-value",
|
|
464
432
|
messageId: "literal",
|
|
465
|
-
target: prop || t
|
|
433
|
+
target: prop || t,
|
|
466
434
|
});
|
|
467
435
|
}
|
|
468
436
|
if (prop) {
|
|
@@ -475,9 +443,9 @@ function validateDiscriminator(program, discriminator, derivedModels) {
|
|
|
475
443
|
format: {
|
|
476
444
|
val: val,
|
|
477
445
|
model1: discriminatorValues.get(val),
|
|
478
|
-
model2: t.name
|
|
446
|
+
model2: t.name,
|
|
479
447
|
},
|
|
480
|
-
target: prop
|
|
448
|
+
target: prop,
|
|
481
449
|
});
|
|
482
450
|
retVals.push(false);
|
|
483
451
|
}
|
|
@@ -490,20 +458,19 @@ function validateDiscriminator(program, discriminator, derivedModels) {
|
|
|
490
458
|
return retVals.every((v) => v);
|
|
491
459
|
}
|
|
492
460
|
function getSchemaForModel(dpgContext, model, options) {
|
|
493
|
-
|
|
494
|
-
const { usage, needRef, isRequestBody, mediaTypes: contentTypes } = options !== null && options !== void 0 ? options : {};
|
|
461
|
+
const { usage, needRef, isRequestBody, mediaTypes: contentTypes } = options ?? {};
|
|
495
462
|
if (isArrayModelType(model)) {
|
|
496
463
|
return getSchemaForArrayModel(dpgContext, model, options);
|
|
497
464
|
}
|
|
498
465
|
const program = dpgContext.program;
|
|
499
|
-
const isMultipartBody = isMediaTypeMultipartFormData(contentTypes
|
|
466
|
+
const isMultipartBody = isMediaTypeMultipartFormData(contentTypes ?? []);
|
|
500
467
|
const isCoreModel = isAzureCoreErrorType(program, model);
|
|
501
468
|
const modelSchema = {
|
|
502
469
|
name: getModelName(dpgContext, model),
|
|
503
470
|
type: "object",
|
|
504
471
|
isMultipartBody,
|
|
505
|
-
description:
|
|
506
|
-
fromCore: isCoreModel
|
|
472
|
+
description: getDoc(program, model) ?? "",
|
|
473
|
+
fromCore: isCoreModel,
|
|
507
474
|
};
|
|
508
475
|
// normalized the output name
|
|
509
476
|
modelSchema.name = normalizeName(modelSchema.name, NameType.Interface, true /** shouldGuard */);
|
|
@@ -524,32 +491,32 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
524
491
|
if (derivedModels.length > 0) {
|
|
525
492
|
modelSchema.children = {
|
|
526
493
|
all: [],
|
|
527
|
-
immediate: []
|
|
494
|
+
immediate: [],
|
|
528
495
|
};
|
|
529
496
|
}
|
|
530
497
|
for (const child of derivedModels) {
|
|
531
498
|
const childSchema = getSchemaForType(dpgContext, child, {
|
|
532
499
|
usage,
|
|
533
|
-
needRef: true
|
|
500
|
+
needRef: true,
|
|
534
501
|
});
|
|
535
502
|
for (const [name, prop] of child.properties) {
|
|
536
|
-
if (name ===
|
|
503
|
+
if (name === discriminator?.propertyName) {
|
|
537
504
|
const propSchema = getSchemaForType(dpgContext, prop.type, {
|
|
538
505
|
usage,
|
|
539
506
|
needRef: !isAnonymousModelType(prop.type),
|
|
540
|
-
relevantProperty: prop
|
|
507
|
+
relevantProperty: prop,
|
|
541
508
|
});
|
|
542
509
|
childSchema.discriminatorValue = propSchema.type.replace(/"/g, "");
|
|
543
510
|
break;
|
|
544
511
|
}
|
|
545
512
|
}
|
|
546
|
-
|
|
547
|
-
|
|
513
|
+
modelSchema.children?.all?.push(childSchema);
|
|
514
|
+
modelSchema.children?.immediate?.push(childSchema);
|
|
548
515
|
}
|
|
549
516
|
// Enable option `isPolyParent` and discriminator only when it has valid children
|
|
550
517
|
if (discriminator &&
|
|
551
|
-
|
|
552
|
-
|
|
518
|
+
modelSchema?.children?.all?.length &&
|
|
519
|
+
modelSchema?.children?.all?.length > 0) {
|
|
553
520
|
if (!validateDiscriminator(program, discriminator, derivedModels)) {
|
|
554
521
|
// appropriate diagnostic is generated in the validate function
|
|
555
522
|
return {};
|
|
@@ -558,7 +525,7 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
558
525
|
modelSchema.discriminator = {
|
|
559
526
|
name: propertyName,
|
|
560
527
|
type: "string",
|
|
561
|
-
description: `Discriminator property for ${model.name}
|
|
528
|
+
description: `Discriminator property for ${model.name}.`,
|
|
562
529
|
};
|
|
563
530
|
modelSchema.discriminatorValue = propertyName;
|
|
564
531
|
modelSchema.isPolyParent = true;
|
|
@@ -570,12 +537,12 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
570
537
|
if (isRecordModelType(model)) {
|
|
571
538
|
modelSchema.parents = {
|
|
572
539
|
all: [getSchemaForRecordModel(dpgContext, model, { usage })],
|
|
573
|
-
immediate: [getSchemaForRecordModel(dpgContext, model, { usage })]
|
|
540
|
+
immediate: [getSchemaForRecordModel(dpgContext, model, { usage })],
|
|
574
541
|
};
|
|
575
542
|
}
|
|
576
543
|
for (const [propName, prop] of model.properties) {
|
|
577
544
|
const restApiName = getWireName(dpgContext, prop);
|
|
578
|
-
const name = `"${restApiName
|
|
545
|
+
const name = `"${restApiName ?? propName}"`;
|
|
579
546
|
if (!isSchemaProperty(program, prop)) {
|
|
580
547
|
continue;
|
|
581
548
|
}
|
|
@@ -585,7 +552,7 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
585
552
|
relevantProperty: prop,
|
|
586
553
|
isParentRequestBody: isRequestBody,
|
|
587
554
|
isRequestBody: false,
|
|
588
|
-
mediaTypes: contentTypes
|
|
555
|
+
mediaTypes: contentTypes,
|
|
589
556
|
});
|
|
590
557
|
if (propSchema === undefined) {
|
|
591
558
|
continue;
|
|
@@ -600,16 +567,14 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
600
567
|
modelSchema.properties[name] = propSchema;
|
|
601
568
|
// if this property is a discriminator property, remove it to keep autorest validation happy
|
|
602
569
|
const { propertyName } = getDiscriminator(program, model) || {};
|
|
603
|
-
if (propertyName &&
|
|
604
|
-
name === `"${propertyName}"` &&
|
|
605
|
-
modelSchema.discriminator) {
|
|
570
|
+
if (propertyName && name === `"${propertyName}"` && modelSchema.discriminator) {
|
|
606
571
|
modelSchema.discriminator = {
|
|
607
572
|
...modelSchema.discriminator,
|
|
608
573
|
...{
|
|
609
|
-
type:
|
|
574
|
+
type: propSchema.typeName ?? propSchema.type,
|
|
610
575
|
typeName: propSchema.typeName,
|
|
611
|
-
outputTypeName: propSchema.outputTypeName
|
|
612
|
-
}
|
|
576
|
+
outputTypeName: propSchema.outputTypeName,
|
|
577
|
+
},
|
|
613
578
|
};
|
|
614
579
|
continue;
|
|
615
580
|
}
|
|
@@ -645,16 +610,16 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
645
610
|
if (modelSchema.parents === undefined) {
|
|
646
611
|
modelSchema.parents = {
|
|
647
612
|
all: [],
|
|
648
|
-
immediate: []
|
|
613
|
+
immediate: [],
|
|
649
614
|
};
|
|
650
615
|
}
|
|
651
|
-
|
|
616
|
+
modelSchema.parents.all?.push(getSchemaForType(dpgContext, model.baseModel, {
|
|
652
617
|
usage,
|
|
653
|
-
needRef: true
|
|
618
|
+
needRef: true,
|
|
654
619
|
}));
|
|
655
|
-
|
|
620
|
+
modelSchema.parents.immediate?.push(getSchemaForType(dpgContext, model.baseModel, {
|
|
656
621
|
usage,
|
|
657
|
-
needRef: true
|
|
622
|
+
needRef: true,
|
|
658
623
|
}));
|
|
659
624
|
}
|
|
660
625
|
return modelSchema;
|
|
@@ -664,24 +629,19 @@ function getSdkVisibility(program, type) {
|
|
|
664
629
|
const visibility = getVisibilityForClass(program, type, lifecycle);
|
|
665
630
|
if (visibility) {
|
|
666
631
|
const result = [];
|
|
667
|
-
if (lifecycle.members.get("Read") &&
|
|
668
|
-
visibility.has(lifecycle.members.get("Read"))) {
|
|
632
|
+
if (lifecycle.members.get("Read") && visibility.has(lifecycle.members.get("Read"))) {
|
|
669
633
|
result.push(Visibility.Read);
|
|
670
634
|
}
|
|
671
|
-
if (lifecycle.members.get("Create") &&
|
|
672
|
-
visibility.has(lifecycle.members.get("Create"))) {
|
|
635
|
+
if (lifecycle.members.get("Create") && visibility.has(lifecycle.members.get("Create"))) {
|
|
673
636
|
result.push(Visibility.Create);
|
|
674
637
|
}
|
|
675
|
-
if (lifecycle.members.get("Update") &&
|
|
676
|
-
visibility.has(lifecycle.members.get("Update"))) {
|
|
638
|
+
if (lifecycle.members.get("Update") && visibility.has(lifecycle.members.get("Update"))) {
|
|
677
639
|
result.push(Visibility.Update);
|
|
678
640
|
}
|
|
679
|
-
if (lifecycle.members.get("Delete") &&
|
|
680
|
-
visibility.has(lifecycle.members.get("Delete"))) {
|
|
641
|
+
if (lifecycle.members.get("Delete") && visibility.has(lifecycle.members.get("Delete"))) {
|
|
681
642
|
result.push(Visibility.Delete);
|
|
682
643
|
}
|
|
683
|
-
if (lifecycle.members.get("Query") &&
|
|
684
|
-
visibility.has(lifecycle.members.get("Query"))) {
|
|
644
|
+
if (lifecycle.members.get("Query") && visibility.has(lifecycle.members.get("Query"))) {
|
|
685
645
|
result.push(Visibility.Query);
|
|
686
646
|
}
|
|
687
647
|
return result;
|
|
@@ -692,7 +652,6 @@ function getSdkVisibility(program, type) {
|
|
|
692
652
|
* Return the model name for a given model
|
|
693
653
|
*/
|
|
694
654
|
function getModelName(dpgContext, model) {
|
|
695
|
-
var _a, _b;
|
|
696
655
|
const { program } = dpgContext;
|
|
697
656
|
// 1. check if this is an anonymous model
|
|
698
657
|
if (model.name === "") {
|
|
@@ -710,22 +669,21 @@ function getModelName(dpgContext, model) {
|
|
|
710
669
|
}
|
|
711
670
|
// 4. check if this is a model with template arguments
|
|
712
671
|
let name = model.name;
|
|
713
|
-
if (
|
|
672
|
+
if (model.templateMapper?.args) {
|
|
714
673
|
// const isPage = getPagedResult(program, model);
|
|
715
674
|
const templateTypeNames = model.templateMapper.args
|
|
716
675
|
.map((arg) => (arg.entityKind === "Indeterminate" ? arg.type : arg))
|
|
717
676
|
.map((arg) => {
|
|
718
|
-
var _a, _b;
|
|
719
677
|
switch (arg.kind) {
|
|
720
678
|
case "Model":
|
|
721
679
|
case "Enum":
|
|
722
680
|
case "Union":
|
|
723
681
|
case "Scalar":
|
|
724
|
-
return
|
|
682
|
+
return arg.name ?? "";
|
|
725
683
|
case "String":
|
|
726
684
|
case "Boolean":
|
|
727
685
|
case "Number":
|
|
728
|
-
return
|
|
686
|
+
return arg.value ?? "";
|
|
729
687
|
default:
|
|
730
688
|
return "";
|
|
731
689
|
}
|
|
@@ -746,9 +704,7 @@ function getModelName(dpgContext, model) {
|
|
|
746
704
|
fullNamespacePrefix = "";
|
|
747
705
|
}
|
|
748
706
|
// 5. check if this model should be namespaced
|
|
749
|
-
return
|
|
750
|
-
? `${fullNamespacePrefix}${name}`
|
|
751
|
-
: name;
|
|
707
|
+
return dpgContext.rlcOptions?.enableModelNamespace ? `${fullNamespacePrefix}${name}` : name;
|
|
752
708
|
}
|
|
753
709
|
// Map an typespec type to an OA schema. Returns undefined when the resulting
|
|
754
710
|
// OA schema is just a regular object schema.
|
|
@@ -776,7 +732,7 @@ function applyIntrinsicDecorators(program, type, target) {
|
|
|
776
732
|
const docStr = getDoc(program, type);
|
|
777
733
|
const isString = isStringType(program, getPropertyType(type));
|
|
778
734
|
const isNumeric = isNumericType(program, getPropertyType(type));
|
|
779
|
-
if (isString && !
|
|
735
|
+
if (isString && !target?.documentation && docStr) {
|
|
780
736
|
newTarget.description = docStr;
|
|
781
737
|
}
|
|
782
738
|
const summaryStr = getSummary(program, type);
|
|
@@ -814,8 +770,7 @@ function applyIntrinsicDecorators(program, type, target) {
|
|
|
814
770
|
return newTarget;
|
|
815
771
|
}
|
|
816
772
|
function getSchemaForEnumMember(program, e) {
|
|
817
|
-
|
|
818
|
-
const value = (_a = e.value) !== null && _a !== void 0 ? _a : e.name;
|
|
773
|
+
const value = e.value ?? e.name;
|
|
819
774
|
const type = enumMemberType(e) === "string" ? `"${value}"` : `${value}`;
|
|
820
775
|
return { type, description: getDoc(program, e), isConstant: true };
|
|
821
776
|
}
|
|
@@ -830,7 +785,7 @@ function getSchemaForEnum(dpgContext, e) {
|
|
|
830
785
|
if (type !== enumMemberType(option)) {
|
|
831
786
|
reportDiagnostic(dpgContext.program, {
|
|
832
787
|
code: "union-unsupported",
|
|
833
|
-
target: e
|
|
788
|
+
target: e,
|
|
834
789
|
});
|
|
835
790
|
continue;
|
|
836
791
|
}
|
|
@@ -842,12 +797,12 @@ function getSchemaForEnum(dpgContext, e) {
|
|
|
842
797
|
typeName: normalizeName(e.name, NameType.Interface),
|
|
843
798
|
outputTypeName: normalizeName(e.name, NameType.Interface) + "Output",
|
|
844
799
|
description: getDoc(dpgContext.program, e),
|
|
845
|
-
memberType: type
|
|
800
|
+
memberType: type,
|
|
846
801
|
};
|
|
847
802
|
if (values.length > 0) {
|
|
848
803
|
schema.enum = values;
|
|
849
804
|
const unionAlias = values
|
|
850
|
-
.map((item) =>
|
|
805
|
+
.map((item) => `${getTypeName(item, [SchemaContext.Input]) ?? item}`)
|
|
851
806
|
.join(" | ");
|
|
852
807
|
schema.alias = unionAlias;
|
|
853
808
|
schema.outputAlias = unionAlias;
|
|
@@ -865,10 +820,9 @@ function enumMemberType(member) {
|
|
|
865
820
|
* Map TypeSpec intrinsic models to open api definitions
|
|
866
821
|
*/
|
|
867
822
|
function getSchemaForArrayModel(dpgContext, type, options) {
|
|
868
|
-
var _a, _b, _c;
|
|
869
823
|
const { program } = dpgContext;
|
|
870
824
|
const { indexer } = type;
|
|
871
|
-
const { usage, isParentRequestBody, mediaTypes: contentTypes } = options
|
|
825
|
+
const { usage, isParentRequestBody, mediaTypes: contentTypes } = options ?? {};
|
|
872
826
|
let schema = {};
|
|
873
827
|
if (!indexer) {
|
|
874
828
|
return schema;
|
|
@@ -884,13 +838,13 @@ function getSchemaForArrayModel(dpgContext, type, options) {
|
|
|
884
838
|
isParentRequestBody: hasMediaType(KnownMediaType.MultipartFormData, contentTypes)
|
|
885
839
|
? isParentRequestBody
|
|
886
840
|
: false,
|
|
887
|
-
needRef: !isAnonymousModelType(indexer.value)
|
|
841
|
+
needRef: !isAnonymousModelType(indexer.value),
|
|
888
842
|
}),
|
|
889
|
-
description: getDoc(program, type)
|
|
843
|
+
description: getDoc(program, type),
|
|
890
844
|
};
|
|
891
845
|
if (!program.checker.isStdType(indexer.value) &&
|
|
892
846
|
!isUnknownType(indexer.value) &&
|
|
893
|
-
|
|
847
|
+
indexer.value?.kind &&
|
|
894
848
|
schema.items.name &&
|
|
895
849
|
!schema.items.enum) {
|
|
896
850
|
schema.typeName = `Array<${schema.items.name}>`;
|
|
@@ -932,9 +886,7 @@ function getSchemaForArrayModel(dpgContext, type, options) {
|
|
|
932
886
|
return `${typeName}[]`;
|
|
933
887
|
})
|
|
934
888
|
.join(" | ");
|
|
935
|
-
if (schema.items.outputTypeName &&
|
|
936
|
-
usage &&
|
|
937
|
-
usage.includes(SchemaContext.Output)) {
|
|
889
|
+
if (schema.items.outputTypeName && usage && usage.includes(SchemaContext.Output)) {
|
|
938
890
|
schema.outputTypeName = schema.items.outputTypeName
|
|
939
891
|
.split("|")
|
|
940
892
|
.map((typeName) => {
|
|
@@ -944,7 +896,7 @@ function getSchemaForArrayModel(dpgContext, type, options) {
|
|
|
944
896
|
}
|
|
945
897
|
}
|
|
946
898
|
}
|
|
947
|
-
else if (
|
|
899
|
+
else if (schema.items?.type?.includes("|")) {
|
|
948
900
|
schema.typeName = `(${schema.items.type})[]`;
|
|
949
901
|
}
|
|
950
902
|
else {
|
|
@@ -956,23 +908,22 @@ function getSchemaForArrayModel(dpgContext, type, options) {
|
|
|
956
908
|
}
|
|
957
909
|
}
|
|
958
910
|
function getSchemaForRecordModel(dpgContext, type, options) {
|
|
959
|
-
var _a, _b;
|
|
960
911
|
const { program } = dpgContext;
|
|
961
912
|
const { indexer } = type;
|
|
962
|
-
const { usage } = options
|
|
913
|
+
const { usage } = options ?? {};
|
|
963
914
|
let schema = {};
|
|
964
915
|
if (!indexer) {
|
|
965
916
|
return schema;
|
|
966
917
|
}
|
|
967
918
|
if (isRecordModelType(type)) {
|
|
968
|
-
const valueType = getSchemaForType(dpgContext, indexer
|
|
919
|
+
const valueType = getSchemaForType(dpgContext, indexer?.value, {
|
|
969
920
|
usage,
|
|
970
|
-
needRef: !isAnonymousModelType(indexer.value)
|
|
921
|
+
needRef: !isAnonymousModelType(indexer.value),
|
|
971
922
|
});
|
|
972
923
|
schema = {
|
|
973
924
|
type: "dictionary",
|
|
974
925
|
additionalProperties: valueType,
|
|
975
|
-
description: getDoc(program, type)
|
|
926
|
+
description: getDoc(program, type),
|
|
976
927
|
};
|
|
977
928
|
if (!program.checker.isStdType(indexer.value) &&
|
|
978
929
|
!isUnknownType(indexer.value) &&
|
|
@@ -985,18 +936,14 @@ function getSchemaForRecordModel(dpgContext, type, options) {
|
|
|
985
936
|
}
|
|
986
937
|
}
|
|
987
938
|
else if (isUnknownType(indexer.value)) {
|
|
988
|
-
schema.typeName = `Record<string, ${
|
|
939
|
+
schema.typeName = `Record<string, ${valueType.typeName ?? valueType.type}>`;
|
|
989
940
|
if (usage && usage.includes(SchemaContext.Output)) {
|
|
990
|
-
schema.outputTypeName = `Record<string, ${
|
|
941
|
+
schema.outputTypeName = `Record<string, ${valueType.outputTypeName ?? valueType.type}>`;
|
|
991
942
|
}
|
|
992
943
|
}
|
|
993
944
|
else {
|
|
994
|
-
schema.typeName = `Record<string, ${getTypeName(valueType, [
|
|
995
|
-
|
|
996
|
-
])}>`;
|
|
997
|
-
schema.outputTypeName = `Record<string, ${getTypeName(valueType, [
|
|
998
|
-
SchemaContext.Output
|
|
999
|
-
])}>`;
|
|
945
|
+
schema.typeName = `Record<string, ${getTypeName(valueType, [SchemaContext.Input])}>`;
|
|
946
|
+
schema.outputTypeName = `Record<string, ${getTypeName(valueType, [SchemaContext.Output])}>`;
|
|
1000
947
|
}
|
|
1001
948
|
schema.usage = usage;
|
|
1002
949
|
return schema;
|
|
@@ -1006,16 +953,14 @@ function isUnionType(type) {
|
|
|
1006
953
|
return type.kind === "Union";
|
|
1007
954
|
}
|
|
1008
955
|
export function isObjectOrDictType(schema) {
|
|
1009
|
-
return ((schema.type === "object" &&
|
|
1010
|
-
schema.properties !== undefined) ||
|
|
956
|
+
return ((schema.type === "object" && schema.properties !== undefined) ||
|
|
1011
957
|
schema.type === "dictionary");
|
|
1012
958
|
}
|
|
1013
959
|
export function isArrayType(schema) {
|
|
1014
960
|
return schema.type === "array";
|
|
1015
961
|
}
|
|
1016
962
|
function getSchemaForStdScalar(program, type, options) {
|
|
1017
|
-
|
|
1018
|
-
const { relevantProperty } = options !== null && options !== void 0 ? options : {};
|
|
963
|
+
const { relevantProperty } = options ?? {};
|
|
1019
964
|
if (!program.checker.isStdType(type)) {
|
|
1020
965
|
return undefined;
|
|
1021
966
|
}
|
|
@@ -1039,97 +984,97 @@ function getSchemaForStdScalar(program, type, options) {
|
|
|
1039
984
|
return { type: "string", format: "bytes", description };
|
|
1040
985
|
case "integer":
|
|
1041
986
|
return applyIntrinsicDecorators(program, type, {
|
|
1042
|
-
type: "number"
|
|
987
|
+
type: "number",
|
|
1043
988
|
});
|
|
1044
989
|
case "int8":
|
|
1045
990
|
return applyIntrinsicDecorators(program, type, {
|
|
1046
991
|
type: "number",
|
|
1047
|
-
format: "int8"
|
|
992
|
+
format: "int8",
|
|
1048
993
|
});
|
|
1049
994
|
case "int16":
|
|
1050
995
|
return applyIntrinsicDecorators(program, type, {
|
|
1051
996
|
type: "number",
|
|
1052
|
-
format: "int16"
|
|
997
|
+
format: "int16",
|
|
1053
998
|
});
|
|
1054
999
|
case "int32":
|
|
1055
1000
|
return applyIntrinsicDecorators(program, type, {
|
|
1056
1001
|
type: "number",
|
|
1057
|
-
format: "int32"
|
|
1002
|
+
format: "int32",
|
|
1058
1003
|
});
|
|
1059
1004
|
case "int64":
|
|
1060
1005
|
return applyIntrinsicDecorators(program, type, {
|
|
1061
1006
|
type: "number",
|
|
1062
|
-
format: "int64"
|
|
1007
|
+
format: "int64",
|
|
1063
1008
|
});
|
|
1064
1009
|
case "safeint":
|
|
1065
1010
|
return applyIntrinsicDecorators(program, type, {
|
|
1066
1011
|
type: "number",
|
|
1067
|
-
format: "safeint"
|
|
1012
|
+
format: "safeint",
|
|
1068
1013
|
});
|
|
1069
1014
|
case "numeric":
|
|
1070
1015
|
return applyIntrinsicDecorators(program, type, {
|
|
1071
|
-
type: "number"
|
|
1016
|
+
type: "number",
|
|
1072
1017
|
});
|
|
1073
1018
|
case "uint8":
|
|
1074
1019
|
return applyIntrinsicDecorators(program, type, {
|
|
1075
1020
|
type: "number",
|
|
1076
|
-
format: "uint8"
|
|
1021
|
+
format: "uint8",
|
|
1077
1022
|
});
|
|
1078
1023
|
case "uint16":
|
|
1079
1024
|
return applyIntrinsicDecorators(program, type, {
|
|
1080
1025
|
type: "number",
|
|
1081
|
-
format: "uint16"
|
|
1026
|
+
format: "uint16",
|
|
1082
1027
|
});
|
|
1083
1028
|
case "uint32":
|
|
1084
1029
|
return applyIntrinsicDecorators(program, type, {
|
|
1085
1030
|
type: "number",
|
|
1086
|
-
format: "uint32"
|
|
1031
|
+
format: "uint32",
|
|
1087
1032
|
});
|
|
1088
1033
|
case "uint64":
|
|
1089
1034
|
return applyIntrinsicDecorators(program, type, {
|
|
1090
1035
|
type: "number",
|
|
1091
|
-
format: "uint64"
|
|
1036
|
+
format: "uint64",
|
|
1092
1037
|
});
|
|
1093
1038
|
case "float64":
|
|
1094
1039
|
return applyIntrinsicDecorators(program, type, {
|
|
1095
1040
|
type: "number",
|
|
1096
|
-
format: "float64"
|
|
1041
|
+
format: "float64",
|
|
1097
1042
|
});
|
|
1098
1043
|
case "float32":
|
|
1099
1044
|
return applyIntrinsicDecorators(program, type, {
|
|
1100
1045
|
type: "number",
|
|
1101
|
-
format: "float32"
|
|
1046
|
+
format: "float32",
|
|
1102
1047
|
});
|
|
1103
1048
|
case "float":
|
|
1104
1049
|
return applyIntrinsicDecorators(program, type, {
|
|
1105
1050
|
type: "number",
|
|
1106
|
-
format: "float"
|
|
1051
|
+
format: "float",
|
|
1107
1052
|
});
|
|
1108
1053
|
case "decimal":
|
|
1109
1054
|
reportDiagnostic(program, {
|
|
1110
1055
|
code: "decimal-to-number",
|
|
1111
1056
|
format: {
|
|
1112
|
-
propertyName:
|
|
1057
|
+
propertyName: relevantProperty?.name ?? "",
|
|
1113
1058
|
},
|
|
1114
|
-
target: relevantProperty
|
|
1059
|
+
target: relevantProperty ?? NoTarget,
|
|
1115
1060
|
});
|
|
1116
1061
|
return applyIntrinsicDecorators(program, type, {
|
|
1117
1062
|
type: "number",
|
|
1118
1063
|
format: "decimal",
|
|
1119
|
-
description: "decimal"
|
|
1064
|
+
description: "decimal",
|
|
1120
1065
|
});
|
|
1121
1066
|
case "decimal128":
|
|
1122
1067
|
reportDiagnostic(program, {
|
|
1123
1068
|
code: "decimal-to-number",
|
|
1124
1069
|
format: {
|
|
1125
|
-
propertyName:
|
|
1070
|
+
propertyName: relevantProperty?.name ?? "",
|
|
1126
1071
|
},
|
|
1127
|
-
target: relevantProperty
|
|
1072
|
+
target: relevantProperty ?? NoTarget,
|
|
1128
1073
|
});
|
|
1129
1074
|
return applyIntrinsicDecorators(program, type, {
|
|
1130
1075
|
type: "number",
|
|
1131
1076
|
format: "decimal128",
|
|
1132
|
-
description: "decimal128"
|
|
1077
|
+
description: "decimal128",
|
|
1133
1078
|
});
|
|
1134
1079
|
case "string":
|
|
1135
1080
|
if (format === "binary") {
|
|
@@ -1138,11 +1083,11 @@ function getSchemaForStdScalar(program, type, options) {
|
|
|
1138
1083
|
format: "binary",
|
|
1139
1084
|
description,
|
|
1140
1085
|
typeName: BINARY_TYPE_UNION,
|
|
1141
|
-
outputTypeName: "Uint8Array"
|
|
1086
|
+
outputTypeName: "Uint8Array",
|
|
1142
1087
|
};
|
|
1143
1088
|
}
|
|
1144
1089
|
return applyIntrinsicDecorators(program, type, {
|
|
1145
|
-
type: "string"
|
|
1090
|
+
type: "string",
|
|
1146
1091
|
});
|
|
1147
1092
|
case "boolean":
|
|
1148
1093
|
return { type: "boolean", description };
|
|
@@ -1152,7 +1097,7 @@ function getSchemaForStdScalar(program, type, options) {
|
|
|
1152
1097
|
format,
|
|
1153
1098
|
description,
|
|
1154
1099
|
typeName: "string",
|
|
1155
|
-
outputTypeName: "string"
|
|
1100
|
+
outputTypeName: "string",
|
|
1156
1101
|
};
|
|
1157
1102
|
case "utcDateTime":
|
|
1158
1103
|
return {
|
|
@@ -1160,7 +1105,7 @@ function getSchemaForStdScalar(program, type, options) {
|
|
|
1160
1105
|
format,
|
|
1161
1106
|
description,
|
|
1162
1107
|
typeName: "Date | string",
|
|
1163
|
-
outputTypeName: "string"
|
|
1108
|
+
outputTypeName: "string",
|
|
1164
1109
|
};
|
|
1165
1110
|
case "offsetDateTime":
|
|
1166
1111
|
return {
|
|
@@ -1168,7 +1113,7 @@ function getSchemaForStdScalar(program, type, options) {
|
|
|
1168
1113
|
format: "date-time",
|
|
1169
1114
|
description,
|
|
1170
1115
|
typeName: "string",
|
|
1171
|
-
outputTypeName: "string"
|
|
1116
|
+
outputTypeName: "string",
|
|
1172
1117
|
};
|
|
1173
1118
|
case "plainTime":
|
|
1174
1119
|
return {
|
|
@@ -1176,7 +1121,7 @@ function getSchemaForStdScalar(program, type, options) {
|
|
|
1176
1121
|
format: "time",
|
|
1177
1122
|
description,
|
|
1178
1123
|
typeName: "string",
|
|
1179
|
-
outputTypeName: "string"
|
|
1124
|
+
outputTypeName: "string",
|
|
1180
1125
|
};
|
|
1181
1126
|
case "duration":
|
|
1182
1127
|
return { type: "string", format, description };
|
|
@@ -1188,25 +1133,17 @@ function isEncodeTypeEffective(type, encodeData) {
|
|
|
1188
1133
|
if (!encodeData) {
|
|
1189
1134
|
return false;
|
|
1190
1135
|
}
|
|
1191
|
-
const datetimeTypes = [
|
|
1192
|
-
|
|
1193
|
-
"utcdatetime",
|
|
1194
|
-
"offsetdatetime",
|
|
1195
|
-
"plaintime"
|
|
1196
|
-
];
|
|
1197
|
-
if (datetimeTypes.includes(type.name.toLowerCase()) &&
|
|
1198
|
-
encodeData.type.name === "string") {
|
|
1136
|
+
const datetimeTypes = ["plaindate", "utcdatetime", "offsetdatetime", "plaintime"];
|
|
1137
|
+
if (datetimeTypes.includes(type.name.toLowerCase()) && encodeData.type.name === "string") {
|
|
1199
1138
|
return false;
|
|
1200
1139
|
}
|
|
1201
1140
|
return true;
|
|
1202
1141
|
}
|
|
1203
1142
|
export function getTypeName(schema, usage) {
|
|
1204
|
-
var _a, _b;
|
|
1205
1143
|
// TODO: Handle more cases
|
|
1206
|
-
return
|
|
1144
|
+
return getPriorityName(schema, usage) ?? schema.type ?? "any";
|
|
1207
1145
|
}
|
|
1208
1146
|
export function getImportedModelName(schema, usage) {
|
|
1209
|
-
var _a, _b;
|
|
1210
1147
|
switch (schema.type) {
|
|
1211
1148
|
case "array": {
|
|
1212
1149
|
const ret = new Set();
|
|
@@ -1218,7 +1155,7 @@ export function getImportedModelName(schema, usage) {
|
|
|
1218
1155
|
case "object": {
|
|
1219
1156
|
if (isAnonymousObjectSchema(schema)) {
|
|
1220
1157
|
const ret = new Set();
|
|
1221
|
-
const properties =
|
|
1158
|
+
const properties = schema.properties ?? {};
|
|
1222
1159
|
for (const name in properties) {
|
|
1223
1160
|
if (!properties[name]) {
|
|
1224
1161
|
continue;
|
|
@@ -1227,9 +1164,7 @@ export function getImportedModelName(schema, usage) {
|
|
|
1227
1164
|
}
|
|
1228
1165
|
return [...ret];
|
|
1229
1166
|
}
|
|
1230
|
-
return getPriorityName(schema, usage)
|
|
1231
|
-
? [getPriorityName(schema, usage)]
|
|
1232
|
-
: [];
|
|
1167
|
+
return getPriorityName(schema, usage) ? [getPriorityName(schema, usage)] : [];
|
|
1233
1168
|
}
|
|
1234
1169
|
case "dictionary": {
|
|
1235
1170
|
const ret = new Set();
|
|
@@ -1240,7 +1175,7 @@ export function getImportedModelName(schema, usage) {
|
|
|
1240
1175
|
}
|
|
1241
1176
|
case "union": {
|
|
1242
1177
|
const ret = new Set();
|
|
1243
|
-
(
|
|
1178
|
+
(schema.enum ?? [])
|
|
1244
1179
|
.filter((i) => !!i)
|
|
1245
1180
|
.forEach((i) => getImportedModelName(i, usage).forEach((it) => ret.add(it)));
|
|
1246
1181
|
return [...ret];
|
|
@@ -1250,12 +1185,9 @@ export function getImportedModelName(schema, usage) {
|
|
|
1250
1185
|
}
|
|
1251
1186
|
}
|
|
1252
1187
|
function getPriorityName(schema, usage) {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
!usage.includes(SchemaContext.Output)
|
|
1257
|
-
? ((_a = schema.typeName) !== null && _a !== void 0 ? _a : schema.name)
|
|
1258
|
-
: ((_c = (_b = schema.outputTypeName) !== null && _b !== void 0 ? _b : schema.typeName) !== null && _c !== void 0 ? _c : schema.name);
|
|
1188
|
+
return usage && usage.includes(SchemaContext.Input) && !usage.includes(SchemaContext.Output)
|
|
1189
|
+
? (schema.typeName ?? schema.name)
|
|
1190
|
+
: (schema.outputTypeName ?? schema.typeName ?? schema.name);
|
|
1259
1191
|
}
|
|
1260
1192
|
function getEnumStringDescription(type) {
|
|
1261
1193
|
if ((type.name === "string" ||
|
|
@@ -1275,15 +1207,13 @@ function getEnumStringDescription(type) {
|
|
|
1275
1207
|
return undefined;
|
|
1276
1208
|
}
|
|
1277
1209
|
function getBinaryDescription(type) {
|
|
1278
|
-
|
|
1279
|
-
if ((_a = type === null || type === void 0 ? void 0 : type.typeName) === null || _a === void 0 ? void 0 : _a.includes(BINARY_TYPE_UNION)) {
|
|
1210
|
+
if (type?.typeName?.includes(BINARY_TYPE_UNION)) {
|
|
1280
1211
|
return `Value may contain any sequence of octets`;
|
|
1281
1212
|
}
|
|
1282
1213
|
return undefined;
|
|
1283
1214
|
}
|
|
1284
1215
|
function getDecimalDescription(type) {
|
|
1285
|
-
if ((type.format === "decimal" || type.format === "decimal128") &&
|
|
1286
|
-
type.type === "number") {
|
|
1216
|
+
if ((type.format === "decimal" || type.format === "decimal128") && type.type === "number") {
|
|
1287
1217
|
return `NOTE: This property is represented as a 'number' in JavaScript, but it corresponds to a 'decimal' type in other languages.
|
|
1288
1218
|
Due to the inherent limitations of floating-point arithmetic in JavaScript, precision issues may arise when performing arithmetic operations.
|
|
1289
1219
|
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.
|
|
@@ -1294,21 +1224,20 @@ Always be cautious with direct arithmetic operations and consider implementing a
|
|
|
1294
1224
|
return undefined;
|
|
1295
1225
|
}
|
|
1296
1226
|
export function getFormattedPropertyDoc(program, type, schemaType, sperator = "\n\n") {
|
|
1297
|
-
var _a, _b;
|
|
1298
1227
|
const propertyDoc = getDoc(program, type);
|
|
1299
|
-
const enhancedDocFromType =
|
|
1228
|
+
const enhancedDocFromType = getEnumStringDescription(schemaType) ??
|
|
1229
|
+
getDecimalDescription(schemaType) ??
|
|
1230
|
+
getBinaryDescription(schemaType);
|
|
1300
1231
|
if (propertyDoc && enhancedDocFromType) {
|
|
1301
1232
|
return `${propertyDoc}${sperator}${enhancedDocFromType}`;
|
|
1302
1233
|
}
|
|
1303
|
-
return propertyDoc
|
|
1234
|
+
return propertyDoc ?? enhancedDocFromType;
|
|
1304
1235
|
}
|
|
1305
1236
|
export function getBodyType(route) {
|
|
1306
|
-
|
|
1307
|
-
const bodyModel = (_a = route.parameters.body) === null || _a === void 0 ? void 0 : _a.type;
|
|
1237
|
+
const bodyModel = route.parameters.body?.type;
|
|
1308
1238
|
return bodyModel;
|
|
1309
1239
|
}
|
|
1310
1240
|
export function getValueTypeValue(value) {
|
|
1311
|
-
var _a;
|
|
1312
1241
|
switch (value.valueKind) {
|
|
1313
1242
|
case "ArrayValue":
|
|
1314
1243
|
return value.values.map((x) => getValueTypeValue(x));
|
|
@@ -1319,11 +1248,11 @@ export function getValueTypeValue(value) {
|
|
|
1319
1248
|
case "NumericValue":
|
|
1320
1249
|
return value.value.asNumber();
|
|
1321
1250
|
case "EnumValue":
|
|
1322
|
-
return
|
|
1251
|
+
return value.value.value ?? value.value.name;
|
|
1323
1252
|
case "ObjectValue":
|
|
1324
1253
|
return Object.fromEntries([...value.properties.keys()].map((x) => [
|
|
1325
1254
|
x,
|
|
1326
|
-
getValueTypeValue(value.properties.get(x).value)
|
|
1255
|
+
getValueTypeValue(value.properties.get(x).value),
|
|
1327
1256
|
]));
|
|
1328
1257
|
default:
|
|
1329
1258
|
// TODO: handle scalar value
|
|
@@ -1340,28 +1269,25 @@ export function getValueTypeValue(value) {
|
|
|
1340
1269
|
* @returns
|
|
1341
1270
|
*/
|
|
1342
1271
|
export function predictDefaultValue(dpgContext, param) {
|
|
1343
|
-
var _a, _b;
|
|
1344
1272
|
if (!param) {
|
|
1345
1273
|
return;
|
|
1346
1274
|
}
|
|
1347
1275
|
const program = dpgContext.program;
|
|
1348
|
-
const specificDefault = param.defaultValue
|
|
1349
|
-
? getValueTypeValue(param.defaultValue)
|
|
1350
|
-
: undefined;
|
|
1276
|
+
const specificDefault = param.defaultValue ? getValueTypeValue(param.defaultValue) : undefined;
|
|
1351
1277
|
if (specificDefault) {
|
|
1352
1278
|
if (typeof specificDefault === "object") {
|
|
1353
1279
|
reportDiagnostic(program, {
|
|
1354
1280
|
code: "default-value-object",
|
|
1355
1281
|
format: {
|
|
1356
|
-
propertyName: param.name
|
|
1282
|
+
propertyName: param.name,
|
|
1357
1283
|
},
|
|
1358
|
-
target: param
|
|
1284
|
+
target: param,
|
|
1359
1285
|
});
|
|
1360
1286
|
return specificDefault.toString();
|
|
1361
1287
|
}
|
|
1362
1288
|
return specificDefault;
|
|
1363
1289
|
}
|
|
1364
|
-
const serviceNamespace =
|
|
1290
|
+
const serviceNamespace = getDefaultService(program, dpgContext.rlcOptions?.isModularLibrary)?.type;
|
|
1365
1291
|
if (!serviceNamespace) {
|
|
1366
1292
|
return;
|
|
1367
1293
|
}
|
|
@@ -1376,13 +1302,13 @@ export function getDefaultService(program, isModularLibrary = true) {
|
|
|
1376
1302
|
if (!services || services.length === 0) {
|
|
1377
1303
|
reportDiagnostic(program, {
|
|
1378
1304
|
code: "no-service-defined",
|
|
1379
|
-
target: NoTarget
|
|
1305
|
+
target: NoTarget,
|
|
1380
1306
|
});
|
|
1381
1307
|
}
|
|
1382
1308
|
if (services.length > 1 && !isModularLibrary) {
|
|
1383
1309
|
reportDiagnostic(program, {
|
|
1384
1310
|
code: "more-than-one-service",
|
|
1385
|
-
target: NoTarget
|
|
1311
|
+
target: NoTarget,
|
|
1386
1312
|
});
|
|
1387
1313
|
}
|
|
1388
1314
|
return services[0];
|
|
@@ -1391,11 +1317,10 @@ export function getDefaultService(program, isModularLibrary = true) {
|
|
|
1391
1317
|
* Return the default api version from the program; undefined if no default
|
|
1392
1318
|
*/
|
|
1393
1319
|
export function getDefaultApiVersionString(dpgContext) {
|
|
1394
|
-
var _a, _b;
|
|
1395
1320
|
const program = dpgContext.program;
|
|
1396
|
-
const isModularLibrary =
|
|
1321
|
+
const isModularLibrary = dpgContext.rlcOptions?.isModularLibrary;
|
|
1397
1322
|
return getDefaultService(program, isModularLibrary)
|
|
1398
|
-
?
|
|
1323
|
+
? getDefaultApiVersion(dpgContext, getDefaultService(program, isModularLibrary).type)?.value
|
|
1399
1324
|
: undefined;
|
|
1400
1325
|
}
|
|
1401
1326
|
export function trimUsage(model) {
|
|
@@ -1423,14 +1348,10 @@ export function isAzureCoreErrorType(program, t) {
|
|
|
1423
1348
|
return isAzureCoreFoundationsNamespace(effective);
|
|
1424
1349
|
}
|
|
1425
1350
|
function isAzureCoreFoundationsNamespace(t, skipFoundation = false) {
|
|
1426
|
-
var _a;
|
|
1427
1351
|
const namespaces = (skipFoundation ? ".Azure.Core" : ".Azure.Core.Foundations").split(".");
|
|
1428
1352
|
while (namespaces.length > 0 &&
|
|
1429
|
-
(
|
|
1430
|
-
|
|
1431
|
-
(t === null || t === void 0 ? void 0 : t.kind) === "Union" ||
|
|
1432
|
-
(t === null || t === void 0 ? void 0 : t.kind) === "Namespace") &&
|
|
1433
|
-
((_a = t.namespace) === null || _a === void 0 ? void 0 : _a.name) === namespaces.pop()) {
|
|
1353
|
+
(t?.kind === "Model" || t?.kind === "Enum" || t?.kind === "Union" || t?.kind === "Namespace") &&
|
|
1354
|
+
t.namespace?.name === namespaces.pop()) {
|
|
1434
1355
|
t = t.namespace;
|
|
1435
1356
|
}
|
|
1436
1357
|
return namespaces.length == 0;
|
|
@@ -1476,8 +1397,7 @@ export function getModelInlineSigniture(schema, options = {}) {
|
|
|
1476
1397
|
return schemaSignature;
|
|
1477
1398
|
}
|
|
1478
1399
|
function getMultipartInlineSignature(schema, importedModels, usage) {
|
|
1479
|
-
|
|
1480
|
-
const types = Object.entries((_a = schema.properties) !== null && _a !== void 0 ? _a : {})
|
|
1400
|
+
const types = Object.entries(schema.properties ?? {})
|
|
1481
1401
|
.map(([propertyName, property]) => {
|
|
1482
1402
|
let schema;
|
|
1483
1403
|
// Flatten arrays for file uploads
|
|
@@ -1515,20 +1435,14 @@ function getMultipartInlineSignature(schema, importedModels, usage) {
|
|
|
1515
1435
|
* represented as properties in typespec.
|
|
1516
1436
|
*/
|
|
1517
1437
|
export function isSchemaProperty(program, property) {
|
|
1518
|
-
var _a;
|
|
1519
1438
|
const headerInfo = getHeaderFieldName(program, property);
|
|
1520
1439
|
const queryInfo = getQueryParamName(program, property);
|
|
1521
1440
|
const pathInfo = getPathParamName(program, property);
|
|
1522
1441
|
const statusCodeInfo = isStatusCode(program, property);
|
|
1523
|
-
const isNonVisibility =
|
|
1524
|
-
return !(headerInfo ||
|
|
1525
|
-
queryInfo ||
|
|
1526
|
-
pathInfo ||
|
|
1527
|
-
statusCodeInfo ||
|
|
1528
|
-
isNonVisibility);
|
|
1442
|
+
const isNonVisibility = getSdkVisibility(program, property)?.includes(Visibility.None);
|
|
1443
|
+
return !(headerInfo || queryInfo || pathInfo || statusCodeInfo || isNonVisibility);
|
|
1529
1444
|
}
|
|
1530
1445
|
export function getEffectiveSchemaType(program, type) {
|
|
1531
|
-
var _a, _b;
|
|
1532
1446
|
// If type is an anonymous model, tries to find a named model that has the same properties
|
|
1533
1447
|
let effective = undefined;
|
|
1534
1448
|
if (type.kind === "Union") {
|
|
@@ -1536,8 +1450,8 @@ export function getEffectiveSchemaType(program, type) {
|
|
|
1536
1450
|
.map((x) => x.type)
|
|
1537
1451
|
.filter((t) => !isNullType(t));
|
|
1538
1452
|
if (nonNullOptions.length === 1 &&
|
|
1539
|
-
|
|
1540
|
-
|
|
1453
|
+
nonNullOptions[0]?.kind === "Model" &&
|
|
1454
|
+
nonNullOptions[0]?.name === "") {
|
|
1541
1455
|
effective = getEffectiveModelType(program, nonNullOptions[0]);
|
|
1542
1456
|
}
|
|
1543
1457
|
return type;
|
|
@@ -1545,16 +1459,13 @@ export function getEffectiveSchemaType(program, type) {
|
|
|
1545
1459
|
else if (type.name === "") {
|
|
1546
1460
|
effective = getEffectiveModelType(program, type, (property) => isSchemaProperty(program, property));
|
|
1547
1461
|
}
|
|
1548
|
-
if (effective
|
|
1462
|
+
if (effective?.name) {
|
|
1549
1463
|
return effective;
|
|
1550
1464
|
}
|
|
1551
1465
|
return type;
|
|
1552
1466
|
}
|
|
1553
1467
|
export function isBodyRequired(parameter) {
|
|
1554
|
-
|
|
1555
|
-
return ((_a = parameter.body) === null || _a === void 0 ? void 0 : _a.type) && ((_c = (_b = parameter.body) === null || _b === void 0 ? void 0 : _b.property) === null || _c === void 0 ? void 0 : _c.optional) !== true
|
|
1556
|
-
? true
|
|
1557
|
-
: false;
|
|
1468
|
+
return parameter.body?.type && parameter.body?.property?.optional !== true ? true : false;
|
|
1558
1469
|
}
|
|
1559
1470
|
export function getCollectionFormat(context, param) {
|
|
1560
1471
|
const type = param.param;
|
|
@@ -1563,7 +1474,7 @@ export function getCollectionFormat(context, param) {
|
|
|
1563
1474
|
if (param.explode) {
|
|
1564
1475
|
return "multi";
|
|
1565
1476
|
}
|
|
1566
|
-
switch (encode
|
|
1477
|
+
switch (encode?.encoding) {
|
|
1567
1478
|
case "ArrayEncoding.pipeDelimited":
|
|
1568
1479
|
return "pipes";
|
|
1569
1480
|
case "ArrayEncoding.spaceDelimited":
|