fix prisma db
This commit is contained in:
parent
697cd906c0
commit
3da5103b34
|
|
@ -110,17 +110,21 @@ export const parseTypeDef = async (path: string) => {
|
||||||
if (found) {
|
if (found) {
|
||||||
exports[t.id.value].push(found);
|
exports[t.id.value].push(found);
|
||||||
exported = true;
|
exported = true;
|
||||||
} else {
|
|
||||||
exports[t.id.value].push({
|
|
||||||
kind: "const",
|
|
||||||
type: "named",
|
|
||||||
val: s.orig.value,
|
|
||||||
});
|
|
||||||
exported = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (body.specifiers) {
|
||||||
|
for (const s of body.specifiers) {
|
||||||
|
if (s.type === "ExportSpecifier" && s.orig) {
|
||||||
|
exports[t.id.value].push({
|
||||||
|
kind: "type",
|
||||||
|
type: "named",
|
||||||
|
val: s.orig.value,
|
||||||
|
});
|
||||||
|
exported = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!exported) {
|
if (!exported) {
|
||||||
console.log("export-named-declaration", body);
|
console.log("export-named-declaration", body);
|
||||||
|
|
|
||||||
|
|
@ -16,19 +16,22 @@ export const registerSiteTypings = (
|
||||||
) => {
|
) => {
|
||||||
if (p.site_dts) {
|
if (p.site_dts) {
|
||||||
register(monaco, p.site_dts, "ts:site.d.ts");
|
register(monaco, p.site_dts, "ts:site.d.ts");
|
||||||
register(
|
|
||||||
monaco,
|
const dts_text = Object.entries(p.site_dts_entry)
|
||||||
`
|
|
||||||
declare global {
|
|
||||||
import * as _ from "index"
|
|
||||||
${Object.entries(p.site_dts_entry)
|
|
||||||
.map(([name, type]) => {
|
.map(([name, type]) => {
|
||||||
return `
|
return `
|
||||||
${type} ${name} = _.${name};`;
|
${type} ${name} = _.${name};`;
|
||||||
})
|
})
|
||||||
.join("\n")}
|
.join("\n");
|
||||||
}
|
|
||||||
export {}
|
register(
|
||||||
|
monaco,
|
||||||
|
`\
|
||||||
|
declare global {
|
||||||
|
import * as _ from "index"
|
||||||
|
${dts_text}
|
||||||
|
}
|
||||||
|
export {}
|
||||||
`,
|
`,
|
||||||
"ts:active_global.d.ts"
|
"ts:active_global.d.ts"
|
||||||
);
|
);
|
||||||
|
|
@ -78,10 +81,8 @@ declare module "ts:runtime/library" {
|
||||||
`ts:runtime/library.d.ts`
|
`ts:runtime/library.d.ts`
|
||||||
);
|
);
|
||||||
|
|
||||||
register(
|
const prisma_text = `\
|
||||||
monaco,
|
declare global {
|
||||||
`\
|
|
||||||
declare module "ts:prisma" {
|
|
||||||
${prisma["prisma.d.ts"]
|
${prisma["prisma.d.ts"]
|
||||||
.replace(
|
.replace(
|
||||||
`import * as runtime from './runtime/library.js';`,
|
`import * as runtime from './runtime/library.js';`,
|
||||||
|
|
@ -90,10 +91,11 @@ declare module "ts:prisma" {
|
||||||
.replace(
|
.replace(
|
||||||
`import * as runtime from './runtime/library';`,
|
`import * as runtime from './runtime/library';`,
|
||||||
`import * as runtime from 'ts:runtime/library';`
|
`import * as runtime from 'ts:runtime/library';`
|
||||||
)}
|
)
|
||||||
}`,
|
.replaceAll(`export type`, `type`)}
|
||||||
`ts:prisma.d.ts`
|
}
|
||||||
);
|
export {}`;
|
||||||
|
register(monaco, prisma_text, `ts:prisma.d.ts`);
|
||||||
|
|
||||||
register(
|
register(
|
||||||
monaco,
|
monaco,
|
||||||
|
|
@ -183,7 +185,6 @@ export function jsxs(
|
||||||
monaco,
|
monaco,
|
||||||
`\
|
`\
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import prisma from 'ts:prisma';
|
|
||||||
import { PrismaExtend } from "ts:prisma_ext"
|
import { PrismaExtend } from "ts:prisma_ext"
|
||||||
|
|
||||||
${iftext(
|
${iftext(
|
||||||
|
|
@ -195,7 +196,7 @@ import type * as SRVAPI from "${apiPath}";`
|
||||||
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
const db: prisma.PrismaClient & PrismaExtend;
|
const db: PrismaClient & PrismaExtend;
|
||||||
|
|
||||||
${baseTypings}
|
${baseTypings}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue