@azure-tools/typespec-ts 0.56.0-dev.13 → 0.56.0-dev.15
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 +16 -0
- package/README.md +31 -15
- package/dist/src/context-manager.d.ts +6 -6
- package/dist/src/context-manager.d.ts.map +1 -1
- package/dist/src/context-manager.js +1 -0
- package/dist/src/context-manager.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 -1
- package/dist/src/framework/declaration.js.map +1 -1
- package/dist/src/framework/hooks/binder.d.ts +2 -5
- package/dist/src/framework/hooks/binder.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.js +2 -29
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/sdk-types.d.ts +3 -3
- package/dist/src/framework/hooks/sdk-types.d.ts.map +1 -1
- package/dist/src/framework/hooks/sdk-types.js.map +1 -1
- package/dist/src/framework/hooks/use-dependencies.d.ts +1 -1
- package/dist/src/framework/hooks/use-dependencies.d.ts.map +1 -1
- package/dist/src/framework/load-static-helpers.d.ts +2 -2
- package/dist/src/framework/load-static-helpers.d.ts.map +1 -1
- package/dist/src/framework/load-static-helpers.js +1 -13
- package/dist/src/framework/load-static-helpers.js.map +1 -1
- package/dist/src/framework/reference.js.map +1 -1
- package/dist/src/framework/source-file-batch.d.ts +1 -1
- package/dist/src/framework/source-file-batch.d.ts.map +1 -1
- package/dist/src/framework/source-file-batch.js +1 -1
- package/dist/src/framework/source-file-batch.js.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +14 -17
- package/dist/src/index.js.map +1 -1
- package/dist/src/interfaces.d.ts +0 -1
- package/dist/src/interfaces.d.ts.map +1 -1
- package/dist/src/lib.d.ts +18 -4
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +22 -6
- package/dist/src/lib.js.map +1 -1
- package/dist/src/meta-tree.d.ts +2 -2
- package/dist/src/meta-tree.d.ts.map +1 -1
- package/dist/src/metadata/build-api-extractor-config.d.ts +1 -1
- package/dist/src/metadata/build-api-extractor-config.d.ts.map +1 -1
- package/dist/src/metadata/build-changelog-file.d.ts +1 -1
- package/dist/src/metadata/build-changelog-file.d.ts.map +1 -1
- package/dist/src/metadata/build-es-lint-config.d.ts +1 -1
- package/dist/src/metadata/build-es-lint-config.d.ts.map +1 -1
- package/dist/src/metadata/build-package-file.d.ts +3 -5
- package/dist/src/metadata/build-package-file.d.ts.map +1 -1
- package/dist/src/metadata/build-package-file.js +10 -45
- package/dist/src/metadata/build-package-file.js.map +1 -1
- package/dist/src/metadata/build-readme-file.d.ts +1 -1
- package/dist/src/metadata/build-readme-file.d.ts.map +1 -1
- package/dist/src/metadata/build-readme-file.js +3 -3
- package/dist/src/metadata/build-readme-file.js.map +1 -1
- package/dist/src/metadata/build-sample-env-file.d.ts +1 -1
- package/dist/src/metadata/build-sample-env-file.d.ts.map +1 -1
- package/dist/src/metadata/build-test-config.d.ts +1 -1
- package/dist/src/metadata/build-test-config.d.ts.map +1 -1
- package/dist/src/metadata/build-ts-config.d.ts +11 -5
- package/dist/src/metadata/build-ts-config.d.ts.map +1 -1
- package/dist/src/metadata/build-ts-config.js +36 -8
- package/dist/src/metadata/build-ts-config.js.map +1 -1
- package/dist/src/metadata/build-vitest-config.d.ts +1 -1
- package/dist/src/metadata/build-vitest-config.d.ts.map +1 -1
- package/dist/src/metadata/build-warp-config.d.ts +1 -3
- package/dist/src/metadata/build-warp-config.d.ts.map +1 -1
- package/dist/src/metadata/build-warp-config.js +0 -2
- package/dist/src/metadata/build-warp-config.js.map +1 -1
- package/dist/src/metadata/package-json/azure-package-common.d.ts +1 -1
- package/dist/src/metadata/package-json/azure-package-common.d.ts.map +1 -1
- package/dist/src/metadata/package-json/build-azure-monorepo-package.d.ts +1 -2
- package/dist/src/metadata/package-json/build-azure-monorepo-package.d.ts.map +1 -1
- package/dist/src/metadata/package-json/build-azure-monorepo-package.js +2 -16
- package/dist/src/metadata/package-json/build-azure-monorepo-package.js.map +1 -1
- package/dist/src/metadata/package-json/package-common.d.ts.map +1 -1
- package/dist/src/metadata/package-json/package-common.js +0 -15
- package/dist/src/metadata/package-json/package-common.js.map +1 -1
- package/dist/src/metadata/test/build-recorded-client.d.ts +1 -1
- package/dist/src/metadata/test/build-recorded-client.d.ts.map +1 -1
- package/dist/src/metadata/test/build-sample-test.d.ts +1 -1
- package/dist/src/metadata/test/build-sample-test.d.ts.map +1 -1
- package/dist/src/metadata/test/build-snippets.d.ts +1 -1
- package/dist/src/metadata/test/build-snippets.d.ts.map +1 -1
- package/dist/src/metadata/utils.d.ts +1 -1
- package/dist/src/metadata/utils.d.ts.map +1 -1
- package/dist/src/modular/build-classical-client.d.ts +3 -3
- package/dist/src/modular/build-classical-client.d.ts.map +1 -1
- package/dist/src/modular/build-classical-client.js +1 -1
- package/dist/src/modular/build-classical-client.js.map +1 -1
- package/dist/src/modular/build-classical-operation-groups.d.ts +3 -3
- package/dist/src/modular/build-classical-operation-groups.d.ts.map +1 -1
- package/dist/src/modular/build-classical-operation-groups.js +1 -0
- package/dist/src/modular/build-classical-operation-groups.js.map +1 -1
- package/dist/src/modular/build-client-context.d.ts +3 -3
- package/dist/src/modular/build-client-context.d.ts.map +1 -1
- package/dist/src/modular/build-client-context.js +1 -0
- package/dist/src/modular/build-client-context.js.map +1 -1
- package/dist/src/modular/build-modular-options.d.ts +2 -2
- package/dist/src/modular/build-modular-options.d.ts.map +1 -1
- package/dist/src/modular/build-operations.d.ts +5 -5
- package/dist/src/modular/build-operations.d.ts.map +1 -1
- package/dist/src/modular/build-operations.js +7 -4
- package/dist/src/modular/build-operations.js.map +1 -1
- package/dist/src/modular/build-project-files.d.ts +2 -2
- package/dist/src/modular/build-project-files.d.ts.map +1 -1
- package/dist/src/modular/build-restore-poller.d.ts +3 -3
- package/dist/src/modular/build-restore-poller.d.ts.map +1 -1
- package/dist/src/modular/build-restore-poller.js +1 -0
- package/dist/src/modular/build-restore-poller.js.map +1 -1
- package/dist/src/modular/build-root-index.d.ts +3 -3
- package/dist/src/modular/build-root-index.d.ts.map +1 -1
- package/dist/src/modular/build-root-index.js +4 -3
- package/dist/src/modular/build-root-index.js.map +1 -1
- package/dist/src/modular/build-subpath-index.d.ts +2 -2
- package/dist/src/modular/build-subpath-index.d.ts.map +1 -1
- package/dist/src/modular/build-subpath-index.js +1 -1
- package/dist/src/modular/build-subpath-index.js.map +1 -1
- package/dist/src/modular/emit-logger-file.d.ts +1 -1
- package/dist/src/modular/emit-logger-file.d.ts.map +1 -1
- package/dist/src/modular/emit-models-options.d.ts +3 -3
- package/dist/src/modular/emit-models-options.d.ts.map +1 -1
- package/dist/src/modular/emit-models-options.js.map +1 -1
- package/dist/src/modular/emit-models.d.ts +3 -3
- package/dist/src/modular/emit-models.d.ts.map +1 -1
- package/dist/src/modular/emit-models.js +1 -1
- package/dist/src/modular/emit-models.js.map +1 -1
- package/dist/src/modular/emit-samples.d.ts +1 -1
- package/dist/src/modular/emit-samples.d.ts.map +1 -1
- package/dist/src/modular/emit-samples.js +1 -1
- package/dist/src/modular/emit-samples.js.map +1 -1
- package/dist/src/modular/emit-tests.d.ts +1 -1
- package/dist/src/modular/emit-tests.d.ts.map +1 -1
- package/dist/src/modular/emit-tests.js +1 -0
- package/dist/src/modular/emit-tests.js.map +1 -1
- package/dist/src/modular/external-dependencies.d.ts +1 -1
- package/dist/src/modular/external-dependencies.d.ts.map +1 -1
- package/dist/src/modular/external-dependencies.js +10 -0
- package/dist/src/modular/external-dependencies.js.map +1 -1
- package/dist/src/modular/helpers/classical-operation-helpers.d.ts +3 -3
- package/dist/src/modular/helpers/classical-operation-helpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/classical-operation-helpers.js +1 -1
- package/dist/src/modular/helpers/classical-operation-helpers.js.map +1 -1
- package/dist/src/modular/helpers/client-helpers.d.ts +6 -6
- package/dist/src/modular/helpers/client-helpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/client-helpers.js +24 -7
- package/dist/src/modular/helpers/client-helpers.js.map +1 -1
- package/dist/src/modular/helpers/client-option-helpers.d.ts +1 -1
- package/dist/src/modular/helpers/client-option-helpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/example-value-helpers.d.ts +3 -3
- package/dist/src/modular/helpers/example-value-helpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/example-value-helpers.js +1 -0
- package/dist/src/modular/helpers/example-value-helpers.js.map +1 -1
- package/dist/src/modular/helpers/naming-helpers.d.ts +7 -4
- package/dist/src/modular/helpers/naming-helpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/naming-helpers.js +44 -5
- package/dist/src/modular/helpers/naming-helpers.js.map +1 -1
- package/dist/src/modular/helpers/operation-helpers.d.ts +7 -7
- package/dist/src/modular/helpers/operation-helpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operation-helpers.js +24 -21
- package/dist/src/modular/helpers/operation-helpers.js.map +1 -1
- package/dist/src/modular/helpers/type-helpers.d.ts +3 -3
- package/dist/src/modular/helpers/type-helpers.d.ts.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/build-deserializer-function.d.ts +4 -4
- package/dist/src/modular/serialization/build-deserializer-function.d.ts.map +1 -1
- package/dist/src/modular/serialization/build-deserializer-function.js.map +1 -1
- package/dist/src/modular/serialization/build-serializer-function.d.ts +4 -4
- package/dist/src/modular/serialization/build-serializer-function.d.ts.map +1 -1
- package/dist/src/modular/serialization/build-serializer-function.js.map +1 -1
- package/dist/src/modular/serialization/build-xml-serializer-function.d.ts +4 -4
- package/dist/src/modular/serialization/build-xml-serializer-function.d.ts.map +1 -1
- package/dist/src/modular/serialization/build-xml-serializer-function.js.map +1 -1
- package/dist/src/modular/serialization/serialize-utils.d.ts +1 -1
- package/dist/src/modular/serialization/serialize-utils.d.ts.map +1 -1
- package/dist/src/modular/static-helpers-metadata.d.ts +0 -12
- package/dist/src/modular/static-helpers-metadata.d.ts.map +1 -1
- package/dist/src/modular/static-helpers-metadata.js +0 -12
- package/dist/src/modular/static-helpers-metadata.js.map +1 -1
- package/dist/src/modular/type-expressions/get-credential-expression.d.ts +1 -1
- package/dist/src/modular/type-expressions/get-credential-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.d.ts +3 -3
- package/dist/src/modular/type-expressions/get-enum-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-model-expression.d.ts +3 -3
- package/dist/src/modular/type-expressions/get-model-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.d.ts +3 -3
- package/dist/src/modular/type-expressions/get-nullable-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.d.ts +2 -2
- package/dist/src/modular/type-expressions/get-type-expression.d.ts.map +1 -1
- package/dist/src/modular/type-expressions/get-union-expression.d.ts +3 -3
- 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/modular/type-expressions/utils.d.ts +1 -1
- package/dist/src/modular/type-expressions/utils.d.ts.map +1 -1
- package/dist/src/transform/transform-api-version-info.d.ts +3 -3
- package/dist/src/transform/transform-api-version-info.d.ts.map +1 -1
- package/dist/src/transform/transform-api-version-info.js +1 -1
- package/dist/src/transform/transform-api-version-info.js.map +1 -1
- package/dist/src/transform/transform-client-options.d.ts +4 -4
- package/dist/src/transform/transform-client-options.d.ts.map +1 -1
- package/dist/src/transform/transform-client-options.js +1 -3
- package/dist/src/transform/transform-client-options.js.map +1 -1
- package/dist/src/transform/transform-helper-function-details.d.ts +3 -3
- package/dist/src/transform/transform-helper-function-details.d.ts.map +1 -1
- package/dist/src/transform/transform-helper-function-details.js +1 -1
- package/dist/src/transform/transform-helper-function-details.js.map +1 -1
- package/dist/src/transform/transform-parameters.d.ts +4 -4
- package/dist/src/transform/transform-parameters.d.ts.map +1 -1
- package/dist/src/transform/transform-parameters.js.map +1 -1
- package/dist/src/transform/transform-paths.d.ts +3 -3
- package/dist/src/transform/transform-paths.d.ts.map +1 -1
- package/dist/src/transform/transform-paths.js +1 -1
- package/dist/src/transform/transform-paths.js.map +1 -1
- package/dist/src/transform/transform-responses.d.ts +3 -3
- package/dist/src/transform/transform-responses.d.ts.map +1 -1
- package/dist/src/transform/transform-responses.js +1 -1
- package/dist/src/transform/transform-responses.js.map +1 -1
- package/dist/src/transform/transform-schemas.d.ts +2 -2
- package/dist/src/transform/transform-schemas.d.ts.map +1 -1
- package/dist/src/transform/transform-schemas.js +2 -2
- package/dist/src/transform/transform-schemas.js.map +1 -1
- package/dist/src/transform/transform-telemetry-info.d.ts +2 -2
- package/dist/src/transform/transform-telemetry-info.d.ts.map +1 -1
- package/dist/src/transform/transform.d.ts +3 -3
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/utils/api-version-util.d.ts +1 -1
- package/dist/src/utils/api-version-util.d.ts.map +1 -1
- package/dist/src/utils/client-utils.d.ts +4 -4
- package/dist/src/utils/client-utils.d.ts.map +1 -1
- package/dist/src/utils/credential-utils.d.ts +3 -3
- package/dist/src/utils/credential-utils.d.ts.map +1 -1
- package/dist/src/utils/credential-utils.js.map +1 -1
- package/dist/src/utils/cross-language-def.d.ts +1 -1
- package/dist/src/utils/cross-language-def.d.ts.map +1 -1
- package/dist/src/utils/emit-util.d.ts +2 -2
- package/dist/src/utils/emit-util.d.ts.map +1 -1
- package/dist/src/utils/emit-util.js +2 -2
- package/dist/src/utils/emit-util.js.map +1 -1
- package/dist/src/utils/file-system-utils.d.ts +1 -1
- package/dist/src/utils/file-system-utils.d.ts.map +1 -1
- package/dist/src/utils/file-system-utils.js.map +1 -1
- package/dist/src/utils/import-helper.js +1 -0
- package/dist/src/utils/import-helper.js.map +1 -1
- package/dist/src/utils/imports-util.d.ts +1 -1
- package/dist/src/utils/imports-util.d.ts.map +1 -1
- package/dist/src/utils/imports-util.js +2 -1
- package/dist/src/utils/imports-util.js.map +1 -1
- package/dist/src/utils/interfaces.d.ts +3 -3
- package/dist/src/utils/interfaces.d.ts.map +1 -1
- package/dist/src/utils/interfaces.js +2 -1
- package/dist/src/utils/interfaces.js.map +1 -1
- package/dist/src/utils/model-utils.d.ts +4 -4
- package/dist/src/utils/model-utils.d.ts.map +1 -1
- package/dist/src/utils/name-constructors.d.ts +1 -1
- package/dist/src/utils/name-constructors.d.ts.map +1 -1
- package/dist/src/utils/namespace-utils.d.ts +2 -2
- package/dist/src/utils/namespace-utils.d.ts.map +1 -1
- package/dist/src/utils/namespace-utils.js +1 -1
- package/dist/src/utils/namespace-utils.js.map +1 -1
- package/dist/src/utils/operation-helpers.d.ts +2 -2
- package/dist/src/utils/operation-helpers.d.ts.map +1 -1
- package/dist/src/utils/operation-helpers.js.map +1 -1
- package/dist/src/utils/operation-util.d.ts +5 -5
- package/dist/src/utils/operation-util.d.ts.map +1 -1
- package/dist/src/utils/operation-util.js +1 -1
- package/dist/src/utils/operation-util.js.map +1 -1
- package/dist/src/utils/parameter-utils.d.ts +3 -3
- package/dist/src/utils/parameter-utils.d.ts.map +1 -1
- package/dist/src/utils/parameter-utils.js.map +1 -1
- package/dist/src/utils/schema-helpers.d.ts +1 -1
- package/dist/src/utils/schema-helpers.d.ts.map +1 -1
- package/dist/src/utils/schema-helpers.js +1 -1
- package/dist/src/utils/schema-helpers.js.map +1 -1
- package/dist/src/utils/type-util.d.ts +1 -1
- package/dist/src/utils/type-util.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -38
- package/src/context-manager.ts +6 -6
- package/src/framework/declaration.ts +7 -6
- package/src/framework/hooks/binder.ts +5 -33
- package/src/framework/hooks/sdk-types.ts +8 -8
- package/src/framework/hooks/use-dependencies.ts +1 -1
- package/src/framework/load-static-helpers.ts +3 -18
- package/src/framework/reference.ts +2 -2
- package/src/framework/sample.ts +2 -2
- package/src/framework/source-file-batch.ts +2 -2
- package/src/index.ts +23 -27
- package/src/interfaces.ts +0 -1
- package/src/lib.ts +43 -11
- package/src/meta-tree.ts +2 -2
- package/src/metadata/build-api-extractor-config.ts +1 -1
- package/src/metadata/build-changelog-file.ts +1 -1
- package/src/metadata/build-es-lint-config.ts +1 -1
- package/src/metadata/build-package-file.ts +11 -49
- package/src/metadata/build-readme-file.ts +4 -4
- package/src/metadata/build-sample-env-file.ts +1 -1
- package/src/metadata/build-test-config.ts +1 -1
- package/src/metadata/build-ts-config.ts +38 -9
- package/src/metadata/build-vitest-config.ts +1 -1
- package/src/metadata/build-warp-config.ts +1 -3
- package/src/metadata/package-json/azure-package-common.ts +1 -1
- package/src/metadata/package-json/build-azure-monorepo-package.ts +3 -20
- package/src/metadata/package-json/package-common.ts +0 -15
- package/src/metadata/test/build-recorded-client.ts +1 -1
- package/src/metadata/test/build-sample-test.ts +1 -1
- package/src/metadata/test/build-snippets.ts +1 -1
- package/src/metadata/utils.ts +1 -1
- package/src/modular/build-classical-client.ts +6 -6
- package/src/modular/build-classical-operation-groups.ts +6 -3
- package/src/modular/build-client-context.ts +3 -3
- package/src/modular/build-modular-options.ts +2 -2
- package/src/modular/build-operations.ts +12 -9
- package/src/modular/build-project-files.ts +2 -2
- package/src/modular/build-restore-poller.ts +6 -3
- package/src/modular/build-root-index.ts +9 -10
- package/src/modular/build-subpath-index.ts +5 -2
- package/src/modular/emit-logger-file.ts +1 -1
- package/src/modular/emit-models-options.ts +6 -3
- package/src/modular/emit-models.ts +23 -33
- package/src/modular/emit-samples.ts +11 -11
- package/src/modular/emit-tests.ts +3 -3
- package/src/modular/external-dependencies.ts +11 -1
- package/src/modular/helpers/classical-operation-helpers.ts +10 -7
- package/src/modular/helpers/client-helpers.ts +36 -19
- package/src/modular/helpers/client-option-helpers.ts +1 -1
- package/src/modular/helpers/example-value-helpers.ts +9 -9
- package/src/modular/helpers/naming-helpers.ts +55 -7
- package/src/modular/helpers/operation-helpers.ts +46 -44
- package/src/modular/helpers/type-helpers.ts +3 -3
- package/src/modular/interfaces.ts +1 -1
- package/src/modular/serialization/build-deserializer-function.ts +9 -9
- package/src/modular/serialization/build-serializer-function.ts +9 -9
- package/src/modular/serialization/build-xml-serializer-function.ts +7 -7
- package/src/modular/serialization/serialize-utils.ts +1 -1
- package/src/modular/static-helpers-metadata.ts +0 -13
- package/src/modular/type-expressions/get-credential-expression.ts +1 -1
- package/src/modular/type-expressions/get-enum-expression.ts +3 -3
- package/src/modular/type-expressions/get-model-expression.ts +3 -3
- package/src/modular/type-expressions/get-nullable-expression.ts +3 -3
- package/src/modular/type-expressions/get-type-expression.ts +2 -2
- package/src/modular/type-expressions/get-union-expression.ts +3 -3
- package/src/modular/type-expressions/utils.ts +1 -1
- package/src/transform/transform-api-version-info.ts +8 -3
- package/src/transform/transform-client-options.ts +5 -7
- package/src/transform/transform-helper-function-details.ts +6 -3
- package/src/transform/transform-parameters.ts +15 -11
- package/src/transform/transform-paths.ts +10 -4
- package/src/transform/transform-responses.ts +11 -8
- package/src/transform/transform-schemas.ts +7 -4
- package/src/transform/transform-telemetry-info.ts +3 -3
- package/src/transform/transform.ts +11 -11
- package/src/utils/api-version-util.ts +1 -1
- package/src/utils/client-utils.ts +8 -8
- package/src/utils/credential-utils.ts +3 -3
- package/src/utils/cross-language-def.ts +1 -1
- package/src/utils/emit-util.ts +9 -3
- package/src/utils/file-system-utils.ts +1 -1
- package/src/utils/imports-util.ts +2 -2
- package/src/utils/interfaces.ts +3 -3
- package/src/utils/model-utils.ts +23 -23
- package/src/utils/name-constructors.ts +1 -1
- package/src/utils/namespace-utils.ts +8 -2
- package/src/utils/operation-helpers.ts +11 -7
- package/src/utils/operation-util.ts +23 -16
- package/src/utils/parameter-utils.ts +4 -4
- package/src/utils/schema-helpers.ts +7 -1
- package/src/utils/type-util.ts +1 -1
- package/static/static-helpers/multipartHelpers.ts +2 -6
- package/static/static-helpers/platform-types-browser.mts +0 -5
- package/static/static-helpers/platform-types-react-native.mts +0 -5
- package/static/static-helpers/platform-types.ts +0 -7
- package/static/static-helpers/serialization/get-binary-stream-response-browser.mts +0 -22
- package/static/static-helpers/serialization/get-binary-stream-response-react-native.mts +0 -1
- package/static/static-helpers/serialization/get-binary-stream-response.ts +0 -22
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
SdkClientType,
|
|
3
|
+
SdkServiceOperation,
|
|
4
|
+
} from "@azure-tools/typespec-client-generator-core";
|
|
2
5
|
import { joinPaths, NoTarget } from "@typespec/compiler";
|
|
3
6
|
import { Project, SourceFile, StructureKind } from "ts-morph";
|
|
4
7
|
import { useContext } from "../context-manager.js";
|
|
@@ -12,19 +15,15 @@ import {
|
|
|
12
15
|
} from "../framework/source-file-batch.js";
|
|
13
16
|
import { reportDiagnostic } from "../lib.js";
|
|
14
17
|
import { getClientModuleInfo } from "../utils/client-utils.js";
|
|
15
|
-
import { SdkContext } from "../utils/interfaces.js";
|
|
18
|
+
import type { SdkContext } from "../utils/interfaces.js";
|
|
16
19
|
import { NameType, normalizeName } from "../utils/name-utils.js";
|
|
17
20
|
import { getMethodHierarchiesMap } from "../utils/operation-util.js";
|
|
18
21
|
import { partitionAndEmitExports } from "./build-subpath-index.js";
|
|
22
|
+
import { AzureCoreDependencies } from "./external-dependencies.js";
|
|
19
23
|
import { getClassicalClientName } from "./helpers/naming-helpers.js";
|
|
20
24
|
import { isLroOnlyOperation } from "./helpers/operation-helpers.js";
|
|
21
|
-
import { ModularEmitterOptions } from "./interfaces.js";
|
|
22
|
-
import {
|
|
23
|
-
CloudSettingHelpers,
|
|
24
|
-
MultipartHelpers,
|
|
25
|
-
PagingHelpers,
|
|
26
|
-
PlatformTypeHelpers,
|
|
27
|
-
} from "./static-helpers-metadata.js";
|
|
25
|
+
import type { ModularEmitterOptions } from "./interfaces.js";
|
|
26
|
+
import { CloudSettingHelpers, MultipartHelpers, PagingHelpers } from "./static-helpers-metadata.js";
|
|
28
27
|
|
|
29
28
|
export function buildRootIndex(
|
|
30
29
|
context: SdkContext,
|
|
@@ -179,7 +178,7 @@ function exportFileContentsType(context: SdkContext, rootIndexFile: SourceFile)
|
|
|
179
178
|
rootIndexFile,
|
|
180
179
|
[
|
|
181
180
|
resolveReference(MultipartHelpers.FileContents),
|
|
182
|
-
resolveReference(
|
|
181
|
+
resolveReference(AzureCoreDependencies["NodeReadableStream"]),
|
|
183
182
|
],
|
|
184
183
|
true,
|
|
185
184
|
);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
SdkClientType,
|
|
3
|
+
SdkServiceOperation,
|
|
4
|
+
} from "@azure-tools/typespec-client-generator-core";
|
|
2
5
|
import { joinPaths } from "@typespec/compiler";
|
|
3
|
-
import { ModularEmitterOptions } from "./interfaces.js";
|
|
6
|
+
import type { ModularEmitterOptions } from "./interfaces.js";
|
|
4
7
|
|
|
5
8
|
import { Node, SourceFile, StructureKind } from "ts-morph";
|
|
6
9
|
import { useContext } from "../context-manager.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext } from "../context-manager.js";
|
|
2
|
-
import { ModularEmitterOptions } from "./interfaces.js";
|
|
2
|
+
import type { ModularEmitterOptions } from "./interfaces.js";
|
|
3
3
|
|
|
4
4
|
export function emitLoggerFile(emitterOptions: ModularEmitterOptions, srcPath: string = "src") {
|
|
5
5
|
const project = useContext("outputProject");
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { joinPaths } from "@typespec/compiler";
|
|
2
2
|
|
|
3
|
-
import { ModularEmitterOptions } from "./interfaces.js";
|
|
3
|
+
import type { ModularEmitterOptions } from "./interfaces.js";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import type {
|
|
6
|
+
SdkClientType,
|
|
7
|
+
SdkServiceOperation,
|
|
8
|
+
} from "@azure-tools/typespec-client-generator-core";
|
|
6
9
|
import { useContext } from "../context-manager.js";
|
|
7
10
|
import { getClientModuleInfo } from "../utils/client-utils.js";
|
|
8
|
-
import { SdkContext } from "../utils/interfaces.js";
|
|
11
|
+
import type { SdkContext } from "../utils/interfaces.js";
|
|
9
12
|
import { NameType, normalizeName } from "../utils/name-utils.js";
|
|
10
13
|
import { getMethodHierarchiesMap } from "../utils/operation-util.js";
|
|
11
14
|
import { buildOperationOptions } from "./build-operations.js";
|
|
@@ -2,31 +2,31 @@ import {
|
|
|
2
2
|
isPagedResultModel,
|
|
3
3
|
isReadOnly,
|
|
4
4
|
listAllServiceNamespaces,
|
|
5
|
-
SdkArrayType,
|
|
6
|
-
SdkClientType,
|
|
7
|
-
SdkDictionaryType,
|
|
8
|
-
SdkEnumType,
|
|
9
|
-
SdkEnumValueType,
|
|
10
|
-
SdkHttpOperation,
|
|
11
|
-
SdkMethod,
|
|
12
|
-
SdkModelPropertyType,
|
|
13
|
-
SdkModelType,
|
|
14
|
-
SdkNullableType,
|
|
15
|
-
SdkServiceMethod,
|
|
16
|
-
SdkServiceOperation,
|
|
17
|
-
SdkType,
|
|
18
|
-
SdkUnionType,
|
|
5
|
+
type SdkArrayType,
|
|
6
|
+
type SdkClientType,
|
|
7
|
+
type SdkDictionaryType,
|
|
8
|
+
type SdkEnumType,
|
|
9
|
+
type SdkEnumValueType,
|
|
10
|
+
type SdkHttpOperation,
|
|
11
|
+
type SdkMethod,
|
|
12
|
+
type SdkModelPropertyType,
|
|
13
|
+
type SdkModelType,
|
|
14
|
+
type SdkNullableType,
|
|
15
|
+
type SdkServiceMethod,
|
|
16
|
+
type SdkServiceOperation,
|
|
17
|
+
type SdkType,
|
|
18
|
+
type SdkUnionType,
|
|
19
19
|
UsageFlags,
|
|
20
20
|
} from "@azure-tools/typespec-client-generator-core";
|
|
21
21
|
import {
|
|
22
|
-
EnumDeclarationStructure,
|
|
23
|
-
EnumMemberStructure,
|
|
24
|
-
InterfaceDeclarationStructure,
|
|
25
|
-
OptionalKind,
|
|
26
|
-
PropertySignatureStructure,
|
|
22
|
+
type EnumDeclarationStructure,
|
|
23
|
+
type EnumMemberStructure,
|
|
24
|
+
type InterfaceDeclarationStructure,
|
|
25
|
+
type OptionalKind,
|
|
26
|
+
type PropertySignatureStructure,
|
|
27
27
|
SourceFile,
|
|
28
28
|
StructureKind,
|
|
29
|
-
TypeAliasDeclarationStructure,
|
|
29
|
+
type TypeAliasDeclarationStructure,
|
|
30
30
|
} from "ts-morph";
|
|
31
31
|
// import { isKey } from "@typespec/compiler";
|
|
32
32
|
import {
|
|
@@ -49,7 +49,7 @@ import { refkey } from "../framework/refkey.js";
|
|
|
49
49
|
import { beginSourceFileBatch, flushSourceFileBatch } from "../framework/source-file-batch.js";
|
|
50
50
|
import { reportDiagnostic } from "../lib.js";
|
|
51
51
|
import { getClientHierarchyMap } from "../utils/client-utils.js";
|
|
52
|
-
import { SdkContext } from "../utils/interfaces.js";
|
|
52
|
+
import type { SdkContext } from "../utils/interfaces.js";
|
|
53
53
|
import { isAzureCoreErrorType } from "../utils/model-utils.js";
|
|
54
54
|
import { fixLeadingNumber, NameType, normalizeName } from "../utils/name-utils.js";
|
|
55
55
|
import { getMethodHierarchiesMap } from "../utils/operation-util.js";
|
|
@@ -95,12 +95,7 @@ type InterfaceStructure = OptionalKind<InterfaceDeclarationStructure> & {
|
|
|
95
95
|
function isGenerableType(
|
|
96
96
|
type: SdkType,
|
|
97
97
|
): type is
|
|
98
|
-
|
|
|
99
|
-
| SdkEnumType
|
|
100
|
-
| SdkUnionType
|
|
101
|
-
| SdkDictionaryType
|
|
102
|
-
| SdkArrayType
|
|
103
|
-
| SdkNullableType {
|
|
98
|
+
SdkModelType | SdkEnumType | SdkUnionType | SdkDictionaryType | SdkArrayType | SdkNullableType {
|
|
104
99
|
return (
|
|
105
100
|
type.kind === "model" ||
|
|
106
101
|
type.kind === "enum" ||
|
|
@@ -808,12 +803,7 @@ export function getAdditionalPropertiesName(context: SdkContext, model: SdkModel
|
|
|
808
803
|
export function normalizeModelName(
|
|
809
804
|
context: SdkContext,
|
|
810
805
|
type:
|
|
811
|
-
|
|
|
812
|
-
| SdkEnumType
|
|
813
|
-
| SdkUnionType
|
|
814
|
-
| SdkArrayType
|
|
815
|
-
| SdkDictionaryType
|
|
816
|
-
| SdkNullableType,
|
|
806
|
+
SdkModelType | SdkEnumType | SdkUnionType | SdkArrayType | SdkDictionaryType | SdkNullableType,
|
|
817
807
|
nameType: NameType = NameType.Interface,
|
|
818
808
|
skipPolymorphicUnionSuffix = false,
|
|
819
809
|
rawModelName?: boolean,
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isReadOnly,
|
|
3
|
-
SdkClientInitializationType,
|
|
4
|
-
SdkClientType,
|
|
5
|
-
SdkExampleValue,
|
|
6
|
-
SdkHttpOperationExample,
|
|
7
|
-
SdkHttpParameterExampleValue,
|
|
8
|
-
SdkModelPropertyType,
|
|
9
|
-
SdkServiceOperation,
|
|
3
|
+
type SdkClientInitializationType,
|
|
4
|
+
type SdkClientType,
|
|
5
|
+
type SdkExampleValue,
|
|
6
|
+
type SdkHttpOperationExample,
|
|
7
|
+
type SdkHttpParameterExampleValue,
|
|
8
|
+
type SdkModelPropertyType,
|
|
9
|
+
type SdkServiceOperation,
|
|
10
10
|
} from "@azure-tools/typespec-client-generator-core";
|
|
11
11
|
import { joinPaths, NoTarget } from "@typespec/compiler";
|
|
12
|
-
import { FunctionDeclarationStructure, SourceFile, StructureKind } from "ts-morph";
|
|
12
|
+
import { type FunctionDeclarationStructure, SourceFile, StructureKind } from "ts-morph";
|
|
13
13
|
import { useContext } from "../context-manager.js";
|
|
14
14
|
import { resolveReference } from "../framework/reference.js";
|
|
15
15
|
import { reportDiagnostic } from "../index.js";
|
|
16
16
|
import { AzureIdentityDependencies } from "../modular/external-dependencies.js";
|
|
17
17
|
import { getSubscriptionId } from "../transform/transform-client-options.js";
|
|
18
18
|
import { hasKeyCredential, hasTokenCredential } from "../utils/credential-utils.js";
|
|
19
|
-
import { SdkContext } from "../utils/interfaces.js";
|
|
19
|
+
import type { SdkContext } from "../utils/interfaces.js";
|
|
20
20
|
import { NameType, normalizeName } from "../utils/name-utils.js";
|
|
21
21
|
import {
|
|
22
22
|
getMethodHierarchiesMap,
|
|
23
23
|
isTenantLevelOperation,
|
|
24
|
-
ServiceOperation,
|
|
24
|
+
type ServiceOperation,
|
|
25
25
|
} from "../utils/operation-util.js";
|
|
26
26
|
import {
|
|
27
27
|
getClientParameterName,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import { getClassicalClientName } from "./helpers/naming-helpers.js";
|
|
33
33
|
import { getOperationFunction } from "./helpers/operation-helpers.js";
|
|
34
34
|
import { buildPropertyNameMapper, isSpreadBodyParameter } from "./helpers/type-helpers.js";
|
|
35
|
-
import { ModelOverrideOptions } from "./serialization/serialize-utils.js";
|
|
35
|
+
import type { ModelOverrideOptions } from "./serialization/serialize-utils.js";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Interfaces for samples generations
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type CompilerHost, joinPaths } from "@typespec/compiler";
|
|
2
2
|
import { SourceFile } from "ts-morph";
|
|
3
3
|
import { resolveReference } from "../framework/reference.js";
|
|
4
|
-
import { SdkContext } from "../utils/interfaces.js";
|
|
4
|
+
import type { SdkContext } from "../utils/interfaces.js";
|
|
5
5
|
import { NameType, normalizeName } from "../utils/name-utils.js";
|
|
6
|
-
import { ServiceOperation } from "../utils/operation-util.js";
|
|
6
|
+
import type { ServiceOperation } from "../utils/operation-util.js";
|
|
7
7
|
import { AzureTestDependencies } from "./external-dependencies.js";
|
|
8
8
|
import {
|
|
9
9
|
buildParameterValueMap,
|
|
10
|
-
ClientEmitOptions,
|
|
10
|
+
type ClientEmitOptions,
|
|
11
11
|
createSourceFile,
|
|
12
12
|
generateMethodCall,
|
|
13
13
|
generateResponseAssertions,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoreDependencies } from "../framework/dependency.js";
|
|
1
|
+
import type { CoreDependencies } from "../framework/dependency.js";
|
|
2
2
|
|
|
3
3
|
export const DefaultCoreDependencies: CoreDependencies = {
|
|
4
4
|
Client: {
|
|
@@ -207,6 +207,16 @@ export const AzureCoreDependencies: CoreDependencies = {
|
|
|
207
207
|
name: "ErrorResponse",
|
|
208
208
|
module: "@azure-rest/core-client",
|
|
209
209
|
},
|
|
210
|
+
getBinaryStreamResponse: {
|
|
211
|
+
kind: "externalDependency",
|
|
212
|
+
module: "@azure-rest/core-client",
|
|
213
|
+
name: "getBinaryStreamResponse",
|
|
214
|
+
},
|
|
215
|
+
NodeReadableStream: {
|
|
216
|
+
kind: "externalDependency",
|
|
217
|
+
module: "@azure/core-rest-pipeline",
|
|
218
|
+
name: "NodeReadableStream",
|
|
219
|
+
},
|
|
210
220
|
};
|
|
211
221
|
|
|
212
222
|
export const AzureIdentityDependencies = {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
SdkClientType,
|
|
3
|
+
SdkServiceOperation,
|
|
4
|
+
} from "@azure-tools/typespec-client-generator-core";
|
|
2
5
|
import {
|
|
3
|
-
FunctionDeclarationStructure,
|
|
4
|
-
InterfaceDeclarationStructure,
|
|
5
|
-
OptionalKind,
|
|
6
|
-
PropertySignatureStructure,
|
|
6
|
+
type FunctionDeclarationStructure,
|
|
7
|
+
type InterfaceDeclarationStructure,
|
|
8
|
+
type OptionalKind,
|
|
9
|
+
type PropertySignatureStructure,
|
|
7
10
|
SourceFile,
|
|
8
11
|
StructureKind,
|
|
9
12
|
} from "ts-morph";
|
|
@@ -11,9 +14,9 @@ import { addDeclaration } from "../../framework/declaration.js";
|
|
|
11
14
|
import { resolveReference } from "../../framework/reference.js";
|
|
12
15
|
import { refkey } from "../../framework/refkey.js";
|
|
13
16
|
import { getClientModuleInfo } from "../../utils/client-utils.js";
|
|
14
|
-
import { SdkContext } from "../../utils/interfaces.js";
|
|
17
|
+
import type { SdkContext } from "../../utils/interfaces.js";
|
|
15
18
|
import { NameType, normalizeName } from "../../utils/name-utils.js";
|
|
16
|
-
import { ServiceOperation } from "../../utils/operation-util.js";
|
|
19
|
+
import type { ServiceOperation } from "../../utils/operation-util.js";
|
|
17
20
|
import { AzurePollingDependencies } from "../external-dependencies.js";
|
|
18
21
|
import { PagingHelpers, SimplePollerHelpers } from "../static-helpers-metadata.js";
|
|
19
22
|
import { getClassicalLayerPrefix } from "./naming-helpers.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
SdkClientType,
|
|
3
3
|
SdkCredentialParameter,
|
|
4
4
|
SdkEndpointParameter,
|
|
@@ -6,11 +6,16 @@ import {
|
|
|
6
6
|
SdkMethodParameter,
|
|
7
7
|
SdkServiceOperation,
|
|
8
8
|
} from "@azure-tools/typespec-client-generator-core";
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
Node,
|
|
11
|
+
type OptionalKind,
|
|
12
|
+
type ParameterDeclarationStructure,
|
|
13
|
+
StatementedNode,
|
|
14
|
+
} from "ts-morph";
|
|
15
|
+
import type { ModularEmitterOptions } from "../interfaces.js";
|
|
11
16
|
|
|
12
17
|
import { resolveReference } from "../../framework/reference.js";
|
|
13
|
-
import { SdkContext } from "../../utils/interfaces.js";
|
|
18
|
+
import type { SdkContext } from "../../utils/interfaces.js";
|
|
14
19
|
import { NameType, normalizeName } from "../../utils/name-utils.js";
|
|
15
20
|
import { CloudSettingHelpers } from "../static-helpers-metadata.js";
|
|
16
21
|
import { getTypeExpression } from "../type-expressions/get-type-expression.js";
|
|
@@ -27,10 +32,7 @@ interface ClientParameterOptions {
|
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
type SdkParameter =
|
|
30
|
-
|
|
|
31
|
-
| SdkEndpointParameter
|
|
32
|
-
| SdkCredentialParameter
|
|
33
|
-
| SdkHttpParameter;
|
|
35
|
+
SdkMethodParameter | SdkEndpointParameter | SdkCredentialParameter | SdkHttpParameter;
|
|
34
36
|
|
|
35
37
|
export function hasDefaultValue(p: SdkParameter) {
|
|
36
38
|
if (p.clientDefaultValue || p.__raw?.defaultValue || p.type.kind === "constant") {
|
|
@@ -236,7 +238,7 @@ export function buildGetClientEndpointParam(
|
|
|
236
238
|
* @returns - an expression representing the options to be passed in to getClient
|
|
237
239
|
*/
|
|
238
240
|
export function buildGetClientOptionsParam(
|
|
239
|
-
context: StatementedNode,
|
|
241
|
+
context: StatementedNode & Node,
|
|
240
242
|
emitterOptions: ModularEmitterOptions,
|
|
241
243
|
endpointParam: string,
|
|
242
244
|
apiVersionParamName?: string,
|
|
@@ -319,23 +321,38 @@ function buildLoggingOptions(): string | undefined {
|
|
|
319
321
|
* Core telemetry policy: https://azure.github.io/azure-sdk/general_azurecore.html#telemetry-policy
|
|
320
322
|
*/
|
|
321
323
|
export function buildUserAgentOptions(
|
|
322
|
-
context: StatementedNode,
|
|
324
|
+
context: StatementedNode & Node,
|
|
323
325
|
emitterOptions: ModularEmitterOptions,
|
|
324
326
|
): string {
|
|
325
327
|
const userAgentStatements = [];
|
|
326
328
|
const prefixFromOptions = "const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;";
|
|
327
329
|
userAgentStatements.push(prefixFromOptions);
|
|
328
330
|
|
|
331
|
+
const packageName = emitterOptions.options.packageDetails?.name;
|
|
329
332
|
const clientPackageName =
|
|
330
|
-
emitterOptions.options.packageDetails?.nameWithoutScope ??
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
333
|
+
emitterOptions.options.packageDetails?.nameWithoutScope ?? packageName ?? "";
|
|
334
|
+
|
|
335
|
+
// The version is read from the generated package.json at runtime rather than
|
|
336
|
+
// hardcoded here: once the package is generated, its version is owned by
|
|
337
|
+
// package.json. We import it via the package's own "./package.json" export so
|
|
338
|
+
// the specifier is identical in `src` and the built `dist` output.
|
|
339
|
+
let userAgentInfoStatement = "";
|
|
340
|
+
if (clientPackageName && packageName) {
|
|
341
|
+
const packageJsonModule = `${packageName}/package.json`;
|
|
342
|
+
const sourceFile = context.getSourceFile();
|
|
343
|
+
const hasPackageJsonImport = sourceFile
|
|
344
|
+
.getImportDeclarations()
|
|
345
|
+
.some((declaration) => declaration.getModuleSpecifierValue() === packageJsonModule);
|
|
346
|
+
if (!hasPackageJsonImport) {
|
|
347
|
+
sourceFile.addImportDeclaration({
|
|
348
|
+
defaultImport: "pkgJson",
|
|
349
|
+
moduleSpecifier: packageJsonModule,
|
|
350
|
+
attributes: [{ name: "type", value: "json" }],
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
userAgentInfoStatement =
|
|
354
|
+
"const userAgentInfo = `azsdk-js-" + clientPackageName + "/${pkgJson.version}`;";
|
|
355
|
+
}
|
|
339
356
|
|
|
340
357
|
if (!userAgentInfoStatement) {
|
|
341
358
|
// Without package name/version we cannot build a meaningful telemetry token,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DecoratedType, SdkModelType } from "@azure-tools/typespec-client-generator-core";
|
|
1
|
+
import type { DecoratedType, SdkModelType } from "@azure-tools/typespec-client-generator-core";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Represents a header-to-property mapping from @clientOption("header", ...).
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isReadOnly,
|
|
3
|
-
SdkClientInitializationType,
|
|
4
|
-
SdkClientType,
|
|
5
|
-
SdkExampleValue,
|
|
6
|
-
SdkHttpOperationExample,
|
|
7
|
-
SdkHttpParameterExampleValue,
|
|
8
|
-
SdkModelPropertyType,
|
|
9
|
-
SdkServiceOperation,
|
|
3
|
+
type SdkClientInitializationType,
|
|
4
|
+
type SdkClientType,
|
|
5
|
+
type SdkExampleValue,
|
|
6
|
+
type SdkHttpOperationExample,
|
|
7
|
+
type SdkHttpParameterExampleValue,
|
|
8
|
+
type SdkModelPropertyType,
|
|
9
|
+
type SdkServiceOperation,
|
|
10
10
|
} from "@azure-tools/typespec-client-generator-core";
|
|
11
11
|
import { joinPaths } from "@typespec/compiler";
|
|
12
12
|
import { SourceFile } from "ts-morph";
|
|
@@ -14,9 +14,9 @@ import { useContext } from "../../context-manager.js";
|
|
|
14
14
|
import { resolveReference } from "../../framework/reference.js";
|
|
15
15
|
import { getSubscriptionId } from "../../transform/transform-client-options.js";
|
|
16
16
|
import { hasKeyCredential, hasTokenCredential } from "../../utils/credential-utils.js";
|
|
17
|
-
import { SdkContext } from "../../utils/interfaces.js";
|
|
17
|
+
import type { SdkContext } from "../../utils/interfaces.js";
|
|
18
18
|
import { NameType, normalizeName } from "../../utils/name-utils.js";
|
|
19
|
-
import { getMethodHierarchiesMap, ServiceOperation } from "../../utils/operation-util.js";
|
|
19
|
+
import { getMethodHierarchiesMap, type ServiceOperation } from "../../utils/operation-util.js";
|
|
20
20
|
import { AzureIdentityDependencies, AzureTestDependencies } from "../external-dependencies.js";
|
|
21
21
|
import { getClientParametersDeclaration } from "./client-helpers.js";
|
|
22
22
|
import { getClassicalClientName } from "./naming-helpers.js";
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
getClientNameOverride,
|
|
3
|
+
type SdkClientType,
|
|
4
|
+
type SdkServiceOperation,
|
|
5
|
+
} from "@azure-tools/typespec-client-generator-core";
|
|
6
|
+
import pluralize from "pluralize";
|
|
7
|
+
import type { SdkContext } from "../../utils/interfaces.js";
|
|
3
8
|
import { NameType, normalizeName, ReservedModelNames } from "../../utils/name-utils.js";
|
|
4
|
-
import { ServiceOperation } from "../../utils/operation-util.js";
|
|
9
|
+
import type { ServiceOperation } from "../../utils/operation-util.js";
|
|
5
10
|
|
|
6
11
|
export function getClientName(client: SdkClientType<SdkServiceOperation>): string {
|
|
7
12
|
return client.name.replace(/Client$/, "");
|
|
@@ -12,19 +17,47 @@ export function getClassicalClientName(client: SdkClientType<SdkServiceOperation
|
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
export interface GuardedName {
|
|
20
|
+
/** The name used for the generated API-layer function (e.g. `deleteConversation`). */
|
|
15
21
|
name: string;
|
|
22
|
+
/** The name used for the public method exposed on clients and operation groups. */
|
|
23
|
+
propertyName: string;
|
|
16
24
|
fixme?: string[];
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
export function getOperationName(
|
|
20
28
|
operation: ServiceOperation,
|
|
21
29
|
dpgContext?: SdkContext,
|
|
30
|
+
prefixes: string[] = [],
|
|
22
31
|
): GuardedName {
|
|
23
|
-
const
|
|
32
|
+
const name = normalizeName(operation.name, NameType.Method, true);
|
|
33
|
+
const propertyName = normalizeName(operation.name, NameType.Property);
|
|
24
34
|
const isDataplane = dpgContext !== undefined && !dpgContext.emitterOptions?.azureArm;
|
|
25
|
-
|
|
35
|
+
// An explicit `@clientName` override is an intentional naming choice by the user, so we
|
|
36
|
+
// honor it verbatim and skip the reserved-word disambiguation (and its `@fixme`). The
|
|
37
|
+
// public method keeps the reserved word (e.g. `delete`), while the generated API-layer
|
|
38
|
+
// function stays guarded (e.g. `$delete`) because a reserved word is not a valid function
|
|
39
|
+
// binding in JavaScript.
|
|
40
|
+
const hasClientNameOverride =
|
|
41
|
+
dpgContext !== undefined &&
|
|
42
|
+
operation.__raw !== undefined &&
|
|
43
|
+
getClientNameOverride(dpgContext, operation.__raw) !== undefined;
|
|
44
|
+
if (isReservedName(operation.name, NameType.Method) && isDataplane && !hasClientNameOverride) {
|
|
45
|
+
const suffix = getReservedNameGroupSuffix(prefixes);
|
|
46
|
+
if (suffix) {
|
|
47
|
+
// Disambiguate the reserved word by suffixing the singularized operation group
|
|
48
|
+
// name, e.g. `delete` in the `Conversations` group becomes `deleteConversation`.
|
|
49
|
+
const disambiguated = normalizeName(`${operation.name}_${suffix}`, NameType.Method);
|
|
50
|
+
return {
|
|
51
|
+
name: disambiguated,
|
|
52
|
+
propertyName: disambiguated,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// There is no operation group to disambiguate the reserved word with (e.g. a top-level
|
|
56
|
+
// operation), so keep the guarded name (e.g. `$delete`) and surface a fixme asking the
|
|
57
|
+
// user to override the generated name.
|
|
26
58
|
return {
|
|
27
|
-
name
|
|
59
|
+
name,
|
|
60
|
+
propertyName,
|
|
28
61
|
fixme: [
|
|
29
62
|
`${operation.name} is a reserved word that cannot be used as an operation name.
|
|
30
63
|
Please add @clientName("clientName") or @clientName("<JS-Specific-Name>", "javascript")
|
|
@@ -33,10 +66,25 @@ export function getOperationName(
|
|
|
33
66
|
};
|
|
34
67
|
}
|
|
35
68
|
return {
|
|
36
|
-
name
|
|
69
|
+
name,
|
|
70
|
+
propertyName,
|
|
37
71
|
};
|
|
38
72
|
}
|
|
39
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Builds the suffix used to disambiguate a reserved-word operation name from the
|
|
76
|
+
* operation group it belongs to. The innermost operation group name is singularized
|
|
77
|
+
* so that, for example, the `Conversations` group yields `Conversation`.
|
|
78
|
+
*/
|
|
79
|
+
function getReservedNameGroupSuffix(prefixes: string[]): string | undefined {
|
|
80
|
+
const groups = prefixes.filter((prefix) => prefix && prefix.length > 0);
|
|
81
|
+
const innermostGroup = groups[groups.length - 1];
|
|
82
|
+
if (!innermostGroup) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
return pluralize.singular(normalizeName(innermostGroup, NameType.Interface));
|
|
86
|
+
}
|
|
87
|
+
|
|
40
88
|
export function isReservedName(name: string, nameType: NameType): boolean {
|
|
41
89
|
return ReservedModelNames.some(
|
|
42
90
|
(reservedName) =>
|