@azure-tools/typespec-ts 0.54.2 → 0.55.0-dev.10
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 +0 -9
- package/README.md +68 -105
- package/dist/src/framework/hooks/binder.d.ts +1 -1
- package/dist/src/framework/hooks/binder.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.js +3 -4
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/sdk-types.d.ts +2 -3
- package/dist/src/framework/hooks/sdk-types.d.ts.map +1 -1
- package/dist/src/framework/hooks/sdk-types.js +2 -3
- package/dist/src/framework/hooks/sdk-types.js.map +1 -1
- package/dist/src/framework/load-static-helpers.d.ts +4 -1
- package/dist/src/framework/load-static-helpers.d.ts.map +1 -1
- package/dist/src/framework/load-static-helpers.js +26 -34
- package/dist/src/framework/load-static-helpers.js.map +1 -1
- package/dist/src/framework/sample.js +1 -1
- package/dist/src/framework/sample.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +104 -170
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +2 -18
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +30 -124
- package/dist/src/lib.js.map +1 -1
- package/dist/src/modular/build-classical-client.js +2 -2
- package/dist/src/modular/build-classical-client.js.map +1 -1
- package/dist/src/modular/build-client-context.d.ts.map +1 -1
- package/dist/src/modular/build-client-context.js +6 -15
- package/dist/src/modular/build-client-context.js.map +1 -1
- package/dist/src/modular/build-project-files.d.ts.map +1 -1
- package/dist/src/modular/build-project-files.js +4 -4
- package/dist/src/modular/build-project-files.js.map +1 -1
- package/dist/src/modular/build-restore-poller.js +2 -2
- package/dist/src/modular/build-restore-poller.js.map +1 -1
- package/dist/src/modular/build-root-index.d.ts.map +1 -1
- package/dist/src/modular/build-root-index.js +9 -13
- package/dist/src/modular/build-root-index.js.map +1 -1
- package/dist/src/modular/build-subpath-index.d.ts.map +1 -1
- package/dist/src/modular/build-subpath-index.js +4 -4
- package/dist/src/modular/build-subpath-index.js.map +1 -1
- package/dist/src/modular/emit-logger-file.d.ts.map +1 -1
- package/dist/src/modular/emit-logger-file.js +0 -3
- package/dist/src/modular/emit-logger-file.js.map +1 -1
- package/dist/src/modular/emit-models-options.js +2 -2
- package/dist/src/modular/emit-models-options.js.map +1 -1
- package/dist/src/modular/emit-models.d.ts.map +1 -1
- package/dist/src/modular/emit-models.js +7 -22
- package/dist/src/modular/emit-models.js.map +1 -1
- package/dist/src/modular/emit-samples.d.ts.map +1 -1
- package/dist/src/modular/emit-samples.js +10 -28
- package/dist/src/modular/emit-samples.js.map +1 -1
- package/dist/src/modular/emit-tests.d.ts +2 -1
- package/dist/src/modular/emit-tests.d.ts.map +1 -1
- package/dist/src/modular/emit-tests.js +21 -11
- package/dist/src/modular/emit-tests.js.map +1 -1
- package/dist/src/modular/helpers/client-helpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/client-helpers.js +6 -16
- package/dist/src/modular/helpers/client-helpers.js.map +1 -1
- package/dist/src/modular/helpers/example-value-helpers.d.ts +1 -1
- package/dist/src/modular/helpers/example-value-helpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/example-value-helpers.js +11 -28
- package/dist/src/modular/helpers/example-value-helpers.js.map +1 -1
- package/dist/src/modular/serialization/serialize-utils.js +2 -2
- package/dist/src/modular/serialization/serialize-utils.js.map +1 -1
- package/dist/src/rlc-common/helpers/imports-util.d.ts +3 -4
- package/dist/src/rlc-common/helpers/imports-util.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/imports-util.js +43 -56
- package/dist/src/rlc-common/helpers/imports-util.js.map +1 -1
- package/dist/src/rlc-common/helpers/name-constructors.d.ts +0 -9
- package/dist/src/rlc-common/helpers/name-constructors.d.ts.map +1 -1
- package/dist/src/rlc-common/helpers/name-constructors.js +1 -17
- package/dist/src/rlc-common/helpers/name-constructors.js.map +1 -1
- package/dist/src/rlc-common/index.d.ts +0 -18
- package/dist/src/rlc-common/index.d.ts.map +1 -1
- package/dist/src/rlc-common/index.js +0 -18
- package/dist/src/rlc-common/index.js.map +1 -1
- package/dist/src/rlc-common/interfaces.d.ts +2 -20
- package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
- package/dist/src/rlc-common/interfaces.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts +1 -1
- package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-api-extractor-config.js +5 -42
- package/dist/src/rlc-common/metadata/build-api-extractor-config.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts +2 -2
- package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-es-lint-config.js +3 -41
- package/dist/src/rlc-common/metadata/build-es-lint-config.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-package-file.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-package-file.js +25 -73
- package/dist/src/rlc-common/metadata/build-package-file.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-readme-file.d.ts +2 -2
- package/dist/src/rlc-common/metadata/build-readme-file.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-readme-file.js +18 -108
- package/dist/src/rlc-common/metadata/build-readme-file.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-sample-env-file.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-sample-env-file.js +1 -2
- package/dist/src/rlc-common/metadata/build-sample-env-file.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-test-config.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-test-config.js +1 -4
- package/dist/src/rlc-common/metadata/build-test-config.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-ts-config.d.ts +2 -2
- package/dist/src/rlc-common/metadata/build-ts-config.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-ts-config.js +19 -60
- package/dist/src/rlc-common/metadata/build-ts-config.js.map +1 -1
- package/dist/src/rlc-common/metadata/build-warp-config.d.ts +1 -1
- package/dist/src/rlc-common/metadata/build-warp-config.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/build-warp-config.js +0 -3
- package/dist/src/rlc-common/metadata/build-warp-config.js.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts +1 -38
- package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/azure-package-common.js +1 -108
- package/dist/src/rlc-common/metadata/package-json/azure-package-common.js.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts +0 -39
- package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js +4 -20
- package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/package-common.d.ts +1 -22
- package/dist/src/rlc-common/metadata/package-json/package-common.d.ts.map +1 -1
- package/dist/src/rlc-common/metadata/package-json/package-common.js +21 -98
- package/dist/src/rlc-common/metadata/package-json/package-common.js.map +1 -1
- package/dist/src/rlc-common/static/polling-content.d.ts +1 -1
- package/dist/src/rlc-common/static/polling-content.d.ts.map +1 -1
- package/dist/src/rlc-common/static/polling-content.js +1 -1
- package/dist/src/rlc-common/test/build-recorded-client.d.ts +1 -1
- package/dist/src/rlc-common/test/build-recorded-client.d.ts.map +1 -1
- package/dist/src/rlc-common/test/build-recorded-client.js +2 -5
- package/dist/src/rlc-common/test/build-recorded-client.js.map +1 -1
- package/dist/src/rlc-common/test/build-sample-test.d.ts +1 -1
- package/dist/src/rlc-common/test/build-sample-test.d.ts.map +1 -1
- package/dist/src/rlc-common/test/build-sample-test.js +2 -5
- package/dist/src/rlc-common/test/build-sample-test.js.map +1 -1
- package/dist/src/rlc-common/test/build-snippets.d.ts +1 -1
- package/dist/src/rlc-common/test/build-snippets.d.ts.map +1 -1
- package/dist/src/rlc-common/test/build-snippets.js +2 -6
- package/dist/src/rlc-common/test/build-snippets.js.map +1 -1
- package/dist/src/rlc-common/test/template.d.ts +3 -3
- package/dist/src/rlc-common/test/template.d.ts.map +1 -1
- package/dist/src/rlc-common/test/template.js +1 -35
- package/dist/src/rlc-common/test/template.js.map +1 -1
- package/dist/src/transform/transform-helper-function-details.d.ts +2 -2
- package/dist/src/transform/transform-helper-function-details.d.ts.map +1 -1
- package/dist/src/transform/transform-helper-function-details.js +1 -9
- package/dist/src/transform/transform-helper-function-details.js.map +1 -1
- package/dist/src/transform/transform-schemas.js +1 -1
- package/dist/src/transform/transform-schemas.js.map +1 -1
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/transform/transform.js +9 -16
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transfrom-rlc-options.d.ts +2 -2
- package/dist/src/transform/transfrom-rlc-options.d.ts.map +1 -1
- package/dist/src/transform/transfrom-rlc-options.js +29 -94
- package/dist/src/transform/transfrom-rlc-options.js.map +1 -1
- package/dist/src/utils/client-utils.d.ts +1 -1
- package/dist/src/utils/client-utils.d.ts.map +1 -1
- package/dist/src/utils/client-utils.js +4 -5
- package/dist/src/utils/client-utils.js.map +1 -1
- package/dist/src/utils/emit-util.d.ts +0 -1
- package/dist/src/utils/emit-util.d.ts.map +1 -1
- package/dist/src/utils/emit-util.js +13 -24
- package/dist/src/utils/emit-util.js.map +1 -1
- package/dist/src/utils/file-system-utils.d.ts +4 -4
- package/dist/src/utils/file-system-utils.d.ts.map +1 -1
- package/dist/src/utils/file-system-utils.js +14 -16
- package/dist/src/utils/file-system-utils.js.map +1 -1
- package/dist/src/utils/import-helper.js +3 -3
- package/dist/src/utils/import-helper.js.map +1 -1
- package/dist/src/utils/model-utils.d.ts +1 -1
- package/dist/src/utils/model-utils.d.ts.map +1 -1
- package/dist/src/utils/model-utils.js +4 -11
- package/dist/src/utils/model-utils.js.map +1 -1
- package/dist/src/utils/resolve-project-root.d.ts +6 -4
- package/dist/src/utils/resolve-project-root.d.ts.map +1 -1
- package/dist/src/utils/resolve-project-root.js +11 -18
- package/dist/src/utils/resolve-project-root.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -59
- package/src/framework/hooks/binder.ts +4 -5
- package/src/framework/hooks/sdk-types.ts +2 -3
- package/src/framework/load-static-helpers.ts +38 -41
- package/src/framework/sample.ts +1 -1
- package/src/index.ts +126 -204
- package/src/lib.ts +32 -143
- package/src/modular/build-classical-client.ts +2 -2
- package/src/modular/build-client-context.ts +6 -14
- package/src/modular/build-project-files.ts +11 -4
- package/src/modular/build-restore-poller.ts +2 -2
- package/src/modular/build-root-index.ts +9 -13
- package/src/modular/build-subpath-index.ts +4 -4
- package/src/modular/emit-logger-file.ts +0 -3
- package/src/modular/emit-models-options.ts +2 -2
- package/src/modular/emit-models.ts +7 -23
- package/src/modular/emit-samples.ts +10 -26
- package/src/modular/emit-tests.ts +28 -11
- package/src/modular/helpers/client-helpers.ts +7 -17
- package/src/modular/helpers/example-value-helpers.ts +11 -26
- package/src/modular/serialization/serialize-utils.ts +2 -2
- package/src/rlc-common/helpers/imports-util.ts +44 -56
- package/src/rlc-common/helpers/name-constructors.ts +1 -23
- package/src/rlc-common/index.ts +0 -18
- package/src/rlc-common/interfaces.ts +2 -23
- package/src/rlc-common/metadata/build-api-extractor-config.ts +5 -47
- package/src/rlc-common/metadata/build-es-lint-config.ts +3 -42
- package/src/rlc-common/metadata/build-package-file.ts +24 -86
- package/src/rlc-common/metadata/build-readme-file.ts +19 -121
- package/src/rlc-common/metadata/build-sample-env-file.ts +1 -4
- package/src/rlc-common/metadata/build-test-config.ts +1 -6
- package/src/rlc-common/metadata/build-ts-config.ts +30 -72
- package/src/rlc-common/metadata/build-warp-config.ts +0 -4
- package/src/rlc-common/metadata/package-json/azure-package-common.ts +2 -134
- package/src/rlc-common/metadata/package-json/build-azure-monorepo-package.ts +4 -24
- package/src/rlc-common/metadata/package-json/package-common.ts +22 -120
- package/src/rlc-common/static/polling-content.ts +1 -1
- package/src/rlc-common/test/build-recorded-client.ts +2 -5
- package/src/rlc-common/test/build-sample-test.ts +2 -5
- package/src/rlc-common/test/build-snippets.ts +2 -6
- package/src/rlc-common/test/template.ts +1 -35
- package/src/transform/transform-helper-function-details.ts +1 -10
- package/src/transform/transform-schemas.ts +1 -1
- package/src/transform/transform.ts +8 -19
- package/src/transform/transfrom-rlc-options.ts +29 -127
- package/src/utils/client-utils.ts +4 -5
- package/src/utils/emit-util.ts +14 -39
- package/src/utils/file-system-utils.ts +14 -15
- package/src/utils/import-helper.ts +3 -3
- package/src/utils/model-utils.ts +4 -17
- package/src/utils/resolve-project-root.ts +11 -24
- package/dist/src/rlc-common/build-client-definitions.d.ts +0 -6
- package/dist/src/rlc-common/build-client-definitions.d.ts.map +0 -1
- package/dist/src/rlc-common/build-client-definitions.js +0 -157
- package/dist/src/rlc-common/build-client-definitions.js.map +0 -1
- package/dist/src/rlc-common/build-client.d.ts +0 -9
- package/dist/src/rlc-common/build-client.d.ts.map +0 -1
- package/dist/src/rlc-common/build-client.js +0 -391
- package/dist/src/rlc-common/build-client.js.map +0 -1
- package/dist/src/rlc-common/build-index-file.d.ts +0 -6
- package/dist/src/rlc-common/build-index-file.d.ts.map +0 -1
- package/dist/src/rlc-common/build-index-file.js +0 -241
- package/dist/src/rlc-common/build-index-file.js.map +0 -1
- package/dist/src/rlc-common/build-is-unexpected-helper.d.ts +0 -6
- package/dist/src/rlc-common/build-is-unexpected-helper.d.ts.map +0 -1
- package/dist/src/rlc-common/build-is-unexpected-helper.js +0 -223
- package/dist/src/rlc-common/build-is-unexpected-helper.js.map +0 -1
- package/dist/src/rlc-common/build-logger.d.ts +0 -6
- package/dist/src/rlc-common/build-logger.d.ts.map +0 -1
- package/dist/src/rlc-common/build-logger.js +0 -31
- package/dist/src/rlc-common/build-logger.js.map +0 -1
- package/dist/src/rlc-common/build-method-shortcuts.d.ts +0 -5
- package/dist/src/rlc-common/build-method-shortcuts.d.ts.map +0 -1
- package/dist/src/rlc-common/build-method-shortcuts.js +0 -54
- package/dist/src/rlc-common/build-method-shortcuts.js.map +0 -1
- package/dist/src/rlc-common/build-object-types.d.ts +0 -29
- package/dist/src/rlc-common/build-object-types.d.ts.map +0 -1
- package/dist/src/rlc-common/build-object-types.js +0 -412
- package/dist/src/rlc-common/build-object-types.js.map +0 -1
- package/dist/src/rlc-common/build-paginate-helper.d.ts +0 -6
- package/dist/src/rlc-common/build-paginate-helper.d.ts.map +0 -1
- package/dist/src/rlc-common/build-paginate-helper.js +0 -27
- package/dist/src/rlc-common/build-paginate-helper.js.map +0 -1
- package/dist/src/rlc-common/build-parameter-types.d.ts +0 -14
- package/dist/src/rlc-common/build-parameter-types.d.ts.map +0 -1
- package/dist/src/rlc-common/build-parameter-types.js +0 -391
- package/dist/src/rlc-common/build-parameter-types.js.map +0 -1
- package/dist/src/rlc-common/build-polling-helper.d.ts +0 -6
- package/dist/src/rlc-common/build-polling-helper.d.ts.map +0 -1
- package/dist/src/rlc-common/build-polling-helper.js +0 -61
- package/dist/src/rlc-common/build-polling-helper.js.map +0 -1
- package/dist/src/rlc-common/build-response-types.d.ts +0 -6
- package/dist/src/rlc-common/build-response-types.d.ts.map +0 -1
- package/dist/src/rlc-common/build-response-types.js +0 -143
- package/dist/src/rlc-common/build-response-types.js.map +0 -1
- package/dist/src/rlc-common/build-samples.d.ts +0 -3
- package/dist/src/rlc-common/build-samples.d.ts.map +0 -1
- package/dist/src/rlc-common/build-samples.js +0 -30
- package/dist/src/rlc-common/build-samples.js.map +0 -1
- package/dist/src/rlc-common/build-schema-type.d.ts +0 -20
- package/dist/src/rlc-common/build-schema-type.d.ts.map +0 -1
- package/dist/src/rlc-common/build-schema-type.js +0 -71
- package/dist/src/rlc-common/build-schema-type.js.map +0 -1
- package/dist/src/rlc-common/build-serialize-helper.d.ts +0 -6
- package/dist/src/rlc-common/build-serialize-helper.d.ts.map +0 -1
- package/dist/src/rlc-common/build-serialize-helper.js +0 -36
- package/dist/src/rlc-common/build-serialize-helper.js.map +0 -1
- package/dist/src/rlc-common/build-top-level-index-file.d.ts +0 -6
- package/dist/src/rlc-common/build-top-level-index-file.d.ts.map +0 -1
- package/dist/src/rlc-common/build-top-level-index-file.js +0 -48
- package/dist/src/rlc-common/build-top-level-index-file.js.map +0 -1
- package/dist/src/rlc-common/helpers/package-util.d.ts +0 -7
- package/dist/src/rlc-common/helpers/package-util.d.ts.map +0 -1
- package/dist/src/rlc-common/helpers/package-util.js +0 -10
- package/dist/src/rlc-common/helpers/package-util.js.map +0 -1
- package/dist/src/rlc-common/helpers/path-utils.d.ts +0 -2
- package/dist/src/rlc-common/helpers/path-utils.d.ts.map +0 -1
- package/dist/src/rlc-common/helpers/path-utils.js +0 -10
- package/dist/src/rlc-common/helpers/path-utils.js.map +0 -1
- package/dist/src/rlc-common/helpers/shortcut-methods.d.ts +0 -4
- package/dist/src/rlc-common/helpers/shortcut-methods.d.ts.map +0 -1
- package/dist/src/rlc-common/helpers/shortcut-methods.js +0 -49
- package/dist/src/rlc-common/helpers/shortcut-methods.js.map +0 -1
- package/dist/src/rlc-common/helpers/value-generation-util.d.ts +0 -12
- package/dist/src/rlc-common/helpers/value-generation-util.d.ts.map +0 -1
- package/dist/src/rlc-common/helpers/value-generation-util.js +0 -161
- package/dist/src/rlc-common/helpers/value-generation-util.js.map +0 -1
- package/dist/src/rlc-common/metadata/build-rollup-config.d.ts +0 -6
- package/dist/src/rlc-common/metadata/build-rollup-config.d.ts.map +0 -1
- package/dist/src/rlc-common/metadata/build-rollup-config.js +0 -140
- package/dist/src/rlc-common/metadata/build-rollup-config.js.map +0 -1
- package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.d.ts +0 -8
- package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.d.ts.map +0 -1
- package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.js +0 -101
- package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.js.map +0 -1
- package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.d.ts +0 -57
- package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.d.ts.map +0 -1
- package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.js +0 -53
- package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.js.map +0 -1
- package/dist/src/rlc-common/transform-sample-groups.d.ts +0 -9
- package/dist/src/rlc-common/transform-sample-groups.d.ts.map +0 -1
- package/dist/src/rlc-common/transform-sample-groups.js +0 -313
- package/dist/src/rlc-common/transform-sample-groups.js.map +0 -1
- package/dist/src/utils/dirname.d.ts +0 -9
- package/dist/src/utils/dirname.d.ts.map +0 -1
- package/dist/src/utils/dirname.js +0 -12
- package/dist/src/utils/dirname.js.map +0 -1
- package/src/rlc-common/build-client-definitions.ts +0 -235
- package/src/rlc-common/build-client.ts +0 -490
- package/src/rlc-common/build-index-file.ts +0 -344
- package/src/rlc-common/build-is-unexpected-helper.ts +0 -248
- package/src/rlc-common/build-logger.ts +0 -43
- package/src/rlc-common/build-method-shortcuts.ts +0 -71
- package/src/rlc-common/build-object-types.ts +0 -603
- package/src/rlc-common/build-paginate-helper.ts +0 -31
- package/src/rlc-common/build-parameter-types.ts +0 -554
- package/src/rlc-common/build-polling-helper.ts +0 -83
- package/src/rlc-common/build-response-types.ts +0 -180
- package/src/rlc-common/build-samples.ts +0 -32
- package/src/rlc-common/build-schema-type.ts +0 -89
- package/src/rlc-common/build-serialize-helper.ts +0 -49
- package/src/rlc-common/build-top-level-index-file.ts +0 -58
- package/src/rlc-common/helpers/package-util.ts +0 -13
- package/src/rlc-common/helpers/path-utils.ts +0 -10
- package/src/rlc-common/helpers/shortcut-methods.ts +0 -58
- package/src/rlc-common/helpers/value-generation-util.ts +0 -234
- package/src/rlc-common/metadata/build-rollup-config.ts +0 -147
- package/src/rlc-common/metadata/package-json/build-azure-standalone-package.ts +0 -123
- package/src/rlc-common/metadata/package-json/build-flavorless-package.ts +0 -68
- package/src/rlc-common/transform-sample-groups.ts +0 -407
- package/src/utils/dirname.ts +0 -12
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
NameType,
|
|
8
8
|
normalizeName,
|
|
9
9
|
PackageDetails,
|
|
10
|
-
PackageFlavor,
|
|
11
10
|
pascalCase,
|
|
12
11
|
RLCOptions,
|
|
13
12
|
ServiceInfo,
|
|
@@ -29,7 +28,7 @@ export function transformRLCOptions(
|
|
|
29
28
|
emitterOptions,
|
|
30
29
|
dpgContext.generationPathDetail?.rootDir ?? "",
|
|
31
30
|
);
|
|
32
|
-
const batch = getRLCClients(dpgContext
|
|
31
|
+
const batch = getRLCClients(dpgContext);
|
|
33
32
|
options.batch = batch;
|
|
34
33
|
return options;
|
|
35
34
|
}
|
|
@@ -39,33 +38,19 @@ function extractRLCOptions(
|
|
|
39
38
|
generationRootDir: string,
|
|
40
39
|
): RLCOptions {
|
|
41
40
|
const program = dpgContext.program;
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const includeShortcuts = getIncludeShortcuts(emitterOptions);
|
|
45
|
-
const packageDetails = getPackageDetails(program, emitterOptions, isModularLibrary);
|
|
46
|
-
const flavor = getFlavor(emitterOptions, packageDetails);
|
|
47
|
-
const moduleKind = getModuleKind(emitterOptions);
|
|
48
|
-
const serviceInfo = getServiceInfo(program, isModularLibrary);
|
|
41
|
+
const packageDetails = getPackageDetails(program, emitterOptions);
|
|
42
|
+
const serviceInfo = getServiceInfo(program);
|
|
49
43
|
const includeHeadersInResponse = emitterOptions["include-headers-in-response"] === true;
|
|
50
|
-
const azureSdkForJs = getAzureSdkForJs(emitterOptions, flavor);
|
|
51
44
|
const generateMetadata = getGenerateMetadata(emitterOptions);
|
|
52
|
-
const generateTest = getGenerateTest(emitterOptions
|
|
45
|
+
const generateTest = getGenerateTest(emitterOptions);
|
|
53
46
|
const generateSample = getGenerateSample(dpgContext, emitterOptions);
|
|
54
|
-
const credentialInfo = getCredentialInfo(program, emitterOptions
|
|
47
|
+
const credentialInfo = getCredentialInfo(program, emitterOptions);
|
|
55
48
|
const azureOutputDirectory = getAzureOutputDirectory(generationRootDir);
|
|
56
|
-
const enableOperationGroup = getEnableOperationGroup(
|
|
57
|
-
dpgContext,
|
|
58
|
-
emitterOptions,
|
|
59
|
-
isModularLibrary,
|
|
60
|
-
);
|
|
49
|
+
const enableOperationGroup = getEnableOperationGroup(dpgContext, emitterOptions);
|
|
61
50
|
const enableModelNamespace = getEnableModelNamespace(dpgContext, emitterOptions);
|
|
62
51
|
const hierarchyClient = getHierarchyClient(emitterOptions);
|
|
63
52
|
const clearOutputFolder = getClearOutputFolder(emitterOptions);
|
|
64
|
-
const multiClient = emitterOptions["multi-client"];
|
|
65
53
|
const isTypeSpecTest = emitterOptions["is-typespec-test"];
|
|
66
|
-
const title = emitterOptions.title;
|
|
67
|
-
const dependencyInfo = emitterOptions["dependency-info"];
|
|
68
|
-
const productDocLink = emitterOptions["product-doc-link"];
|
|
69
54
|
const compatibilityMode = emitterOptions["compatibility-mode"];
|
|
70
55
|
const compatibilityLro = emitterOptions["compatibility-lro"];
|
|
71
56
|
const experimentalExtensibleEnums = emitterOptions["experimental-extensible-enums"];
|
|
@@ -77,35 +62,25 @@ function extractRLCOptions(
|
|
|
77
62
|
const typespecTitleMap = emitterOptions["typespec-title-map"];
|
|
78
63
|
const generateReactNativeTarget = emitterOptions["generate-react-native-target"] === true;
|
|
79
64
|
const hasSubscriptionId = getSubscriptionId(dpgContext);
|
|
80
|
-
const ignoreNullableOnOptional = getIgnoreNullableOnOptional(emitterOptions
|
|
81
|
-
const wrapNonModelReturn = getWrapNonModelReturn(emitterOptions
|
|
65
|
+
const ignoreNullableOnOptional = getIgnoreNullableOnOptional(emitterOptions);
|
|
66
|
+
const wrapNonModelReturn = getWrapNonModelReturn(emitterOptions);
|
|
82
67
|
const isMultiService = (dpgContext.allServiceNamespaces?.length ?? 0) > 1;
|
|
83
68
|
|
|
84
69
|
return {
|
|
85
70
|
...credentialInfo,
|
|
86
71
|
includeHeadersInResponse,
|
|
87
|
-
flavor,
|
|
88
|
-
moduleKind,
|
|
89
|
-
includeShortcuts,
|
|
90
72
|
packageDetails,
|
|
91
73
|
generateMetadata,
|
|
92
74
|
generateTest,
|
|
93
75
|
generateSample,
|
|
94
|
-
azureSdkForJs,
|
|
95
76
|
serviceInfo,
|
|
96
77
|
azureOutputDirectory,
|
|
97
|
-
sourceFrom: "TypeSpec",
|
|
98
78
|
enableOperationGroup,
|
|
99
79
|
enableModelNamespace,
|
|
100
80
|
hierarchyClient,
|
|
101
81
|
azureArm: dpgContext.arm,
|
|
102
82
|
clearOutputFolder,
|
|
103
|
-
multiClient,
|
|
104
83
|
isTypeSpecTest,
|
|
105
|
-
title,
|
|
106
|
-
dependencyInfo,
|
|
107
|
-
productDocLink,
|
|
108
|
-
isModularLibrary,
|
|
109
84
|
compatibilityMode,
|
|
110
85
|
compatibilityLro,
|
|
111
86
|
experimentalExtensibleEnums,
|
|
@@ -123,8 +98,8 @@ function extractRLCOptions(
|
|
|
123
98
|
};
|
|
124
99
|
}
|
|
125
100
|
|
|
126
|
-
function processAuth(program: Program
|
|
127
|
-
const serviceNs = getDefaultService(program
|
|
101
|
+
function processAuth(program: Program) {
|
|
102
|
+
const serviceNs = getDefaultService(program)?.type;
|
|
128
103
|
if (!serviceNs) {
|
|
129
104
|
return undefined;
|
|
130
105
|
}
|
|
@@ -189,11 +164,7 @@ function processAuth(program: Program, isModularLibrary: boolean) {
|
|
|
189
164
|
return securityInfo;
|
|
190
165
|
}
|
|
191
166
|
|
|
192
|
-
function getEnableOperationGroup(
|
|
193
|
-
dpgContext: SdkContext,
|
|
194
|
-
emitterOptions: EmitterOptions,
|
|
195
|
-
isModularLibrary: boolean,
|
|
196
|
-
) {
|
|
167
|
+
function getEnableOperationGroup(dpgContext: SdkContext, emitterOptions: EmitterOptions) {
|
|
197
168
|
if (
|
|
198
169
|
emitterOptions["enable-operation-group"] === true ||
|
|
199
170
|
emitterOptions["enable-operation-group"] === false
|
|
@@ -201,7 +172,7 @@ function getEnableOperationGroup(
|
|
|
201
172
|
return emitterOptions["enable-operation-group"];
|
|
202
173
|
}
|
|
203
174
|
// Only detect if existing name conflicts if customers don't set hierarchyClient to true
|
|
204
|
-
return detectIfNameConflicts(dpgContext
|
|
175
|
+
return detectIfNameConflicts(dpgContext);
|
|
205
176
|
}
|
|
206
177
|
|
|
207
178
|
function getEnableModelNamespace(dpgContext: SdkContext, emitterOptions: EmitterOptions) {
|
|
@@ -227,8 +198,8 @@ function getClearOutputFolder(emitterOptions: EmitterOptions) {
|
|
|
227
198
|
return emitterOptions["clear-output-folder"] ? true : false;
|
|
228
199
|
}
|
|
229
200
|
|
|
230
|
-
function detectIfNameConflicts(dpgContext: SdkContext
|
|
231
|
-
const clients = getRLCClients(dpgContext
|
|
201
|
+
function detectIfNameConflicts(dpgContext: SdkContext) {
|
|
202
|
+
const clients = getRLCClients(dpgContext);
|
|
232
203
|
for (const client of clients) {
|
|
233
204
|
// only consider it's conflict when there are conflicts in the same client
|
|
234
205
|
const nameSet = new Set<string>();
|
|
@@ -247,66 +218,25 @@ function detectIfNameConflicts(dpgContext: SdkContext, isModularLibrary: boolean
|
|
|
247
218
|
return false;
|
|
248
219
|
}
|
|
249
220
|
|
|
250
|
-
function getIgnoreNullableOnOptional(
|
|
251
|
-
emitterOptions: EmitterOptions,
|
|
252
|
-
flavor: PackageFlavor,
|
|
253
|
-
): boolean {
|
|
221
|
+
function getIgnoreNullableOnOptional(emitterOptions: EmitterOptions): boolean {
|
|
254
222
|
// If explicitly set in options, use that value
|
|
255
223
|
if (emitterOptions["ignore-nullable-on-optional"] !== undefined) {
|
|
256
224
|
return Boolean(emitterOptions["ignore-nullable-on-optional"]);
|
|
257
225
|
}
|
|
258
|
-
// Default to true
|
|
259
|
-
return
|
|
226
|
+
// Default to true (same as HLC behavior)
|
|
227
|
+
return true;
|
|
260
228
|
}
|
|
261
229
|
|
|
262
|
-
function getWrapNonModelReturn(emitterOptions: EmitterOptions
|
|
230
|
+
function getWrapNonModelReturn(emitterOptions: EmitterOptions): boolean {
|
|
263
231
|
// If explicitly set in options, use that value
|
|
264
232
|
if (emitterOptions["wrap-non-model-return"] !== undefined) {
|
|
265
233
|
return Boolean(emitterOptions["wrap-non-model-return"]);
|
|
266
234
|
}
|
|
267
|
-
// Default to true
|
|
268
|
-
return
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function getIncludeShortcuts(emitterOptions: EmitterOptions) {
|
|
272
|
-
return Boolean(emitterOptions["include-shortcuts"]);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function getModuleKind(emitterOptions: EmitterOptions) {
|
|
276
|
-
return emitterOptions["module-kind"] ?? "esm";
|
|
235
|
+
// Default to true to maintain HLC backward compatibility
|
|
236
|
+
return true;
|
|
277
237
|
}
|
|
278
238
|
|
|
279
|
-
function
|
|
280
|
-
const flavor = emitterOptions.flavor;
|
|
281
|
-
|
|
282
|
-
if (flavor !== undefined) {
|
|
283
|
-
if (flavor.toLowerCase() === "azure") {
|
|
284
|
-
return "azure";
|
|
285
|
-
} else {
|
|
286
|
-
return undefined;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const branded = emitterOptions.branded;
|
|
291
|
-
if (branded !== undefined) {
|
|
292
|
-
return branded ? "azure" : undefined;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const scopeName = packageDetails?.scopeName;
|
|
296
|
-
if (
|
|
297
|
-
scopeName !== undefined &&
|
|
298
|
-
(scopeName.startsWith("azure") || scopeName.startsWith("msinternal"))
|
|
299
|
-
) {
|
|
300
|
-
return "azure";
|
|
301
|
-
} else {
|
|
302
|
-
return undefined;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function buildPackageDetails(
|
|
306
|
-
program: Program,
|
|
307
|
-
emitterOptions: EmitterOptions,
|
|
308
|
-
isModularLibrary: boolean,
|
|
309
|
-
): PackageDetails {
|
|
239
|
+
function buildPackageDetails(program: Program, emitterOptions: EmitterOptions): PackageDetails {
|
|
310
240
|
const defaultDetail = {
|
|
311
241
|
name: "@msinternal/unamedpackage",
|
|
312
242
|
nameWithoutScope: "unamedpackage",
|
|
@@ -317,10 +247,7 @@ function buildPackageDetails(
|
|
|
317
247
|
...emitterOptions["package-details"],
|
|
318
248
|
name:
|
|
319
249
|
emitterOptions["package-details"]?.name ??
|
|
320
|
-
normalizeName(
|
|
321
|
-
emitterOptions?.title ?? getDefaultService(program, isModularLibrary)?.title ?? "",
|
|
322
|
-
NameType.Class,
|
|
323
|
-
),
|
|
250
|
+
normalizeName(getDefaultService(program)?.title ?? "", NameType.Class),
|
|
324
251
|
version: emitterOptions["package-details"]?.version ?? "1.0.0-beta.1",
|
|
325
252
|
isVersionUserProvided,
|
|
326
253
|
};
|
|
@@ -334,31 +261,18 @@ function buildPackageDetails(
|
|
|
334
261
|
return packageDetails ?? defaultDetail;
|
|
335
262
|
}
|
|
336
263
|
|
|
337
|
-
function getPackageDetails(
|
|
338
|
-
program
|
|
339
|
-
emitterOptions: EmitterOptions,
|
|
340
|
-
isModularLibrary: boolean,
|
|
341
|
-
): PackageDetails {
|
|
342
|
-
return buildPackageDetails(program, emitterOptions, isModularLibrary);
|
|
264
|
+
function getPackageDetails(program: Program, emitterOptions: EmitterOptions): PackageDetails {
|
|
265
|
+
return buildPackageDetails(program, emitterOptions);
|
|
343
266
|
}
|
|
344
267
|
|
|
345
|
-
function getServiceInfo(program: Program
|
|
346
|
-
const defaultService = getDefaultService(program
|
|
268
|
+
function getServiceInfo(program: Program): ServiceInfo {
|
|
269
|
+
const defaultService = getDefaultService(program);
|
|
347
270
|
return {
|
|
348
271
|
title: defaultService?.title,
|
|
349
272
|
description: defaultService && getDoc(program, defaultService.type),
|
|
350
273
|
};
|
|
351
274
|
}
|
|
352
275
|
|
|
353
|
-
function getAzureSdkForJs(emitterOptions: EmitterOptions, flavor: PackageFlavor) {
|
|
354
|
-
return flavor !== "azure"
|
|
355
|
-
? false
|
|
356
|
-
: emitterOptions["azure-sdk-for-js"] === undefined ||
|
|
357
|
-
emitterOptions["azure-sdk-for-js"] === null
|
|
358
|
-
? true
|
|
359
|
-
: Boolean(emitterOptions["azure-sdk-for-js"]);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
276
|
function getGenerateMetadata(emitterOptions: EmitterOptions) {
|
|
363
277
|
if (
|
|
364
278
|
emitterOptions["generate-metadata"] === undefined ||
|
|
@@ -374,11 +288,7 @@ function getGenerateMetadata(emitterOptions: EmitterOptions) {
|
|
|
374
288
|
* @param emitterOptions
|
|
375
289
|
* @returns
|
|
376
290
|
*/
|
|
377
|
-
function getGenerateTest(emitterOptions: EmitterOptions
|
|
378
|
-
// Disable generateTest if azureSdkForJS is false
|
|
379
|
-
if (!getAzureSdkForJs(emitterOptions, flavor)) {
|
|
380
|
-
return false;
|
|
381
|
-
}
|
|
291
|
+
function getGenerateTest(emitterOptions: EmitterOptions) {
|
|
382
292
|
return emitterOptions["generate-test"];
|
|
383
293
|
}
|
|
384
294
|
|
|
@@ -400,12 +310,8 @@ function getGenerateSample(dpgContext: SdkContext, emitterOptions: EmitterOption
|
|
|
400
310
|
return Boolean(emitterOptions["generate-sample"]);
|
|
401
311
|
}
|
|
402
312
|
|
|
403
|
-
export function getCredentialInfo(
|
|
404
|
-
program
|
|
405
|
-
emitterOptions: EmitterOptions,
|
|
406
|
-
isModularLibrary: boolean = true,
|
|
407
|
-
) {
|
|
408
|
-
const securityInfo = processAuth(program, isModularLibrary);
|
|
313
|
+
export function getCredentialInfo(program: Program, emitterOptions: EmitterOptions) {
|
|
314
|
+
const securityInfo = processAuth(program);
|
|
409
315
|
const addCredentials =
|
|
410
316
|
emitterOptions["add-credentials"] === false
|
|
411
317
|
? false
|
|
@@ -444,10 +350,6 @@ function getAzureOutputDirectory(emitterOutputDir: string): string | undefined {
|
|
|
444
350
|
}
|
|
445
351
|
|
|
446
352
|
export function getSubscriptionId(dpgContext: SdkContext) {
|
|
447
|
-
//TODO Need consider multi-client cases, skip multi-client cases check for now
|
|
448
|
-
if (dpgContext.rlcOptions?.multiClient) {
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
353
|
for (const client of dpgContext.sdkPackage.clients) {
|
|
452
354
|
if (
|
|
453
355
|
getClientParameters(client, dpgContext)
|
|
@@ -18,14 +18,13 @@ import { ModularClientOptions } from "../modular/interfaces.js";
|
|
|
18
18
|
import { NameType, normalizeName } from "../rlc-common/index.js";
|
|
19
19
|
import { SdkContext } from "./interfaces.js";
|
|
20
20
|
|
|
21
|
-
export function getRLCClients(dpgContext: SdkContext
|
|
22
|
-
const modular = isModularLibrary ?? dpgContext.rlcOptions?.isModularLibrary ?? false;
|
|
21
|
+
export function getRLCClients(dpgContext: SdkContext): SdkClient[] {
|
|
23
22
|
const clients = listClients(dpgContext);
|
|
24
23
|
const rawServiceNamespaces =
|
|
25
24
|
dpgContext.allServiceNamespaces ?? listAllServiceNamespaces(dpgContext);
|
|
26
25
|
|
|
27
|
-
// For one client
|
|
28
|
-
if (
|
|
26
|
+
// For one client: Return the client from listClients with multi-service support
|
|
27
|
+
if (clients.length === 1) {
|
|
29
28
|
return clients.map((client) => {
|
|
30
29
|
const services = client.services;
|
|
31
30
|
return {
|
|
@@ -35,7 +34,7 @@ export function getRLCClients(dpgContext: SdkContext, isModularLibrary?: boolean
|
|
|
35
34
|
};
|
|
36
35
|
});
|
|
37
36
|
} else {
|
|
38
|
-
// For
|
|
37
|
+
// For multiple clients:
|
|
39
38
|
// Flatten all services and return one client per service
|
|
40
39
|
const services = new Set<Namespace>();
|
|
41
40
|
clients.forEach((c) => {
|
package/src/utils/emit-util.ts
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
import { CompilerHost, NoTarget, Program } from "@typespec/compiler";
|
|
2
|
-
import { dirname, join } from "path";
|
|
1
|
+
import { CompilerHost, getDirectoryPath, joinPaths, NoTarget, Program } from "@typespec/compiler";
|
|
3
2
|
import { format } from "prettier";
|
|
3
|
+
import prettierPluginBabel from "prettier/plugins/babel";
|
|
4
|
+
import prettierPluginEstree from "prettier/plugins/estree";
|
|
5
|
+
import prettierPluginTypescript from "prettier/plugins/typescript";
|
|
4
6
|
import { prettierJSONOptions, prettierTypeScriptOptions, reportDiagnostic } from "../lib.js";
|
|
5
|
-
import {
|
|
6
|
-
buildSchemaTypes,
|
|
7
|
-
ContentBuilder,
|
|
8
|
-
File,
|
|
9
|
-
isAzurePackage,
|
|
10
|
-
RLCModel,
|
|
11
|
-
} from "../rlc-common/index.js";
|
|
12
|
-
|
|
13
|
-
export async function emitModels(rlcModels: RLCModel, program: Program) {
|
|
14
|
-
const schemaOutput = buildSchemaTypes(rlcModels);
|
|
15
|
-
const isAzureFlavor = isAzurePackage(rlcModels);
|
|
16
|
-
if (schemaOutput) {
|
|
17
|
-
const { inputModelFile, outputModelFile } = schemaOutput;
|
|
18
|
-
if (inputModelFile) {
|
|
19
|
-
await emitFile(inputModelFile, program, isAzureFlavor);
|
|
20
|
-
}
|
|
21
|
-
if (outputModelFile) {
|
|
22
|
-
await emitFile(outputModelFile, program, isAzureFlavor);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
7
|
+
import { ContentBuilder, File, RLCModel } from "../rlc-common/index.js";
|
|
26
8
|
|
|
27
9
|
export async function emitContentByBuilder(
|
|
28
10
|
program: Program,
|
|
@@ -33,7 +15,6 @@ export async function emitContentByBuilder(
|
|
|
33
15
|
if (!Array.isArray(builderFnOrList)) {
|
|
34
16
|
builderFnOrList = [builderFnOrList];
|
|
35
17
|
}
|
|
36
|
-
const isAzureFlavor = isAzurePackage(rlcModels);
|
|
37
18
|
for (const builderFn of builderFnOrList) {
|
|
38
19
|
let contentFiles: File[] | File | undefined = builderFn(rlcModels);
|
|
39
20
|
if (!contentFiles) {
|
|
@@ -43,26 +24,20 @@ export async function emitContentByBuilder(
|
|
|
43
24
|
contentFiles = [contentFiles];
|
|
44
25
|
}
|
|
45
26
|
for (const file of contentFiles) {
|
|
46
|
-
await emitFile(file, program,
|
|
27
|
+
await emitFile(file, program, emitterOutputDir);
|
|
47
28
|
}
|
|
48
29
|
}
|
|
49
30
|
}
|
|
50
31
|
|
|
51
|
-
async function emitFile(
|
|
52
|
-
file: File,
|
|
53
|
-
program: Program,
|
|
54
|
-
isAzureFlavor: boolean,
|
|
55
|
-
emitterOutputDir?: string,
|
|
56
|
-
) {
|
|
32
|
+
async function emitFile(file: File, program: Program, emitterOutputDir?: string) {
|
|
57
33
|
if (program.compilerOptions.noEmit || program.hasError()) {
|
|
58
34
|
return;
|
|
59
35
|
}
|
|
60
36
|
const host: CompilerHost = program.host;
|
|
61
|
-
const filePath =
|
|
37
|
+
const filePath = joinPaths(emitterOutputDir ?? "", file.path);
|
|
62
38
|
const isJson = /\.json$/gi.test(filePath);
|
|
63
39
|
const isSourceCode = /\.(ts|js)$/gi.test(filePath);
|
|
64
|
-
const
|
|
65
|
-
const licenseHeader = `${microsoftHeader}// Licensed under the MIT License.\n`;
|
|
40
|
+
const licenseHeader = `// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n`;
|
|
66
41
|
let prettierFileContent = file.content;
|
|
67
42
|
|
|
68
43
|
if (isSourceCode) {
|
|
@@ -71,10 +46,10 @@ async function emitFile(
|
|
|
71
46
|
// Format the contents if necessary
|
|
72
47
|
if (isJson || isSourceCode) {
|
|
73
48
|
try {
|
|
74
|
-
prettierFileContent = await format(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
49
|
+
prettierFileContent = await format(prettierFileContent, {
|
|
50
|
+
...(isJson ? prettierJSONOptions : prettierTypeScriptOptions),
|
|
51
|
+
plugins: [prettierPluginTypescript, prettierPluginEstree, prettierPluginBabel],
|
|
52
|
+
});
|
|
78
53
|
} catch (e) {
|
|
79
54
|
reportDiagnostic(program, {
|
|
80
55
|
code: "file-formatting-error",
|
|
@@ -87,6 +62,6 @@ async function emitFile(
|
|
|
87
62
|
// Continue with unformatted content rather than crashing
|
|
88
63
|
}
|
|
89
64
|
}
|
|
90
|
-
await host.mkdirp(
|
|
65
|
+
await host.mkdirp(getDirectoryPath(filePath));
|
|
91
66
|
await host.writeFile(filePath, prettierFileContent);
|
|
92
67
|
}
|
|
@@ -1,49 +1,48 @@
|
|
|
1
|
-
import { NoTarget, Program } from "@typespec/compiler";
|
|
2
|
-
import { mkdir, readdir, rm, stat } from "fs/promises";
|
|
3
|
-
import { resolve } from "path";
|
|
1
|
+
import { NoTarget, Program, resolvePath, type CompilerHost } from "@typespec/compiler";
|
|
4
2
|
import { reportDiagnostic } from "../lib.js";
|
|
5
3
|
|
|
6
|
-
export async function pathExists(targetPath: string): Promise<boolean> {
|
|
4
|
+
export async function pathExists(host: CompilerHost, targetPath: string): Promise<boolean> {
|
|
7
5
|
try {
|
|
8
|
-
await stat(targetPath);
|
|
6
|
+
await host.stat(targetPath);
|
|
9
7
|
return true;
|
|
10
8
|
} catch {
|
|
11
9
|
return false;
|
|
12
10
|
}
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
export async function emptyDir(dirPath: string): Promise<void> {
|
|
13
|
+
export async function emptyDir(host: CompilerHost, dirPath: string): Promise<void> {
|
|
16
14
|
let entries: string[];
|
|
17
15
|
try {
|
|
18
|
-
entries = await
|
|
16
|
+
entries = await host.readDir(dirPath);
|
|
19
17
|
} catch {
|
|
20
|
-
await
|
|
18
|
+
await host.mkdirp(dirPath);
|
|
21
19
|
return;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
await Promise.all(
|
|
25
|
-
entries.map((entry) => rm(
|
|
23
|
+
entries.map((entry) => host.rm(resolvePath(dirPath, entry), { recursive: true })),
|
|
26
24
|
);
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
export async function clearDirectory(
|
|
28
|
+
host: CompilerHost,
|
|
30
29
|
dirPath: string,
|
|
31
30
|
excludeNames: string[] = [],
|
|
32
31
|
program?: Program,
|
|
33
32
|
): Promise<void> {
|
|
34
|
-
if (!(await pathExists(dirPath))) {
|
|
33
|
+
if (!(await pathExists(host, dirPath))) {
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
// If no exclude names, just use regular emptyDir for efficiency
|
|
39
38
|
if (excludeNames.length === 0) {
|
|
40
|
-
await emptyDir(dirPath);
|
|
39
|
+
await emptyDir(host, dirPath);
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
try {
|
|
45
44
|
// Get all subdirectories and files
|
|
46
|
-
const entries = await
|
|
45
|
+
const entries = await host.readDir(dirPath);
|
|
47
46
|
|
|
48
47
|
// Filter entries to exclude those that should be preserved
|
|
49
48
|
const filteredEntries = entries.filter((entry) => {
|
|
@@ -52,8 +51,8 @@ export async function clearDirectory(
|
|
|
52
51
|
|
|
53
52
|
// Process each entry
|
|
54
53
|
for (const entry of filteredEntries) {
|
|
55
|
-
const entryPath =
|
|
56
|
-
await rm(entryPath, { recursive: true
|
|
54
|
+
const entryPath = resolvePath(dirPath, entry);
|
|
55
|
+
await host.rm(entryPath, { recursive: true });
|
|
57
56
|
}
|
|
58
57
|
} catch (error) {
|
|
59
58
|
// If there's an error, fall back to regular emptyDir
|
|
@@ -64,6 +63,6 @@ export async function clearDirectory(
|
|
|
64
63
|
target: NoTarget,
|
|
65
64
|
});
|
|
66
65
|
}
|
|
67
|
-
await emptyDir(dirPath);
|
|
66
|
+
await emptyDir(host, dirPath);
|
|
68
67
|
}
|
|
69
68
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getDirectoryPath, getRelativePathFromDirectory, resolvePath } from "@typespec/compiler";
|
|
2
2
|
import { SourceFile } from "ts-morph";
|
|
3
3
|
import { useContext } from "../context-manager.js";
|
|
4
4
|
|
|
@@ -20,7 +20,7 @@ export function addImportBySymbol(symbol: string, currentFile: SourceFile) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// Resolve absolute path and compute a relative path from the current file to the module.
|
|
23
|
-
const moduleAbsolutePath =
|
|
23
|
+
const moduleAbsolutePath = resolvePath(modulePath);
|
|
24
24
|
const relativeImportPath = getRelativeImportPath(currentFile.getFilePath(), moduleAbsolutePath)
|
|
25
25
|
.replace(/\\/g, "/")
|
|
26
26
|
.replace(/\.ts$/, ".js");
|
|
@@ -53,7 +53,7 @@ export function addImportBySymbol(symbol: string, currentFile: SourceFile) {
|
|
|
53
53
|
* @returns {string} The relative path adjusted for import syntax.
|
|
54
54
|
*/
|
|
55
55
|
function getRelativeImportPath(from: string, to: string) {
|
|
56
|
-
const relativePath =
|
|
56
|
+
const relativePath = getRelativePathFromDirectory(getDirectoryPath(from), to, false);
|
|
57
57
|
// Adjust the path format to TypeScript module syntax
|
|
58
58
|
return relativePath.startsWith(".") ? relativePath : "./" + relativePath;
|
|
59
59
|
}
|
package/src/utils/model-utils.ts
CHANGED
|
@@ -1492,10 +1492,7 @@ export function predictDefaultValue(dpgContext: SdkContext, param?: ModelPropert
|
|
|
1492
1492
|
}
|
|
1493
1493
|
return specificDefault;
|
|
1494
1494
|
}
|
|
1495
|
-
const serviceNamespace = getDefaultService(
|
|
1496
|
-
program,
|
|
1497
|
-
dpgContext.rlcOptions?.isModularLibrary,
|
|
1498
|
-
)?.type;
|
|
1495
|
+
const serviceNamespace = getDefaultService(program)?.type;
|
|
1499
1496
|
if (!serviceNamespace) {
|
|
1500
1497
|
return;
|
|
1501
1498
|
}
|
|
@@ -1506,10 +1503,7 @@ export function predictDefaultValue(dpgContext: SdkContext, param?: ModelPropert
|
|
|
1506
1503
|
return;
|
|
1507
1504
|
}
|
|
1508
1505
|
|
|
1509
|
-
export function getDefaultService(
|
|
1510
|
-
program: Program,
|
|
1511
|
-
isModularLibrary: boolean = true,
|
|
1512
|
-
): Service | undefined {
|
|
1506
|
+
export function getDefaultService(program: Program): Service | undefined {
|
|
1513
1507
|
const services = listServices(program);
|
|
1514
1508
|
if (!services || services.length === 0) {
|
|
1515
1509
|
reportDiagnostic(program, {
|
|
@@ -1517,12 +1511,6 @@ export function getDefaultService(
|
|
|
1517
1511
|
target: NoTarget,
|
|
1518
1512
|
});
|
|
1519
1513
|
}
|
|
1520
|
-
if (services.length > 1 && !isModularLibrary) {
|
|
1521
|
-
reportDiagnostic(program, {
|
|
1522
|
-
code: "more-than-one-service",
|
|
1523
|
-
target: NoTarget,
|
|
1524
|
-
});
|
|
1525
|
-
}
|
|
1526
1514
|
return services[0];
|
|
1527
1515
|
}
|
|
1528
1516
|
/**
|
|
@@ -1530,9 +1518,8 @@ export function getDefaultService(
|
|
|
1530
1518
|
*/
|
|
1531
1519
|
export function getDefaultApiVersionString(dpgContext: SdkContext): string | undefined {
|
|
1532
1520
|
const program = dpgContext.program;
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
? getDefaultApiVersion(dpgContext, getDefaultService(program, isModularLibrary)!.type)?.value
|
|
1521
|
+
return getDefaultService(program)
|
|
1522
|
+
? getDefaultApiVersion(dpgContext, getDefaultService(program)!.type)?.value
|
|
1536
1523
|
: undefined;
|
|
1537
1524
|
}
|
|
1538
1525
|
|
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dirname, resolve } from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
1
|
+
import { resolvePath } from "@typespec/compiler";
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Returns the package root directory for the emitter.
|
|
5
|
+
*
|
|
6
|
+
* The compiled output lives at `dist/src/utils/resolve-project-root.js`,
|
|
7
|
+
* so the package root is 3 levels up. This avoids filesystem access,
|
|
8
|
+
* making it compatible with virtual file systems (e.g., the playground).
|
|
9
9
|
*/
|
|
10
|
-
export function resolveProjectRoot(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (existsSync(packageJsonPath)) {
|
|
16
|
-
return currentDir; // Return the directory containing the package.json
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const parentDir = resolve(currentDir, "..");
|
|
20
|
-
|
|
21
|
-
if (parentDir === currentDir) {
|
|
22
|
-
// If we've reached the root directory and haven't found package.json
|
|
23
|
-
throw new Error("Could not find package.json");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Recursively search the parent directory
|
|
27
|
-
return resolveProjectRoot(parentDir);
|
|
10
|
+
export function resolveProjectRoot(): string {
|
|
11
|
+
// Use the global URL constructor (works in both Node.js and browsers)
|
|
12
|
+
const currentDir = new URL(".", import.meta.url).pathname;
|
|
13
|
+
// From dist/src/utils/ -> package root (3 levels: utils -> src -> dist -> root)
|
|
14
|
+
return resolvePath(currentDir, "../../..");
|
|
28
15
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-client-definitions.d.ts","sourceRoot":"","sources":["../../../src/rlc-common/build-client-definitions.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAuB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhE,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ;;;EAmGrD"}
|