fluncle 0.246.0 → 0.248.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 (2) hide show
  1. package/bin/fluncle.mjs +85 -3
  2. package/package.json +1 -1
package/bin/fluncle.mjs CHANGED
@@ -622,7 +622,7 @@ function parseVersion(version) {
622
622
  var currentVersion;
623
623
  var init_version = __esm(() => {
624
624
  init_output();
625
- currentVersion = "0.246.0".trim() ? "0.246.0".trim() : "0.1.0";
625
+ currentVersion = "0.248.0".trim() ? "0.248.0".trim() : "0.1.0";
626
626
  });
627
627
 
628
628
  // src/update-notifier.ts
@@ -2335,7 +2335,7 @@ function parseVersion2(version) {
2335
2335
  var currentVersion2, latestReleaseUrl = "https://api.github.com/repos/mauricekleine/fluncle/releases/latest";
2336
2336
  var init_version2 = __esm(() => {
2337
2337
  init_output();
2338
- currentVersion2 = "0.246.0".trim() ? "0.246.0".trim() : "0.1.0";
2338
+ currentVersion2 = "0.248.0".trim() ? "0.248.0".trim() : "0.1.0";
2339
2339
  });
2340
2340
 
2341
2341
  // ../../packages/registry/src/index.ts
@@ -13494,7 +13494,7 @@ var init_admin_hub_counts = __esm(() => {
13494
13494
  });
13495
13495
 
13496
13496
  // ../../packages/contracts/src/orpc/admin-labels.ts
13497
- var LabelSeedStateSchema, LabelAdminItemSchema, listLabelsAdmin, updateLabel, listLabelArtistRules, replaceLabelArtistRules, MergeLabelResultSchema, mergeLabel, LabelAliasSourceSchema, LabelAliasKindSchema, LabelAliasCandidateSchema, listLabelAliases, confirmLabelAlias, rejectLabelAlias, DescribeLabelBodySchema, describeLabel, draftLabelBio, LabelBioWorkItemSchema, listLabelsMissingBio, adminLabelsContract;
13497
+ var LabelSeedStateSchema, LabelAdminItemSchema, listLabelsAdmin, updateLabel, listLabelArtistRules, replaceLabelArtistRules, MergeLabelResultSchema, mergeLabel, MB_LABEL_MBID_PATTERN, MintLabelOutcomeSchema, LabelTakeOverResultSchema, mintLabel, LabelAliasSourceSchema, LabelAliasKindSchema, LabelAliasCandidateSchema, listLabelAliases, confirmLabelAlias, rejectLabelAlias, DescribeLabelBodySchema, describeLabel, draftLabelBio, LabelBioWorkItemSchema, listLabelsMissingBio, adminLabelsContract;
13498
13498
  var init_admin_labels = __esm(() => {
13499
13499
  init_dist3();
13500
13500
  init_zod();
@@ -13588,6 +13588,34 @@ var init_admin_labels = __esm(() => {
13588
13588
  summary: "Merge a slug-split label into its canonical row (operator; re-points + redirects)",
13589
13589
  tags: ["Admin"]
13590
13590
  }).input(object({ canonicalSlug: string2(), slug: string2() })).output(object({ ok: literal(true), result: MergeLabelResultSchema }));
13591
+ MB_LABEL_MBID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
13592
+ MintLabelOutcomeSchema = _enum(["minted", "adopted", "known", "taken_over"]).meta({ id: "MintLabelOutcome" });
13593
+ LabelTakeOverResultSchema = object({
13594
+ clearedFacts: array(string2()),
13595
+ droppedRules: number2(),
13596
+ previousMbLabelId: string2().nullable(),
13597
+ rearmedSeedNode: boolean2(),
13598
+ retiredFrontierNodes: number2(),
13599
+ slug: string2()
13600
+ }).meta({ id: "LabelTakeOverResult" });
13601
+ mintLabel = oc.route({
13602
+ method: "POST",
13603
+ operationId: "mintLabel",
13604
+ path: "/admin/labels",
13605
+ summary: "Mint a label from its MusicBrainz identity (operator; connect-or-create, idempotent)",
13606
+ tags: ["Admin"]
13607
+ }).input(object({
13608
+ mbLabelId: string2().regex(MB_LABEL_MBID_PATTERN, {
13609
+ error: "mbLabelId must be a MusicBrainz label MBID"
13610
+ }),
13611
+ seedState: LabelSeedStateSchema.optional(),
13612
+ takeOverSlug: string2().min(1).optional()
13613
+ })).output(object({
13614
+ label: LabelAdminItemSchema,
13615
+ ok: literal(true),
13616
+ outcome: MintLabelOutcomeSchema,
13617
+ takenOver: LabelTakeOverResultSchema.optional()
13618
+ }));
13591
13619
  LabelAliasSourceSchema = _enum(["operator", "apple", "musicbrainz", "discogs", "spotify"]).meta({ id: "LabelAliasSource" });
13592
13620
  LabelAliasKindSchema = _enum(["name", "hint"]).meta({ id: "LabelAliasKind" });
13593
13621
  LabelAliasCandidateSchema = object({
@@ -13674,6 +13702,7 @@ var init_admin_labels = __esm(() => {
13674
13702
  list_labels_admin: listLabelsAdmin,
13675
13703
  list_labels_missing_bio: listLabelsMissingBio,
13676
13704
  merge_label: mergeLabel,
13705
+ mint_label: mintLabel,
13677
13706
  reject_label_alias: rejectLabelAlias,
13678
13707
  replace_label_artist_rules: replaceLabelArtistRules,
13679
13708
  update_label: updateLabel
@@ -19114,6 +19143,18 @@ async function updateLabelCommand(slugOrId, seedState, rewalk = false) {
19114
19143
  });
19115
19144
  return response.label;
19116
19145
  }
19146
+ async function mintLabelCommand(mbLabelId, seedState, takeOverSlug) {
19147
+ const mbid = mbLabelId.trim().toLowerCase();
19148
+ if (!MBID_PATTERN2.test(mbid)) {
19149
+ throw new Error(`'${mbLabelId}' is not a MusicBrainz label MBID`);
19150
+ }
19151
+ const response = await adminApiPost("/api/v1/admin/labels", {
19152
+ mbLabelId: mbid,
19153
+ ...seedState === undefined ? {} : { seedState },
19154
+ ...takeOverSlug === undefined ? {} : { takeOverSlug: takeOverSlug.trim().toLowerCase() }
19155
+ });
19156
+ return { label: response.label, outcome: response.outcome, takenOver: response.takenOver };
19157
+ }
19117
19158
  async function describeLabelCommand(slug, options) {
19118
19159
  return adminApiPost(`/api/v1/admin/labels/${encodeURIComponent(slug)}/bio`, buildBioBody2(options));
19119
19160
  }
@@ -21567,6 +21608,28 @@ function labelUpdateLines(label, options) {
21567
21608
  }
21568
21609
  return lines;
21569
21610
  }
21611
+ var LABEL_MINT_WORDS = {
21612
+ adopted: "ADOPTED",
21613
+ known: "ALREADY KNOWN",
21614
+ minted: "MINTED",
21615
+ taken_over: "TAKEN OVER"
21616
+ };
21617
+ function labelMintLine(label, outcome, requestedMbid, takenOver) {
21618
+ const word = LABEL_MINT_WORDS[outcome] ?? outcome.toUpperCase();
21619
+ const line = `${word} \u2014 ${label.name} (${label.slug}), MusicBrainz ${label.mbLabelId ?? requestedMbid}, seed state ${label.seedState.toUpperCase()}.`;
21620
+ if (!takenOver) {
21621
+ return line;
21622
+ }
21623
+ const dropped = [
21624
+ `replaced MusicBrainz ${takenOver.previousMbLabelId ?? "none"}`,
21625
+ `${takenOver.droppedRules} artist ${takenOver.droppedRules === 1 ? "rule" : "rules"} dropped`,
21626
+ ...takenOver.clearedFacts.length === 0 ? [] : [`cleared ${takenOver.clearedFacts.join(", ")}`],
21627
+ ...takenOver.retiredFrontierNodes === 0 ? [] : ["retired the old crawl node"],
21628
+ ...takenOver.rearmedSeedNode ? ["re-armed the seed"] : []
21629
+ ].join(" \xB7 ");
21630
+ return `${line}
21631
+ ${dropped}.`;
21632
+ }
21570
21633
  var ARTIST_RULE_BOUNDARY = "Rules change what the next crawl takes. Everything already here stays.";
21571
21634
  var UNLISTED_RULE_BOUNDARY = "Unlisted takes the artist page down. The crawl and everything already here stay.";
21572
21635
  function artistRuleWriteLine(prefix, boundary = ARTIST_RULE_BOUNDARY) {
@@ -22894,6 +22957,23 @@ JSON field reference:
22894
22957
  console.log(line);
22895
22958
  }
22896
22959
  });
22960
+ labels.command("mint").description("Mint a label from its MusicBrainz MBID (operator; idempotent)").argument("<mbid>", "The MusicBrainz label MBID").option("--seed-state <state>", "Rule it on arrival: enabled, disabled, or undecided").option("--take-over <slug>", "Re-point this trackless row's identity onto the minted entity").option("--json", "Print JSON", false).action(async (mbid, options) => {
22961
+ const seedState = options.seedState;
22962
+ if (seedState !== undefined && seedState !== "enabled" && seedState !== "disabled" && seedState !== "undecided") {
22963
+ throw new Error("Pass --seed-state enabled|disabled|undecided");
22964
+ }
22965
+ const takeOver = options.takeOver?.trim();
22966
+ if (options.takeOver !== undefined && !takeOver) {
22967
+ throw new Error("Pass --take-over <slug>");
22968
+ }
22969
+ await Promise.resolve().then(() => init_admin_labels2());
22970
+ const { label, outcome, takenOver } = await mintLabelCommand(mbid, seedState, takeOver);
22971
+ if (options.json) {
22972
+ printJson({ label, ok: true, outcome, ...takenOver ? { takenOver } : {} });
22973
+ return;
22974
+ }
22975
+ console.log(labelMintLine(label, outcome, mbid, takenOver));
22976
+ });
22897
22977
  labels.command("merge").description("Merge a slug-split label into its canonical row (operator; re-points + redirects)").argument("<losingSlug>", "The duplicate label to fold away").argument("<canonicalSlug>", "The label to keep \u2014 everything re-points onto it").option("--json", "Print JSON", false).action(async (losingSlug, canonicalSlug, options) => {
22898
22978
  await Promise.resolve().then(() => init_admin_labels2());
22899
22979
  const result = await mergeLabelCommand(losingSlug, canonicalSlug);
@@ -25909,6 +25989,7 @@ var stringOptions = new Set([
25909
25989
  "--stream",
25910
25990
  "--stream-version",
25911
25991
  "--subject",
25992
+ "--take-over",
25912
25993
  "--target",
25913
25994
  "--title",
25914
25995
  "--through-seq",
@@ -25969,6 +26050,7 @@ export {
25969
26050
  UNLISTED_RULE_BOUNDARY,
25970
26051
  artistRuleLines,
25971
26052
  createProgram,
26053
+ labelMintLine,
25972
26054
  labelUpdateLines,
25973
26055
  parseTelemetryTimestamp,
25974
26056
  unmatchedRowLine
package/package.json CHANGED
@@ -31,5 +31,5 @@
31
31
  "url": "git+https://github.com/mauricekleine/fluncle.git"
32
32
  },
33
33
  "type": "module",
34
- "version": "0.246.0"
34
+ "version": "0.248.0"
35
35
  }