()
| 58 | } |
| 59 | |
| 60 | public toJS(): string { |
| 61 | const { edge, wasm, generator, datamodel: inlineSchema, runtimeName, reusedJs, compilerBuild } = this.options |
| 62 | |
| 63 | if (reusedJs) { |
| 64 | return `module.exports = { ...require(class="st">'${reusedJs}') }` |
| 65 | } |
| 66 | |
| 67 | const config: Omit<GetPrismaClientConfig, class="st">'runtimeDataModel' | class="st">'parameterizationSchema'> = { |
| 68 | previewFeatures: generator.previewFeatures, |
| 69 | clientVersion: this.options.clientVersion, |
| 70 | engineVersion: this.options.engineVersion, |
| 71 | activeProvider: this.options.activeProvider, |
| 72 | inlineSchema, |
| 73 | } |
| 74 | |
| 75 | const code = `${commonCodeJS({ ...this.options, browser: false })} |
| 76 | ${buildRequirePath(edge)} |
| 77 | |
| 78 | /** |
| 79 | * Enums |
| 80 | */ |
| 81 | ${this.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toJS()).join(class="st">'\n\n')} |
| 82 | ${this.dmmf.datamodel.enums |
| 83 | .map((datamodelEnum) => new Enum(datamodelEnumToSchemaEnum(datamodelEnum), false).toJS()) |
| 84 | .join(class="st">'\n\n')} |
| 85 | |
| 86 | ${new Enum( |
| 87 | { |
| 88 | name: class="st">'ModelName', |
| 89 | values: this.dmmf.mappings.modelOperations.map((m) => m.model), |
| 90 | }, |
| 91 | true, |
| 92 | ).toJS()} |
| 93 | /** |
| 94 | * Create the Client |
| 95 | */ |
| 96 | const config = ${JSON.stringify(config, null, 2)} |
| 97 | ${buildRuntimeDataModel(this.dmmf.datamodel, runtimeName)} |
| 98 | ${this.buildParamGraphConfig()} |
| 99 | ${buildQueryCompilerWasmModule(wasm, runtimeName, compilerBuild)} |
| 100 | ${buildDebugInitialization(edge)} |
| 101 | const PrismaClient = getPrismaClient(config) |
| 102 | exports.PrismaClient = PrismaClient |
| 103 | Object.assign(exports, Prisma) |
| 104 | ` |
| 105 | return code |
| 106 | } |
| 107 | |
| 108 | public toTS(): string { |
| 109 | const { reusedTs } = this.options |
nothing calls this directly
no test coverage detected