omni-rest 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +47 -20
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +47 -20
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1532,9 +1532,18 @@ function write(filePath, content) {
|
|
|
1532
1532
|
function createPrismaClient() {
|
|
1533
1533
|
const customClient = tryLoadFromSchemaOutput();
|
|
1534
1534
|
if (customClient) return customClient;
|
|
1535
|
+
const standardPrismaClient = tryLoadFromStandardOutput();
|
|
1536
|
+
if (standardPrismaClient) return standardPrismaClient;
|
|
1535
1537
|
try {
|
|
1536
1538
|
const clientPath = __require.resolve("@prisma/client", { paths: [cwd] });
|
|
1537
|
-
const
|
|
1539
|
+
const mod = __require(clientPath);
|
|
1540
|
+
const PrismaClient = mod.PrismaClient ?? mod.default?.PrismaClient;
|
|
1541
|
+
if (!PrismaClient) throw new Error("PrismaClient not found in @prisma/client");
|
|
1542
|
+
const runtimeDataModel = mod?.Prisma?.runtimeDataModel ?? mod?.Prisma?._runtimeDataModel;
|
|
1543
|
+
if (runtimeDataModel?.models) {
|
|
1544
|
+
return { _runtimeDataModel: runtimeDataModel, $disconnect: async () => {
|
|
1545
|
+
} };
|
|
1546
|
+
}
|
|
1538
1547
|
return new PrismaClient();
|
|
1539
1548
|
} catch {
|
|
1540
1549
|
throw new Error(
|
|
@@ -1557,15 +1566,29 @@ function tryLoadFromSchemaOutput() {
|
|
|
1557
1566
|
const indexPath = path__namespace.default.join(outputDir, "index.js");
|
|
1558
1567
|
if (!fs3__namespace.default.existsSync(indexPath)) continue;
|
|
1559
1568
|
const mod = __require(indexPath);
|
|
1569
|
+
const runtimeDataModel = mod?.Prisma?.runtimeDataModel ?? mod?.Prisma?._runtimeDataModel;
|
|
1570
|
+
if (runtimeDataModel?.models) {
|
|
1571
|
+
return {
|
|
1572
|
+
_runtimeDataModel: runtimeDataModel,
|
|
1573
|
+
$disconnect: async () => {
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1560
1577
|
const PrismaClient = mod.PrismaClient ?? mod.default?.PrismaClient;
|
|
1561
1578
|
if (!PrismaClient) continue;
|
|
1562
|
-
const providerMatch = schema.match(/provider\s*=\s*["']([^"']+)["']/);
|
|
1563
|
-
const provider = providerMatch?.[1] ?? "postgresql";
|
|
1564
|
-
const dummyUrl = getDummyUrl(provider);
|
|
1565
1579
|
try {
|
|
1566
|
-
return new PrismaClient({ datasourceUrl: dummyUrl });
|
|
1567
|
-
} catch {
|
|
1568
1580
|
return new PrismaClient();
|
|
1581
|
+
} catch {
|
|
1582
|
+
for (const opt of [
|
|
1583
|
+
{ datasourceUrl: "postgresql://x:x@localhost/x" },
|
|
1584
|
+
{ datasources: { db: { url: "postgresql://x:x@localhost/x" } } }
|
|
1585
|
+
]) {
|
|
1586
|
+
try {
|
|
1587
|
+
return new PrismaClient(opt);
|
|
1588
|
+
} catch {
|
|
1589
|
+
continue;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1569
1592
|
}
|
|
1570
1593
|
} catch {
|
|
1571
1594
|
continue;
|
|
@@ -1573,21 +1596,25 @@ function tryLoadFromSchemaOutput() {
|
|
|
1573
1596
|
}
|
|
1574
1597
|
return null;
|
|
1575
1598
|
}
|
|
1576
|
-
function
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1599
|
+
function tryLoadFromStandardOutput() {
|
|
1600
|
+
const candidates = [
|
|
1601
|
+
path__namespace.default.resolve(cwd, "node_modules/.prisma/client/index.js"),
|
|
1602
|
+
path__namespace.default.resolve(cwd, "node_modules/.prisma/client/default.js")
|
|
1603
|
+
];
|
|
1604
|
+
for (const clientPath of candidates) {
|
|
1605
|
+
if (!fs3__namespace.default.existsSync(clientPath)) continue;
|
|
1606
|
+
try {
|
|
1607
|
+
const mod = __require(clientPath);
|
|
1608
|
+
const runtimeDataModel = mod?.Prisma?.runtimeDataModel ?? mod?.Prisma?._runtimeDataModel;
|
|
1609
|
+
if (runtimeDataModel?.models) {
|
|
1610
|
+
return { _runtimeDataModel: runtimeDataModel, $disconnect: async () => {
|
|
1611
|
+
} };
|
|
1612
|
+
}
|
|
1613
|
+
} catch {
|
|
1614
|
+
continue;
|
|
1615
|
+
}
|
|
1590
1616
|
}
|
|
1617
|
+
return null;
|
|
1591
1618
|
}
|
|
1592
1619
|
var USAGE = `
|
|
1593
1620
|
Usage:
|