@prisma-next/family-mongo 0.12.0-dev.17 → 0.12.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,53 +0,0 @@
1
- import type { ControlPolicy } from '@prisma-next/contract/types';
2
- import type {
3
- SchemaIssue,
4
- SchemaVerificationNode,
5
- VerifierOutcome,
6
- } from '@prisma-next/framework-components/control';
7
- import { verifierDisposition } from './verifier-disposition';
8
-
9
- /**
10
- * Reconciles a control-policy disposition with the Mongo family's strict-mode
11
- * contract for live-only extras — the single point where `strict` and the
12
- * control policy meet.
13
- *
14
- * The control policy decides first; only a `fail` is reconciled against the
15
- * caller's base node status. Call sites stamp a live-only extra with
16
- * `strict ? 'fail' : 'warn'` and a declared missing/mismatch with `fail`, so
17
- * this one step encodes the whole matrix:
18
- *
19
- * | live-vs-declared | strict | non-strict |
20
- * |-------------------------------------|----------|------------|
21
- * | declared missing / mismatch | fail | fail |
22
- * | live-only extra (managed/tolerated) | fail | warn |
23
- * | live-only extra (external) | suppress (extras ignored, both modes) |
24
- * | anything (observed) | warn (both modes) |
25
- *
26
- * `tolerated` no longer diverges from `managed` on a non-strict extra index:
27
- * both soften to `warn`, because the softening comes from the base status the
28
- * caller already computed from `strict`, not from per-policy special-casing.
29
- */
30
- function reconcileMongoOutcome(
31
- controlPolicy: ControlPolicy,
32
- issueKind: SchemaIssue['kind'],
33
- baseStatus: SchemaVerificationNode['status'],
34
- ): VerifierOutcome {
35
- const disposition = verifierDisposition(controlPolicy, issueKind);
36
- return disposition === 'fail' ? baseStatus : disposition;
37
- }
38
-
39
- export function emitMongoIssueAndNodeUnderControlPolicy(
40
- controlPolicy: ControlPolicy,
41
- issue: SchemaIssue,
42
- node: SchemaVerificationNode,
43
- issues: SchemaIssue[],
44
- nodes: SchemaVerificationNode[],
45
- ): VerifierOutcome {
46
- const outcome = reconcileMongoOutcome(controlPolicy, issue.kind, node.status);
47
- if (outcome === 'suppress') {
48
- return 'suppress';
49
- }
50
- issues.push(issue);
51
- nodes.push({ ...node, status: outcome });
52
- return outcome;
53
- }
@@ -1,42 +0,0 @@
1
- import type { ControlPolicy } from '@prisma-next/contract/types';
2
- import type {
3
- SchemaIssue,
4
- VerifierIssueCategory,
5
- VerifierOutcome,
6
- } from '@prisma-next/framework-components/control';
7
- import { dispositionForCategory } from '@prisma-next/framework-components/control';
8
-
9
- /**
10
- * Classifies the verifier issue kinds the Mongo schema differ emits into the
11
- * target-neutral categories the framework grades. Mongo only emits the kinds
12
- * listed below (missing/extra collections, missing/extra indexes, missing/extra
13
- * validators, and validator/options mismatches coded as `type_mismatch`); any
14
- * other kind never reaches this classifier and is graded conservatively as a
15
- * declared-incompatible divergence. Mongo owns this mapping rather than
16
- * importing the SQL classifier — the two families share only the framework's
17
- * category grading.
18
- */
19
- export function classifyMongoVerifierIssueKind(kind: SchemaIssue['kind']): VerifierIssueCategory {
20
- switch (kind) {
21
- case 'extra_table':
22
- return 'extraTopLevelObject';
23
- case 'extra_index':
24
- case 'extra_validator':
25
- return 'extraAuxiliary';
26
- case 'missing_table':
27
- case 'type_missing':
28
- return 'declaredMissing';
29
- case 'index_mismatch':
30
- case 'type_mismatch':
31
- return 'declaredIncompatible';
32
- default:
33
- return 'declaredIncompatible';
34
- }
35
- }
36
-
37
- export function verifierDisposition(
38
- controlPolicy: ControlPolicy,
39
- issueKind: SchemaIssue['kind'],
40
- ): VerifierOutcome {
41
- return dispositionForCategory(controlPolicy, classifyMongoVerifierIssueKind(issueKind));
42
- }
@@ -1,4 +0,0 @@
1
- export {
2
- defaultMongoDomainNamespaceId,
3
- defaultMongoStorageNamespaceId,
4
- } from '../core/default-namespace';