-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
6682 lines (6619 loc) · 235 KB
/
Copy pathindex.html
File metadata and controls
6682 lines (6619 loc) · 235 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ReleaseDiff — compare two metadata snapshots, in your browser</title>
<meta name="description" content="Catch metadata errors before you deliver. Compare two release-metadata snapshots and see what changed, what fails ISRC and barcode validation, and what looks wrong. Runs entirely in your browser; your files never upload.">
<link rel="canonical" href="https://notgabriels-sys.github.io/releasediff-demo/">
<meta property="og:type" content="website">
<meta property="og:site_name" content="ReleaseDiff">
<meta property="og:title" content="ReleaseDiff — compare two metadata snapshots, in your browser">
<meta property="og:description" content="Catch metadata errors before you deliver. Compare two release-metadata snapshots and see what changed, what fails ISRC and barcode validation, and what looks wrong. Runs entirely in your browser; your files never upload.">
<meta property="og:url" content="https://notgabriels-sys.github.io/releasediff-demo/">
<meta property="og:image" content="https://notgabriels-sys.github.io/releasediff-demo/og.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="ReleaseDiff — compare two metadata snapshots, in your browser">
<meta name="twitter:description" content="Catch metadata errors before you deliver. Compare two release-metadata snapshots and see what changed, what fails ISRC and barcode validation, and what looks wrong. Runs entirely in your browser; your files never upload.">
<meta name="twitter:image" content="https://notgabriels-sys.github.io/releasediff-demo/og.png">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SoftwareApplication",
"name": "ReleaseDiff",
"applicationCategory": "BusinessApplication",
"applicationSubCategory": "Music metadata quality control",
"operatingSystem": "Any (runs in a web browser)",
"url": "https://notgabriels-sys.github.io/releasediff-demo/",
"description": "Compare two release-metadata snapshots and see what changed, what fails ISRC and barcode validation, and what looks wrong before delivery. Runs entirely in the browser; files are never uploaded.",
"license": "https://opensource.org/licenses/MIT",
"isAccessibleForFree": true,
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "EUR" },
"featureList": [
"Compare two metadata snapshots and classify every change by review priority",
"Validate ISRC format and EAN-13/UPC-A check digits",
"Detect duplicate identities and conflicting release information",
"Distinguish formatting-only differences from real value changes",
"Attribute every finding to the file it came from",
"Produce a deterministic, reproducible JSON audit report"
]
}
</script>
<style>
:root{
--bg:#0b0d10; --panel:#12151a; --panel-2:#171b21; --line:#242a33;
--ink:#e6e9ef; --ink-dim:#9aa3b2; --ink-faint:#6b7383;
--accent:#7aa2f7; --ok:#79d68b; --warn:#e5c07b; --bad:#f07178;
--mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace;
--sans:system-ui,-apple-system,"Segoe UI",Inter,Helvetica,Arial,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{background:var(--bg);color:var(--ink);font:15px/1.55 var(--sans);-webkit-font-smoothing:antialiased}
a{color:var(--accent)}
.wrap{max-width:1080px;margin:0 auto;padding:40px 20px 72px}
header h1{font-size:30px;margin:0 0 6px;letter-spacing:-.02em}
header h1 span{color:var(--ink-faint);font-weight:400}
.tagline{color:var(--ink-dim);margin:0 0 18px;max-width:62ch}
.privacy{display:inline-flex;gap:9px;align-items:flex-start;background:var(--panel);border:1px solid var(--line);
border-left:3px solid var(--ok);border-radius:7px;padding:11px 14px;color:var(--ink-dim);font-size:13.5px;max-width:70ch}
.privacy b{color:var(--ink);font-weight:600}
.grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin:26px 0 0}
@media (max-width:720px){.grid{grid-template-columns:1fr}}
.slot{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:16px;transition:border-color .12s,background .12s}
.slot.drag{border-color:var(--accent);background:var(--panel-2)}
.slot h2{margin:0 0 3px;font-size:12px;letter-spacing:.09em;text-transform:uppercase;color:var(--ink-faint)}
.slot .name{font-family:var(--mono);font-size:13px;color:var(--ink);word-break:break-all;min-height:19px}
.slot .meta{font-family:var(--mono);font-size:11.5px;color:var(--ink-faint);margin-top:5px;min-height:16px}
.slot .drop{margin-top:11px;border:1px dashed var(--line);border-radius:7px;padding:14px;text-align:center;
color:var(--ink-faint);font-size:13px;cursor:pointer}
.slot .drop:hover{border-color:var(--accent);color:var(--ink-dim)}
input[type=file]{display:none}
.controls{display:flex;flex-wrap:wrap;gap:9px;align-items:center;margin:18px 0 0}
button{font:inherit;font-size:13.5px;background:var(--panel-2);color:var(--ink);border:1px solid var(--line);
border-radius:7px;padding:8px 14px;cursor:pointer;transition:border-color .12s,background .12s}
button:hover:not(:disabled){border-color:var(--accent)}
button:disabled{opacity:.42;cursor:not-allowed}
button.primary{background:var(--accent);border-color:var(--accent);color:#0b0d10;font-weight:600}
button.primary:hover:not(:disabled){filter:brightness(1.08)}
.sep{flex:1}
.verdict{margin:26px 0 0;border-radius:10px;border:1px solid var(--line);background:var(--panel);overflow:hidden}
.verdict .bar{padding:15px 18px;display:flex;align-items:baseline;gap:14px;flex-wrap:wrap;border-left:4px solid var(--line)}
.verdict.clean .bar{border-left-color:var(--ok)}
.verdict.review_required .bar{border-left-color:var(--warn)}
.verdict.blocked .bar{border-left-color:var(--bad)}
.verdict .label{font-family:var(--mono);font-size:17px;font-weight:700;letter-spacing:.04em}
.verdict.clean .label{color:var(--ok)}
.verdict.review_required .label{color:var(--warn)}
.verdict.blocked .label{color:var(--bad)}
.verdict .counts{font-family:var(--mono);font-size:12.5px;color:var(--ink-dim)}
.verdict .exit{margin-left:auto;font-family:var(--mono);font-size:12px;color:var(--ink-faint)}
.section{border-top:1px solid var(--line);padding:15px 18px}
.section h3{margin:0 0 11px;font-size:11.5px;letter-spacing:.09em;text-transform:uppercase;color:var(--ink-faint)}
.issue{display:flex;gap:10px;align-items:flex-start;padding:7px 0;border-bottom:1px solid rgba(255,255,255,.04);font-size:13.5px}
.issue:last-child{border-bottom:0}
.chip{font-family:var(--mono);font-size:10.5px;letter-spacing:.05em;text-transform:uppercase;padding:2px 7px;border-radius:4px;
border:1px solid var(--line);color:var(--ink-faint);white-space:nowrap;flex-shrink:0;margin-top:1px}
.chip.before{color:var(--accent);border-color:rgba(122,162,247,.4)}
.chip.after{color:#c586e0;border-color:rgba(197,134,224,.4)}
.chip.high{color:var(--bad);border-color:rgba(240,113,120,.4)}
.chip.normal{color:var(--warn);border-color:rgba(229,192,123,.4)}
.chip.info{color:var(--ink-dim)}
.chips{display:flex;flex-direction:column;gap:3px;flex-shrink:0}
.issue .body{min-width:0}
.issue .code{font-family:var(--mono);color:var(--ink)}
.issue .msg{color:var(--ink-dim)}
.issue .where{font-family:var(--mono);font-size:11.5px;color:var(--ink-faint);margin-top:2px}
.val{font-family:var(--mono);font-size:12.5px;color:var(--ink);background:var(--panel-2);border:1px solid var(--line);
border-radius:4px;padding:1px 5px;word-break:break-all}
.arrow{color:var(--ink-faint);margin:0 5px}
.empty{color:var(--ink-faint);font-size:13.5px;font-style:italic}
.err{color:var(--bad);font-family:var(--mono);font-size:13px;white-space:pre-wrap}
footer{margin-top:46px;padding-top:22px;border-top:1px solid var(--line);color:var(--ink-faint);font-size:13px}
footer p{margin:0 0 11px;max-width:74ch}
footer .quote{border-left:2px solid var(--line);padding-left:13px;color:var(--ink-dim)}
footer code{font-family:var(--mono);font-size:12px;color:var(--ink-dim)}
.note{background:var(--panel);border:1px solid var(--line);border-radius:7px;padding:11px 14px;margin:0 0 13px;color:var(--ink-dim)}
.cta{margin:30px 0 0;display:flex;gap:18px;align-items:center;justify-content:space-between;flex-wrap:wrap;
background:var(--panel);border:1px solid var(--line);border-left:3px solid var(--accent);
border-radius:10px;padding:16px 18px}
.cta b{color:var(--ink);display:block;margin-bottom:3px}
.cta span{color:var(--ink-dim);font-size:13.5px;max-width:62ch;display:block}
.cta-btn{background:var(--accent);color:#0b0d10;font-weight:600;font-size:13.5px;text-decoration:none;
padding:9px 16px;border-radius:7px;white-space:nowrap}
.cta-btn:hover{filter:brightness(1.08)}
</style>
</head>
<body>
<div class="wrap">
<header>
<h1>ReleaseDiff <span>· browser demo</span></h1>
<p class="tagline">A rejected delivery can cost you days. Most rejections trace back to something
small — an ISRC that gained hyphens, a title that changed between the spreadsheet and the export,
a contributor missing on one track. ReleaseDiff compares two metadata snapshots and shows you
exactly what changed, what fails validation, and what looks wrong, before you send anything.</p>
<div class="privacy">
<span>🔒</span>
<span><b>Your files never leave this page.</b> The whole audit engine is embedded in this HTML file
and runs in your browser. It contains no network code at all — no <code>fetch</code>, no
<code>XMLHttpRequest</code>, no WebSocket. You can disconnect from the internet and it still works.</span>
</div>
</header>
<div class="grid">
<div class="slot" id="slot-before">
<h2>Before</h2>
<div class="name" id="name-before">no file</div>
<div class="meta" id="meta-before"></div>
<div class="drop" data-for="before">Drop a CSV here, or click to choose</div>
<input type="file" id="file-before" accept=".csv,text/csv">
</div>
<div class="slot" id="slot-after">
<h2>After</h2>
<div class="name" id="name-after">no file</div>
<div class="meta" id="meta-after"></div>
<div class="drop" data-for="after">Drop a CSV here, or click to choose</div>
<input type="file" id="file-after" accept=".csv,text/csv">
</div>
</div>
<div class="controls">
<button id="run" class="primary" disabled>Compare</button>
<button id="sample-review">Load an example with changes</button>
<button id="sample-blocked">Load an example with blockers</button>
<span class="sep"></span>
<button id="download" disabled>Download report JSON</button>
<button id="clear">Clear</button>
</div>
<div id="out"></div>
<div class="cta">
<div>
<b>Need the paperwork too? There is a paid kit.</b>
<span><b>ReleaseDiff Pro — Label Metadata Change Audit Kit</b> adds the parts a label
actually hands over: a printable approval record, a change-request form and a
distributor handoff checklist (editable DOCX and print-ready PDF), two metadata
workbooks, an operating guide, and three worked examples. Same engine, and the same
absence of network code, verified the same way. One file, no install. What you are using here stays free and
MIT — Pro is for when a human has to sign something.</span>
</div>
<a class="cta-btn" href="https://notgabriel.gumroad.com/l/releasediff-pro"
target="_blank" rel="noopener noreferrer">See ReleaseDiff Pro</a>
</div>
<footer>
<p class="quote">ReleaseDiff compares two local metadata snapshots, validates common identifiers and
required fields, highlights exact changes by review priority, and produces an auditable report
without uploading the files.</p>
<p class="quote">ReleaseDiff checks only the data you provide. It does not verify rights, identifier
ownership, distributor acceptance, or publication on any external platform.</p>
<div class="note"><b>Status.</b> This page and the command-line tool are free and MIT.
<code>@notgabriels/releasediff</code> is not on npm yet, so the CLI runs from a local
checkout. The paid kit is
<a href="https://notgabriel.gumroad.com/l/releasediff-pro">ReleaseDiff Pro</a>.
The example files use invented labels, artists and catalogue numbers, and ISRCs in the
unallocated <code>ZZ</code> prefix — they are not real releases.</div>
<div class="note"><b>Built from commit <code>d454b13</code>.</b> The engine embedded in this page
is the one built from that exact commit, and the reports it produces are byte-for-byte identical to
the ones the command-line tool writes <em>at that commit</em> — same SHA-256, same exit codes.
Development has continued since, and the report format has changed: findings now carry per-file
row evidence rather than a single <code>input</code> and <code>rows</code> pair. So do not read
this page as showing the current format. It is a fixed, self-consistent snapshot.</div>
<p><b><a href="https://github.com/notgabriels-sys/deadwax">Source code on GitHub →</a></b>
MIT licensed. The engine on this page is built from that repository, and every check it
performs is readable there, along with the tests that pin the behaviour.</p>
<p><b><a href="https://gabriel-tools-and-code.notgabriels960914.chatgpt.site">Gabriel García Alonso — Tools + Code →</a></b>
the working index of the audio tools, studio utilities, plug-ins, design packs and repositories
this comes from. It states plainly what is released, what is only a candidate, and what is not
available at all.</p>
<p>The engine embedded in this page bundles <code>csv-parse</code> and <code>lossless-json</code>,
both MIT-licensed; their notices are reproduced in the engine's licence header and in
<code>releasediff-engine.THIRD-PARTY-NOTICES.md</code>. ReleaseDiff itself is MIT.</p>
</footer>
</div>
<script type="module">
/*!
* ReleaseDiff. Copyright (c) 2026 Gabriel Garcia Alonso. MIT licence; see LICENSE.
*
* This file is a bundle: the packages below are inlined into it and are
* redistributed with it. Their licences are reproduced in full in
* releasediff-engine.THIRD-PARTY-NOTICES.md, which ships beside this file.
*
* csv-parse 7.0.2 — MIT
* lossless-json 4.3.1 — MIT
*/
// packages/core/dist/src/config.js
var DEFAULT_ALIASES = Object.freeze({
track_title: "track_title",
track_name: "track_title",
mix_version: "track_version",
track_subtitle: "track_version",
artist: "primary_artist",
main_artist: "primary_artist",
recording_isrc: "isrc",
barcode: "upc_ean",
upc: "upc_ean",
ean: "upc_ean",
disc: "disc_number",
disc_no: "disc_number",
track_no: "track_number",
track_number: "track_number",
"track_#": "track_number"
});
var HIGH_FIELDS = [
"isrc",
"upc_ean",
"primary_artist",
"release_primary_artist",
"track_title",
"track_version",
"release_title",
"release_version",
"release_date",
"explicit",
"p_line",
"c_line"
];
var NORMAL_FIELDS = [
"featured_artists",
"contributors",
"roles",
"publisher",
"language",
"release_language",
"genre",
"release_genre",
"catalog_number",
"disc_number",
"track_number"
];
var DEFAULT_SEVERITIES = Object.freeze(Object.fromEntries([
...HIGH_FIELDS.map((field) => [field, "high"]),
...NORMAL_FIELDS.map((field) => [field, "normal"])
]));
var CONFIG_KEYS = /* @__PURE__ */ new Set([
"schemaVersion",
"aliases",
"ignoredFields",
"requiredFields",
"severities",
"releaseConsistencyFields",
"positionMatch",
"delimiter",
"formattingSeverities",
"significantPresenceFields"
]);
var POSITION_MATCH_KEYS = /* @__PURE__ */ new Set(["enabled", "releaseKeyField"]);
var FORMATTING_SEVERITY_KEYS = /* @__PURE__ */ new Set([
"outerWhitespace",
"lineEndings",
"identifierSeparators",
"unicodeNormalization"
]);
var ConfigError = class extends Error {
code = "invalid_configuration";
};
var DEFAULT_CONFIG = deepFreezeConfig({
schemaVersion: "releasediff.config.v1",
aliases: DEFAULT_ALIASES,
ignoredFields: [],
requiredFields: ["track_title", "primary_artist"],
severities: DEFAULT_SEVERITIES,
releaseConsistencyFields: [
"upc_ean",
"release_title",
"release_primary_artist",
"release_date",
"p_line",
"c_line"
],
positionMatch: { enabled: true, releaseKeyField: "release_id" },
delimiter: "auto",
formattingSeverities: {
outerWhitespace: "info",
lineEndings: "info",
identifierSeparators: "info",
unicodeNormalization: "info"
},
significantPresenceFields: []
}, true);
function validateConfig(value) {
if (!isPlainObject(value))
throw new ConfigError("configuration must be an object");
assertExactKeys(value, CONFIG_KEYS, "configuration");
if (value.schemaVersion !== "releasediff.config.v1") {
throw new ConfigError("schemaVersion must be releasediff.config.v1");
}
assertStringRecord(value.aliases, "aliases");
assertStringArray(value.ignoredFields, "ignoredFields");
assertStringArray(value.requiredFields, "requiredFields");
assertSeverityRecord(value.severities);
assertStringArray(value.releaseConsistencyFields, "releaseConsistencyFields");
assertPositionMatch(value.positionMatch);
assertDelimiter(value.delimiter);
assertFormattingSeverities(value.formattingSeverities);
assertStringArray(value.significantPresenceFields, "significantPresenceFields");
return deepFreezeConfig({
schemaVersion: value.schemaVersion,
aliases: value.aliases,
ignoredFields: value.ignoredFields,
requiredFields: value.requiredFields,
severities: value.severities,
releaseConsistencyFields: value.releaseConsistencyFields,
positionMatch: value.positionMatch,
delimiter: value.delimiter,
formattingSeverities: value.formattingSeverities,
significantPresenceFields: value.significantPresenceFields
});
}
function stableConfigJson(config2) {
return [
"{",
` "schemaVersion": ${JSON.stringify(config2.schemaVersion)},`,
` "aliases": ${serializeStringRecord(config2.aliases, 2)},`,
` "ignoredFields": ${serializeJson(sortedUnique(config2.ignoredFields), 2)},`,
` "requiredFields": ${serializeJson(sortedUnique(config2.requiredFields), 2)},`,
` "severities": ${serializeStringRecord(config2.severities, 2)},`,
` "releaseConsistencyFields": ${serializeJson(sortedUnique(config2.releaseConsistencyFields), 2)},`,
` "positionMatch": ${serializeJson({
enabled: config2.positionMatch.enabled,
releaseKeyField: config2.positionMatch.releaseKeyField
}, 2)},`,
` "delimiter": ${JSON.stringify(config2.delimiter)},`,
` "formattingSeverities": ${serializeJson({
outerWhitespace: config2.formattingSeverities.outerWhitespace,
lineEndings: config2.formattingSeverities.lineEndings,
identifierSeparators: config2.formattingSeverities.identifierSeparators,
unicodeNormalization: config2.formattingSeverities.unicodeNormalization
}, 2)},`,
` "significantPresenceFields": ${serializeJson(sortedUnique(config2.significantPresenceFields), 2)}`,
"}",
""
].join("\n");
}
function isPlainObject(value) {
if (typeof value !== "object" || value === null)
return false;
const prototype = Object.getPrototypeOf(value);
return prototype === Object.prototype || prototype === null;
}
function assertExactKeys(value, allowed, name) {
for (const key of Object.keys(value)) {
if (!allowed.has(key))
throw new ConfigError(`unknown ${name} property: ${key}`);
}
}
function assertStringRecord(value, name) {
if (!isPlainObject(value))
throw new ConfigError(`${name} must be an object`);
for (const [key, item] of Object.entries(value)) {
assertMapKey(key, name);
if (typeof item !== "string")
throw new ConfigError(`${name}.${key} must be a string`);
}
}
function assertMapKey(key, name) {
const codePoints = [...key].length;
if (codePoints < 1 || codePoints > 256) {
throw new ConfigError(`${name} property names must contain 1 to 256 characters`);
}
}
function assertStringArray(value, name) {
if (!Array.isArray(value))
throw new ConfigError(`${name} must be an array of strings`);
for (let index = 0; index < value.length; index += 1) {
if (typeof value[index] !== "string")
throw new ConfigError(`${name} must be an array of strings`);
}
}
function assertSeverityRecord(value) {
assertStringRecord(value, "severities");
for (const [key, severity] of Object.entries(value)) {
if (!isSeverity(severity))
throw new ConfigError(`severities.${key} must be info, normal, or high`);
}
}
function assertPositionMatch(value) {
if (!isPlainObject(value))
throw new ConfigError("positionMatch must be an object");
assertExactKeys(value, POSITION_MATCH_KEYS, "positionMatch");
if (typeof value.enabled !== "boolean")
throw new ConfigError("positionMatch.enabled must be a boolean");
if (typeof value.releaseKeyField !== "string") {
throw new ConfigError("positionMatch.releaseKeyField must be a string");
}
}
function assertDelimiter(value) {
if (value !== "auto" && value !== "," && value !== ";" && value !== " ") {
throw new ConfigError("delimiter must be auto, comma, semicolon, or tab");
}
}
function assertFormattingSeverities(value) {
if (!isPlainObject(value))
throw new ConfigError("formattingSeverities must be an object");
assertExactKeys(value, FORMATTING_SEVERITY_KEYS, "formattingSeverities");
for (const key of FORMATTING_SEVERITY_KEYS) {
if (!isSeverity(value[key])) {
throw new ConfigError(`formattingSeverities.${key} must be info, normal, or high`);
}
}
}
function isSeverity(value) {
return value === "info" || value === "normal" || value === "high";
}
function deepFreezeConfig(value, preserveDeclaredArrayOrder = false) {
return Object.freeze({
schemaVersion: value.schemaVersion,
aliases: freezeStringRecord(value.aliases),
ignoredFields: freezeStringArray(value.ignoredFields, preserveDeclaredArrayOrder),
requiredFields: freezeStringArray(value.requiredFields, preserveDeclaredArrayOrder),
severities: freezeSeverityRecord(value.severities),
releaseConsistencyFields: freezeStringArray(value.releaseConsistencyFields, preserveDeclaredArrayOrder),
positionMatch: Object.freeze({
enabled: value.positionMatch.enabled,
releaseKeyField: value.positionMatch.releaseKeyField
}),
delimiter: value.delimiter,
formattingSeverities: Object.freeze({
outerWhitespace: value.formattingSeverities.outerWhitespace,
lineEndings: value.formattingSeverities.lineEndings,
identifierSeparators: value.formattingSeverities.identifierSeparators,
unicodeNormalization: value.formattingSeverities.unicodeNormalization
}),
significantPresenceFields: freezeStringArray(value.significantPresenceFields, preserveDeclaredArrayOrder)
});
}
function freezeStringRecord(value) {
const copy2 = /* @__PURE__ */ Object.create(null);
for (const [key, item] of sortedEntries(value))
copy2[key] = item;
return Object.freeze(copy2);
}
function freezeSeverityRecord(value) {
const copy2 = /* @__PURE__ */ Object.create(null);
for (const [key, item] of sortedEntries(value))
copy2[key] = item;
return Object.freeze(copy2);
}
function freezeStringArray(values, preserveDeclaredOrder) {
return Object.freeze(preserveDeclaredOrder ? [...values] : sortedUnique(values));
}
function serializeStringRecord(value, indent) {
const entries = sortedEntries(value);
if (entries.length === 0)
return "{}";
const memberIndent = " ".repeat(indent + 2);
const closingIndent = " ".repeat(indent);
const members = entries.map(([key, item]) => `${memberIndent}${JSON.stringify(key)}: ${JSON.stringify(item)}`);
return `{
${members.join(",\n")}
${closingIndent}}`;
}
function serializeJson(value, indent) {
return JSON.stringify(value, null, 2).replaceAll("\n", `
${" ".repeat(indent)}`);
}
function sortedEntries(value) {
return Object.entries(value).sort(([left], [right]) => compareCodePoints(left, right));
}
function sortedUnique(values) {
return [...new Set(values)].sort(compareCodePoints);
}
function compareCodePoints(left, right) {
return left < right ? -1 : left > right ? 1 : 0;
}
// packages/core/dist/src/normalization.js
function normalizeHeader(value) {
return value.normalize("NFC").trim().replace(/[ ._-]+/g, "_").replace(/[A-Z]/g, (c) => c.toLowerCase());
}
function normalizeText(value) {
return value.normalize("NFC").replace(/\r\n?/g, "\n");
}
function normalizeForField(field, raw4) {
const text = normalizeText(raw4);
if (field === "isrc")
return text.replace(/[ -]/g, "").toUpperCase();
if (field === "upc_ean")
return text.replace(/[ -]/g, "");
if (field === "record_id" || field === "release_id")
return text.trim();
if (field === "disc_number" || field === "track_number")
return text.trim();
return text.trim();
}
function formattingDifferenceKinds(field, before, after) {
if (before === after || normalizeForField(field, before) !== normalizeForField(field, after))
return [];
const kinds = /* @__PURE__ */ new Set();
const beforeLines = before.replace(/\r\n?/g, "\n");
const afterLines = after.replace(/\r\n?/g, "\n");
if (before !== beforeLines || after !== afterLines)
kinds.add("lineEndings");
if (beforeLines !== beforeLines.trim() || afterLines !== afterLines.trim())
kinds.add("outerWhitespace");
const beforeCore = beforeLines.trim();
const afterCore = afterLines.trim();
if ((field === "isrc" || field === "upc_ean") && beforeCore !== afterCore) {
kinds.add("identifierSeparators");
}
if (beforeCore !== afterCore && beforeCore.normalize("NFC") === afterCore.normalize("NFC")) {
kinds.add("unicodeNormalization");
}
if (kinds.size === 0)
kinds.add("unicodeNormalization");
return [...kinds];
}
// packages/core/dist/src/identifiers.js
function invalid(normalized, code, message) {
return { valid: false, normalized, code, message };
}
function validateIsrc(raw4) {
const normalized = normalizeForField("isrc", raw4);
if (/^[A-Z]{2}[A-Z0-9]{3}[0-9]{7}$/.test(normalized))
return { valid: true, normalized };
return {
valid: false,
normalized,
code: "invalid_isrc",
message: "ISRC must contain 2 letters, 3 alphanumeric registrant characters, and 7 digits"
};
}
function gs1CheckDigit(body) {
let sum = 0;
for (let index = body.length - 1, position = 1; index >= 0; index -= 1, position += 1) {
sum += Number(body[index]) * (position % 2 === 1 ? 3 : 1);
}
return (10 - sum % 10) % 10;
}
function validateUpcEan(raw4) {
const normalized = normalizeForField("upc_ean", raw4);
if (!/^\d+$/.test(normalized))
return invalid(normalized, "invalid_barcode_characters", "UPC/EAN must contain decimal digits only");
if (normalized.length !== 12 && normalized.length !== 13) {
return invalid(normalized, "unsupported_barcode_length", "ReleaseDiff v1 supports UPC-A (12 digits) and EAN-13 (13 digits)");
}
const expected = gs1CheckDigit(normalized.slice(0, -1));
return expected === Number(normalized.at(-1)) ? { valid: true, normalized } : invalid(normalized, "invalid_barcode_check_digit", `UPC/EAN check digit must be ${expected}`);
}
function validatePositivePosition(raw4) {
const normalized = normalizeForField("track_number", raw4);
if (!/^[0-9]+$/.test(normalized) || /^0+$/.test(normalized)) {
return invalid(normalized, "invalid_position", "Position must be a positive base-10 integer");
}
return { valid: true, normalized: normalized.replace(/^0+(?=\d)/, "") };
}
// packages/core/dist/src/cells.js
var ABSENT_CELL = Object.freeze({
presence: "absent",
raw: null,
originalType: null,
sourceHeader: null
});
function presentCell(raw4, originalType, sourceHeader) {
return Object.freeze({
presence: raw4 === null || raw4 === "" ? "blank" : "present",
raw: raw4,
originalType,
sourceHeader
});
}
function getCell(record, field) {
return record.fields.get(field) ?? ABSENT_CELL;
}
// packages/core/dist/src/position.js
function positionKey(record, config2) {
const releaseField = config2.positionMatch.releaseKeyField;
const releaseKey = validReleaseKey(record, releaseField);
const disc = validatePositivePosition(raw(record, "disc_number"));
const track = validatePositivePosition(raw(record, "track_number"));
if (releaseKey === "" || !disc.valid || !track.valid)
return null;
return {
releaseField,
releaseKey,
disc: disc.normalized,
track: track.normalized,
key: JSON.stringify([releaseKey, disc.normalized, track.normalized])
};
}
function validReleaseKey(record, field) {
const value = raw(record, field);
if (field === "upc_ean") {
const upcEan = validateUpcEan(value);
return upcEan.valid ? upcEan.normalized : "";
}
if (field === "isrc") {
const isrc = validateIsrc(value);
return isrc.valid ? isrc.normalized : "";
}
return normalizeForField(field, value);
}
function raw(record, field) {
return getCell(record, field).raw ?? "";
}
// packages/core/dist/src/dataset-validation.js
var IDENTIFIER_FIELDS = [
"record_id",
"release_id",
"isrc",
"upc_ean",
"catalog_number"
];
var POSITION_FIELDS = ["disc_number", "track_number"];
function validateDataset(dataset, config2, input) {
const records = sortedRecords(dataset.records);
const blockingIssues = [...dataset.adapterBlockingIssues];
appendRequiredFieldIssues(blockingIssues, records, config2);
appendNonStringIdentifierIssues(blockingIssues, records);
appendIdentifierIssues(blockingIssues, records);
appendPositionIssues(blockingIssues, records);
appendMissingIdentityIssues(blockingIssues, records, config2);
appendDuplicateIssues(blockingIssues, records, "record_id", "duplicate_record_id", (record) => normalizedRaw(record, "record_id"));
appendDuplicateIssues(blockingIssues, records, "isrc", "duplicate_isrc", validIsrcKey);
appendPositionDuplicateIssues(blockingIssues, records, config2);
appendReleaseConsistencyIssues(blockingIssues, records, config2);
appendBarcodeIdentityIssues(blockingIssues, records, config2);
return {
blockingIssues: blockingIssues.map((issue2) => attribute(issue2, input)),
diagnostics: dataset.adapterDiagnostics.map((issue2) => attribute(issue2, input))
};
}
function attribute(draft, input) {
return { input, code: draft.code, message: draft.message, field: draft.field, rows: draft.rows };
}
function raw2(record, field) {
return getCell(record, field).raw ?? "";
}
function normalizedRaw(record, field) {
return normalizeForField(field, raw2(record, field));
}
function hasUsableIdentity(record, config2) {
const recordId = normalizedRaw(record, "record_id");
const isrc = raw2(record, "isrc");
const position = config2.positionMatch.enabled && positionKey(record, config2) !== null;
return recordId !== "" || isrc !== "" && validateIsrc(isrc).valid || position;
}
function appendRequiredFieldIssues(issues, records, config2) {
const fields = sortedUnique2(config2.requiredFields);
for (const record of records) {
for (const field of fields) {
if (normalizedRaw(record, field) === "") {
issues.push(issue("missing_required_field", `Missing required field ${field}`, field, [record.sourceRow]));
}
}
}
}
function appendNonStringIdentifierIssues(issues, records) {
for (const record of records) {
for (const field of IDENTIFIER_FIELDS) {
const cell = getCell(record, field);
if (cell.raw !== "" && cell.raw !== null && (cell.originalType === "number" || cell.originalType === "boolean")) {
issues.push(issue("non_string_identifier", `${field} must be a string in source data`, field, [record.sourceRow]));
}
}
}
}
function appendIdentifierIssues(issues, records) {
for (const record of records) {
appendIdentifierIssue(issues, record, "isrc", validateIsrc);
appendIdentifierIssue(issues, record, "upc_ean", validateUpcEan);
}
}
function appendIdentifierIssue(issues, record, field, validate) {
const value = raw2(record, field);
if (value === "")
return;
const result = validate(value);
if (!result.valid)
issues.push(issue(result.code, result.message, field, [record.sourceRow]));
}
function appendPositionIssues(issues, records) {
for (const record of records) {
for (const field of POSITION_FIELDS) {
const value = raw2(record, field);
if (value === "")
continue;
const result = validatePositivePosition(value);
if (!result.valid)
issues.push(issue(result.code, result.message, field, [record.sourceRow]));
}
}
}
function appendMissingIdentityIssues(issues, records, config2) {
for (const record of records) {
if (!hasUsableIdentity(record, config2)) {
issues.push(issue("missing_stable_identity", "Record has no usable stable identity", null, [record.sourceRow]));
}
}
}
function appendDuplicateIssues(issues, records, field, code, keyOf) {
const index = duplicateRowsByKey(records, keyOf);
for (const [key, rows] of sortedEntriesByFirstRow(index, (rows2) => rows2[0])) {
issues.push(issue(code, `Duplicate ${field} value ${JSON.stringify(key)}`, field, rows));
}
}
function appendPositionDuplicateIssues(issues, records, config2) {
if (!config2.positionMatch.enabled)
return;
const parts = /* @__PURE__ */ new Map();
const index = duplicateRowsByKey(records, (record) => {
const position = positionKey(record, config2);
if (position === null)
return "";
parts.set(position.key, position);
return position.key;
});
for (const [key, rows] of sortedEntriesByFirstRow(index, (rows2) => rows2[0])) {
const position = parts.get(key);
issues.push(issue("duplicate_position", `Duplicate configured position for ${position.releaseField} ${JSON.stringify(position.releaseKey)}: disc ${position.disc}, track ${position.track}`, "track_number", rows));
}
}
function appendReleaseConsistencyIssues(issues, records, config2) {
appendGroupConflictIssues(issues, records, (record) => normalizedRaw(record, "release_id"), sortedUnique2(config2.releaseConsistencyFields), "conflicting_release_value", (field, releaseId) => `Conflicting ${field} values for release_id ${JSON.stringify(releaseId)}`);
}
function appendBarcodeIdentityIssues(issues, records, config2) {
const fields = sortedUnique2([...config2.releaseConsistencyFields, "release_id"]).filter((field) => field !== "upc_ean");
appendGroupConflictIssues(issues, records, (record) => {
const barcode = validateUpcEan(raw2(record, "upc_ean"));
return barcode.valid ? barcode.normalized : "";
}, fields, "conflicting_barcode_identity", (field, barcode) => `Conflicting ${field} values for upc_ean ${JSON.stringify(barcode)}`, (group) => sharesOneReleaseId(group));
}
function sharesOneReleaseId(group) {
let shared = null;
for (const record of group) {
const releaseId = normalizedRaw(record, "release_id");
if (releaseId === "")
return false;
if (shared === null)
shared = releaseId;
else if (releaseId !== shared)
return false;
}
return shared !== null;
}
function appendGroupConflictIssues(issues, records, groupKeyOf, fields, code, messageOf, skipGroup = () => false) {
const groups = /* @__PURE__ */ new Map();
const candidates = [];
for (const record of records) {
const groupKey = groupKeyOf(record);
if (groupKey === "")
continue;
const group = groups.get(groupKey);
if (group === void 0)
groups.set(groupKey, [record]);
else
group.push(record);
}
for (const [groupKey, group] of groups) {
if (skipGroup(group))
continue;
for (const field of fields) {
const values = /* @__PURE__ */ new Map();
for (const record of group) {
const value = normalizedRaw(record, field);
if (value === "")
continue;
const rows2 = values.get(value);
if (rows2 === void 0)
values.set(value, [record.sourceRow]);
else
rows2.push(record.sourceRow);
}
if (values.size < 2)
continue;
const rows = [...values.values()].flat().sort(compareNumbers);
candidates.push({ groupKey, field, rows });
}
}
candidates.sort((left, right) => {
const rowOrder = compareNumbers(left.rows[0], right.rows[0]);
if (rowOrder !== 0)
return rowOrder;
const groupOrder = compareCodePoints2(left.groupKey, right.groupKey);
return groupOrder !== 0 ? groupOrder : compareCodePoints2(left.field, right.field);
});
for (const candidate of candidates) {
issues.push(issue(code, messageOf(candidate.field, candidate.groupKey), candidate.field, candidate.rows));
}
}
function validIsrcKey(record) {
const value = raw2(record, "isrc");
if (value === "")
return "";
const result = validateIsrc(value);
return result.valid ? result.normalized : "";
}
function duplicateRowsByKey(records, keyOf) {
const allRows = /* @__PURE__ */ new Map();
for (const record of records) {
const key = keyOf(record);
if (key === "")
continue;
const rows = allRows.get(key);
if (rows === void 0)
allRows.set(key, [record.sourceRow]);
else
rows.push(record.sourceRow);
}
const duplicates = /* @__PURE__ */ new Map();
for (const [key, rows] of allRows) {
if (rows.length > 1)
duplicates.set(key, rows.sort(compareNumbers));
}
return duplicates;
}
function issue(code, message, field, rows) {
return { code, message, field, rows };
}
function sortedRecords(records) {
return records.map((record, index) => ({ record, index })).sort((left, right) => {
const rowOrder = compareNumbers(left.record.sourceRow, right.record.sourceRow);
return rowOrder !== 0 ? rowOrder : compareNumbers(left.index, right.index);
}).map((item) => item.record);
}
function sortedUnique2(values) {
return [...new Set(values)].sort(compareCodePoints2);
}
function sortedEntriesByFirstRow(value, firstRowOf) {
return [...value.entries()].sort(([leftKey, left], [rightKey, right]) => {
const rowOrder = compareNumbers(firstRowOf(left), firstRowOf(right));
return rowOrder !== 0 ? rowOrder : compareCodePoints2(leftKey, rightKey);
});
}
function compareCodePoints2(left, right) {
return left < right ? -1 : left > right ? 1 : 0;
}
function compareNumbers(left, right) {
return left - right;
}
// packages/core/dist/src/matching.js
function matchDatasets(before, after, config2) {
const unmatchedBefore = indexesOf(before.records);
const unmatchedAfter = indexesOf(after.records);
const recordIdKey = (record) => normalizedRaw2(record, "record_id");
const isrcKey = (record) => validIsrcKey2(record);
const blockingIssues = conflictingIdentityIssues(before, after, recordIdKey, isrcKey);
const pairs = [
...matchUnique(before, after, unmatchedBefore, unmatchedAfter, "record_id", recordIdKey),
...matchUnique(before, after, unmatchedBefore, unmatchedAfter, "isrc", isrcKey)
];
if (config2.positionMatch.enabled) {
pairs.push(...matchUnique(before, after, unmatchedBefore, unmatchedAfter, "position", (record) => positionKey(record, config2)?.key ?? ""));
}
return {
pairs,
unmatchedBefore: sortedIndexesBySourceRow(before.records, unmatchedBefore),
unmatchedAfter: sortedIndexesBySourceRow(after.records, unmatchedAfter),
blockingIssues
};
}
function matchUnique(before, after, unmatchedBefore, unmatchedAfter, rule, keyOf) {
const beforeKeys = uniqueIndex(before.records, unmatchedBefore, keyOf);
const afterKeys = uniqueIndex(after.records, unmatchedAfter, keyOf);
const pairs = [];
for (const key of [...beforeKeys.keys()].sort(compareCodePoints3)) {
const beforeIndex = beforeKeys.get(key);
const afterIndex = afterKeys.get(key);
if (beforeIndex === void 0 || afterIndex === void 0)
continue;
pairs.push({ beforeIndex, afterIndex, rule, key });
unmatchedBefore.delete(beforeIndex);
unmatchedAfter.delete(afterIndex);
}
return pairs;
}
function conflictingIdentityIssues(before, after, recordIdKey, isrcKey) {
const recordIdsBefore = uniqueIndex(before.records, indexesOf(before.records), recordIdKey);
const recordIdsAfter = uniqueIndex(after.records, indexesOf(after.records), recordIdKey);
const isrcsBefore = uniqueIndex(before.records, indexesOf(before.records), isrcKey);
const isrcsAfter = uniqueIndex(after.records, indexesOf(after.records), isrcKey);
const issuesByRows = /* @__PURE__ */ new Map();
appendConflictingIdentityIssues(issuesByRows, before.records, after.records, recordIdsBefore, recordIdsAfter, isrcsBefore, isrcsAfter, recordIdKey, isrcKey);
appendConflictingIdentityIssues(issuesByRows, after.records, before.records, recordIdsAfter, recordIdsBefore, isrcsAfter, isrcsBefore, recordIdKey, isrcKey);
return [...issuesByRows.values()].sort((left, right) => {
for (let index = 0; index < Math.min(left.rows.length, right.rows.length); index += 1) {
const rowOrder = compareNumbers2(left.rows[index], right.rows[index]);
if (rowOrder !== 0)
return rowOrder;
}
return compareNumbers2(left.rows.length, right.rows.length);
});
}
function appendConflictingIdentityIssues(issuesByRows, sourceRecords, counterpartRecords, sourceRecordIds, counterpartRecordIds, sourceIsrcs, counterpartIsrcs, recordIdKey, isrcKey) {
for (const sourceIndex of sortedIndexesBySourceRow(sourceRecords, indexesOf(sourceRecords))) {
const recordId = recordIdKey(sourceRecords[sourceIndex]);
const isrc = isrcKey(sourceRecords[sourceIndex]);
const recordIdCounterpart = recordId === "" ? void 0 : counterpartRecordIds.get(recordId);
const isrcCounterpart = isrc === "" ? void 0 : counterpartIsrcs.get(isrc);
if (recordIdCounterpart === void 0 || isrcCounterpart === void 0 || recordIdCounterpart === isrcCounterpart)
continue;
if (sourceRecordIds.get(recordId) !== sourceIndex || sourceIsrcs.get(isrc) !== sourceIndex)
continue;
const rows = [
sourceRecords[sourceIndex].sourceRow,
counterpartRecords[recordIdCounterpart].sourceRow,
counterpartRecords[isrcCounterpart].sourceRow
].sort(compareNumbers2);
const uniqueRows = [...new Set(rows)];
const signature = JSON.stringify(uniqueRows);
if (!issuesByRows.has(signature)) {
issuesByRows.set(signature, {
// The rows come from both files, so neither file alone is the answer.
input: "both",
code: "conflicting_identity_evidence",
message: "record_id and ISRC identify different counterpart rows",
field: null,
rows: uniqueRows
});
}
}
}
function uniqueIndex(records, unmatched, keyOf) {
const index = /* @__PURE__ */ new Map();
const duplicates = /* @__PURE__ */ new Set();
for (const recordIndex of unmatched) {
const key = keyOf(records[recordIndex]);
if (key === "" || duplicates.has(key))
continue;
if (index.has(key)) {
index.delete(key);
duplicates.add(key);
} else {
index.set(key, recordIndex);
}
}
return index;
}
function validIsrcKey2(record) {
const isrc = validateIsrc(raw3(record, "isrc"));
return isrc.valid ? isrc.normalized : "";
}
function raw3(record, field) {
return getCell(record, field).raw ?? "";
}
function normalizedRaw2(record, field) {
return normalizeForField(field, raw3(record, field));
}
function indexesOf(records) {
return new Set(records.map((_, index) => index));
}
function sortedIndexesBySourceRow(records, indexes) {