@uniweb/api 0.3.7 → 0.4.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.
package/src/mock/seed.js CHANGED
@@ -3,46 +3,63 @@
3
3
  * template uses and a seed nobody edits should still show something.
4
4
  *
5
5
  * ⭐ **A seed is the mock's whole data model**, and it is a plain object on purpose:
6
- * a developer edits it in one file, diffs it, and commits it. That is the property
7
- * a database would take away.
6
+ * a developer edits it in one file, diffs it, and commits it.
8
7
  *
9
- * ⚠️ `schemas` here lists only what the mock ENFORCES — who may create, and which
10
- * sections are insert-only. It is not a data-schema and cannot validate content;
11
- * the real schema lives in the foundation, where the site build reads it.
8
+ * - **`accounts`** — `operator: true` marks the account that runs the site's
9
+ * service. Everyone else is a member. Seeded accounts are verified.
10
+ * - **`schemas`** — per Model: `creatable_by` (`any_user`, the default, or
11
+ * `unit_members` — the operator only) and `sections`, the Model's sections as
12
+ * the framework lowers them. With `sections`, writes are shape-checked.
13
+ * - **`entities`** — `uuid` must be a UUID, as it is on the wire; content is items,
14
+ * each naming its section. The entity's `brief` is derived from its brief
15
+ * section's item, as the backend derives it.
12
16
  */
13
17
  export const DEFAULT_SEED = {
14
18
  accounts: [
15
- // The organiser belongs to a unit, so `creatable_by: unit_members` lets them
16
- // author the programme.
17
- { username: 'organiser', password: 'organiser', handle: 'organiser', units: ['conf'], roles: ['member'] },
18
- // The attendee belongs to none — the same rule refuses them, server-side, and
19
- // that refusal is the demo.
20
- { username: 'attendee', password: 'attendee', handle: 'attendee', units: [], roles: ['member'] },
19
+ // The organiser runs the site, so the rule on `@/track` lets them author the programme.
20
+ { username: 'organiser', password: 'organiser', operator: true },
21
+ // The attendee is a member — the same rule refuses them, server-side, and that
22
+ // refusal is the demo. They may record attending, which anyone may.
23
+ { username: 'attendee', password: 'attendee' },
21
24
  ],
22
25
  schemas: {
23
- '@/track': { creatable_by: 'unit_members' },
24
- '@/session': { creatable_by: 'unit_members' },
26
+ '@/track': {
27
+ creatable_by: 'unit_members',
28
+ sections: {
29
+ track: { kind: 'single', brief: true, fields: { name: { type: 'string', required: true } } },
30
+ sessions: {
31
+ kind: 'multi',
32
+ fields: { title: { type: 'string', required: true }, room: { type: 'string' }, minutes: { type: 'int' } },
33
+ },
34
+ },
35
+ },
25
36
  // Check-ins are insert-only: an attendee may record attending, and nobody —
26
37
  // including them — may edit or remove it afterwards.
27
- '@/attendance': { creatable_by: 'any_user', append_only: ['checkins'] },
38
+ '@/attendance': {
39
+ creatable_by: 'any_user',
40
+ sections: {
41
+ attendance: { kind: 'single', brief: true, fields: { who: { type: 'string' } } },
42
+ checkins: { kind: 'multi', append_only: true, fields: { session: { type: 'string' }, at: { type: 'string' } } },
43
+ },
44
+ },
28
45
  },
29
46
  entities: [
30
47
  {
31
- uuid: 'track-main',
48
+ uuid: '01926d5e-0000-7000-8000-00000000a001',
32
49
  model: '@/track',
33
- data: { name: 'Main hall' },
34
50
  items: [
35
- { id: 'sess-1', section: 'sessions', data: { title: 'Opening keynote', room: 'Hall A', minutes: 45 } },
36
- { id: 'sess-2', section: 'sessions', data: { title: 'Designing for the edge', room: 'Hall A', minutes: 30 } },
37
- { id: 'sess-3', section: 'sessions', data: { title: 'Closing panel', room: 'Hall A', minutes: 60 } },
51
+ { section: 'track', data: { name: 'Main hall' } },
52
+ { section: 'sessions', data: { title: 'Opening keynote', room: 'Hall A', minutes: 45 } },
53
+ { section: 'sessions', data: { title: 'Designing for the edge', room: 'Hall A', minutes: 30 } },
54
+ { section: 'sessions', data: { title: 'Closing panel', room: 'Hall A', minutes: 60 } },
38
55
  ],
39
56
  },
40
57
  {
41
- uuid: 'track-workshops',
58
+ uuid: '01926d5e-0000-7000-8000-00000000a002',
42
59
  model: '@/track',
43
- data: { name: 'Workshops' },
44
60
  items: [
45
- { id: 'sess-4', section: 'sessions', data: { title: 'Hands-on: foundations', room: 'Room 2', minutes: 90 } },
61
+ { section: 'track', data: { name: 'Workshops' } },
62
+ { section: 'sessions', data: { title: 'Hands-on: foundations', room: 'Room 2', minutes: 90 } },
46
63
  ],
47
64
  },
48
65
  ],