This commit is contained in:
Rizky 2024-05-08 22:26:09 +07:00
parent acc85512c5
commit 699c93a27f
6 changed files with 24 additions and 3 deletions

View File

@ -30,6 +30,13 @@ export const _ = {
const action = pathname.split("/")[1]; const action = pathname.split("/")[1];
switch (action) { switch (action) {
case "prisma.ext.d.ts": {
const path = dir.path(
`app/srv/ws/sync/code/templates/typings/prisma_ext_d_ts`
);
const file = Bun.file(path);
return new Response(file);
}
case "type_def": { case "type_def": {
const path = dir.data(`/code/${site_id}/site/typings.d.ts`); const path = dir.data(`/code/${site_id}/site/typings.d.ts`);
const file = Bun.file(path); const file = Bun.file(path);

File diff suppressed because one or more lines are too long

View File

@ -46,6 +46,14 @@ export const loadTypings = async (p: PG) => {
p.render(); p.render();
} }
}), }),
fetch(`/prod/${id_site}/_prasi/prisma.ext`)
.catch(() => {})
.then(async (res) => {
if (res) {
p.prisma_ext = (await res.text()).replace("./prisma", "ts:prisma");
p.render();
}
}),
]); ]);
}; };

View File

@ -153,6 +153,7 @@ export const EDGlobal = {
site_exports: {} as Record<string, any>, site_exports: {} as Record<string, any>,
site_dts: "", site_dts: "",
site_dts_entry: {} as any, site_dts_entry: {} as any,
prisma_ext: "",
script: { script: {
site_types: {} as Record<string, string>, site_types: {} as Record<string, string>,
loaded: false, loaded: false,

View File

@ -187,6 +187,7 @@ export const EdScriptMonaco: FC<{}> = () => {
site_dts: p.site_dts, site_dts: p.site_dts,
site_dts_entry: p.site_dts_entry, site_dts_entry: p.site_dts_entry,
site_exports: p.site_exports, site_exports: p.site_exports,
prisma_ext: p.prisma_ext,
script: { script: {
siteTypes: p.script.site_types, siteTypes: p.script.site_types,
}, },

View File

@ -1,6 +1,5 @@
import type { OnMount } from "@monaco-editor/react"; import type { OnMount } from "@monaco-editor/react";
import { w } from "../types/general"; import { w } from "../types/general";
import { prismaExtendType } from "./prisma-extend";
import { baseTypings } from "./types/base"; import { baseTypings } from "./types/base";
import { extractProp } from "./types/prop"; import { extractProp } from "./types/prop";
export type MonacoEditor = Parameters<OnMount>[0]; export type MonacoEditor = Parameters<OnMount>[0];
@ -39,6 +38,7 @@ export const registerSiteTypings = (
export const monacoTypings = async ( export const monacoTypings = async (
p: { p: {
site_dts: string; site_dts: string;
prisma_ext: string;
site_dts_entry: any; site_dts_entry: any;
site: { api_url: string }; site: { api_url: string };
site_exports: Record<string, any>; site_exports: Record<string, any>;
@ -133,6 +133,8 @@ ${(
apiPath = "gen/srv/api/srv"; apiPath = "gen/srv/api/srv";
} }
register(monaco, p.prisma_ext, "ts:prisma.ext");
register( register(
monaco, monaco,
`\ `\
@ -151,8 +153,10 @@ import "./api"
import type * as SRVAPI from "${apiPath}";` import type * as SRVAPI from "${apiPath}";`
)} )}
import { PrismaExtend } from "ts:prisma.ext"
declare global { declare global {
const db: prisma.PrismaClient & ${prismaExtendType}; const db: prisma.PrismaClient & PrismaExtend;
${baseTypings} ${baseTypings}