From b1358b30e2c4cb8ed7d0ecfa3f4ae64229265e69 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Sun, 12 Oct 2025 00:58:23 +0700 Subject: [PATCH] Script to sync eslint deps --- .../main_2025-10-10-14-14.json | 10 - .../measurements/main_2025-10-10-14-14.json | 10 - .../postgres-base/main_2025-10-10-14-14.json | 10 - common/config/rush/pnpm-lock.yaml | 346 ++++++++++++++---- common/scripts/package.json | 9 +- packages/measurements-otlp/CHANGELOG.json | 25 ++ packages/measurements-otlp/CHANGELOG.md | 9 +- packages/measurements-otlp/package.json | 16 +- .../src/__tests__/telemetry.test.ts | 40 +- packages/measurements/CHANGELOG.json | 22 ++ packages/measurements/CHANGELOG.md | 9 +- packages/measurements/package.json | 14 +- .../src/__tests__/context.test.ts | 168 +++++---- .../measurements/src/__tests__/index.test.ts | 14 +- .../src/__tests__/metrics.test.ts | 106 +++--- .../src/__tests__/performance.test.ts | 35 +- packages/measurements/src/index.ts | 2 +- packages/platform-rig/CHANGELOG.json | 12 + packages/platform-rig/CHANGELOG.md | 9 +- packages/platform-rig/bin/sync-eslint-deps.js | 187 ++++++++++ packages/platform-rig/package.json | 14 +- packages/postgres-base/CHANGELOG.json | 17 + packages/postgres-base/CHANGELOG.md | 9 +- packages/postgres-base/package.json | 14 +- 24 files changed, 814 insertions(+), 293 deletions(-) delete mode 100644 common/changes/@hcengineering/measurements-otlp/main_2025-10-10-14-14.json delete mode 100644 common/changes/@hcengineering/measurements/main_2025-10-10-14-14.json delete mode 100644 common/changes/@hcengineering/postgres-base/main_2025-10-10-14-14.json create mode 100755 packages/platform-rig/bin/sync-eslint-deps.js diff --git a/common/changes/@hcengineering/measurements-otlp/main_2025-10-10-14-14.json b/common/changes/@hcengineering/measurements-otlp/main_2025-10-10-14-14.json deleted file mode 100644 index 2f15c7c742..0000000000 --- a/common/changes/@hcengineering/measurements-otlp/main_2025-10-10-14-14.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@hcengineering/measurements-otlp", - "comment": "Add tests", - "type": "none" - } - ], - "packageName": "@hcengineering/measurements-otlp" -} \ No newline at end of file diff --git a/common/changes/@hcengineering/measurements/main_2025-10-10-14-14.json b/common/changes/@hcengineering/measurements/main_2025-10-10-14-14.json deleted file mode 100644 index e0b4688e14..0000000000 --- a/common/changes/@hcengineering/measurements/main_2025-10-10-14-14.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@hcengineering/measurements", - "comment": "Add tests", - "type": "none" - } - ], - "packageName": "@hcengineering/measurements" -} \ No newline at end of file diff --git a/common/changes/@hcengineering/postgres-base/main_2025-10-10-14-14.json b/common/changes/@hcengineering/postgres-base/main_2025-10-10-14-14.json deleted file mode 100644 index 471a48b322..0000000000 --- a/common/changes/@hcengineering/postgres-base/main_2025-10-10-14-14.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@hcengineering/postgres-base", - "comment": "", - "type": "none" - } - ], - "packageName": "@hcengineering/postgres-base" -} \ No newline at end of file diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index b124de599c..480300df36 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -18,6 +18,30 @@ importers: '@types/jest': specifier: ^29.5.5 version: 29.5.14 + '@typescript-eslint/eslint-plugin': + specifier: ^8.46.0 + version: 8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/parser': + specifier: ^8.46.0 + version: 8.46.0(eslint@8.57.1)(typescript@5.9.3) + eslint: + specifier: ^8.54.0 + version: 8.57.1 + eslint-config-standard-with-typescript: + specifier: ^40.0.0 + version: 40.0.0(@typescript-eslint/eslint-plugin@8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3))(eslint-plugin-import@2.32.0(eslint@8.57.1))(eslint-plugin-n@15.7.0(eslint@8.57.1))(eslint-plugin-promise@6.6.0(eslint@8.57.1))(eslint@8.57.1)(typescript@5.9.3) + eslint-plugin-import: + specifier: ^2.26.0 + version: 2.32.0(eslint@8.57.1) + eslint-plugin-n: + specifier: ^15.4.0 + version: 15.7.0(eslint@8.57.1) + eslint-plugin-node: + specifier: ^11.1.0 + version: 11.1.0(eslint@8.57.1) + eslint-plugin-promise: + specifier: ^6.1.1 + version: 6.6.0(eslint@8.57.1) jest: specifier: ^29.7.0 version: 29.7.0(@types/node@22.18.1) @@ -79,6 +103,30 @@ importers: '@types/jest': specifier: ^29.5.5 version: 29.5.14 + '@typescript-eslint/eslint-plugin': + specifier: ^8.46.0 + version: 8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/parser': + specifier: ^8.46.0 + version: 8.46.0(eslint@8.57.1)(typescript@5.9.3) + eslint: + specifier: ^8.54.0 + version: 8.57.1 + eslint-config-standard-with-typescript: + specifier: ^40.0.0 + version: 40.0.0(@typescript-eslint/eslint-plugin@8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3))(eslint-plugin-import@2.32.0(eslint@8.57.1))(eslint-plugin-n@15.7.0(eslint@8.57.1))(eslint-plugin-promise@6.6.0(eslint@8.57.1))(eslint@8.57.1)(typescript@5.9.3) + eslint-plugin-import: + specifier: ^2.26.0 + version: 2.32.0(eslint@8.57.1) + eslint-plugin-n: + specifier: ^15.4.0 + version: 15.7.0(eslint@8.57.1) + eslint-plugin-node: + specifier: ^11.1.0 + version: 11.1.0(eslint@8.57.1) + eslint-plugin-promise: + specifier: ^6.1.1 + version: 6.6.0(eslint@8.57.1) jest: specifier: ^29.7.0 version: 29.7.0(@types/node@22.18.1) @@ -89,11 +137,11 @@ importers: ../../packages/platform-rig: dependencies: '@typescript-eslint/eslint-plugin': - specifier: ^6.11.0 - version: 6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3) + specifier: ^8.46.0 + version: 8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3) '@typescript-eslint/parser': - specifier: ^6.11.0 - version: 6.21.0(eslint@8.57.1)(typescript@5.9.3) + specifier: ^8.46.0 + version: 8.46.0(eslint@8.57.1)(typescript@5.9.3) esbuild: specifier: ^0.25.10 version: 0.25.10 @@ -105,7 +153,7 @@ importers: version: 8.57.1 eslint-config-standard-with-typescript: specifier: ^40.0.0 - version: 40.0.0(@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3))(eslint-plugin-import@2.32.0(eslint@8.57.1))(eslint-plugin-n@15.7.0(eslint@8.57.1))(eslint-plugin-promise@6.6.0(eslint@8.57.1))(eslint@8.57.1)(typescript@5.9.3) + version: 40.0.0(@typescript-eslint/eslint-plugin@8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3))(eslint-plugin-import@2.32.0(eslint@8.57.1))(eslint-plugin-n@15.7.0(eslint@8.57.1))(eslint-plugin-promise@6.6.0(eslint@8.57.1))(eslint@8.57.1)(typescript@5.9.3) eslint-plugin-import: specifier: ^2.26.0 version: 2.32.0(eslint@8.57.1) @@ -143,6 +191,30 @@ importers: '@types/node': specifier: ^22.15.29 version: 22.18.1 + '@typescript-eslint/eslint-plugin': + specifier: ^8.46.0 + version: 8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/parser': + specifier: ^8.46.0 + version: 8.46.0(eslint@8.57.1)(typescript@5.9.3) + eslint: + specifier: ^8.54.0 + version: 8.57.1 + eslint-config-standard-with-typescript: + specifier: ^40.0.0 + version: 40.0.0(@typescript-eslint/eslint-plugin@8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3))(eslint-plugin-import@2.32.0(eslint@8.57.1))(eslint-plugin-n@15.7.0(eslint@8.57.1))(eslint-plugin-promise@6.6.0(eslint@8.57.1))(eslint@8.57.1)(typescript@5.9.3) + eslint-plugin-import: + specifier: ^2.26.0 + version: 2.32.0(eslint@8.57.1) + eslint-plugin-n: + specifier: ^15.4.0 + version: 15.7.0(eslint@8.57.1) + eslint-plugin-node: + specifier: ^11.1.0 + version: 11.1.0(eslint@8.57.1) + eslint-plugin-promise: + specifier: ^6.1.1 + version: 6.6.0(eslint@8.57.1) jest: specifier: ^29.7.0 version: 29.7.0(@types/node@22.18.1) @@ -155,6 +227,27 @@ importers: '@hcengineering/platform-rig': specifier: workspace:^0.7.12 version: link:../../packages/platform-rig + '@typescript-eslint/eslint-plugin': + specifier: ^8.46.0 + version: 8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/parser': + specifier: ^8.46.0 + version: 8.46.0(eslint@8.57.1)(typescript@5.9.3) + eslint: + specifier: ^8.54.0 + version: 8.57.1 + eslint-config-standard-with-typescript: + specifier: ^40.0.0 + version: 40.0.0(@typescript-eslint/eslint-plugin@8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3))(eslint-plugin-import@2.32.0(eslint@8.57.1))(eslint-plugin-n@15.7.0(eslint@8.57.1))(eslint-plugin-promise@6.6.0(eslint@8.57.1))(eslint@8.57.1)(typescript@5.9.3) + eslint-plugin-import: + specifier: ^2.26.0 + version: 2.32.0(eslint@8.57.1) + eslint-plugin-n: + specifier: ^15.4.0 + version: 15.7.0(eslint@8.57.1) + eslint-plugin-promise: + specifier: ^6.1.1 + version: 6.6.0(eslint@8.57.1) packages: @@ -1200,9 +1293,6 @@ packages: '@types/jest@29.5.14': resolution: {integrity: sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==} - '@types/json-schema@7.0.15': - resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} - '@types/json5@0.0.29': resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} @@ -1224,9 +1314,6 @@ packages: '@types/pg@8.15.5': resolution: {integrity: sha512-LF7lF6zWEKxuT3/OR8wAZGzkg4ENGXFNyiV/JeOt9z5B+0ZVwbql9McqX5c/WStFq1GaGso7H1AzP/qSzmlCKQ==} - '@types/semver@7.7.1': - resolution: {integrity: sha512-FmgJfu+MOcQ370SD0ev7EI8TlCAfKYU+B4m5T3yXc1CiRN94g/SZPtsCkk506aUDtlMnFZvasDwHHUcZUEaYuA==} - '@types/stack-utils@2.0.3': resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} @@ -1239,16 +1326,13 @@ packages: '@types/yargs@17.0.33': resolution: {integrity: sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==} - '@typescript-eslint/eslint-plugin@6.21.0': - resolution: {integrity: sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==} - engines: {node: ^16.0.0 || >=18.0.0} + '@typescript-eslint/eslint-plugin@8.46.0': + resolution: {integrity: sha512-hA8gxBq4ukonVXPy0OKhiaUh/68D0E88GSmtC1iAEnGaieuDi38LhS7jdCHRLi6ErJBNDGCzvh5EnzdPwUc0DA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha - eslint: ^7.0.0 || ^8.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true + '@typescript-eslint/parser': ^8.46.0 + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <6.0.0' '@typescript-eslint/parser@6.21.0': resolution: {integrity: sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==} @@ -1260,24 +1344,48 @@ packages: typescript: optional: true + '@typescript-eslint/parser@8.46.0': + resolution: {integrity: sha512-n1H6IcDhmmUEG7TNVSspGmiHHutt7iVKtZwRppD7e04wha5MrkV1h3pti9xQLcCMt6YWsncpoT0HMjkH1FNwWQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <6.0.0' + + '@typescript-eslint/project-service@8.46.0': + resolution: {integrity: sha512-OEhec0mH+U5Je2NZOeK1AbVCdm0ChyapAyTeXVIYTPXDJ3F07+cu87PPXcGoYqZ7M9YJVvFnfpGg1UmCIqM+QQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.0.0' + '@typescript-eslint/scope-manager@6.21.0': resolution: {integrity: sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==} engines: {node: ^16.0.0 || >=18.0.0} - '@typescript-eslint/type-utils@6.21.0': - resolution: {integrity: sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag==} - engines: {node: ^16.0.0 || >=18.0.0} + '@typescript-eslint/scope-manager@8.46.0': + resolution: {integrity: sha512-lWETPa9XGcBes4jqAMYD9fW0j4n6hrPtTJwWDmtqgFO/4HF4jmdH/Q6wggTw5qIT5TXjKzbt7GsZUBnWoO3dqw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/tsconfig-utils@8.46.0': + resolution: {integrity: sha512-WrYXKGAHY836/N7zoK/kzi6p8tXFhasHh8ocFL9VZSAkvH956gfeRfcnhs3xzRy8qQ/dq3q44v1jvQieMFg2cw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true + typescript: '>=4.8.4 <6.0.0' + + '@typescript-eslint/type-utils@8.46.0': + resolution: {integrity: sha512-hy+lvYV1lZpVs2jRaEYvgCblZxUoJiPyCemwbQZ+NGulWkQRy0HRPYAoef/CNSzaLt+MLvMptZsHXHlkEilaeg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <6.0.0' '@typescript-eslint/types@6.21.0': resolution: {integrity: sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==} engines: {node: ^16.0.0 || >=18.0.0} + '@typescript-eslint/types@8.46.0': + resolution: {integrity: sha512-bHGGJyVjSE4dJJIO5yyEWt/cHyNwga/zXGJbJJ8TiO01aVREK6gCTu3L+5wrkb1FbDkQ+TKjMNe9R/QQQP9+rA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript-eslint/typescript-estree@6.21.0': resolution: {integrity: sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==} engines: {node: ^16.0.0 || >=18.0.0} @@ -1287,16 +1395,27 @@ packages: typescript: optional: true - '@typescript-eslint/utils@6.21.0': - resolution: {integrity: sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==} - engines: {node: ^16.0.0 || >=18.0.0} + '@typescript-eslint/typescript-estree@8.46.0': + resolution: {integrity: sha512-ekDCUfVpAKWJbRfm8T1YRrCot1KFxZn21oV76v5Fj4tr7ELyk84OS+ouvYdcDAwZL89WpEkEj2DKQ+qg//+ucg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 + typescript: '>=4.8.4 <6.0.0' + + '@typescript-eslint/utils@8.46.0': + resolution: {integrity: sha512-nD6yGWPj1xiOm4Gk0k6hLSZz2XkNXhuYmyIrOWcHoPuAhjT9i5bAG+xbWPgFeNR8HPHHtpNKdYUXJl/D3x7f5g==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <6.0.0' '@typescript-eslint/visitor-keys@6.21.0': resolution: {integrity: sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==} engines: {node: ^16.0.0 || >=18.0.0} + '@typescript-eslint/visitor-keys@8.46.0': + resolution: {integrity: sha512-FrvMpAK+hTbFy7vH5j1+tMYHMSKLE6RzluFJlkFNKD0p9YsUT75JlBSmr5so3QRzvMwU5/bIEdeNrxm8du8l3Q==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@ungap/structured-clone@1.3.0': resolution: {integrity: sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==} @@ -1707,6 +1826,12 @@ packages: eslint: optional: true + eslint-plugin-es@3.0.1: + resolution: {integrity: sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==} + engines: {node: '>=8.10.0'} + peerDependencies: + eslint: '>=4.19.1' + eslint-plugin-es@4.1.0: resolution: {integrity: sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==} engines: {node: '>=8.10.0'} @@ -1725,6 +1850,12 @@ packages: peerDependencies: eslint: '>=7.0.0' + eslint-plugin-node@11.1.0: + resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==} + engines: {node: '>=8.10.0'} + peerDependencies: + eslint: '>=5.16.0' + eslint-plugin-promise@6.6.0: resolution: {integrity: sha512-57Zzfw8G6+Gq7axm2Pdo3gW/Rx3h9Yywgn61uE/3elTCOePEHVrn2i5CdfBwA1BLK0Q0WqctICIUSqXZW/VprQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1757,6 +1888,10 @@ packages: resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + eslint-visitor-keys@4.2.1: + resolution: {integrity: sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + eslint@8.57.1: resolution: {integrity: sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2002,6 +2137,10 @@ packages: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} + ignore@7.0.5: + resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} + engines: {node: '>= 4'} + import-fresh@3.3.1: resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} engines: {node: '>=6'} @@ -2443,6 +2582,10 @@ packages: resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} engines: {node: '>=16 || 14 >=14.17'} + minimatch@9.0.5: + resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} + engines: {node: '>=16 || 14 >=14.17'} + minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} @@ -2885,6 +3028,12 @@ packages: peerDependencies: typescript: '>=4.2.0' + ts-api-utils@2.1.0: + resolution: {integrity: sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==} + engines: {node: '>=18.12'} + peerDependencies: + typescript: '>=4.8.4' + ts-jest@29.4.1: resolution: {integrity: sha512-SaeUtjfpg9Uqu8IbeDKtdaS0g8lS6FT6OzM3ezrDfErPJPHNDo/Ey+VFGP1bQIDfagYDLyRpd7O15XpG1Es2Uw==} engines: {node: ^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0} @@ -4382,8 +4531,6 @@ snapshots: expect: 29.7.0 pretty-format: 29.7.0 - '@types/json-schema@7.0.15': {} - '@types/json5@0.0.29': {} '@types/memcached@2.2.10': @@ -4412,8 +4559,6 @@ snapshots: pg-protocol: 1.10.3 pg-types: 2.2.0 - '@types/semver@7.7.1': {} - '@types/stack-utils@2.0.3': {} '@types/tedious@4.0.14': @@ -4426,22 +4571,19 @@ snapshots: dependencies: '@types/yargs-parser': 21.0.3 - '@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3)': + '@typescript-eslint/eslint-plugin@8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.1 - '@typescript-eslint/parser': 6.21.0(eslint@8.57.1)(typescript@5.9.3) - '@typescript-eslint/scope-manager': 6.21.0 - '@typescript-eslint/type-utils': 6.21.0(eslint@8.57.1)(typescript@5.9.3) - '@typescript-eslint/utils': 6.21.0(eslint@8.57.1)(typescript@5.9.3) - '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.4.1 + '@typescript-eslint/parser': 8.46.0(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/scope-manager': 8.46.0 + '@typescript-eslint/type-utils': 8.46.0(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/utils': 8.46.0(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/visitor-keys': 8.46.0 eslint: 8.57.1 graphemer: 1.4.0 - ignore: 5.3.2 + ignore: 7.0.5 natural-compare: 1.4.0 - semver: 7.7.2 - ts-api-utils: 1.4.3(typescript@5.9.3) - optionalDependencies: + ts-api-utils: 2.1.0(typescript@5.9.3) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -4459,25 +4601,57 @@ snapshots: transitivePeerDependencies: - supports-color + '@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3)': + dependencies: + '@typescript-eslint/scope-manager': 8.46.0 + '@typescript-eslint/types': 8.46.0 + '@typescript-eslint/typescript-estree': 8.46.0(typescript@5.9.3) + '@typescript-eslint/visitor-keys': 8.46.0 + debug: 4.4.1 + eslint: 8.57.1 + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/project-service@8.46.0(typescript@5.9.3)': + dependencies: + '@typescript-eslint/tsconfig-utils': 8.46.0(typescript@5.9.3) + '@typescript-eslint/types': 8.46.0 + debug: 4.4.1 + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + '@typescript-eslint/scope-manager@6.21.0': dependencies: '@typescript-eslint/types': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0 - '@typescript-eslint/type-utils@6.21.0(eslint@8.57.1)(typescript@5.9.3)': + '@typescript-eslint/scope-manager@8.46.0': dependencies: - '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.9.3) - '@typescript-eslint/utils': 6.21.0(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/types': 8.46.0 + '@typescript-eslint/visitor-keys': 8.46.0 + + '@typescript-eslint/tsconfig-utils@8.46.0(typescript@5.9.3)': + dependencies: + typescript: 5.9.3 + + '@typescript-eslint/type-utils@8.46.0(eslint@8.57.1)(typescript@5.9.3)': + dependencies: + '@typescript-eslint/types': 8.46.0 + '@typescript-eslint/typescript-estree': 8.46.0(typescript@5.9.3) + '@typescript-eslint/utils': 8.46.0(eslint@8.57.1)(typescript@5.9.3) debug: 4.4.1 eslint: 8.57.1 - ts-api-utils: 1.4.3(typescript@5.9.3) - optionalDependencies: + ts-api-utils: 2.1.0(typescript@5.9.3) typescript: 5.9.3 transitivePeerDependencies: - supports-color '@typescript-eslint/types@6.21.0': {} + '@typescript-eslint/types@8.46.0': {} + '@typescript-eslint/typescript-estree@6.21.0(typescript@5.9.3)': dependencies: '@typescript-eslint/types': 6.21.0 @@ -4493,25 +4667,43 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@6.21.0(eslint@8.57.1)(typescript@5.9.3)': + '@typescript-eslint/typescript-estree@8.46.0(typescript@5.9.3)': dependencies: - '@eslint-community/eslint-utils': 4.9.0(eslint@8.57.1) - '@types/json-schema': 7.0.15 - '@types/semver': 7.7.1 - '@typescript-eslint/scope-manager': 6.21.0 - '@typescript-eslint/types': 6.21.0 - '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.9.3) - eslint: 8.57.1 + '@typescript-eslint/project-service': 8.46.0(typescript@5.9.3) + '@typescript-eslint/tsconfig-utils': 8.46.0(typescript@5.9.3) + '@typescript-eslint/types': 8.46.0 + '@typescript-eslint/visitor-keys': 8.46.0 + debug: 4.4.1 + fast-glob: 3.3.3 + is-glob: 4.0.3 + minimatch: 9.0.5 semver: 7.7.2 + ts-api-utils: 2.1.0(typescript@5.9.3) + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/utils@8.46.0(eslint@8.57.1)(typescript@5.9.3)': + dependencies: + '@eslint-community/eslint-utils': 4.9.0(eslint@8.57.1) + '@typescript-eslint/scope-manager': 8.46.0 + '@typescript-eslint/types': 8.46.0 + '@typescript-eslint/typescript-estree': 8.46.0(typescript@5.9.3) + eslint: 8.57.1 + typescript: 5.9.3 transitivePeerDependencies: - supports-color - - typescript '@typescript-eslint/visitor-keys@6.21.0': dependencies: '@typescript-eslint/types': 6.21.0 eslint-visitor-keys: 3.4.3 + '@typescript-eslint/visitor-keys@8.46.0': + dependencies: + '@typescript-eslint/types': 8.46.0 + eslint-visitor-keys: 4.2.1 + '@ungap/structured-clone@1.3.0': {} acorn-import-attributes@1.9.5(acorn@8.15.0): @@ -5016,9 +5208,9 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-config-standard-with-typescript@40.0.0(@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3))(eslint-plugin-import@2.32.0(eslint@8.57.1))(eslint-plugin-n@15.7.0(eslint@8.57.1))(eslint-plugin-promise@6.6.0(eslint@8.57.1))(eslint@8.57.1)(typescript@5.9.3): + eslint-config-standard-with-typescript@40.0.0(@typescript-eslint/eslint-plugin@8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3))(eslint-plugin-import@2.32.0(eslint@8.57.1))(eslint-plugin-n@15.7.0(eslint@8.57.1))(eslint-plugin-promise@6.6.0(eslint@8.57.1))(eslint@8.57.1)(typescript@5.9.3): dependencies: - '@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3) + '@typescript-eslint/eslint-plugin': 8.46.0(@typescript-eslint/parser@8.46.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3) '@typescript-eslint/parser': 6.21.0(eslint@8.57.1)(typescript@5.9.3) eslint: 8.57.1 eslint-config-standard: 17.1.0(eslint-plugin-import@2.32.0(eslint@8.57.1))(eslint-plugin-n@15.7.0(eslint@8.57.1))(eslint-plugin-promise@6.6.0(eslint@8.57.1))(eslint@8.57.1) @@ -5048,6 +5240,12 @@ snapshots: optionalDependencies: eslint: 8.57.1 + eslint-plugin-es@3.0.1(eslint@8.57.1): + dependencies: + eslint: 8.57.1 + eslint-utils: 2.1.0 + regexpp: 3.2.0 + eslint-plugin-es@4.1.0(eslint@8.57.1): dependencies: eslint: 8.57.1 @@ -5089,6 +5287,16 @@ snapshots: resolve: 1.22.10 semver: 7.7.2 + eslint-plugin-node@11.1.0(eslint@8.57.1): + dependencies: + eslint: 8.57.1 + eslint-plugin-es: 3.0.1(eslint@8.57.1) + eslint-utils: 2.1.0 + ignore: 5.3.2 + minimatch: 3.1.2 + resolve: 1.22.10 + semver: 6.3.1 + eslint-plugin-promise@6.6.0(eslint@8.57.1): dependencies: eslint: 8.57.1 @@ -5113,6 +5321,8 @@ snapshots: eslint-visitor-keys@3.4.3: {} + eslint-visitor-keys@4.2.1: {} + eslint@8.57.1: dependencies: '@eslint-community/eslint-utils': 4.9.0(eslint@8.57.1) @@ -5423,6 +5633,8 @@ snapshots: ignore@5.3.2: {} + ignore@7.0.5: {} + import-fresh@3.3.1: dependencies: parent-module: 1.0.1 @@ -6045,6 +6257,10 @@ snapshots: dependencies: brace-expansion: 2.0.2 + minimatch@9.0.5: + dependencies: + brace-expansion: 2.0.2 + minimist@1.2.8: {} module-details-from-path@1.0.4: {} @@ -6509,6 +6725,10 @@ snapshots: dependencies: typescript: 5.9.3 + ts-api-utils@2.1.0(typescript@5.9.3): + dependencies: + typescript: 5.9.3 + ts-jest@29.4.1(@babel/core@7.28.4)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.28.4))(jest-util@29.7.0)(jest@29.7.0(@types/node@22.18.1))(typescript@5.9.3): dependencies: bs-logger: 0.2.6 diff --git a/common/scripts/package.json b/common/scripts/package.json index 058d929774..d394890641 100644 --- a/common/scripts/package.json +++ b/common/scripts/package.json @@ -5,7 +5,14 @@ "format": "echo \"No format specified\"" }, "devDependencies": { - "@hcengineering/platform-rig": "workspace:^0.7.12" + "@hcengineering/platform-rig": "workspace:^0.7.13", + "@typescript-eslint/eslint-plugin": "^8.46.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-promise": "^6.1.1", + "eslint-plugin-n": "^15.4.0", + "eslint": "^8.54.0", + "@typescript-eslint/parser": "^8.46.0", + "eslint-config-standard-with-typescript": "^40.0.0" }, "private": true } diff --git a/packages/measurements-otlp/CHANGELOG.json b/packages/measurements-otlp/CHANGELOG.json index 07533eb4ef..29981d5732 100644 --- a/packages/measurements-otlp/CHANGELOG.json +++ b/packages/measurements-otlp/CHANGELOG.json @@ -1,6 +1,31 @@ { "name": "@hcengineering/measurements-otlp", "entries": [ + { + "version": "0.7.11", + "tag": "@hcengineering/measurements-otlp_v0.7.11", + "date": "Sat, 11 Oct 2025 17:58:53 GMT", + "comments": { + "none": [ + { + "comment": "Add tests" + } + ], + "patch": [ + { + "comment": "Fix eslint deps" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@hcengineering/measurements\" from `^0.7.10` to `0.7.11`" + }, + { + "comment": "Updating dependency \"@hcengineering/platform-rig\" from `^0.7.12` to `0.7.13`" + } + ] + } + }, { "version": "0.7.10", "tag": "@hcengineering/measurements-otlp_v0.7.10", diff --git a/packages/measurements-otlp/CHANGELOG.md b/packages/measurements-otlp/CHANGELOG.md index 69185c1289..2b61689590 100644 --- a/packages/measurements-otlp/CHANGELOG.md +++ b/packages/measurements-otlp/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @hcengineering/measurements-otlp -This log was last generated on Fri, 10 Oct 2025 12:32:59 GMT and should not be manually modified. +This log was last generated on Sat, 11 Oct 2025 17:58:53 GMT and should not be manually modified. + +## 0.7.11 +Sat, 11 Oct 2025 17:58:53 GMT + +### Patches + +- Fix eslint deps ## 0.7.10 Fri, 10 Oct 2025 12:32:59 GMT diff --git a/packages/measurements-otlp/package.json b/packages/measurements-otlp/package.json index 26abe9d052..ef09da693e 100644 --- a/packages/measurements-otlp/package.json +++ b/packages/measurements-otlp/package.json @@ -1,6 +1,6 @@ { "name": "@hcengineering/measurements-otlp", - "version": "0.7.10", + "version": "0.7.11", "main": "lib/index.js", "svelte": "src/index.ts", "types": "types/index.d.ts", @@ -27,13 +27,21 @@ "_phase:validate": "compile validate" }, "devDependencies": { - "@hcengineering/platform-rig": "workspace:^0.7.12", + "@hcengineering/platform-rig": "workspace:^0.7.13", "jest": "^29.7.0", "ts-jest": "^29.1.1", - "@types/jest": "^29.5.5" + "@types/jest": "^29.5.5", + "@typescript-eslint/eslint-plugin": "^8.46.0", + "@typescript-eslint/parser": "^8.46.0", + "eslint": "^8.54.0", + "eslint-config-standard-with-typescript": "^40.0.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^6.1.1", + "eslint-plugin-n": "^15.4.0" }, "dependencies": { - "@hcengineering/measurements": "workspace:^0.7.10", + "@hcengineering/measurements": "workspace:^0.7.11", "@opentelemetry/sdk-node": "^0.203.0", "@opentelemetry/sdk-logs": "^0.203.0", "@opentelemetry/auto-instrumentations-node": "^0.62.0", diff --git a/packages/measurements-otlp/src/__tests__/telemetry.test.ts b/packages/measurements-otlp/src/__tests__/telemetry.test.ts index bd6aafa63a..660147942f 100644 --- a/packages/measurements-otlp/src/__tests__/telemetry.test.ts +++ b/packages/measurements-otlp/src/__tests__/telemetry.test.ts @@ -1,7 +1,7 @@ -import { OpenTelemetryMetricsContext } from '../telemetry' import { newMetrics, type MeasureLogger } from '@hcengineering/measurements' -import { trace, context, SpanStatusCode } from '@opentelemetry/api' +import { context, trace } from '@opentelemetry/api' import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node' +import { OpenTelemetryMetricsContext } from '../telemetry' describe('telemetry', () => { let tracer: any @@ -14,7 +14,7 @@ describe('telemetry', () => { }) afterAll(() => { - provider.shutdown() + void provider.shutdown() }) describe('OpenTelemetryMetricsContext', () => { @@ -101,7 +101,7 @@ describe('telemetry', () => { let executed = false await ctx.with('operation', { op: 'test' }, async () => { executed = true - await new Promise(resolve => setTimeout(resolve, 10)) + await new Promise((resolve) => setTimeout(resolve, 10)) }) expect(executed).toBe(true) @@ -132,16 +132,7 @@ describe('telemetry', () => { it('should handle errors in async operations', async () => { const metrics = newMetrics() const span = tracer.startSpan('test-span') - const ctx = new OpenTelemetryMetricsContext( - 'test', - tracer, - context.active(), - span, - {}, - {}, - metrics, - mockLogger - ) + const ctx = new OpenTelemetryMetricsContext('test', tracer, context.active(), span, {}, {}, metrics, mockLogger) await expect( ctx.with('operation', { op: 'test' }, async () => { @@ -357,16 +348,7 @@ describe('telemetry', () => { const span = tracer.startSpan('test-span') const spanEndSpy = jest.spyOn(span, 'end') - const ctx = new OpenTelemetryMetricsContext( - 'test', - tracer, - context.active(), - span, - {}, - {}, - metrics, - mockLogger - ) + const ctx = new OpenTelemetryMetricsContext('test', tracer, context.active(), span, {}, {}, metrics, mockLogger) ctx.end() ctx.end() // Second call should be no-op @@ -409,7 +391,7 @@ describe('telemetry', () => { 'operation', { op: 'test' }, async () => { - await new Promise(resolve => setTimeout(resolve, 10)) + await new Promise((resolve) => setTimeout(resolve, 10)) }, {}, { log: true } @@ -442,7 +424,7 @@ describe('telemetry', () => { it('should set span attributes from params', () => { const metrics = newMetrics() - + const ctx = new OpenTelemetryMetricsContext( 'parent', tracer, @@ -455,7 +437,11 @@ describe('telemetry', () => { ) // When creating a child with span: true, attributes are set on the child's span - const child = ctx.newChild('child', { key1: 'value1', key2: 'value2' }, { span: true }) as OpenTelemetryMetricsContext + const child = ctx.newChild( + 'child', + { key1: 'value1', key2: 'value2' }, + { span: true } + ) as OpenTelemetryMetricsContext // The child should have been created successfully expect(child).toBeDefined() diff --git a/packages/measurements/CHANGELOG.json b/packages/measurements/CHANGELOG.json index ff042fd1e9..177ce67e4c 100644 --- a/packages/measurements/CHANGELOG.json +++ b/packages/measurements/CHANGELOG.json @@ -1,6 +1,28 @@ { "name": "@hcengineering/measurements", "entries": [ + { + "version": "0.7.11", + "tag": "@hcengineering/measurements_v0.7.11", + "date": "Sat, 11 Oct 2025 17:58:53 GMT", + "comments": { + "none": [ + { + "comment": "Add tests" + } + ], + "patch": [ + { + "comment": "Fix eslint deps" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@hcengineering/platform-rig\" from `^0.7.12` to `0.7.13`" + } + ] + } + }, { "version": "0.7.10", "tag": "@hcengineering/measurements_v0.7.10", diff --git a/packages/measurements/CHANGELOG.md b/packages/measurements/CHANGELOG.md index fa46e9c0ea..d532018d7d 100644 --- a/packages/measurements/CHANGELOG.md +++ b/packages/measurements/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @hcengineering/measurements -This log was last generated on Fri, 10 Oct 2025 12:32:59 GMT and should not be manually modified. +This log was last generated on Sat, 11 Oct 2025 17:58:53 GMT and should not be manually modified. + +## 0.7.11 +Sat, 11 Oct 2025 17:58:53 GMT + +### Patches + +- Fix eslint deps ## 0.7.10 Fri, 10 Oct 2025 12:32:59 GMT diff --git a/packages/measurements/package.json b/packages/measurements/package.json index 08e79ff7b2..58b92c3489 100644 --- a/packages/measurements/package.json +++ b/packages/measurements/package.json @@ -1,6 +1,6 @@ { "name": "@hcengineering/measurements", - "version": "0.7.10", + "version": "0.7.11", "main": "lib/index.js", "svelte": "src/index.ts", "types": "types/index.d.ts", @@ -27,10 +27,18 @@ "_phase:validate": "compile validate" }, "devDependencies": { - "@hcengineering/platform-rig": "workspace:^0.7.12", + "@hcengineering/platform-rig": "workspace:^0.7.13", "jest": "^29.7.0", "ts-jest": "^29.1.1", - "@types/jest": "^29.5.5" + "@types/jest": "^29.5.5", + "@typescript-eslint/eslint-plugin": "^8.46.0", + "@typescript-eslint/parser": "^8.46.0", + "eslint": "^8.54.0", + "eslint-config-standard-with-typescript": "^40.0.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^6.1.1", + "eslint-plugin-n": "^15.4.0" }, "repository": "https://github.com/hcengineering/platform", "exports": { diff --git a/packages/measurements/src/__tests__/context.test.ts b/packages/measurements/src/__tests__/context.test.ts index 7a56de9579..ef9a65a662 100644 --- a/packages/measurements/src/__tests__/context.test.ts +++ b/packages/measurements/src/__tests__/context.test.ts @@ -16,7 +16,7 @@ describe('context', () => { describe('consoleLogger', () => { it('should create a logger with params', () => { const logger = consoleLogger({ service: 'test' }) - + expect(logger).toBeDefined() expect(typeof logger.info).toBe('function') expect(typeof logger.error).toBe('function') @@ -27,9 +27,9 @@ describe('context', () => { it('should log info messages', () => { const consoleSpy = jest.spyOn(console, 'info').mockImplementation() const logger = consoleLogger({ service: 'test' }) - + logger.info('Test message', { key: 'value' }) - + expect(consoleSpy).toHaveBeenCalled() consoleSpy.mockRestore() }) @@ -37,9 +37,9 @@ describe('context', () => { it('should log error messages', () => { const consoleSpy = jest.spyOn(console, 'error').mockImplementation() const logger = consoleLogger({ service: 'test' }) - + logger.error('Error message', { error: 'details' }) - + expect(consoleSpy).toHaveBeenCalled() consoleSpy.mockRestore() }) @@ -47,9 +47,9 @@ describe('context', () => { it('should log warn messages', () => { const consoleSpy = jest.spyOn(console, 'warn').mockImplementation() const logger = consoleLogger({ service: 'test' }) - + logger.warn('Warning message', { warning: 'info' }) - + expect(consoleSpy).toHaveBeenCalled() consoleSpy.mockRestore() }) @@ -58,9 +58,9 @@ describe('context', () => { const consoleSpy = jest.spyOn(console, 'error').mockImplementation() const logger = consoleLogger({}) const error = new Error('Test error') - + logger.error('Error occurred', { error }) - + expect(consoleSpy).toHaveBeenCalled() const call = consoleSpy.mock.calls[0] expect(call[0]).toBe('Error occurred') @@ -78,7 +78,7 @@ describe('context', () => { it('should create a new context', () => { const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', { op: 'create' }, {}, metrics, logger) - + expect(ctx).toBeDefined() expect(ctx.metrics).toBe(metrics) expect(ctx.logger).toBe(logger) @@ -87,10 +87,10 @@ describe('context', () => { it('should measure operation duration', async () => { const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', { op: 'create' }, {}, metrics, logger) - - await new Promise(resolve => setTimeout(resolve, 50)) + + await new Promise((resolve) => setTimeout(resolve, 50)) ctx.end() - + expect(metrics.operations).toBe(1) expect(metrics.value).toBeGreaterThan(40) }) @@ -99,7 +99,7 @@ describe('context', () => { const metrics = newMetrics() const ctx = new MeasureMetricsContext('parent', { op: 'parent' }, {}, metrics, logger) const child = ctx.newChild('child', { op: 'child' }) - + expect(child).toBeDefined() expect(child.parent).toBe(ctx) }) @@ -107,13 +107,13 @@ describe('context', () => { it('should execute async operation with context', async () => { const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, logger) - + let executed = false await ctx.with('operation', { op: 'test' }, async () => { executed = true - await new Promise(resolve => setTimeout(resolve, 10)) + await new Promise((resolve) => setTimeout(resolve, 10)) }) - + expect(executed).toBe(true) expect(metrics.measurements.operation).toBeDefined() }) @@ -121,11 +121,11 @@ describe('context', () => { it('should execute sync operation with context', () => { const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, logger) - + const result = ctx.withSync('operation', { op: 'test' }, () => { return 42 }) - + expect(result).toBe(42) expect(metrics.measurements.operation).toBeDefined() }) @@ -133,9 +133,9 @@ describe('context', () => { it('should measure custom value', () => { const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, logger) - + ctx.measure('custom', 100) - + expect(metrics.measurements['#custom']).toBeDefined() expect(metrics.measurements['#custom'].value).toBe(100) }) @@ -148,11 +148,14 @@ describe('context', () => { close: jest.fn(async () => {}), logOperation: jest.fn() } - + const ctx = new MeasureMetricsContext('test', { op: 'test' }, {}, newMetrics(), mockLogger) ctx.info('Test message', { key: 'value' }) - - expect(mockLogger.info).toHaveBeenCalledWith('Test message', expect.objectContaining({ key: 'value', op: 'test' })) + + expect(mockLogger.info).toHaveBeenCalledWith( + 'Test message', + expect.objectContaining({ key: 'value', op: 'test' }) + ) }) it('should log error messages', () => { @@ -163,11 +166,14 @@ describe('context', () => { close: jest.fn(async () => {}), logOperation: jest.fn() } - + const ctx = new MeasureMetricsContext('test', { op: 'test' }, {}, newMetrics(), mockLogger) ctx.error('Error message', { error: 'details' }) - - expect(mockLogger.error).toHaveBeenCalledWith('Error message', expect.objectContaining({ error: 'details', op: 'test' })) + + expect(mockLogger.error).toHaveBeenCalledWith( + 'Error message', + expect.objectContaining({ error: 'details', op: 'test' }) + ) }) it('should log warn messages', () => { @@ -178,17 +184,20 @@ describe('context', () => { close: jest.fn(async () => {}), logOperation: jest.fn() } - + const ctx = new MeasureMetricsContext('test', { op: 'test' }, {}, newMetrics(), mockLogger) ctx.warn('Warning message', { warning: 'info' }) - - expect(mockLogger.warn).toHaveBeenCalledWith('Warning message', expect.objectContaining({ warning: 'info', op: 'test' })) + + expect(mockLogger.warn).toHaveBeenCalledWith( + 'Warning message', + expect.objectContaining({ warning: 'info', op: 'test' }) + ) }) it('should get params', () => { const ctx = new MeasureMetricsContext('test', { op: 'test', method: 'GET' }, {}, newMetrics(), logger) const params = ctx.getParams() - + expect(params).toEqual({ op: 'test', method: 'GET' }) }) @@ -196,28 +205,29 @@ describe('context', () => { const metrics = newMetrics() const ctx = new MeasureMetricsContext('parent', {}, {}, metrics, logger) ctx.contextData = { userId: '123' } - + const child = ctx.newChild('child', {}) - + expect(child.contextData).toBe(ctx.contextData) }) it('should handle named parameters', () => { const metrics = newMetrics() - new MeasureMetricsContext('test', { method: 'GET' }, {}, metrics, logger) - + const r = new MeasureMetricsContext('test', { method: 'GET' }, {}, metrics, logger) + expect(r).toBeNull() expect(metrics.namedParams.method).toBe('GET') }) it('should update named parameters on multiple contexts', () => { const metrics = newMetrics() const ctx1 = new MeasureMetricsContext('test1', { method: 'GET' }, {}, metrics, logger) - + expect(ctx1).toBeNull() expect(metrics.namedParams.method).toBe('GET') - + // Create another context with different value for same param const ctx2 = new MeasureMetricsContext('test2', { method: 'POST' }, {}, metrics, logger) - + expect(ctx2).toBeNull() + // The second context will see existing value is different, so it will update to '*' // But this happens within the constructor logic expect(metrics.namedParams.method).toBe('POST') @@ -227,33 +237,33 @@ describe('context', () => { describe('NoMetricsContext', () => { it('should create a no-op context', () => { const ctx = new NoMetricsContext() - + expect(ctx).toBeDefined() expect(ctx.logger).toBeDefined() }) it('should execute operations without measuring', async () => { const ctx = new NoMetricsContext() - + let executed = false await ctx.with('operation', {}, async () => { executed = true }) - + expect(executed).toBe(true) }) it('should create child contexts', () => { const ctx = new NoMetricsContext() const child = ctx.newChild('child', {}) - + expect(child).toBeDefined() expect(child).toBeInstanceOf(NoMetricsContext) }) it('should handle measure calls without error', () => { const ctx = new NoMetricsContext() - + expect(() => { ctx.measure('test', 100) }).not.toThrow() @@ -261,7 +271,7 @@ describe('context', () => { it('should handle end calls without error', () => { const ctx = new NoMetricsContext() - + expect(() => { ctx.end() }).not.toThrow() @@ -270,7 +280,7 @@ describe('context', () => { it('should return empty params', () => { const ctx = new NoMetricsContext() const params = ctx.getParams() - + expect(params).toEqual({}) }) }) @@ -279,17 +289,17 @@ describe('context', () => { it('should wrap method with context', async () => { class TestClass { @withContext('testOperation', { service: 'test' }) - async testMethod(ctx: MeasureContext, value: number): Promise { + async testMethod (ctx: MeasureContext, value: number): Promise { return value * 2 } } - + const instance = new TestClass() const metrics = newMetrics() const ctx = new MeasureMetricsContext('root', {}, {}, metrics, noParamsLogger) - + const result = await instance.testMethod(ctx, 21) - + expect(result).toBe(42) expect(metrics.measurements.testOperation).toBeDefined() }) @@ -308,9 +318,9 @@ describe('context', () => { setOperationLogProfiling(true) const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, noParamsLogger) - + const { opLogMetrics, op } = registerOperationLog(ctx) - + expect(opLogMetrics).toBe(metrics) expect(op).toBeDefined() expect(ctx.id).toBeDefined() @@ -320,9 +330,9 @@ describe('context', () => { setOperationLogProfiling(false) const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, noParamsLogger) - + const { opLogMetrics, op } = registerOperationLog(ctx) - + expect(opLogMetrics).toBeUndefined() expect(op).toBeUndefined() }) @@ -331,10 +341,10 @@ describe('context', () => { setOperationLogProfiling(true) const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, noParamsLogger) - + const { opLogMetrics, op } = registerOperationLog(ctx) updateOperationLog(opLogMetrics, op) - + expect(op?.end).toBeGreaterThan(0) }) @@ -342,14 +352,14 @@ describe('context', () => { setOperationLogProfiling(true) const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, noParamsLogger) - + registerOperationLog(ctx) - + let executed = false await addOperation(ctx, 'asyncOp', { op: 'test' }, async () => { executed = true }) - + expect(executed).toBe(true) expect(metrics.opLog).toBeDefined() }) @@ -358,11 +368,11 @@ describe('context', () => { setOperationLogProfiling(true) const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, noParamsLogger) - + registerOperationLog(ctx) - + // Create many operation log entries - if (metrics.opLog && ctx.id) { + if (metrics.opLog != null && ctx.id != null) { for (let i = 0; i < 50; i++) { metrics.opLog[ctx.id].ops.push({ op: `test${i}`, @@ -371,10 +381,10 @@ describe('context', () => { params: {} }) } - + const op = metrics.opLog[ctx.id] updateOperationLog(metrics, op) - + expect(Object.keys(metrics.opLog).length).toBeLessThanOrEqual(31) } }) @@ -384,7 +394,7 @@ describe('context', () => { it('should return empty metadata', () => { const ctx = new MeasureMetricsContext('test', {}, {}, newMetrics(), noParamsLogger) const meta = ctx.extractMeta() - + expect(meta).toEqual({}) }) }) @@ -393,35 +403,35 @@ describe('context', () => { it('should handle promise rejection', async () => { const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, noParamsLogger) - + await expect( ctx.with('operation', { op: 'test' }, async () => { throw new Error('Test error') }) ).rejects.toThrow('Test error') - + expect(metrics.measurements.operation).toBeDefined() }) it('should return null promise for null sync result', async () => { const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, noParamsLogger) - + const result = await ctx.with('operation', { op: 'test' }, () => { return null }) - + expect(result).toBeUndefined() }) it('should handle sync return value', async () => { const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, noParamsLogger) - + const result = await ctx.with('operation', { op: 'test' }, () => { return 42 }) - + expect(result).toBe(42) }) @@ -433,14 +443,20 @@ describe('context', () => { close: jest.fn(async () => {}), logOperation: jest.fn() } - + const metrics = newMetrics() const ctx = new MeasureMetricsContext('test', {}, {}, metrics, mockLogger) - - await ctx.with('operation', { op: 'test' }, async () => { - await new Promise(resolve => setTimeout(resolve, 10)) - }, {}, { log: true }) - + + await ctx.with( + 'operation', + { op: 'test' }, + async () => { + await new Promise((resolve) => setTimeout(resolve, 10)) + }, + {}, + { log: true } + ) + expect(mockLogger.logOperation).toHaveBeenCalledWith( 'operation', expect.any(Number), diff --git a/packages/measurements/src/__tests__/index.test.ts b/packages/measurements/src/__tests__/index.test.ts index 1bd75aff15..d701edd4e2 100644 --- a/packages/measurements/src/__tests__/index.test.ts +++ b/packages/measurements/src/__tests__/index.test.ts @@ -10,7 +10,7 @@ describe('index', () => { it('should return increasing values over time', async () => { const first = platformNow() - await new Promise(resolve => setTimeout(resolve, 10)) + await new Promise((resolve) => setTimeout(resolve, 10)) const second = platformNow() expect(second).toBeGreaterThan(first) }) @@ -19,27 +19,27 @@ describe('index', () => { describe('platformNowDiff', () => { it('should calculate the difference between timestamps', async () => { const start = platformNow() - await new Promise(resolve => setTimeout(resolve, 50)) + await new Promise((resolve) => setTimeout(resolve, 50)) const diff = platformNowDiff(start) - + expect(diff).toBeGreaterThan(40) expect(diff).toBeLessThan(100) }) it('should round to 2 decimal places', async () => { const start = platformNow() - await new Promise(resolve => setTimeout(resolve, 10)) + await new Promise((resolve) => setTimeout(resolve, 10)) const diff = platformNowDiff(start) - + // Check that it has at most 2 decimal places - const decimalPlaces = (diff.toString().split('.')[1] || '').length + const decimalPlaces = (diff.toString().split('.')[1] ?? '').length expect(decimalPlaces).toBeLessThanOrEqual(2) }) it('should handle very small differences', () => { const start = platformNow() const diff = platformNowDiff(start) - + expect(diff).toBeGreaterThanOrEqual(0) expect(typeof diff).toBe('number') }) diff --git a/packages/measurements/src/__tests__/metrics.test.ts b/packages/measurements/src/__tests__/metrics.test.ts index 108a614e44..e10136fa72 100644 --- a/packages/measurements/src/__tests__/metrics.test.ts +++ b/packages/measurements/src/__tests__/metrics.test.ts @@ -14,7 +14,7 @@ describe('metrics', () => { describe('newMetrics', () => { it('should create a new metrics object with default values', () => { const metrics = newMetrics() - + expect(metrics.operations).toBe(0) expect(metrics.value).toBe(0) expect(metrics.measurements).toEqual({}) @@ -27,10 +27,10 @@ describe('metrics', () => { it('should measure operation duration', async () => { const metrics = newMetrics() const done = measure(metrics, { operation: 'test' }) - - await new Promise(resolve => setTimeout(resolve, 50)) + + await new Promise((resolve) => setTimeout(resolve, 50)) done() - + expect(metrics.operations).toBe(1) expect(metrics.value).toBeGreaterThan(40) }) @@ -41,24 +41,24 @@ describe('metrics', () => { const done = measure(metrics, { operation: 'test' }, {}, (spend) => { capturedSpend = spend }) - - await new Promise(resolve => setTimeout(resolve, 50)) + + await new Promise((resolve) => setTimeout(resolve, 50)) done() - + expect(capturedSpend).toBeGreaterThan(40) }) it('should handle multiple operations', async () => { const metrics = newMetrics() - + const done1 = measure(metrics, { operation: 'test' }) - await new Promise(resolve => setTimeout(resolve, 20)) + await new Promise((resolve) => setTimeout(resolve, 20)) done1() - + const done2 = measure(metrics, { operation: 'test' }) - await new Promise(resolve => setTimeout(resolve, 20)) + await new Promise((resolve) => setTimeout(resolve, 20)) done2() - + expect(metrics.operations).toBe(2) expect(metrics.value).toBeGreaterThan(30) }) @@ -68,9 +68,9 @@ describe('metrics', () => { it('should update metrics with custom value', () => { const metrics = newMetrics() const st = platformNow() - + updateMeasure(metrics, st, { op: 'test' }, {}, undefined, 100) - + expect(metrics.operations).toBe(1) expect(metrics.value).toBe(100) }) @@ -78,15 +78,15 @@ describe('metrics', () => { it('should override operations when override is true', () => { const metrics = newMetrics() const st = platformNow() - + // First call without override - accumulates value and increments operations updateMeasure(metrics, st, { op: 'test' }, {}, undefined, 50, false) expect(metrics.value).toBe(50) expect(metrics.operations).toBe(1) - + // Second call with override - sets operations, doesn't add to value updateMeasure(metrics, st, { op: 'test' }, {}, undefined, 100, true) - + expect(metrics.operations).toBe(100) // overridden expect(metrics.value).toBe(50) // not changed when override=true }) @@ -94,10 +94,10 @@ describe('metrics', () => { it('should track parameters', () => { const metrics = newMetrics() const st = platformNow() - + updateMeasure(metrics, st, { method: 'GET' }, {}, undefined, 100) updateMeasure(metrics, st, { method: 'POST' }, {}, undefined, 200) - + expect(metrics.params.method).toBeDefined() expect(metrics.params.method.GET).toBeDefined() expect(metrics.params.method.POST).toBeDefined() @@ -108,10 +108,10 @@ describe('metrics', () => { it('should handle multiple parameters as counters', () => { const metrics = newMetrics() const st = platformNow() - + updateMeasure(metrics, st, { method: 'GET', status: '200' }, {}, undefined, 100) updateMeasure(metrics, st, { method: 'GET', status: '404' }, {}, undefined, 50) - + expect(metrics.params.method.GET).toBeDefined() expect(metrics.params.method.GET.topResult).toBeDefined() expect(metrics.params.method.GET.topResult?.length).toBeGreaterThan(0) @@ -120,10 +120,10 @@ describe('metrics', () => { it('should update top results', () => { const metrics = newMetrics() const st = platformNow() - + updateMeasure(metrics, st, {}, { request: 'slow' }, undefined, 100) updateMeasure(metrics, st, {}, { request: 'fast' }, undefined, 10) - + expect(metrics.topResult).toBeDefined() expect(metrics.topResult?.length).toBeGreaterThan(0) }) @@ -133,7 +133,7 @@ describe('metrics', () => { it('should create child metrics in hierarchy', () => { const root = newMetrics() const child = childMetrics(root, ['level1', 'level2']) - + expect(root.measurements.level1).toBeDefined() expect(root.measurements.level1.measurements.level2).toBeDefined() expect(child).toBe(root.measurements.level1.measurements.level2) @@ -143,14 +143,14 @@ describe('metrics', () => { const root = newMetrics() const child1 = childMetrics(root, ['level1']) const child2 = childMetrics(root, ['level1']) - + expect(child1).toBe(child2) }) it('should create nested paths', () => { const root = newMetrics() childMetrics(root, ['api', 'users', 'create']) - + expect(root.measurements.api).toBeDefined() expect(root.measurements.api.measurements.users).toBeDefined() expect(root.measurements.api.measurements.users.measurements.create).toBeDefined() @@ -162,45 +162,45 @@ describe('metrics', () => { const metrics = newMetrics() metrics.value = 100 metrics.operations = 10 - + const child1 = childMetrics(metrics, ['child1']) child1.value = 50 child1.operations = 5 - + const child2 = childMetrics(metrics, ['child2']) child2.value = 30 child2.operations = 3 - + const aggregated = metricsAggregate(metrics) - + expect(aggregated.value).toBe(80) // child1 + child2 expect(aggregated.operations).toBe(10) }) it('should limit number of child metrics', () => { const metrics = newMetrics() - + for (let i = 0; i < 10; i++) { const child = childMetrics(metrics, [`child${i}`]) child.value = i * 10 } - + const aggregated = metricsAggregate(metrics, 3) - + expect(Object.keys(aggregated.measurements).length).toBe(3) }) it('should filter out metrics starting with #', () => { const metrics = newMetrics() - + const child1 = childMetrics(metrics, ['normal']) child1.value = 50 - + const child2 = childMetrics(metrics, ['#internal']) child2.value = 30 - + const aggregated = metricsAggregate(metrics) - + expect(aggregated.value).toBe(50) // only 'normal' counted }) }) @@ -210,9 +210,9 @@ describe('metrics', () => { const metrics = newMetrics() metrics.value = 100 metrics.operations = 10 - + const str = metricsToString(metrics, 'TestMetrics', 50) - + expect(str).toContain('TestMetrics') expect(str).toContain('100') expect(str).toContain('10') @@ -223,9 +223,9 @@ describe('metrics', () => { const child = childMetrics(metrics, ['operation']) child.value = 50 child.operations = 5 - + const str = metricsToString(metrics, 'TestMetrics', 50) - + expect(str).toContain('operation') }) }) @@ -235,9 +235,9 @@ describe('metrics', () => { const metrics = newMetrics() metrics.value = 100 metrics.operations = 10 - + const json = metricsToJson(metrics) - + // aggregated value is the total value when no children expect(json.$total).toBe(100) expect(json.$ops).toBe(10) @@ -248,12 +248,12 @@ describe('metrics', () => { const child = childMetrics(metrics, ['operation']) child.value = 50 child.operations = 5 - + const json = metricsToJson(metrics) - + expect(json).toBeDefined() const keys = Object.keys(json) - expect(keys.some(k => k.includes('operation'))).toBe(true) + expect(keys.some((k) => k.includes('operation'))).toBe(true) }) }) @@ -262,9 +262,9 @@ describe('metrics', () => { const metrics = newMetrics() metrics.value = 100 metrics.operations = 10 - + const rows = metricsToRows(metrics, 'TestMetrics') - + expect(Array.isArray(rows)).toBe(true) expect(rows.length).toBeGreaterThan(0) expect(rows[0]).toContain('TestMetrics') @@ -275,20 +275,20 @@ describe('metrics', () => { const child = childMetrics(metrics, ['operation']) child.value = 50 child.operations = 5 - + const rows = metricsToRows(metrics, 'TestMetrics') - + expect(rows.length).toBeGreaterThan(1) - expect(rows.some(row => row.includes('operation'))).toBe(true) + expect(rows.some((row) => row.includes('operation'))).toBe(true) }) it('should properly format row values', () => { const metrics = newMetrics() metrics.value = 100 metrics.operations = 10 - + const rows = metricsToRows(metrics, 'TestMetrics') - + expect(rows[0]).toHaveLength(5) // offset, name, avg, total, ops expect(typeof rows[0][0]).toBe('number') // offset expect(typeof rows[0][1]).toBe('string') // name diff --git a/packages/measurements/src/__tests__/performance.test.ts b/packages/measurements/src/__tests__/performance.test.ts index 315690fd9e..14f0ff3e35 100644 --- a/packages/measurements/src/__tests__/performance.test.ts +++ b/packages/measurements/src/__tests__/performance.test.ts @@ -1,6 +1,5 @@ -import { MeasureMetricsContext, NoMetricsContext } from '../context' +import { MeasureMetricsContext, NoMetricsContext, noParamsLogger } from '../context' import { newMetrics, metricsAggregate } from '../metrics' -import { noParamsLogger } from '../context' import type { MeasureContext } from '../types' describe('performance', () => { @@ -20,7 +19,7 @@ describe('performance', () => { // With measurement context const metrics = newMetrics() const ctx = new MeasureMetricsContext('root', {}, {}, metrics, noParamsLogger) - + const measuredStart = performance.now() for (let i = 0; i < iterations; i++) { await ctx.with('operation', { iteration: i }, async () => { @@ -40,7 +39,7 @@ describe('performance', () => { expect(metrics.measurements.operation).toBeDefined() expect(metrics.measurements.operation.operations).toBe(iterations) - + // Overhead should be reasonable (typically < 50% for simple operations) // This is informational rather than a strict assertion expect(overheadPercentage).toBeLessThan(200) @@ -95,12 +94,13 @@ describe('performance', () => { // Complex params with multiple tracked values const complexStart = performance.now() for (let i = 0; i < iterations; i++) { - await ctx.with('complex', - { + await ctx.with( + 'complex', + { method: i % 3 === 0 ? 'GET' : i % 3 === 1 ? 'POST' : 'PUT', status: i % 2 === 0 ? 200 : 404, cached: i % 4 === 0 - }, + }, async () => { await simulateWork(1) }, @@ -165,7 +165,7 @@ describe('performance', () => { const requests = 50 const baselineStart = performance.now() - + // Simulate without metrics for (let i = 0; i < requests; i++) { await simulateAPIRequest(null, i) @@ -174,7 +174,7 @@ describe('performance', () => { // Reset for measured run const measuredStart = performance.now() - + // Simulate with metrics for (let i = 0; i < requests; i++) { await simulateAPIRequest(ctx, i) @@ -189,10 +189,10 @@ describe('performance', () => { console.log(` With metrics: ${measuredTime.toFixed(2)}ms`) console.log(` Overhead: ${overhead.toFixed(2)}ms (${overheadPercentage.toFixed(2)}%)`) console.log(` Per request: ${(overhead / requests).toFixed(4)}ms`) - + // Check metrics structure const aggregated = metricsAggregate(metrics, 10) - console.log(` Collected operations: ${aggregated.measurements.request?.operations || 0}`) + console.log(` Collected operations: ${aggregated.measurements.request?.operations ?? 0}`) expect(aggregated.measurements.request).toBeDefined() expect(overheadPercentage).toBeLessThan(100) // Should be less than 100% overhead @@ -202,15 +202,16 @@ describe('performance', () => { // Helper functions -async function simulateWork(durationMs: number): Promise { +async function simulateWork (durationMs: number): Promise { const end = performance.now() + durationMs while (performance.now() < end) { // Busy wait to simulate work - Math.random() * Math.random() + const r = Math.random() * Math.random() + expect(r).toBeGreaterThanOrEqual(0) } } -async function deepNestedExecution( +async function deepNestedExecution ( ctx: MeasureContext, depth: number, workMs: number, @@ -226,10 +227,10 @@ async function deepNestedExecution( }) } -async function simulateAPIRequest(ctx: MeasureContext | null, requestId: number): Promise { +async function simulateAPIRequest (ctx: MeasureContext | null, requestId: number): Promise { const method = ['GET', 'POST', 'PUT'][requestId % 3] const endpoint = `/api/resource/${requestId % 10}` - + if (ctx === null) { // No metrics version await simulateWork(1) @@ -256,4 +257,4 @@ async function simulateAPIRequest(ctx: MeasureContext | null, requestId: number) await simulateWork(1) }) }) -} \ No newline at end of file +} diff --git a/packages/measurements/src/index.ts b/packages/measurements/src/index.ts index d736098c8a..16e4d95df6 100644 --- a/packages/measurements/src/index.ts +++ b/packages/measurements/src/index.ts @@ -1,6 +1,6 @@ export * from './context' export * from './metrics' -export * from './types' +export type * from './types' /** * Return a current performance timestamp diff --git a/packages/platform-rig/CHANGELOG.json b/packages/platform-rig/CHANGELOG.json index 08e76f1a6e..0384274795 100644 --- a/packages/platform-rig/CHANGELOG.json +++ b/packages/platform-rig/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@hcengineering/platform-rig", "entries": [ + { + "version": "0.7.13", + "tag": "@hcengineering/platform-rig_v0.7.13", + "date": "Sat, 11 Oct 2025 17:58:53 GMT", + "comments": { + "patch": [ + { + "comment": "Script to sync eslint deps" + } + ] + } + }, { "version": "0.7.12", "tag": "@hcengineering/platform-rig_v0.7.12", diff --git a/packages/platform-rig/CHANGELOG.md b/packages/platform-rig/CHANGELOG.md index 873c611dd9..f53aa2f328 100644 --- a/packages/platform-rig/CHANGELOG.md +++ b/packages/platform-rig/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @hcengineering/platform-rig -This log was last generated on Fri, 10 Oct 2025 14:20:06 GMT and should not be manually modified. +This log was last generated on Sat, 11 Oct 2025 17:58:53 GMT and should not be manually modified. + +## 0.7.13 +Sat, 11 Oct 2025 17:58:53 GMT + +### Patches + +- Script to sync eslint deps ## 0.7.12 Fri, 10 Oct 2025 14:20:06 GMT diff --git a/packages/platform-rig/bin/sync-eslint-deps.js b/packages/platform-rig/bin/sync-eslint-deps.js new file mode 100755 index 0000000000..e76f47cd59 --- /dev/null +++ b/packages/platform-rig/bin/sync-eslint-deps.js @@ -0,0 +1,187 @@ +#!/usr/bin/env node +// +// Copyright © 2025 Hardcore Engineering Inc. +// +// Script to sync ESLint dev dependencies from platform-rig to all Rush packages +// + +const fs = require('fs') +const path = require('path') +const { execSync } = require('child_process') + +// ESLint related dependency prefixes to sync +const ESLINT_PATTERNS = ['eslint', '@typescript-eslint/', 'eslint-plugin-', 'eslint-config-'] + +/** + * Get list of Rush projects using 'rush list --json' + */ +function getRushProjects() { + try { + const output = execSync('rush list --json', { + encoding: 'utf-8', + stdio: ['pipe', 'pipe', 'pipe'] + }) + + const data = JSON.parse(output) + const projects = data.projects || data + + if (!Array.isArray(projects)) { + throw new Error('Expected rush list --json to return an array of projects') + } + + return projects + } catch (err) { + if (err.message.includes('rush') || err.code === 'ENOENT') { + throw new Error('Failed to run "rush list --json". Make sure you are in a Rush workspace and Rush is installed.') + } + throw new Error(`Failed to get Rush projects: ${err.message}`) + } +} + +/** + * Check if a dependency name matches ESLint patterns + */ +function isEslintDependency(depName) { + return ESLINT_PATTERNS.some((pattern) => depName.startsWith(pattern)) +} + +/** + * Get ESLint dev dependencies from platform-rig package.json + */ +function getEslintDepsFromPlatformRig(platformRigPath) { + const packageJsonPath = path.join(platformRigPath, 'package.json') + + if (!fs.existsSync(packageJsonPath)) { + throw new Error(`platform-rig package.json not found at: ${packageJsonPath}`) + } + + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) + const dependencies = packageJson.dependencies || {} + + const eslintDeps = {} + for (const [name, version] of Object.entries(dependencies)) { + if (isEslintDependency(name)) { + eslintDeps[name] = version + } + } + + return eslintDeps +} + +/** + * Update package.json with ESLint dependencies + */ +function updatePackageJson(packagePath, eslintDeps) { + const packageJsonPath = path.join(packagePath, 'package.json') + + if (!fs.existsSync(packageJsonPath)) { + console.warn(`⚠️ package.json not found at: ${packageJsonPath}`) + return { updated: false, changes: [] } + } + + const content = fs.readFileSync(packageJsonPath, 'utf-8') + const packageJson = JSON.parse(content) + + // Skip if this is the platform-rig package itself + if (packageJson.name === '@hcengineering/platform-rig') { + return { updated: false, changes: [] } + } + + // Initialize devDependencies if it doesn't exist + if (!packageJson.devDependencies) { + packageJson.devDependencies = {} + } + + const changes = [] + let hasChanges = false + + // Add or update ESLint dependencies + for (const [name, version] of Object.entries(eslintDeps)) { + const currentVersion = packageJson.devDependencies[name] + + if (currentVersion !== version) { + packageJson.devDependencies[name] = version + hasChanges = true + + if (currentVersion) { + changes.push(` ${name}: ${currentVersion} → ${version}`) + } else { + changes.push(` ${name}: (new) → ${version}`) + } + } + } + + if (hasChanges) { + // Preserve original formatting by maintaining indent detection + const indent = content.match(/^(\s+)/m)?.[1]?.length || 2 + const newContent = JSON.stringify(packageJson, null, indent) + '\n' + fs.writeFileSync(packageJsonPath, newContent, 'utf-8') + } + + return { updated: hasChanges, changes } +} + +/** + * Main execution + */ +function main() { + console.log('🔍 Syncing ESLint dependencies from platform-rig to all packages...\n') + + try { + // Get all Rush projects + const projects = getRushProjects() + console.log(`Found ${projects.length} projects in Rush workspace\n`) + + // Find platform-rig project + const platformRigProject = projects.find((p) => p.name === '@hcengineering/platform-rig') + if (!platformRigProject) { + throw new Error('platform-rig package not found in Rush workspace') + } + + // Get ESLint dependencies from platform-rig + const eslintDeps = getEslintDepsFromPlatformRig(platformRigProject.fullPath) + + if (Object.keys(eslintDeps).length === 0) { + console.log('⚠️ No ESLint dependencies found in platform-rig') + return + } + + console.log('📦 ESLint dependencies from platform-rig:') + for (const [name, version] of Object.entries(eslintDeps)) { + console.log(` ${name}: ${version}`) + } + console.log() + + // Update all packages + let updatedCount = 0 + let skippedCount = 0 + + for (const project of projects) { + const result = updatePackageJson(project.fullPath, eslintDeps) + + if (result.updated) { + updatedCount++ + console.log(`✅ Updated ${project.name}`) + result.changes.forEach((change) => console.log(change)) + console.log() + } else if (result.changes.length === 0 && project.name !== '@hcengineering/platform-rig') { + skippedCount++ + } + } + + console.log('━'.repeat(50)) + console.log(`✨ Sync complete!`) + console.log(` Updated: ${updatedCount} package(s)`) + console.log(` Skipped: ${skippedCount} package(s) (already up-to-date)`) + + if (updatedCount > 0) { + console.log('\n💡 Don\'t forget to run "rush update" to install the updated dependencies') + } + } catch (error) { + console.error(`\n❌ Error: ${error.message}`) + process.exit(1) + } +} + +// Run the script +main() diff --git a/packages/platform-rig/package.json b/packages/platform-rig/package.json index 8b94219f19..84a0f54026 100644 --- a/packages/platform-rig/package.json +++ b/packages/platform-rig/package.json @@ -1,6 +1,6 @@ { "name": "@hcengineering/platform-rig", - "version": "0.7.12", + "version": "0.7.13", "scripts": { "build": "echo 'Not required'", "format": "echo 'Not required'" @@ -13,12 +13,12 @@ "typescript": "^5.9.3", "esbuild": "^0.25.10", "esbuild-plugin-copy": "^2.1.1", - "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/eslint-plugin": "^8.46.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-promise": "^6.1.1", "eslint-plugin-n": "^15.4.0", "eslint": "^8.54.0", - "@typescript-eslint/parser": "^6.11.0", + "@typescript-eslint/parser": "^8.46.0", "eslint-config-standard-with-typescript": "^40.0.0", "prettier": "^3.6.2", "prettier-plugin-svelte": "^3.4.0", @@ -30,8 +30,14 @@ "do-svelte-check": "./bin/do-svelte-check.js", "bump-package-version": "./bin/bump-package-version.js", "bump-changes-from-tag": "./bin/bump-changes-from-tag.js", - "update-deps": "./bin/update-deps.js" + "update-deps": "./bin/update-deps.js", + "sync-eslint-deps": "./bin/sync-eslint-deps.js" }, + "files": [ + "bin/**/*", + "profiles/**/*", + "package.json" + ], "publishConfig": { "access": "public" } diff --git a/packages/postgres-base/CHANGELOG.json b/packages/postgres-base/CHANGELOG.json index ff2eeec02d..9aad29ddde 100644 --- a/packages/postgres-base/CHANGELOG.json +++ b/packages/postgres-base/CHANGELOG.json @@ -1,6 +1,23 @@ { "name": "@hcengineering/postgres-base", "entries": [ + { + "version": "0.7.11", + "tag": "@hcengineering/postgres-base_v0.7.11", + "date": "Sat, 11 Oct 2025 17:58:53 GMT", + "comments": { + "patch": [ + { + "comment": "Fix eslint deps" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@hcengineering/platform-rig\" from `^0.7.12` to `0.7.13`" + } + ] + } + }, { "version": "0.7.10", "tag": "@hcengineering/postgres-base_v0.7.10", diff --git a/packages/postgres-base/CHANGELOG.md b/packages/postgres-base/CHANGELOG.md index dd559eb1e2..cb87f67b9f 100644 --- a/packages/postgres-base/CHANGELOG.md +++ b/packages/postgres-base/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @hcengineering/postgres-base -This log was last generated on Fri, 10 Oct 2025 12:32:59 GMT and should not be manually modified. +This log was last generated on Sat, 11 Oct 2025 17:58:53 GMT and should not be manually modified. + +## 0.7.11 +Sat, 11 Oct 2025 17:58:53 GMT + +### Patches + +- Fix eslint deps ## 0.7.10 Fri, 10 Oct 2025 12:32:59 GMT diff --git a/packages/postgres-base/package.json b/packages/postgres-base/package.json index 331682a242..c778b01999 100644 --- a/packages/postgres-base/package.json +++ b/packages/postgres-base/package.json @@ -1,6 +1,6 @@ { "name": "@hcengineering/postgres-base", - "version": "0.7.10", + "version": "0.7.11", "main": "lib/index.js", "svelte": "src/index.ts", "types": "types/index.d.ts", @@ -28,11 +28,19 @@ "_phase:validate": "compile validate" }, "devDependencies": { - "@hcengineering/platform-rig": "workspace:^0.7.12", + "@hcengineering/platform-rig": "workspace:^0.7.13", "jest": "^29.7.0", "ts-jest": "^29.1.1", "@types/jest": "^29.5.5", - "@types/node": "^22.15.29" + "@types/node": "^22.15.29", + "@typescript-eslint/eslint-plugin": "^8.46.0", + "@typescript-eslint/parser": "^8.46.0", + "eslint": "^8.54.0", + "eslint-config-standard-with-typescript": "^40.0.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^6.1.1", + "eslint-plugin-n": "^15.4.0" }, "dependencies": { "postgres": "^3.4.7"