@azure-tools/typespec-ts 0.53.3 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/src/framework/hooks/binder.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.js +102 -44
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/sdkTypes.js +1 -1
- package/dist/src/framework/hooks/sdkTypes.js.map +1 -1
- package/dist/src/framework/load-static-helpers.js +1 -1
- package/dist/src/framework/load-static-helpers.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +1 -10
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +0 -5
- package/dist/src/lib.js.map +1 -1
- package/dist/src/metaTree.d.ts +1 -1
- package/dist/src/metaTree.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +1 -1
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
- package/dist/src/modular/buildClientContext.js +1 -1
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildOperations.js +1 -1
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildProjectFiles.js +1 -1
- package/dist/src/modular/buildProjectFiles.js.map +1 -1
- package/dist/src/modular/buildRestorePoller.js +1 -1
- package/dist/src/modular/buildRestorePoller.js.map +1 -1
- package/dist/src/modular/buildRootIndex.js +1 -1
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/emitModels.d.ts +1 -1
- package/dist/src/modular/emitModels.d.ts.map +1 -1
- package/dist/src/modular/emitModels.js +1 -1
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/emitModelsOptions.js +1 -1
- package/dist/src/modular/emitModelsOptions.js.map +1 -1
- package/dist/src/modular/emitSamples.js +1 -1
- package/dist/src/modular/emitSamples.js.map +1 -1
- package/dist/src/modular/emitTests.js +1 -1
- package/dist/src/modular/emitTests.js.map +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.js +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +1 -1
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.js +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.js.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.js +1 -1
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +53 -34
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +1 -1
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/interfaces.d.ts +1 -1
- package/dist/src/modular/interfaces.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.js +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.js +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
- package/dist/src/rlc-common/buildClient.d.ts +9 -0
- package/dist/src/rlc-common/buildClient.d.ts.map +1 -0
- package/dist/src/rlc-common/buildClient.js +413 -0
- package/dist/src/rlc-common/buildClient.js.map +1 -0
- package/dist/src/rlc-common/buildClientDefinitions.d.ts +6 -0
- package/dist/src/rlc-common/buildClientDefinitions.d.ts.map +1 -0
- package/dist/src/rlc-common/buildClientDefinitions.js +174 -0
- package/dist/src/rlc-common/buildClientDefinitions.js.map +1 -0
- package/dist/src/rlc-common/buildIndexFile.d.ts +6 -0
- package/dist/src/rlc-common/buildIndexFile.d.ts.map +1 -0
- package/dist/src/rlc-common/buildIndexFile.js +242 -0
- package/dist/src/rlc-common/buildIndexFile.js.map +1 -0
- package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts +6 -0
- package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts.map +1 -0
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js +224 -0
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +1 -0
- package/dist/src/rlc-common/buildLogger.d.ts +6 -0
- package/dist/src/rlc-common/buildLogger.d.ts.map +1 -0
- package/dist/src/rlc-common/buildLogger.js +32 -0
- package/dist/src/rlc-common/buildLogger.js.map +1 -0
- package/dist/src/rlc-common/buildMethodShortcuts.d.ts +5 -0
- package/dist/src/rlc-common/buildMethodShortcuts.d.ts.map +1 -0
- package/dist/src/rlc-common/buildMethodShortcuts.js +54 -0
- package/dist/src/rlc-common/buildMethodShortcuts.js.map +1 -0
- package/dist/src/rlc-common/buildObjectTypes.d.ts +29 -0
- package/dist/src/rlc-common/buildObjectTypes.d.ts.map +1 -0
- package/dist/src/rlc-common/buildObjectTypes.js +451 -0
- package/dist/src/rlc-common/buildObjectTypes.js.map +1 -0
- package/dist/src/rlc-common/buildPaginateHelper.d.ts +6 -0
- package/dist/src/rlc-common/buildPaginateHelper.d.ts.map +1 -0
- package/dist/src/rlc-common/buildPaginateHelper.js +27 -0
- package/dist/src/rlc-common/buildPaginateHelper.js.map +1 -0
- package/dist/src/rlc-common/buildParameterTypes.d.ts +14 -0
- package/dist/src/rlc-common/buildParameterTypes.d.ts.map +1 -0
- package/dist/src/rlc-common/buildParameterTypes.js +381 -0
- package/dist/src/rlc-common/buildParameterTypes.js.map +1 -0
- package/dist/src/rlc-common/buildPollingHelper.d.ts +6 -0
- package/dist/src/rlc-common/buildPollingHelper.d.ts.map +1 -0
- package/dist/src/rlc-common/buildPollingHelper.js +62 -0
- package/dist/src/rlc-common/buildPollingHelper.js.map +1 -0
- package/dist/src/rlc-common/buildResponseTypes.d.ts +6 -0
- package/dist/src/rlc-common/buildResponseTypes.d.ts.map +1 -0
- package/dist/src/rlc-common/buildResponseTypes.js +147 -0
- package/dist/src/rlc-common/buildResponseTypes.js.map +1 -0
- package/dist/src/rlc-common/buildSamples.d.ts +3 -0
- package/dist/src/rlc-common/buildSamples.d.ts.map +1 -0
- package/dist/src/rlc-common/buildSamples.js +30 -0
- package/dist/src/rlc-common/buildSamples.js.map +1 -0
- package/dist/src/rlc-common/buildSchemaType.d.ts +20 -0
- package/dist/src/rlc-common/buildSchemaType.d.ts.map +1 -0
- package/dist/src/rlc-common/buildSchemaType.js +53 -0
- package/dist/src/rlc-common/buildSchemaType.js.map +1 -0
- package/dist/src/rlc-common/buildSerializeHelper.d.ts +6 -0
- package/dist/src/rlc-common/buildSerializeHelper.d.ts.map +1 -0
- package/dist/src/rlc-common/buildSerializeHelper.js +36 -0
- package/dist/src/rlc-common/buildSerializeHelper.js.map +1 -0
- package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts +6 -0
- package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts.map +1 -0
- package/dist/src/rlc-common/buildTopLevelIndexFile.js +52 -0
- package/dist/src/rlc-common/buildTopLevelIndexFile.js.map +1 -0
- package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts +17 -0
- package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/apiVersionUtil.js +45 -0
- package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +1 -0
- package/dist/src/rlc-common/helpers/importsUtil.d.ts +18 -0
- package/dist/src/rlc-common/helpers/importsUtil.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/importsUtil.js +169 -0
- package/dist/src/rlc-common/helpers/importsUtil.js.map +1 -0
- package/dist/src/rlc-common/helpers/nameConstructors.d.ts +42 -0
- package/dist/src/rlc-common/helpers/nameConstructors.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/nameConstructors.js +63 -0
- package/dist/src/rlc-common/helpers/nameConstructors.js.map +1 -0
- package/dist/src/rlc-common/helpers/nameUtils.d.ts +37 -0
- package/dist/src/rlc-common/helpers/nameUtils.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/nameUtils.js +246 -0
- package/dist/src/rlc-common/helpers/nameUtils.js.map +1 -0
- package/dist/src/rlc-common/helpers/operationHelpers.d.ts +16 -0
- package/dist/src/rlc-common/helpers/operationHelpers.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/operationHelpers.js +119 -0
- package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -0
- package/dist/src/rlc-common/helpers/packageUtil.d.ts +7 -0
- package/dist/src/rlc-common/helpers/packageUtil.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/packageUtil.js +13 -0
- package/dist/src/rlc-common/helpers/packageUtil.js.map +1 -0
- package/dist/src/rlc-common/helpers/pathUtils.d.ts +2 -0
- package/dist/src/rlc-common/helpers/pathUtils.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/pathUtils.js +12 -0
- package/dist/src/rlc-common/helpers/pathUtils.js.map +1 -0
- package/dist/src/rlc-common/helpers/schemaHelpers.d.ts +10 -0
- package/dist/src/rlc-common/helpers/schemaHelpers.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/schemaHelpers.js +41 -0
- package/dist/src/rlc-common/helpers/schemaHelpers.js.map +1 -0
- package/dist/src/rlc-common/helpers/shortcutMethods.d.ts +4 -0
- package/dist/src/rlc-common/helpers/shortcutMethods.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/shortcutMethods.js +49 -0
- package/dist/src/rlc-common/helpers/shortcutMethods.js.map +1 -0
- package/dist/src/rlc-common/helpers/typeUtil.d.ts +32 -0
- package/dist/src/rlc-common/helpers/typeUtil.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/typeUtil.js +167 -0
- package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -0
- package/dist/src/rlc-common/helpers/valueGenerationUtil.d.ts +12 -0
- package/dist/src/rlc-common/helpers/valueGenerationUtil.d.ts.map +1 -0
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js +165 -0
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +1 -0
- package/dist/src/rlc-common/index.d.ts +41 -0
- package/dist/src/rlc-common/index.d.ts.map +1 -0
- package/dist/src/rlc-common/index.js +43 -0
- package/dist/src/rlc-common/index.js.map +1 -0
- package/dist/src/rlc-common/interfaces.d.ts +369 -0
- package/dist/src/rlc-common/interfaces.d.ts.map +1 -0
- package/dist/src/rlc-common/interfaces.js +11 -0
- package/dist/src/rlc-common/interfaces.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +56 -0
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildChangelogFile.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildChangelogFile.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildChangelogFile.js +26 -0
- package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildESLintConfig.js +82 -0
- package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildLicenseFile.d.ts +5 -0
- package/dist/src/rlc-common/metadata/buildLicenseFile.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildLicenseFile.js +32 -0
- package/dist/src/rlc-common/metadata/buildLicenseFile.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildPackageFile.d.ts +25 -0
- package/dist/src/rlc-common/metadata/buildPackageFile.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildPackageFile.js +201 -0
- package/dist/src/rlc-common/metadata/buildPackageFile.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts +11 -0
- package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildReadmeFile.js +426 -0
- package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildRollupConfig.js +142 -0
- package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +17 -0
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildTestConfig.d.ts +16 -0
- package/dist/src/rlc-common/metadata/buildTestConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildTestConfig.js +55 -0
- package/dist/src/rlc-common/metadata/buildTestConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildTsConfig.d.ts +61 -0
- package/dist/src/rlc-common/metadata/buildTsConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildTsConfig.js +170 -0
- package/dist/src/rlc-common/metadata/buildTsConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts +6 -0
- package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildVitestConfig.js +28 -0
- package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts +20 -0
- package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/buildWarpConfig.js +77 -0
- package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts +51 -0
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +121 -0
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts +242 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +176 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts +8 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js +102 -0
- package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.d.ts +57 -0
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js +53 -0
- package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts +64 -0
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +183 -0
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -0
- package/dist/src/rlc-common/metadata/utils.d.ts +3 -0
- package/dist/src/rlc-common/metadata/utils.d.ts.map +1 -0
- package/dist/src/rlc-common/metadata/utils.js +7 -0
- package/dist/src/rlc-common/metadata/utils.js.map +1 -0
- package/dist/src/rlc-common/static/paginateContent.d.ts +2 -0
- package/dist/src/rlc-common/static/paginateContent.d.ts.map +1 -0
- package/dist/src/rlc-common/static/paginateContent.js +345 -0
- package/dist/src/rlc-common/static/paginateContent.js.map +1 -0
- package/dist/src/rlc-common/static/pollingContent.d.ts +2 -0
- package/dist/src/rlc-common/static/pollingContent.d.ts.map +1 -0
- package/dist/src/rlc-common/static/pollingContent.js +225 -0
- package/dist/src/rlc-common/static/pollingContent.js.map +1 -0
- package/dist/src/rlc-common/static/sampleTemplate.d.ts +2 -0
- package/dist/src/rlc-common/static/sampleTemplate.d.ts.map +1 -0
- package/dist/src/rlc-common/static/sampleTemplate.js +56 -0
- package/dist/src/rlc-common/static/sampleTemplate.js.map +1 -0
- package/dist/src/rlc-common/static/serializeHelper.d.ts +6 -0
- package/dist/src/rlc-common/static/serializeHelper.d.ts.map +1 -0
- package/dist/src/rlc-common/static/serializeHelper.js +31 -0
- package/dist/src/rlc-common/static/serializeHelper.js.map +1 -0
- package/dist/src/rlc-common/test/buildKarmaConfig.d.ts +6 -0
- package/dist/src/rlc-common/test/buildKarmaConfig.d.ts.map +1 -0
- package/dist/src/rlc-common/test/buildKarmaConfig.js +11 -0
- package/dist/src/rlc-common/test/buildKarmaConfig.js.map +1 -0
- package/dist/src/rlc-common/test/buildRecordedClient.d.ts +6 -0
- package/dist/src/rlc-common/test/buildRecordedClient.d.ts.map +1 -0
- package/dist/src/rlc-common/test/buildRecordedClient.js +18 -0
- package/dist/src/rlc-common/test/buildRecordedClient.js.map +1 -0
- package/dist/src/rlc-common/test/buildSampleTest.d.ts +6 -0
- package/dist/src/rlc-common/test/buildSampleTest.d.ts.map +1 -0
- package/dist/src/rlc-common/test/buildSampleTest.js +15 -0
- package/dist/src/rlc-common/test/buildSampleTest.js.map +1 -0
- package/dist/src/rlc-common/test/buildSnippets.d.ts +6 -0
- package/dist/src/rlc-common/test/buildSnippets.d.ts.map +1 -0
- package/dist/src/rlc-common/test/buildSnippets.js +29 -0
- package/dist/src/rlc-common/test/buildSnippets.js.map +1 -0
- package/dist/src/rlc-common/test/template.d.ts +5 -0
- package/dist/src/rlc-common/test/template.d.ts.map +1 -0
- package/dist/src/rlc-common/test/template.js +261 -0
- package/dist/src/rlc-common/test/template.js.map +1 -0
- package/dist/src/rlc-common/transformSampleGroups.d.ts +9 -0
- package/dist/src/rlc-common/transformSampleGroups.d.ts.map +1 -0
- package/dist/src/rlc-common/transformSampleGroups.js +317 -0
- package/dist/src/rlc-common/transformSampleGroups.js.map +1 -0
- package/dist/src/transform/transform.d.ts +1 -1
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/transform/transform.js +1 -1
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +1 -1
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.d.ts +1 -1
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +1 -1
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.d.ts +1 -1
- package/dist/src/transform/transformPaths.d.ts.map +1 -1
- package/dist/src/transform/transformPaths.js +1 -1
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.d.ts +1 -1
- package/dist/src/transform/transformResponses.d.ts.map +1 -1
- package/dist/src/transform/transformResponses.js +1 -1
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.js +1 -1
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/src/transform/transformTelemetryInfo.d.ts +1 -1
- package/dist/src/transform/transformTelemetryInfo.d.ts.map +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +1 -3
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/clientUtils.js +1 -1
- package/dist/src/utils/clientUtils.js.map +1 -1
- package/dist/src/utils/crossLanguageDef.js +1 -1
- package/dist/src/utils/crossLanguageDef.js.map +1 -1
- package/dist/src/utils/emitUtil.d.ts +1 -1
- package/dist/src/utils/emitUtil.d.ts.map +1 -1
- package/dist/src/utils/emitUtil.js +1 -1
- package/dist/src/utils/emitUtil.js.map +1 -1
- package/dist/src/utils/interfaces.d.ts +1 -1
- package/dist/src/utils/interfaces.d.ts.map +1 -1
- package/dist/src/utils/modelUtils.d.ts +1 -1
- package/dist/src/utils/modelUtils.d.ts.map +1 -1
- package/dist/src/utils/modelUtils.js +1 -1
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.d.ts +1 -1
- package/dist/src/utils/operationUtil.d.ts.map +1 -1
- package/dist/src/utils/operationUtil.js +1 -1
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/src/utils/parameterUtils.d.ts +1 -1
- package/dist/src/utils/parameterUtils.d.ts.map +1 -1
- package/dist/src/utils/parameterUtils.js +1 -1
- package/dist/src/utils/parameterUtils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/framework/hooks/binder.ts +142 -51
- package/src/framework/hooks/sdkTypes.ts +1 -1
- package/src/framework/load-static-helpers.ts +1 -1
- package/src/index.ts +5 -1
- package/src/lib.ts +1 -16
- package/src/metaTree.ts +1 -1
- package/src/modular/buildClassicalClient.ts +1 -1
- package/src/modular/buildClassicalOperationGroups.ts +1 -1
- package/src/modular/buildClientContext.ts +1 -1
- package/src/modular/buildOperations.ts +1 -1
- package/src/modular/buildProjectFiles.ts +1 -1
- package/src/modular/buildRestorePoller.ts +1 -1
- package/src/modular/buildRootIndex.ts +1 -1
- package/src/modular/emitModels.ts +1 -1
- package/src/modular/emitModelsOptions.ts +1 -1
- package/src/modular/emitSamples.ts +1 -1
- package/src/modular/emitTests.ts +1 -1
- package/src/modular/helpers/classicalOperationHelpers.ts +1 -1
- package/src/modular/helpers/clientHelpers.ts +1 -1
- package/src/modular/helpers/exampleValueHelpers.ts +1 -1
- package/src/modular/helpers/namingHelpers.ts +1 -1
- package/src/modular/helpers/operationHelpers.ts +65 -42
- package/src/modular/helpers/typeHelpers.ts +1 -1
- package/src/modular/interfaces.ts +1 -1
- package/src/modular/serialization/buildDeserializerFunction.ts +1 -1
- package/src/modular/serialization/buildSerializerFunction.ts +1 -1
- package/src/modular/serialization/buildXmlSerializerFunction.ts +1 -1
- package/src/modular/type-expressions/get-type-expression.ts +1 -1
- package/src/rlc-common/buildClient.ts +561 -0
- package/src/rlc-common/buildClientDefinitions.ts +278 -0
- package/src/rlc-common/buildIndexFile.ts +344 -0
- package/src/rlc-common/buildIsUnexpectedHelper.ts +255 -0
- package/src/rlc-common/buildLogger.ts +43 -0
- package/src/rlc-common/buildMethodShortcuts.ts +83 -0
- package/src/rlc-common/buildObjectTypes.ts +680 -0
- package/src/rlc-common/buildPaginateHelper.ts +34 -0
- package/src/rlc-common/buildParameterTypes.ts +575 -0
- package/src/rlc-common/buildPollingHelper.ts +83 -0
- package/src/rlc-common/buildResponseTypes.ts +203 -0
- package/src/rlc-common/buildSamples.ts +32 -0
- package/src/rlc-common/buildSchemaType.ts +81 -0
- package/src/rlc-common/buildSerializeHelper.ts +49 -0
- package/src/rlc-common/buildTopLevelIndexFile.ts +65 -0
- package/src/rlc-common/helpers/apiVersionUtil.ts +53 -0
- package/src/rlc-common/helpers/importsUtil.ts +187 -0
- package/src/rlc-common/helpers/nameConstructors.ts +144 -0
- package/src/rlc-common/helpers/nameUtils.ts +319 -0
- package/src/rlc-common/helpers/operationHelpers.ts +155 -0
- package/src/rlc-common/helpers/packageUtil.ts +13 -0
- package/src/rlc-common/helpers/pathUtils.ts +15 -0
- package/src/rlc-common/helpers/schemaHelpers.ts +61 -0
- package/src/rlc-common/helpers/shortcutMethods.ts +67 -0
- package/src/rlc-common/helpers/typeUtil.ts +173 -0
- package/src/rlc-common/helpers/valueGenerationUtil.ts +257 -0
- package/src/rlc-common/index.ts +43 -0
- package/src/rlc-common/interfaces.ts +441 -0
- package/src/rlc-common/metadata/buildApiExtractorConfig.ts +71 -0
- package/src/rlc-common/metadata/buildChangelogFile.ts +29 -0
- package/src/rlc-common/metadata/buildESLintConfig.ts +86 -0
- package/src/rlc-common/metadata/buildLicenseFile.ts +33 -0
- package/src/rlc-common/metadata/buildPackageFile.ts +250 -0
- package/src/rlc-common/metadata/buildReadmeFile.ts +528 -0
- package/src/rlc-common/metadata/buildRollupConfig.ts +150 -0
- package/src/rlc-common/metadata/buildSampleEnvFile.ts +22 -0
- package/src/rlc-common/metadata/buildTestConfig.ts +72 -0
- package/src/rlc-common/metadata/buildTsConfig.ts +222 -0
- package/src/rlc-common/metadata/buildVitestConfig.ts +36 -0
- package/src/rlc-common/metadata/buildWarpConfig.ts +94 -0
- package/src/rlc-common/metadata/packageJson/azurePackageCommon.ts +161 -0
- package/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.ts +220 -0
- package/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.ts +134 -0
- package/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.ts +70 -0
- package/src/rlc-common/metadata/packageJson/packageCommon.ts +255 -0
- package/src/rlc-common/metadata/utils.ts +8 -0
- package/src/rlc-common/static/paginateContent.ts +345 -0
- package/src/rlc-common/static/pollingContent.ts +225 -0
- package/src/rlc-common/static/sampleTemplate.ts +56 -0
- package/src/rlc-common/static/serializeHelper.ts +34 -0
- package/src/rlc-common/test/buildKarmaConfig.ts +12 -0
- package/src/rlc-common/test/buildRecordedClient.ts +18 -0
- package/src/rlc-common/test/buildSampleTest.ts +15 -0
- package/src/rlc-common/test/buildSnippets.ts +35 -0
- package/src/rlc-common/test/template.ts +263 -0
- package/src/rlc-common/transformSampleGroups.ts +458 -0
- package/src/transform/transform.ts +1 -1
- package/src/transform/transformApiVersionInfo.ts +1 -1
- package/src/transform/transformHelperFunctionDetails.ts +1 -1
- package/src/transform/transformParameters.ts +1 -1
- package/src/transform/transformPaths.ts +1 -1
- package/src/transform/transformResponses.ts +1 -1
- package/src/transform/transformSchemas.ts +1 -1
- package/src/transform/transformTelemetryInfo.ts +1 -1
- package/src/transform/transfromRLCOptions.ts +1 -3
- package/src/utils/clientUtils.ts +1 -1
- package/src/utils/crossLanguageDef.ts +1 -1
- package/src/utils/emitUtil.ts +1 -1
- package/src/utils/interfaces.ts +1 -1
- package/src/utils/modelUtils.ts +1 -1
- package/src/utils/operationUtil.ts +1 -1
- package/src/utils/parameterUtils.ts +1 -1
- package/LICENSE +0 -21
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
InterfaceDeclarationStructure,
|
|
6
|
+
OptionalKind,
|
|
7
|
+
PropertySignatureStructure,
|
|
8
|
+
StructureKind,
|
|
9
|
+
TypeAliasDeclarationStructure
|
|
10
|
+
} from "ts-morph";
|
|
11
|
+
import { NameType, normalizeName } from "./helpers/nameUtils.js";
|
|
12
|
+
import {
|
|
13
|
+
isArraySchema,
|
|
14
|
+
isDictionarySchema,
|
|
15
|
+
isObjectSchema
|
|
16
|
+
} from "./helpers/schemaHelpers.js";
|
|
17
|
+
import {
|
|
18
|
+
ArraySchema,
|
|
19
|
+
ObjectSchema,
|
|
20
|
+
Parameter,
|
|
21
|
+
Property,
|
|
22
|
+
RLCModel,
|
|
23
|
+
Schema,
|
|
24
|
+
SchemaContext
|
|
25
|
+
} from "./interfaces.js";
|
|
26
|
+
import { getMultipartPartTypeName } from "./helpers/nameConstructors.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Generates interfaces for ObjectSchemas
|
|
30
|
+
*/
|
|
31
|
+
export function buildObjectInterfaces(
|
|
32
|
+
model: RLCModel,
|
|
33
|
+
importedModels: Set<string>,
|
|
34
|
+
schemaUsage: SchemaContext[]
|
|
35
|
+
): InterfaceDeclarationStructure[] {
|
|
36
|
+
const objectSchemas: ObjectSchema[] = (model.schemas ?? []).filter(
|
|
37
|
+
(o) =>
|
|
38
|
+
isObjectSchema(o) &&
|
|
39
|
+
(o as ObjectSchema).usage?.some((u) => schemaUsage.includes(u))
|
|
40
|
+
);
|
|
41
|
+
const objectInterfaces: InterfaceDeclarationStructure[] = [];
|
|
42
|
+
|
|
43
|
+
for (const objectSchema of objectSchemas) {
|
|
44
|
+
if (
|
|
45
|
+
objectSchema.alias ||
|
|
46
|
+
objectSchema.outputAlias ||
|
|
47
|
+
objectSchema.fromCore
|
|
48
|
+
) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// FIXME: disabling new multipart generation for modular while we figure out the story
|
|
53
|
+
if (objectSchema.isMultipartBody && !model.options?.isModularLibrary) {
|
|
54
|
+
objectInterfaces.push(
|
|
55
|
+
...buildMultipartPartDefinitions(
|
|
56
|
+
objectSchema,
|
|
57
|
+
importedModels,
|
|
58
|
+
schemaUsage
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const baseName = getObjectBaseName(objectSchema, schemaUsage);
|
|
65
|
+
const interfaceDeclaration = getObjectInterfaceDeclaration(
|
|
66
|
+
model,
|
|
67
|
+
baseName,
|
|
68
|
+
objectSchema,
|
|
69
|
+
schemaUsage,
|
|
70
|
+
importedModels
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
objectInterfaces.push(interfaceDeclaration);
|
|
74
|
+
}
|
|
75
|
+
return objectInterfaces;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const MULTIPART_FILE_METADATA_PROPERTIES: OptionalKind<PropertySignatureStructure>[] =
|
|
79
|
+
[
|
|
80
|
+
{
|
|
81
|
+
name: "filename",
|
|
82
|
+
hasQuestionToken: true,
|
|
83
|
+
type: "string"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "contentType",
|
|
87
|
+
hasQuestionToken: true,
|
|
88
|
+
type: "string"
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
function buildMultipartPartDefinitions(
|
|
93
|
+
schema: ObjectSchema,
|
|
94
|
+
importedModels: Set<string>,
|
|
95
|
+
schemaUsage: SchemaContext[]
|
|
96
|
+
): InterfaceDeclarationStructure[] {
|
|
97
|
+
if (!schema.isMultipartBody) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Transform property signatures into individual models
|
|
102
|
+
const propertySignatures = getPropertySignatures(
|
|
103
|
+
schema.properties ?? {},
|
|
104
|
+
schemaUsage,
|
|
105
|
+
importedModels,
|
|
106
|
+
{ flattenBinaryArrays: true }
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const structures: InterfaceDeclarationStructure[] = [];
|
|
110
|
+
|
|
111
|
+
for (const signature of propertySignatures) {
|
|
112
|
+
const name = signature.name;
|
|
113
|
+
const propertySchema = schema.properties?.[name];
|
|
114
|
+
const typeName = getMultipartPartTypeName(schema.name, name);
|
|
115
|
+
|
|
116
|
+
const isFileUpload = signature.type?.toString().includes("File") ?? false;
|
|
117
|
+
|
|
118
|
+
const additionalProperties: any[] = [];
|
|
119
|
+
|
|
120
|
+
if ((propertySchema as any).multipartOptions) {
|
|
121
|
+
const multipartOptions: any = (propertySchema as any).multipartOptions;
|
|
122
|
+
if (multipartOptions.filenameSchema) {
|
|
123
|
+
additionalProperties.push(
|
|
124
|
+
getPropertySignature(
|
|
125
|
+
{ name: "filename", ...multipartOptions.filenameSchema },
|
|
126
|
+
[SchemaContext.Input],
|
|
127
|
+
importedModels
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if (multipartOptions.contentTypeSchema) {
|
|
132
|
+
additionalProperties.push(
|
|
133
|
+
getPropertySignature(
|
|
134
|
+
{ name: "contentType", ...multipartOptions.contentTypeSchema },
|
|
135
|
+
[SchemaContext.Input],
|
|
136
|
+
importedModels
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
} else if (isFileUpload) {
|
|
141
|
+
// default additional file metadata properties (legacy)
|
|
142
|
+
additionalProperties.push(...MULTIPART_FILE_METADATA_PROPERTIES);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
structures.push({
|
|
146
|
+
kind: StructureKind.Interface,
|
|
147
|
+
isExported: true,
|
|
148
|
+
name: typeName,
|
|
149
|
+
properties: [
|
|
150
|
+
{
|
|
151
|
+
name: "name",
|
|
152
|
+
type: name
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "body",
|
|
156
|
+
type: signature.type
|
|
157
|
+
},
|
|
158
|
+
...additionalProperties
|
|
159
|
+
]
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return structures;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function buildObjectAliases(
|
|
167
|
+
model: RLCModel,
|
|
168
|
+
importedModels: Set<string>,
|
|
169
|
+
schemaUsage: SchemaContext[]
|
|
170
|
+
) {
|
|
171
|
+
const objectSchemas: ObjectSchema[] = (model.schemas ?? []).filter(
|
|
172
|
+
(o) =>
|
|
173
|
+
isObjectSchema(o) &&
|
|
174
|
+
(o as ObjectSchema).usage?.some((u) => schemaUsage.includes(u))
|
|
175
|
+
);
|
|
176
|
+
const objectAliases: TypeAliasDeclarationStructure[] = [];
|
|
177
|
+
|
|
178
|
+
for (const objectSchema of objectSchemas) {
|
|
179
|
+
// FIXME: disabling new multipart generation for modular while we figure out the story
|
|
180
|
+
if (objectSchema.isMultipartBody && !model.options?.isModularLibrary) {
|
|
181
|
+
const propertySignatures = getPropertySignatures(
|
|
182
|
+
objectSchema.properties ?? {},
|
|
183
|
+
schemaUsage,
|
|
184
|
+
importedModels,
|
|
185
|
+
{ flattenBinaryArrays: true }
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const objectTypeNames = propertySignatures.map((sig) =>
|
|
189
|
+
getMultipartPartTypeName(objectSchema.name, sig.name)
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
objectAliases.push({
|
|
193
|
+
kind: StructureKind.TypeAlias,
|
|
194
|
+
...(objectSchema.description && {
|
|
195
|
+
docs: [{ description: objectSchema.description }]
|
|
196
|
+
}),
|
|
197
|
+
name: objectSchema.typeName!,
|
|
198
|
+
type: `FormData | Array<${objectTypeNames.join("|") || "unknown"}>`,
|
|
199
|
+
isExported: true
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (objectSchema.alias || objectSchema.outputAlias) {
|
|
204
|
+
const description = objectSchema.description;
|
|
205
|
+
const modelName = schemaUsage.includes(SchemaContext.Input)
|
|
206
|
+
? `${objectSchema.typeName}`
|
|
207
|
+
: `${objectSchema.outputTypeName}`;
|
|
208
|
+
objectAliases.push({
|
|
209
|
+
kind: StructureKind.TypeAlias,
|
|
210
|
+
...(description && { docs: [{ description }] }),
|
|
211
|
+
name: modelName,
|
|
212
|
+
type: schemaUsage.includes(SchemaContext.Input)
|
|
213
|
+
? `${objectSchema.alias}`
|
|
214
|
+
: `${objectSchema.outputAlias}`,
|
|
215
|
+
isExported: true,
|
|
216
|
+
docs: [description ?? "Alias for " + modelName]
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return objectAliases;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function buildPolymorphicAliases(
|
|
224
|
+
model: RLCModel,
|
|
225
|
+
schemaUsage: SchemaContext[]
|
|
226
|
+
) {
|
|
227
|
+
// We'll add aliases for polymorphic objects
|
|
228
|
+
const objectAliases: TypeAliasDeclarationStructure[] = [];
|
|
229
|
+
const objectSchemas: ObjectSchema[] = (model.schemas ?? []).filter(
|
|
230
|
+
(o) =>
|
|
231
|
+
isObjectSchema(o) &&
|
|
232
|
+
(o as ObjectSchema).usage?.some((u) => schemaUsage.includes(u))
|
|
233
|
+
);
|
|
234
|
+
for (const objectSchema of objectSchemas) {
|
|
235
|
+
const baseName = getObjectBaseName(objectSchema, schemaUsage);
|
|
236
|
+
const typeAlias = getPolymorphicTypeAlias(
|
|
237
|
+
baseName,
|
|
238
|
+
objectSchema,
|
|
239
|
+
schemaUsage
|
|
240
|
+
);
|
|
241
|
+
if (typeAlias) {
|
|
242
|
+
objectAliases.push(typeAlias);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return objectAliases;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Gets a base name for an object schema this is tipically used with suffixes when building interface or type names
|
|
251
|
+
*/
|
|
252
|
+
function getObjectBaseName(
|
|
253
|
+
objectSchema: ObjectSchema,
|
|
254
|
+
schemaUsage: SchemaContext[]
|
|
255
|
+
) {
|
|
256
|
+
const nameSuffix = schemaUsage.includes(SchemaContext.Output) ? "Output" : "";
|
|
257
|
+
const name = normalizeName(
|
|
258
|
+
objectSchema.name,
|
|
259
|
+
NameType.Interface,
|
|
260
|
+
true /** guard name */
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
return `${name}${nameSuffix}`;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* If the current object is a Polymorphic parent, we need to create
|
|
268
|
+
* a type alias with the union of its children to enable polymorphism
|
|
269
|
+
*/
|
|
270
|
+
function getPolymorphicTypeAlias(
|
|
271
|
+
baseName: string,
|
|
272
|
+
objectSchema: ObjectSchema,
|
|
273
|
+
schemaUsage: SchemaContext[]
|
|
274
|
+
): TypeAliasDeclarationStructure | undefined {
|
|
275
|
+
if (!isPolymorphicParent(objectSchema)) {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const unionTypes: string[] = [];
|
|
280
|
+
|
|
281
|
+
// If the object itself has a discriminatorValue add its base to the union
|
|
282
|
+
if (objectSchema.discriminatorValue) {
|
|
283
|
+
unionTypes.push(`${baseName}Parent`);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
for (const child of objectSchema.children?.all ?? []) {
|
|
287
|
+
const nameSuffix = schemaUsage.includes(SchemaContext.Output)
|
|
288
|
+
? "Output"
|
|
289
|
+
: "";
|
|
290
|
+
const name = normalizeName(
|
|
291
|
+
child.name,
|
|
292
|
+
NameType.Interface,
|
|
293
|
+
true /** shouldGuard */
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
unionTypes.push(`${name}${nameSuffix}`);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const description = objectSchema.description;
|
|
300
|
+
|
|
301
|
+
return {
|
|
302
|
+
kind: StructureKind.TypeAlias,
|
|
303
|
+
...(description && { docs: [{ description }] }),
|
|
304
|
+
name: `${baseName}`,
|
|
305
|
+
type: unionTypes.join(" | "),
|
|
306
|
+
isExported: true
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Builds the interface for the current object schema. If it is a polymorphic
|
|
312
|
+
* root node it will suffix it with Base.
|
|
313
|
+
*/
|
|
314
|
+
export function getObjectInterfaceDeclaration(
|
|
315
|
+
model: RLCModel,
|
|
316
|
+
baseName: string,
|
|
317
|
+
objectSchema: ObjectSchema,
|
|
318
|
+
schemaUsage: SchemaContext[],
|
|
319
|
+
importedModels: Set<string>
|
|
320
|
+
): InterfaceDeclarationStructure {
|
|
321
|
+
let interfaceName = `${baseName}`;
|
|
322
|
+
if (isPolymorphicParent(objectSchema)) {
|
|
323
|
+
interfaceName = `${baseName}Parent`;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const properties = objectSchema.properties ?? {};
|
|
327
|
+
|
|
328
|
+
let propertySignatures = getPropertySignatures(
|
|
329
|
+
properties,
|
|
330
|
+
schemaUsage,
|
|
331
|
+
importedModels
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
// Add the polymorphic property if exists
|
|
335
|
+
propertySignatures = addDiscriminatorProperty(
|
|
336
|
+
model,
|
|
337
|
+
objectSchema,
|
|
338
|
+
propertySignatures,
|
|
339
|
+
schemaUsage
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
// Calculate the parents of the current object
|
|
343
|
+
const extendFrom = getImmediateParentsNames(objectSchema, schemaUsage);
|
|
344
|
+
|
|
345
|
+
const description = objectSchema.description;
|
|
346
|
+
return {
|
|
347
|
+
kind: StructureKind.Interface,
|
|
348
|
+
...(description && { docs: [{ description }] }),
|
|
349
|
+
name: interfaceName,
|
|
350
|
+
isExported: true,
|
|
351
|
+
properties: propertySignatures,
|
|
352
|
+
...(extendFrom && { extends: extendFrom })
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function isPolymorphicParent(objectSchema: ObjectSchema) {
|
|
357
|
+
return objectSchema.isPolyParent ? true : false;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function addDiscriminatorProperty(
|
|
361
|
+
model: RLCModel,
|
|
362
|
+
objectSchema: ObjectSchema,
|
|
363
|
+
properties: PropertySignatureStructure[],
|
|
364
|
+
schemaUsage: SchemaContext[]
|
|
365
|
+
): PropertySignatureStructure[] {
|
|
366
|
+
const polymorphicProperty = getDiscriminatorProperty(
|
|
367
|
+
model,
|
|
368
|
+
objectSchema,
|
|
369
|
+
schemaUsage
|
|
370
|
+
);
|
|
371
|
+
|
|
372
|
+
if (polymorphicProperty) {
|
|
373
|
+
// It is possible that the polymorphic property needs to override an existing property.
|
|
374
|
+
// This is usually the case on the top level parent where the property already has a type of string
|
|
375
|
+
// we need to replace it with the polymorphic values of its children
|
|
376
|
+
const filteredProperties = properties.filter(
|
|
377
|
+
(p) => p.name !== polymorphicProperty.name
|
|
378
|
+
);
|
|
379
|
+
return [...filteredProperties, polymorphicProperty];
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return properties;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Finds the name of the property used as discriminator and the discriminator value.
|
|
387
|
+
*/
|
|
388
|
+
function getDiscriminatorProperty(
|
|
389
|
+
model: RLCModel,
|
|
390
|
+
objectSchema: ObjectSchema,
|
|
391
|
+
schemaUsage: SchemaContext[]
|
|
392
|
+
): PropertySignatureStructure | undefined {
|
|
393
|
+
const discriminatorValue = objectSchema.discriminatorValue;
|
|
394
|
+
if (!discriminatorValue && !objectSchema.discriminator) {
|
|
395
|
+
return undefined;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const discriminators = getDiscriminatorValue(objectSchema);
|
|
399
|
+
const discriminatorPropertyName = getDiscriminatorPropertyName(objectSchema);
|
|
400
|
+
|
|
401
|
+
if (discriminators) {
|
|
402
|
+
if (discriminatorPropertyName === undefined) {
|
|
403
|
+
throw new Error(
|
|
404
|
+
`getDiscriminatorProperty: Expected object ${objectSchema.name} to have a discriminator in its hierarchy but found none`
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
const inputTypeName =
|
|
408
|
+
objectSchema.discriminator?.typeName ?? objectSchema.discriminator?.type;
|
|
409
|
+
return {
|
|
410
|
+
kind: StructureKind.PropertySignature,
|
|
411
|
+
name: `"${discriminatorPropertyName}"`,
|
|
412
|
+
type:
|
|
413
|
+
model.options?.sourceFrom === "Swagger"
|
|
414
|
+
? discriminators
|
|
415
|
+
: schemaUsage.includes(SchemaContext.Output)
|
|
416
|
+
? (objectSchema.discriminator?.outputTypeName ?? inputTypeName)
|
|
417
|
+
: inputTypeName
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return undefined;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Finds the closest discriminator property
|
|
426
|
+
*/
|
|
427
|
+
function getDiscriminatorPropertyName(objectSchema: ObjectSchema) {
|
|
428
|
+
if (objectSchema.discriminator !== undefined) {
|
|
429
|
+
return objectSchema.discriminator.name;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const allParents = objectSchema.parents?.all ?? [];
|
|
433
|
+
|
|
434
|
+
for (const parent of allParents) {
|
|
435
|
+
if (isObjectSchema(parent) && parent.discriminator) {
|
|
436
|
+
return parent.discriminator.name;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return undefined;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Calculates the discriminator values that a given object needs
|
|
444
|
+
*/
|
|
445
|
+
function getDiscriminatorValue(objectSchema: ObjectSchema): string | undefined {
|
|
446
|
+
const discriminatorValue = objectSchema.discriminatorValue
|
|
447
|
+
? objectSchema.discriminatorValue
|
|
448
|
+
: objectSchema.discriminator
|
|
449
|
+
? objectSchema.name
|
|
450
|
+
: undefined;
|
|
451
|
+
const children = objectSchema.children?.immediate ?? [];
|
|
452
|
+
|
|
453
|
+
// If the current object has a discriminatorValue but doesn't have any children
|
|
454
|
+
// it is a leaf node and the only discriminator value needed is itself
|
|
455
|
+
if (discriminatorValue && !children.length) {
|
|
456
|
+
return `"${discriminatorValue}"`;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// when the current object has both discriminator and discriminatorValue
|
|
460
|
+
if (children) {
|
|
461
|
+
const discriminatorProperty = objectSchema.discriminator;
|
|
462
|
+
// Even when there are children, if no discriminatorProperty is present this is a leaf in the polymorphism tree
|
|
463
|
+
if (!discriminatorProperty) {
|
|
464
|
+
return `"${discriminatorValue}"`;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// the current object has discriminated children we need to find all the discriminatorValues for each of its children
|
|
468
|
+
const allChildren = objectSchema.children?.all ?? [];
|
|
469
|
+
|
|
470
|
+
// Top level parents may not have a discriminator of their own.
|
|
471
|
+
const selfDiscriminator = discriminatorValue
|
|
472
|
+
? [`"${discriminatorValue}"`]
|
|
473
|
+
: [];
|
|
474
|
+
|
|
475
|
+
const childValues = getChildDiscriminatorValues(allChildren).map(
|
|
476
|
+
(v) => `"${v}"`
|
|
477
|
+
);
|
|
478
|
+
|
|
479
|
+
return [...selfDiscriminator, ...childValues].join(" | ");
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return undefined;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Looks into the children and grabs all possible discriminatorValues
|
|
487
|
+
*/
|
|
488
|
+
function getChildDiscriminatorValues(children: ObjectSchema[]): string[] {
|
|
489
|
+
const discriminatorValues = new Set<string>();
|
|
490
|
+
for (const child of children) {
|
|
491
|
+
if (isObjectSchema(child) && child.discriminatorValue) {
|
|
492
|
+
discriminatorValues.add(child.discriminatorValue);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return [...discriminatorValues];
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Gets a list of types a given object may extend from
|
|
501
|
+
*/
|
|
502
|
+
export function getImmediateParentsNames(
|
|
503
|
+
objectSchema: ObjectSchema,
|
|
504
|
+
schemaUsage: SchemaContext[]
|
|
505
|
+
): string[] {
|
|
506
|
+
if (!objectSchema.parents?.immediate) {
|
|
507
|
+
return [];
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const extendFrom: string[] = [];
|
|
511
|
+
|
|
512
|
+
// If an immediate parent is an empty DictionarySchema, that means that the object has been marked
|
|
513
|
+
// with additional properties. We need to add Record<string, unknown> to the extend list and
|
|
514
|
+
if (
|
|
515
|
+
objectSchema.parents.immediate.find((im) =>
|
|
516
|
+
isDictionarySchema(im, { filterEmpty: true })
|
|
517
|
+
)
|
|
518
|
+
) {
|
|
519
|
+
extendFrom.push("Record<string, unknown>");
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// Get the rest of the parents excluding any DictionarySchemas
|
|
523
|
+
const parents = objectSchema.parents.immediate
|
|
524
|
+
.filter((p) => !isDictionarySchema(p, { filterEmpty: true }))
|
|
525
|
+
.map((parent) => {
|
|
526
|
+
const nameSuffix = schemaUsage.includes(SchemaContext.Output)
|
|
527
|
+
? "Output"
|
|
528
|
+
: "";
|
|
529
|
+
const name = isDictionarySchema(parent)
|
|
530
|
+
? Object.entries(objectSchema.properties!)?.some((prop) => {
|
|
531
|
+
const typeName = prop[1].typeName ?? prop[1].type;
|
|
532
|
+
return (
|
|
533
|
+
`Record<string, ${typeName}>` !== parent.typeName &&
|
|
534
|
+
!(parent as any).additionalProperties?.typeName?.includes(
|
|
535
|
+
typeName
|
|
536
|
+
)
|
|
537
|
+
);
|
|
538
|
+
})
|
|
539
|
+
? schemaUsage.includes(SchemaContext.Output)
|
|
540
|
+
? "Record<string, any>"
|
|
541
|
+
: "Record<string, unknown>"
|
|
542
|
+
: `${
|
|
543
|
+
(schemaUsage.includes(SchemaContext.Output)
|
|
544
|
+
? parent.outputTypeName
|
|
545
|
+
: parent.typeName) ?? parent.name
|
|
546
|
+
}`
|
|
547
|
+
: `${normalizeName(
|
|
548
|
+
parent.name,
|
|
549
|
+
NameType.Interface,
|
|
550
|
+
true /** shouldGuard */
|
|
551
|
+
)}${nameSuffix}`;
|
|
552
|
+
|
|
553
|
+
return isObjectSchema(parent) && isPolymorphicParent(parent)
|
|
554
|
+
? `${name}Parent`
|
|
555
|
+
: name;
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
return [...parents, ...extendFrom];
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
interface GetPropertySignatureOptions {
|
|
562
|
+
flattenBinaryArrays?: boolean;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function getPropertySignatures(
|
|
566
|
+
properties: { [key: string]: Property },
|
|
567
|
+
schemaUsage: SchemaContext[],
|
|
568
|
+
importedModels: Set<string>,
|
|
569
|
+
options: GetPropertySignatureOptions = {}
|
|
570
|
+
) {
|
|
571
|
+
let validProperties = Object.keys(properties);
|
|
572
|
+
const readOnlyFilter = (name: string) => {
|
|
573
|
+
const prop = properties[name];
|
|
574
|
+
return !(schemaUsage.includes(SchemaContext.Input) && prop?.readOnly);
|
|
575
|
+
};
|
|
576
|
+
const neverFilter = (name: string) => {
|
|
577
|
+
const prop = properties[name];
|
|
578
|
+
return prop?.type !== "never";
|
|
579
|
+
};
|
|
580
|
+
validProperties = validProperties.filter(readOnlyFilter).filter(neverFilter);
|
|
581
|
+
return validProperties.map((p) => {
|
|
582
|
+
const prop = properties[p];
|
|
583
|
+
if (!prop) {
|
|
584
|
+
throw new Error(`Property '${p}' not found`);
|
|
585
|
+
}
|
|
586
|
+
return getPropertySignature(
|
|
587
|
+
{ ...prop, name: p } as Schema,
|
|
588
|
+
schemaUsage,
|
|
589
|
+
importedModels,
|
|
590
|
+
options
|
|
591
|
+
);
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function isBinaryArray(schema: Schema): boolean {
|
|
596
|
+
return Boolean(
|
|
597
|
+
isArraySchema(schema) &&
|
|
598
|
+
(schema.items?.typeName?.includes("NodeJS.ReadableStream") ||
|
|
599
|
+
schema.items?.outputTypeName?.includes("NodeJS.ReadableStream"))
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Builds a Typescript property or parameter signature
|
|
605
|
+
* @param schema - Property or parameter to get the Typescript signature for
|
|
606
|
+
* @param importedModels - Set to track the models that need to be imported
|
|
607
|
+
* @returns a PropertySignatureStructure for the property.
|
|
608
|
+
*/
|
|
609
|
+
export function getPropertySignature(
|
|
610
|
+
property: Property | Parameter,
|
|
611
|
+
schemaUsage: SchemaContext[],
|
|
612
|
+
importedModels: Set<string>,
|
|
613
|
+
options: GetPropertySignatureOptions = {}
|
|
614
|
+
): PropertySignatureStructure {
|
|
615
|
+
let schema: Schema;
|
|
616
|
+
if (options.flattenBinaryArrays && isBinaryArray(property)) {
|
|
617
|
+
schema = {
|
|
618
|
+
...((property as ArraySchema).items ?? property),
|
|
619
|
+
name: property.name
|
|
620
|
+
};
|
|
621
|
+
} else {
|
|
622
|
+
schema = property;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
const propertyName = schema.name;
|
|
626
|
+
const description = schema.description;
|
|
627
|
+
let type;
|
|
628
|
+
const hasCoreInArray =
|
|
629
|
+
schema.type === "array" &&
|
|
630
|
+
(schema as any).items &&
|
|
631
|
+
(schema as any).items.fromCore;
|
|
632
|
+
const hasCoreInRecord =
|
|
633
|
+
schema.type === "dictionary" &&
|
|
634
|
+
(schema as any).additionalProperties &&
|
|
635
|
+
(schema as any).additionalProperties.fromCore;
|
|
636
|
+
if (hasCoreInArray && schema.typeName) {
|
|
637
|
+
type = schema.typeName;
|
|
638
|
+
importedModels.add(
|
|
639
|
+
(schema as any).items.typeName ?? (schema as any).items.name
|
|
640
|
+
);
|
|
641
|
+
} else if (hasCoreInRecord && schema.typeName) {
|
|
642
|
+
type = schema.typeName;
|
|
643
|
+
importedModels.add(
|
|
644
|
+
(schema as any).additionalProperties.typeName ??
|
|
645
|
+
(schema as any).additionalProperties.name
|
|
646
|
+
);
|
|
647
|
+
} else {
|
|
648
|
+
type =
|
|
649
|
+
generateForOutput(schemaUsage, schema.usage) && schema.outputTypeName
|
|
650
|
+
? schema.outputTypeName
|
|
651
|
+
: schema.typeName
|
|
652
|
+
? schema.typeName
|
|
653
|
+
: schema.type;
|
|
654
|
+
if (schema.typeName && schema.fromCore) {
|
|
655
|
+
importedModels.add(schema.typeName);
|
|
656
|
+
type = schema.typeName;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
return {
|
|
661
|
+
name: propertyName,
|
|
662
|
+
...(description && { docs: [{ description }] }),
|
|
663
|
+
hasQuestionToken: !schema.required,
|
|
664
|
+
isReadonly: generateForOutput(schemaUsage, schema.usage) && schema.readOnly,
|
|
665
|
+
type,
|
|
666
|
+
kind: StructureKind.PropertySignature
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function generateForOutput(
|
|
671
|
+
schemaUsage: SchemaContext[],
|
|
672
|
+
propertyUsage?: SchemaContext[]
|
|
673
|
+
) {
|
|
674
|
+
return (
|
|
675
|
+
(schemaUsage.includes(SchemaContext.Output) &&
|
|
676
|
+
propertyUsage?.includes(SchemaContext.Output)) ||
|
|
677
|
+
(schemaUsage.includes(SchemaContext.Exception) &&
|
|
678
|
+
propertyUsage?.includes(SchemaContext.Exception))
|
|
679
|
+
);
|
|
680
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RLCModel } from "./interfaces.js";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
+
// @ts-ignore: to fix the handlebars issue
|
|
5
|
+
import hbs from "handlebars";
|
|
6
|
+
import { paginateContent } from "./static/paginateContent.js";
|
|
7
|
+
|
|
8
|
+
export function buildPaginateHelper(model: RLCModel) {
|
|
9
|
+
const pagingInfo = model.helperDetails;
|
|
10
|
+
// return directly if no paging info
|
|
11
|
+
if (!pagingInfo || pagingInfo.hasPaging !== true || !pagingInfo.pageDetails) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
hbs.registerHelper(
|
|
16
|
+
"quoteWrap",
|
|
17
|
+
function (value: string | number | boolean | string[]) {
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
return value.map((element) => `"${element}"`).join();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return `"${value}"`;
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const { srcPath } = model;
|
|
27
|
+
const paginateHelperContents = hbs.compile(paginateContent, {
|
|
28
|
+
noEscape: true
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
path: path.join(srcPath, "paginateHelper.ts"),
|
|
32
|
+
content: paginateHelperContents(pagingInfo.pageDetails)
|
|
33
|
+
};
|
|
34
|
+
}
|