@prisma-next/cli 0.12.0 → 0.13.0-dev.1
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 +2 -2
- package/dist/cli.mjs +180 -163
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-KgJorIvG.mjs → client-CJzuo5wX.mjs} +222 -107
- package/dist/client-CJzuo5wX.mjs.map +1 -0
- package/dist/{command-helpers-Bbw1GbwL.mjs → command-helpers-DGMvGBeX.mjs} +318 -25
- package/dist/command-helpers-DGMvGBeX.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.d.mts.map +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +4 -5
- 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 +3 -3
- 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 +6 -6
- 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 +10 -7
- 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 -1
- package/dist/commands/migrate.d.mts +37 -3
- package/dist/commands/migrate.d.mts.map +1 -1
- package/dist/commands/migrate.mjs +298 -12
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.d.mts +55 -13
- package/dist/commands/migration-check.d.mts.map +1 -1
- package/dist/commands/migration-check.mjs +3 -2
- package/dist/commands/migration-graph.d.mts +17 -8
- package/dist/commands/migration-graph.d.mts.map +1 -1
- package/dist/commands/migration-graph.mjs +185 -2
- package/dist/commands/migration-graph.mjs.map +1 -0
- package/dist/commands/migration-list.d.mts +26 -27
- package/dist/commands/migration-list.d.mts.map +1 -1
- package/dist/commands/migration-list.mjs +2 -190
- package/dist/commands/migration-log.d.mts +9 -19
- package/dist/commands/migration-log.d.mts.map +1 -1
- package/dist/commands/migration-log.mjs +1 -137
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +6 -5
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +1 -1
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.d.mts +17 -21
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +24 -36
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +42 -144
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +3 -759
- package/dist/commands/ref.d.mts +1 -1
- package/dist/commands/ref.d.mts.map +1 -1
- package/dist/commands/ref.mjs +4 -4
- package/dist/commands/ref.mjs.map +1 -1
- package/dist/commands/telemetry/index.d.mts +7 -0
- package/dist/commands/telemetry/index.d.mts.map +1 -0
- package/dist/commands/telemetry/index.mjs +2 -0
- package/dist/{config-loader-B6sJjXTv.mjs → config-loader-p9JMrekQ.mjs} +1 -1
- package/dist/{config-loader-B6sJjXTv.mjs.map → config-loader-p9JMrekQ.mjs.map} +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/{contract-at-errors-BxP-TOMl.mjs → contract-at-errors-CFXsstzm.mjs} +2 -2
- package/dist/{contract-at-errors-BxP-TOMl.mjs.map → contract-at-errors-CFXsstzm.mjs.map} +1 -1
- package/dist/{contract-emit-DxcGl4Uq.mjs → contract-emit-B_qriF8B.mjs} +5 -5
- package/dist/{contract-emit-DxcGl4Uq.mjs.map → contract-emit-B_qriF8B.mjs.map} +1 -1
- package/dist/{contract-emit-D-4jrNve.mjs → contract-emit-C8HmtboH.mjs} +12 -7
- package/dist/contract-emit-C8HmtboH.mjs.map +1 -0
- package/dist/{contract-enrichment-a0V5Y_mL.mjs → contract-enrichment-gn9sWbPw.mjs} +1 -1
- package/dist/{contract-enrichment-a0V5Y_mL.mjs.map → contract-enrichment-gn9sWbPw.mjs.map} +1 -1
- package/dist/{contract-infer-D8uEbJuu.mjs → contract-infer-BYT_ra_U.mjs} +5 -5
- package/dist/contract-infer-BYT_ra_U.mjs.map +1 -0
- package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs → contract-space-aggregate-loader-ClI1KN6d.mjs} +5 -5
- package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs.map → contract-space-aggregate-loader-ClI1KN6d.mjs.map} +1 -1
- package/dist/{db-verify-v_vUKXTU.mjs → db-verify-C24FKhb7.mjs} +6 -6
- package/dist/{db-verify-v_vUKXTU.mjs.map → db-verify-C24FKhb7.mjs.map} +1 -1
- package/dist/exports/control-api.d.mts +5 -3
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +3 -3
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.d.mts +1 -3
- package/dist/exports/init-output.d.mts.map +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/{extension-pack-inputs-IDvjRCi3.mjs → extension-pack-inputs-1ySHqxKG.mjs} +1 -1
- package/dist/{extension-pack-inputs-IDvjRCi3.mjs.map → extension-pack-inputs-1ySHqxKG.mjs.map} +1 -1
- package/dist/{framework-components-fYXjz_in.mjs → framework-components-YVQHhPH7.mjs} +2 -2
- package/dist/{framework-components-fYXjz_in.mjs.map → framework-components-YVQHhPH7.mjs.map} +1 -1
- package/dist/{global-flags-DEHjV8_s.d.mts → global-flags-BpoOYtNZ.d.mts} +1 -1
- package/dist/{global-flags-DEHjV8_s.d.mts.map → global-flags-BpoOYtNZ.d.mts.map} +1 -1
- package/dist/{init-Cv9UzWL5.mjs → init-0HwB-Vh8.mjs} +5 -58
- package/dist/init-0HwB-Vh8.mjs.map +1 -0
- package/dist/{inspect-live-schema-C6ohV_oQ.mjs → inspect-live-schema-DF6IwcDl.mjs} +7 -5
- package/dist/inspect-live-schema-DF6IwcDl.mjs.map +1 -0
- package/dist/migration-check-soB5uZEQ.mjs +573 -0
- package/dist/migration-check-soB5uZEQ.mjs.map +1 -0
- package/dist/migration-cli.mjs +1 -1
- package/dist/migration-cli.mjs.map +1 -1
- package/dist/{migration-command-scaffold-CjvwO6at.mjs → migration-command-scaffold-DA-Lhx6o.mjs} +5 -5
- package/dist/{migration-command-scaffold-CjvwO6at.mjs.map → migration-command-scaffold-DA-Lhx6o.mjs.map} +1 -1
- package/dist/migration-graph-command-render-CEez7YUK.mjs +1960 -0
- package/dist/migration-graph-command-render-CEez7YUK.mjs.map +1 -0
- package/dist/migration-list-DlJJ_38Z.mjs +230 -0
- package/dist/migration-list-DlJJ_38Z.mjs.map +1 -0
- package/dist/migration-log-CG0qQAFm.mjs +222 -0
- package/dist/migration-log-CG0qQAFm.mjs.map +1 -0
- package/dist/migration-path-target-Ce6OZImp.mjs +38 -0
- package/dist/migration-path-target-Ce6OZImp.mjs.map +1 -0
- package/dist/{migration-plan-9DJ7q7_z.mjs → migration-plan-z5Ing-TD.mjs} +9 -8
- package/dist/migration-plan-z5Ing-TD.mjs.map +1 -0
- package/dist/migration-status-CgWSoI_g.mjs +446 -0
- package/dist/migration-status-CgWSoI_g.mjs.map +1 -0
- package/dist/{output-B60Gw5fu.mjs → output-mEQ74_nd.mjs} +1 -1
- package/dist/{output-B60Gw5fu.mjs.map → output-mEQ74_nd.mjs.map} +1 -1
- package/dist/{progress-adapter-C644QK8l.mjs → progress-adapter-CjAeTxY_.mjs} +1 -1
- package/dist/{progress-adapter-C644QK8l.mjs.map → progress-adapter-CjAeTxY_.mjs.map} +1 -1
- package/dist/{ref-advancement-DUZqsue6.mjs → ref-advancement-BkXlikCA.mjs} +1 -1
- package/dist/{ref-advancement-DUZqsue6.mjs.map → ref-advancement-BkXlikCA.mjs.map} +1 -1
- package/dist/schemas-CeGMYFYX.d.mts +191 -0
- package/dist/schemas-CeGMYFYX.d.mts.map +1 -0
- package/dist/schemas-KhXMzNA_.mjs +112 -0
- package/dist/schemas-KhXMzNA_.mjs.map +1 -0
- package/dist/telemetry-BIM4beEO.mjs +122 -0
- package/dist/telemetry-BIM4beEO.mjs.map +1 -0
- package/dist/{terminal-ui-5Y6mrg93.d.mts → terminal-ui-DGRNFWna.d.mts} +1 -1
- package/dist/terminal-ui-DGRNFWna.d.mts.map +1 -0
- package/dist/{types-Dt_SfqFm.d.mts → types-C_tYiJYx.d.mts} +53 -31
- package/dist/types-C_tYiJYx.d.mts.map +1 -0
- package/dist/{verify-DCA9Sldu.mjs → verify-DcOYZ1tH.mjs} +2 -2
- package/dist/{verify-DCA9Sldu.mjs.map → verify-DcOYZ1tH.mjs.map} +1 -1
- package/package.json +26 -22
- package/src/cli.ts +5 -0
- package/src/commands/contract-infer.ts +2 -2
- package/src/commands/db-update.ts +7 -1
- package/src/commands/init/index.ts +6 -35
- package/src/commands/init/init.ts +1 -14
- package/src/commands/init/inputs.ts +0 -75
- package/src/commands/inspect-live-schema.ts +10 -0
- package/src/commands/json/schemas.ts +195 -0
- package/src/commands/migrate.ts +527 -8
- package/src/commands/migration-check.ts +469 -134
- package/src/commands/migration-graph.ts +164 -91
- package/src/commands/migration-list.ts +72 -39
- package/src/commands/migration-log.ts +52 -102
- package/src/commands/migration-new.ts +2 -1
- package/src/commands/migration-plan.ts +2 -1
- package/src/commands/migration-show.ts +31 -66
- package/src/commands/migration-status-overlay.ts +61 -0
- package/src/commands/migration-status.ts +458 -1066
- package/src/commands/telemetry/index.ts +107 -0
- package/src/commands/telemetry/status.ts +67 -0
- package/src/control-api/client.ts +70 -9
- package/src/control-api/operations/contract-emit.ts +22 -2
- package/src/control-api/operations/db-init.ts +6 -3
- package/src/control-api/operations/{db-apply.ts → db-run.ts} +55 -14
- package/src/control-api/operations/db-update.ts +7 -4
- package/src/control-api/operations/db-verify.ts +15 -5
- package/src/control-api/operations/{migration-apply.ts → migrate.ts} +181 -80
- package/src/control-api/operations/{apply.ts → run-migration.ts} +33 -27
- package/src/control-api/types.ts +56 -29
- package/src/utils/cli-errors.ts +70 -2
- package/src/utils/formatters/errors.ts +11 -0
- package/src/utils/formatters/migration-graph-command-render.ts +239 -0
- package/src/utils/formatters/migration-graph-grid-layout.ts +1134 -0
- package/src/utils/formatters/migration-graph-labels.ts +408 -0
- package/src/utils/formatters/migration-graph-model.ts +103 -0
- package/src/utils/formatters/migration-graph-occlusion-render.ts +258 -0
- package/src/utils/formatters/migration-graph-rows.ts +128 -15
- package/src/utils/formatters/migration-graph-space-render.ts +188 -0
- package/src/utils/formatters/migration-list-data-column.ts +4 -91
- package/src/utils/formatters/migration-list-graph-topology.ts +72 -94
- package/src/utils/formatters/migration-list-render.ts +135 -71
- package/src/utils/formatters/migration-list-styler.ts +46 -5
- package/src/utils/formatters/migration-list-types.ts +5 -21
- package/src/utils/formatters/migration-log-table.ts +205 -0
- package/src/utils/formatters/migrations.ts +33 -11
- package/src/utils/global-flags.ts +35 -0
- package/src/utils/integrity-violation-to-check-failure.ts +28 -19
- package/src/utils/legend.ts +38 -0
- package/src/utils/migration-path-target.ts +60 -0
- package/src/utils/telemetry.ts +68 -32
- package/dist/client-KgJorIvG.mjs.map +0 -1
- package/dist/command-helpers-Bbw1GbwL.mjs.map +0 -1
- package/dist/commands/migration-list.mjs.map +0 -1
- package/dist/commands/migration-log.mjs.map +0 -1
- package/dist/commands/migration-status.mjs.map +0 -1
- package/dist/contract-emit-D-4jrNve.mjs.map +0 -1
- package/dist/contract-infer-D8uEbJuu.mjs.map +0 -1
- package/dist/graph-render-rFAqZujX.mjs +0 -1081
- package/dist/graph-render-rFAqZujX.mjs.map +0 -1
- package/dist/init-Cv9UzWL5.mjs.map +0 -1
- package/dist/inspect-live-schema-C6ohV_oQ.mjs.map +0 -1
- package/dist/migration-check-BiBJoYYW.mjs +0 -341
- package/dist/migration-check-BiBJoYYW.mjs.map +0 -1
- package/dist/migration-graph-D7DVUElV.mjs +0 -1232
- package/dist/migration-graph-D7DVUElV.mjs.map +0 -1
- package/dist/migration-list-styler-BRwF4-gy.mjs +0 -399
- package/dist/migration-list-styler-BRwF4-gy.mjs.map +0 -1
- package/dist/migration-plan-9DJ7q7_z.mjs.map +0 -1
- package/dist/migration-types-D2FW63pr.d.mts +0 -15
- package/dist/migration-types-D2FW63pr.d.mts.map +0 -1
- package/dist/migrations-Cv2jxNNK.mjs +0 -228
- package/dist/migrations-Cv2jxNNK.mjs.map +0 -1
- package/dist/terminal-ui-5Y6mrg93.d.mts.map +0 -1
- package/dist/types-Dt_SfqFm.d.mts.map +0 -1
- package/src/utils/formatters/graph-migration-mapper.ts +0 -235
- package/src/utils/formatters/graph-render.ts +0 -1323
- package/src/utils/formatters/graph-types.ts +0 -120
- package/src/utils/formatters/migration-graph-layout.ts +0 -1119
- package/src/utils/formatters/migration-graph-tree-render.ts +0 -459
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-status-CgWSoI_g.mjs","names":[],"sources":["../src/commands/migration-status-overlay.ts","../src/commands/migration-status.ts"],"sourcesContent":["import type { MigrationGraph } from '@prisma-next/migration-tools/graph';\nimport { findPath } from '@prisma-next/migration-tools/migration-graph';\nimport type { MigrationEdgeAnnotation } from '../utils/formatters/migration-graph-labels';\n\nexport interface DeriveStatusEdgeAnnotationsInput {\n readonly graph: MigrationGraph;\n readonly targetHash: string;\n readonly originHash: string;\n readonly appliedMigrationHashes: ReadonlySet<string>;\n readonly showAppliedOverlay: boolean;\n}\n\nexport function deriveStatusEdgeAnnotations(\n input: DeriveStatusEdgeAnnotationsInput,\n): ReadonlyMap<string, MigrationEdgeAnnotation> {\n const annotations = new Map<string, MigrationEdgeAnnotation>();\n\n if (input.showAppliedOverlay) {\n for (const edge of input.graph.migrationByHash.values()) {\n if (input.appliedMigrationHashes.has(edge.migrationHash)) {\n annotations.set(edge.migrationHash, { status: 'applied' });\n }\n }\n }\n\n if (!input.graph.nodes.has(input.originHash)) {\n return annotations;\n }\n\n const pendingPath = findPath(input.graph, input.originHash, input.targetHash);\n if (!pendingPath) {\n return annotations;\n }\n\n for (const edge of pendingPath) {\n if (input.appliedMigrationHashes.has(edge.migrationHash)) {\n continue;\n }\n const existing = annotations.get(edge.migrationHash);\n if (existing?.status === 'applied') {\n continue;\n }\n annotations.set(edge.migrationHash, { status: 'pending' });\n }\n\n return annotations;\n}\n\nexport function appliedHashesFromLedger(\n ledgerEntries: ReadonlyArray<{ readonly migrationHash: string }>,\n): ReadonlySet<string> {\n return new Set(ledgerEntries.map((entry) => entry.migrationHash));\n}\n\nexport function statusForMigrationHash(\n migrationHash: string,\n annotations: ReadonlyMap<string, MigrationEdgeAnnotation>,\n): 'applied' | 'pending' | null {\n const status = annotations.get(migrationHash)?.status;\n return status ?? null;\n}\n","import type { LedgerEntryRecord } from '@prisma-next/contract/types';\nimport type {\n ContractMarkerRecordLike,\n ContractSpaceMember,\n} from '@prisma-next/migration-tools/aggregate';\nimport { EMPTY_CONTRACT_HASH } from '@prisma-next/migration-tools/constants';\nimport {\n errorNoInvariantPath,\n errorUnknownInvariant,\n MigrationToolsError,\n} from '@prisma-next/migration-tools/errors';\nimport { findPath, findPathWithDecision } from '@prisma-next/migration-tools/migration-graph';\nimport { parseContractRef } from '@prisma-next/migration-tools/ref-resolution';\nimport type { RefEntry, Refs } from '@prisma-next/migration-tools/refs';\nimport { readRefs } from '@prisma-next/migration-tools/refs';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { dim, yellow } from 'colorette';\nimport { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport { createControlClient } from '../control-api/client';\nimport {\n CliStructuredError,\n errorUnexpected,\n mapMigrationToolsError,\n mapRefResolutionError,\n requireLiveDatabase,\n} from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n collectDeclaredInvariants,\n maskConnectionUrl,\n readContractEnvelope,\n resolveMigrationPaths,\n setCommandDescriptions,\n setCommandExamples,\n setCommandSeeAlso,\n toStructuralEdge,\n} from '../utils/command-helpers';\nimport {\n buildReadAggregate,\n loadContractRawSafely,\n refusePackageCorruptionOnAggregate,\n} from '../utils/contract-space-aggregate-loader';\nimport {\n type MigrationEdgeAnnotation,\n renderMigrationGraphLegend,\n} from '../utils/formatters/migration-graph-labels';\nimport {\n computeGlobalMaxDirNameWidth,\n computeGlobalMaxEdgeTreePrefixWidth,\n indentMigrationGraphTreeBlock,\n renderMigrationGraphSpaceTree,\n} from '../utils/formatters/migration-graph-space-render';\nimport type { MigrationListEntry } from '../utils/formatters/migration-list-types';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { type GlobalFlags, parseGlobalFlagsOrExit } from '../utils/global-flags';\nimport { shouldShowLegend, validateLegendOptions } from '../utils/legend';\nimport { handleResult } from '../utils/result-handler';\nimport { createTerminalUI, type TerminalUI } from '../utils/terminal-ui';\nimport type {\n MigrationStatusEntry,\n MigrationStatusResult,\n MigrationStatusSpace,\n StatusDiagnosticJson,\n} from './json/schemas';\nimport { migrationStatusJsonResultSchema } from './json/schemas';\nimport {\n listRefsByContractHash,\n migrationSpaceListEntriesFromAggregate,\n runMigrationList,\n} from './migration-list';\nimport {\n appliedHashesFromLedger,\n deriveStatusEdgeAnnotations,\n statusForMigrationHash,\n} from './migration-status-overlay';\n\nexport type { StatusRef } from '../utils/migration-types';\nexport type {\n MigrationStatusEntry,\n MigrationStatusResult,\n MigrationStatusSpace,\n StatusDiagnosticJson,\n};\nexport { migrationStatusJsonResultSchema };\n\nexport interface MigrationStatusOptions extends CommonCommandOptions {\n readonly db?: string;\n readonly config?: string;\n readonly to?: string;\n readonly from?: string;\n readonly space?: string;\n readonly legend?: boolean;\n readonly ascii?: boolean;\n}\n\nexport interface MigrationStatusTreeSection {\n readonly space: string;\n readonly tree: string;\n readonly showHeading: boolean;\n}\n\ninterface MigrationStatusCommandResult {\n readonly ok: true;\n readonly spaces: readonly MigrationStatusSpace[];\n readonly summary: string;\n readonly diagnostics: readonly StatusDiagnosticJson[];\n readonly treeSections: readonly MigrationStatusTreeSection[];\n}\n\nfunction shortDisplayHash(hash: string): string {\n const stripped = hash.startsWith('sha256:') ? hash.slice(7) : hash;\n return stripped.slice(0, 12);\n}\n\nfunction resolveTarget(contractHash: string, activeRefHash: string | undefined): string {\n return activeRefHash ?? contractHash;\n}\n\nfunction buildStatusMigrations(\n listMigrations: readonly MigrationListEntry[],\n annotations: ReadonlyMap<string, MigrationEdgeAnnotation>,\n): readonly MigrationStatusEntry[] {\n return listMigrations.map((migration) => ({\n ...migration,\n status: statusForMigrationHash(migration.hash, annotations),\n }));\n}\n\nfunction renderSpaceTree(args: {\n readonly member: ContractSpaceMember;\n readonly liveContractHash: string;\n readonly migrations: readonly MigrationListEntry[];\n readonly markerHash: string | undefined;\n readonly showDbMarker: boolean;\n readonly statusOverlay: ReadonlyMap<string, MigrationEdgeAnnotation>;\n readonly colorize: boolean;\n readonly glyphMode: 'unicode' | 'ascii';\n readonly isAppSpace: boolean;\n readonly globalMaxEdgeTreePrefixWidth?: number;\n readonly globalMaxDirNameWidth?: number;\n}): string {\n const graph = args.member.graph();\n if (graph.nodes.size === 0) {\n return '';\n }\n return renderMigrationGraphSpaceTree({\n graph,\n migrations: args.migrations,\n liveContractHash: args.liveContractHash,\n refsByHash: listRefsByContractHash(args.member),\n statusOverlayByHash: args.statusOverlay,\n colorize: args.colorize,\n glyphMode: args.glyphMode,\n isAppSpace: args.isAppSpace,\n ...(args.showDbMarker && args.markerHash !== undefined ? { dbHash: args.markerHash } : {}),\n ...(args.globalMaxEdgeTreePrefixWidth !== undefined\n ? { globalMaxEdgeTreePrefixWidth: args.globalMaxEdgeTreePrefixWidth }\n : {}),\n ...(args.globalMaxDirNameWidth !== undefined\n ? { globalMaxDirNameWidth: args.globalMaxDirNameWidth }\n : {}),\n });\n}\n\nfunction countPending(migrations: readonly MigrationStatusEntry[]): number {\n return migrations.filter((m) => m.status === 'pending').length;\n}\n\nexport function buildNoPathSummary(args: {\n readonly markerHash: string | undefined;\n readonly targetHash: string;\n readonly explicitTarget: boolean;\n readonly refName: string | undefined;\n}): string {\n const markerPart =\n args.markerHash !== undefined\n ? `the database state (${shortDisplayHash(args.markerHash)})`\n : 'the database state';\n const targetShort = shortDisplayHash(args.targetHash);\n if (!args.explicitTarget) {\n return `No migration path from ${markerPart} to the application's contract (${targetShort}). Run \\`prisma-next migration plan --name <name>\\` to author one.`;\n }\n const targetLabel =\n args.refName !== undefined\n ? `the target (${targetShort} via \\`${args.refName}\\`)`\n : `the target (${targetShort})`;\n return `No migration path from ${markerPart} to ${targetLabel}. Run \\`prisma-next migration plan --name <name>\\` to author one, or pass \\`--to <contract>\\` to pick a reachable target.`;\n}\n\nexport function buildStatusHeadline(args: {\n readonly pendingCount: number;\n readonly targetHash: string;\n readonly markerDiverged: boolean;\n readonly markerHash: string | undefined;\n}): string {\n if (args.markerDiverged && args.markerHash !== undefined) {\n return `Database marker ${shortDisplayHash(args.markerHash)} is not in the on-disk migration graph`;\n }\n if (args.pendingCount === 0) {\n return 'Up to date';\n }\n return `${args.pendingCount} pending — run \\`prisma-next migrate --to ${shortDisplayHash(args.targetHash)}\\``;\n}\n\nexport function formatStatusSummary(\n result: MigrationStatusCommandResult,\n colorize: boolean,\n): string {\n const c = (fn: (s: string) => string, s: string) => (colorize ? fn(s) : s);\n const lines: string[] = [];\n const pendingTotal = result.spaces.reduce(\n (sum, space) => sum + countPending(space.migrations),\n 0,\n );\n const hasDivergence = result.diagnostics.some(\n (d) => d.code === 'MIGRATION.MARKER_NOT_IN_HISTORY',\n );\n if (hasDivergence || pendingTotal > 0) {\n lines.push(c(yellow, result.summary));\n } else {\n lines.push(result.summary);\n }\n const missingInvariantsDiagnostic = result.diagnostics.find(\n (d) => d.code === 'MIGRATION.MISSING_INVARIANTS',\n );\n if (missingInvariantsDiagnostic !== undefined) {\n lines.push(c(dim, missingInvariantsDiagnostic.message));\n }\n return lines.join('\\n');\n}\n\nexport function formatStatusHumanOutput(\n result: MigrationStatusCommandResult,\n colorize: boolean,\n): string {\n const sections: string[] = [];\n for (const section of result.treeSections) {\n if (section.showHeading) {\n sections.push(`${section.space}:`);\n }\n if (section.tree.length > 0) {\n sections.push(section.tree);\n } else {\n sections.push('(no migrations)');\n }\n sections.push('');\n }\n sections.push(formatStatusSummary(result, colorize));\n return sections.join('\\n').trimEnd();\n}\n\nasync function readMarkersAndLedgers(args: {\n readonly client: ReturnType<typeof createControlClient>;\n readonly spaceIds: readonly string[];\n}): Promise<{\n readonly markersBySpace: ReadonlyMap<string, ContractMarkerRecordLike>;\n readonly ledgersBySpace: ReadonlyMap<string, readonly LedgerEntryRecord[]>;\n}> {\n const markersBySpace = new Map<string, ContractMarkerRecordLike>();\n const all = await args.client.readAllMarkers();\n for (const [spaceId, marker] of all) {\n markersBySpace.set(spaceId, marker);\n }\n const ledgersBySpace = new Map<string, readonly LedgerEntryRecord[]>();\n for (const spaceId of args.spaceIds) {\n ledgersBySpace.set(spaceId, await args.client.readLedger(spaceId));\n }\n return { markersBySpace, ledgersBySpace };\n}\n\nexport async function executeMigrationStatusCommand(\n options: MigrationStatusOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n): Promise<Result<MigrationStatusCommandResult, CliStructuredError>> {\n const config = await loadConfig(options.config);\n const { configPath, migrationsDir, migrationsRelative, refsDir } = resolveMigrationPaths(\n options.config,\n config,\n );\n\n const dbConnection = options.db ?? config.db?.connection;\n const hasDriver = !!config.driver;\n const usingFromOverride = options.from !== undefined;\n\n if (!usingFromOverride) {\n const missingDb = requireLiveDatabase({\n dbConnection,\n hasDriver,\n why: 'migration status needs a database connection to read the marker and ledger (or pass --from for offline path preview)',\n retryCommand: 'prisma-next migration status --from <contract>',\n });\n if (missingDb) {\n return notOk(missingDb);\n }\n }\n\n let allRefs: Refs = {};\n try {\n allRefs = await readRefs(refsDir);\n } catch (error) {\n if (MigrationToolsError.is(error)) {\n return notOk(mapMigrationToolsError(error));\n }\n throw error;\n }\n\n const diagnostics: StatusDiagnosticJson[] = [];\n let contractHash: string = EMPTY_CONTRACT_HASH;\n try {\n const envelope = await readContractEnvelope(config);\n contractHash = envelope.storageHash;\n } catch (error) {\n diagnostics.push({\n code: 'CONTRACT.UNREADABLE',\n severity: 'warn',\n message: `Could not read contract: ${error instanceof Error ? error.message : 'unknown error'}`,\n hints: [\"Run 'prisma-next contract emit' to generate a valid contract\"],\n });\n }\n\n const loaded = await buildReadAggregate(config, { migrationsDir });\n if (!loaded.ok) {\n return notOk(loaded.failure);\n }\n\n const { aggregate } = loaded.value;\n const contractRawForAggregate = await loadContractRawSafely(config);\n if (contractRawForAggregate !== null) {\n const corruptionFailure = refusePackageCorruptionOnAggregate(aggregate);\n if (corruptionFailure) {\n return notOk(corruptionFailure);\n }\n }\n const appGraph = aggregate.app.graph();\n\n let activeRefHash: string | undefined;\n let activeRefName: string | undefined;\n let activeRefEntry: RefEntry | undefined;\n let fromOverrideHash: string | undefined;\n\n if (options.to) {\n const refResult = parseContractRef(options.to, { graph: appGraph, refs: allRefs });\n if (!refResult.ok) {\n return notOk(mapRefResolutionError(refResult.failure));\n }\n activeRefHash = refResult.value.hash;\n if (refResult.value.provenance.kind === 'ref') {\n activeRefName = refResult.value.provenance.refName;\n activeRefEntry = allRefs[activeRefName];\n }\n }\n\n if (options.from) {\n const fromResult = parseContractRef(options.from, { graph: appGraph, refs: allRefs });\n if (!fromResult.ok) {\n return notOk(mapRefResolutionError(fromResult.failure));\n }\n fromOverrideHash = fromResult.value.hash;\n }\n\n const requiredInvariants: readonly string[] = [...(activeRefEntry?.invariants ?? [])].sort();\n\n if (!flags.json && !flags.quiet) {\n const details: Array<{ label: string; value: string }> = [\n { label: 'config', value: configPath },\n { label: 'migrations', value: migrationsRelative },\n ];\n if (dbConnection && hasDriver) {\n details.push({ label: 'database', value: maskConnectionUrl(String(dbConnection)) });\n }\n if (activeRefName) {\n details.push({ label: 'ref', value: activeRefName });\n }\n if (options.from) {\n details.push({ label: 'from', value: options.from });\n }\n if (options.space) {\n details.push({ label: 'space', value: options.space });\n }\n const header = formatStyledHeader({\n command: 'migration status',\n description: 'Show migration history and applied status',\n details,\n flags,\n });\n ui.stderr(header);\n if (shouldShowLegend(options, flags)) {\n ui.stderr(\n renderMigrationGraphLegend({\n colorize: flags.color !== false,\n glyphMode: ui.resolveGlyphMode(options.ascii === true),\n }),\n );\n ui.stderr('');\n }\n }\n\n const listSpaces = await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir);\n const listResult = runMigrationList({\n spaces: listSpaces,\n ...ifDefined('spaceFilter', options.space),\n });\n if (!listResult.ok) {\n return listResult;\n }\n\n const scopedSpaces = listResult.value.spaces;\n const showSpaceHeadings = scopedSpaces.length > 1;\n\n let markersBySpace = new Map<string, ContractMarkerRecordLike>();\n let ledgersBySpace = new Map<string, readonly LedgerEntryRecord[]>();\n let connected = false;\n\n if (dbConnection && hasDriver && !usingFromOverride) {\n const client = createControlClient({\n family: config.family,\n target: config.target,\n adapter: config.adapter,\n driver: config.driver,\n extensionPacks: config.extensionPacks ?? [],\n });\n try {\n await client.connect(dbConnection);\n connected = true;\n const read = await readMarkersAndLedgers({\n client,\n spaceIds: scopedSpaces.map((s) => s.space),\n });\n markersBySpace = new Map(read.markersBySpace);\n ledgersBySpace = new Map(read.ledgersBySpace);\n } catch (error) {\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n return notOk(\n errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: `Failed to read database state: ${error instanceof Error ? error.message : String(error)}`,\n }),\n );\n } finally {\n await client.close();\n }\n }\n\n if (activeRefEntry && activeRefEntry.invariants.length > 0 && connected) {\n const declared = collectDeclaredInvariants(appGraph);\n const markerInvariants = markersBySpace.get(aggregate.app.spaceId)?.invariants ?? [];\n const known = new Set<string>(declared);\n for (const id of markerInvariants) known.add(id);\n const unknown = activeRefEntry.invariants.filter((id) => !known.has(id));\n if (unknown.length > 0) {\n return notOk(\n mapMigrationToolsError(\n errorUnknownInvariant({\n ...ifDefined('refName', activeRefName),\n unknown,\n declared: [...declared].sort(),\n }),\n ),\n );\n }\n }\n\n const showAppliedOverlay = connected && !usingFromOverride;\n const showDbMarker = connected && !usingFromOverride;\n const glyphMode = ui.resolveGlyphMode(options.ascii === true);\n const colorize = flags.color !== false;\n\n const statusSpaces: MigrationStatusSpace[] = [];\n const treeSections: MigrationStatusTreeSection[] = [];\n let markerDiverged = false;\n let markerCannotReachTarget = false;\n let headlineTargetHash = activeRefHash ?? contractHash;\n let totalPending = 0;\n\n const globalLayoutInputs = showSpaceHeadings\n ? scopedSpaces\n .filter((spaceEntry) => spaceEntry.migrations.length > 0)\n .map((spaceEntry) => ({\n graph: aggregate.space(spaceEntry.space)!.graph(),\n liveContractHash: contractHash,\n }))\n : [];\n const globalMaxEdgeTreePrefixWidth =\n globalLayoutInputs.length > 0\n ? computeGlobalMaxEdgeTreePrefixWidth(globalLayoutInputs)\n : undefined;\n const globalMaxDirNameWidth =\n globalLayoutInputs.length > 0 ? computeGlobalMaxDirNameWidth(globalLayoutInputs) : undefined;\n\n for (const spaceEntry of scopedSpaces) {\n const member = aggregate.space(spaceEntry.space);\n if (member === undefined) {\n continue;\n }\n const graph = member.graph();\n const spaceContractHash = member.contract().storage.storageHash;\n const targetHash = resolveTarget(spaceContractHash, activeRefHash);\n if (spaceEntry.space === aggregate.app.spaceId) {\n headlineTargetHash = targetHash;\n }\n\n const markerRecord = markersBySpace.get(spaceEntry.space);\n const markerHash = usingFromOverride\n ? fromOverrideHash\n : (markerRecord?.storageHash ?? undefined);\n const originHash = markerHash ?? EMPTY_CONTRACT_HASH;\n const markerInGraph =\n markerHash === undefined || graph.nodes.has(markerHash) || markerHash === spaceContractHash;\n if (\n connected &&\n !usingFromOverride &&\n markerInGraph &&\n originHash !== targetHash &&\n findPath(graph, originHash, targetHash) === null\n ) {\n markerCannotReachTarget = true;\n }\n\n if (connected && !usingFromOverride && markerHash !== undefined && !markerInGraph) {\n markerDiverged = true;\n diagnostics.push({\n code: 'MIGRATION.MARKER_NOT_IN_HISTORY',\n severity: 'warn',\n message:\n 'Database was updated outside the migration system (marker does not match any migration)',\n hints: [\n \"Run 'prisma-next db sign' to overwrite the marker if the database already matches the contract\",\n \"Run 'prisma-next db update' to push the current contract to the database\",\n ],\n });\n }\n\n const ledger = ledgersBySpace.get(spaceEntry.space) ?? [];\n const appliedHashes = showAppliedOverlay ? appliedHashesFromLedger(ledger) : new Set<string>();\n\n const annotations = deriveStatusEdgeAnnotations({\n graph,\n targetHash,\n originHash,\n appliedMigrationHashes: appliedHashes,\n showAppliedOverlay,\n });\n const isAppSpace = spaceEntry.space === aggregate.app.spaceId;\n const tree = renderSpaceTree({\n member,\n liveContractHash: contractHash,\n migrations: spaceEntry.migrations,\n markerHash,\n showDbMarker,\n statusOverlay: annotations,\n colorize,\n glyphMode,\n isAppSpace,\n ...(globalMaxEdgeTreePrefixWidth !== undefined ? { globalMaxEdgeTreePrefixWidth } : {}),\n ...(globalMaxDirNameWidth !== undefined ? { globalMaxDirNameWidth } : {}),\n });\n const migrations = buildStatusMigrations(spaceEntry.migrations, annotations);\n const pending = countPending(migrations);\n totalPending += pending;\n\n statusSpaces.push({\n space: spaceEntry.space,\n currentContract: markerHash ?? null,\n targetContract: targetHash,\n migrations: [...migrations],\n });\n const displayTree =\n showSpaceHeadings && tree.length > 0 ? indentMigrationGraphTreeBlock(tree, ' ') : tree;\n treeSections.push({\n space: spaceEntry.space,\n tree: displayTree,\n showHeading: showSpaceHeadings,\n });\n }\n\n if (connected && requiredInvariants.length > 0) {\n const markerInvariants = markersBySpace.get(aggregate.app.spaceId)?.invariants ?? [];\n const markerSet = new Set(markerInvariants);\n const missing = requiredInvariants.filter((id) => !markerSet.has(id));\n if (missing.length > 0) {\n diagnostics.push({\n code: 'MIGRATION.MISSING_INVARIANTS',\n ...ifDefined('ref', activeRefName),\n invariants: missing,\n message: `missing invariant(s): ${missing.join(', ')}`,\n });\n if (activeRefHash !== undefined) {\n const originHash =\n markersBySpace.get(aggregate.app.spaceId)?.storageHash ?? EMPTY_CONTRACT_HASH;\n const outcome = findPathWithDecision(appGraph, originHash, activeRefHash, {\n ...ifDefined('refName', activeRefName),\n required: new Set(missing),\n });\n if (outcome.kind === 'unsatisfiable') {\n return notOk(\n mapMigrationToolsError(\n errorNoInvariantPath({\n ...ifDefined('refName', activeRefName),\n required: [...missing].sort(),\n missing: outcome.missing,\n structuralPath: outcome.structuralPath.map(toStructuralEdge),\n }),\n ),\n );\n }\n }\n }\n }\n\n const appMarkerHash = markersBySpace.get(aggregate.app.spaceId)?.storageHash;\n const summary = markerCannotReachTarget\n ? buildNoPathSummary({\n markerHash: appMarkerHash,\n targetHash: headlineTargetHash,\n explicitTarget: options.to !== undefined,\n refName: activeRefName,\n })\n : buildStatusHeadline({\n pendingCount: totalPending,\n targetHash: headlineTargetHash,\n markerDiverged,\n markerHash: appMarkerHash,\n });\n\n if (scopedSpaces.every((s) => s.migrations.length === 0)) {\n return ok({\n ok: true,\n spaces: statusSpaces,\n summary: 'No migrations found',\n diagnostics,\n treeSections,\n });\n }\n\n return ok({\n ok: true,\n spaces: statusSpaces,\n summary,\n diagnostics,\n treeSections,\n });\n}\n\nexport function createMigrationStatusCommand(): Command {\n const command = new Command('status');\n setCommandDescriptions(\n command,\n 'Show migration path and pending status',\n 'Shows which migrations are pending between the database marker and\\n' +\n 'the target contract. Requires a database connection.\\n' +\n 'Pass --from for an offline path preview without a database.\\n' +\n 'Use `migration graph` for topology, `migration log` for history,\\n' +\n 'and `migration list` for on-disk enumeration.',\n );\n setCommandExamples(command, [\n 'prisma-next migration status --db $DATABASE_URL',\n 'prisma-next migration status --to production --db $DATABASE_URL',\n 'prisma-next migration status --from sha256:abc --to production',\n 'prisma-next migration status --from sha256:abc --to production --json',\n 'prisma-next migration status --ascii --from sha256:abc --to production',\n 'prisma-next migration status --legend --from sha256:abc --to production',\n ]);\n setCommandSeeAlso(command, [\n { verb: 'migration log', oneLiner: 'Show executed migration history' },\n { verb: 'migration list', oneLiner: 'List on-disk migrations' },\n { verb: 'migration graph', oneLiner: 'Show the migration graph topology' },\n { verb: 'migration show', oneLiner: 'Display migration package contents' },\n ]);\n addGlobalOptions(command)\n .option('--db <url>', 'Database connection string')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--space <id>', 'Narrow output to a single contract space')\n .option(\n '--to <contract>',\n 'Target contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)',\n )\n .option(\n '--from <contract>',\n 'Origin contract reference; same grammar as --to. Supplying --from switches to offline path computation.',\n )\n .option('--legend', 'Print a key for the tree glyphs and lane colors')\n .option('--ascii', 'Use ASCII glyphs (pipe-friendly)')\n .action(async (options: MigrationStatusOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n const ui = createTerminalUI(flags);\n\n const legendValidation = validateLegendOptions(options, flags);\n if (!legendValidation.ok) {\n process.exit(handleResult(legendValidation, flags, ui));\n }\n\n const result = await executeMigrationStatusCommand(options, flags, ui);\n\n const exitCode = handleResult(result, flags, ui, (statusResult) => {\n if (flags.json) {\n const jsonResult: MigrationStatusResult = {\n ok: true,\n spaces: [...statusResult.spaces],\n summary: statusResult.summary,\n diagnostics: [...statusResult.diagnostics],\n };\n ui.output(JSON.stringify(jsonResult, null, 2));\n } else if (!flags.quiet) {\n ui.output(formatStatusHumanOutput(statusResult, flags.color !== false));\n }\n });\n\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAYA,SAAgB,4BACd,OAC8C;CAC9C,MAAM,8BAAc,IAAI,IAAqC;CAE7D,IAAI,MAAM;OACH,MAAM,QAAQ,MAAM,MAAM,gBAAgB,OAAO,GACpD,IAAI,MAAM,uBAAuB,IAAI,KAAK,aAAa,GACrD,YAAY,IAAI,KAAK,eAAe,EAAE,QAAQ,UAAU,CAAC;CAAA;C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4BAA4B,CAAC,CAClD,OAAO,mBAAmB,+BAA+B,CAAC,CAC1D,OAAO,gBAAgB,0CAA0C,CAAC,CAClE,OACC,mBACA,2FACF,CAAC,CACA,OACC,qBACA,yGACF,CAAC,CACA,OAAO,YAAY,iDAAiD,CAAC,CACrE,OAAO,WAAW,kCAAkC,CAAC,CACrD,OAAO,OAAO,YAAoC;EACjD,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EAEjC,MAAM,mBAAmB,sBAAsB,SAAS,KAAK;EAC7D,IAAI,CAAC,iBAAiB,IACpB,QAAQ,KAAK,aAAa,kBAAkB,OAAO,EAAE,CAAC;EAKxD,MAAM,WAAW,aAAa,MAFT,8BAA8B,SAAS,OAAO,EAAE,GAE/B,OAAO,KAAK,iBAAiB;GACjE,IAAI,MAAM,MAAM;IACd,MAAM,aAAoC;KACxC,IAAI;KACJ,QAAQ,CAAC,GAAG,aAAa,MAAM;KAC/B,SAAS,aAAa;KACtB,aAAa,CAAC,GAAG,aAAa,WAAW;IAC3C;IACA,GAAG,OAAO,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC;GAC/C,OAAO,IAAI,CAAC,MAAM,OAChB,GAAG,OAAO,wBAAwB,cAAc,MAAM,UAAU,KAAK,CAAC;EAE1E,CAAC;EAED,QAAQ,KAAK,QAAQ;CACvB,CAAC;CAEH,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-
|
|
1
|
+
{"version":3,"file":"output-mEQ74_nd.mjs","names":[],"sources":["../src/commands/init/output.ts"],"sourcesContent":["import { type } from 'arktype';\nimport type { GlobalFlags } from '../../utils/global-flags';\nimport type { TerminalUI } from '../../utils/terminal-ui';\n\n/**\n * arktype schema for the structured success document `init --json` writes\n * to stdout (FR1.5). The same shape backs the human-readable outro\n * renderer (FR10), so the two output modes carry identical information.\n *\n * `target` is normalised to the user-facing flag value (`mongodb` rather\n * than the internal `mongo`) so consumers can round-trip the document\n * straight into a follow-up `--target` invocation.\n *\n * The `ok: true` literal is the documented success/error discriminator —\n * see [Style Guide § JSON Semantics](../../../../../../../docs/CLI%20Style%20Guide.md#json-semantics).\n * Error envelopes (`CliErrorEnvelope`) carry `ok: false` so consumers can\n * branch with `if (doc.ok)` without inspecting the rest of the structure.\n */\nexport const InitOutputSchema = type({\n ok: 'true',\n target: \"'postgres'|'mongodb'\",\n authoring: \"'psl'|'typescript'\",\n schemaPath: 'string',\n filesWritten: 'string[]',\n /**\n * FR9.1 — files removed from disk during this run. Populated only on\n * re-init when previously-emitted contract artefacts (`contract.json`,\n * `contract.d.ts`, `start-/end-contract.*`, `ops.json`,\n * `migration.json`) were left behind by an earlier run. Empty on a\n * green-field init.\n */\n filesDeleted: 'string[]',\n packagesInstalled: {\n skipped: 'boolean',\n deps: 'string[]',\n devDeps: 'string[]',\n },\n contractEmitted: 'boolean',\n nextSteps: 'string[]',\n warnings: 'string[]',\n});\n\nexport type InitOutput = typeof InitOutputSchema.infer;\n\n/**\n * Serialises the output document for `--json`. Sorted keys are not enforced\n * — `JSON.stringify` preserves insertion order, and the schema field order\n * is the documented order, which matches what users will see when they\n * `jq .` the result.\n */\nexport function formatInitJson(output: InitOutput): string {\n return JSON.stringify(output, null, 2);\n}\n\n/**\n * Renders the human-readable outro on stderr (FR10.1). Re-uses the same\n * data structure as the JSON output so the two stay in lock-step.\n *\n * Warnings come before \"Next steps\" because they describe state the user\n * needs to be aware of before acting on the next-steps list.\n */\nexport function renderInitOutro(ui: TerminalUI, output: InitOutput, flags: GlobalFlags): void {\n if (flags.quiet || flags.json) {\n return;\n }\n\n for (const warning of output.warnings) {\n ui.warn(warning);\n }\n\n const lines: string[] = [];\n lines.push(`Target: ${output.target}`);\n lines.push(`Authoring: ${output.authoring}`);\n lines.push(`Schema: ${output.schemaPath}`);\n lines.push('');\n lines.push('Files written:');\n for (const file of output.filesWritten) {\n lines.push(` • ${file}`);\n }\n\n if (output.filesDeleted.length > 0) {\n lines.push('');\n lines.push('Files deleted (stale contract artefacts):');\n for (const file of output.filesDeleted) {\n lines.push(` • ${file}`);\n }\n }\n\n if (!output.packagesInstalled.skipped) {\n lines.push('');\n lines.push('Packages installed:');\n for (const dep of output.packagesInstalled.deps) {\n lines.push(` • ${dep}`);\n }\n for (const dep of output.packagesInstalled.devDeps) {\n lines.push(` • ${dep} (dev)`);\n }\n }\n\n lines.push('');\n lines.push('Next steps:');\n for (const step of output.nextSteps) {\n lines.push(` ${step}`);\n }\n\n ui.note(lines.join('\\n'), 'Done');\n}\n\n/**\n * Builds the `nextSteps` array from the resolved scaffold state. Steps are\n * ordered by the workflow a user needs to follow: configure connection →\n * (emit if not yet done) → run a starter query → docs / agent skill.\n *\n * The strings are stable and human-readable; agents wanting to act on them\n * should match on substrings (e.g. \"DATABASE_URL\") rather than exact text,\n * since copy may evolve.\n */\nexport function buildNextSteps(options: {\n readonly target: 'postgres' | 'mongodb';\n readonly contractEmitted: boolean;\n readonly emitCommand: string;\n readonly schemaPath: string;\n /**\n * Whether the project-level Prisma Next skills install actually ran\n * and succeeded during this `init`. When false (the user passed\n * `--no-skill`, so the install was skipped), the\n * \"registered with your agent runtime\" step is omitted — the skip is\n * already surfaced in the warnings array with a manual-install hint.\n */\n readonly skillRegistered: boolean;\n}): string[] {\n const steps: string[] = [];\n let stepNumber = 1;\n const push = (text: string): void => {\n steps.push(`${stepNumber}. ${text}`);\n stepNumber += 1;\n };\n push('Set DATABASE_URL in your environment (export it or add it to .env).');\n if (!options.contractEmitted) {\n push(`Emit the contract: \\`${options.emitCommand}\\``);\n push(`Edit your schema at ${options.schemaPath}, then re-run the emit command.`);\n } else {\n push(`Edit your schema at ${options.schemaPath}, then re-run \\`${options.emitCommand}\\`.`);\n }\n push('Open prisma-next.md for a quick reference on how to write your first typed query.');\n if (options.skillRegistered) {\n push(\n 'Prisma Next skills are registered with your agent runtime — open the project in your IDE and ask the agent to add a model, run a query, or plan a migration.',\n );\n }\n return steps;\n}\n"],"mappings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KAAK,IAAI,GAAG,MAAM;AAClC;;;;;;;;;;AAWA,SAAgB,eAAe,SAalB;CACX,MAAM,QAAkB,CAAC;CACzB,IAAI,aAAa;CACjB,MAAM,QAAQ,SAAuB;EACnC,MAAM,KAAK,GAAG,WAAW,IAAI,MAAM;EACnC,cAAc;CAChB;CACA,KAAK,qEAAqE;CAC1E,IAAI,CAAC,QAAQ,iBAAiB;EAC5B,KAAK,wBAAwB,QAAQ,YAAY,GAAG;EACpD,KAAK,uBAAuB,QAAQ,WAAW,gCAAgC;CACjF,OACE,KAAK,uBAAuB,QAAQ,WAAW,kBAAkB,QAAQ,YAAY,IAAI;CAE3F,KAAK,mFAAmF;CACxF,IAAI,QAAQ,iBACV,KACE,8JACF;CAEF,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress-adapter-
|
|
1
|
+
{"version":3,"file":"progress-adapter-CjAeTxY_.mjs","names":[],"sources":["../src/utils/progress-adapter.ts"],"sourcesContent":["import type { SpinnerResult } from '@clack/prompts';\nimport type { ControlProgressEvent, OnControlProgress } from '../control-api/types';\nimport type { GlobalFlags } from './global-flags';\nimport type { TerminalUI } from './terminal-ui';\n\n/**\n * Options for creating a progress adapter.\n */\ninterface ProgressAdapterOptions {\n readonly ui: TerminalUI;\n readonly flags: GlobalFlags;\n}\n\n/**\n * State for tracking active spans in the progress adapter.\n */\ninterface SpanState {\n readonly spinner: SpinnerResult;\n readonly startTime: number;\n readonly label: string;\n}\n\n/**\n * Creates a progress adapter that converts control-api progress events\n * into CLI spinner/progress output on stderr.\n *\n * The adapter:\n * - Starts/succeeds spinners for top-level span boundaries\n * - Prints per-operation lines for nested spans (e.g., migration operations under 'apply')\n * - Respects quiet/json/non-TTY flags (no-op in those cases)\n */\nexport function createProgressAdapter(options: ProgressAdapterOptions): OnControlProgress {\n const { ui, flags } = options;\n\n // Skip progress if quiet, JSON output, or non-interactive\n if (flags.quiet || flags.json || !ui.isInteractive) {\n return () => {};\n }\n\n // Track active spans by spanId\n const activeSpans = new Map<string, SpanState>();\n\n return (event: ControlProgressEvent) => {\n if (event.kind === 'spanStart') {\n // Nested spans (with parentSpanId) are printed as step lines\n if (event.parentSpanId) {\n ui.step(`${event.label}...`);\n return;\n }\n\n // Top-level spans get a spinner\n const spinner = ui.spinner();\n spinner.start(event.label);\n\n activeSpans.set(event.spanId, {\n spinner,\n startTime: Date.now(),\n label: event.label,\n });\n } else if (event.kind === 'spanEnd') {\n const spanState = activeSpans.get(event.spanId);\n if (spanState) {\n const elapsed = Date.now() - spanState.startTime;\n if (event.outcome === 'error') {\n spanState.spinner.error(`${spanState.label} (failed)`);\n } else if (event.outcome === 'skipped') {\n spanState.spinner.stop(`${spanState.label} (skipped)`);\n } else {\n spanState.spinner.stop(`${spanState.label} (${elapsed}ms)`);\n }\n activeSpans.delete(event.spanId);\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;AA+BA,SAAgB,sBAAsB,SAAoD;CACxF,MAAM,EAAE,IAAI,UAAU;CAGtB,IAAI,MAAM,SAAS,MAAM,QAAQ,CAAC,GAAG,eACnC,aAAa,CAAC;CAIhB,MAAM,8BAAc,IAAI,IAAuB;CAE/C,QAAQ,UAAgC;EACtC,IAAI,MAAM,SAAS,aAAa;GAE9B,IAAI,MAAM,cAAc;IACtB,GAAG,KAAK,GAAG,MAAM,MAAM,IAAI;IAC3B;GACF;GAGA,MAAM,UAAU,GAAG,QAAQ;GAC3B,QAAQ,MAAM,MAAM,KAAK;GAEzB,YAAY,IAAI,MAAM,QAAQ;IAC5B;IACA,WAAW,KAAK,IAAI;IACpB,OAAO,MAAM;GACf,CAAC;EACH,OAAO,IAAI,MAAM,SAAS,WAAW;GACnC,MAAM,YAAY,YAAY,IAAI,MAAM,MAAM;GAC9C,IAAI,WAAW;IACb,MAAM,UAAU,KAAK,IAAI,IAAI,UAAU;IACvC,IAAI,MAAM,YAAY,SACpB,UAAU,QAAQ,MAAM,GAAG,UAAU,MAAM,UAAU;SAChD,IAAI,MAAM,YAAY,WAC3B,UAAU,QAAQ,KAAK,GAAG,UAAU,MAAM,WAAW;SAErD,UAAU,QAAQ,KAAK,GAAG,UAAU,MAAM,IAAI,QAAQ,IAAI;IAE5D,YAAY,OAAO,MAAM,MAAM;GACjC;EACF;CACF;AACF"}
|
|
@@ -47,4 +47,4 @@ async function buildRefAdvancementFields(options) {
|
|
|
47
47
|
//#endregion
|
|
48
48
|
export { readContractIR as i, computeRefAdvancementName as n, executeRefAdvancement as r, buildRefAdvancementFields as t };
|
|
49
49
|
|
|
50
|
-
//# sourceMappingURL=ref-advancement-
|
|
50
|
+
//# sourceMappingURL=ref-advancement-BkXlikCA.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref-advancement-
|
|
1
|
+
{"version":3,"file":"ref-advancement-BkXlikCA.mjs","names":[],"sources":["../src/utils/ref-advancement.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { ContractIR } from '@prisma-next/migration-tools/refs';\nimport { writeRefPaired } from '@prisma-next/migration-tools/refs';\nimport { ifDefined } from '@prisma-next/utils/defined';\n\nexport interface RefAdvancementFields {\n readonly advancedRef: { readonly name: string; readonly hash: string } | null;\n readonly plannedAdvanceRef: { readonly name: string; readonly hash: string } | null;\n}\n\nexport function computeRefAdvancementName(options: {\n readonly advanceRef?: string;\n readonly db?: string;\n}): string | null {\n if (options.advanceRef !== undefined) {\n return options.advanceRef;\n }\n if (options.db === undefined) {\n return 'db';\n }\n return null;\n}\n\nexport async function readContractIR(\n contractJson: Record<string, unknown>,\n contractJsonPath: string,\n): Promise<ContractIR> {\n const contractDtsPath = contractJsonPath.replace(/\\.json$/i, '.d.ts');\n const contractDts = await readFile(contractDtsPath, 'utf-8');\n return { contract: contractJson, contractDts };\n}\n\nexport async function executeRefAdvancement(\n refsDir: string,\n name: string,\n hash: string,\n contractIR: ContractIR,\n): Promise<{ name: string; hash: string }> {\n await writeRefPaired(refsDir, name, { hash, invariants: [] }, contractIR);\n return { name, hash };\n}\n\nexport async function buildRefAdvancementFields(options: {\n readonly advanceRef?: string;\n readonly db?: string;\n readonly refsDir: string;\n readonly contractIR: ContractIR;\n readonly mode: 'plan' | 'apply';\n readonly hash: string;\n}): Promise<RefAdvancementFields> {\n const name = computeRefAdvancementName({\n ...ifDefined('advanceRef', options.advanceRef),\n ...ifDefined('db', options.db),\n });\n if (name === null) {\n return { advancedRef: null, plannedAdvanceRef: null };\n }\n if (options.mode === 'plan') {\n return { advancedRef: null, plannedAdvanceRef: { name, hash: options.hash } };\n }\n const advancedRef = await executeRefAdvancement(\n options.refsDir,\n name,\n options.hash,\n options.contractIR,\n );\n return { advancedRef, plannedAdvanceRef: null };\n}\n"],"mappings":";;;;AAUA,SAAgB,0BAA0B,SAGxB;CAChB,IAAI,QAAQ,eAAe,KAAA,GACzB,OAAO,QAAQ;CAEjB,IAAI,QAAQ,OAAO,KAAA,GACjB,OAAO;CAET,OAAO;AACT;AAEA,eAAsB,eACpB,cACA,kBACqB;CAGrB,OAAO;EAAE,UAAU;EAAc,aAAA,MADP,SADF,iBAAiB,QAAQ,YAAY,OACZ,GAAG,OAAO;CACd;AAC/C;AAEA,eAAsB,sBACpB,SACA,MACA,MACA,YACyC;CACzC,MAAM,eAAe,SAAS,MAAM;EAAE;EAAM,YAAY,CAAC;CAAE,GAAG,UAAU;CACxE,OAAO;EAAE;EAAM;CAAK;AACtB;AAEA,eAAsB,0BAA0B,SAOd;CAChC,MAAM,OAAO,0BAA0B;EACrC,GAAG,UAAU,cAAc,QAAQ,UAAU;EAC7C,GAAG,UAAU,MAAM,QAAQ,EAAE;CAC/B,CAAC;CACD,IAAI,SAAS,MACX,OAAO;EAAE,aAAa;EAAM,mBAAmB;CAAK;CAEtD,IAAI,QAAQ,SAAS,QACnB,OAAO;EAAE,aAAa;EAAM,mBAAmB;GAAE;GAAM,MAAM,QAAQ;EAAK;CAAE;CAQ9E,OAAO;EAAE,aAAA,MANiB,sBACxB,QAAQ,SACR,MACA,QAAQ,MACR,QAAQ,UACV;EACsB,mBAAmB;CAAK;AAChD"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
//#region src/commands/json/schemas.d.ts
|
|
2
|
+
declare const migrationSpaceListEntrySchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
3
|
+
space: string;
|
|
4
|
+
migrations: {
|
|
5
|
+
name: string;
|
|
6
|
+
hash: string;
|
|
7
|
+
fromContract: string | null;
|
|
8
|
+
toContract: string;
|
|
9
|
+
operationCount: number;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
refs: string[];
|
|
12
|
+
providedInvariants: string[];
|
|
13
|
+
}[];
|
|
14
|
+
}, {}>;
|
|
15
|
+
type MigrationSpaceListEntry = typeof migrationSpaceListEntrySchema.infer;
|
|
16
|
+
declare const migrationListResultSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
17
|
+
ok: true;
|
|
18
|
+
summary: string;
|
|
19
|
+
spaces: {
|
|
20
|
+
space: string;
|
|
21
|
+
migrations: {
|
|
22
|
+
name: string;
|
|
23
|
+
hash: string;
|
|
24
|
+
fromContract: string | null;
|
|
25
|
+
toContract: string;
|
|
26
|
+
operationCount: number;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
refs: string[];
|
|
29
|
+
providedInvariants: string[];
|
|
30
|
+
}[];
|
|
31
|
+
}[];
|
|
32
|
+
}, {}>;
|
|
33
|
+
type MigrationListResult = typeof migrationListResultSchema.infer;
|
|
34
|
+
declare const migrationSpaceGraphEntrySchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
35
|
+
space: string;
|
|
36
|
+
contracts: {
|
|
37
|
+
hash: string;
|
|
38
|
+
refs: string[];
|
|
39
|
+
}[];
|
|
40
|
+
migrations: {
|
|
41
|
+
name: string;
|
|
42
|
+
hash: string;
|
|
43
|
+
fromContract: string | null;
|
|
44
|
+
toContract: string;
|
|
45
|
+
}[];
|
|
46
|
+
}, {}>;
|
|
47
|
+
type MigrationSpaceGraphEntry = typeof migrationSpaceGraphEntrySchema.infer;
|
|
48
|
+
declare const migrationStatusEntrySchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
49
|
+
name: string;
|
|
50
|
+
hash: string;
|
|
51
|
+
fromContract: string | null;
|
|
52
|
+
toContract: string;
|
|
53
|
+
operationCount: number;
|
|
54
|
+
createdAt: string;
|
|
55
|
+
refs: string[];
|
|
56
|
+
providedInvariants: string[];
|
|
57
|
+
status: "applied" | "pending" | null;
|
|
58
|
+
}, {}>;
|
|
59
|
+
type MigrationStatusEntry = typeof migrationStatusEntrySchema.infer;
|
|
60
|
+
declare const statusDiagnosticSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
61
|
+
code: "CONTRACT.UNREADABLE";
|
|
62
|
+
severity: "warn" | "info";
|
|
63
|
+
message: string;
|
|
64
|
+
hints: string[];
|
|
65
|
+
} | {
|
|
66
|
+
code: "MIGRATION.MARKER_NOT_IN_HISTORY";
|
|
67
|
+
severity: "warn" | "info";
|
|
68
|
+
message: string;
|
|
69
|
+
hints: string[];
|
|
70
|
+
} | {
|
|
71
|
+
code: "MIGRATION.MISSING_INVARIANTS";
|
|
72
|
+
invariants: string[];
|
|
73
|
+
message: string;
|
|
74
|
+
ref?: string;
|
|
75
|
+
}, {}>;
|
|
76
|
+
type StatusDiagnosticJson = typeof statusDiagnosticSchema.infer;
|
|
77
|
+
declare const migrationStatusSpaceSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
78
|
+
space: string;
|
|
79
|
+
currentContract: string | null;
|
|
80
|
+
targetContract: string;
|
|
81
|
+
migrations: {
|
|
82
|
+
name: string;
|
|
83
|
+
hash: string;
|
|
84
|
+
fromContract: string | null;
|
|
85
|
+
toContract: string;
|
|
86
|
+
operationCount: number;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
refs: string[];
|
|
89
|
+
providedInvariants: string[];
|
|
90
|
+
status: "applied" | "pending" | null;
|
|
91
|
+
}[];
|
|
92
|
+
}, {}>;
|
|
93
|
+
type MigrationStatusSpace = typeof migrationStatusSpaceSchema.infer;
|
|
94
|
+
declare const migrationStatusJsonResultSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
95
|
+
ok: true;
|
|
96
|
+
summary: string;
|
|
97
|
+
spaces: {
|
|
98
|
+
space: string;
|
|
99
|
+
currentContract: string | null;
|
|
100
|
+
targetContract: string;
|
|
101
|
+
migrations: {
|
|
102
|
+
name: string;
|
|
103
|
+
hash: string;
|
|
104
|
+
fromContract: string | null;
|
|
105
|
+
toContract: string;
|
|
106
|
+
operationCount: number;
|
|
107
|
+
createdAt: string;
|
|
108
|
+
refs: string[];
|
|
109
|
+
providedInvariants: string[];
|
|
110
|
+
status: "applied" | "pending" | null;
|
|
111
|
+
}[];
|
|
112
|
+
}[];
|
|
113
|
+
diagnostics: ({
|
|
114
|
+
code: "CONTRACT.UNREADABLE";
|
|
115
|
+
severity: "warn" | "info";
|
|
116
|
+
message: string;
|
|
117
|
+
hints: string[];
|
|
118
|
+
} | {
|
|
119
|
+
code: "MIGRATION.MARKER_NOT_IN_HISTORY";
|
|
120
|
+
severity: "warn" | "info";
|
|
121
|
+
message: string;
|
|
122
|
+
hints: string[];
|
|
123
|
+
} | {
|
|
124
|
+
code: "MIGRATION.MISSING_INVARIANTS";
|
|
125
|
+
invariants: string[];
|
|
126
|
+
message: string;
|
|
127
|
+
ref?: string;
|
|
128
|
+
})[];
|
|
129
|
+
}, {}>;
|
|
130
|
+
type MigrationStatusResult = typeof migrationStatusJsonResultSchema.infer;
|
|
131
|
+
declare const migrationLogResultSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
132
|
+
ok: true;
|
|
133
|
+
summary: string;
|
|
134
|
+
records: {
|
|
135
|
+
space: string;
|
|
136
|
+
name: string;
|
|
137
|
+
hash: string;
|
|
138
|
+
fromContract: string | null;
|
|
139
|
+
toContract: string;
|
|
140
|
+
appliedAt: string;
|
|
141
|
+
operationCount: number;
|
|
142
|
+
}[];
|
|
143
|
+
}, {}>;
|
|
144
|
+
type MigrationLogResult = typeof migrationLogResultSchema.infer;
|
|
145
|
+
declare const migrationShowResultSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
146
|
+
ok: true;
|
|
147
|
+
summary: string;
|
|
148
|
+
migration: {
|
|
149
|
+
space: string;
|
|
150
|
+
name: string;
|
|
151
|
+
hash: string;
|
|
152
|
+
fromContract: string | null;
|
|
153
|
+
toContract: string;
|
|
154
|
+
createdAt: string;
|
|
155
|
+
operations: {
|
|
156
|
+
id: string;
|
|
157
|
+
label: string;
|
|
158
|
+
operationClass: string;
|
|
159
|
+
}[];
|
|
160
|
+
preview: {
|
|
161
|
+
statements: {
|
|
162
|
+
text: string;
|
|
163
|
+
language: string;
|
|
164
|
+
}[];
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
}, {}>;
|
|
168
|
+
type MigrationShowResult = typeof migrationShowResultSchema.infer;
|
|
169
|
+
declare const checkFailureSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
170
|
+
space: string;
|
|
171
|
+
code: string;
|
|
172
|
+
where: string;
|
|
173
|
+
why: string;
|
|
174
|
+
fix: string;
|
|
175
|
+
}, {}>;
|
|
176
|
+
type CheckFailure = typeof checkFailureSchema.infer;
|
|
177
|
+
declare const migrationCheckResultSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
178
|
+
ok: boolean;
|
|
179
|
+
failures: {
|
|
180
|
+
space: string;
|
|
181
|
+
code: string;
|
|
182
|
+
where: string;
|
|
183
|
+
why: string;
|
|
184
|
+
fix: string;
|
|
185
|
+
}[];
|
|
186
|
+
summary: string;
|
|
187
|
+
}, {}>;
|
|
188
|
+
type MigrationCheckResult = typeof migrationCheckResultSchema.infer;
|
|
189
|
+
//#endregion
|
|
190
|
+
export { MigrationShowResult as a, MigrationStatusEntry as c, StatusDiagnosticJson as d, migrationCheckResultSchema as f, MigrationLogResult as i, MigrationStatusResult as l, MigrationCheckResult as n, MigrationSpaceGraphEntry as o, migrationStatusJsonResultSchema as p, MigrationListResult as r, MigrationSpaceListEntry as s, CheckFailure as t, MigrationStatusSpace as u };
|
|
191
|
+
//# sourceMappingURL=schemas-CeGMYFYX.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas-CeGMYFYX.d.mts","names":[],"sources":["../src/commands/json/schemas.ts"],"mappings":";cA6Ba,6BAAA,gDAA6B,UAAA;;;;;;;;;;;;;KAK9B,uBAAA,UAAiC,6BAAA,CAA8B,KAAK;AAAA,cAEnE,yBAAA,gDAAyB,UAAA;;;;;;;;;;;;;;;;;KAM1B,mBAAA,UAA6B,yBAAA,CAA0B,KAAK;AAAA,cAW3D,8BAAA,gDAA8B,UAAA;;;;;;;;;;;;;KAM/B,wBAAA,UAAkC,8BAAA,CAA+B,KAAK;AAAA,cAUrE,0BAAA,gDAA0B,UAAA;;;;;;;;;;;KAM3B,oBAAA,UAA8B,0BAAA,CAA2B,KAAK;AAAA,cAuB7D,sBAAA,gDAAsB,UAAA;;;;;;;;;;;;;;;;KAIvB,oBAAA,UAA8B,sBAAA,CAAuB,KAAK;AAAA,cAEzD,0BAAA,gDAA0B,UAAA;;;;;;;;;;;;;;;;KAO3B,oBAAA,UAA8B,0BAAA,CAA2B,KAAK;AAAA,cAE7D,+BAAA,gDAA+B,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOhC,qBAAA,UAA+B,+BAAA,CAAgC,KAAK;AAAA,cAcnE,wBAAA,gDAAwB,UAAA;;;;;;;;;;;;;KAMzB,kBAAA,UAA4B,wBAAA,CAAyB,KAAK;AAAA,cA8BzD,yBAAA,gDAAyB,UAAA;;;;;;;;;;;;;;;;;;;;;;;KAM1B,mBAAA,UAA6B,yBAAA,CAA0B,KAAK;AAAA,cAE3D,kBAAA,gDAAkB,UAAA;;;;;;;KAQnB,YAAA,UAAsB,kBAAA,CAAmB,KAAK;AAAA,cAE7C,0BAAA,gDAA0B,UAAA;;;;;;;;;;;KAM3B,oBAAA,UAA8B,0BAAA,CAA2B,KAAK"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { type } from "arktype";
|
|
2
|
+
//#region src/commands/json/schemas.ts
|
|
3
|
+
const migrationEntrySchema = type({
|
|
4
|
+
name: "string",
|
|
5
|
+
hash: "string",
|
|
6
|
+
fromContract: "string | null",
|
|
7
|
+
toContract: "string",
|
|
8
|
+
operationCount: "number",
|
|
9
|
+
createdAt: "string",
|
|
10
|
+
refs: "string[]",
|
|
11
|
+
providedInvariants: "string[]"
|
|
12
|
+
});
|
|
13
|
+
const contractRefSchema = type({
|
|
14
|
+
hash: "string",
|
|
15
|
+
refs: "string[]"
|
|
16
|
+
});
|
|
17
|
+
const successEnvelopeBaseSchema = type({
|
|
18
|
+
ok: "true",
|
|
19
|
+
summary: "string"
|
|
20
|
+
});
|
|
21
|
+
const migrationSpaceListEntrySchema = type({
|
|
22
|
+
space: "string",
|
|
23
|
+
migrations: migrationEntrySchema.array()
|
|
24
|
+
});
|
|
25
|
+
successEnvelopeBaseSchema.and(type({ spaces: migrationSpaceListEntrySchema.array() }));
|
|
26
|
+
const graphMigrationSchema = type({
|
|
27
|
+
name: "string",
|
|
28
|
+
hash: "string",
|
|
29
|
+
fromContract: "string | null",
|
|
30
|
+
toContract: "string"
|
|
31
|
+
});
|
|
32
|
+
const migrationSpaceGraphEntrySchema = type({
|
|
33
|
+
space: "string",
|
|
34
|
+
contracts: contractRefSchema.array(),
|
|
35
|
+
migrations: graphMigrationSchema.array()
|
|
36
|
+
});
|
|
37
|
+
successEnvelopeBaseSchema.and(type({ spaces: migrationSpaceGraphEntrySchema.array() }));
|
|
38
|
+
const migrationStatusEntrySchema = migrationEntrySchema.and(type({ status: "\"applied\" | \"pending\" | null" }));
|
|
39
|
+
const contractUnreadableDiagnosticSchema = type({
|
|
40
|
+
code: "\"CONTRACT.UNREADABLE\"",
|
|
41
|
+
severity: "\"warn\" | \"info\"",
|
|
42
|
+
message: "string",
|
|
43
|
+
hints: "string[]"
|
|
44
|
+
});
|
|
45
|
+
const markerNotInHistoryDiagnosticSchema = type({
|
|
46
|
+
code: "\"MIGRATION.MARKER_NOT_IN_HISTORY\"",
|
|
47
|
+
severity: "\"warn\" | \"info\"",
|
|
48
|
+
message: "string",
|
|
49
|
+
hints: "string[]"
|
|
50
|
+
});
|
|
51
|
+
const missingInvariantsDiagnosticSchema = type({
|
|
52
|
+
code: "\"MIGRATION.MISSING_INVARIANTS\"",
|
|
53
|
+
"ref?": "string",
|
|
54
|
+
invariants: "string[]",
|
|
55
|
+
message: "string"
|
|
56
|
+
});
|
|
57
|
+
const statusDiagnosticSchema = contractUnreadableDiagnosticSchema.or(markerNotInHistoryDiagnosticSchema).or(missingInvariantsDiagnosticSchema);
|
|
58
|
+
const migrationStatusSpaceSchema = type({
|
|
59
|
+
space: "string",
|
|
60
|
+
currentContract: "string | null",
|
|
61
|
+
targetContract: "string",
|
|
62
|
+
migrations: migrationStatusEntrySchema.array()
|
|
63
|
+
});
|
|
64
|
+
const migrationStatusJsonResultSchema = successEnvelopeBaseSchema.and(type({
|
|
65
|
+
spaces: migrationStatusSpaceSchema.array(),
|
|
66
|
+
diagnostics: statusDiagnosticSchema.array()
|
|
67
|
+
}));
|
|
68
|
+
const ledgerRecordSchema = type({
|
|
69
|
+
space: "string",
|
|
70
|
+
name: "string",
|
|
71
|
+
hash: "string",
|
|
72
|
+
fromContract: "string | null",
|
|
73
|
+
toContract: "string",
|
|
74
|
+
appliedAt: "string",
|
|
75
|
+
operationCount: "number"
|
|
76
|
+
});
|
|
77
|
+
successEnvelopeBaseSchema.and(type({ records: ledgerRecordSchema.array() }));
|
|
78
|
+
const showOperationSchema = type({
|
|
79
|
+
id: "string",
|
|
80
|
+
label: "string",
|
|
81
|
+
operationClass: "string"
|
|
82
|
+
});
|
|
83
|
+
const showPreviewStatementSchema = type({
|
|
84
|
+
text: "string",
|
|
85
|
+
language: "string"
|
|
86
|
+
});
|
|
87
|
+
const showMigrationSchema = type({
|
|
88
|
+
space: "string",
|
|
89
|
+
name: "string",
|
|
90
|
+
hash: "string",
|
|
91
|
+
fromContract: "string | null",
|
|
92
|
+
toContract: "string",
|
|
93
|
+
createdAt: "string",
|
|
94
|
+
operations: showOperationSchema.array(),
|
|
95
|
+
preview: type({ statements: showPreviewStatementSchema.array() })
|
|
96
|
+
});
|
|
97
|
+
successEnvelopeBaseSchema.and(type({ migration: showMigrationSchema }));
|
|
98
|
+
const migrationCheckResultSchema = type({
|
|
99
|
+
ok: "boolean",
|
|
100
|
+
failures: type({
|
|
101
|
+
space: "string",
|
|
102
|
+
code: "string",
|
|
103
|
+
where: "string",
|
|
104
|
+
why: "string",
|
|
105
|
+
fix: "string"
|
|
106
|
+
}).array(),
|
|
107
|
+
summary: "string"
|
|
108
|
+
});
|
|
109
|
+
//#endregion
|
|
110
|
+
export { migrationStatusJsonResultSchema as n, migrationCheckResultSchema as t };
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=schemas-KhXMzNA_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas-KhXMzNA_.mjs","names":[],"sources":["../src/commands/json/schemas.ts"],"sourcesContent":["import { type } from 'arktype';\n\nexport const migrationEntrySchema = type({\n name: 'string',\n hash: 'string',\n fromContract: 'string | null',\n toContract: 'string',\n operationCount: 'number',\n createdAt: 'string',\n refs: 'string[]',\n providedInvariants: 'string[]',\n});\n\nexport type MigrationEntry = typeof migrationEntrySchema.infer;\n\nexport const contractRefSchema = type({\n hash: 'string',\n refs: 'string[]',\n});\n\nexport type ContractRef = typeof contractRefSchema.infer;\n\nexport const successEnvelopeBaseSchema = type({\n ok: 'true',\n summary: 'string',\n});\n\nexport type SuccessEnvelopeBase = typeof successEnvelopeBaseSchema.infer;\n\nexport const migrationSpaceListEntrySchema = type({\n space: 'string',\n migrations: migrationEntrySchema.array(),\n});\n\nexport type MigrationSpaceListEntry = typeof migrationSpaceListEntrySchema.infer;\n\nexport const migrationListResultSchema = successEnvelopeBaseSchema.and(\n type({\n spaces: migrationSpaceListEntrySchema.array(),\n }),\n);\n\nexport type MigrationListResult = typeof migrationListResultSchema.infer;\n\nexport const graphMigrationSchema = type({\n name: 'string',\n hash: 'string',\n fromContract: 'string | null',\n toContract: 'string',\n});\n\nexport type GraphMigration = typeof graphMigrationSchema.infer;\n\nexport const migrationSpaceGraphEntrySchema = type({\n space: 'string',\n contracts: contractRefSchema.array(),\n migrations: graphMigrationSchema.array(),\n});\n\nexport type MigrationSpaceGraphEntry = typeof migrationSpaceGraphEntrySchema.infer;\n\nexport const migrationGraphJsonResultSchema = successEnvelopeBaseSchema.and(\n type({\n spaces: migrationSpaceGraphEntrySchema.array(),\n }),\n);\n\nexport type MigrationGraphJsonResult = typeof migrationGraphJsonResultSchema.infer;\n\nexport const migrationStatusEntrySchema = migrationEntrySchema.and(\n type({\n status: '\"applied\" | \"pending\" | null',\n }),\n);\n\nexport type MigrationStatusEntry = typeof migrationStatusEntrySchema.infer;\n\nconst contractUnreadableDiagnosticSchema = type({\n code: '\"CONTRACT.UNREADABLE\"',\n severity: '\"warn\" | \"info\"',\n message: 'string',\n hints: 'string[]',\n});\n\nconst markerNotInHistoryDiagnosticSchema = type({\n code: '\"MIGRATION.MARKER_NOT_IN_HISTORY\"',\n severity: '\"warn\" | \"info\"',\n message: 'string',\n hints: 'string[]',\n});\n\nconst missingInvariantsDiagnosticSchema = type({\n code: '\"MIGRATION.MISSING_INVARIANTS\"',\n 'ref?': 'string',\n invariants: 'string[]',\n message: 'string',\n});\n\nexport const statusDiagnosticSchema = contractUnreadableDiagnosticSchema\n .or(markerNotInHistoryDiagnosticSchema)\n .or(missingInvariantsDiagnosticSchema);\n\nexport type StatusDiagnosticJson = typeof statusDiagnosticSchema.infer;\n\nexport const migrationStatusSpaceSchema = type({\n space: 'string',\n currentContract: 'string | null',\n targetContract: 'string',\n migrations: migrationStatusEntrySchema.array(),\n});\n\nexport type MigrationStatusSpace = typeof migrationStatusSpaceSchema.infer;\n\nexport const migrationStatusJsonResultSchema = successEnvelopeBaseSchema.and(\n type({\n spaces: migrationStatusSpaceSchema.array(),\n diagnostics: statusDiagnosticSchema.array(),\n }),\n);\n\nexport type MigrationStatusResult = typeof migrationStatusJsonResultSchema.infer;\n\nexport const ledgerRecordSchema = type({\n space: 'string',\n name: 'string',\n hash: 'string',\n fromContract: 'string | null',\n toContract: 'string',\n appliedAt: 'string',\n operationCount: 'number',\n});\n\nexport type LedgerRecord = typeof ledgerRecordSchema.infer;\n\nexport const migrationLogResultSchema = successEnvelopeBaseSchema.and(\n type({\n records: ledgerRecordSchema.array(),\n }),\n);\n\nexport type MigrationLogResult = typeof migrationLogResultSchema.infer;\n\nexport const showOperationSchema = type({\n id: 'string',\n label: 'string',\n operationClass: 'string',\n});\n\nexport type ShowOperation = typeof showOperationSchema.infer;\n\nexport const showPreviewStatementSchema = type({\n text: 'string',\n language: 'string',\n});\n\nexport const showMigrationSchema = type({\n space: 'string',\n name: 'string',\n hash: 'string',\n fromContract: 'string | null',\n toContract: 'string',\n createdAt: 'string',\n operations: showOperationSchema.array(),\n preview: type({\n statements: showPreviewStatementSchema.array(),\n }),\n});\n\nexport type ShowMigration = typeof showMigrationSchema.infer;\n\nexport const migrationShowResultSchema = successEnvelopeBaseSchema.and(\n type({\n migration: showMigrationSchema,\n }),\n);\n\nexport type MigrationShowResult = typeof migrationShowResultSchema.infer;\n\nexport const checkFailureSchema = type({\n space: 'string',\n code: 'string',\n where: 'string',\n why: 'string',\n fix: 'string',\n});\n\nexport type CheckFailure = typeof checkFailureSchema.infer;\n\nexport const migrationCheckResultSchema = type({\n ok: 'boolean',\n failures: checkFailureSchema.array(),\n summary: 'string',\n});\n\nexport type MigrationCheckResult = typeof migrationCheckResultSchema.infer;\n"],"mappings":";;AAEA,MAAa,uBAAuB,KAAK;CACvC,MAAM;CACN,MAAM;CACN,cAAc;CACd,YAAY;CACZ,gBAAgB;CAChB,WAAW;CACX,MAAM;CACN,oB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,WAAW;CACX,gBAAgB;AAClB,CAAC;AAIuC,0BAA0B,IAChE,KAAK,EACH,SAAS,mBAAmB,MAAM,EACpC,CAAC,CACH;AAIA,MAAa,sBAAsB,KAAK;CACtC,IAAI;CACJ,OAAO;CACP,gBAAgB;AAClB,CAAC;AAID,MAAa,6BAA6B,KAAK;CAC7C,MAAM;CACN,UAAU;AACZ,CAAC;AAED,MAAa,sBAAsB,KAAK;CACtC,OAAO;CACP,MAAM;CACN,MAAM;CACN,cAAc;CACd,YAAY;CACZ,WAAW;CACX,YAAY,oBAAoB,MAAM;CACtC,SAAS,KAAK,EACZ,YAAY,2BAA2B,MAAM,EAC/C,CAAC;AACH,CAAC;AAIwC,0BAA0B,IACjE,KAAK,EACH,WAAW,oBACb,CAAC,CACH;AAcA,MAAa,6BAA6B,KAAK;CAC7C,IAAI;CACJ,UAZgC,KAAK;EACrC,OAAO;EACP,MAAM;EACN,OAAO;EACP,KAAK;EACL,KAAK;CACP,CAMY,CAAA,CAAmB,MAAM;CACnC,SAAS;AACX,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { D as isCI, O as formatCommandHelp, _ as createTerminalUI, g as parseGlobalFlagsOrExit, h as parseGlobalFlags, l as setCommandDescriptions, t as addGlobalOptions, u as setCommandExamples } from "./command-helpers-DGMvGBeX.mjs";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { readUserConfig, resolveGating, userConfigPath, writeUserConfig } from "@prisma-next/cli-telemetry";
|
|
4
|
+
//#region src/commands/telemetry/status.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the same gate the runtime uses (CI check + `resolveGating`) and
|
|
7
|
+
* projects it into a user-facing status. Pure read: never mints, never
|
|
8
|
+
* writes. The `installationId` value itself is never surfaced — only its
|
|
9
|
+
* presence — so `status` discloses nothing identifying.
|
|
10
|
+
*/
|
|
11
|
+
function resolveTelemetryStatus(inputs) {
|
|
12
|
+
const config = readUserConfig();
|
|
13
|
+
const configPath = userConfigPath();
|
|
14
|
+
const installationIdStored = typeof config.installationId === "string" && config.installationId.length > 0;
|
|
15
|
+
if (inputs.inCI) return {
|
|
16
|
+
enabled: false,
|
|
17
|
+
reason: "ci",
|
|
18
|
+
configPath,
|
|
19
|
+
installationIdStored
|
|
20
|
+
};
|
|
21
|
+
const gating = resolveGating({
|
|
22
|
+
env: inputs.env,
|
|
23
|
+
config
|
|
24
|
+
});
|
|
25
|
+
if (!gating.enabled) return {
|
|
26
|
+
enabled: false,
|
|
27
|
+
reason: gating.reason === "env-override" ? "env-opt-out" : "stored-opt-out",
|
|
28
|
+
configPath,
|
|
29
|
+
installationIdStored
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
enabled: true,
|
|
33
|
+
reason: config.enableTelemetry === true ? "stored-opt-in" : "default-on",
|
|
34
|
+
configPath,
|
|
35
|
+
installationIdStored
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const REASON_EXPLANATION = {
|
|
39
|
+
ci: "CI environment detected — telemetry is hard-disabled.",
|
|
40
|
+
"env-opt-out": "an environment opt-out is set (DO_NOT_TRACK / PRISMA_NEXT_DISABLE_TELEMETRY).",
|
|
41
|
+
"stored-opt-out": "\"enableTelemetry\": false is stored in your config.",
|
|
42
|
+
"stored-opt-in": "\"enableTelemetry\": true is stored in your config.",
|
|
43
|
+
"default-on": "no explicit choice is stored, so the opt-out default applies."
|
|
44
|
+
};
|
|
45
|
+
function formatTelemetryStatusLines(status) {
|
|
46
|
+
return [
|
|
47
|
+
`Telemetry is ${status.enabled ? "enabled" : "disabled"}: ${REASON_EXPLANATION[status.reason]}`,
|
|
48
|
+
`Config file: ${status.configPath}`,
|
|
49
|
+
`Installation ID: ${status.installationIdStored ? "stored" : "not stored"}`
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/commands/telemetry/index.ts
|
|
54
|
+
function createTelemetryStatusCommand() {
|
|
55
|
+
const command = new Command("status");
|
|
56
|
+
setCommandDescriptions(command, "Show whether anonymous CLI telemetry is enabled and why", "Reports whether telemetry is currently enabled or disabled and the reason\n(default-on, stored opt-out, environment opt-out, or CI), the path to your\nuser-level config file, and whether an installation ID has been stored.\nRead-only: never sends an event, never mints an ID, never writes anything.");
|
|
57
|
+
return addGlobalOptions(command).action((options) => {
|
|
58
|
+
const flags = parseGlobalFlagsOrExit(options);
|
|
59
|
+
const ui = createTerminalUI(flags);
|
|
60
|
+
const status = resolveTelemetryStatus({
|
|
61
|
+
env: process.env,
|
|
62
|
+
inCI: isCI()
|
|
63
|
+
});
|
|
64
|
+
if (flags.json) ui.output(JSON.stringify(status));
|
|
65
|
+
else for (const line of formatTelemetryStatusLines(status)) ui.output(line);
|
|
66
|
+
process.exit(0);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function createTelemetryEnableCommand() {
|
|
70
|
+
const command = new Command("enable");
|
|
71
|
+
setCommandDescriptions(command, "Enable anonymous CLI telemetry", "Stores \"enableTelemetry\": true in your user-level config and mints an\ninstallation ID if one is not already stored.");
|
|
72
|
+
return addGlobalOptions(command).action((options) => {
|
|
73
|
+
const flags = parseGlobalFlagsOrExit(options);
|
|
74
|
+
writeUserConfig({ enableTelemetry: true });
|
|
75
|
+
const ui = createTerminalUI(flags);
|
|
76
|
+
if (flags.json) ui.output(JSON.stringify({
|
|
77
|
+
enableTelemetry: true,
|
|
78
|
+
configPath: userConfigPath()
|
|
79
|
+
}));
|
|
80
|
+
else ui.output(`Telemetry enabled. Preference stored in ${userConfigPath()}.`);
|
|
81
|
+
process.exit(0);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function createTelemetryDisableCommand() {
|
|
85
|
+
const command = new Command("disable");
|
|
86
|
+
setCommandDescriptions(command, "Disable anonymous CLI telemetry", "Stores \"enableTelemetry\": false in your user-level config. No installation\nID is minted and no event is sent.");
|
|
87
|
+
return addGlobalOptions(command).action((options) => {
|
|
88
|
+
const flags = parseGlobalFlagsOrExit(options);
|
|
89
|
+
writeUserConfig({ enableTelemetry: false });
|
|
90
|
+
const ui = createTerminalUI(flags);
|
|
91
|
+
if (flags.json) ui.output(JSON.stringify({
|
|
92
|
+
enableTelemetry: false,
|
|
93
|
+
configPath: userConfigPath()
|
|
94
|
+
}));
|
|
95
|
+
else ui.output(`Telemetry disabled. Preference stored in ${userConfigPath()}.`);
|
|
96
|
+
process.exit(0);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function createTelemetryCommand() {
|
|
100
|
+
const command = new Command("telemetry");
|
|
101
|
+
setCommandDescriptions(command, "Inspect and change anonymous CLI telemetry", "Show telemetry status, or enable / disable anonymous CLI usage data.\nTelemetry is on by default (opt-out); see https://prisma-next.dev/docs/cli/telemetry\nfor what is collected and why.");
|
|
102
|
+
setCommandExamples(command, [
|
|
103
|
+
"prisma-next telemetry status",
|
|
104
|
+
"prisma-next telemetry disable",
|
|
105
|
+
"prisma-next telemetry enable"
|
|
106
|
+
]);
|
|
107
|
+
command.configureHelp({
|
|
108
|
+
formatHelp: (cmd) => formatCommandHelp({
|
|
109
|
+
command: cmd,
|
|
110
|
+
flags: parseGlobalFlags({})
|
|
111
|
+
}),
|
|
112
|
+
subcommandDescription: () => ""
|
|
113
|
+
});
|
|
114
|
+
command.addCommand(createTelemetryStatusCommand());
|
|
115
|
+
command.addCommand(createTelemetryEnableCommand());
|
|
116
|
+
command.addCommand(createTelemetryDisableCommand());
|
|
117
|
+
return command;
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { createTelemetryCommand as t };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=telemetry-BIM4beEO.mjs.map
|