laranex-schema-viewer-ui 0.2.0 → 0.3.0

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.
Files changed (269) hide show
  1. package/NOTICE +11 -0
  2. package/README.md +15 -2
  3. package/contract/check.mjs +7 -3
  4. package/contract/conformance/comparison/column-fields-same-driver.json +387 -0
  5. package/contract/conformance/comparison/combined-declared-only.json +275 -0
  6. package/contract/conformance/comparison/constraints.json +356 -0
  7. package/contract/conformance/comparison/cross-driver-types.json +453 -0
  8. package/contract/conformance/comparison/foreign-key-matching.json +615 -0
  9. package/contract/conformance/comparison/incomplete-coverage.json +214 -0
  10. package/contract/conformance/comparison/incomplete-limit.json +249 -0
  11. package/contract/conformance/comparison/index-matching.json +588 -0
  12. package/contract/conformance/comparison/primary-key.json +443 -0
  13. package/contract/conformance/comparison/referential-actions-mysql.json +321 -0
  14. package/contract/conformance/comparison/severity-overrides.json +283 -0
  15. package/contract/conformance/comparison/tables-missing-extra.json +306 -0
  16. package/contract/conformance/comparison/tenant-schemas-equal.json +329 -0
  17. package/contract/conformance/comparison/unnamed-duplicates.json +268 -0
  18. package/contract/conformance/comparison-diagnostics/both-sides-and-omitted.json +330 -0
  19. package/contract/conformance/comparison-diagnostics/complete.json +390 -0
  20. package/contract/conformance/comparison-diagnostics/coverage.json +405 -0
  21. package/contract/conformance/comparison-diagnostics/limit-zero.json +335 -0
  22. package/contract/conformance/comparison-diagnostics/omitted.json +370 -0
  23. package/contract/conformance/comparison-diagnostics/tenant-schema-label.json +162 -0
  24. package/contract/conformance/coverage-gaps/combined-document.json +71 -0
  25. package/contract/conformance/coverage-gaps/complete.json +53 -0
  26. package/contract/conformance/coverage-gaps/coverage-unknown.json +33 -0
  27. package/contract/conformance/coverage-gaps/declared-document.json +56 -0
  28. package/contract/conformance/coverage-gaps/default-schema-not-read.json +57 -0
  29. package/contract/conformance/coverage-gaps/default-schema-unknown.json +52 -0
  30. package/contract/conformance/coverage-gaps/feature-states.json +65 -0
  31. package/contract/conformance/coverage-gaps/features-then-schema.json +67 -0
  32. package/contract/conformance/coverage-gaps/not-applicable.json +50 -0
  33. package/contract/conformance/coverage-gaps/schema-not-read.json +58 -0
  34. package/contract/conformance/coverage-gaps/schemas-unknown.json +50 -0
  35. package/contract/conformance/gate/comparison-drift.json +346 -0
  36. package/contract/conformance/gate/diagnostics-only.json +257 -0
  37. package/contract/conformance/gate/extraction-warning-only.json +176 -0
  38. package/contract/conformance/gate/failed-inspection.json +183 -0
  39. package/contract/conformance/gate/incomplete-comparison.json +310 -0
  40. package/contract/conformance/gate/incomplete-coverage.json +355 -0
  41. package/contract/conformance/gate/incomplete-required-coverage.json +233 -0
  42. package/contract/conformance/gate/invalid-document.json +52 -0
  43. package/contract/conformance/gate/migration-only.json +650 -0
  44. package/contract/conformance/gate/migration-unknown.json +315 -0
  45. package/contract/conformance/gate/newer-minor.json +352 -0
  46. package/contract/conformance/gate/not-a-document.json +37 -0
  47. package/contract/conformance/gate/partial-coverage.json +242 -0
  48. package/contract/conformance/gate/precedence.json +431 -0
  49. package/contract/conformance/gate/requested-missing.json +417 -0
  50. package/contract/conformance/gate/requested-none.json +245 -0
  51. package/contract/conformance/gate/requested-wildcard-empty.json +189 -0
  52. package/contract/conformance/gate/requested-wildcard.json +387 -0
  53. package/contract/conformance/gate/threshold-below-severity.json +312 -0
  54. package/contract/conformance/gate/threshold-likely-at-certainty.json +312 -0
  55. package/contract/conformance/gate/threshold-likely-below-certainty.json +312 -0
  56. package/contract/conformance/gate/unsupported-version.json +269 -0
  57. package/contract/conformance/gate/zero-comparisons.json +242 -0
  58. package/contract/conformance/graph/composite-unordered-pairs.json +1 -1
  59. package/contract/conformance/graph/cross-connection-foreign-key.json +1 -1
  60. package/contract/conformance/graph/cross-connection-relationship.json +1 -1
  61. package/contract/conformance/graph/duplicate-foreign-keys.json +1 -1
  62. package/contract/conformance/graph/duplicate-table-names.json +1 -1
  63. package/contract/conformance/graph/foreign-key-and-relationships.json +1 -1
  64. package/contract/conformance/graph/foreign-key-only.json +1 -1
  65. package/contract/conformance/graph/link-note.json +1 -1
  66. package/contract/conformance/graph/multiple-between-tables.json +1 -1
  67. package/contract/conformance/graph/pivot.json +1 -1
  68. package/contract/conformance/graph/polymorphic.json +1 -1
  69. package/contract/conformance/graph/relationship-only.json +1 -1
  70. package/contract/conformance/graph/self-reference.json +1 -1
  71. package/contract/conformance/graph/through.json +1 -1
  72. package/contract/conformance/graph/unresolved-endpoint.json +1 -1
  73. package/contract/conformance/inference/association-table-without-key.json +283 -0
  74. package/contract/conformance/inference/association-table.json +314 -0
  75. package/contract/conformance/inference/composite-foreign-key.json +295 -0
  76. package/contract/conformance/inference/covered-by-relationship.json +224 -0
  77. package/contract/conformance/inference/many-to-one.json +223 -0
  78. package/contract/conformance/inference/multiple-foreign-keys.json +318 -0
  79. package/contract/conformance/inference/multiple-models.json +241 -0
  80. package/contract/conformance/inference/one-to-one-unique-constraint.json +241 -0
  81. package/contract/conformance/inference/one-to-one-unique-index.json +423 -0
  82. package/contract/conformance/inference/self-reference.json +169 -0
  83. package/contract/conformance/inference/unconfirmed-foreign-key.json +223 -0
  84. package/contract/conformance/inference/unmapped-tables.json +273 -0
  85. package/contract/conformance/migrations/behind.json +64 -0
  86. package/contract/conformance/migrations/diverged.json +62 -0
  87. package/contract/conformance/migrations/history-unavailable.json +15 -0
  88. package/contract/conformance/migrations/merge-behind.json +80 -0
  89. package/contract/conformance/migrations/missing-parent-recorded.json +55 -0
  90. package/contract/conformance/migrations/multiple-heads-behind.json +68 -0
  91. package/contract/conformance/migrations/multiple-heads-up-to-date.json +67 -0
  92. package/contract/conformance/migrations/partial-history-behind.json +55 -0
  93. package/contract/conformance/migrations/partial-history-missing-pending.json +69 -0
  94. package/contract/conformance/migrations/uninitialized-without-history.json +13 -0
  95. package/contract/conformance/migrations/uninitialized.json +63 -0
  96. package/contract/conformance/migrations/unknown-revision.json +64 -0
  97. package/contract/conformance/migrations/up-to-date.json +61 -0
  98. package/contract/conformance/migrations/version-table-unreadable.json +59 -0
  99. package/contract/conformance/overrides/empty.json +9 -0
  100. package/contract/conformance/overrides/every-field.json +262 -0
  101. package/contract/conformance/overrides/field-of-another-type.json +32 -0
  102. package/contract/conformance/overrides/field-on-missing-or-extra.json +25 -0
  103. package/contract/conformance/overrides/malformed.json +37 -0
  104. package/contract/conformance/overrides/not-an-array.json +15 -0
  105. package/contract/conformance/overrides/repeated.json +41 -0
  106. package/contract/conformance/overrides/unknown-field.json +18 -0
  107. package/contract/conformance/overrides/unknown-values.json +32 -0
  108. package/contract/conformance/requests/duplicates.json +271 -0
  109. package/contract/conformance/requests/explicit-over-wildcard.json +212 -0
  110. package/contract/conformance/requests/explicit-pairs.json +192 -0
  111. package/contract/conformance/requests/no-requests.json +130 -0
  112. package/contract/conformance/requests/ordering.json +271 -0
  113. package/contract/conformance/requests/unknown-connection.json +218 -0
  114. package/contract/conformance/requests/wildcard-baseline-is-a-name.json +162 -0
  115. package/contract/conformance/requests/wildcard-declared-coverage.json +82 -0
  116. package/contract/conformance/requests/wildcard-default-schema.json +202 -0
  117. package/contract/conformance/requests/wildcard-no-match.json +180 -0
  118. package/contract/conformance/requests/wildcard-no-schemas.json +180 -0
  119. package/contract/conformance/requests/wildcard-other-connection.json +222 -0
  120. package/contract/conformance/requests/wildcard-tenants.json +202 -0
  121. package/contract/conformance/store/add-to-empty.json +596 -0
  122. package/contract/conformance/store/complete-drops-diagnostic.json +516 -0
  123. package/contract/conformance/store/idempotent.json +701 -0
  124. package/contract/conformance/store/replace.json +639 -0
  125. package/contract/fixtures/gate/invalid/checked-comparisons-unsorted.json +265 -0
  126. package/contract/fixtures/gate/invalid/comparison-finding-kind.json +264 -0
  127. package/contract/fixtures/gate/invalid/counts-mismatch.json +264 -0
  128. package/contract/fixtures/gate/invalid/exit-code-out-of-range.json +84 -0
  129. package/contract/fixtures/gate/invalid/finding-wrong-id.json +264 -0
  130. package/contract/fixtures/gate/invalid/findings-unsorted.json +264 -0
  131. package/contract/fixtures/gate/invalid/incomplete-reported-as-drift.json +84 -0
  132. package/contract/fixtures/gate/invalid/invalid-document-with-findings.json +34 -0
  133. package/contract/fixtures/gate/invalid/migration-finding-severity.json +264 -0
  134. package/contract/fixtures/gate/invalid/passed-flag-mismatch.json +264 -0
  135. package/contract/fixtures/gate/invalid/passed-with-qualifying-findings.json +264 -0
  136. package/contract/fixtures/gate/invalid/requested-unsorted.json +285 -0
  137. package/contract/fixtures/gate/invalid/unknown-error-kind.json +84 -0
  138. package/contract/fixtures/gate/valid/drift.json +258 -0
  139. package/contract/fixtures/gate/valid/incomplete.json +78 -0
  140. package/contract/fixtures/gate/valid/invalid.json +26 -0
  141. package/contract/fixtures/gate/valid/migrations.json +102 -0
  142. package/contract/fixtures/gate/valid/passed.json +58 -0
  143. package/contract/fixtures/gate/valid/requested.json +269 -0
  144. package/contract/fixtures/invalid/backs-check-constraint.json +5 -53
  145. package/contract/fixtures/invalid/column-subject-without-columns.json +642 -0
  146. package/contract/fixtures/invalid/comparison-omitted-but-complete.json +2232 -0
  147. package/contract/fixtures/invalid/comparison-same-scope.json +2749 -0
  148. package/contract/fixtures/invalid/comparison-summary-mismatch.json +2749 -0
  149. package/contract/fixtures/invalid/comparison-unknown-connection.json +2749 -0
  150. package/contract/fixtures/invalid/comparison-wrong-id.json +2749 -0
  151. package/contract/fixtures/invalid/coverage-claims-complete.json +12 -17
  152. package/contract/fixtures/invalid/coverage-for-wrong-source.json +4 -32
  153. package/contract/fixtures/invalid/diagnostic-unknown-subject.json +12 -17
  154. package/contract/fixtures/invalid/diagnostic-wrong-id.json +644 -0
  155. package/contract/fixtures/invalid/difference-changed-without-fields.json +2743 -0
  156. package/contract/fixtures/invalid/difference-key-names-schema.json +2749 -0
  157. package/contract/fixtures/invalid/difference-key-unknown-column.json +2749 -0
  158. package/contract/fixtures/invalid/difference-missing-with-target.json +2753 -0
  159. package/contract/fixtures/invalid/difference-side-outside-scope.json +2749 -0
  160. package/contract/fixtures/invalid/difference-side-wrong-entity.json +2749 -0
  161. package/contract/fixtures/invalid/difference-wrong-id.json +2749 -0
  162. package/contract/fixtures/invalid/differences-unsorted.json +2749 -0
  163. package/contract/fixtures/invalid/drift-without-both-sources.json +12 -17
  164. package/contract/fixtures/invalid/{index-columns-out-of-order.json → driver-alias.json} +6 -54
  165. package/contract/fixtures/invalid/duplicate-ids.json +5 -29
  166. package/contract/fixtures/invalid/foreign-key-across-connections.json +8 -26
  167. package/contract/fixtures/invalid/foreign-key-column-counts.json +5 -11
  168. package/contract/fixtures/invalid/foreign-key-unknown-target.json +5 -53
  169. package/contract/fixtures/invalid/index-part-column-and-expression.json +5 -53
  170. package/contract/fixtures/invalid/inferred-covered-foreign-key.json +2176 -0
  171. package/contract/fixtures/invalid/inferred-kind-mismatch.json +2191 -0
  172. package/contract/fixtures/invalid/inferred-model-not-mapping-table.json +2191 -0
  173. package/contract/fixtures/invalid/inferred-unknown-foreign-key.json +2191 -0
  174. package/contract/fixtures/invalid/inferred-wrong-id.json +2191 -0
  175. package/contract/fixtures/invalid/inferred-wrong-links.json +2191 -0
  176. package/contract/fixtures/invalid/link-state-mismatch.json +44 -97
  177. package/contract/fixtures/invalid/migration-coverage-wrong-table.json +1699 -0
  178. package/contract/fixtures/invalid/migration-revisions-without-version-table.json +1699 -0
  179. package/contract/fixtures/invalid/migration-unknown-coverage-certain.json +1699 -0
  180. package/contract/fixtures/invalid/migration-unlisted-unknown-revision.json +1697 -0
  181. package/contract/fixtures/invalid/migration-version-table-outside-scope.json +1699 -0
  182. package/contract/fixtures/invalid/migration-wrong-heads.json +1698 -0
  183. package/contract/fixtures/invalid/migration-wrong-id.json +1699 -0
  184. package/contract/fixtures/invalid/migration-wrong-missing.json +1697 -0
  185. package/contract/fixtures/invalid/migration-wrong-status.json +1695 -0
  186. package/contract/fixtures/invalid/missing-field.json +5 -15
  187. package/contract/fixtures/invalid/pivot-unknown-column.json +44 -97
  188. package/contract/fixtures/invalid/predicate-without-partial.json +5 -15
  189. package/contract/fixtures/invalid/primary-index-not-unique.json +6 -54
  190. package/contract/fixtures/invalid/primary-index-other-columns.json +811 -0
  191. package/contract/fixtures/invalid/provenance-outside-source.json +5 -15
  192. package/contract/fixtures/invalid/related-model-missing.json +12 -17
  193. package/contract/fixtures/invalid/strict-other-minor.json +301 -0
  194. package/contract/fixtures/invalid/unknown-property-strict.json +6 -16
  195. package/contract/fixtures/invalid/unsupported-major.json +7 -17
  196. package/contract/fixtures/invalid/wrong-format.json +5 -15
  197. package/contract/fixtures/valid/combined-drift.json +12 -17
  198. package/contract/fixtures/valid/combined-eloquent.json +44 -97
  199. package/contract/fixtures/valid/combined-multi-connection.json +8 -26
  200. package/contract/fixtures/valid/comparison-incomplete.json +2225 -0
  201. package/contract/fixtures/valid/comparison-multi-connection.json +889 -0
  202. package/contract/fixtures/valid/comparison-schema-named-tables.json +381 -0
  203. package/contract/fixtures/valid/comparison-tenant-schemas.json +2742 -0
  204. package/contract/fixtures/valid/database-mysql-indexes.json +4 -32
  205. package/contract/fixtures/valid/database-postgresql-indexes.json +5 -53
  206. package/contract/fixtures/valid/database-sqlite-indexes.json +5 -15
  207. package/contract/fixtures/valid/declared-multi-connection.json +4 -1
  208. package/contract/fixtures/valid/declared-sqlalchemy.json +5 -11
  209. package/contract/fixtures/valid/inferred-associations.json +2184 -0
  210. package/contract/fixtures/valid/migrations-alembic.json +1692 -0
  211. package/contract/gate-report.schema.json +242 -0
  212. package/contract/schema.json +636 -18
  213. package/dist/lib/contract-C2tN-NIP.js +409 -0
  214. package/dist/lib/contract-C2tN-NIP.js.map +1 -0
  215. package/dist/lib/contract.js +3 -1
  216. package/dist/lib/export-L1rzMCoW.js +651 -0
  217. package/dist/lib/export-L1rzMCoW.js.map +1 -0
  218. package/dist/lib/export.js +1 -0
  219. package/dist/lib/index.js +4383 -1831
  220. package/dist/lib/index.js.map +1 -1
  221. package/dist/lib/styles.css +1 -1
  222. package/dist/lib/validate-BF7eATfB.js +1781 -0
  223. package/dist/lib/validate-BF7eATfB.js.map +1 -0
  224. package/dist/types/contract/comparison.d.ts +65 -0
  225. package/dist/types/contract/document.d.ts +2 -2
  226. package/dist/types/contract/gate.d.ts +63 -0
  227. package/dist/types/contract/ids.d.ts +10 -0
  228. package/dist/types/contract/index.d.ts +5 -0
  229. package/dist/types/contract/inference.d.ts +10 -0
  230. package/dist/types/contract/migration.d.ts +8 -0
  231. package/dist/types/contract/serialize.d.ts +1 -0
  232. package/dist/types/contract/types.d.ts +122 -5
  233. package/dist/types/export/common.d.ts +44 -0
  234. package/dist/types/export/dbml.d.ts +3 -0
  235. package/dist/types/export/index.d.ts +10 -0
  236. package/dist/types/export/json.d.ts +7 -0
  237. package/dist/types/export/markdown.d.ts +4 -0
  238. package/dist/types/export/mermaid.d.ts +4 -0
  239. package/dist/types/export/types.d.ts +28 -0
  240. package/dist/types/index.d.ts +1 -0
  241. package/dist/types/viewer/Browse.d.ts +6 -2
  242. package/dist/types/viewer/Compare.d.ts +39 -0
  243. package/dist/types/viewer/Details.d.ts +40 -7
  244. package/dist/types/viewer/DownloadDialog.d.ts +16 -0
  245. package/dist/types/viewer/Inferred.d.ts +20 -0
  246. package/dist/types/viewer/Migrations.d.ts +14 -0
  247. package/dist/types/viewer/SchemaEdge.d.ts +3 -1
  248. package/dist/types/viewer/SchemaViewer.d.ts +2 -0
  249. package/dist/types/viewer/TableNode.d.ts +6 -0
  250. package/dist/types/viewer/brand.d.ts +32 -0
  251. package/dist/types/viewer/exportImage.d.ts +21 -2
  252. package/dist/types/viewer/graph.d.ts +16 -2
  253. package/dist/types/viewer/icons.d.ts +96 -0
  254. package/dist/types/viewer/intelligence.d.ts +55 -0
  255. package/dist/types/viewer/layout.d.ts +5 -0
  256. package/dist/types/viewer/offline.d.ts +9 -0
  257. package/dist/types/viewer/ui.d.ts +7 -29
  258. package/dist/viewer/app.css +1 -1
  259. package/dist/viewer/app.js +36 -8
  260. package/dist/viewer/favicon.ico +0 -0
  261. package/dist/viewer/favicon.svg +1 -1
  262. package/dist/viewer/index.html +2 -2
  263. package/dist/viewer/manifest.json +19 -13
  264. package/dist/viewer/offline.js +67 -0
  265. package/docs/contract.md +494 -26
  266. package/docs/integration.md +10 -7
  267. package/package.json +7 -2
  268. package/dist/lib/contract-N4axHCW3.js +0 -774
  269. package/dist/lib/contract-N4axHCW3.js.map +0 -1
package/NOTICE CHANGED
@@ -9,6 +9,17 @@ and orthogonal edge routing are adapted from Laranex Laravel Schema Viewer,
9
9
  ui/src/elk.ts, ui/src/layout.ts and ui/src/routing.ts, inspected at commit
10
10
  62b056a (https://github.com/laranex/laravel-schema-viewer).
11
11
 
12
+ The icons (src/viewer/icons.tsx) and the brand mark (src/viewer/brand.ts),
13
+ which is also the favicon and the documentation site's logo, are adapted from
14
+ Laranex Laravel Schema Viewer, ui/src/App.tsx and ui/src/components/*.tsx,
15
+ inspected at commit 62b056a: the same shapes, proportions and viewBoxes, drawn
16
+ in the viewer's own theme colors. The icons Laravel has no counterpart for
17
+ (select, details, changes, compare, migrations, behind, branch, circle) are
18
+ drawn for this package in the same style. No third-party icon set is used.
19
+ The line ends (crow's foot, bar, double bar and through arrow) are adapted from
20
+ ui/src/components/LinkEdge.tsx at the same commit and drawn the same way in
21
+ images (src/viewer/graph.ts END_SHAPES).
22
+
12
23
  The laranex-schema contract takes its structure and camelCase naming from
13
24
  Laravel Schema Viewer's serialized document (src/Schema/*.php) and its
14
25
  provenance-preserving rules from Python Schema Viewer's snapshot contract
package/README.md CHANGED
@@ -16,10 +16,23 @@ import 'laranex-schema-viewer-ui/styles.css';
16
16
 
17
17
  ```js
18
18
  import { validateDocument, buildGraph, canonicalJson } from 'laranex-schema-viewer-ui/contract';
19
+ import { dbml, mermaid, markdown, json } from 'laranex-schema-viewer-ui/export';
19
20
  ```
20
21
 
21
- Hosts without Node.js serve `node_modules/laranex-schema-viewer-ui/dist/viewer/` as static files with a
22
- `snapshot.json` beside `index.html`, or use `<laranex-schema-viewer src="snapshot.json">`.
22
+ The viewer's Download dialog exports a connection as Mermaid, DBML, Markdown or a scoped JSON document, the diagram as
23
+ SVG or PNG, and the whole viewer as one offline HTML file, all in the browser; see [docs/exports.md](docs/exports.md).
24
+
25
+ The viewer displays the comparisons, migration tracks and inferred associations a document stores (Compare and
26
+ Migrations tabs, difference marks on the diagram, inferred marks on foreign-key edges) and never computes them; see
27
+ [docs/views.md](docs/views.md).
28
+
29
+ Hosts without Node.js serve `node_modules/laranex-schema-viewer-ui/dist/viewer/` as static files (including its
30
+ `favicon.svg` and `favicon.ico`) with a `snapshot.json` beside `index.html`, or use
31
+ `<laranex-schema-viewer src="snapshot.json">`. Using the viewer (layout, connections, line ends, column details,
32
+ shortcuts and deep links) is described in [docs/viewer.md](docs/viewer.md).
33
+
34
+ Its icons, brand mark, favicon and line ends come from Laranex Laravel Schema Viewer, drawn in this package's own
35
+ theme colors (see NOTICE); [docs/parity.md](docs/parity.md) compares the two viewers feature by feature.
23
36
 
24
37
  ## License
25
38
 
@@ -3,10 +3,11 @@
3
3
  //
4
4
  // node node_modules/laranex-schema-viewer-ui/contract/check.mjs [--lenient] [--no-graph] [--no-canonical] FILE...
5
5
  //
6
- // By default a document must pass strict validation, store exactly the links the shared graph builder produces, and
7
- // be written in canonical form. Exits 1 when any file fails.
6
+ // By default a document must pass strict validation (which also checks comparison ids, order and summaries, and
7
+ // migration statuses), store exactly the links the shared graph builder produces and the inferred associations the
8
+ // shared inference produces, and be written in canonical form. Exits 1 when any file fails.
8
9
  import { readFileSync } from 'node:fs';
9
- import { buildGraph, canonicalJson, validateDocument } from '../dist/lib/contract.js';
10
+ import { buildGraph, canonicalJson, inferAssociations, validateDocument } from '../dist/lib/contract.js';
10
11
 
11
12
  const args = process.argv.slice(2);
12
13
  const flags = new Set(args.filter((a) => a.startsWith('--')));
@@ -37,6 +38,9 @@ for (const file of files) {
37
38
  if (canonicalJson(expected.derivedLinks) !== canonicalJson(doc.derivedLinks)) {
38
39
  problems.push('derivedLinks differ from the shared graph builder');
39
40
  }
41
+ if (canonicalJson(inferAssociations(doc)) !== canonicalJson(doc.inferredAssociations)) {
42
+ problems.push('inferredAssociations differ from the shared inference');
43
+ }
40
44
  }
41
45
  if (!flags.has('--no-canonical') && canonicalJson(doc) !== text) {
42
46
  problems.push('not in canonical form (sorted keys, two-space indentation, trailing newline)');
@@ -0,0 +1,387 @@
1
+ {
2
+ "description": "Columns match by name; on one driver types compare as written (certain), defaults as normalized SQL (likely), and fields are sorted",
3
+ "expected": {
4
+ "baseline": {
5
+ "connection": "connection:a",
6
+ "schema": null
7
+ },
8
+ "complete": true,
9
+ "differences": [
10
+ {
11
+ "baseline": {
12
+ "id": null,
13
+ "label": "users.email",
14
+ "table": "a:users"
15
+ },
16
+ "certainty": "certain",
17
+ "change": "changed",
18
+ "fields": [
19
+ {
20
+ "baseline": true,
21
+ "field": "nullable",
22
+ "target": false
23
+ },
24
+ {
25
+ "baseline": "varchar(255)",
26
+ "field": "type",
27
+ "target": "VARCHAR(320)"
28
+ }
29
+ ],
30
+ "id": "x411857b333eecaa2",
31
+ "key": [
32
+ "users",
33
+ "email"
34
+ ],
35
+ "objectType": "column",
36
+ "severity": "warning",
37
+ "target": {
38
+ "id": null,
39
+ "label": "users.email",
40
+ "table": "b:users"
41
+ }
42
+ },
43
+ {
44
+ "baseline": {
45
+ "id": null,
46
+ "label": "users.note",
47
+ "table": "a:users"
48
+ },
49
+ "certainty": "certain",
50
+ "change": "changed",
51
+ "fields": [
52
+ {
53
+ "baseline": "old",
54
+ "field": "comment",
55
+ "target": "new"
56
+ }
57
+ ],
58
+ "id": "x46fb774d0d31dcf8",
59
+ "key": [
60
+ "users",
61
+ "note"
62
+ ],
63
+ "objectType": "column",
64
+ "severity": "info",
65
+ "target": {
66
+ "id": null,
67
+ "label": "users.note",
68
+ "table": "b:users"
69
+ }
70
+ },
71
+ {
72
+ "baseline": null,
73
+ "certainty": "certain",
74
+ "change": "extra",
75
+ "fields": [],
76
+ "id": "xb29093c0bc285345",
77
+ "key": [
78
+ "users",
79
+ "phone"
80
+ ],
81
+ "objectType": "column",
82
+ "severity": "error",
83
+ "target": {
84
+ "id": null,
85
+ "label": "users.phone",
86
+ "table": "b:users"
87
+ }
88
+ },
89
+ {
90
+ "baseline": {
91
+ "id": null,
92
+ "label": "users.status",
93
+ "table": "a:users"
94
+ },
95
+ "certainty": "likely",
96
+ "change": "changed",
97
+ "fields": [
98
+ {
99
+ "baseline": {
100
+ "kind": "literal",
101
+ "value": "'a'::text"
102
+ },
103
+ "field": "default",
104
+ "target": {
105
+ "kind": "literal",
106
+ "value": "'b'::text"
107
+ }
108
+ }
109
+ ],
110
+ "id": "x2f91ca963ed4eca9",
111
+ "key": [
112
+ "users",
113
+ "status"
114
+ ],
115
+ "objectType": "column",
116
+ "severity": "warning",
117
+ "target": {
118
+ "id": null,
119
+ "label": "users.status",
120
+ "table": "b:users"
121
+ }
122
+ }
123
+ ],
124
+ "id": "ccd30999b0df19108",
125
+ "omitted": 0,
126
+ "summary": {
127
+ "changed": 3,
128
+ "extra": 1,
129
+ "missing": 0
130
+ },
131
+ "target": {
132
+ "connection": "connection:b",
133
+ "schema": null
134
+ }
135
+ },
136
+ "input": {
137
+ "baseline": {
138
+ "connection": "connection:a",
139
+ "schema": null
140
+ },
141
+ "document": {
142
+ "connections": [
143
+ {
144
+ "coverage": {
145
+ "database": {
146
+ "complete": true,
147
+ "features": {
148
+ "checkConstraints": "complete",
149
+ "columnTypes": "complete",
150
+ "columns": "complete",
151
+ "comments": "complete",
152
+ "defaults": "complete",
153
+ "foreignKeys": "complete",
154
+ "includedColumns": "complete",
155
+ "indexExpressions": "complete",
156
+ "indexPredicates": "complete",
157
+ "indexes": "complete",
158
+ "primaryKeys": "complete",
159
+ "referentialActions": "complete",
160
+ "tables": "complete",
161
+ "uniqueConstraints": "complete"
162
+ },
163
+ "schemas": null
164
+ },
165
+ "declared": null
166
+ },
167
+ "defaultSchema": null,
168
+ "driver": "postgresql",
169
+ "id": "connection:a",
170
+ "name": "a",
171
+ "tables": [
172
+ {
173
+ "columns": [
174
+ {
175
+ "autoIncrement": false,
176
+ "collation": null,
177
+ "comment": null,
178
+ "default": null,
179
+ "enum": null,
180
+ "generated": null,
181
+ "name": "email",
182
+ "note": null,
183
+ "nullable": true,
184
+ "ormDefault": null,
185
+ "provenance": [
186
+ "database"
187
+ ],
188
+ "timezone": null,
189
+ "type": "varchar(255)",
190
+ "typeName": "varchar"
191
+ },
192
+ {
193
+ "autoIncrement": false,
194
+ "collation": null,
195
+ "comment": "old",
196
+ "default": null,
197
+ "enum": null,
198
+ "generated": null,
199
+ "name": "note",
200
+ "note": null,
201
+ "nullable": false,
202
+ "ormDefault": null,
203
+ "provenance": [
204
+ "database"
205
+ ],
206
+ "timezone": null,
207
+ "type": "text",
208
+ "typeName": "text"
209
+ },
210
+ {
211
+ "autoIncrement": false,
212
+ "collation": null,
213
+ "comment": null,
214
+ "default": {
215
+ "kind": "literal",
216
+ "value": "'a'::text"
217
+ },
218
+ "enum": null,
219
+ "generated": null,
220
+ "name": "status",
221
+ "note": null,
222
+ "nullable": false,
223
+ "ormDefault": null,
224
+ "provenance": [
225
+ "database"
226
+ ],
227
+ "timezone": null,
228
+ "type": "text",
229
+ "typeName": "text"
230
+ }
231
+ ],
232
+ "comment": "People",
233
+ "constraints": [],
234
+ "foreignKeys": [],
235
+ "id": "a:users",
236
+ "indexes": [],
237
+ "name": "users",
238
+ "note": null,
239
+ "owner": {
240
+ "kind": "application",
241
+ "package": null
242
+ },
243
+ "primaryKey": [],
244
+ "provenance": [
245
+ "database"
246
+ ],
247
+ "schema": null
248
+ }
249
+ ]
250
+ },
251
+ {
252
+ "coverage": {
253
+ "database": {
254
+ "complete": true,
255
+ "features": {
256
+ "checkConstraints": "complete",
257
+ "columnTypes": "complete",
258
+ "columns": "complete",
259
+ "comments": "complete",
260
+ "defaults": "complete",
261
+ "foreignKeys": "complete",
262
+ "includedColumns": "complete",
263
+ "indexExpressions": "complete",
264
+ "indexPredicates": "complete",
265
+ "indexes": "complete",
266
+ "primaryKeys": "complete",
267
+ "referentialActions": "complete",
268
+ "tables": "complete",
269
+ "uniqueConstraints": "complete"
270
+ },
271
+ "schemas": null
272
+ },
273
+ "declared": null
274
+ },
275
+ "defaultSchema": null,
276
+ "driver": "postgresql",
277
+ "id": "connection:b",
278
+ "name": "b",
279
+ "tables": [
280
+ {
281
+ "columns": [
282
+ {
283
+ "autoIncrement": false,
284
+ "collation": null,
285
+ "comment": null,
286
+ "default": null,
287
+ "enum": null,
288
+ "generated": null,
289
+ "name": "email",
290
+ "note": null,
291
+ "nullable": false,
292
+ "ormDefault": null,
293
+ "provenance": [
294
+ "database"
295
+ ],
296
+ "timezone": null,
297
+ "type": "VARCHAR(320)",
298
+ "typeName": "varchar"
299
+ },
300
+ {
301
+ "autoIncrement": false,
302
+ "collation": null,
303
+ "comment": "new",
304
+ "default": null,
305
+ "enum": null,
306
+ "generated": null,
307
+ "name": "note",
308
+ "note": null,
309
+ "nullable": false,
310
+ "ormDefault": null,
311
+ "provenance": [
312
+ "database"
313
+ ],
314
+ "timezone": null,
315
+ "type": "text",
316
+ "typeName": "text"
317
+ },
318
+ {
319
+ "autoIncrement": false,
320
+ "collation": null,
321
+ "comment": null,
322
+ "default": null,
323
+ "enum": null,
324
+ "generated": null,
325
+ "name": "phone",
326
+ "note": null,
327
+ "nullable": false,
328
+ "ormDefault": null,
329
+ "provenance": [
330
+ "database"
331
+ ],
332
+ "timezone": null,
333
+ "type": "text",
334
+ "typeName": "text"
335
+ },
336
+ {
337
+ "autoIncrement": false,
338
+ "collation": null,
339
+ "comment": null,
340
+ "default": {
341
+ "kind": "literal",
342
+ "value": "'b'::text"
343
+ },
344
+ "enum": null,
345
+ "generated": null,
346
+ "name": "status",
347
+ "note": null,
348
+ "nullable": false,
349
+ "ormDefault": null,
350
+ "provenance": [
351
+ "database"
352
+ ],
353
+ "timezone": null,
354
+ "type": "text",
355
+ "typeName": "text"
356
+ }
357
+ ],
358
+ "comment": "People",
359
+ "constraints": [],
360
+ "foreignKeys": [],
361
+ "id": "b:users",
362
+ "indexes": [],
363
+ "name": "users",
364
+ "note": null,
365
+ "owner": {
366
+ "kind": "application",
367
+ "package": null
368
+ },
369
+ "primaryKey": [],
370
+ "provenance": [
371
+ "database"
372
+ ],
373
+ "schema": null
374
+ }
375
+ ]
376
+ }
377
+ ],
378
+ "source": "database"
379
+ },
380
+ "limit": null,
381
+ "overrides": [],
382
+ "target": {
383
+ "connection": "connection:b",
384
+ "schema": null
385
+ }
386
+ }
387
+ }