From ac95934b08271a4f104b56cb7ec49b63e3f4bb35 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 18 Nov 2021 22:06:18 +0000 Subject: [PATCH] chore(NA): splits types from code on @elastic/apm-synthtrace (#118786) * chore(NA): auto creation of the package.json for the new types pkg rule * chore(NA): first alpha api extractor working version * chore(NA): support kbn-analytics * chore(NA): correctly read tsconfig files and deps from ts_config rule * chore(NA): layed out pkg_npm_types tree artifact custom rule * chore(NA): missing todos * chore(NA): node modules link mapping * chore(NA): fully working pkg_npm_types rule * chore(NA): fix changes on new packages using elastic datemath pkgs * docs(NA): remove todo * docs(NA): last todo text correction * chore(NA): removed commented lines * fix(NA): include missing package version * chore(NA): include license keys * chore(NA): change mock types package into private * chore(NA): split types_pkg from code_pkg on @elastic/apm-synthtrace * chore(NA): disable validator on ts_project rule * chore(NA): move into ts_project wrapper * chore(NA): complete types exports * chore(NA): export types as type only * chore(NA): fix type exports * chore(NA): only include exception type Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- package.json | 1 + packages/BUILD.bazel | 1 + packages/elastic-apm-synthtrace/BUILD.bazel | 34 ++++++++++++++------ packages/elastic-apm-synthtrace/package.json | 1 - packages/elastic-apm-synthtrace/src/index.ts | 1 + yarn.lock | 4 +++ 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 576b763af9d50..ad70aa18a28e6 100644 --- a/package.json +++ b/package.json @@ -509,6 +509,7 @@ "@types/deep-freeze-strict": "^1.1.0", "@types/delete-empty": "^2.0.0", "@types/ejs": "^3.0.6", + "@types/elastic__apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace/npm_module_types", "@types/elastic__datemath": "link:bazel-bin/packages/elastic-datemath/npm_module_types", "@types/elasticsearch": "^5.0.33", "@types/enzyme": "^3.10.8", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index a03072fc64663..ea13727ce7615 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -73,6 +73,7 @@ filegroup( filegroup( name = "build_pkg_types", srcs = [ + "//packages/elastic-apm-synthtrace:build_types", "//packages/elastic-datemath:build_types", ], ) diff --git a/packages/elastic-apm-synthtrace/BUILD.bazel b/packages/elastic-apm-synthtrace/BUILD.bazel index 8ae1632ffee4c..7fb188de435b6 100644 --- a/packages/elastic-apm-synthtrace/BUILD.bazel +++ b/packages/elastic-apm-synthtrace/BUILD.bazel @@ -1,9 +1,10 @@ -load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") -load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") -load("//src/dev/bazel:index.bzl", "jsts_transpiler") +load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") PKG_BASE_NAME = "elastic-apm-synthtrace" PKG_REQUIRE_NAME = "@elastic/apm-synthtrace" +TYPES_PKG_REQUIRE_NAME = "@types/elastic__apm-synthtrace" SOURCE_FILES = glob( [ @@ -31,21 +32,18 @@ RUNTIME_DEPS = [ "@npm//moment", "@npm//object-hash", "@npm//p-limit", - "@npm//utility-types", - "@npm//uuid", "@npm//yargs", ] TYPES_DEPS = [ "//packages/elastic-datemath:npm_module_types", "@npm//@elastic/elasticsearch", - "@npm//moment", - "@npm//p-limit", "@npm//@types/jest", "@npm//@types/lodash", "@npm//@types/node", - "@npm//@types/uuid", "@npm//@types/object-hash", + "@npm//moment", + "@npm//p-limit", ] jsts_transpiler( @@ -75,12 +73,13 @@ ts_project( root_dir = "src", source_map = True, tsconfig = ":tsconfig", + validate = False, ) js_library( name = PKG_BASE_NAME, srcs = NPM_MODULE_EXTRA_FILES, - deps = RUNTIME_DEPS + [":target_node", ":tsc_types"], + deps = RUNTIME_DEPS + [":target_node"], package_name = PKG_REQUIRE_NAME, visibility = ["//visibility:public"], ) @@ -99,3 +98,20 @@ filegroup( ], visibility = ["//visibility:public"], ) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = TYPES_PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [ + ":npm_module_types", + ], + visibility = ["//visibility:public"], +) diff --git a/packages/elastic-apm-synthtrace/package.json b/packages/elastic-apm-synthtrace/package.json index 43699e4795586..d2f2016a891b3 100644 --- a/packages/elastic-apm-synthtrace/package.json +++ b/packages/elastic-apm-synthtrace/package.json @@ -4,6 +4,5 @@ "description": "Elastic APM trace data generator", "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target_node/index.js", - "types": "./target_types/index.d.ts", "private": true } diff --git a/packages/elastic-apm-synthtrace/src/index.ts b/packages/elastic-apm-synthtrace/src/index.ts index 70105438ff5ae..931215c75fde4 100644 --- a/packages/elastic-apm-synthtrace/src/index.ts +++ b/packages/elastic-apm-synthtrace/src/index.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +export type { Exception } from './lib/entity'; export { service } from './lib/service'; export { browser } from './lib/browser'; export { timerange } from './lib/timerange'; diff --git a/yarn.lock b/yarn.lock index 9c3f279557035..b061a9032f743 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5361,6 +5361,10 @@ resolved "https://registry.yarnpkg.com/@types/ejs/-/ejs-3.0.6.tgz#aca442289df623bfa8e47c23961f0357847b83fe" integrity sha512-fj1hi+ZSW0xPLrJJD+YNwIh9GZbyaIepG26E/gXvp8nCa2pYokxUYO1sK9qjGxp2g8ryZYuon7wmjpwE2cyASQ== +"@types/elastic__apm-synthtrace@link:bazel-bin/packages/elastic-apm-synthtrace/npm_module_types": + version "0.0.0" + uid "" + "@types/elastic__datemath@link:bazel-bin/packages/elastic-datemath/npm_module_types": version "0.0.0" uid ""