@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
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
import { Project, SourceFile } from "ts-morph";
|
|
6
|
-
import { getImportModuleName } from "./helpers/name-constructors.js";
|
|
7
|
-
import { NameType, normalizeName } from "./helpers/name-utils.js";
|
|
8
|
-
import {
|
|
9
|
-
hasCsvCollection,
|
|
10
|
-
hasInputModels,
|
|
11
|
-
hasMultiCollection,
|
|
12
|
-
hasOutputModels,
|
|
13
|
-
hasPagingOperations,
|
|
14
|
-
hasPipeCollection,
|
|
15
|
-
hasPollingOperations,
|
|
16
|
-
hasSsvCollection,
|
|
17
|
-
hasTsvCollection,
|
|
18
|
-
hasUnexpectedHelper,
|
|
19
|
-
} from "./helpers/operation-helpers.js";
|
|
20
|
-
import { isAzurePackage } from "./helpers/package-util.js";
|
|
21
|
-
import { RLCModel } from "./interfaces.js";
|
|
22
|
-
|
|
23
|
-
export function buildIndexFile(model: RLCModel) {
|
|
24
|
-
const multiClient = Boolean(model.options?.multiClient),
|
|
25
|
-
batch = model.options?.batch;
|
|
26
|
-
const project = new Project();
|
|
27
|
-
const { srcPath } = model;
|
|
28
|
-
const filePath = path.join(srcPath, `index.ts`);
|
|
29
|
-
const indexFile = project.createSourceFile(filePath, undefined, {
|
|
30
|
-
overwrite: true,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (!multiClient || !batch || batch?.length === 1) {
|
|
34
|
-
// if we are generate single client package for RLC
|
|
35
|
-
generateRLCIndex(indexFile, model);
|
|
36
|
-
} else {
|
|
37
|
-
generateRLCIndexForMultiClient(indexFile, model);
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
path: filePath,
|
|
41
|
-
content: indexFile.getFullText(),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// to generate a index.ts for each single module inside the multi client RLC package
|
|
46
|
-
function generateRLCIndexForMultiClient(file: SourceFile, model: RLCModel) {
|
|
47
|
-
const clientName = model.libraryName;
|
|
48
|
-
const createClientFuncName = `createClient`;
|
|
49
|
-
const moduleName = normalizeName(clientName, NameType.File);
|
|
50
|
-
|
|
51
|
-
file.addImportDeclaration({
|
|
52
|
-
namespaceImport: "Parameters",
|
|
53
|
-
moduleSpecifier: getImportModuleName(
|
|
54
|
-
{ cjsName: "./parameters", esModulesName: "./parameters.js" },
|
|
55
|
-
model,
|
|
56
|
-
),
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
file.addImportDeclaration({
|
|
60
|
-
namespaceImport: "Responses",
|
|
61
|
-
moduleSpecifier: getImportModuleName(
|
|
62
|
-
{ cjsName: "./responses", esModulesName: "./responses.js" },
|
|
63
|
-
model,
|
|
64
|
-
),
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
file.addImportDeclaration({
|
|
68
|
-
namespaceImport: "Client",
|
|
69
|
-
moduleSpecifier: getImportModuleName(
|
|
70
|
-
{
|
|
71
|
-
cjsName: "./clientDefinitions",
|
|
72
|
-
esModulesName: "./clientDefinitions.js",
|
|
73
|
-
},
|
|
74
|
-
model,
|
|
75
|
-
),
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const exports = ["Parameters", "Responses", "Client"];
|
|
79
|
-
if (hasInputModels(model)) {
|
|
80
|
-
file.addImportDeclaration({
|
|
81
|
-
namespaceImport: "Models",
|
|
82
|
-
moduleSpecifier: getImportModuleName(
|
|
83
|
-
{
|
|
84
|
-
cjsName: "./models",
|
|
85
|
-
esModulesName: "./models.js",
|
|
86
|
-
},
|
|
87
|
-
model,
|
|
88
|
-
),
|
|
89
|
-
});
|
|
90
|
-
exports.push("Models");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (hasOutputModels(model)) {
|
|
94
|
-
file.addImportDeclaration({
|
|
95
|
-
namespaceImport: "OutputModels",
|
|
96
|
-
moduleSpecifier: getImportModuleName(
|
|
97
|
-
{
|
|
98
|
-
cjsName: "./outputModels",
|
|
99
|
-
esModulesName: "./outputModels.js",
|
|
100
|
-
},
|
|
101
|
-
model,
|
|
102
|
-
),
|
|
103
|
-
});
|
|
104
|
-
exports.push("OutputModels");
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (hasPagingOperations(model)) {
|
|
108
|
-
file.addImportDeclaration({
|
|
109
|
-
namespaceImport: "PaginateHelper",
|
|
110
|
-
moduleSpecifier: getImportModuleName(
|
|
111
|
-
{
|
|
112
|
-
cjsName: "./paginateHelper",
|
|
113
|
-
esModulesName: "./paginateHelper.js",
|
|
114
|
-
},
|
|
115
|
-
model,
|
|
116
|
-
),
|
|
117
|
-
});
|
|
118
|
-
exports.push("PaginateHelper");
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (hasUnexpectedHelper(model)) {
|
|
122
|
-
file.addImportDeclaration({
|
|
123
|
-
namespaceImport: "UnexpectedHelper",
|
|
124
|
-
moduleSpecifier: getImportModuleName(
|
|
125
|
-
{
|
|
126
|
-
cjsName: "./isUnexpected",
|
|
127
|
-
esModulesName: "./isUnexpected.js",
|
|
128
|
-
},
|
|
129
|
-
model,
|
|
130
|
-
),
|
|
131
|
-
});
|
|
132
|
-
exports.push("UnexpectedHelper");
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (hasPollingOperations(model)) {
|
|
136
|
-
file.addImportDeclaration({
|
|
137
|
-
namespaceImport: "PollingHelper",
|
|
138
|
-
moduleSpecifier: getImportModuleName(
|
|
139
|
-
{
|
|
140
|
-
cjsName: "./pollingHelper",
|
|
141
|
-
esModulesName: "./pollingHelper.js",
|
|
142
|
-
},
|
|
143
|
-
model,
|
|
144
|
-
),
|
|
145
|
-
});
|
|
146
|
-
exports.push("PollingHelper");
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
hasMultiCollection(model) ||
|
|
151
|
-
hasSsvCollection(model) ||
|
|
152
|
-
hasPipeCollection(model) ||
|
|
153
|
-
hasTsvCollection(model) ||
|
|
154
|
-
hasCsvCollection(model)
|
|
155
|
-
) {
|
|
156
|
-
file.addImportDeclaration({
|
|
157
|
-
namespaceImport: "SerializeHelper",
|
|
158
|
-
moduleSpecifier: getImportModuleName(
|
|
159
|
-
{
|
|
160
|
-
cjsName: "./serializeHelper",
|
|
161
|
-
esModulesName: "./serializeHelper.js",
|
|
162
|
-
},
|
|
163
|
-
model,
|
|
164
|
-
),
|
|
165
|
-
});
|
|
166
|
-
exports.push("SerializeHelper");
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
file.addExportDeclarations([
|
|
170
|
-
{
|
|
171
|
-
moduleSpecifier: getImportModuleName(
|
|
172
|
-
{
|
|
173
|
-
cjsName: `./${moduleName}`,
|
|
174
|
-
esModulesName: `./${moduleName}.js`,
|
|
175
|
-
},
|
|
176
|
-
model,
|
|
177
|
-
),
|
|
178
|
-
namedExports: [`${createClientFuncName}`, `${clientName}ClientOptions`],
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
namedExports: [...exports],
|
|
182
|
-
},
|
|
183
|
-
]);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function generateRLCIndex(file: SourceFile, model: RLCModel) {
|
|
187
|
-
const clientName = model.libraryName;
|
|
188
|
-
const createClientFuncName = `${clientName}`;
|
|
189
|
-
const moduleName = normalizeName(clientName, NameType.File);
|
|
190
|
-
|
|
191
|
-
file.addImportDeclaration({
|
|
192
|
-
moduleSpecifier: getImportModuleName(
|
|
193
|
-
{
|
|
194
|
-
cjsName: `./${moduleName}`,
|
|
195
|
-
esModulesName: `./${moduleName}.js`,
|
|
196
|
-
},
|
|
197
|
-
model,
|
|
198
|
-
),
|
|
199
|
-
defaultImport: createClientFuncName,
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
file.addExportDeclarations([
|
|
203
|
-
{
|
|
204
|
-
moduleSpecifier: getImportModuleName(
|
|
205
|
-
{
|
|
206
|
-
cjsName: `./${moduleName}`,
|
|
207
|
-
esModulesName: `./${moduleName}.js`,
|
|
208
|
-
},
|
|
209
|
-
model,
|
|
210
|
-
),
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
moduleSpecifier: getImportModuleName(
|
|
214
|
-
{
|
|
215
|
-
cjsName: `./parameters`,
|
|
216
|
-
esModulesName: `./parameters.js`,
|
|
217
|
-
},
|
|
218
|
-
model,
|
|
219
|
-
),
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
moduleSpecifier: getImportModuleName(
|
|
223
|
-
{
|
|
224
|
-
cjsName: `./responses`,
|
|
225
|
-
esModulesName: `./responses.js`,
|
|
226
|
-
},
|
|
227
|
-
model,
|
|
228
|
-
),
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
moduleSpecifier: getImportModuleName(
|
|
232
|
-
{
|
|
233
|
-
cjsName: `./clientDefinitions`,
|
|
234
|
-
esModulesName: `./clientDefinitions.js`,
|
|
235
|
-
},
|
|
236
|
-
model,
|
|
237
|
-
),
|
|
238
|
-
},
|
|
239
|
-
]);
|
|
240
|
-
|
|
241
|
-
if (hasUnexpectedHelper(model)) {
|
|
242
|
-
file.addExportDeclarations([
|
|
243
|
-
{
|
|
244
|
-
moduleSpecifier: getImportModuleName(
|
|
245
|
-
{
|
|
246
|
-
cjsName: `./isUnexpected`,
|
|
247
|
-
esModulesName: `./isUnexpected.js`,
|
|
248
|
-
},
|
|
249
|
-
model,
|
|
250
|
-
),
|
|
251
|
-
},
|
|
252
|
-
]);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (hasInputModels(model)) {
|
|
256
|
-
file.addExportDeclarations([
|
|
257
|
-
{
|
|
258
|
-
moduleSpecifier: getImportModuleName(
|
|
259
|
-
{
|
|
260
|
-
cjsName: `./models`,
|
|
261
|
-
esModulesName: `./models.js`,
|
|
262
|
-
},
|
|
263
|
-
model,
|
|
264
|
-
),
|
|
265
|
-
},
|
|
266
|
-
]);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (hasOutputModels(model)) {
|
|
270
|
-
file.addExportDeclarations([
|
|
271
|
-
{
|
|
272
|
-
moduleSpecifier: getImportModuleName(
|
|
273
|
-
{
|
|
274
|
-
cjsName: `./outputModels`,
|
|
275
|
-
esModulesName: `./outputModels.js`,
|
|
276
|
-
},
|
|
277
|
-
model,
|
|
278
|
-
),
|
|
279
|
-
},
|
|
280
|
-
]);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (hasPagingOperations(model)) {
|
|
284
|
-
file.addExportDeclarations([
|
|
285
|
-
{
|
|
286
|
-
moduleSpecifier: getImportModuleName(
|
|
287
|
-
{
|
|
288
|
-
cjsName: `./paginateHelper`,
|
|
289
|
-
esModulesName: `./paginateHelper.js`,
|
|
290
|
-
},
|
|
291
|
-
model,
|
|
292
|
-
),
|
|
293
|
-
},
|
|
294
|
-
]);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (hasPollingOperations(model)) {
|
|
298
|
-
file.addExportDeclarations([
|
|
299
|
-
{
|
|
300
|
-
moduleSpecifier: getImportModuleName(
|
|
301
|
-
{
|
|
302
|
-
cjsName: `./pollingHelper`,
|
|
303
|
-
esModulesName: `./pollingHelper.js`,
|
|
304
|
-
},
|
|
305
|
-
model,
|
|
306
|
-
),
|
|
307
|
-
},
|
|
308
|
-
]);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (
|
|
312
|
-
hasMultiCollection(model) ||
|
|
313
|
-
hasSsvCollection(model) ||
|
|
314
|
-
hasPipeCollection(model) ||
|
|
315
|
-
hasTsvCollection(model) ||
|
|
316
|
-
hasCsvCollection(model)
|
|
317
|
-
) {
|
|
318
|
-
file.addExportDeclarations([
|
|
319
|
-
{
|
|
320
|
-
moduleSpecifier: getImportModuleName(
|
|
321
|
-
{
|
|
322
|
-
cjsName: `./serializeHelper`,
|
|
323
|
-
esModulesName: `./serializeHelper.js`,
|
|
324
|
-
},
|
|
325
|
-
model,
|
|
326
|
-
),
|
|
327
|
-
},
|
|
328
|
-
]);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
if (isAzurePackage(model)) {
|
|
332
|
-
file.addExportDeclarations([
|
|
333
|
-
{
|
|
334
|
-
moduleSpecifier: "@azure/core-rest-pipeline",
|
|
335
|
-
namedExports: ["RestError", "isRestError"],
|
|
336
|
-
},
|
|
337
|
-
]);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
file.addExportAssignment({
|
|
341
|
-
expression: createClientFuncName,
|
|
342
|
-
isExportEquals: false,
|
|
343
|
-
});
|
|
344
|
-
}
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
import {
|
|
6
|
-
FunctionDeclarationOverloadStructure,
|
|
7
|
-
OptionalKind,
|
|
8
|
-
Project,
|
|
9
|
-
VariableDeclarationKind,
|
|
10
|
-
} from "ts-morph";
|
|
11
|
-
import { getImportModuleName } from "./helpers/name-constructors.js";
|
|
12
|
-
import { hasUnexpectedHelper } from "./helpers/operation-helpers.js";
|
|
13
|
-
import { RLCModel } from "./interfaces.js";
|
|
14
|
-
export function buildIsUnexpectedHelper(model: RLCModel) {
|
|
15
|
-
if (!hasUnexpectedHelper(model)) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const project = new Project();
|
|
19
|
-
const srcPath = model.srcPath;
|
|
20
|
-
const filePath = path.join(srcPath, `isUnexpected.ts`);
|
|
21
|
-
const isErrorHelper = project.createSourceFile(filePath, undefined, {
|
|
22
|
-
overwrite: true,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
let map: Record<string, string[]> = {};
|
|
26
|
-
const allResponseTypes: Set<string> = new Set();
|
|
27
|
-
const allErrorTypes: Set<string> = new Set();
|
|
28
|
-
const overloads: OptionalKind<FunctionDeclarationOverloadStructure>[] = [];
|
|
29
|
-
const pathDictionary = model.paths;
|
|
30
|
-
|
|
31
|
-
for (const [path, details] of Object.entries(pathDictionary)) {
|
|
32
|
-
for (const [methodName, methodDetails] of Object.entries(details.methods)) {
|
|
33
|
-
const originalMethod = methodName.toUpperCase();
|
|
34
|
-
const operation = `${originalMethod} ${path}`;
|
|
35
|
-
const successCodeSet = new Set<string>(map["operation"] ?? []);
|
|
36
|
-
for (const detail of methodDetails) {
|
|
37
|
-
detail.successStatus.forEach(successCodeSet.add, successCodeSet);
|
|
38
|
-
// LROs may call the same path but with GET
|
|
39
|
-
// to get the operation status.
|
|
40
|
-
if (detail.operationHelperDetail?.lroDetails?.isLongRunning && originalMethod !== "GET") {
|
|
41
|
-
const operation = `GET ${path}`;
|
|
42
|
-
const logicalSuccessCodes = detail.operationHelperDetail?.lroDetails?.logicalResponseTypes
|
|
43
|
-
?.success
|
|
44
|
-
? ["200"]
|
|
45
|
-
: [];
|
|
46
|
-
const initialSuccessCodes =
|
|
47
|
-
(pathDictionary[path]?.methods["get"] &&
|
|
48
|
-
pathDictionary[path]?.methods["get"]?.[0]?.successStatus) ??
|
|
49
|
-
detail.successStatus;
|
|
50
|
-
map = {
|
|
51
|
-
...map,
|
|
52
|
-
...{
|
|
53
|
-
[operation]: Array.from(new Set(logicalSuccessCodes.concat(initialSuccessCodes))),
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const successTypes = [...detail.responseTypes.success];
|
|
59
|
-
const errorTypes = [...detail.responseTypes.error];
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
model.helperDetails?.clientLroOverload &&
|
|
63
|
-
detail.operationHelperDetail?.lroDetails?.logicalResponseTypes?.success
|
|
64
|
-
) {
|
|
65
|
-
successTypes.push(
|
|
66
|
-
...(detail.operationHelperDetail.lroDetails.logicalResponseTypes.success ?? []),
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!successTypes.length || !errorTypes.length || !errorTypes[0]) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
successTypes.forEach((t) => allResponseTypes.add(t));
|
|
75
|
-
errorTypes.forEach((t) => {
|
|
76
|
-
allResponseTypes.add(t);
|
|
77
|
-
allErrorTypes.add(t);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
overloads.push({
|
|
81
|
-
isExported: true,
|
|
82
|
-
parameters: [
|
|
83
|
-
{
|
|
84
|
-
name: "response",
|
|
85
|
-
type: [...successTypes, ...errorTypes].join(" | "),
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
returnType: `response is ${errorTypes[0]}`,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
map = { ...map, ...{ [operation]: Array.from(successCodeSet) } };
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
isErrorHelper.addImportDeclaration({
|
|
95
|
-
isTypeOnly: true,
|
|
96
|
-
namedImports: [...allResponseTypes],
|
|
97
|
-
moduleSpecifier: getImportModuleName(
|
|
98
|
-
{
|
|
99
|
-
cjsName: `./responses`,
|
|
100
|
-
esModulesName: `./responses.js`,
|
|
101
|
-
},
|
|
102
|
-
model,
|
|
103
|
-
),
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
isErrorHelper.addVariableStatement({
|
|
107
|
-
declarations: [
|
|
108
|
-
{
|
|
109
|
-
name: "responseMap",
|
|
110
|
-
initializer: JSON.stringify(map),
|
|
111
|
-
type: "Record<string, string[]>",
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
declarationKind: VariableDeclarationKind.Const,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
if (allErrorTypes.size) {
|
|
118
|
-
isErrorHelper.addFunction({
|
|
119
|
-
overloads,
|
|
120
|
-
isExported: true,
|
|
121
|
-
name: "isUnexpected",
|
|
122
|
-
parameters: [
|
|
123
|
-
{
|
|
124
|
-
name: "response",
|
|
125
|
-
type: [...allResponseTypes].join(" | "),
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
returnType: `response is ${[...allErrorTypes].join(" | ")}`,
|
|
129
|
-
statements: [
|
|
130
|
-
`
|
|
131
|
-
const lroOriginal = response.headers["x-ms-original-url"];
|
|
132
|
-
const url = new URL(lroOriginal ?? response.request.url);
|
|
133
|
-
const method = response.request.method;
|
|
134
|
-
let pathDetails = responseMap[\`\${method} \${url.pathname}\`];
|
|
135
|
-
if (!pathDetails) {
|
|
136
|
-
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
137
|
-
}
|
|
138
|
-
return !pathDetails.includes(response.status);
|
|
139
|
-
`,
|
|
140
|
-
],
|
|
141
|
-
});
|
|
142
|
-
isErrorHelper.addFunction({
|
|
143
|
-
isExported: false,
|
|
144
|
-
name: "getParametrizedPathSuccess",
|
|
145
|
-
parameters: [
|
|
146
|
-
{
|
|
147
|
-
name: "method",
|
|
148
|
-
type: "string",
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
name: "path",
|
|
152
|
-
type: "string",
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
returnType: `string[]`,
|
|
156
|
-
statements: [
|
|
157
|
-
`
|
|
158
|
-
const pathParts = path.split("/");
|
|
159
|
-
|
|
160
|
-
// Traverse list to match the longest candidate
|
|
161
|
-
// matchedLen: the length of candidate path
|
|
162
|
-
// matchedValue: the matched status code array
|
|
163
|
-
let matchedLen = -1,
|
|
164
|
-
matchedValue: string[] = [];
|
|
165
|
-
|
|
166
|
-
// Iterate the responseMap to find a match
|
|
167
|
-
for (const [key, value] of Object.entries(responseMap)) {
|
|
168
|
-
// Extracting the path from the map key which is in format
|
|
169
|
-
// GET /path/foo
|
|
170
|
-
if (!key.startsWith(method)) {
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
const candidatePath = getPathFromMapKey(key);
|
|
174
|
-
// Get each part of the url path
|
|
175
|
-
const candidateParts = candidatePath.split("/");
|
|
176
|
-
|
|
177
|
-
// track if we have found a match to return the values found.
|
|
178
|
-
let found = true;
|
|
179
|
-
for (
|
|
180
|
-
let i = candidateParts.length - 1, j = pathParts.length - 1;
|
|
181
|
-
i >= 1 && j >= 1;
|
|
182
|
-
i--, j--
|
|
183
|
-
) {
|
|
184
|
-
if (
|
|
185
|
-
candidateParts[i]?.startsWith("{") &&
|
|
186
|
-
candidateParts[i]?.indexOf("}") !== -1
|
|
187
|
-
) {
|
|
188
|
-
const start = candidateParts[i]!.indexOf("}") + 1,
|
|
189
|
-
end = candidateParts[i]?.length;
|
|
190
|
-
// If the current part of the candidate is a "template" part
|
|
191
|
-
// Try to use the suffix of pattern to match the path
|
|
192
|
-
// {guid} ==> $
|
|
193
|
-
// {guid}:export ==> :export$
|
|
194
|
-
const isMatched = new RegExp(
|
|
195
|
-
\`\${candidateParts[i]?.slice(start, end)}\`
|
|
196
|
-
).test(pathParts[j] || '');
|
|
197
|
-
|
|
198
|
-
if (!isMatched) {
|
|
199
|
-
found = false;
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// If the candidate part is not a template and
|
|
206
|
-
// the parts don't match mark the candidate as not found
|
|
207
|
-
// to move on with the next candidate path.
|
|
208
|
-
if (candidateParts[i] !== pathParts[j]) {
|
|
209
|
-
found = false;
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// We finished evaluating the current candidate parts
|
|
215
|
-
// Update the matched value if and only if we found the longer pattern
|
|
216
|
-
if (found && candidatePath.length > matchedLen) {
|
|
217
|
-
matchedLen = candidatePath.length;
|
|
218
|
-
matchedValue = value;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return matchedValue;
|
|
223
|
-
`,
|
|
224
|
-
],
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
isErrorHelper.addFunction({
|
|
228
|
-
isExported: false,
|
|
229
|
-
name: "getPathFromMapKey",
|
|
230
|
-
parameters: [
|
|
231
|
-
{
|
|
232
|
-
name: "mapKey",
|
|
233
|
-
type: "string",
|
|
234
|
-
},
|
|
235
|
-
],
|
|
236
|
-
returnType: `string`,
|
|
237
|
-
statements: [
|
|
238
|
-
`const pathStart = mapKey.indexOf("/");
|
|
239
|
-
return mapKey.slice(pathStart);`,
|
|
240
|
-
],
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return {
|
|
245
|
-
path: filePath,
|
|
246
|
-
content: isErrorHelper.getFullText(),
|
|
247
|
-
};
|
|
248
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
import { Project } from "ts-morph";
|
|
6
|
-
import { RLCModel } from "./interfaces.js";
|
|
7
|
-
|
|
8
|
-
export function buildLogger(model: RLCModel) {
|
|
9
|
-
if (!model.options) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
// Disable logger for non-Azure packages
|
|
13
|
-
if (model.options.flavor !== "azure") {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
const project = new Project();
|
|
17
|
-
const { srcPath, rlcSourceDir } = model;
|
|
18
|
-
const { packageDetails } = model.options;
|
|
19
|
-
const filePath = path.join(
|
|
20
|
-
model.options.sourceFrom === "Swagger"
|
|
21
|
-
? srcPath.substring(
|
|
22
|
-
0,
|
|
23
|
-
srcPath.includes("generated") && !srcPath.includes("src")
|
|
24
|
-
? srcPath.lastIndexOf("generated") + 10
|
|
25
|
-
: srcPath.lastIndexOf("src") + 4,
|
|
26
|
-
)
|
|
27
|
-
: rlcSourceDir!,
|
|
28
|
-
`logger.ts`,
|
|
29
|
-
);
|
|
30
|
-
const loggerFile = project.createSourceFile("logger.ts", undefined, {
|
|
31
|
-
overwrite: true,
|
|
32
|
-
});
|
|
33
|
-
loggerFile.addImportDeclaration({
|
|
34
|
-
namedImports: ["createClientLogger"],
|
|
35
|
-
moduleSpecifier: `@azure/logger`,
|
|
36
|
-
});
|
|
37
|
-
loggerFile.addStatements(
|
|
38
|
-
`export const logger = createClientLogger("${
|
|
39
|
-
packageDetails!.nameWithoutScope ?? packageDetails?.name ?? ""
|
|
40
|
-
}")`,
|
|
41
|
-
);
|
|
42
|
-
return { path: filePath, content: loggerFile.getFullText() };
|
|
43
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import { CasingConvention, NameType, normalizeName, ReservedName } from "./helpers/name-utils.js";
|
|
5
|
-
import { PathMetadata, PathParameter, Paths } from "./interfaces.js";
|
|
6
|
-
|
|
7
|
-
export const REST_CLIENT_RESERVED: ReservedName[] = [
|
|
8
|
-
{ name: "path", reservedFor: [NameType.Property, NameType.OperationGroup] },
|
|
9
|
-
{
|
|
10
|
-
name: "pathUnchecked",
|
|
11
|
-
reservedFor: [NameType.Property, NameType.OperationGroup],
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
name: "pipeline",
|
|
15
|
-
reservedFor: [NameType.Property, NameType.OperationGroup],
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
export function buildMethodShortcutImplementation(paths: Paths) {
|
|
20
|
-
const keys: Record<string, string[]> = {};
|
|
21
|
-
for (const path of Object.keys(paths)) {
|
|
22
|
-
const pathMetadata = paths[path];
|
|
23
|
-
if (!pathMetadata) {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
const groupName = normalizeName(
|
|
27
|
-
pathMetadata.operationGroupName,
|
|
28
|
-
NameType.OperationGroup,
|
|
29
|
-
true,
|
|
30
|
-
REST_CLIENT_RESERVED,
|
|
31
|
-
CasingConvention.Camel,
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
if (keys[groupName]) {
|
|
35
|
-
keys[groupName].push(...buildOperationDeclarations(path, pathMetadata));
|
|
36
|
-
} else {
|
|
37
|
-
keys[groupName] = buildOperationDeclarations(path, pathMetadata);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return keys;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function buildOperationDeclarations(path: string, pathMetadata: PathMetadata) {
|
|
44
|
-
let ops: string[] = [];
|
|
45
|
-
for (const method of Object.keys(pathMetadata.methods)) {
|
|
46
|
-
const methodOps = pathMetadata.methods[method];
|
|
47
|
-
if (!methodOps) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
for (const op of methodOps) {
|
|
51
|
-
const pathParams = pathMetadata?.pathParameters;
|
|
52
|
-
const name = normalizeName(op.operationName, NameType.Property);
|
|
53
|
-
const methodDefinitions = generateOperationDeclaration(path, name, method, pathParams);
|
|
54
|
-
ops = [...ops, methodDefinitions];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return ops;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function generateOperationDeclaration(
|
|
62
|
-
path: string,
|
|
63
|
-
operationName: string,
|
|
64
|
-
method: string,
|
|
65
|
-
pathParams: PathParameter[] = [],
|
|
66
|
-
): string {
|
|
67
|
-
const pathParamNames = `${pathParams.length > 0 ? `${pathParams.map((p) => p.name)},` : ""}`;
|
|
68
|
-
return `"${operationName}": (${pathParamNames} options) => {
|
|
69
|
-
return client.path("${path}", ${pathParamNames}).${method}(options);
|
|
70
|
-
}`;
|
|
71
|
-
}
|