« get me outta code hell

directory.js « wiki-properties « composite « data « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-properties/directory.js
blob: 41ce4b27115278ea74a3d4786f3dcaf022a42a42 (plain)
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
// The all-encompassing "directory" property, used as the unique identifier for
// almost any data object. Also corresponds to a part of the URL which pages of
// such objects are visited at.

import {input, templateCompositeFrom} from '#composite';

import {isDirectory, isName} from '#validators';

import {exposeDependency} from '#composite/control-flow';
import {withDirectory} from '#composite/wiki-data';

export default templateCompositeFrom({
  annotation: `directory`,

  compose: false,

  inputs: {
    name: input({
      validate: isName,
      defaultDependency: 'name',
    }),
  },

  steps: () => [
    withDirectory({
      directory: input.updateValue({validate: isDirectory}),
    }),

    exposeDependency({
      dependency: '#directory',
    }),
  ],
});