@azure-tools/typespec-ts 0.56.0-dev.8 → 0.56.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 +43 -0
- package/README.md +31 -15
- package/dist/src/context-manager.d.ts +23 -6
- package/dist/src/context-manager.d.ts.map +1 -1
- package/dist/src/context-manager.js +22 -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 +12 -3
- package/dist/src/framework/hooks/sdk-types.d.ts.map +1 -1
- package/dist/src/framework/hooks/sdk-types.js +13 -0
- 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 +24 -19
- 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 +3 -3
- 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 +11 -6
- package/dist/src/modular/helpers/client-helpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/client-helpers.js +38 -17
- 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 +32 -30
- 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 +43 -40
- package/src/context-manager.ts +29 -6
- package/src/framework/declaration.ts +7 -6
- package/src/framework/hooks/binder.ts +5 -33
- package/src/framework/hooks/sdk-types.ts +22 -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 +34 -29
- 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 +8 -12
- 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 +52 -32
- 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 +56 -54
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-tools/typespec-ts",
|
|
3
|
-
"version": "0.56.0
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "A TypeSpec emitter for TypeScript",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,50 +17,53 @@
|
|
|
17
17
|
"author": "Jose Heredia <joheredi@microsoft.com>",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@azure-rest/core-client": "^2.
|
|
21
|
-
"@typespec/http-specs": "^0.1.0-alpha.38 || >=0.1.0-alpha.39-dev <0.1.0-alpha.39",
|
|
22
|
-
"@typespec/spector": "^0.1.0-alpha.25 || >=0.1.0-alpha.26-dev <0.1.0-alpha.26",
|
|
23
|
-
"@typespec/spec-api": "^0.1.0-alpha.14 || >=0.1.0-alpha.15-dev <0.1.0-alpha.15",
|
|
24
|
-
"@typespec/tspd": "^0.75.0 || >=0.76.0-dev <0.76.0",
|
|
25
|
-
"@azure-tools/azure-http-specs": "^0.1.0-alpha.42 || >=0.1.0-alpha.43-dev <0.1.0-alpha.43",
|
|
26
|
-
"@azure-tools/typespec-autorest": "^0.69.1 || >=0.70.0-dev <0.70.0",
|
|
27
|
-
"@azure-tools/typespec-azure-core": "^0.69.0 || >=0.70.0-dev <0.70.0",
|
|
28
|
-
"@azure-tools/typespec-azure-resource-manager": "^0.69.1 || >=0.70.0-dev <0.70.0",
|
|
29
|
-
"@azure-tools/typespec-client-generator-core": "^0.69.1 || >=0.70.0-dev <0.70.0",
|
|
20
|
+
"@azure-rest/core-client": "^2.7.0",
|
|
30
21
|
"@azure/abort-controller": "^2.1.2",
|
|
31
22
|
"@azure/core-auth": "^1.6.0",
|
|
32
23
|
"@azure/core-lro": "^3.1.0",
|
|
33
24
|
"@azure/core-paging": "^1.5.0",
|
|
34
|
-
"@azure/core-rest-pipeline": "^1.
|
|
25
|
+
"@azure/core-rest-pipeline": "^1.24.0",
|
|
35
26
|
"@azure/core-util": "^1.4.0",
|
|
36
27
|
"@azure/logger": "^1.0.4",
|
|
37
|
-
"@typespec/
|
|
38
|
-
"@typespec/http": "^1.13.0",
|
|
39
|
-
"@typespec/openapi": "^1.13.0",
|
|
40
|
-
"@typespec/rest": "^0.83.0 || >=0.84.0-dev <0.84.0",
|
|
41
|
-
"@typespec/versioning": "^0.83.0 || >=0.84.0-dev <0.84.0",
|
|
42
|
-
"@typespec/xml": "^0.83.0 || >=0.84.0-dev <0.84.0",
|
|
43
|
-
"@typespec/ts-http-runtime": "0.3.6",
|
|
28
|
+
"@typespec/ts-http-runtime": "0.3.7",
|
|
44
29
|
"cross-env": "^10.1.0",
|
|
45
|
-
"concurrently": "^10.0.
|
|
30
|
+
"concurrently": "^10.0.4",
|
|
46
31
|
"vitest": "^4.1.3",
|
|
47
|
-
"vite": "^8.
|
|
32
|
+
"vite": "^8.1.2",
|
|
48
33
|
"@vitest/coverage-v8": "^4.1.3",
|
|
49
34
|
"@microsoft/api-extractor": "^7.58.1",
|
|
50
|
-
"
|
|
35
|
+
"@types/pluralize": "^0.0.33",
|
|
36
|
+
"yaml": "^2.8.3",
|
|
37
|
+
"@azure-tools/spector-runner": "^0.1.0",
|
|
38
|
+
"@typespec/spector": "^0.1.0-alpha.28",
|
|
39
|
+
"@typespec/http-specs": "^0.1.0-alpha.41",
|
|
40
|
+
"@typespec/spec-api": "^0.1.0-alpha.16",
|
|
41
|
+
"@azure-tools/azure-http-specs": "^0.1.0-alpha.44",
|
|
42
|
+
"@typespec/tspd": "^0.77.0",
|
|
43
|
+
"@azure-tools/typespec-azure-core": "^0.71.0",
|
|
44
|
+
"@azure-tools/typespec-client-generator-core": "^0.71.0",
|
|
45
|
+
"@azure-tools/typespec-autorest": "^0.71.0",
|
|
46
|
+
"@typespec/compiler": "^1.15.0",
|
|
47
|
+
"@typespec/http": "^1.15.0",
|
|
48
|
+
"@typespec/openapi": "^1.15.0",
|
|
49
|
+
"@azure-tools/typespec-azure-resource-manager": "^0.71.0",
|
|
50
|
+
"@typespec/versioning": "^0.85.0",
|
|
51
|
+
"@typespec/xml": "^0.85.0",
|
|
52
|
+
"@typespec/rest": "^0.85.0"
|
|
51
53
|
},
|
|
52
54
|
"peerDependencies": {
|
|
53
|
-
"@azure-tools/typespec-azure-core": "^0.
|
|
54
|
-
"@
|
|
55
|
-
"@typespec/
|
|
56
|
-
"@typespec
|
|
57
|
-
"@typespec/rest": "^0.
|
|
58
|
-
"@typespec/versioning": "^0.
|
|
59
|
-
"@typespec/xml": "^0.
|
|
55
|
+
"@azure-tools/typespec-azure-core": "^0.71.0",
|
|
56
|
+
"@typespec/compiler": "^1.15.0",
|
|
57
|
+
"@typespec/http": "^1.15.0",
|
|
58
|
+
"@azure-tools/typespec-client-generator-core": "^0.71.0",
|
|
59
|
+
"@typespec/rest": "^0.85.0",
|
|
60
|
+
"@typespec/versioning": "^0.85.0",
|
|
61
|
+
"@typespec/xml": "^0.85.0"
|
|
60
62
|
},
|
|
61
63
|
"dependencies": {
|
|
62
|
-
"fast-xml-parser": "^5.
|
|
63
|
-
"
|
|
64
|
+
"fast-xml-parser": "^5.10.1",
|
|
65
|
+
"pluralize": "^8.0.0",
|
|
66
|
+
"prettier": "^3.9.5",
|
|
64
67
|
"ts-morph": "^23.0.0",
|
|
65
68
|
"tslib": "^2.3.1"
|
|
66
69
|
},
|
|
@@ -85,23 +88,23 @@
|
|
|
85
88
|
"test-next:coverage": "vitest run --project test-next --coverage",
|
|
86
89
|
"clean": "rimraf ./dist ./typespec-output",
|
|
87
90
|
"build": "tsc -p .",
|
|
88
|
-
"test": "
|
|
89
|
-
"lint": "
|
|
90
|
-
"lint:fix": "
|
|
91
|
+
"test": "pnpm test-next && pnpm unit-test && pnpm integration-test-ci",
|
|
92
|
+
"lint": "oxlint . --deny-warnings",
|
|
93
|
+
"lint:fix": "oxlint . --fix",
|
|
91
94
|
"check:tree": "node ./test/commands/check-clean-tree.ts",
|
|
92
|
-
"integration-test-ci": "
|
|
93
|
-
"spector-test": "concurrently --kill-others --success first \"
|
|
95
|
+
"integration-test-ci": "pnpm copy:typespec && pnpm spector-test",
|
|
96
|
+
"spector-test": "concurrently --kill-others --success first \"pnpm start-test-server\" \"pnpm generate-and-run\"",
|
|
94
97
|
"start-test-server": "node ./test/commands/start-test-server.js",
|
|
95
98
|
"copy:typespec": "node ./test/commands/copy-typespec.ts",
|
|
96
|
-
"generate-and-run": "
|
|
99
|
+
"generate-and-run": "pnpm generate-tsp-only:client && concurrently --kill-others-on-fail \"pnpm integration-test:alone\" \"pnpm generate-tsp-only:declarations\" && pnpm stop-test-server",
|
|
97
100
|
"generate-tsp-only": "node ./test/commands/gen-spector.js",
|
|
98
101
|
"generate-tsp-only:client": "node ./test/commands/gen-spector.js --phase=client",
|
|
99
102
|
"generate-tsp-only:declarations": "node ./test/commands/gen-spector.js --phase=declarations",
|
|
100
|
-
"regen-test-baselines": "
|
|
103
|
+
"regen-test-baselines": "pnpm generate-tsp-only",
|
|
101
104
|
"integration-test:alone": "vitest run --project integration-azure-modular",
|
|
102
|
-
"stop-test-server": "
|
|
105
|
+
"stop-test-server": "pnpm exec tsp-spector server stop -p 3002",
|
|
103
106
|
"unit-test": "cross-env NODE_OPTIONS=--max-old-space-size=1024 vitest run --project unit-modular",
|
|
104
107
|
"gen:scenario-suites": "node ./test/commands/gen-scenario-suites.ts",
|
|
105
|
-
"regen-docs": "
|
|
108
|
+
"regen-docs": "pnpm build && tspd doc . --enable-experimental --output-dir ../../website/src/content/docs/docs/emitters/clients/typespec-ts/reference --skip-js"
|
|
106
109
|
}
|
|
107
110
|
}
|
package/src/context-manager.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { SdkContext } from "@azure-tools/typespec-client-generator-core";
|
|
2
|
-
import { EmitContext } from "@typespec/compiler";
|
|
1
|
+
import type { SdkContext } from "@azure-tools/typespec-client-generator-core";
|
|
2
|
+
import type { EmitContext } from "@typespec/compiler";
|
|
3
3
|
import { Project, SourceFile } from "ts-morph";
|
|
4
|
-
import { ExternalDependencies } from "./framework/dependency.js";
|
|
5
|
-
import { Binder } from "./framework/hooks/binder.js";
|
|
6
|
-
import { SdkTypeContext } from "./framework/hooks/sdk-types.js";
|
|
7
|
-
import { ClientTypeMetaTree } from "./meta-tree.js";
|
|
4
|
+
import type { ExternalDependencies } from "./framework/dependency.js";
|
|
5
|
+
import type { Binder } from "./framework/hooks/binder.js";
|
|
6
|
+
import type { SdkTypeContext } from "./framework/hooks/sdk-types.js";
|
|
7
|
+
import type { ClientTypeMetaTree } from "./meta-tree.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Contexts Object Guidelines
|
|
@@ -72,6 +72,19 @@ class ContextManager {
|
|
|
72
72
|
public getContext<K extends ContextKey>(key: K): Contexts[K] | undefined {
|
|
73
73
|
return this.contexts.get(key) as Contexts[K] | undefined;
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Clears all stored contexts.
|
|
78
|
+
*
|
|
79
|
+
* The manager is a process-wide singleton, so the values provided during an
|
|
80
|
+
* emit (the `EmitContext`/`Program`, the TCGC `SdkContext`, the ts-morph
|
|
81
|
+
* `Project`, etc.) stay reachable from this map until the next emit overwrites
|
|
82
|
+
* them. Clearing at the end of an emit lets the whole previous program graph
|
|
83
|
+
* be collected instead of being retained until the following emit.
|
|
84
|
+
*/
|
|
85
|
+
public clearContexts(): void {
|
|
86
|
+
this.contexts.clear();
|
|
87
|
+
}
|
|
75
88
|
}
|
|
76
89
|
|
|
77
90
|
// Expose the singleton instance of the context manager.
|
|
@@ -99,3 +112,13 @@ export function useContext<K extends ContextKey>(key: K): Contexts[K] {
|
|
|
99
112
|
export function provideContext<K extends ContextKey>(key: K, value: Contexts[K]): void {
|
|
100
113
|
contextManager.setContext(key, value);
|
|
101
114
|
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Clears all contexts held by the singleton context manager. Call this once an
|
|
118
|
+
* emit has finished writing its output so the retained program graph (compiler
|
|
119
|
+
* `EmitContext`/`Program`, TCGC `SdkContext`, ts-morph `Project`, binder, …) can
|
|
120
|
+
* be garbage collected instead of lingering until the next emit overwrites it.
|
|
121
|
+
*/
|
|
122
|
+
export function clearContexts(): void {
|
|
123
|
+
contextManager.clearContexts();
|
|
124
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClassDeclaration,
|
|
3
|
-
ClassDeclarationStructure,
|
|
3
|
+
type ClassDeclarationStructure,
|
|
4
4
|
EnumDeclaration,
|
|
5
|
-
EnumDeclarationStructure,
|
|
5
|
+
type EnumDeclarationStructure,
|
|
6
6
|
FunctionDeclaration,
|
|
7
|
-
FunctionDeclarationStructure,
|
|
7
|
+
type FunctionDeclarationStructure,
|
|
8
8
|
InterfaceDeclaration,
|
|
9
|
-
InterfaceDeclarationStructure,
|
|
9
|
+
type InterfaceDeclarationStructure,
|
|
10
10
|
SourceFile,
|
|
11
|
-
StatementStructures,
|
|
11
|
+
type StatementStructures,
|
|
12
12
|
StructureKind,
|
|
13
13
|
TypeAliasDeclaration,
|
|
14
|
-
TypeAliasDeclarationStructure,
|
|
14
|
+
type TypeAliasDeclarationStructure,
|
|
15
15
|
} from "ts-morph";
|
|
16
16
|
import { useBinder } from "./hooks/binder.js";
|
|
17
17
|
import { refkey as getRefKey } from "./refkey.js";
|
|
@@ -81,6 +81,7 @@ export function addDeclaration(
|
|
|
81
81
|
|
|
82
82
|
// Update the declaration name to be unique
|
|
83
83
|
const trackedDeclaration = { ...declaration, name: trackedDeclarationName };
|
|
84
|
+
trackedDeclaration.leadingTrivia ??= "\n";
|
|
84
85
|
|
|
85
86
|
// Skip empty type aliases (they have no body to emit). Done before
|
|
86
87
|
// dispatching so behaviour is identical whether batching or not.
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { joinPaths, normalizePath } from "@typespec/compiler";
|
|
2
2
|
import {
|
|
3
|
-
ImportDeclarationStructure,
|
|
4
|
-
ImportSpecifierStructure,
|
|
3
|
+
type ImportDeclarationStructure,
|
|
4
|
+
type ImportSpecifierStructure,
|
|
5
5
|
Project,
|
|
6
6
|
SourceFile,
|
|
7
7
|
StructureKind,
|
|
8
8
|
} from "ts-morph";
|
|
9
9
|
import { provideContext, useContext } from "../../context-manager.js";
|
|
10
10
|
import { generateLocallyUniqueName } from "../../modular/helpers/naming-helpers.js";
|
|
11
|
-
import { ReferenceableSymbol } from "../dependency.js";
|
|
12
|
-
import { SourceFileSymbol, StaticHelperMetadata } from "../load-static-helpers.js";
|
|
11
|
+
import type { ReferenceableSymbol } from "../dependency.js";
|
|
12
|
+
import { SourceFileSymbol, type StaticHelperMetadata } from "../load-static-helpers.js";
|
|
13
13
|
import { refkey } from "../refkey.js";
|
|
14
14
|
import { provideDependencies, useDependencies } from "./use-dependencies.js";
|
|
15
15
|
|
|
@@ -22,9 +22,6 @@ export interface DeclarationInfo {
|
|
|
22
22
|
export interface BinderOptions {
|
|
23
23
|
staticHelpers?: Map<string, StaticHelperMetadata>;
|
|
24
24
|
dependencies?: Record<string, ReferenceableSymbol>;
|
|
25
|
-
/** When true, use #platform/ subpath imports for static helpers with platform variants.
|
|
26
|
-
* Should be true for warp packages; false for tshy packages. */
|
|
27
|
-
useSubpathImports?: boolean;
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
export interface Binder {
|
|
@@ -50,7 +47,6 @@ class BinderImp implements Binder {
|
|
|
50
47
|
private project: Project;
|
|
51
48
|
private dependencies: Record<string, ReferenceableSymbol>;
|
|
52
49
|
private staticHelpers: Map<string, StaticHelperMetadata>;
|
|
53
|
-
private useSubpathImports: boolean;
|
|
54
50
|
|
|
55
51
|
constructor(project: Project, options: BinderOptions = {}) {
|
|
56
52
|
this.project = project;
|
|
@@ -58,7 +54,6 @@ class BinderImp implements Binder {
|
|
|
58
54
|
provideDependencies(options.dependencies);
|
|
59
55
|
this.staticHelpers = options.staticHelpers ?? new Map();
|
|
60
56
|
this.dependencies = useDependencies();
|
|
61
|
-
this.useSubpathImports = options.useSubpathImports ?? false;
|
|
62
57
|
}
|
|
63
58
|
|
|
64
59
|
trackDeclaration(refkey: unknown, name: string, sourceFile: SourceFile): string {
|
|
@@ -185,27 +180,6 @@ class BinderImp implements Binder {
|
|
|
185
180
|
return importSpecifier;
|
|
186
181
|
}
|
|
187
182
|
|
|
188
|
-
/**
|
|
189
|
-
* Returns the #platform/ subpath import specifier for a static helper file
|
|
190
|
-
* that has a polyfill variant (-browser.mts or -react-native.mts sibling),
|
|
191
|
-
* or undefined if subpath imports are disabled or no variant exists.
|
|
192
|
-
* e.g. "src/static-helpers/serialization/get-binary-response.ts"
|
|
193
|
-
* -> "#platform/static-helpers/serialization/get-binary-response"
|
|
194
|
-
*/
|
|
195
|
-
private getPlatformImportSpecifier(declarationSourceFile: SourceFile): string | undefined {
|
|
196
|
-
if (!this.useSubpathImports) return undefined;
|
|
197
|
-
const filePath = declarationSourceFile.getFilePath();
|
|
198
|
-
const srcIndex = filePath.indexOf("/src/");
|
|
199
|
-
if (srcIndex === -1) return undefined;
|
|
200
|
-
// Check if a -browser.mts or -react-native.mts sibling exists
|
|
201
|
-
const basePath = filePath.replace(/\.ts$/, "");
|
|
202
|
-
const hasBrowserVariant = this.project.getSourceFile(basePath + "-browser.mts");
|
|
203
|
-
const hasReactNativeVariant = this.project.getSourceFile(basePath + "-react-native.mts");
|
|
204
|
-
if (!hasBrowserVariant && !hasReactNativeVariant) return undefined;
|
|
205
|
-
const relativePath = filePath.substring(srcIndex + "/src/".length);
|
|
206
|
-
return "#platform/" + relativePath.replace(/\.ts$/, "");
|
|
207
|
-
}
|
|
208
|
-
|
|
209
183
|
/**
|
|
210
184
|
* Applies all tracked imports to their respective source files.
|
|
211
185
|
*/
|
|
@@ -316,9 +290,7 @@ class BinderImp implements Binder {
|
|
|
316
290
|
|
|
317
291
|
if (file !== declarationSourceFile) {
|
|
318
292
|
this.trackReference(declarationKey, file);
|
|
319
|
-
|
|
320
|
-
const platformSpecifier = this.getPlatformImportSpecifier(declarationSourceFile);
|
|
321
|
-
const importTarget = platformSpecifier ?? declarationSourceFile;
|
|
293
|
+
const importTarget = declarationSourceFile;
|
|
322
294
|
const importDec = this.addImport(file, importTarget, name);
|
|
323
295
|
name = importDec.alias ?? name;
|
|
324
296
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
SdkClientType,
|
|
3
|
-
SdkHttpOperation,
|
|
4
|
-
SdkModelPropertyType,
|
|
5
|
-
SdkModelType,
|
|
6
|
-
SdkServiceMethod,
|
|
7
|
-
SdkType,
|
|
2
|
+
type SdkClientType,
|
|
3
|
+
type SdkHttpOperation,
|
|
4
|
+
type SdkModelPropertyType,
|
|
5
|
+
type SdkModelType,
|
|
6
|
+
type SdkServiceMethod,
|
|
7
|
+
type SdkType,
|
|
8
8
|
getClientType,
|
|
9
9
|
} from "@azure-tools/typespec-client-generator-core";
|
|
10
|
-
import { Operation, Type, getNamespaceFullName } from "@typespec/compiler";
|
|
10
|
+
import { type Operation, type Type, getNamespaceFullName } from "@typespec/compiler";
|
|
11
11
|
import { provideContext, useContext } from "../../context-manager.js";
|
|
12
12
|
|
|
13
13
|
import { reportDiagnostic } from "../../lib.js";
|
|
14
14
|
import { visitPackageTypes } from "../../modular/emit-models.js";
|
|
15
15
|
import { getAllAncestors, getAllProperties } from "../../modular/helpers/operation-helpers.js";
|
|
16
16
|
import { normalizeModelPropertyName } from "../../modular/type-expressions/get-type-expression.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
19
|
|
|
20
20
|
export const emitQueue: Set<SdkType> = new Set<SdkType>();
|
|
@@ -29,6 +29,20 @@ export const flattenPropertyModelMap: Map<SdkModelPropertyType, SdkModelType> =
|
|
|
29
29
|
*/
|
|
30
30
|
export const pagedModelsKeptPublic = new Set<SdkType>();
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Releases the module-level state that accumulates while visiting a package's
|
|
34
|
+
* types. These collections are cleared at the start of every
|
|
35
|
+
* {@link visitPackageTypes} call, but because they live at module scope they
|
|
36
|
+
* otherwise keep the most recently emitted program's SDK types reachable until
|
|
37
|
+
* the next emit runs. Call this once an emit has fully finished so that state
|
|
38
|
+
* can be garbage collected.
|
|
39
|
+
*/
|
|
40
|
+
export function resetSdkTypesState(): void {
|
|
41
|
+
emitQueue.clear();
|
|
42
|
+
flattenPropertyModelMap.clear();
|
|
43
|
+
pagedModelsKeptPublic.clear();
|
|
44
|
+
}
|
|
45
|
+
|
|
32
46
|
export interface SdkTypeContext {
|
|
33
47
|
operations: Map<Type, SdkServiceMethod<SdkHttpOperation>>;
|
|
34
48
|
types: Map<Type, SdkType>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { provideContext, useContext } from "../../context-manager.js";
|
|
2
2
|
import { DefaultCoreDependencies } from "../../modular/external-dependencies.js";
|
|
3
|
-
import { ExternalDependencies } from "../dependency.js";
|
|
3
|
+
import type { ExternalDependencies } from "../dependency.js";
|
|
4
4
|
|
|
5
5
|
export function provideDependencies(customDependencies: Partial<ExternalDependencies> = {}) {
|
|
6
6
|
const dependencies = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CompilerHost, joinPaths, NoTarget, Program } from "@typespec/compiler";
|
|
1
|
+
import { type CompilerHost, joinPaths, NoTarget, type Program } from "@typespec/compiler";
|
|
2
2
|
import {
|
|
3
3
|
ClassDeclaration,
|
|
4
4
|
EnumDeclaration,
|
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
TypeAliasDeclaration,
|
|
10
10
|
} from "ts-morph";
|
|
11
11
|
import { reportDiagnostic } from "../lib.js";
|
|
12
|
-
import { ModularEmitterOptions } from "../modular/interfaces.js";
|
|
12
|
+
import type { ModularEmitterOptions } from "../modular/interfaces.js";
|
|
13
13
|
import { resolveProjectRoot } from "../utils/resolve-project-root.js";
|
|
14
14
|
import { refkey } from "./refkey.js";
|
|
15
15
|
export const SourceFileSymbol = Symbol("SourceFile");
|
|
16
|
+
|
|
16
17
|
export interface StaticHelperMetadata {
|
|
17
18
|
name: string;
|
|
18
19
|
kind: "function" | "interface" | "typeAlias" | "class" | "enum";
|
|
@@ -94,22 +95,6 @@ export async function loadStaticHelpers(
|
|
|
94
95
|
const addedFile = project.createSourceFile(targetPath, contents, {
|
|
95
96
|
overwrite: true,
|
|
96
97
|
});
|
|
97
|
-
addedFile.getImportDeclarations().map((i) => {
|
|
98
|
-
// Rewrite relative platform-types imports to #platform/ specifiers
|
|
99
|
-
// so that browser/react-native variants are resolved via subpath imports.
|
|
100
|
-
// Only rewrite imports to the default variant (not -browser/-react-native variants
|
|
101
|
-
// which are already platform-specific direct imports).
|
|
102
|
-
const specifier = i.getModuleSpecifierValue();
|
|
103
|
-
if (
|
|
104
|
-
specifier.startsWith(".") &&
|
|
105
|
-
specifier.includes("platform-types") &&
|
|
106
|
-
!specifier.includes("-browser") &&
|
|
107
|
-
!specifier.includes("-react-native")
|
|
108
|
-
) {
|
|
109
|
-
i.setModuleSpecifier("#platform/static-helpers/platform-types");
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
98
|
for (const entry of Object.values(helpers)) {
|
|
114
99
|
if (!addedFile.getFilePath().endsWith(entry.location)) {
|
|
115
100
|
continue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReferenceableSymbol } from "./dependency.js";
|
|
1
|
+
import type { ReferenceableSymbol } from "./dependency.js";
|
|
2
2
|
import { useBinder } from "./hooks/binder.js";
|
|
3
|
-
import { SourceFileSymbol, StaticHelperMetadata } from "./load-static-helpers.js";
|
|
3
|
+
import { SourceFileSymbol, type StaticHelperMetadata } from "./load-static-helpers.js";
|
|
4
4
|
import { refkey as getRefkey } from "./refkey.js";
|
|
5
5
|
|
|
6
6
|
export function resolveReference(refkey: unknown): string {
|
package/src/framework/sample.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type CompilerHost,
|
|
6
|
+
type EmitContext,
|
|
7
|
+
type Program,
|
|
7
8
|
getBaseFileName,
|
|
8
9
|
getDirectoryPath,
|
|
9
10
|
joinPaths,
|
|
10
11
|
resolvePath,
|
|
11
|
-
type CompilerHost,
|
|
12
12
|
} from "@typespec/compiler";
|
|
13
|
-
import { provideContext, useContext } from "./context-manager.js";
|
|
13
|
+
import { clearContexts, provideContext, useContext } from "./context-manager.js";
|
|
14
14
|
import { buildRootIndex, buildSubClientIndexFile } from "./modular/build-root-index.js";
|
|
15
15
|
import {
|
|
16
16
|
AzureCoreDependencies,
|
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
CreateRecorderHelpers,
|
|
24
24
|
MultipartHelpers,
|
|
25
25
|
PagingHelpers,
|
|
26
|
-
PlatformTypeHelpers,
|
|
27
26
|
PollingHelpers,
|
|
28
27
|
SerializationHelpers,
|
|
29
28
|
SimplePollerHelpers,
|
|
@@ -33,20 +32,20 @@ import {
|
|
|
33
32
|
} from "./modular/static-helpers-metadata.js";
|
|
34
33
|
import { emitContentByBuilder } from "./utils/emit-util.js";
|
|
35
34
|
import { clearDirectory, emptyDir, pathExists } from "./utils/file-system-utils.js";
|
|
36
|
-
import { GenerationDirDetail, SdkContext } from "./utils/interfaces.js";
|
|
35
|
+
import type { GenerationDirDetail, SdkContext } from "./utils/interfaces.js";
|
|
37
36
|
|
|
38
37
|
import {
|
|
39
|
-
SdkClientType,
|
|
40
|
-
SdkServiceOperation,
|
|
38
|
+
type SdkClientType,
|
|
39
|
+
type SdkServiceOperation,
|
|
41
40
|
createSdkContext,
|
|
42
41
|
listAllServiceNamespaces,
|
|
43
42
|
} from "@azure-tools/typespec-client-generator-core";
|
|
44
43
|
import { Project } from "ts-morph";
|
|
45
44
|
import { provideBinder } from "./framework/hooks/binder.js";
|
|
46
|
-
import { provideSdkTypes } from "./framework/hooks/sdk-types.js";
|
|
45
|
+
import { provideSdkTypes, resetSdkTypesState } from "./framework/hooks/sdk-types.js";
|
|
47
46
|
import { loadStaticHelpers } from "./framework/load-static-helpers.js";
|
|
48
|
-
import { ClientModel, ClientOptions } from "./interfaces.js";
|
|
49
|
-
import { EmitterOptions } from "./lib.js";
|
|
47
|
+
import type { ClientModel, ClientOptions } from "./interfaces.js";
|
|
48
|
+
import type { EmitterOptions } from "./lib.js";
|
|
50
49
|
import { buildApiExtractorConfig } from "./metadata/build-api-extractor-config.js";
|
|
51
50
|
import { buildChangelogFile } from "./metadata/build-changelog-file.js";
|
|
52
51
|
import { buildEsLintConfig } from "./metadata/build-es-lint-config.js";
|
|
@@ -76,7 +75,7 @@ import { buildSampleTest } from "./metadata/test/build-sample-test.js";
|
|
|
76
75
|
import { buildSnippets } from "./metadata/test/build-snippets.js";
|
|
77
76
|
import { buildClassicalClient } from "./modular/build-classical-client.js";
|
|
78
77
|
import { buildClassicOperationFiles } from "./modular/build-classical-operation-groups.js";
|
|
79
|
-
import { buildClientContext
|
|
78
|
+
import { buildClientContext } from "./modular/build-client-context.js";
|
|
80
79
|
import { transformModularEmitterOptions } from "./modular/build-modular-options.js";
|
|
81
80
|
import { buildOperationFiles } from "./modular/build-operations.js";
|
|
82
81
|
import { getModuleExports } from "./modular/build-project-files.js";
|
|
@@ -88,7 +87,7 @@ import { emitNonModelResponseTypes, emitTypes } from "./modular/emit-models.js";
|
|
|
88
87
|
import { emitSamples } from "./modular/emit-samples.js";
|
|
89
88
|
import { emitTests } from "./modular/emit-tests.js";
|
|
90
89
|
import { getClassicalClientName } from "./modular/helpers/naming-helpers.js";
|
|
91
|
-
import { ModularEmitterOptions } from "./modular/interfaces.js";
|
|
90
|
+
import type { ModularEmitterOptions } from "./modular/interfaces.js";
|
|
92
91
|
import { packageUsesXmlSerialization } from "./modular/serialization/build-xml-serializer-function.js";
|
|
93
92
|
import { transformClientOptions } from "./transform/transform-client-options.js";
|
|
94
93
|
import { transformClientModel } from "./transform/transform.js";
|
|
@@ -139,7 +138,6 @@ export async function $onEmit(context: EmitContext) {
|
|
|
139
138
|
...SimplePollerHelpers,
|
|
140
139
|
...UrlTemplateHelpers,
|
|
141
140
|
...MultipartHelpers,
|
|
142
|
-
...PlatformTypeHelpers,
|
|
143
141
|
...CloudSettingHelpers,
|
|
144
142
|
...XmlHelpers,
|
|
145
143
|
...(resolvedEmitterOptions.generateTest ? CreateRecorderHelpers : {}),
|
|
@@ -165,7 +163,6 @@ export async function $onEmit(context: EmitContext) {
|
|
|
165
163
|
dependencies: {
|
|
166
164
|
...extraDependencies,
|
|
167
165
|
},
|
|
168
|
-
useSubpathImports: true,
|
|
169
166
|
});
|
|
170
167
|
provideSdkTypes(dpgContext);
|
|
171
168
|
|
|
@@ -188,6 +185,15 @@ export async function $onEmit(context: EmitContext) {
|
|
|
188
185
|
|
|
189
186
|
await generateMetadataAndTest(dpgContext);
|
|
190
187
|
|
|
188
|
+
// Release the emitter's process-wide singleton state now that this emit has
|
|
189
|
+
// finished writing output. Without this, the context manager keeps the whole
|
|
190
|
+
// previous program graph (compiler `EmitContext`/`Program`, TCGC `SdkContext`,
|
|
191
|
+
// ts-morph `Project`, binder, …) reachable until the next emit overwrites it.
|
|
192
|
+
// Clearing here lets it be collected between emits, which matters for hosts
|
|
193
|
+
// that run many emits in one process (test suites, benchmarks, watch mode).
|
|
194
|
+
clearContexts();
|
|
195
|
+
resetSdkTypesState();
|
|
196
|
+
|
|
191
197
|
async function enrichDpgContext() {
|
|
192
198
|
const generationPathDetail: GenerationDirDetail = await calculateGenerationDir();
|
|
193
199
|
dpgContext.generationPathDetail = generationPathDetail;
|
|
@@ -446,19 +452,18 @@ export async function $onEmit(context: EmitContext) {
|
|
|
446
452
|
modularPackageInfo = {
|
|
447
453
|
...modularPackageInfo,
|
|
448
454
|
dependencies,
|
|
449
|
-
clientContextPaths: getRelativeContextPaths(context, modularEmitterOptions),
|
|
450
455
|
};
|
|
451
456
|
}
|
|
452
457
|
commonBuilders.push((model) => buildPackageFile(model, modularPackageInfo));
|
|
453
458
|
// Generate warp.config.yml for Azure monorepo ESM packages
|
|
454
459
|
commonBuilders.push((model) => buildWarpConfig(model, modularPackageInfo));
|
|
455
460
|
commonBuilders.push(buildTsConfig);
|
|
456
|
-
commonBuilders.push(buildTsSrcEsmConfig);
|
|
457
|
-
commonBuilders.push(buildTsSrcBrowserConfig);
|
|
461
|
+
commonBuilders.push(() => buildTsSrcEsmConfig(modularPackageInfo["exports"]));
|
|
462
|
+
commonBuilders.push(() => buildTsSrcBrowserConfig(modularPackageInfo["exports"]));
|
|
458
463
|
if (option.generateReactNativeTarget) {
|
|
459
|
-
commonBuilders.push(buildTsSrcReactNativeConfig);
|
|
464
|
+
commonBuilders.push(() => buildTsSrcReactNativeConfig(modularPackageInfo["exports"]));
|
|
460
465
|
}
|
|
461
|
-
commonBuilders.push(buildTsSrcCjsConfig);
|
|
466
|
+
commonBuilders.push(() => buildTsSrcCjsConfig(modularPackageInfo["exports"]));
|
|
462
467
|
if (option.generateSample) {
|
|
463
468
|
commonBuilders.push(buildTsSampleConfig);
|
|
464
469
|
}
|
|
@@ -499,14 +504,13 @@ export async function $onEmit(context: EmitContext) {
|
|
|
499
504
|
}
|
|
500
505
|
const modularPackageInfo = {
|
|
501
506
|
exports: getModuleExports(context, modularEmitterOptions),
|
|
502
|
-
clientContextPaths: getRelativeContextPaths(context, modularEmitterOptions),
|
|
503
507
|
...(Object.keys(additionalDependencies).length > 0 && {
|
|
504
508
|
dependencies: additionalDependencies,
|
|
505
509
|
}),
|
|
506
510
|
};
|
|
507
511
|
|
|
508
512
|
// Always update package.json (adds #platform/* imports) along with
|
|
509
|
-
// exports
|
|
513
|
+
// exports and LRO deps.
|
|
510
514
|
{
|
|
511
515
|
// Read package.json content via host and pass parsed object
|
|
512
516
|
const pkgSourceFile = await host.readFile(existingPackageFilePath);
|
|
@@ -524,6 +528,14 @@ export async function $onEmit(context: EmitContext) {
|
|
|
524
528
|
// Update warp.config.yml for Azure monorepo packages
|
|
525
529
|
updateBuilders.push((model: ClientModel) => buildWarpConfig(model, modularPackageInfo));
|
|
526
530
|
|
|
531
|
+
// Re-sync tsconfig.src.*.json `include` with the warp exports
|
|
532
|
+
updateBuilders.push(() => buildTsSrcEsmConfig(modularPackageInfo["exports"]));
|
|
533
|
+
updateBuilders.push(() => buildTsSrcBrowserConfig(modularPackageInfo["exports"]));
|
|
534
|
+
if (option.generateReactNativeTarget) {
|
|
535
|
+
updateBuilders.push(() => buildTsSrcReactNativeConfig(modularPackageInfo["exports"]));
|
|
536
|
+
}
|
|
537
|
+
updateBuilders.push(() => buildTsSrcCjsConfig(modularPackageInfo["exports"]));
|
|
538
|
+
|
|
527
539
|
// If the client name changed, regenerate the README and snippets completely;
|
|
528
540
|
// otherwise update only the API reference link in-place.
|
|
529
541
|
if (hasReadmeFile) {
|
|
@@ -571,13 +583,6 @@ export async function $onEmit(context: EmitContext) {
|
|
|
571
583
|
);
|
|
572
584
|
}
|
|
573
585
|
}
|
|
574
|
-
|
|
575
|
-
function getRelativeContextPaths(context: SdkContext, options: ModularEmitterOptions) {
|
|
576
|
-
const clientMap = getClientHierarchyMap(context);
|
|
577
|
-
return Array.from(clientMap)
|
|
578
|
-
.map((subClient) => getClientContextPath(subClient, options))
|
|
579
|
-
.map((path) => path.substring(path.indexOf("src")));
|
|
580
|
-
}
|
|
581
586
|
}
|
|
582
587
|
|
|
583
588
|
export async function createContextWithDefaultOptions(
|
package/src/interfaces.ts
CHANGED