From a26dcf997d8e55464834feaa7e6f7bf796a398a5 Mon Sep 17 00:00:00 2001 From: Hank Stoever Date: Mon, 11 Sep 2023 12:34:07 -0700 Subject: [PATCH] fix: return nullable for fetch inscription by name --- api/src/routes/trpc/bridge-router.ts | 15 +++-- api/src/routes/trpc/search-router.ts | 7 --- package.json | 3 +- packages/api-types/src/export-types.ts | 2 +- pnpm-lock.yaml | 84 ++++++++++++++++++-------- turbo.json | 21 +++---- 6 files changed, 76 insertions(+), 56 deletions(-) diff --git a/api/src/routes/trpc/bridge-router.ts b/api/src/routes/trpc/bridge-router.ts index c9433f7..b351413 100644 --- a/api/src/routes/trpc/bridge-router.ts +++ b/api/src/routes/trpc/bridge-router.ts @@ -61,10 +61,12 @@ export const bridgeRouter = router({ getInscriptionByName: procedure .input(z.object({ name: z.string() })) .output( - z.object({ - inscriptionId: z.string(), - owner: z.string(), - }) + z.nullable( + z.object({ + inscriptionId: z.string(), + owner: z.string(), + }) + ) ) .query(async ({ ctx, input }) => { expectDb(ctx.prisma); @@ -85,10 +87,7 @@ export const bridgeRouter = router({ }); if (inscribedName === null) { - throw new TRPCError({ - message: `Unable to fetch inscription for ${input.name}`, - code: 'NOT_FOUND', - }); + return null; } const inscriptionId = inscriptionBuffToId(hexToBytes(inscribedName.inscription_id)); diff --git a/api/src/routes/trpc/search-router.ts b/api/src/routes/trpc/search-router.ts index 79c0003..e91487b 100644 --- a/api/src/routes/trpc/search-router.ts +++ b/api/src/routes/trpc/search-router.ts @@ -1,12 +1,5 @@ import { router, procedure } from './base'; -import { expectDb } from '@db/db-utils'; import { z } from 'zod'; -import { convertDbName } from '~/contracts/utils'; -import { parseFqn } from '@bns-x/core'; -import { nameObjectToHex } from '~/utils'; -import { TRPCError } from '@trpc/server'; -import { fetchInscriptionOwner, inscriptionBuffToId } from '@fetchers/inscriptions'; -import { hexToBytes, bytesToHex } from 'micro-stacks/common'; export const nameSearchResultSchema = z.object({ name: z.string(), diff --git a/package.json b/package.json index 1824f71..99dfccb 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "typecheck": "turbo run typecheck --continue", "api:prod": "pnpm --filter @bns-x/api prod", "build:packages": "turbo run build --filter=@bns-x/client --filter=@bns-x/api-types --filter=@bns-x/bridge", + "build:trpc": "pnpm --filter @bns-x/api build:trpc && pnpm build:packages", "publish-local": "pnpm build:packages && pnpm publish -r", "test": "turbo run test" }, @@ -41,7 +42,7 @@ "prettier": "^2.8.7", "start-server-and-test": "^1.15.2", "tsup": "^6.5.0", - "turbo": "^1.7.0", + "turbo": "^1.10.13", "typescript": "4.9.5" }, "devDependencies": { diff --git a/packages/api-types/src/export-types.ts b/packages/api-types/src/export-types.ts index c9ce4de..a076d3b 100644 --- a/packages/api-types/src/export-types.ts +++ b/packages/api-types/src/export-types.ts @@ -258,7 +258,7 @@ export type AppProcedures = { { inscriptionId: string; owner: string; - } + } | null >; getNameByInscription: AnyProc< 'query', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 90cf330..dbe2d7b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -46,8 +46,8 @@ importers: specifier: ^6.5.0 version: 6.5.0(@swc/core@1.3.14)(typescript@4.9.5) turbo: - specifier: ^1.7.0 - version: 1.7.0 + specifier: ^1.10.13 + version: 1.10.13 typescript: specifier: 4.9.5 version: 4.9.5 @@ -342,7 +342,7 @@ importers: version: 29.3.1(@types/node@18.11.9) ts-jest: specifier: ^29.0.3 - version: 29.0.3(@babel/core@7.22.9)(esbuild@0.17.7)(jest@29.3.1)(typescript@4.9.5) + version: 29.0.3(@babel/core@7.20.5)(esbuild@0.17.7)(jest@29.3.1)(typescript@4.9.5) tsup: specifier: ^6.7.0 version: 6.7.0(@swc/core@1.3.14)(typescript@4.9.5) @@ -434,7 +434,7 @@ importers: version: 1.4.2 ts-jest: specifier: ^29.0.3 - version: 29.0.3(@babel/core@7.22.9)(esbuild@0.17.7)(jest@29.3.1)(typescript@4.9.5) + version: 29.0.3(@babel/core@7.20.5)(esbuild@0.17.7)(jest@29.3.1)(typescript@4.9.5) tsup: specifier: ^6.7.0 version: 6.7.0(@swc/core@1.3.14)(typescript@4.9.5) @@ -15938,6 +15938,41 @@ packages: /ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} + /ts-jest@29.0.3(@babel/core@7.20.5)(esbuild@0.17.7)(jest@29.3.1)(typescript@4.9.5): + resolution: {integrity: sha512-Ibygvmuyq1qp/z3yTh9QTwVVAbFdDy/+4BtIQR2sp6baF2SJU/8CKK/hhnGIDY2L90Az2jIqTwZPnN2p+BweiQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + hasBin: true + peerDependencies: + '@babel/core': '>=7.0.0-beta.0 <8' + '@jest/types': ^29.0.0 + babel-jest: ^29.0.0 + esbuild: '*' + jest: ^29.0.0 + typescript: '>=4.3' + peerDependenciesMeta: + '@babel/core': + optional: true + '@jest/types': + optional: true + babel-jest: + optional: true + esbuild: + optional: true + dependencies: + '@babel/core': 7.20.5 + bs-logger: 0.2.6 + esbuild: 0.17.7 + fast-json-stable-stringify: 2.1.0 + jest: 29.3.1(@types/node@18.11.9) + jest-util: 29.3.1 + json5: 2.2.3 + lodash.memoize: 4.1.2 + make-error: 1.3.6 + semver: 7.3.8 + typescript: 4.9.5 + yargs-parser: 21.1.1 + dev: true + /ts-jest@29.0.3(@babel/core@7.22.9)(esbuild@0.15.18)(jest@29.3.1)(typescript@4.9.5): resolution: {integrity: sha512-Ibygvmuyq1qp/z3yTh9QTwVVAbFdDy/+4BtIQR2sp6baF2SJU/8CKK/hhnGIDY2L90Az2jIqTwZPnN2p+BweiQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -16154,65 +16189,64 @@ packages: yargs: 17.6.2 dev: true - /turbo-darwin-64@1.7.0: - resolution: {integrity: sha512-hSGAueSf5Ko8J67mpqjpt9FsP6ePn1nMcl7IVPoJq5dHsgX3anCP/BPlexJ502bNK+87DDyhQhJ/LPSJXKrSYQ==} + /turbo-darwin-64@1.10.13: + resolution: {integrity: sha512-vmngGfa2dlYvX7UFVncsNDMuT4X2KPyPJ2Jj+xvf5nvQnZR/3IeDEGleGVuMi/hRzdinoxwXqgk9flEmAYp0Xw==} cpu: [x64] os: [darwin] requiresBuild: true dev: false optional: true - /turbo-darwin-arm64@1.7.0: - resolution: {integrity: sha512-BLLOW5W6VZxk5+0ZOj5AO1qjM0P5isIgjbEuyAl8lHZ4s9antUbY4CtFrspT32XxPTYoDl4UjviPMcSsbcl3WQ==} + /turbo-darwin-arm64@1.10.13: + resolution: {integrity: sha512-eMoJC+k7gIS4i2qL6rKmrIQGP6Wr9nN4odzzgHFngLTMimok2cGLK3qbJs5O5F/XAtEeRAmuxeRnzQwTl/iuAw==} cpu: [arm64] os: [darwin] requiresBuild: true dev: false optional: true - /turbo-linux-64@1.7.0: - resolution: {integrity: sha512-aw2qxmfZa+kT87SB3GNUoFimqEPzTlzlRqhPgHuAAT6Uf0JHnmebPt4K+ZPtDNl5yfVmtB05bhHPqw+5QV97Yg==} + /turbo-linux-64@1.10.13: + resolution: {integrity: sha512-0CyYmnKTs6kcx7+JRH3nPEqCnzWduM0hj8GP/aodhaIkLNSAGAa+RiYZz6C7IXN+xUVh5rrWTnU2f1SkIy7Gdg==} cpu: [x64] os: [linux] requiresBuild: true dev: false optional: true - /turbo-linux-arm64@1.7.0: - resolution: {integrity: sha512-AJEx2jX+zO5fQtJpO3r6uhTabj4oSA5ZhB7zTs/rwu/XqoydsvStA4X8NDW4poTbOjF7DcSHizqwi04tSMzpJw==} + /turbo-linux-arm64@1.10.13: + resolution: {integrity: sha512-0iBKviSGQQlh2OjZgBsGjkPXoxvRIxrrLLbLObwJo3sOjIH0loGmVIimGS5E323soMfi/o+sidjk2wU1kFfD7Q==} cpu: [arm64] os: [linux] requiresBuild: true dev: false optional: true - /turbo-windows-64@1.7.0: - resolution: {integrity: sha512-ewj7PPv2uxqv0r31hgnBa3E5qwUu7eyVRP5M1gB/TJXfSHduU79gbxpKCyxIZv2fL/N2/3U7EPOQPSZxBAoljA==} + /turbo-windows-64@1.10.13: + resolution: {integrity: sha512-S5XySRfW2AmnTeY1IT+Jdr6Goq7mxWganVFfrmqU+qqq3Om/nr0GkcUX+KTIo9mPrN0D3p5QViBRzulwB5iuUQ==} cpu: [x64] os: [win32] requiresBuild: true dev: false optional: true - /turbo-windows-arm64@1.7.0: - resolution: {integrity: sha512-LzjOUzveWkvTD0jP8DBMYiAnYemmydsvqxdSmsUapHHJkl6wKZIOQNSO7pxsy+9XM/1/+0f9Y9F9ZNl5lePTEA==} + /turbo-windows-arm64@1.10.13: + resolution: {integrity: sha512-nKol6+CyiExJIuoIc3exUQPIBjP9nIq5SkMJgJuxsot2hkgGrafAg/izVDRDrRduQcXj2s8LdtxJHvvnbI8hEQ==} cpu: [arm64] os: [win32] requiresBuild: true dev: false optional: true - /turbo@1.7.0: - resolution: {integrity: sha512-cwympNwQNnQZ/TffBd8yT0i0O10Cf/hlxccCYgUcwhcGEb9rDjE5thDbHoHw1hlJQUF/5ua7ERJe7Zr0lNE/ww==} + /turbo@1.10.13: + resolution: {integrity: sha512-vOF5IPytgQPIsgGtT0n2uGZizR2N3kKuPIn4b5p5DdeLoI0BV7uNiydT7eSzdkPRpdXNnO8UwS658VaI4+YSzQ==} hasBin: true - requiresBuild: true optionalDependencies: - turbo-darwin-64: 1.7.0 - turbo-darwin-arm64: 1.7.0 - turbo-linux-64: 1.7.0 - turbo-linux-arm64: 1.7.0 - turbo-windows-64: 1.7.0 - turbo-windows-arm64: 1.7.0 + turbo-darwin-64: 1.10.13 + turbo-darwin-arm64: 1.10.13 + turbo-linux-64: 1.10.13 + turbo-linux-arm64: 1.10.13 + turbo-windows-64: 1.10.13 + turbo-windows-arm64: 1.10.13 dev: false /type-check@0.4.0: diff --git a/turbo.json b/turbo.json index 7d7fd09..cb696db 100644 --- a/turbo.json +++ b/turbo.json @@ -1,24 +1,17 @@ { - "baseBranch": "origin/main", + "$schema": "https://turbo.build/schema.json", "pipeline": { "build": { - "dependsOn": [ - "^build" - ], - "outputs": [ - "dist/**", - ".next/**" - ] + "dependsOn": ["^build"], + "outputs": ["dist/**", ".next/**"], + "outputMode": "new-only" }, "test": { - "dependsOn": [ - "^build" - ], + "dependsOn": ["^build"], "outputs": [] }, "lint": { - "outputs": [], - "parallel": true + "outputs": [] }, "dev": { "cache": false @@ -28,4 +21,4 @@ "outputs": [] } } -} \ No newline at end of file +}