@prisma-next/cli 0.3.0-dev.13 → 0.3.0-dev.14
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/README.md +109 -25
- package/dist/{chunk-CVNWLFXO.js → chunk-6EPKRATC.js} +2 -2
- package/dist/{chunk-BZMBKEEQ.js → chunk-DIJPT5TZ.js} +3 -33
- package/dist/chunk-DIJPT5TZ.js.map +1 -0
- package/dist/{chunk-QUPBU4KV.js → chunk-MG7PBERL.js} +2 -2
- package/dist/chunk-VI2YETW7.js +38 -0
- package/dist/chunk-VI2YETW7.js.map +1 -0
- package/dist/cli.js +34 -38
- package/dist/cli.js.map +1 -1
- package/dist/commands/contract-emit.js +3 -2
- package/dist/commands/db-init.d.ts.map +1 -1
- package/dist/commands/db-init.js +21 -19
- package/dist/commands/db-init.js.map +1 -1
- package/dist/commands/db-introspect.d.ts.map +1 -1
- package/dist/commands/db-introspect.js +13 -16
- package/dist/commands/db-introspect.js.map +1 -1
- package/dist/commands/db-schema-verify.d.ts.map +1 -1
- package/dist/commands/db-schema-verify.js +8 -7
- package/dist/commands/db-schema-verify.js.map +1 -1
- package/dist/commands/db-sign.js +8 -7
- package/dist/commands/db-sign.js.map +1 -1
- package/dist/commands/db-verify.d.ts.map +1 -1
- package/dist/commands/db-verify.js +8 -7
- package/dist/commands/db-verify.js.map +1 -1
- package/dist/control-api/client.d.ts +13 -0
- package/dist/control-api/client.d.ts.map +1 -0
- package/dist/control-api/operations/db-init.d.ts +27 -0
- package/dist/control-api/operations/db-init.d.ts.map +1 -0
- package/dist/control-api/types.d.ts +203 -0
- package/dist/control-api/types.d.ts.map +1 -0
- package/dist/exports/control-api.d.ts +13 -0
- package/dist/exports/control-api.d.ts.map +1 -0
- package/dist/exports/control-api.js +240 -0
- package/dist/exports/control-api.js.map +1 -0
- package/dist/exports/index.js +3 -2
- package/dist/exports/index.js.map +1 -1
- package/dist/utils/cli-errors.d.ts +1 -1
- package/dist/utils/cli-errors.d.ts.map +1 -1
- package/package.json +14 -10
- package/src/commands/db-init.ts +12 -11
- package/src/commands/db-introspect.ts +16 -18
- package/src/commands/db-schema-verify.ts +6 -7
- package/src/commands/db-sign.ts +6 -6
- package/src/commands/db-verify.ts +6 -7
- package/src/control-api/client.ts +229 -0
- package/src/control-api/operations/db-init.ts +167 -0
- package/src/control-api/types.ts +251 -0
- package/src/exports/control-api.ts +34 -0
- package/src/utils/cli-errors.ts +1 -1
- package/dist/chunk-BZMBKEEQ.js.map +0 -1
- /package/dist/{chunk-CVNWLFXO.js.map → chunk-6EPKRATC.js.map} +0 -0
- /package/dist/{chunk-QUPBU4KV.js.map → chunk-MG7PBERL.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
errorContractConfigMissing,
|
|
65
65
|
errorContractMissingExtensionPacks,
|
|
66
66
|
errorContractValidationFailed,
|
|
67
|
-
|
|
67
|
+
errorDatabaseConnectionRequired,
|
|
68
68
|
errorDriverRequired,
|
|
69
69
|
errorFamilyReadMarkerSqlRequired,
|
|
70
70
|
errorFileNotFound,
|
|
@@ -1348,10 +1348,10 @@ function createDbInitCommand() {
|
|
|
1348
1348
|
{ where: { path: contractPathAbsolute } }
|
|
1349
1349
|
);
|
|
1350
1350
|
}
|
|
1351
|
-
const
|
|
1352
|
-
if (!
|
|
1353
|
-
throw
|
|
1354
|
-
why: `Database
|
|
1351
|
+
const dbConnection = options.db ?? config.db?.connection;
|
|
1352
|
+
if (!dbConnection) {
|
|
1353
|
+
throw errorDatabaseConnectionRequired({
|
|
1354
|
+
why: `Database connection is required for db init (set db.connection in ${configPath}, or pass --db <url>)`
|
|
1355
1355
|
});
|
|
1356
1356
|
}
|
|
1357
1357
|
if (!config.driver) {
|
|
@@ -1366,20 +1366,20 @@ function createDbInitCommand() {
|
|
|
1366
1366
|
const migrations = config.target.migrations;
|
|
1367
1367
|
let driver;
|
|
1368
1368
|
try {
|
|
1369
|
-
driver = await withSpinner(() => driverDescriptor.create(
|
|
1369
|
+
driver = await withSpinner(() => driverDescriptor.create(dbConnection), {
|
|
1370
1370
|
message: "Connecting to database...",
|
|
1371
1371
|
flags
|
|
1372
1372
|
});
|
|
1373
1373
|
} catch (error) {
|
|
1374
1374
|
const message = error instanceof Error ? error.message : String(error);
|
|
1375
1375
|
const code = error.code;
|
|
1376
|
-
const redacted = redactDatabaseUrl(
|
|
1376
|
+
const redacted = typeof dbConnection === "string" ? redactDatabaseUrl(dbConnection) : void 0;
|
|
1377
1377
|
throw errorRuntime("Database connection failed", {
|
|
1378
1378
|
why: message,
|
|
1379
|
-
fix: "Verify the database
|
|
1379
|
+
fix: "Verify the database connection, ensure the database is reachable, and confirm credentials/permissions",
|
|
1380
1380
|
meta: {
|
|
1381
1381
|
...typeof code !== "undefined" ? { code } : {},
|
|
1382
|
-
...redacted
|
|
1382
|
+
...redacted ?? {}
|
|
1383
1383
|
}
|
|
1384
1384
|
});
|
|
1385
1385
|
}
|
|
@@ -1581,7 +1581,7 @@ function createDbInitCommand() {
|
|
|
1581
1581
|
import { readFile as readFile2 } from "fs/promises";
|
|
1582
1582
|
import { relative as relative4, resolve as resolve4 } from "path";
|
|
1583
1583
|
import {
|
|
1584
|
-
|
|
1584
|
+
errorDatabaseConnectionRequired as errorDatabaseConnectionRequired2,
|
|
1585
1585
|
errorDriverRequired as errorDriverRequired2,
|
|
1586
1586
|
errorRuntime as errorRuntime2,
|
|
1587
1587
|
errorUnexpected as errorUnexpected3
|
|
@@ -1627,8 +1627,8 @@ function createDbIntrospectCommand() {
|
|
|
1627
1627
|
if (options.db) {
|
|
1628
1628
|
const maskedUrl = options.db.replace(/:([^:@]+)@/, ":****@");
|
|
1629
1629
|
details.push({ label: "database", value: maskedUrl });
|
|
1630
|
-
} else if (config.db?.
|
|
1631
|
-
const maskedUrl = config.db.
|
|
1630
|
+
} else if (config.db?.connection && typeof config.db.connection === "string") {
|
|
1631
|
+
const maskedUrl = config.db.connection.replace(/:([^:@]+)@/, ":****@");
|
|
1632
1632
|
details.push({ label: "database", value: maskedUrl });
|
|
1633
1633
|
}
|
|
1634
1634
|
const header = formatStyledHeader({
|
|
@@ -1640,15 +1640,15 @@ function createDbIntrospectCommand() {
|
|
|
1640
1640
|
});
|
|
1641
1641
|
console.log(header);
|
|
1642
1642
|
}
|
|
1643
|
-
const
|
|
1644
|
-
if (!
|
|
1645
|
-
throw
|
|
1643
|
+
const dbConnection = options.db ?? config.db?.connection;
|
|
1644
|
+
if (!dbConnection) {
|
|
1645
|
+
throw errorDatabaseConnectionRequired2();
|
|
1646
1646
|
}
|
|
1647
1647
|
if (!config.driver) {
|
|
1648
1648
|
throw errorDriverRequired2();
|
|
1649
1649
|
}
|
|
1650
1650
|
const driverDescriptor = config.driver;
|
|
1651
|
-
const driver = await withSpinner(() => driverDescriptor.create(
|
|
1651
|
+
const driver = await withSpinner(() => driverDescriptor.create(dbConnection), {
|
|
1652
1652
|
message: "Connecting to database...",
|
|
1653
1653
|
flags
|
|
1654
1654
|
});
|
|
@@ -1698,6 +1698,7 @@ function createDbIntrospectCommand() {
|
|
|
1698
1698
|
if (!flags.quiet && flags.json !== "object" && process.stdout.isTTY) {
|
|
1699
1699
|
console.log("");
|
|
1700
1700
|
}
|
|
1701
|
+
const connectionForMeta = typeof dbConnection === "string" ? dbConnection.replace(/:([^:@]+)@/, ":****@") : void 0;
|
|
1701
1702
|
const introspectResult = {
|
|
1702
1703
|
ok: true,
|
|
1703
1704
|
summary: "Schema introspected successfully",
|
|
@@ -1706,15 +1707,10 @@ function createDbIntrospectCommand() {
|
|
|
1706
1707
|
id: config.target.targetId
|
|
1707
1708
|
},
|
|
1708
1709
|
schema: schemaIR,
|
|
1709
|
-
...configPath ||
|
|
1710
|
+
...configPath || connectionForMeta ? {
|
|
1710
1711
|
meta: {
|
|
1711
1712
|
...configPath ? { configPath } : {},
|
|
1712
|
-
...
|
|
1713
|
-
dbUrl: (options.db ?? config.db?.url ?? "").replace(
|
|
1714
|
-
/:([^:@]+)@/,
|
|
1715
|
-
":****@"
|
|
1716
|
-
)
|
|
1717
|
-
} : {}
|
|
1713
|
+
...connectionForMeta ? { dbUrl: connectionForMeta } : {}
|
|
1718
1714
|
}
|
|
1719
1715
|
} : {},
|
|
1720
1716
|
timings: {
|
|
@@ -1746,7 +1742,7 @@ function createDbIntrospectCommand() {
|
|
|
1746
1742
|
import { readFile as readFile3 } from "fs/promises";
|
|
1747
1743
|
import { relative as relative5, resolve as resolve5 } from "path";
|
|
1748
1744
|
import {
|
|
1749
|
-
|
|
1745
|
+
errorDatabaseConnectionRequired as errorDatabaseConnectionRequired3,
|
|
1750
1746
|
errorDriverRequired as errorDriverRequired3,
|
|
1751
1747
|
errorFileNotFound as errorFileNotFound2,
|
|
1752
1748
|
errorRuntime as errorRuntime3,
|
|
@@ -1817,11 +1813,11 @@ function createDbSchemaVerifyCommand() {
|
|
|
1817
1813
|
const familyInstance = config.family.create(stack);
|
|
1818
1814
|
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1819
1815
|
assertContractRequirementsSatisfied({ contract: contractIR, stack });
|
|
1820
|
-
const
|
|
1821
|
-
if (!
|
|
1822
|
-
throw
|
|
1816
|
+
const dbConnection = options.db ?? config.db?.connection;
|
|
1817
|
+
if (!dbConnection) {
|
|
1818
|
+
throw errorDatabaseConnectionRequired3();
|
|
1823
1819
|
}
|
|
1824
|
-
const driver = await withSpinner(() => driverDescriptor.create(
|
|
1820
|
+
const driver = await withSpinner(() => driverDescriptor.create(dbConnection), {
|
|
1825
1821
|
message: "Connecting to database...",
|
|
1826
1822
|
flags
|
|
1827
1823
|
});
|
|
@@ -1884,7 +1880,7 @@ function createDbSchemaVerifyCommand() {
|
|
|
1884
1880
|
import { readFile as readFile4 } from "fs/promises";
|
|
1885
1881
|
import { relative as relative6, resolve as resolve6 } from "path";
|
|
1886
1882
|
import {
|
|
1887
|
-
|
|
1883
|
+
errorDatabaseConnectionRequired as errorDatabaseConnectionRequired4,
|
|
1888
1884
|
errorDriverRequired as errorDriverRequired4,
|
|
1889
1885
|
errorFileNotFound as errorFileNotFound3,
|
|
1890
1886
|
errorRuntime as errorRuntime4,
|
|
@@ -1942,9 +1938,9 @@ function createDbSignCommand() {
|
|
|
1942
1938
|
});
|
|
1943
1939
|
}
|
|
1944
1940
|
const contractJson = JSON.parse(contractJsonContent);
|
|
1945
|
-
const
|
|
1946
|
-
if (!
|
|
1947
|
-
throw
|
|
1941
|
+
const dbConnection = options.db ?? config.db?.connection;
|
|
1942
|
+
if (!dbConnection) {
|
|
1943
|
+
throw errorDatabaseConnectionRequired4();
|
|
1948
1944
|
}
|
|
1949
1945
|
if (!config.driver) {
|
|
1950
1946
|
throw errorDriverRequired4();
|
|
@@ -1965,7 +1961,7 @@ function createDbSignCommand() {
|
|
|
1965
1961
|
config.target.targetId,
|
|
1966
1962
|
rawComponents
|
|
1967
1963
|
);
|
|
1968
|
-
const driver = await driverDescriptor.create(
|
|
1964
|
+
const driver = await driverDescriptor.create(dbConnection);
|
|
1969
1965
|
try {
|
|
1970
1966
|
let schemaVerifyResult;
|
|
1971
1967
|
try {
|
|
@@ -2055,7 +2051,7 @@ function createDbSignCommand() {
|
|
|
2055
2051
|
import { readFile as readFile5 } from "fs/promises";
|
|
2056
2052
|
import { relative as relative7, resolve as resolve7 } from "path";
|
|
2057
2053
|
import {
|
|
2058
|
-
|
|
2054
|
+
errorDatabaseConnectionRequired as errorDatabaseConnectionRequired5,
|
|
2059
2055
|
errorDriverRequired as errorDriverRequired5,
|
|
2060
2056
|
errorFileNotFound as errorFileNotFound4,
|
|
2061
2057
|
errorHashMismatch as errorHashMismatch2,
|
|
@@ -2116,15 +2112,15 @@ function createDbVerifyCommand() {
|
|
|
2116
2112
|
});
|
|
2117
2113
|
}
|
|
2118
2114
|
const contractJson = JSON.parse(contractJsonContent);
|
|
2119
|
-
const
|
|
2120
|
-
if (!
|
|
2121
|
-
throw
|
|
2115
|
+
const dbConnection = options.db ?? config.db?.connection;
|
|
2116
|
+
if (!dbConnection) {
|
|
2117
|
+
throw errorDatabaseConnectionRequired5();
|
|
2122
2118
|
}
|
|
2123
2119
|
if (!config.driver) {
|
|
2124
2120
|
throw errorDriverRequired5();
|
|
2125
2121
|
}
|
|
2126
2122
|
const driverDescriptor = config.driver;
|
|
2127
|
-
const driver = await withSpinner(() => driverDescriptor.create(
|
|
2123
|
+
const driver = await withSpinner(() => driverDescriptor.create(dbConnection), {
|
|
2128
2124
|
message: "Connecting to database...",
|
|
2129
2125
|
flags
|
|
2130
2126
|
});
|