@prisma-next/cli 0.1.0-pr.55.2 → 0.1.0-pr.56.2
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 +14 -13
- package/dist/{chunk-4W62XWA4.js → chunk-XS2KZ6CJ.js} +1 -1
- package/dist/chunk-XS2KZ6CJ.js.map +1 -0
- package/dist/cli.js +13 -18
- package/dist/cli.js.map +1 -1
- package/dist/commands/contract-emit.js +1 -1
- package/dist/commands/db-init.js +2 -3
- package/dist/commands/db-init.js.map +1 -1
- package/dist/commands/db-introspect.js +4 -5
- package/dist/commands/db-introspect.js.map +1 -1
- package/dist/commands/db-schema-verify.js +2 -3
- package/dist/commands/db-schema-verify.js.map +1 -1
- package/dist/commands/db-sign.js +3 -4
- package/dist/commands/db-sign.js.map +1 -1
- package/dist/commands/db-verify.js +2 -3
- package/dist/commands/db-verify.js.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +11 -11
- package/dist/chunk-4W62XWA4.js.map +0 -1
package/README.md
CHANGED
|
@@ -221,20 +221,21 @@ Failure:
|
|
|
221
221
|
|
|
222
222
|
**Family Requirements:**
|
|
223
223
|
|
|
224
|
-
The family must provide a `create()` method in the family descriptor that returns a `
|
|
224
|
+
The family must provide a `create()` method in the family descriptor that returns a `ControlFamilyInstance` with a `verify()` method:
|
|
225
225
|
|
|
226
226
|
```typescript
|
|
227
|
-
interface
|
|
227
|
+
interface ControlFamilyDescriptor {
|
|
228
228
|
create(options: {
|
|
229
|
-
target:
|
|
230
|
-
adapter:
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
target: ControlTargetDescriptor;
|
|
230
|
+
adapter: ControlAdapterDescriptor;
|
|
231
|
+
driver: ControlDriverDescriptor;
|
|
232
|
+
extensions: ControlExtensionDescriptor[];
|
|
233
|
+
}): ControlFamilyInstance;
|
|
233
234
|
}
|
|
234
235
|
|
|
235
|
-
interface
|
|
236
|
+
interface ControlFamilyInstance {
|
|
236
237
|
verify(options: {
|
|
237
|
-
driver:
|
|
238
|
+
driver: ControlDriverInstance;
|
|
238
239
|
contractIR: ContractIR;
|
|
239
240
|
expectedTargetId: string;
|
|
240
241
|
contractPath: string;
|
|
@@ -377,11 +378,11 @@ sql schema (tables: 2)
|
|
|
377
378
|
**Family Requirements:**
|
|
378
379
|
|
|
379
380
|
The family must provide:
|
|
380
|
-
1. A `create()` method in the family descriptor that returns a `
|
|
381
|
-
2. An optional `toSchemaView()` method on the `
|
|
381
|
+
1. A `create()` method in the family descriptor that returns a `ControlFamilyInstance` with an `introspect()` method
|
|
382
|
+
2. An optional `toSchemaView()` method on the `ControlFamilyInstance` to project family-specific schema IR into `CoreSchemaView`
|
|
382
383
|
|
|
383
384
|
```typescript
|
|
384
|
-
interface
|
|
385
|
+
interface ControlFamilyInstance {
|
|
385
386
|
introspect(options: {
|
|
386
387
|
driver: ControlDriverInstance;
|
|
387
388
|
contractIR?: ContractIR;
|
|
@@ -583,10 +584,10 @@ The `db sign` command is idempotent and safe to run multiple times:
|
|
|
583
584
|
- Safe to run in CI/deployment pipelines
|
|
584
585
|
|
|
585
586
|
**Family Requirements:**
|
|
586
|
-
The family must provide a `create()` method in the family descriptor that returns a `
|
|
587
|
+
The family must provide a `create()` method in the family descriptor that returns a `ControlFamilyInstance` with `schemaVerify()` and `sign()` methods:
|
|
587
588
|
|
|
588
589
|
```typescript
|
|
589
|
-
interface
|
|
590
|
+
interface ControlFamilyInstance {
|
|
590
591
|
schemaVerify(options: {
|
|
591
592
|
driver: ControlDriverInstance;
|
|
592
593
|
contractIR: ContractIR;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/contract-emit.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, relative, resolve } from 'node:path';\nimport { errorContractConfigMissing } from '@prisma-next/core-control-plane/errors';\nimport { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport { setCommandDescriptions } from '../utils/command-helpers';\nimport { parseGlobalFlags } from '../utils/global-flags';\nimport {\n formatCommandHelp,\n formatEmitJson,\n formatEmitOutput,\n formatStyledHeader,\n formatSuccessMessage,\n} from '../utils/output';\nimport { performAction } from '../utils/result';\nimport { handleResult } from '../utils/result-handler';\nimport { withSpinner } from '../utils/spinner';\n\ninterface ContractEmitOptions {\n readonly config?: string;\n readonly json?: string | boolean;\n readonly quiet?: boolean;\n readonly q?: boolean;\n readonly verbose?: boolean;\n readonly v?: boolean;\n readonly vv?: boolean;\n readonly trace?: boolean;\n readonly timestamps?: boolean;\n readonly color?: boolean;\n readonly 'no-color'?: boolean;\n}\n\nexport function createContractEmitCommand(): Command {\n const command = new Command('emit');\n setCommandDescriptions(\n command,\n 'Write your contract to JSON and sign it',\n 'Reads your contract source (TypeScript or Prisma schema) and emits contract.json and\\n' +\n 'contract.d.ts. The contract.json contains the canonical contract structure, and\\n' +\n 'contract.d.ts provides TypeScript types for type-safe query building.',\n );\n command\n .configureHelp({\n formatHelp: (cmd) => {\n const flags = parseGlobalFlags({});\n return formatCommandHelp({ command: cmd, flags });\n },\n })\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--json [format]', 'Output as JSON (object or ndjson)', false)\n .option('-q, --quiet', 'Quiet mode: errors only')\n .option('-v, --verbose', 'Verbose output: debug info, timings')\n .option('-vv, --trace', 'Trace output: deep internals, stack traces')\n .option('--timestamps', 'Add timestamps to output')\n .option('--color', 'Force color output')\n .option('--no-color', 'Disable color output')\n .action(async (options: ContractEmitOptions) => {\n const flags = parseGlobalFlags(options);\n\n const result = await performAction(async () => {\n // Load config\n const config = await loadConfig(options.config);\n\n // Resolve contract from config\n if (!config.contract) {\n throw errorContractConfigMissing({\n why: 'Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ..., types: ... }',\n });\n }\n\n // Contract config is already normalized by defineConfig() with defaults applied\n const contractConfig = config.contract;\n\n // Resolve artifact paths from config (already normalized by defineConfig() with defaults)\n if (!contractConfig.output || !contractConfig.types) {\n throw errorContractConfigMissing({\n why: 'Contract config must have output and types paths. This should not happen if defineConfig() was used.',\n });\n }\n const outputJsonPath = resolve(contractConfig.output);\n const outputDtsPath = resolve(contractConfig.types);\n\n // Output header (only for human-readable output)\n if (flags.json !== 'object' && !flags.quiet) {\n // Normalize config path for display (match contract path format - no ./ prefix)\n const configPath = options.config\n ? relative(process.cwd(), resolve(options.config))\n : 'prisma-next.config.ts';\n // Convert absolute paths to relative paths for display\n const contractPath = relative(process.cwd(), outputJsonPath);\n const typesPath = relative(process.cwd(), outputDtsPath);\n const header = formatStyledHeader({\n command: 'contract emit',\n description: 'Write your contract to JSON and sign it',\n url: 'https://pris.ly/contract-emit',\n details: [\n { label: 'config', value: configPath },\n { label: 'contract', value: contractPath },\n { label: 'types', value: typesPath },\n ],\n flags,\n });\n console.log(header);\n }\n\n // Create family instance (assembles operation registry, type imports, extension IDs)\n // Note: emit command doesn't need driver, but ControlFamilyDescriptor.create() requires it\n // We'll need to provide a minimal driver descriptor or make driver optional for emit\n // For now, we'll require driver to be present in config even for emit\n if (!config.driver) {\n throw errorContractConfigMissing({\n why: 'Config.driver is required. Even though emit does not use the driver, it is required by ControlFamilyDescriptor.create()',\n });\n }\n const familyInstance = config.family.create({\n target: config.target,\n adapter: config.adapter,\n driver: config.driver,\n extensions: config.extensions ?? [],\n });\n\n // Resolve contract source from config (user's config handles loading)\n let contractRaw: unknown;\n if (typeof contractConfig.source === 'function') {\n contractRaw = await contractConfig.source();\n } else {\n contractRaw = contractConfig.source;\n }\n\n // Call emitContract on family instance (handles stripping mappings and validation internally)\n const emitResult = await withSpinner(\n () => familyInstance.emitContract({ contractIR: contractRaw }),\n {\n message: 'Emitting contract...',\n flags,\n },\n );\n\n // Create directories if needed\n mkdirSync(dirname(outputJsonPath), { recursive: true });\n mkdirSync(dirname(outputDtsPath), { recursive: true });\n\n // Write the results to files\n writeFileSync(outputJsonPath, emitResult.contractJson, 'utf-8');\n writeFileSync(outputDtsPath, emitResult.contractDts, 'utf-8');\n\n // Add blank line after all async operations if spinners were shown\n if (!flags.quiet && flags.json !== 'object' && process.stdout.isTTY) {\n console.log('');\n }\n\n // Return result with file paths for output formatting\n return {\n coreHash: emitResult.coreHash,\n profileHash: emitResult.profileHash,\n outDir: dirname(outputJsonPath),\n files: {\n json: outputJsonPath,\n dts: outputDtsPath,\n },\n timings: {\n total: 0, // Timing is handled by emitContract internally if needed\n },\n };\n });\n\n // Handle result - formats output and returns exit code\n const exitCode = handleResult(result, flags, (emitResult) => {\n // Output based on flags\n if (flags.json === 'object') {\n // JSON output to stdout\n console.log(formatEmitJson(emitResult));\n } else {\n // Human-readable output to stdout\n const output = formatEmitOutput(emitResult, flags);\n if (output) {\n console.log(output);\n }\n // Output success message\n if (!flags.quiet) {\n console.log(formatSuccessMessage(flags));\n }\n }\n });\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,qBAAqB;AACzC,SAAS,SAAS,UAAU,eAAe;AAC3C,SAAS,kCAAkC;AAC3C,SAAS,eAAe;AA6BjB,SAAS,4BAAqC;AACnD,QAAM,UAAU,IAAI,QAAQ,MAAM;AAClC;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EAGF;AACA,UACG,cAAc;AAAA,IACb,YAAY,CAAC,QAAQ;AACnB,YAAM,QAAQ,iBAAiB,CAAC,CAAC;AACjC,aAAO,kBAAkB,EAAE,SAAS,KAAK,MAAM,CAAC;AAAA,IAClD;AAAA,EACF,CAAC,EACA,OAAO,mBAAmB,+BAA+B,EACzD,OAAO,mBAAmB,qCAAqC,KAAK,EACpE,OAAO,eAAe,yBAAyB,EAC/C,OAAO,iBAAiB,qCAAqC,EAC7D,OAAO,gBAAgB,4CAA4C,EACnE,OAAO,gBAAgB,0BAA0B,EACjD,OAAO,WAAW,oBAAoB,EACtC,OAAO,cAAc,sBAAsB,EAC3C,OAAO,OAAO,YAAiC;AAC9C,UAAM,QAAQ,iBAAiB,OAAO;A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@ function createDbInitCommand() {
|
|
|
1262
1262
|
driver: driverDescriptor,
|
|
1263
1263
|
extensions: config.extensions ?? []
|
|
1264
1264
|
});
|
|
1265
|
-
const
|
|
1266
|
-
const contractIR = typedFamilyInstance.validateContractIR(contractJson);
|
|
1265
|
+
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1267
1266
|
const planner = migrations.createPlanner(familyInstance);
|
|
1268
1267
|
const runner = migrations.createRunner(familyInstance);
|
|
1269
|
-
const schemaIR = await withSpinner(() =>
|
|
1268
|
+
const schemaIR = await withSpinner(() => familyInstance.introspect({ driver }), {
|
|
1270
1269
|
message: "Introspecting database schema...",
|
|
1271
1270
|
flags
|
|
1272
1271
|
});
|
|
@@ -1458,14 +1457,13 @@ function createDbIntrospectCommand() {
|
|
|
1458
1457
|
driver: driverDescriptor,
|
|
1459
1458
|
extensions: config.extensions ?? []
|
|
1460
1459
|
});
|
|
1461
|
-
const typedFamilyInstance = familyInstance;
|
|
1462
1460
|
if (contractIR) {
|
|
1463
|
-
contractIR =
|
|
1461
|
+
contractIR = familyInstance.validateContractIR(contractIR);
|
|
1464
1462
|
}
|
|
1465
1463
|
let schemaIR;
|
|
1466
1464
|
try {
|
|
1467
1465
|
schemaIR = await withSpinner(
|
|
1468
|
-
() =>
|
|
1466
|
+
() => familyInstance.introspect({
|
|
1469
1467
|
driver,
|
|
1470
1468
|
contractIR
|
|
1471
1469
|
}),
|
|
@@ -1480,9 +1478,9 @@ function createDbIntrospectCommand() {
|
|
|
1480
1478
|
});
|
|
1481
1479
|
}
|
|
1482
1480
|
let schemaView;
|
|
1483
|
-
if (
|
|
1481
|
+
if (familyInstance.toSchemaView) {
|
|
1484
1482
|
try {
|
|
1485
|
-
schemaView =
|
|
1483
|
+
schemaView = familyInstance.toSchemaView(schemaIR);
|
|
1486
1484
|
} catch (error) {
|
|
1487
1485
|
if (flags.verbose) {
|
|
1488
1486
|
console.error(
|
|
@@ -1619,12 +1617,11 @@ function createDbSchemaVerifyCommand() {
|
|
|
1619
1617
|
driver: driverDescriptor,
|
|
1620
1618
|
extensions: config.extensions ?? []
|
|
1621
1619
|
});
|
|
1622
|
-
const
|
|
1623
|
-
const contractIR = typedFamilyInstance.validateContractIR(contractJson);
|
|
1620
|
+
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1624
1621
|
let schemaVerifyResult;
|
|
1625
1622
|
try {
|
|
1626
1623
|
schemaVerifyResult = await withSpinner(
|
|
1627
|
-
() =>
|
|
1624
|
+
() => familyInstance.schemaVerify({
|
|
1628
1625
|
driver,
|
|
1629
1626
|
contractIR,
|
|
1630
1627
|
strict: options.strict ?? false,
|
|
@@ -1745,13 +1742,12 @@ function createDbSignCommand() {
|
|
|
1745
1742
|
driver: driverDescriptor,
|
|
1746
1743
|
extensions: config.extensions ?? []
|
|
1747
1744
|
});
|
|
1748
|
-
const
|
|
1749
|
-
const contractIR = typedFamilyInstance.validateContractIR(contractJson);
|
|
1745
|
+
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1750
1746
|
let schemaVerifyResult;
|
|
1751
1747
|
try {
|
|
1752
1748
|
schemaVerifyResult = await withSpinner(
|
|
1753
1749
|
async () => {
|
|
1754
|
-
return await
|
|
1750
|
+
return await familyInstance.schemaVerify({
|
|
1755
1751
|
driver,
|
|
1756
1752
|
contractIR,
|
|
1757
1753
|
strict: false,
|
|
@@ -1776,7 +1772,7 @@ function createDbSignCommand() {
|
|
|
1776
1772
|
try {
|
|
1777
1773
|
signResult = await withSpinner(
|
|
1778
1774
|
async () => {
|
|
1779
|
-
return await
|
|
1775
|
+
return await familyInstance.sign({
|
|
1780
1776
|
driver,
|
|
1781
1777
|
contractIR,
|
|
1782
1778
|
contractPath: contractPathAbsolute,
|
|
@@ -1917,12 +1913,11 @@ function createDbVerifyCommand() {
|
|
|
1917
1913
|
driver: driverDescriptor,
|
|
1918
1914
|
extensions: config.extensions ?? []
|
|
1919
1915
|
});
|
|
1920
|
-
const
|
|
1921
|
-
const contractIR = typedFamilyInstance.validateContractIR(contractJson);
|
|
1916
|
+
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1922
1917
|
let verifyResult;
|
|
1923
1918
|
try {
|
|
1924
1919
|
verifyResult = await withSpinner(
|
|
1925
|
-
() =>
|
|
1920
|
+
() => familyInstance.verify({
|
|
1926
1921
|
driver,
|
|
1927
1922
|
contractIR,
|
|
1928
1923
|
expectedTargetId: config.target.targetId,
|