From 318adf4d6507a732a92bf2a5e986d08c6e383991 Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Sat, 11 May 2024 18:18:31 -0400 Subject: [PATCH 1/8] Force .mjs import suffixes in compiled .mjs files --- js/package.json | 3 +- js/plugins/evaluators/src/index.ts | 4 +- js/pnpm-lock.yaml | 241 +++++++++++++++++++++++++++++ js/tsup.common.ts | 80 +++++++++- 4 files changed, 322 insertions(+), 6 deletions(-) diff --git a/js/package.json b/js/package.json index 54807b5d10..e0493cccd7 100644 --- a/js/package.json +++ b/js/package.json @@ -17,7 +17,8 @@ "devDependencies": { "npm-run-all": "^4.1.5", "only-allow": "^1.2.1", - "typescript": "^4.9.0" + "typescript": "^4.9.0", + "esbuild": "^0.21.1" }, "packageManager": "pnpm@9.1.0+sha256.22e36fba7f4880ecf749a5ca128b8435da085ecd49575e7fb9e64d6bf4fad394" } diff --git a/js/plugins/evaluators/src/index.ts b/js/plugins/evaluators/src/index.ts index d26410428a..92d6e17b1c 100644 --- a/js/plugins/evaluators/src/index.ts +++ b/js/plugins/evaluators/src/index.ts @@ -29,8 +29,8 @@ import { answerRelevancyScore, faithfulnessScore, maliciousnessScore, -} from './metrics'; -import { GenkitMetric } from './types.js'; +} from './metrics/index.js'; +import { GenkitMetric } from './types'; export { GenkitMetric }; const PLUGIN_NAME = 'genkitEval'; diff --git a/js/pnpm-lock.yaml b/js/pnpm-lock.yaml index bc059a33bf..bfc7a8fc2b 100644 --- a/js/pnpm-lock.yaml +++ b/js/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: devDependencies: + esbuild: + specifier: ^0.21.1 + version: 0.21.1 npm-run-all: specifier: ^4.1.5 version: 4.1.5 @@ -1275,138 +1278,276 @@ packages: cpu: [ppc64] os: [aix] + '@esbuild/aix-ppc64@0.21.1': + resolution: {integrity: sha512-O7yppwipkXvnEPjzkSXJRk2g4bS8sUx9p9oXHq9MU/U7lxUzZVsnFZMDTmeeX9bfQxrFcvOacl/ENgOh0WP9pA==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [aix] + '@esbuild/android-arm64@0.19.12': resolution: {integrity: sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==} engines: {node: '>=12'} cpu: [arm64] os: [android] + '@esbuild/android-arm64@0.21.1': + resolution: {integrity: sha512-jXhccq6es+onw7x8MxoFnm820mz7sGa9J14kLADclmiEUH4fyj+FjR6t0M93RgtlI/awHWhtF0Wgfhqgf9gDZA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + '@esbuild/android-arm@0.19.12': resolution: {integrity: sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==} engines: {node: '>=12'} cpu: [arm] os: [android] + '@esbuild/android-arm@0.21.1': + resolution: {integrity: sha512-hh3jKWikdnTtHCglDAeVO3Oyh8MaH8xZUaWMiCCvJ9/c3NtPqZq+CACOlGTxhddypXhl+8B45SeceYBfB/e8Ow==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + '@esbuild/android-x64@0.19.12': resolution: {integrity: sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==} engines: {node: '>=12'} cpu: [x64] os: [android] + '@esbuild/android-x64@0.21.1': + resolution: {integrity: sha512-NPObtlBh4jQHE01gJeucqEhdoD/4ya2owSIS8lZYS58aR0x7oZo9lB2lVFxgTANSa5MGCBeoQtr+yA9oKCGPvA==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + '@esbuild/darwin-arm64@0.19.12': resolution: {integrity: sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] + '@esbuild/darwin-arm64@0.21.1': + resolution: {integrity: sha512-BLT7TDzqsVlQRmJfO/FirzKlzmDpBWwmCUlyggfzUwg1cAxVxeA4O6b1XkMInlxISdfPAOunV9zXjvh5x99Heg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + '@esbuild/darwin-x64@0.19.12': resolution: {integrity: sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==} engines: {node: '>=12'} cpu: [x64] os: [darwin] + '@esbuild/darwin-x64@0.21.1': + resolution: {integrity: sha512-D3h3wBQmeS/vp93O4B+SWsXB8HvRDwMyhTNhBd8yMbh5wN/2pPWRW5o/hM3EKgk9bdKd9594lMGoTCTiglQGRQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + '@esbuild/freebsd-arm64@0.19.12': resolution: {integrity: sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] + '@esbuild/freebsd-arm64@0.21.1': + resolution: {integrity: sha512-/uVdqqpNKXIxT6TyS/oSK4XE4xWOqp6fh4B5tgAwozkyWdylcX+W4YF2v6SKsL4wCQ5h1bnaSNjWPXG/2hp8AQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + '@esbuild/freebsd-x64@0.19.12': resolution: {integrity: sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] + '@esbuild/freebsd-x64@0.21.1': + resolution: {integrity: sha512-paAkKN1n1jJitw+dAoR27TdCzxRl1FOEITx3h201R6NoXUojpMzgMLdkXVgCvaCSCqwYkeGLoe9UVNRDKSvQgw==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + '@esbuild/linux-arm64@0.19.12': resolution: {integrity: sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==} engines: {node: '>=12'} cpu: [arm64] os: [linux] + '@esbuild/linux-arm64@0.21.1': + resolution: {integrity: sha512-G65d08YoH00TL7Xg4LaL3gLV21bpoAhQ+r31NUu013YB7KK0fyXIt05VbsJtpqh/6wWxoLJZOvQHYnodRrnbUQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + '@esbuild/linux-arm@0.19.12': resolution: {integrity: sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==} engines: {node: '>=12'} cpu: [arm] os: [linux] + '@esbuild/linux-arm@0.21.1': + resolution: {integrity: sha512-tRHnxWJnvNnDpNVnsyDhr1DIQZUfCXlHSCDohbXFqmg9W4kKR7g8LmA3kzcwbuxbRMKeit8ladnCabU5f2traA==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + '@esbuild/linux-ia32@0.19.12': resolution: {integrity: sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==} engines: {node: '>=12'} cpu: [ia32] os: [linux] + '@esbuild/linux-ia32@0.21.1': + resolution: {integrity: sha512-tt/54LqNNAqCz++QhxoqB9+XqdsaZOtFD/srEhHYwBd3ZUOepmR1Eeot8bS+Q7BiEvy9vvKbtpHf+r6q8hF5UA==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + '@esbuild/linux-loong64@0.19.12': resolution: {integrity: sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==} engines: {node: '>=12'} cpu: [loong64] os: [linux] + '@esbuild/linux-loong64@0.21.1': + resolution: {integrity: sha512-MhNalK6r0nZD0q8VzUBPwheHzXPr9wronqmZrewLfP7ui9Fv1tdPmg6e7A8lmg0ziQCziSDHxh3cyRt4YMhGnQ==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + '@esbuild/linux-mips64el@0.19.12': resolution: {integrity: sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] + '@esbuild/linux-mips64el@0.21.1': + resolution: {integrity: sha512-YCKVY7Zen5rwZV+nZczOhFmHaeIxR4Zn3jcmNH53LbgF6IKRwmrMywqDrg4SiSNApEefkAbPSIzN39FC8VsxPg==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + '@esbuild/linux-ppc64@0.19.12': resolution: {integrity: sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] + '@esbuild/linux-ppc64@0.21.1': + resolution: {integrity: sha512-bw7bcQ+270IOzDV4mcsKAnDtAFqKO0jVv3IgRSd8iM0ac3L8amvCrujRVt1ajBTJcpDaFhIX+lCNRKteoDSLig==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + '@esbuild/linux-riscv64@0.19.12': resolution: {integrity: sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] + '@esbuild/linux-riscv64@0.21.1': + resolution: {integrity: sha512-ARmDRNkcOGOm1AqUBSwRVDfDeD9hGYRfkudP2QdoonBz1ucWVnfBPfy7H4JPI14eYtZruRSczJxyu7SRYDVOcg==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + '@esbuild/linux-s390x@0.19.12': resolution: {integrity: sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==} engines: {node: '>=12'} cpu: [s390x] os: [linux] + '@esbuild/linux-s390x@0.21.1': + resolution: {integrity: sha512-o73TcUNMuoTZlhwFdsgr8SfQtmMV58sbgq6gQq9G1xUiYnHMTmJbwq65RzMx89l0iya69lR4bxBgtWiiOyDQZA==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + '@esbuild/linux-x64@0.19.12': resolution: {integrity: sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==} engines: {node: '>=12'} cpu: [x64] os: [linux] + '@esbuild/linux-x64@0.21.1': + resolution: {integrity: sha512-da4/1mBJwwgJkbj4fMH7SOXq2zapgTo0LKXX1VUZ0Dxr+e8N0WbS80nSZ5+zf3lvpf8qxrkZdqkOqFfm57gXwA==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + '@esbuild/netbsd-x64@0.19.12': resolution: {integrity: sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] + '@esbuild/netbsd-x64@0.21.1': + resolution: {integrity: sha512-CPWs0HTFe5woTJN5eKPvgraUoRHrCtzlYIAv9wBC+FAyagBSaf+UdZrjwYyTGnwPGkThV4OCI7XibZOnPvONVw==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + '@esbuild/openbsd-x64@0.19.12': resolution: {integrity: sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] + '@esbuild/openbsd-x64@0.21.1': + resolution: {integrity: sha512-xxhTm5QtzNLc24R0hEkcH+zCx/o49AsdFZ0Cy5zSd/5tOj4X2g3/2AJB625NoadUuc4A8B3TenLJoYdWYOYCew==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + '@esbuild/sunos-x64@0.19.12': resolution: {integrity: sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==} engines: {node: '>=12'} cpu: [x64] os: [sunos] + '@esbuild/sunos-x64@0.21.1': + resolution: {integrity: sha512-CWibXszpWys1pYmbr9UiKAkX6x+Sxw8HWtw1dRESK1dLW5fFJ6rMDVw0o8MbadusvVQx1a8xuOxnHXT941Hp1A==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + '@esbuild/win32-arm64@0.19.12': resolution: {integrity: sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==} engines: {node: '>=12'} cpu: [arm64] os: [win32] + '@esbuild/win32-arm64@0.21.1': + resolution: {integrity: sha512-jb5B4k+xkytGbGUS4T+Z89cQJ9DJ4lozGRSV+hhfmCPpfJ3880O31Q1srPCimm+V6UCbnigqD10EgDNgjvjerQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + '@esbuild/win32-ia32@0.19.12': resolution: {integrity: sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==} engines: {node: '>=12'} cpu: [ia32] os: [win32] + '@esbuild/win32-ia32@0.21.1': + resolution: {integrity: sha512-PgyFvjJhXqHn1uxPhyN1wZ6dIomKjiLUQh1LjFvjiV1JmnkZ/oMPrfeEAZg5R/1ftz4LZWZr02kefNIQ5SKREQ==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + '@esbuild/win32-x64@0.19.12': resolution: {integrity: sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==} engines: {node: '>=12'} cpu: [x64] os: [win32] + '@esbuild/win32-x64@0.21.1': + resolution: {integrity: sha512-W9NttRZQR5ehAiqHGDnvfDaGmQOm6Fi4vSlce8mjM75x//XKuVAByohlEX6N17yZnVXxQFuh4fDRunP8ca6bfA==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + '@fastify/busboy@2.1.1': resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} engines: {node: '>=14'} @@ -3125,6 +3266,11 @@ packages: engines: {node: '>=12'} hasBin: true + esbuild@0.21.1: + resolution: {integrity: sha512-GPqx+FX7mdqulCeQ4TsGZQ3djBJkx5k7zBGtqt9ycVlWNg8llJ4RO9n2vciu8BN2zAEs6lPbPl0asZsAh7oWzg==} + engines: {node: '>=12'} + hasBin: true + escalade@3.1.2: resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} engines: {node: '>=6'} @@ -5085,72 +5231,141 @@ snapshots: '@esbuild/aix-ppc64@0.19.12': optional: true + '@esbuild/aix-ppc64@0.21.1': + optional: true + '@esbuild/android-arm64@0.19.12': optional: true + '@esbuild/android-arm64@0.21.1': + optional: true + '@esbuild/android-arm@0.19.12': optional: true + '@esbuild/android-arm@0.21.1': + optional: true + '@esbuild/android-x64@0.19.12': optional: true + '@esbuild/android-x64@0.21.1': + optional: true + '@esbuild/darwin-arm64@0.19.12': optional: true + '@esbuild/darwin-arm64@0.21.1': + optional: true + '@esbuild/darwin-x64@0.19.12': optional: true + '@esbuild/darwin-x64@0.21.1': + optional: true + '@esbuild/freebsd-arm64@0.19.12': optional: true + '@esbuild/freebsd-arm64@0.21.1': + optional: true + '@esbuild/freebsd-x64@0.19.12': optional: true + '@esbuild/freebsd-x64@0.21.1': + optional: true + '@esbuild/linux-arm64@0.19.12': optional: true + '@esbuild/linux-arm64@0.21.1': + optional: true + '@esbuild/linux-arm@0.19.12': optional: true + '@esbuild/linux-arm@0.21.1': + optional: true + '@esbuild/linux-ia32@0.19.12': optional: true + '@esbuild/linux-ia32@0.21.1': + optional: true + '@esbuild/linux-loong64@0.19.12': optional: true + '@esbuild/linux-loong64@0.21.1': + optional: true + '@esbuild/linux-mips64el@0.19.12': optional: true + '@esbuild/linux-mips64el@0.21.1': + optional: true + '@esbuild/linux-ppc64@0.19.12': optional: true + '@esbuild/linux-ppc64@0.21.1': + optional: true + '@esbuild/linux-riscv64@0.19.12': optional: true + '@esbuild/linux-riscv64@0.21.1': + optional: true + '@esbuild/linux-s390x@0.19.12': optional: true + '@esbuild/linux-s390x@0.21.1': + optional: true + '@esbuild/linux-x64@0.19.12': optional: true + '@esbuild/linux-x64@0.21.1': + optional: true + '@esbuild/netbsd-x64@0.19.12': optional: true + '@esbuild/netbsd-x64@0.21.1': + optional: true + '@esbuild/openbsd-x64@0.19.12': optional: true + '@esbuild/openbsd-x64@0.21.1': + optional: true + '@esbuild/sunos-x64@0.19.12': optional: true + '@esbuild/sunos-x64@0.21.1': + optional: true + '@esbuild/win32-arm64@0.19.12': optional: true + '@esbuild/win32-arm64@0.21.1': + optional: true + '@esbuild/win32-ia32@0.19.12': optional: true + '@esbuild/win32-ia32@0.21.1': + optional: true + '@esbuild/win32-x64@0.19.12': optional: true + '@esbuild/win32-x64@0.21.1': + optional: true + '@fastify/busboy@2.1.1': {} '@firebase/app-check-interop-types@0.3.1': {} @@ -7039,6 +7254,32 @@ snapshots: '@esbuild/win32-ia32': 0.19.12 '@esbuild/win32-x64': 0.19.12 + esbuild@0.21.1: + optionalDependencies: + '@esbuild/aix-ppc64': 0.21.1 + '@esbuild/android-arm': 0.21.1 + '@esbuild/android-arm64': 0.21.1 + '@esbuild/android-x64': 0.21.1 + '@esbuild/darwin-arm64': 0.21.1 + '@esbuild/darwin-x64': 0.21.1 + '@esbuild/freebsd-arm64': 0.21.1 + '@esbuild/freebsd-x64': 0.21.1 + '@esbuild/linux-arm': 0.21.1 + '@esbuild/linux-arm64': 0.21.1 + '@esbuild/linux-ia32': 0.21.1 + '@esbuild/linux-loong64': 0.21.1 + '@esbuild/linux-mips64el': 0.21.1 + '@esbuild/linux-ppc64': 0.21.1 + '@esbuild/linux-riscv64': 0.21.1 + '@esbuild/linux-s390x': 0.21.1 + '@esbuild/linux-x64': 0.21.1 + '@esbuild/netbsd-x64': 0.21.1 + '@esbuild/openbsd-x64': 0.21.1 + '@esbuild/sunos-x64': 0.21.1 + '@esbuild/win32-arm64': 0.21.1 + '@esbuild/win32-ia32': 0.21.1 + '@esbuild/win32-x64': 0.21.1 + escalade@3.1.2: {} escape-html@1.0.3: {} diff --git a/js/tsup.common.ts b/js/tsup.common.ts index c2f16a950e..187f11924e 100644 --- a/js/tsup.common.ts +++ b/js/tsup.common.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import { Plugin } from 'esbuild'; + export const defaultOptions = { format: ['cjs', 'esm'], dts: true, @@ -24,11 +26,9 @@ export const defaultOptions = { entry: ['src/**/*.ts'], bundle: false, treeshake: false, + esbuildPlugins: [forceEsmExtensionsPlugin()], }; -/** - * - */ export function fromPackageJson(packageJson: { exports?: { [key: string]: { import: string } }; }): string[] { @@ -42,3 +42,77 @@ export function fromPackageJson(packageJson: { } return out; } + +function forceEsmExtensionsPlugin(): Plugin { + return { + name: 'forceEsmExtensionsPlugin', + setup(build) { + const isEsm = build.initialOptions.format === 'esm'; + + build.onEnd(async (result) => { + if (result.errors.length > 0) { + return; + } + + for (const outputFile of result.outputFiles || []) { + if ( + !( + outputFile.path.endsWith('.js') || + outputFile.path.endsWith('.mjs') + ) + ) { + continue; + } + + const fileContents = outputFile.text; + const nextFileContents = modifyRelativeImports(fileContents, isEsm); + + outputFile.contents = Buffer.from(nextFileContents); + } + }); + }, + }; +} + +const CJS_RELATIVE_IMPORT_EXP = /require\(["'](\..+)["']\)(;)?/gm; +const ESM_RELATIVE_IMPORT_EXP = /from ["'](\..+)["'](;)?/gm; + +function modifyRelativeImports(contents: string, isEsm: boolean): string { + const extension = isEsm ? '.mjs' : '.js'; + const importExpression = isEsm + ? ESM_RELATIVE_IMPORT_EXP + : CJS_RELATIVE_IMPORT_EXP; + + return contents.replace( + importExpression, + (_, importPath, maybeSemicolon = '') => { + if (importPath.endsWith('.')) { + return isEsm + ? `from '${importPath}/index${extension}'${maybeSemicolon}` + : `require("${importPath}/index${extension}")${maybeSemicolon}`; + } + if (importPath.endsWith('/')) { + return isEsm + ? `from '${importPath}index${extension}'${maybeSemicolon}` + : `require("${importPath}index${extension}")${maybeSemicolon}`; + } + + if (importPath.endsWith(extension)) { + return isEsm + ? `from '${importPath}'${maybeSemicolon}` + : `require("${importPath}")${maybeSemicolon}`; + } + + return isEsm + ? `from '${maybeStripExistingExtension(importPath)}${extension}'${maybeSemicolon}` + : `require("${maybeStripExistingExtension(importPath)}${extension}")${maybeSemicolon}`; + } + ); +} + +function maybeStripExistingExtension(importPath: string) { + if (importPath.endsWith('.js') || importPath.endsWith('.mjs')) { + return importPath.substring(0, importPath.lastIndexOf('.')); + } + return importPath; +} From 81f5fd0565a66adca904fc414ab53c698d8338ed Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Sun, 12 May 2024 10:44:01 -0400 Subject: [PATCH 2/8] mark type exports --- js/ai/src/index.ts | 28 ++++++++-------- js/ai/src/retriever.ts | 8 ++--- js/flow/src/index.ts | 16 ++++----- js/tsup.common.ts | 75 ------------------------------------------ 4 files changed, 26 insertions(+), 101 deletions(-) diff --git a/js/ai/src/index.ts b/js/ai/src/index.ts index 06df9efec3..99f7cf68a6 100644 --- a/js/ai/src/index.ts +++ b/js/ai/src/index.ts @@ -15,35 +15,35 @@ */ export { - EvaluatorAction, - EvaluatorInfo, - EvaluatorReference, + type EvaluatorAction, + type EvaluatorInfo, + type EvaluatorReference, evaluate, evaluatorRef, } from './evaluator.js'; export { Candidate, - GenerateOptions, + type GenerateOptions, GenerateResponse, - GenerateStreamOptions, - GenerateStreamResponse, + type GenerateStreamOptions, + type GenerateStreamResponse, Message, generate, generateStream, toGenerateRequest, } from './generate.js'; -export { PromptAction, definePrompt, renderPrompt } from './prompt.js'; +export { type PromptAction, definePrompt, renderPrompt } from './prompt.js'; export { - IndexerAction, - IndexerInfo, - IndexerReference, - RetrieverAction, - RetrieverInfo, - RetrieverReference, + type IndexerAction, + type IndexerInfo, + type IndexerReference, + type RetrieverAction, + type RetrieverInfo, + type RetrieverReference, index, indexerRef, retrieve, retrieverRef, } from './retriever.js'; -export { ToolAction, asTool, defineTool } from './tool.js'; +export { type ToolAction, asTool, defineTool } from './tool.js'; export * from './types.js'; diff --git a/js/ai/src/retriever.ts b/js/ai/src/retriever.ts index 1ea4d9a4e8..4ccf91fcd4 100644 --- a/js/ai/src/retriever.ts +++ b/js/ai/src/retriever.ts @@ -22,11 +22,11 @@ import { EmbedderInfo } from './embedder.js'; export { Document, - DocumentData, + type DocumentData, DocumentDataSchema, - MediaPart, - Part, - TextPart, + type MediaPart, + type Part, + type TextPart, } from './document.js'; type RetrieverFn = ( diff --git a/js/flow/src/index.ts b/js/flow/src/index.ts index 81828e1851..be3227396a 100644 --- a/js/flow/src/index.ts +++ b/js/flow/src/index.ts @@ -15,19 +15,19 @@ */ export { - FlowState, + type FlowState, FlowStateExecutionSchema, - FlowStateStore, - Operation, + type FlowStateStore, + type Operation, OperationSchema, } from '@genkit-ai/core'; export { FirestoreStateStore } from './firestoreStateStore.js'; export { Flow, - FlowAuthPolicy, - FlowWrapper, - StepsFunction, - __RequestWithAuth, + type FlowAuthPolicy, + type FlowWrapper, + type StepsFunction, + type __RequestWithAuth, defineFlow, runFlow, startFlowsServer, @@ -35,7 +35,7 @@ export { } from './flow.js'; export { run, runAction, runMap } from './steps.js'; export { - FlowInvokeEnvelopeMessage, + type FlowInvokeEnvelopeMessage, FlowInvokeEnvelopeMessageSchema, } from './types.js'; export { getFlowAuth } from './utils.js'; diff --git a/js/tsup.common.ts b/js/tsup.common.ts index 187f11924e..e1e931a935 100644 --- a/js/tsup.common.ts +++ b/js/tsup.common.ts @@ -26,7 +26,6 @@ export const defaultOptions = { entry: ['src/**/*.ts'], bundle: false, treeshake: false, - esbuildPlugins: [forceEsmExtensionsPlugin()], }; export function fromPackageJson(packageJson: { @@ -42,77 +41,3 @@ export function fromPackageJson(packageJson: { } return out; } - -function forceEsmExtensionsPlugin(): Plugin { - return { - name: 'forceEsmExtensionsPlugin', - setup(build) { - const isEsm = build.initialOptions.format === 'esm'; - - build.onEnd(async (result) => { - if (result.errors.length > 0) { - return; - } - - for (const outputFile of result.outputFiles || []) { - if ( - !( - outputFile.path.endsWith('.js') || - outputFile.path.endsWith('.mjs') - ) - ) { - continue; - } - - const fileContents = outputFile.text; - const nextFileContents = modifyRelativeImports(fileContents, isEsm); - - outputFile.contents = Buffer.from(nextFileContents); - } - }); - }, - }; -} - -const CJS_RELATIVE_IMPORT_EXP = /require\(["'](\..+)["']\)(;)?/gm; -const ESM_RELATIVE_IMPORT_EXP = /from ["'](\..+)["'](;)?/gm; - -function modifyRelativeImports(contents: string, isEsm: boolean): string { - const extension = isEsm ? '.mjs' : '.js'; - const importExpression = isEsm - ? ESM_RELATIVE_IMPORT_EXP - : CJS_RELATIVE_IMPORT_EXP; - - return contents.replace( - importExpression, - (_, importPath, maybeSemicolon = '') => { - if (importPath.endsWith('.')) { - return isEsm - ? `from '${importPath}/index${extension}'${maybeSemicolon}` - : `require("${importPath}/index${extension}")${maybeSemicolon}`; - } - if (importPath.endsWith('/')) { - return isEsm - ? `from '${importPath}index${extension}'${maybeSemicolon}` - : `require("${importPath}index${extension}")${maybeSemicolon}`; - } - - if (importPath.endsWith(extension)) { - return isEsm - ? `from '${importPath}'${maybeSemicolon}` - : `require("${importPath}")${maybeSemicolon}`; - } - - return isEsm - ? `from '${maybeStripExistingExtension(importPath)}${extension}'${maybeSemicolon}` - : `require("${maybeStripExistingExtension(importPath)}${extension}")${maybeSemicolon}`; - } - ); -} - -function maybeStripExistingExtension(importPath: string) { - if (importPath.endsWith('.js') || importPath.endsWith('.mjs')) { - return importPath.substring(0, importPath.lastIndexOf('.')); - } - return importPath; -} From 6f1ad1da487cf5a7ded845287f8e2df3f457dd2c Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Sun, 12 May 2024 10:50:42 -0400 Subject: [PATCH 3/8] undo --- js/plugins/evaluators/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/plugins/evaluators/src/index.ts b/js/plugins/evaluators/src/index.ts index 92d6e17b1c..46a3d6eba3 100644 --- a/js/plugins/evaluators/src/index.ts +++ b/js/plugins/evaluators/src/index.ts @@ -29,7 +29,7 @@ import { answerRelevancyScore, faithfulnessScore, maliciousnessScore, -} from './metrics/index.js'; +} from './metrics'; import { GenkitMetric } from './types'; export { GenkitMetric }; From c8c76b1ce72653630ea8f808585e17844d98c811 Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Sun, 12 May 2024 10:51:12 -0400 Subject: [PATCH 4/8] more undo --- js/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/package.json b/js/package.json index e0493cccd7..54807b5d10 100644 --- a/js/package.json +++ b/js/package.json @@ -17,8 +17,7 @@ "devDependencies": { "npm-run-all": "^4.1.5", "only-allow": "^1.2.1", - "typescript": "^4.9.0", - "esbuild": "^0.21.1" + "typescript": "^4.9.0" }, "packageManager": "pnpm@9.1.0+sha256.22e36fba7f4880ecf749a5ca128b8435da085ecd49575e7fb9e64d6bf4fad394" } From cc396a948354a72494ebf59946795f0683fefd86 Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Sun, 12 May 2024 10:53:09 -0400 Subject: [PATCH 5/8] update lock --- js/pnpm-lock.yaml | 241 ---------------------------------------------- 1 file changed, 241 deletions(-) diff --git a/js/pnpm-lock.yaml b/js/pnpm-lock.yaml index bfc7a8fc2b..bc059a33bf 100644 --- a/js/pnpm-lock.yaml +++ b/js/pnpm-lock.yaml @@ -8,9 +8,6 @@ importers: .: devDependencies: - esbuild: - specifier: ^0.21.1 - version: 0.21.1 npm-run-all: specifier: ^4.1.5 version: 4.1.5 @@ -1278,276 +1275,138 @@ packages: cpu: [ppc64] os: [aix] - '@esbuild/aix-ppc64@0.21.1': - resolution: {integrity: sha512-O7yppwipkXvnEPjzkSXJRk2g4bS8sUx9p9oXHq9MU/U7lxUzZVsnFZMDTmeeX9bfQxrFcvOacl/ENgOh0WP9pA==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [aix] - '@esbuild/android-arm64@0.19.12': resolution: {integrity: sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==} engines: {node: '>=12'} cpu: [arm64] os: [android] - '@esbuild/android-arm64@0.21.1': - resolution: {integrity: sha512-jXhccq6es+onw7x8MxoFnm820mz7sGa9J14kLADclmiEUH4fyj+FjR6t0M93RgtlI/awHWhtF0Wgfhqgf9gDZA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - '@esbuild/android-arm@0.19.12': resolution: {integrity: sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==} engines: {node: '>=12'} cpu: [arm] os: [android] - '@esbuild/android-arm@0.21.1': - resolution: {integrity: sha512-hh3jKWikdnTtHCglDAeVO3Oyh8MaH8xZUaWMiCCvJ9/c3NtPqZq+CACOlGTxhddypXhl+8B45SeceYBfB/e8Ow==} - engines: {node: '>=12'} - cpu: [arm] - os: [android] - '@esbuild/android-x64@0.19.12': resolution: {integrity: sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==} engines: {node: '>=12'} cpu: [x64] os: [android] - '@esbuild/android-x64@0.21.1': - resolution: {integrity: sha512-NPObtlBh4jQHE01gJeucqEhdoD/4ya2owSIS8lZYS58aR0x7oZo9lB2lVFxgTANSa5MGCBeoQtr+yA9oKCGPvA==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - '@esbuild/darwin-arm64@0.19.12': resolution: {integrity: sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] - '@esbuild/darwin-arm64@0.21.1': - resolution: {integrity: sha512-BLT7TDzqsVlQRmJfO/FirzKlzmDpBWwmCUlyggfzUwg1cAxVxeA4O6b1XkMInlxISdfPAOunV9zXjvh5x99Heg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - '@esbuild/darwin-x64@0.19.12': resolution: {integrity: sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==} engines: {node: '>=12'} cpu: [x64] os: [darwin] - '@esbuild/darwin-x64@0.21.1': - resolution: {integrity: sha512-D3h3wBQmeS/vp93O4B+SWsXB8HvRDwMyhTNhBd8yMbh5wN/2pPWRW5o/hM3EKgk9bdKd9594lMGoTCTiglQGRQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - '@esbuild/freebsd-arm64@0.19.12': resolution: {integrity: sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-arm64@0.21.1': - resolution: {integrity: sha512-/uVdqqpNKXIxT6TyS/oSK4XE4xWOqp6fh4B5tgAwozkyWdylcX+W4YF2v6SKsL4wCQ5h1bnaSNjWPXG/2hp8AQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - '@esbuild/freebsd-x64@0.19.12': resolution: {integrity: sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] - '@esbuild/freebsd-x64@0.21.1': - resolution: {integrity: sha512-paAkKN1n1jJitw+dAoR27TdCzxRl1FOEITx3h201R6NoXUojpMzgMLdkXVgCvaCSCqwYkeGLoe9UVNRDKSvQgw==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - '@esbuild/linux-arm64@0.19.12': resolution: {integrity: sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==} engines: {node: '>=12'} cpu: [arm64] os: [linux] - '@esbuild/linux-arm64@0.21.1': - resolution: {integrity: sha512-G65d08YoH00TL7Xg4LaL3gLV21bpoAhQ+r31NUu013YB7KK0fyXIt05VbsJtpqh/6wWxoLJZOvQHYnodRrnbUQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - '@esbuild/linux-arm@0.19.12': resolution: {integrity: sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==} engines: {node: '>=12'} cpu: [arm] os: [linux] - '@esbuild/linux-arm@0.21.1': - resolution: {integrity: sha512-tRHnxWJnvNnDpNVnsyDhr1DIQZUfCXlHSCDohbXFqmg9W4kKR7g8LmA3kzcwbuxbRMKeit8ladnCabU5f2traA==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - '@esbuild/linux-ia32@0.19.12': resolution: {integrity: sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==} engines: {node: '>=12'} cpu: [ia32] os: [linux] - '@esbuild/linux-ia32@0.21.1': - resolution: {integrity: sha512-tt/54LqNNAqCz++QhxoqB9+XqdsaZOtFD/srEhHYwBd3ZUOepmR1Eeot8bS+Q7BiEvy9vvKbtpHf+r6q8hF5UA==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - '@esbuild/linux-loong64@0.19.12': resolution: {integrity: sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==} engines: {node: '>=12'} cpu: [loong64] os: [linux] - '@esbuild/linux-loong64@0.21.1': - resolution: {integrity: sha512-MhNalK6r0nZD0q8VzUBPwheHzXPr9wronqmZrewLfP7ui9Fv1tdPmg6e7A8lmg0ziQCziSDHxh3cyRt4YMhGnQ==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - '@esbuild/linux-mips64el@0.19.12': resolution: {integrity: sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] - '@esbuild/linux-mips64el@0.21.1': - resolution: {integrity: sha512-YCKVY7Zen5rwZV+nZczOhFmHaeIxR4Zn3jcmNH53LbgF6IKRwmrMywqDrg4SiSNApEefkAbPSIzN39FC8VsxPg==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - '@esbuild/linux-ppc64@0.19.12': resolution: {integrity: sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] - '@esbuild/linux-ppc64@0.21.1': - resolution: {integrity: sha512-bw7bcQ+270IOzDV4mcsKAnDtAFqKO0jVv3IgRSd8iM0ac3L8amvCrujRVt1ajBTJcpDaFhIX+lCNRKteoDSLig==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - '@esbuild/linux-riscv64@0.19.12': resolution: {integrity: sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] - '@esbuild/linux-riscv64@0.21.1': - resolution: {integrity: sha512-ARmDRNkcOGOm1AqUBSwRVDfDeD9hGYRfkudP2QdoonBz1ucWVnfBPfy7H4JPI14eYtZruRSczJxyu7SRYDVOcg==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - '@esbuild/linux-s390x@0.19.12': resolution: {integrity: sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==} engines: {node: '>=12'} cpu: [s390x] os: [linux] - '@esbuild/linux-s390x@0.21.1': - resolution: {integrity: sha512-o73TcUNMuoTZlhwFdsgr8SfQtmMV58sbgq6gQq9G1xUiYnHMTmJbwq65RzMx89l0iya69lR4bxBgtWiiOyDQZA==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - '@esbuild/linux-x64@0.19.12': resolution: {integrity: sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==} engines: {node: '>=12'} cpu: [x64] os: [linux] - '@esbuild/linux-x64@0.21.1': - resolution: {integrity: sha512-da4/1mBJwwgJkbj4fMH7SOXq2zapgTo0LKXX1VUZ0Dxr+e8N0WbS80nSZ5+zf3lvpf8qxrkZdqkOqFfm57gXwA==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - '@esbuild/netbsd-x64@0.19.12': resolution: {integrity: sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] - '@esbuild/netbsd-x64@0.21.1': - resolution: {integrity: sha512-CPWs0HTFe5woTJN5eKPvgraUoRHrCtzlYIAv9wBC+FAyagBSaf+UdZrjwYyTGnwPGkThV4OCI7XibZOnPvONVw==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - '@esbuild/openbsd-x64@0.19.12': resolution: {integrity: sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] - '@esbuild/openbsd-x64@0.21.1': - resolution: {integrity: sha512-xxhTm5QtzNLc24R0hEkcH+zCx/o49AsdFZ0Cy5zSd/5tOj4X2g3/2AJB625NoadUuc4A8B3TenLJoYdWYOYCew==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - '@esbuild/sunos-x64@0.19.12': resolution: {integrity: sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==} engines: {node: '>=12'} cpu: [x64] os: [sunos] - '@esbuild/sunos-x64@0.21.1': - resolution: {integrity: sha512-CWibXszpWys1pYmbr9UiKAkX6x+Sxw8HWtw1dRESK1dLW5fFJ6rMDVw0o8MbadusvVQx1a8xuOxnHXT941Hp1A==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - '@esbuild/win32-arm64@0.19.12': resolution: {integrity: sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==} engines: {node: '>=12'} cpu: [arm64] os: [win32] - '@esbuild/win32-arm64@0.21.1': - resolution: {integrity: sha512-jb5B4k+xkytGbGUS4T+Z89cQJ9DJ4lozGRSV+hhfmCPpfJ3880O31Q1srPCimm+V6UCbnigqD10EgDNgjvjerQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - '@esbuild/win32-ia32@0.19.12': resolution: {integrity: sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==} engines: {node: '>=12'} cpu: [ia32] os: [win32] - '@esbuild/win32-ia32@0.21.1': - resolution: {integrity: sha512-PgyFvjJhXqHn1uxPhyN1wZ6dIomKjiLUQh1LjFvjiV1JmnkZ/oMPrfeEAZg5R/1ftz4LZWZr02kefNIQ5SKREQ==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - '@esbuild/win32-x64@0.19.12': resolution: {integrity: sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==} engines: {node: '>=12'} cpu: [x64] os: [win32] - '@esbuild/win32-x64@0.21.1': - resolution: {integrity: sha512-W9NttRZQR5ehAiqHGDnvfDaGmQOm6Fi4vSlce8mjM75x//XKuVAByohlEX6N17yZnVXxQFuh4fDRunP8ca6bfA==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - '@fastify/busboy@2.1.1': resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} engines: {node: '>=14'} @@ -3266,11 +3125,6 @@ packages: engines: {node: '>=12'} hasBin: true - esbuild@0.21.1: - resolution: {integrity: sha512-GPqx+FX7mdqulCeQ4TsGZQ3djBJkx5k7zBGtqt9ycVlWNg8llJ4RO9n2vciu8BN2zAEs6lPbPl0asZsAh7oWzg==} - engines: {node: '>=12'} - hasBin: true - escalade@3.1.2: resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} engines: {node: '>=6'} @@ -5231,141 +5085,72 @@ snapshots: '@esbuild/aix-ppc64@0.19.12': optional: true - '@esbuild/aix-ppc64@0.21.1': - optional: true - '@esbuild/android-arm64@0.19.12': optional: true - '@esbuild/android-arm64@0.21.1': - optional: true - '@esbuild/android-arm@0.19.12': optional: true - '@esbuild/android-arm@0.21.1': - optional: true - '@esbuild/android-x64@0.19.12': optional: true - '@esbuild/android-x64@0.21.1': - optional: true - '@esbuild/darwin-arm64@0.19.12': optional: true - '@esbuild/darwin-arm64@0.21.1': - optional: true - '@esbuild/darwin-x64@0.19.12': optional: true - '@esbuild/darwin-x64@0.21.1': - optional: true - '@esbuild/freebsd-arm64@0.19.12': optional: true - '@esbuild/freebsd-arm64@0.21.1': - optional: true - '@esbuild/freebsd-x64@0.19.12': optional: true - '@esbuild/freebsd-x64@0.21.1': - optional: true - '@esbuild/linux-arm64@0.19.12': optional: true - '@esbuild/linux-arm64@0.21.1': - optional: true - '@esbuild/linux-arm@0.19.12': optional: true - '@esbuild/linux-arm@0.21.1': - optional: true - '@esbuild/linux-ia32@0.19.12': optional: true - '@esbuild/linux-ia32@0.21.1': - optional: true - '@esbuild/linux-loong64@0.19.12': optional: true - '@esbuild/linux-loong64@0.21.1': - optional: true - '@esbuild/linux-mips64el@0.19.12': optional: true - '@esbuild/linux-mips64el@0.21.1': - optional: true - '@esbuild/linux-ppc64@0.19.12': optional: true - '@esbuild/linux-ppc64@0.21.1': - optional: true - '@esbuild/linux-riscv64@0.19.12': optional: true - '@esbuild/linux-riscv64@0.21.1': - optional: true - '@esbuild/linux-s390x@0.19.12': optional: true - '@esbuild/linux-s390x@0.21.1': - optional: true - '@esbuild/linux-x64@0.19.12': optional: true - '@esbuild/linux-x64@0.21.1': - optional: true - '@esbuild/netbsd-x64@0.19.12': optional: true - '@esbuild/netbsd-x64@0.21.1': - optional: true - '@esbuild/openbsd-x64@0.19.12': optional: true - '@esbuild/openbsd-x64@0.21.1': - optional: true - '@esbuild/sunos-x64@0.19.12': optional: true - '@esbuild/sunos-x64@0.21.1': - optional: true - '@esbuild/win32-arm64@0.19.12': optional: true - '@esbuild/win32-arm64@0.21.1': - optional: true - '@esbuild/win32-ia32@0.19.12': optional: true - '@esbuild/win32-ia32@0.21.1': - optional: true - '@esbuild/win32-x64@0.19.12': optional: true - '@esbuild/win32-x64@0.21.1': - optional: true - '@fastify/busboy@2.1.1': {} '@firebase/app-check-interop-types@0.3.1': {} @@ -7254,32 +7039,6 @@ snapshots: '@esbuild/win32-ia32': 0.19.12 '@esbuild/win32-x64': 0.19.12 - esbuild@0.21.1: - optionalDependencies: - '@esbuild/aix-ppc64': 0.21.1 - '@esbuild/android-arm': 0.21.1 - '@esbuild/android-arm64': 0.21.1 - '@esbuild/android-x64': 0.21.1 - '@esbuild/darwin-arm64': 0.21.1 - '@esbuild/darwin-x64': 0.21.1 - '@esbuild/freebsd-arm64': 0.21.1 - '@esbuild/freebsd-x64': 0.21.1 - '@esbuild/linux-arm': 0.21.1 - '@esbuild/linux-arm64': 0.21.1 - '@esbuild/linux-ia32': 0.21.1 - '@esbuild/linux-loong64': 0.21.1 - '@esbuild/linux-mips64el': 0.21.1 - '@esbuild/linux-ppc64': 0.21.1 - '@esbuild/linux-riscv64': 0.21.1 - '@esbuild/linux-s390x': 0.21.1 - '@esbuild/linux-x64': 0.21.1 - '@esbuild/netbsd-x64': 0.21.1 - '@esbuild/openbsd-x64': 0.21.1 - '@esbuild/sunos-x64': 0.21.1 - '@esbuild/win32-arm64': 0.21.1 - '@esbuild/win32-ia32': 0.21.1 - '@esbuild/win32-x64': 0.21.1 - escalade@3.1.2: {} escape-html@1.0.3: {} From d49b7f1a203d536d42daa71fa89b7d518b3aba5b Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Sun, 12 May 2024 10:53:57 -0400 Subject: [PATCH 6/8] format --- js/ai/src/index.ts | 22 +++++++++++----------- js/ai/src/retriever.ts | 2 +- js/flow/src/index.ts | 14 +++++++------- js/tsup.common.ts | 2 -- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/js/ai/src/index.ts b/js/ai/src/index.ts index 99f7cf68a6..32fed5fa3f 100644 --- a/js/ai/src/index.ts +++ b/js/ai/src/index.ts @@ -15,35 +15,35 @@ */ export { + evaluate, + evaluatorRef, type EvaluatorAction, type EvaluatorInfo, type EvaluatorReference, - evaluate, - evaluatorRef, } from './evaluator.js'; export { Candidate, - type GenerateOptions, GenerateResponse, - type GenerateStreamOptions, - type GenerateStreamResponse, Message, generate, generateStream, toGenerateRequest, + type GenerateOptions, + type GenerateStreamOptions, + type GenerateStreamResponse, } from './generate.js'; -export { type PromptAction, definePrompt, renderPrompt } from './prompt.js'; +export { definePrompt, renderPrompt, type PromptAction } from './prompt.js'; export { + index, + indexerRef, + retrieve, + retrieverRef, type IndexerAction, type IndexerInfo, type IndexerReference, type RetrieverAction, type RetrieverInfo, type RetrieverReference, - index, - indexerRef, - retrieve, - retrieverRef, } from './retriever.js'; -export { type ToolAction, asTool, defineTool } from './tool.js'; +export { asTool, defineTool, type ToolAction } from './tool.js'; export * from './types.js'; diff --git a/js/ai/src/retriever.ts b/js/ai/src/retriever.ts index 4ccf91fcd4..5df8b7916c 100644 --- a/js/ai/src/retriever.ts +++ b/js/ai/src/retriever.ts @@ -22,8 +22,8 @@ import { EmbedderInfo } from './embedder.js'; export { Document, - type DocumentData, DocumentDataSchema, + type DocumentData, type MediaPart, type Part, type TextPart, diff --git a/js/flow/src/index.ts b/js/flow/src/index.ts index be3227396a..2653fadca5 100644 --- a/js/flow/src/index.ts +++ b/js/flow/src/index.ts @@ -15,27 +15,27 @@ */ export { - type FlowState, FlowStateExecutionSchema, + OperationSchema, + type FlowState, type FlowStateStore, type Operation, - OperationSchema, } from '@genkit-ai/core'; export { FirestoreStateStore } from './firestoreStateStore.js'; export { Flow, - type FlowAuthPolicy, - type FlowWrapper, - type StepsFunction, - type __RequestWithAuth, defineFlow, runFlow, startFlowsServer, streamFlow, + type FlowAuthPolicy, + type FlowWrapper, + type StepsFunction, + type __RequestWithAuth, } from './flow.js'; export { run, runAction, runMap } from './steps.js'; export { - type FlowInvokeEnvelopeMessage, FlowInvokeEnvelopeMessageSchema, + type FlowInvokeEnvelopeMessage, } from './types.js'; export { getFlowAuth } from './utils.js'; diff --git a/js/tsup.common.ts b/js/tsup.common.ts index e1e931a935..72b456911d 100644 --- a/js/tsup.common.ts +++ b/js/tsup.common.ts @@ -14,8 +14,6 @@ * limitations under the License. */ -import { Plugin } from 'esbuild'; - export const defaultOptions = { format: ['cjs', 'esm'], dts: true, From c29eeee521721ebcc7ba47a2d9894c26f29fc343 Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Sun, 12 May 2024 11:16:15 -0400 Subject: [PATCH 7/8] couple more fixes --- js/plugins/evaluators/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/plugins/evaluators/src/index.ts b/js/plugins/evaluators/src/index.ts index 46a3d6eba3..14cd5f14a2 100644 --- a/js/plugins/evaluators/src/index.ts +++ b/js/plugins/evaluators/src/index.ts @@ -29,8 +29,8 @@ import { answerRelevancyScore, faithfulnessScore, maliciousnessScore, -} from './metrics'; -import { GenkitMetric } from './types'; +} from './metrics/index.js'; +import { GenkitMetric } from './types.js'; export { GenkitMetric }; const PLUGIN_NAME = 'genkitEval'; From 0c3e7b078f70b28f629beb3529fcb682017086f2 Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Sun, 12 May 2024 11:41:05 -0400 Subject: [PATCH 8/8] undo --- js/tsup.common.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/tsup.common.ts b/js/tsup.common.ts index 72b456911d..c2f16a950e 100644 --- a/js/tsup.common.ts +++ b/js/tsup.common.ts @@ -26,6 +26,9 @@ export const defaultOptions = { treeshake: false, }; +/** + * + */ export function fromPackageJson(packageJson: { exports?: { [key: string]: { import: string } }; }): string[] {