@yuneta/gobj-ui 6.0.0 → 6.1.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/README.md CHANGED
@@ -537,13 +537,106 @@ schema, so the drawing can be held against the ASCII one in its `.c`.
537
537
  `system` (include the `__*__` system topics too, default `false`),
538
538
  `$container` (mounted by the parent).
539
539
  - Events: `EV_SHOW`, `EV_REBUILD`, `EV_THEME` (restyle — it repaints the G6
540
- graph in place, preserving the user's zoom/pan), plus the internal
541
- `EV_NODE_CLICK` a node click sends into the FSM.
540
+ graph in place, preserving the user's zoom/pan), plus `EV_NODE_CLICK`, which
541
+ a node click sends into the FSM. **With a `node_route` the click IS a
542
+ navigation** and this view makes it; **without one the click is published**
543
+ (`{topic}`) for whoever mounted the view — a host that draws the same picture
544
+ inside its own screens opens the topic in place, with no hash involved. A
545
+ host that subscribes must declare `EV_NODE_CLICK` in its own FSM, as with
546
+ every event a child publishes. Since 6.1.0; before that a click with no route
547
+ was dropped.
542
548
 
543
549
  Barrel-exported and public from 4.0.0. Renders with `@antv/g6`; the cards are
544
550
  HTML nodes carrying their own inline colours, so a theme switch repaints them in
545
551
  place (no CSS of its own).
546
552
 
553
+ ### C_YUI_SCHEMA_EDITOR — a schema edited as a schema
554
+
555
+ Every schema a yuno holds lives in its `treedb_system_schema`, stored as data
556
+ in three flat topics linked by fkeys: `treedbs` → `topics` → `cols`. That is
557
+ the right **storage** and it is not a **screen**. Opened with the ordinary
558
+ topic editor, adding one column to one topic means finding it in a table
559
+ holding every column of every topic of every treedb the yuno has, composing the
560
+ parent fkey by hand, and remembering to raise a `topic_version` that nothing
561
+ asks about.
562
+
563
+ This view puts the schema back together and edits that: **treedb → topics →
564
+ columns**, each in its declared `order`, with the storage composed underneath —
565
+ the qualified id, the fkey to the parent, the place among the siblings, and the
566
+ versions that publish the change.
567
+
568
+ **The versions are the point, not a detail.** `topic_version` is what publishes
569
+ a change of a topic's columns: leave it and the persisted `topic_cols.json`
570
+ masks the whole edit — the restart succeeds and nothing moved. `schema_version`
571
+ is what publishes the schema as a whole ("the stored one wins on ties, and the
572
+ incoming one has to be strictly newer to take over", `c_treedb.c`), and raising
573
+ it is safe: re-projection from C compares `c_schema_version`, the version of
574
+ the **literal**, precisely so that an edit made here survives every start until
575
+ a newer literal arrives. So **every write carries both** and the operator is
576
+ never asked to remember either. The banner in the column screen is for the case
577
+ where something *else* wrote the topic and left its version alone.
578
+
579
+ What the screens offer:
580
+
581
+ | Screen | What it is for |
582
+ |--------|----------------|
583
+ | treedbs | one card per treedb, with its topic count and its `schema_version` beside the `c_schema_version` it was projected from |
584
+ | topics | the topics of one treedb in schema order: pkey, column count, version, system flag |
585
+ | columns | the heart. Rows in `order`, **draggable** — `order` is a field, so a drop writes the rows whose place actually changed, two or three and not forty |
586
+ | diagram | the treedb **drawn from the records being edited**, through `C_YUI_TREEDB_SCHEMA` |
587
+
588
+ And what the toolbar offers, each answering a question the storage could not:
589
+
590
+ - **check** — what the treedb would refuse, from the records alone: a pkey
591
+ naming no column, a hook whose target is missing or is not a fkey, two hooks
592
+ on one fkey, an `enum` flag with no `enum`. Applying a schema is restarting
593
+ the yuno that owns it, so a schema it refuses costs an outage to discover and
594
+ the message lands in that yuno's log, on the node, minutes later.
595
+ - **export** — the schema as its **C literal**, ready to paste into the source.
596
+ An edit made here works and lives nowhere the next build knows about;
597
+ `diff-schema` says the two halves drifted, and this is the other half of that
598
+ answer. Escaping crosses two layers and the second is not JSON's:
599
+ `helper_quote2doublequote()` rewrites *every* single quote before the parse,
600
+ so a quote inside a value can only survive as `\u0027`.
601
+ - **import** — the writes that make the stored schema equal a pasted one, shown
602
+ as a **plan** before it runs. Import is the one operation here that can delete
603
+ a column, so what is confirmed is what runs.
604
+
605
+ The **flags** of a column are checkboxes that say what they do, grouped the way
606
+ they act and dimmed (never hidden) when they are meaningless on the chosen type:
607
+ a flag already set on a column of another type has to stay visible or the next
608
+ save drops it silently. `hook` and `fkey` turn each other off, because they are
609
+ the two ends of one link.
610
+
611
+ A **name is not editable**: the store keys a column by its qualified id —
612
+ treedb, topic and name — so renaming one is creating another and deleting this
613
+ one. The form says so rather than offering a field that quietly does something
614
+ else.
615
+
616
+ **Contract:**
617
+
618
+ - Attributes: `subscriber`, `gobj_remote_yuno` (the transport — the treedb's
619
+ service, or an adapter that reaches it: this view cannot tell and must not),
620
+ `treedb_name` (the system-schema treedb), `readonly` (this yuno does not
621
+ master the tranger, so it refuses every write), `base_route`, `$container`.
622
+ - In: `EV_SHOW` (`{subpath}` — the tail it owns is `<treedb>[/<topic>]` or
623
+ `<treedb>/diagram`), `EV_HIDE`, `EV_TRANSPORT_STATE`, `EV_REFRESH`,
624
+ `EV_LANGUAGE_CHANGED`, `EV_MT_COMMAND_ANSWER`.
625
+ - Out: `EV_POSITION_CHANGED` (`{subpath}` — the host writes the url; this view
626
+ navigates nothing itself), `EV_RECORD_WRITTEN` (whoever owns the Apply needs
627
+ to know the yuno has not re-read its schema yet), `EV_SCHEMA_CHECKED`
628
+ (`{errors, warnings, first}` — so the confirmation that restarts the yuno can
629
+ say what it is about to restart onto).
630
+ - States, because each is a screen and a set of legal actions: `ST_IDLE`,
631
+ `ST_LOADING`, `ST_EMPTY`, `ST_TREEDBS`, `ST_TOPICS`, `ST_DIAGRAM`,
632
+ `ST_COLUMNS`, `ST_SAVING`.
633
+
634
+ The logic is pure and tested apart from the view: `schema_model.js` (the three
635
+ lists regrouped — grouping follows the **fkey**, not a split of the qualified
636
+ id on `.`, which works right up to the first name that carries one),
637
+ `schema_validate.js`, `schema_descs.js`, `schema_to_c.js`, `schema_import.js`,
638
+ `schema_flags.js`. Since 6.1.0.
639
+
547
640
  ### Frontend view — `setup_frontend_view`
548
641
 
549
642
  `setup_frontend_view(self)` opens the **gobj tree of the app's own yuno** in a