1

So I'm building a telegram bot using grammY, Prisma running on Deno. Whilst working on a functionality that requires users to fill in some fields for a form, I decided to use conversations like I always do but this I decided to use Prisma enums for the conversation.form.select. But when I tried importing the enum, I get this error:

error: Uncaught SyntaxError: The requested module '@prisma/client' does not provide an export named 'BusinessTypeEnum'
import { BusinessTypeEnum } from "@prisma/client";
         ^
    at <anonymous> (file:///home/waptik/code/bots/xxxxx/src/telegram/handlers/conversations/xxxx.conversation.ts:6:10)

Environment & setup

  • OS: Ubuntu
  • Database: PlanetScale
  • Deno version: 1.30.3
  • grammY: 1.13.1

Prisma Version

4.9.0

partial conversation.ts

import { GrammyContext, GrammyConversation } from "~grammy/context.ts";
import { Composer, createConversation } from "~grammy/deps.ts";
import { handleErrorMessage } from "~grammy/helpers/handleErrors.ts";
import { Prisma, BusinessTypeEnum } from "@prisma/client";


async function createXxxx(convo: GrammyConversation, ctx: GrammyContext) {
  try {
    await ctx.replyWithChatAction("typing");

    const bizTypes = Object.keys(BusinessTypeEnum).map((o) => o);
    console.log({ bizTypes });

  } catch (e) {
    const message = handleErrorMessage(e);
    await ctx.reply(message);
  }
  return;
}

partial schema.prisma

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["deno"]
  output          = "./generated/client"
}

datasource db {
  provider     = "mysql"
  url          = env("DATABASE_URL")
  relationMode = "prisma"
}


enum BusinessTypeEnum {
  PRODUCT
  SERVICE
  BOTH
  OTHER
}

import_map.json

{
    "imports": {
        "@/": "./src/",
        "@utils/": "./src/utils/",
        "~grammy/": "./src/telegram/",
        "@prisma/client": "./prisma/generated/client/deno/edge.ts",
        "~prisma": "./prisma/mod.ts",
        "$std/": "https://deno.land/std@0.176.0/",
        "grammy": "https://deno.land/x/grammy@v1.13.1/mod.ts",
        "grammy/types": "https://deno.land/x/grammy@v1.13.1/types.deno.ts",
        "grammy-conversations/": "https://deno.land/x/grammy_conversations@v1.1.1/",
        "menu": "https://deno.land/x/grammy_menu@v1.1.2/mod.ts",
        "zod": "https://deno.land/x/zod@v3.20.5/mod.ts",
    }
}

So I'm expecting these values PRODUCT, SERVICE, BOTH, OTHER to be printed in console without any errors.
I also tried this suggestion as well as deleting prisma/generated, node_modules, package***.json before running deno run -A --unstable npm:prisma db push && deno run -A --unstable npm:prisma generate --data-proxy but nothing happened. I created a github issue but I got no replies, that's why I'm posting here.

greybeard
  • 2,249
  • 8
  • 30
  • 66
Stephane
  • 41
  • 7

0 Answers0