@prisma-next/cli 0.5.0-dev.7 → 0.5.0-dev.70
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 +56 -21
- package/dist/cli-errors-D3_sMh2K.mjs +33 -0
- package/dist/cli-errors-D3_sMh2K.mjs.map +1 -0
- package/dist/cli-errors-QH8kf-C2.d.mts +3 -0
- package/dist/cli.mjs +16 -78
- package/dist/cli.mjs.map +1 -1
- package/dist/client-0ZX24FXF.mjs +1398 -0
- package/dist/client-0ZX24FXF.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +2 -4
- package/dist/commands/contract-infer.d.mts.map +1 -1
- package/dist/commands/contract-infer.mjs +2 -4
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +14 -13
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.d.mts.map +1 -1
- package/dist/commands/db-schema.mjs +5 -7
- package/dist/commands/db-schema.mjs.map +1 -1
- package/dist/commands/db-sign.d.mts.map +1 -1
- package/dist/commands/db-sign.mjs +8 -9
- package/dist/commands/db-sign.mjs.map +1 -1
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +13 -13
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.d.mts.map +1 -1
- package/dist/commands/db-verify.mjs +1 -321
- package/dist/commands/migration-apply.d.mts +5 -2
- package/dist/commands/migration-apply.d.mts.map +1 -1
- package/dist/commands/migration-apply.mjs +64 -66
- package/dist/commands/migration-apply.mjs.map +1 -1
- package/dist/commands/migration-new.d.mts +0 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +33 -40
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +14 -5
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -347
- package/dist/commands/migration-ref.d.mts +1 -1
- package/dist/commands/migration-ref.d.mts.map +1 -1
- package/dist/commands/migration-ref.mjs +7 -12
- package/dist/commands/migration-ref.mjs.map +1 -1
- package/dist/commands/migration-show.d.mts +13 -7
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +34 -36
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +23 -5
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +2 -4
- package/dist/{config-loader-C25b63rJ.mjs → config-loader-B6sJjXTv.mjs} +3 -5
- package/dist/config-loader-B6sJjXTv.mjs.map +1 -0
- package/dist/config-loader.d.mts +0 -1
- package/dist/config-loader.d.mts.map +1 -1
- package/dist/config-loader.mjs +2 -3
- package/dist/contract-emit-B3ChISB_.mjs +338 -0
- package/dist/contract-emit-B3ChISB_.mjs.map +1 -0
- package/dist/contract-emit-DkMqO7f2.mjs +148 -0
- package/dist/contract-emit-DkMqO7f2.mjs.map +1 -0
- package/dist/{contract-enrichment-CAOELa-H.mjs → contract-enrichment-CF6ogEJ_.mjs} +4 -6
- package/dist/contract-enrichment-CF6ogEJ_.mjs.map +1 -0
- package/dist/{contract-infer-D9cC3rJm.mjs → contract-infer-BDKAE0B0.mjs} +12 -22
- package/dist/contract-infer-BDKAE0B0.mjs.map +1 -0
- package/dist/db-verify-B4TdDKOI.mjs +403 -0
- package/dist/db-verify-B4TdDKOI.mjs.map +1 -0
- package/dist/exports/config-types.mjs +1 -2
- package/dist/exports/control-api.d.mts +287 -29
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +4 -6
- package/dist/exports/index.d.mts.map +1 -1
- package/dist/exports/index.mjs +28 -30
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.d.mts +2 -4
- package/dist/exports/init-output.d.mts.map +1 -1
- package/dist/exports/init-output.mjs +2 -3
- package/dist/{framework-components-Cr--XBKy.mjs → framework-components-gwAHl7ml.mjs} +3 -4
- package/dist/{framework-components-Cr--XBKy.mjs.map → framework-components-gwAHl7ml.mjs.map} +1 -1
- package/dist/{init-C5220SY9.mjs → init-Deo7U8_U.mjs} +26 -35
- package/dist/init-Deo7U8_U.mjs.map +1 -0
- package/dist/{inspect-live-schema-yrHAvG71.mjs → inspect-live-schema-BAgQMYpD.mjs} +10 -11
- package/dist/inspect-live-schema-BAgQMYpD.mjs.map +1 -0
- package/dist/migration-cli.d.mts +41 -12
- package/dist/migration-cli.d.mts.map +1 -1
- package/dist/migration-cli.mjs +309 -86
- package/dist/migration-cli.mjs.map +1 -1
- package/dist/{migration-command-scaffold-B3B09et6.mjs → migration-command-scaffold-B8J702Uh.mjs} +8 -9
- package/dist/migration-command-scaffold-B8J702Uh.mjs.map +1 -0
- package/dist/migration-plan-BcKNnTM7.mjs +530 -0
- package/dist/migration-plan-BcKNnTM7.mjs.map +1 -0
- package/dist/{migration-status-DUMiH8_G.mjs → migration-status-CjwB2of-.mjs} +117 -64
- package/dist/migration-status-CjwB2of-.mjs.map +1 -0
- package/dist/{migrations-Bo5WtTla.mjs → migrations-CIK94AJf.mjs} +43 -23
- package/dist/migrations-CIK94AJf.mjs.map +1 -0
- package/dist/{output-BpcQrnnq.mjs → output-DnjfCC_u.mjs} +9 -3
- package/dist/output-DnjfCC_u.mjs.map +1 -0
- package/dist/{progress-adapter-DvQWB1nK.mjs → progress-adapter-xASh41wr.mjs} +2 -2
- package/dist/{progress-adapter-DvQWB1nK.mjs.map → progress-adapter-xASh41wr.mjs.map} +1 -1
- package/dist/{result-handler-Ba3zWQsI.mjs → result-handler-DWb1rFS-.mjs} +52 -27
- package/dist/result-handler-DWb1rFS-.mjs.map +1 -0
- package/dist/{terminal-ui-C3ZLwQxK.mjs → terminal-ui-zaRDhJnP.mjs} +2 -6
- package/dist/{terminal-ui-C3ZLwQxK.mjs.map → terminal-ui-zaRDhJnP.mjs.map} +1 -1
- package/dist/{verify-Bkycc-Tf.mjs → verify-BEIa9638.mjs} +3 -4
- package/dist/verify-BEIa9638.mjs.map +1 -0
- package/package.json +28 -26
- package/src/cli.ts +32 -6
- package/src/commands/contract-emit.ts +67 -163
- package/src/commands/contract-infer.ts +7 -20
- package/src/commands/db-init.ts +14 -3
- package/src/commands/db-update.ts +8 -4
- package/src/commands/db-verify.ts +47 -15
- package/src/commands/init/index.ts +1 -1
- package/src/commands/init/init.ts +2 -2
- package/src/commands/init/templates/code-templates.ts +12 -4
- package/src/commands/inspect-live-schema.ts +10 -5
- package/src/commands/migration-apply.ts +92 -71
- package/src/commands/migration-new.ts +42 -45
- package/src/commands/migration-plan.ts +147 -64
- package/src/commands/migration-ref.ts +8 -7
- package/src/commands/migration-show.ts +60 -41
- package/src/commands/migration-status.ts +196 -60
- package/src/config-path-validation.ts +0 -1
- package/src/control-api/client.ts +69 -1
- package/src/control-api/contract-enrichment.ts +6 -4
- package/src/control-api/operations/contract-emit.ts +198 -115
- package/src/control-api/operations/db-apply-aggregate.ts +446 -0
- package/src/control-api/operations/db-init.ts +51 -253
- package/src/control-api/operations/db-update.ts +66 -183
- package/src/control-api/operations/db-verify.ts +342 -0
- package/src/control-api/operations/migration-apply.ts +37 -9
- package/src/control-api/types.ts +125 -7
- package/src/exports/control-api.ts +15 -3
- package/src/load-ts-contract.ts +28 -26
- package/src/migration-cli.ts +445 -122
- package/src/utils/cli-errors.ts +49 -2
- package/src/utils/combine-schema-results.ts +84 -0
- package/src/utils/command-helpers.ts +69 -25
- package/src/utils/contract-space-aggregate-loader.ts +236 -0
- package/src/utils/contract-space-extension-migrations-pass.ts +120 -0
- package/src/utils/contract-space-migrate-pass.ts +156 -0
- package/src/utils/emit-queue.ts +26 -0
- package/src/utils/formatters/graph-migration-mapper.ts +7 -3
- package/src/utils/formatters/migrations.ts +62 -26
- package/src/utils/publish-contract-artifact-pair.ts +134 -0
- package/dist/cli-errors-BFYgBH3L.d.mts +0 -4
- package/dist/cli-errors-Cd79vmTH.mjs +0 -5
- package/dist/client-CrsnY58k.mjs +0 -997
- package/dist/client-CrsnY58k.mjs.map +0 -1
- package/dist/commands/db-verify.mjs.map +0 -1
- package/dist/commands/migration-plan.mjs.map +0 -1
- package/dist/config-loader-C25b63rJ.mjs.map +0 -1
- package/dist/contract-emit--feXyNd7.mjs +0 -4
- package/dist/contract-emit-NJ01hiiv.mjs +0 -195
- package/dist/contract-emit-NJ01hiiv.mjs.map +0 -1
- package/dist/contract-emit-V5SSitUT.mjs +0 -122
- package/dist/contract-emit-V5SSitUT.mjs.map +0 -1
- package/dist/contract-enrichment-CAOELa-H.mjs.map +0 -1
- package/dist/contract-infer-D9cC3rJm.mjs.map +0 -1
- package/dist/extract-operation-statements-DsFfxXVZ.mjs +0 -13
- package/dist/extract-operation-statements-DsFfxXVZ.mjs.map +0 -1
- package/dist/extract-sql-ddl-D9UbZDyz.mjs +0 -26
- package/dist/extract-sql-ddl-D9UbZDyz.mjs.map +0 -1
- package/dist/init-C5220SY9.mjs.map +0 -1
- package/dist/inspect-live-schema-yrHAvG71.mjs.map +0 -1
- package/dist/migration-command-scaffold-B3B09et6.mjs.map +0 -1
- package/dist/migration-status-DUMiH8_G.mjs.map +0 -1
- package/dist/migrations-Bo5WtTla.mjs.map +0 -1
- package/dist/output-BpcQrnnq.mjs.map +0 -1
- package/dist/result-handler-Ba3zWQsI.mjs.map +0 -1
- package/dist/validate-contract-deps-B_Cs29TL.mjs +0 -37
- package/dist/validate-contract-deps-B_Cs29TL.mjs.map +0 -1
- package/dist/verify-Bkycc-Tf.mjs.map +0 -1
- package/src/control-api/operations/extract-operation-statements.ts +0 -14
- package/src/control-api/operations/extract-sql-ddl.ts +0 -47
|
@@ -20,10 +20,20 @@ export { createControlClient } from '../control-api/client';
|
|
|
20
20
|
|
|
21
21
|
// Contract enrichment (merges framework-derived capabilities and extension pack metadata)
|
|
22
22
|
export { enrichContract } from '../control-api/contract-enrichment';
|
|
23
|
-
|
|
24
|
-
// Standalone operations (for tooling that doesn't need full client)
|
|
25
23
|
export { executeContractEmit } from '../control-api/operations/contract-emit';
|
|
26
|
-
|
|
24
|
+
// Standalone operations (for tooling that doesn't need full client).
|
|
25
|
+
// These drive the aggregate-pipeline `db init` / `db update` / `db verify`
|
|
26
|
+
// flow against a loaded contract-space aggregate.
|
|
27
|
+
export { type ExecuteDbInitOptions, executeDbInit } from '../control-api/operations/db-init';
|
|
28
|
+
export {
|
|
29
|
+
type ExecuteDbUpdateOptions,
|
|
30
|
+
executeDbUpdate,
|
|
31
|
+
} from '../control-api/operations/db-update';
|
|
32
|
+
export {
|
|
33
|
+
type ExecuteDbVerifyOptions,
|
|
34
|
+
type ExecuteDbVerifyResult,
|
|
35
|
+
executeDbVerify,
|
|
36
|
+
} from '../control-api/operations/db-verify';
|
|
27
37
|
// CLI-specific types
|
|
28
38
|
export type {
|
|
29
39
|
ContractEmitOptions,
|
|
@@ -54,3 +64,5 @@ export type {
|
|
|
54
64
|
SignOptions,
|
|
55
65
|
VerifyOptions,
|
|
56
66
|
} from '../control-api/types';
|
|
67
|
+
// Lifecycle helpers for hosts that publish to many output paths
|
|
68
|
+
export { disposeEmitQueue } from '../utils/emit-queue';
|
package/src/load-ts-contract.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
4
4
|
import type { Contract } from '@prisma-next/contract/types';
|
|
5
5
|
import type { Plugin } from 'esbuild';
|
|
6
6
|
import { build } from 'esbuild';
|
|
7
|
-
import { join } from 'pathe';
|
|
7
|
+
import { join, resolve as resolvePath } from 'pathe';
|
|
8
8
|
|
|
9
9
|
export interface LoadTsContractOptions {
|
|
10
10
|
readonly allowlist?: ReadonlyArray<string>;
|
|
@@ -78,7 +78,21 @@ function validatePurity(value: unknown): void {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
function createImportAllowlistPlugin(
|
|
81
|
+
function createImportAllowlistPlugin(
|
|
82
|
+
allowlist: ReadonlyArray<string>,
|
|
83
|
+
entryPath: string,
|
|
84
|
+
collected: Set<string>,
|
|
85
|
+
): Plugin {
|
|
86
|
+
// Match against several path forms that esbuild may use as the importer:
|
|
87
|
+
// the absolute resolved entry, the value the caller passed (which may be
|
|
88
|
+
// relative), and the conventional `<stdin>` placeholder. This is more
|
|
89
|
+
// forgiving than `===` against a single form, which broke when esbuild
|
|
90
|
+
// resolved the entry to an absolute path while the caller passed a
|
|
91
|
+
// relative one (or vice versa).
|
|
92
|
+
const entryAbs = resolvePath(entryPath);
|
|
93
|
+
function isFromEntry(importer: string): boolean {
|
|
94
|
+
return importer === entryAbs || importer === entryPath || importer === '<stdin>';
|
|
95
|
+
}
|
|
82
96
|
return {
|
|
83
97
|
name: 'import-allowlist',
|
|
84
98
|
setup(build) {
|
|
@@ -89,8 +103,8 @@ function createImportAllowlistPlugin(allowlist: ReadonlyArray<string>, entryPath
|
|
|
89
103
|
if (args.path.startsWith('.') || args.path.startsWith('/')) {
|
|
90
104
|
return undefined;
|
|
91
105
|
}
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
if (isFromEntry(args.importer) && !isAllowedImport(args.path, allowlist)) {
|
|
107
|
+
collected.add(args.path);
|
|
94
108
|
return {
|
|
95
109
|
path: args.path,
|
|
96
110
|
external: true,
|
|
@@ -132,6 +146,13 @@ export async function loadContractFromTs(
|
|
|
132
146
|
`prisma-next-contract-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`,
|
|
133
147
|
);
|
|
134
148
|
|
|
149
|
+
// Disallowed imports are collected by the allowlist resolver plugin itself,
|
|
150
|
+
// which has the `importer` context to distinguish entry-direct imports from
|
|
151
|
+
// transitive imports made inside allowlisted (`@prisma-next/*`) dependencies.
|
|
152
|
+
// The metafile is intentionally not re-walked: it would surface internal
|
|
153
|
+
// `node:*` imports inside framework code as false positives.
|
|
154
|
+
const disallowedFromEntry = new Set<string>();
|
|
155
|
+
|
|
135
156
|
try {
|
|
136
157
|
const result = await build({
|
|
137
158
|
entryPoints: [entryPath],
|
|
@@ -142,7 +163,7 @@ export async function loadContractFromTs(
|
|
|
142
163
|
outfile: tempFile,
|
|
143
164
|
write: false,
|
|
144
165
|
metafile: true,
|
|
145
|
-
plugins: [createImportAllowlistPlugin(allowlist, entryPath)],
|
|
166
|
+
plugins: [createImportAllowlistPlugin(allowlist, entryPath, disallowedFromEntry)],
|
|
146
167
|
logLevel: 'error',
|
|
147
168
|
});
|
|
148
169
|
|
|
@@ -155,28 +176,9 @@ export async function loadContractFromTs(
|
|
|
155
176
|
throw new Error('No output files generated from bundling');
|
|
156
177
|
}
|
|
157
178
|
|
|
158
|
-
|
|
159
|
-
if (result.metafile) {
|
|
160
|
-
const inputs = result.metafile.inputs;
|
|
161
|
-
for (const [, inputData] of Object.entries(inputs)) {
|
|
162
|
-
const imports =
|
|
163
|
-
(inputData as { imports?: Array<{ path: string; external?: boolean }> }).imports || [];
|
|
164
|
-
for (const imp of imports) {
|
|
165
|
-
if (
|
|
166
|
-
imp.external &&
|
|
167
|
-
!imp.path.startsWith('.') &&
|
|
168
|
-
!imp.path.startsWith('/') &&
|
|
169
|
-
!isAllowedImport(imp.path, allowlist)
|
|
170
|
-
) {
|
|
171
|
-
disallowedImports.push(imp.path);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (disallowedImports.length > 0) {
|
|
179
|
+
if (disallowedFromEntry.size > 0) {
|
|
178
180
|
throw new Error(
|
|
179
|
-
`Disallowed imports detected. Only imports matching the allowlist are permitted:\n Allowlist: ${allowlist.join(', ')}\n Disallowed imports: ${
|
|
181
|
+
`Disallowed imports detected. Only imports matching the allowlist are permitted:\n Allowlist: ${allowlist.join(', ')}\n Disallowed imports: ${[...disallowedFromEntry].join(', ')}`,
|
|
180
182
|
);
|
|
181
183
|
}
|
|
182
184
|
|