« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/language.js5
-rw-r--r--src/data/things/album.js6
-rw-r--r--src/data/things/art-tag.js6
-rw-r--r--src/data/things/artist.js4
-rw-r--r--src/data/things/cacheable-object.js4
-rw-r--r--src/data/things/flash.js4
-rw-r--r--src/data/things/group.js4
-rw-r--r--src/data/things/homepage-layout.js4
-rw-r--r--src/data/things/index.js15
-rw-r--r--src/data/things/thing.js16
-rw-r--r--src/data/things/track.js20
-rw-r--r--src/data/things/validators.js7
-rw-r--r--src/data/things/wiki-info.js4
-rw-r--r--src/data/yaml.js24
14 files changed, 64 insertions, 59 deletions
diff --git a/src/data/language.js b/src/data/language.js
index da9528f..0946690 100644
--- a/src/data/language.js
+++ b/src/data/language.js
@@ -1,11 +1,10 @@
-import {readFile} from 'fs/promises';
+import {readFile} from 'node:fs/promises';
 
 // It stands for "HTML Entities", apparently. Cursed.
 import he from 'he';
 
-import T from './things/index.js';
+import T from '#things';
 
-// TODO: define somewhere besides upd8.js obviously
 export async function processLanguageFile(file) {
   const contents = await readFile(file, 'utf-8');
   const json = JSON.parse(contents);
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 0c87b7c..c012c24 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -1,7 +1,7 @@
-import Thing from './thing.js';
+import {empty} from '#sugar';
+import find from '#find';
 
-import {empty} from '../../util/sugar.js';
-import find from '../../util/find.js';
+import Thing from './thing.js';
 
 export class Album extends Thing {
   static [Thing.referenceType] = 'album';
diff --git a/src/data/things/art-tag.js b/src/data/things/art-tag.js
index 75fb0f7..c103c4d 100644
--- a/src/data/things/art-tag.js
+++ b/src/data/things/art-tag.js
@@ -1,8 +1,6 @@
-import Thing from './thing.js';
+import {sortAlbumsTracksChronologically} from '#wiki-data';
 
-import {
-  sortAlbumsTracksChronologically,
-} from '../../util/wiki-data.js';
+import Thing from './thing.js';
 
 export class ArtTag extends Thing {
   static [Thing.referenceType] = 'tag';
diff --git a/src/data/things/artist.js b/src/data/things/artist.js
index f144b21..522ca5f 100644
--- a/src/data/things/artist.js
+++ b/src/data/things/artist.js
@@ -1,6 +1,6 @@
-import Thing from './thing.js';
+import find from '#find';
 
-import find from '../../util/find.js';
+import Thing from './thing.js';
 
 export class Artist extends Thing {
   static [Thing.referenceType] = 'artist';
diff --git a/src/data/things/cacheable-object.js b/src/data/things/cacheable-object.js
index 6a210cc..ea705a6 100644
--- a/src/data/things/cacheable-object.js
+++ b/src/data/things/cacheable-object.js
@@ -74,9 +74,9 @@
 //      function, which provides a mapping of exposed property names to whether
 //      or not their dependencies are yet met.
 
-import {color, ENABLE_COLOR} from '../../util/cli.js';
+import {inspect as nodeInspect} from 'node:util';
 
-import {inspect as nodeInspect} from 'util';
+import {color, ENABLE_COLOR} from '#cli';
 
 function inspect(value) {
   return nodeInspect(value, {colors: ENABLE_COLOR});
diff --git a/src/data/things/flash.js b/src/data/things/flash.js
index 1383fa8..6eb5234 100644
--- a/src/data/things/flash.js
+++ b/src/data/things/flash.js
@@ -1,6 +1,6 @@
-import Thing from './thing.js';
+import find from '#find';
 
-import find from '../../util/find.js';
+import Thing from './thing.js';
 
 export class Flash extends Thing {
   static [Thing.referenceType] = 'flash';
diff --git a/src/data/things/group.js b/src/data/things/group.js
index 111d671..ba339b3 100644
--- a/src/data/things/group.js
+++ b/src/data/things/group.js
@@ -1,6 +1,6 @@
-import Thing from './thing.js';
+import find from '#find';
 
-import find from '../../util/find.js';
+import Thing from './thing.js';
 
 export class Group extends Thing {
   static [Thing.referenceType] = 'group';
diff --git a/src/data/things/homepage-layout.js b/src/data/things/homepage-layout.js
index a79dd77..ec9e955 100644
--- a/src/data/things/homepage-layout.js
+++ b/src/data/things/homepage-layout.js
@@ -1,6 +1,6 @@
-import Thing from './thing.js';
+import find from '#find';
 
-import find from '../../util/find.js';
+import Thing from './thing.js';
 
 export class HomepageLayout extends Thing {
   static [Thing.getPropertyDescriptors] = ({
diff --git a/src/data/things/index.js b/src/data/things/index.js
index 11b6b1a..591cdc3 100644
--- a/src/data/things/index.js
+++ b/src/data/things/index.js
@@ -1,12 +1,12 @@
-import {logError} from '../../util/cli.js';
-import {openAggregate, showAggregate} from '../../util/sugar.js';
+import * as path from 'node:path';
+import {fileURLToPath} from 'node:url';
 
-import * as path from 'path';
-import {fileURLToPath} from 'url';
+import {logError} from '#cli';
+import * as serialize from '#serialize';
+import {openAggregate, showAggregate} from '#sugar';
+import * as validators from '#validators';
 
 import Thing from './thing.js';
-import * as validators from './validators.js';
-import * as serialize from '../serialize.js';
 
 import * as albumClasses from './album.js';
 import * as artTagClasses from './art-tag.js';
@@ -20,6 +20,9 @@ import * as staticPageClasses from './static-page.js';
 import * as trackClasses from './track.js';
 import * as wikiInfoClasses from './wiki-info.js';
 
+export {default as Thing} from './thing.js';
+export {default as CacheableObject} from './cacheable-object.js';
+
 const allClassLists = {
   'album.js': albumClasses,
   'art-tag.js': artTagClasses,
diff --git a/src/data/things/thing.js b/src/data/things/thing.js
index 5004f4e..c2876f5 100644
--- a/src/data/things/thing.js
+++ b/src/data/things/thing.js
@@ -1,7 +1,12 @@
 // Thing: base class for wiki data types, providing wiki-specific utility
 // functions on top of essential CacheableObject behavior.
 
-import CacheableObject from './cacheable-object.js';
+import {inspect} from 'node:util';
+
+import {color} from '#cli';
+import find from '#find';
+import {empty} from '#sugar';
+import {getKebabCase} from '#wiki-data';
 
 import {
   isAdditionalFileList,
@@ -19,14 +24,9 @@ import {
   validateInstanceOf,
   validateReference,
   validateReferenceList,
-} from './validators.js';
+} from '#validators';
 
-import {inspect} from 'util';
-import {color} from '../../util/cli.js';
-import {empty} from '../../util/sugar.js';
-import {getKebabCase} from '../../util/wiki-data.js';
-
-import find from '../../util/find.js';
+import CacheableObject from './cacheable-object.js';
 
 export default class Thing extends CacheableObject {
   static referenceType = Symbol('Thing.referenceType');
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 36e3adb..e176acb 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -1,10 +1,10 @@
-import Thing from './thing.js';
+import {inspect} from 'node:util';
 
-import {inspect} from 'util';
+import {color} from '#cli';
+import find from '#find';
+import {empty} from '#sugar';
 
-import {color} from '../../util/cli.js';
-import find from '../../util/find.js';
-import {empty} from '../../util/sugar.js';
+import Thing from './thing.js';
 
 export class Track extends Thing {
   static [Thing.referenceType] = 'track';
@@ -47,7 +47,15 @@ export class Track extends Thing {
     hasCoverArt: {
       flags: {update: true, expose: true},
 
-      update: {validate: isBoolean},
+      update: {
+        validate(value) {
+          if (value !== false) {
+            throw new TypeError(`Expected false or null`);
+          }
+
+          return true;
+        },
+      },
 
       expose: {
         dependencies: ['albumData', 'coverArtistContribsByRef'],
diff --git a/src/data/things/validators.js b/src/data/things/validators.js
index 1754adf..fc953c2 100644
--- a/src/data/things/validators.js
+++ b/src/data/things/validators.js
@@ -1,8 +1,7 @@
-import {withAggregate} from '../../util/sugar.js';
+import {inspect as nodeInspect} from 'node:util';
 
-import {color, ENABLE_COLOR} from '../../util/cli.js';
-
-import {inspect as nodeInspect} from 'util';
+import {color, ENABLE_COLOR} from '#cli';
+import {withAggregate} from '#sugar';
 
 function inspect(value) {
   return nodeInspect(value, {colors: ENABLE_COLOR});
diff --git a/src/data/things/wiki-info.js b/src/data/things/wiki-info.js
index adf085e..e906cab 100644
--- a/src/data/things/wiki-info.js
+++ b/src/data/things/wiki-info.js
@@ -1,6 +1,6 @@
-import Thing from './thing.js';
+import find from '#find';
 
-import find from '../../util/find.js';
+import Thing from './thing.js';
 
 export class WikiInfo extends Thing {
   static [Thing.getPropertyDescriptors] = ({
diff --git a/src/data/yaml.js b/src/data/yaml.js
index c0058da..3594319 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -1,15 +1,16 @@
 // yaml.js - specification for HSMusic YAML data file format and utilities for
-// loading and processing YAML files and documents
+// loading, processing, and validating YAML files and documents
 
-import * as path from 'path';
-import yaml from 'js-yaml';
-
-import {readFile, stat} from 'fs/promises';
-import {inspect as nodeInspect} from 'util';
+import {readFile, stat} from 'node:fs/promises';
+import * as path from 'node:path';
+import {inspect as nodeInspect} from 'node:util';
 
-import T from './things/index.js';
+import yaml from 'js-yaml';
 
-import {color, ENABLE_COLOR, logInfo, logWarn} from '../util/cli.js';
+import {color, ENABLE_COLOR, logInfo, logWarn} from '#cli';
+import find, {bindFind} from '#find';
+import {traverse} from '#node-utils';
+import T from '#things';
 
 import {
   conditionallySuppressError,
@@ -20,17 +21,14 @@ import {
   openAggregate,
   showAggregate,
   withAggregate,
-} from '../util/sugar.js';
+} from '#sugar';
 
 import {
   sortAlbumsTracksChronologically,
   sortAlphabetically,
   sortChronologically,
   sortFlashesChronologically,
-} from '../util/wiki-data.js';
-
-import find, {bindFind} from '../util/find.js';
-import {traverse} from '../util/node-utils.js';
+} from '#wiki-data';
 
 // --> General supporting stuff