From 7348c96a25283e8f2da399648c11320cb30069f5 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Wed, 2 Aug 2023 10:42:31 +0900 Subject: [PATCH] fix: handle proto loading in next.js app router (#86) * Bump @grpc/grpc-js from 1.8.14 to 1.8.21 (#85) * Bump protobufjs from 7.2.3 to 7.2.4 (#81) * Bump typescript from 5.0.4 to 5.1.6 (#80) * Bump semver from 5.7.1 to 5.7.2 (#82) * fix proto file loading in next.js app router * set version to 0.5.1 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Luke Kim <80174+lukekim@users.noreply.github.com> --- package.json | 4 ++-- src/client.ts | 6 +++++- yarn.lock | 51 +++++++++++++++++++++++---------------------------- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index e73dee5..92ec9fb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@spiceai/spice", "description": "Spice.js Node.js SDK", - "version": "0.5.0", + "version": "0.5.1", "engines": { "node": ">=18.0.0" }, @@ -44,4 +44,4 @@ "typescript": "^5.0.2", "ws": "^8.13.0" } -} \ No newline at end of file +} diff --git a/src/client.ts b/src/client.ts index 57f05c7..3c8fb5e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -30,7 +30,11 @@ const HTTP_DATA_PATH = 'https://data.spiceai.io'; const FLIGHT_PATH = 'flight.spiceai.io:443'; const PROTO_PATH = './proto/Flight.proto'; -const fullProtoPath = path.join(__dirname, PROTO_PATH); +// If we're running in a Next.js environment, we need to adjust the path to the proto file +const PACKAGE_PATH = __dirname.includes('/.next/server/app') + ? __dirname.replace(/\/\.next\/.*$/, "/node_modules/@spiceai/spice/dist") + : __dirname; +const fullProtoPath = path.join(PACKAGE_PATH, PROTO_PATH); const packageDefinition = protoLoader.loadSync(fullProtoPath, { keepCase: true, diff --git a/yarn.lock b/yarn.lock index 661276a..81ebbed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -307,9 +307,9 @@ "@jridgewell/trace-mapping" "0.3.9" "@grpc/grpc-js@^1.8.14": - version "1.8.14" - resolved "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.8.14.tgz" - integrity sha512-w84maJ6CKl5aApCMzFll0hxtFNT6or9WwMslobKaqWUEf1K+zhlL43bSQhFreyYWIWR+Z0xnVFC1KtLm4ZpM/A== + version "1.8.21" + resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.8.21.tgz#d282b122c71227859bf6c5866f4c40f4a2696513" + integrity sha512-KeyQeZpxeEBSqFVTi3q2K7PiPXmgBfECc4updA1ejCLjYmoAlvvM3ZMp5ztTDUCUQmoY3CpDxvchjO1+rFkoHg== dependencies: "@grpc/proto-loader" "^0.7.0" "@types/node" ">=12.12.47" @@ -769,21 +769,16 @@ resolved "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz" integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== -"@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0": - version "16.18.25" - resolved "https://registry.npmjs.org/@types/node/-/node-16.18.25.tgz" - integrity sha512-rUDO6s9Q/El1R1I21HG4qw/LstTHCPO/oQNAwI/4b2f9EWvMnqt4d3HJwPMawfZ3UvodB8516Yg+VAq54YM+eA== +"@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@^18.16.18": + version "18.16.18" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.16.18.tgz#85da09bafb66d4bc14f7c899185336d0c1736390" + integrity sha512-/aNaQZD0+iSBAGnvvN2Cx92HqE5sZCPZtx2TsK+4nvV23fFe09jVDvpArXr2j9DnYlzuU9WuoykDDc6wqvpNcw== "@types/node@18.14.5": version "18.14.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.5.tgz#4a13a6445862159303fc38586598a9396fc408b3" integrity sha512-CRT4tMK/DHYhw1fcCEBwME9CSaZNclxfzVMe7GsO6ULSwsttbj70wSiX6rZdIjGblu93sTJxLdhNIT85KKI7Qw== -"@types/node@^18.16.18": - version "18.16.18" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.16.18.tgz#85da09bafb66d4bc14f7c899185336d0c1736390" - integrity sha512-/aNaQZD0+iSBAGnvvN2Cx92HqE5sZCPZtx2TsK+4nvV23fFe09jVDvpArXr2j9DnYlzuU9WuoykDDc6wqvpNcw== - "@types/pad-left@2.1.1": version "2.1.1" resolved "https://registry.npmjs.org/@types/pad-left/-/pad-left-2.1.1.tgz" @@ -2372,9 +2367,9 @@ prompts@^2.0.1: sisteransi "^1.0.5" protobufjs@^7.0.0: - version "7.2.3" - resolved "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.3.tgz" - integrity sha512-TtpvOqwB5Gdz/PQmOjgsrGH1nHjAQVCN7JG4A6r1sXRWESL5rNMAiRcBQlCAdKxZcAbstExQePYG8xof/JVRgg== + version "7.2.4" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.2.4.tgz#3fc1ec0cdc89dd91aef9ba6037ba07408485c3ae" + integrity sha512-AT+RJgD2sH8phPmCf7OUZR8xGdcJRga4+1cOaXJ64hvcSkVhNcRHOwIxUatPH15+nj59WAGTDv3LSGZPEQbJaQ== dependencies: "@protobufjs/aspromise" "^1.1.2" "@protobufjs/base64" "^1.1.2" @@ -2488,25 +2483,25 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1: integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== semver@7.x, semver@^7.3.5: - version "7.5.0" - resolved "https://registry.npmjs.org/semver/-/semver-7.5.0.tgz" - integrity sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA== + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== dependencies: lru-cache "^6.0.0" semver@^5.7.1: - version "5.7.1" - resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== semver@^6.0.0, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== semver@~7.0.0: version "7.0.0" - resolved "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== shebang-command@^2.0.0: @@ -2771,9 +2766,9 @@ type-fest@^0.21.3: integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== typescript@^5.0.2: - version "5.0.4" - resolved "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz" - integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== + version "5.1.6" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274" + integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA== typical@^4.0.0: version "4.0.0"