« get me outta code hell

data, yaml: mark ignored fields on `fields` - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-22 10:31:58 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-30 07:59:40 -0400
commitb30585187480a270826767eaf97e1acc66126072 (patch)
tree6478ef73dc72b696c032b631c6ea7edc7fa521fa /src
parent98c2012c0c6233fe3f70ba215c19f6d39d7e1e34 (diff)
data, yaml: mark ignored fields on `fields`
Diffstat (limited to 'src')
-rw-r--r--src/data/things/album.js4
-rw-r--r--src/data/things/artist.js6
-rw-r--r--src/data/things/flash.js8
-rw-r--r--src/data/things/group.js4
-rw-r--r--src/data/things/homepage-layout.js4
-rw-r--r--src/data/things/static-page.js4
-rw-r--r--src/data/things/track.js4
-rw-r--r--src/data/yaml.js17
8 files changed, 28 insertions, 23 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 3a05ac83..9e6d28d9 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -279,9 +279,9 @@ export class Album extends Thing {
 
       'Groups': {property: 'groups'},
       'Art Tags': {property: 'artTags'},
-    },
 
-    ignoredFields: ['Review Points'],
+      'Review Points': {ignore: true},
+    },
   };
 }
 
diff --git a/src/data/things/artist.js b/src/data/things/artist.js
index 502510a8..ab08f522 100644
--- a/src/data/things/artist.js
+++ b/src/data/things/artist.js
@@ -251,8 +251,10 @@ export class Artist extends Thing {
       'Avatar File Extension': {property: 'avatarFileExtension'},
 
       'Aliases': {property: 'aliasNames'},
-    },
 
-    ignoredFields: ['Dead URLs', 'Review Points'],
+      'Dead URLs': {ignore: true},
+
+      'Review Points': {ignore: true},
+    },
   };
 }
diff --git a/src/data/things/flash.js b/src/data/things/flash.js
index 7e859bfa..945d80dd 100644
--- a/src/data/things/flash.js
+++ b/src/data/things/flash.js
@@ -147,9 +147,9 @@ export class Flash extends Thing {
         property: 'contributorContribs',
         transform: parseContributors,
       },
-    },
 
-    ignoredFields: ['Review Points'],
+      'Review Points': {ignore: true},
+    },
   };
 }
 
@@ -200,8 +200,8 @@ export class FlashAct extends Thing {
 
       'Jump': {property: 'jump'},
       'Jump Color': {property: 'jumpColor'},
-    },
 
-    ignoredFields: ['Review Points'],
+      'Review Points': {ignore: true},
+    },
   };
 }
diff --git a/src/data/things/group.js b/src/data/things/group.js
index fe04dfaa..adcd6ad1 100644
--- a/src/data/things/group.js
+++ b/src/data/things/group.js
@@ -93,9 +93,9 @@ export class Group extends Thing {
       'URLs': {property: 'urls'},
 
       'Featured Albums': {property: 'featuredAlbums'},
-    },
 
-    ignoredFields: ['Review Points'],
+      'Review Points': {ignore: true},
+    },
   };
 }
 
diff --git a/src/data/things/homepage-layout.js b/src/data/things/homepage-layout.js
index bd0970fe..38fd5a7a 100644
--- a/src/data/things/homepage-layout.js
+++ b/src/data/things/homepage-layout.js
@@ -42,11 +42,11 @@ export class HomepageLayout extends Thing {
 
   static [Thing.yamlDocumentSpec] = {
     fields: {
+      'Homepage': {ignore: true},
+
       'Sidebar Content': {property: 'sidebarContent'},
       'Navbar Links': {property: 'navbarLinks'},
     },
-
-    ignoredFields: ['Homepage'],
   };
 }
 
diff --git a/src/data/things/static-page.js b/src/data/things/static-page.js
index 7f8b7c91..2da7312b 100644
--- a/src/data/things/static-page.js
+++ b/src/data/things/static-page.js
@@ -38,8 +38,8 @@ export class StaticPage extends Thing {
       'Style': {property: 'stylesheet'},
       'Script': {property: 'script'},
       'Content': {property: 'content'},
-    },
 
-    ignoredFields: ['Review Points'],
+      'Review Points': {ignore: true},
+    },
   };
 }
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 9f44bd8d..dd102683 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -412,9 +412,9 @@ export class Track extends Thing {
       },
 
       'Art Tags': {property: 'artTags'},
-    },
 
-    ignoredFields: ['Review Points'],
+      'Review Points': {ignore: true},
+    },
 
     invalidFieldCombinations: [
       {message: `Re-releases inherit references from the original`, fields: [
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 19f56292..fe8bfdc0 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -80,14 +80,12 @@ function makeProcessDocument(thingConstructor, {
   // YAML into some other format before providing setting it on the Thing
   // instance.
   //
-  fields: fieldSpecs = {},
-
-  // Completely ignored fields. These won't throw an unknown field error if
-  // they're present in a document, but they won't be used for Thing property
-  // generation, either. Useful for stuff that's present in data files but not
-  // yet implemented as part of a Thing's data model!
+  // If a field entry has `ignore: true`, it will be completely skipped by the
+  // YAML parser - it won't be validated, read, or loaded into data objects.
+  // This is mainly useful for fields that are purely annotational or are
+  // currently placeholders.
   //
-  ignoredFields = [],
+  fields: fieldSpecs = {},
 
   // List of fields which are invalid when coexisting in a document.
   // Data objects are generally allowing with regards to what properties go
@@ -120,6 +118,11 @@ function makeProcessDocument(thingConstructor, {
 
   const knownFields = Object.keys(fieldSpecs);
 
+  const ignoredFields =
+    Object.entries(fieldSpecs)
+      .filter(([, {ignore}]) => ignore)
+      .map(([field]) => field);
+
   const propertyToField =
     withEntries(fieldSpecs, entries => entries
       .map(([field, {property}]) => [property, field]));