@yuneta/gobj-ui 7.23.195 → 7.23.196
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 +11 -10
- package/dist/gobj-ui.cjs.js +81 -155
- package/dist/gobj-ui.es.js +81 -155
- package/package.json +1 -1
- package/src/c_yui_schema_editor.js +57 -122
- package/src/schema_validate.js +5 -17
- package/src/schema_validate.test.js +4 -24
- package/src/schema_version_bump.test.js +14 -71
package/dist/gobj-ui.es.js
CHANGED
|
@@ -70158,10 +70158,11 @@ function register_c_yui_treedb_schema() {
|
|
|
70158
70158
|
* operator drew does nothing at all. Restarting on
|
|
70159
70159
|
* this is an outage with no gain.
|
|
70160
70160
|
* `warning` the schema opens and something is not what it looks
|
|
70161
|
-
* like
|
|
70162
|
-
*
|
|
70163
|
-
*
|
|
70164
|
-
*
|
|
70161
|
+
* like.
|
|
70162
|
+
*
|
|
70163
|
+
* A version is not checked here: an edit is a DRAFT and moves no
|
|
70164
|
+
* version, and C_TREEDB's save-schema raises the versions of what
|
|
70165
|
+
* changed when it publishes it.
|
|
70165
70166
|
*
|
|
70166
70167
|
* Every `code` is an i18n key: the caller renders, this decides.
|
|
70167
70168
|
*
|
|
@@ -70208,9 +70209,6 @@ var FKEY_TYPES = [
|
|
|
70208
70209
|
***************************************************************/
|
|
70209
70210
|
function validate_schema(treedb, options) {
|
|
70210
70211
|
let findings = [];
|
|
70211
|
-
let opts = options || {};
|
|
70212
|
-
let written = Array.isArray(opts.written_topics) ? opts.written_topics : [];
|
|
70213
|
-
let baseline = opts.baseline || {};
|
|
70214
70212
|
if (!treedb || !Array.isArray(treedb.topics)) return findings;
|
|
70215
70213
|
let add = (severity, code, topic, col, detail) => {
|
|
70216
70214
|
findings.push({
|
|
@@ -70231,10 +70229,6 @@ function validate_schema(treedb, options) {
|
|
|
70231
70229
|
let pkey = topic.pkey || "id";
|
|
70232
70230
|
if (col_names.indexOf(pkey) < 0) add("error", "pkey names no column", topic.name, "", pkey);
|
|
70233
70231
|
for (let pkey2 of topic_pkey2s(topic.record)) if (col_names.indexOf(pkey2) < 0) add("error", "pkey2 names no column", topic.name, "", pkey2);
|
|
70234
|
-
if (written.indexOf(topic.id) >= 0) {
|
|
70235
|
-
let before = baseline[topic.id];
|
|
70236
|
-
if (before !== void 0 && String(before) === String(topic.topic_version)) add("warning", "topic version not bumped", topic.name, "", String(topic.topic_version));
|
|
70237
|
-
}
|
|
70238
70232
|
for (let col of topic.cols) {
|
|
70239
70233
|
let flags = col_flags(col.record);
|
|
70240
70234
|
let type = col.record ? col.record.type : "";
|
|
@@ -71503,13 +71497,15 @@ function write_options(op) {
|
|
|
71503
71497
|
* fkey, the order of a new sibling, the version that publishes
|
|
71504
71498
|
* the change.
|
|
71505
71499
|
*
|
|
71506
|
-
*
|
|
71507
|
-
*
|
|
71508
|
-
*
|
|
71509
|
-
*
|
|
71510
|
-
* the
|
|
71511
|
-
*
|
|
71512
|
-
*
|
|
71500
|
+
* AN EDIT IS A DRAFT. A write here moves no version and reaches no
|
|
71501
|
+
* treedb: the host SAVES it (C_TREEDB's save-schema raises the
|
|
71502
|
+
* topic_version of what changed and the schema_version, once) and
|
|
71503
|
+
* APPLIES it (apply-schema + a restart of the owning yuno). Until
|
|
71504
|
+
* the owner's design of M36 (2026-09-21 review) every write here
|
|
71505
|
+
* raised both versions, so an edit half made was already the
|
|
71506
|
+
* schema of the next start. The topic list marks what this session
|
|
71507
|
+
* wrote and has not saved; the host's EV_REFRESH after a save is
|
|
71508
|
+
* what forgets it.
|
|
71513
71509
|
*
|
|
71514
71510
|
* WHAT ELSE IS HERE, and why each is here and not somewhere else:
|
|
71515
71511
|
*
|
|
@@ -71854,16 +71850,20 @@ function start_measuring(gobj) {
|
|
|
71854
71850
|
for (let treedb of priv.model.treedbs) for (let topic of treedb.topics) priv.baseline[topic.id] = topic.topic_version;
|
|
71855
71851
|
}
|
|
71856
71852
|
/***************************************************************
|
|
71857
|
-
* "This topic was written
|
|
71853
|
+
* "This topic was written in this session and is not saved."
|
|
71858
71854
|
*
|
|
71859
|
-
*
|
|
71860
|
-
*
|
|
71861
|
-
*
|
|
71855
|
+
* An edit is a DRAFT: it moves no version and reaches no treedb
|
|
71856
|
+
* until the host saves it (C_TREEDB's save-schema, which raises the
|
|
71857
|
+
* versions of what changed) -- and the save makes the host send
|
|
71858
|
+
* EV_REFRESH, whose reload is what forgets the drafts.
|
|
71859
|
+
*
|
|
71860
|
+
* ONE predicate, because it is asked in three places -- the topic
|
|
71861
|
+
* list draws a chip with it, the column view a banner, the export
|
|
71862
|
+
* a warning -- and copies of a rule are how they drift.
|
|
71862
71863
|
***************************************************************/
|
|
71863
|
-
function
|
|
71864
|
-
if (!topic || !written
|
|
71865
|
-
|
|
71866
|
-
return String(baseline[topic.id]) === String(topic.topic_version);
|
|
71864
|
+
function topic_is_draft(written, topic) {
|
|
71865
|
+
if (!topic || !written) return false;
|
|
71866
|
+
return written[topic.id] ? true : false;
|
|
71867
71867
|
}
|
|
71868
71868
|
/***************************************************************
|
|
71869
71869
|
* Say what the whole store would be refused for.
|
|
@@ -72305,7 +72305,7 @@ function render_topics(gobj, $body) {
|
|
|
72305
72305
|
let twice = repeated_names(treedb.topics);
|
|
72306
72306
|
let $rows = [];
|
|
72307
72307
|
for (let topic of treedb.topics) {
|
|
72308
|
-
let pending =
|
|
72308
|
+
let pending = topic_is_draft(priv.written, topic);
|
|
72309
72309
|
let ambiguous = !!twice[topic.name];
|
|
72310
72310
|
let address = ambiguous ? topic.id : topic.name;
|
|
72311
72311
|
let $actions = [];
|
|
@@ -72540,7 +72540,7 @@ function render_columns(gobj, $body) {
|
|
|
72540
72540
|
{ class: "SCHEMA_COLUMNS p-3" },
|
|
72541
72541
|
[]
|
|
72542
72542
|
]);
|
|
72543
|
-
let $banner =
|
|
72543
|
+
let $banner = draft_banner(gobj, topic);
|
|
72544
72544
|
if ($banner) $wrap.appendChild($banner);
|
|
72545
72545
|
let twice = repeated_names(topic.cols);
|
|
72546
72546
|
let $rows = [];
|
|
@@ -72618,66 +72618,37 @@ function render_columns(gobj, $body) {
|
|
|
72618
72618
|
refresh_language($wrap, t);
|
|
72619
72619
|
}
|
|
72620
72620
|
/***************************************************************
|
|
72621
|
-
* "This topic
|
|
72621
|
+
* "This topic has changes that are not saved."
|
|
72622
72622
|
*
|
|
72623
|
-
*
|
|
72624
|
-
*
|
|
72625
|
-
*
|
|
72626
|
-
*
|
|
72627
|
-
*
|
|
72623
|
+
* A draft, not an error: the edit is in __system__ and moves no
|
|
72624
|
+
* version, so the treedb does not see it until the host saves it
|
|
72625
|
+
* (and applies it). The banner says so and offers nothing -- the
|
|
72626
|
+
* save is the host's, one level up, because it publishes the whole
|
|
72627
|
+
* treedb and not one topic.
|
|
72628
72628
|
***************************************************************/
|
|
72629
|
-
function
|
|
72629
|
+
function draft_banner(gobj, topic) {
|
|
72630
72630
|
let priv = gobj.priv;
|
|
72631
|
-
if (!
|
|
72631
|
+
if (!topic_is_draft(priv.written, topic)) return null;
|
|
72632
72632
|
if (is_readonly(gobj)) return null;
|
|
72633
|
-
|
|
72633
|
+
return createElement2([
|
|
72634
72634
|
"div",
|
|
72635
72635
|
{
|
|
72636
|
-
class: "
|
|
72636
|
+
class: "SCHEMA_DRAFT_BANNER notification is-warning is-light p-3 mb-3 is-flex is-align-items-center",
|
|
72637
72637
|
style: "gap:.5rem;"
|
|
72638
72638
|
},
|
|
72639
|
-
[
|
|
72640
|
-
|
|
72641
|
-
|
|
72642
|
-
|
|
72643
|
-
|
|
72644
|
-
|
|
72645
|
-
|
|
72646
|
-
"
|
|
72647
|
-
|
|
72648
|
-
|
|
72649
|
-
|
|
72650
|
-
|
|
72651
|
-
t("version not raised")
|
|
72652
|
-
],
|
|
72653
|
-
[
|
|
72654
|
-
"button",
|
|
72655
|
-
{
|
|
72656
|
-
class: "SCHEMA_VERSION_BUMP button is-warning",
|
|
72657
|
-
type: "button",
|
|
72658
|
-
style: "margin-left:auto;",
|
|
72659
|
-
title: t("raise the version"),
|
|
72660
|
-
"aria-label": t("raise the version"),
|
|
72661
|
-
"data-i18n-title": "raise the version",
|
|
72662
|
-
"data-i18n-aria-label": "raise the version"
|
|
72663
|
-
},
|
|
72664
|
-
[[
|
|
72665
|
-
"span",
|
|
72666
|
-
{ class: "icon" },
|
|
72667
|
-
[["i", { class: "yi-circle-up" }]]
|
|
72668
|
-
], [
|
|
72669
|
-
"span",
|
|
72670
|
-
{ i18n: "raise" },
|
|
72671
|
-
t("raise")
|
|
72672
|
-
]]
|
|
72673
|
-
]
|
|
72674
|
-
]
|
|
72639
|
+
[[
|
|
72640
|
+
"span",
|
|
72641
|
+
{ class: "icon" },
|
|
72642
|
+
[["i", { class: "yi-triangle-exclamation" }]]
|
|
72643
|
+
], [
|
|
72644
|
+
"span",
|
|
72645
|
+
{
|
|
72646
|
+
class: "SCHEMA_DRAFT_TEXT is-size-7",
|
|
72647
|
+
i18n: "unsaved schema changes: save to publish them"
|
|
72648
|
+
},
|
|
72649
|
+
t("unsaved schema changes: save to publish them")
|
|
72650
|
+
]]
|
|
72675
72651
|
]);
|
|
72676
|
-
$banner.querySelector(".SCHEMA_VERSION_BUMP").addEventListener("click", (evt) => {
|
|
72677
|
-
evt.stopPropagation();
|
|
72678
|
-
gobj_send_event(gobj, "EV_BUMP_VERSION", { topic: topic.name }, gobj);
|
|
72679
|
-
});
|
|
72680
|
-
return $banner;
|
|
72681
72652
|
}
|
|
72682
72653
|
/***************************************************************
|
|
72683
72654
|
* One column, as a row. The drag events carry INDEXES in the
|
|
@@ -73546,6 +73517,8 @@ function open_report(gobj, findings, treedb_id) {
|
|
|
73546
73517
|
* as a download, which a published page cannot start anyway.
|
|
73547
73518
|
***************************************************************/
|
|
73548
73519
|
function open_export(gobj, treedb) {
|
|
73520
|
+
let priv = gobj.priv;
|
|
73521
|
+
let drafts = treedb.topics.some((topic) => topic_is_draft(priv.written, topic));
|
|
73549
73522
|
let c_text = schema_to_c(treedb);
|
|
73550
73523
|
let json_text = JSON.stringify(schema_to_json(treedb), null, 4);
|
|
73551
73524
|
let $content = createElement2([
|
|
@@ -73599,13 +73572,29 @@ function open_export(gobj, treedb) {
|
|
|
73599
73572
|
},
|
|
73600
73573
|
t("an edit made here works and lives in no source: this is what to paste back")
|
|
73601
73574
|
],
|
|
73575
|
+
drafts ? [
|
|
73576
|
+
"p",
|
|
73577
|
+
{
|
|
73578
|
+
class: "SCHEMA_EXPORT_DRAFTS notification is-warning is-light p-2 mb-2 is-size-7",
|
|
73579
|
+
i18n: "unsaved changes: save first, so the literal carries the versions that publish it"
|
|
73580
|
+
},
|
|
73581
|
+
t("unsaved changes: save first, so the literal carries the versions that publish it")
|
|
73582
|
+
] : [
|
|
73583
|
+
"span",
|
|
73584
|
+
{},
|
|
73585
|
+
""
|
|
73586
|
+
],
|
|
73602
73587
|
[
|
|
73603
73588
|
"textarea",
|
|
73604
73589
|
{
|
|
73605
73590
|
class: "SCHEMA_EXPORT_TEXT textarea is-small is-family-monospace",
|
|
73606
73591
|
rows: "18",
|
|
73607
73592
|
readonly: "readonly",
|
|
73608
|
-
spellcheck: "false"
|
|
73593
|
+
spellcheck: "false",
|
|
73594
|
+
title: t("schema"),
|
|
73595
|
+
"data-i18n-title": "schema",
|
|
73596
|
+
"aria-label": t("schema"),
|
|
73597
|
+
"data-i18n-aria-label": "schema"
|
|
73609
73598
|
},
|
|
73610
73599
|
c_text
|
|
73611
73600
|
],
|
|
@@ -73619,7 +73608,11 @@ function open_export(gobj, treedb) {
|
|
|
73619
73608
|
"button",
|
|
73620
73609
|
{
|
|
73621
73610
|
class: "SCHEMA_EXPORT_COPY button",
|
|
73622
|
-
type: "button"
|
|
73611
|
+
type: "button",
|
|
73612
|
+
title: t("copy"),
|
|
73613
|
+
"data-i18n-title": "copy",
|
|
73614
|
+
"aria-label": t("copy"),
|
|
73615
|
+
"data-i18n-aria-label": "copy"
|
|
73623
73616
|
},
|
|
73624
73617
|
[[
|
|
73625
73618
|
"span",
|
|
@@ -73954,52 +73947,6 @@ function open_orphans(gobj) {
|
|
|
73954
73947
|
* Writing
|
|
73955
73948
|
***************************/
|
|
73956
73949
|
/***************************************************************
|
|
73957
|
-
* THE TWO VERSIONS A SCHEMA EDIT HAS TO RAISE, and why both.
|
|
73958
|
-
*
|
|
73959
|
-
* `topic_version` is what publishes a change of a topic's
|
|
73960
|
-
* columns: leave it and the persisted `topic_cols.json` masks
|
|
73961
|
-
* the edit, the restart succeeds and nothing moved.
|
|
73962
|
-
*
|
|
73963
|
-
* `schema_version` is what publishes the schema as a whole —
|
|
73964
|
-
* "the stored one wins on ties, and the incoming one has to be
|
|
73965
|
-
* strictly newer to take over" (c_treedb.c). It is safe to
|
|
73966
|
-
* raise: re-projection from C compares `c_schema_version`, the
|
|
73967
|
-
* version of the LITERAL, precisely so that an edit made here
|
|
73968
|
-
* survives every start until a newer literal arrives.
|
|
73969
|
-
*
|
|
73970
|
-
* So every write that changes a schema carries both, and the
|
|
73971
|
-
* operator is never asked to remember either.
|
|
73972
|
-
***************************************************************/
|
|
73973
|
-
function version_writes(gobj, topic) {
|
|
73974
|
-
let treedb = current_treedb(gobj);
|
|
73975
|
-
let writes = [];
|
|
73976
|
-
if (topic) {
|
|
73977
|
-
let version = Number(topic.topic_version);
|
|
73978
|
-
if (!isFinite(version)) version = 0;
|
|
73979
|
-
writes.push({
|
|
73980
|
-
op: "update",
|
|
73981
|
-
topic_name: T_TOPICS,
|
|
73982
|
-
record: {
|
|
73983
|
-
id: topic.id,
|
|
73984
|
-
topic_version: version + 1
|
|
73985
|
-
}
|
|
73986
|
-
});
|
|
73987
|
-
}
|
|
73988
|
-
if (treedb) {
|
|
73989
|
-
let version = Number(treedb.schema_version);
|
|
73990
|
-
if (!isFinite(version)) version = 0;
|
|
73991
|
-
writes.push({
|
|
73992
|
-
op: "update",
|
|
73993
|
-
topic_name: T_TREEDBS,
|
|
73994
|
-
record: {
|
|
73995
|
-
id: treedb.id,
|
|
73996
|
-
schema_version: version + 1
|
|
73997
|
-
}
|
|
73998
|
-
});
|
|
73999
|
-
}
|
|
74000
|
-
return writes;
|
|
74001
|
-
}
|
|
74002
|
-
/***************************************************************
|
|
74003
73950
|
* WHERE THE COLUMNS WERE before this session started moving them.
|
|
74004
73951
|
*
|
|
74005
73952
|
* A drag is a WRITE: the order is a field of the column, so the drop
|
|
@@ -74458,7 +74405,7 @@ function ac_save_column(gobj, event, kw, src) {
|
|
|
74458
74405
|
op: kw.creating ? "create" : "update",
|
|
74459
74406
|
topic_name: T_COLS,
|
|
74460
74407
|
record: column_record(gobj, topic, col, values)
|
|
74461
|
-
}]
|
|
74408
|
+
}]);
|
|
74462
74409
|
}
|
|
74463
74410
|
function ac_delete_column(gobj, event, kw, src) {
|
|
74464
74411
|
let priv = gobj.priv;
|
|
@@ -74509,7 +74456,7 @@ function ac_move_column(gobj, event, kw, src) {
|
|
|
74509
74456
|
};
|
|
74510
74457
|
});
|
|
74511
74458
|
if (writes.length === 0) return 0;
|
|
74512
|
-
return queue_writes(gobj, writes
|
|
74459
|
+
return queue_writes(gobj, writes);
|
|
74513
74460
|
}
|
|
74514
74461
|
/***************************************************************
|
|
74515
74462
|
* Put the columns back where they were before the dragging
|
|
@@ -74529,7 +74476,7 @@ function ac_undo_order(gobj, event, kw, src) {
|
|
|
74529
74476
|
return 0;
|
|
74530
74477
|
}
|
|
74531
74478
|
delete priv.order_undo[topic.id];
|
|
74532
|
-
return queue_writes(gobj, writes
|
|
74479
|
+
return queue_writes(gobj, writes);
|
|
74533
74480
|
}
|
|
74534
74481
|
/***************************************************************
|
|
74535
74482
|
* Editing a topic.
|
|
@@ -74582,7 +74529,7 @@ function ac_save_topic(gobj, event, kw, src) {
|
|
|
74582
74529
|
op: kw.creating ? "create" : "update",
|
|
74583
74530
|
topic_name: T_TOPICS,
|
|
74584
74531
|
record: topic_record(gobj, treedb, topic, values)
|
|
74585
|
-
}]
|
|
74532
|
+
}]);
|
|
74586
74533
|
}
|
|
74587
74534
|
function ac_delete_topic(gobj, event, kw, src) {
|
|
74588
74535
|
let priv = gobj.priv;
|
|
@@ -74599,20 +74546,6 @@ function ac_delete_topic(gobj, event, kw, src) {
|
|
|
74599
74546
|
return 0;
|
|
74600
74547
|
}
|
|
74601
74548
|
/***************************************************************
|
|
74602
|
-
* Raising a version by hand: what the banner offers when
|
|
74603
|
-
* something else wrote the topic and left its version alone.
|
|
74604
|
-
***************************************************************/
|
|
74605
|
-
function ac_bump_version(gobj, event, kw, src) {
|
|
74606
|
-
let priv = gobj.priv;
|
|
74607
|
-
let topic = find_topic(priv.model, priv.treedb_id, kw.topic);
|
|
74608
|
-
if (refuse_if_readonly(gobj, event)) return -1;
|
|
74609
|
-
if (!topic) {
|
|
74610
|
-
log_error(`${gobj_short_name(gobj)}: ${event} names no topic: ${kw.topic}`);
|
|
74611
|
-
return -1;
|
|
74612
|
-
}
|
|
74613
|
-
return queue_writes(gobj, version_writes(gobj, topic));
|
|
74614
|
-
}
|
|
74615
|
-
/***************************************************************
|
|
74616
74549
|
* Deleting a leftover.
|
|
74617
74550
|
***************************************************************/
|
|
74618
74551
|
function ac_delete_orphan(gobj, event, kw, src) {
|
|
@@ -74761,11 +74694,10 @@ function ac_confirmed(gobj, event, kw, src) {
|
|
|
74761
74694
|
topic_name: T_TOPICS,
|
|
74762
74695
|
record: { id: topic.id }
|
|
74763
74696
|
});
|
|
74764
|
-
return queue_writes(gobj, writes
|
|
74697
|
+
return queue_writes(gobj, writes);
|
|
74765
74698
|
}
|
|
74766
74699
|
if (kw.what === "column") {
|
|
74767
|
-
let
|
|
74768
|
-
let col = topic ? find_col(priv.model, priv.treedb_id, kw.topic, kw.col) : null;
|
|
74700
|
+
let col = find_topic(priv.model, priv.treedb_id, kw.topic) ? find_col(priv.model, priv.treedb_id, kw.topic, kw.col) : null;
|
|
74769
74701
|
if (!col) {
|
|
74770
74702
|
log_error(`${gobj_short_name(gobj)}: ${event} names no column: ${kw.col}`);
|
|
74771
74703
|
return -1;
|
|
@@ -74774,7 +74706,7 @@ function ac_confirmed(gobj, event, kw, src) {
|
|
|
74774
74706
|
op: "delete",
|
|
74775
74707
|
topic_name: T_COLS,
|
|
74776
74708
|
record: { id: col.id }
|
|
74777
|
-
}]
|
|
74709
|
+
}]);
|
|
74778
74710
|
}
|
|
74779
74711
|
log_error(`${gobj_short_name(gobj)}: ${event} of nothing this view asked about: ${kw.what}`);
|
|
74780
74712
|
return -1;
|
|
@@ -74963,11 +74895,6 @@ function create_gclass$1(gclass_name) {
|
|
|
74963
74895
|
"EV_UNDO_ORDER",
|
|
74964
74896
|
ac_undo_order,
|
|
74965
74897
|
null
|
|
74966
|
-
],
|
|
74967
|
-
[
|
|
74968
|
-
"EV_BUMP_VERSION",
|
|
74969
|
-
ac_bump_version,
|
|
74970
|
-
null
|
|
74971
74898
|
]
|
|
74972
74899
|
])],
|
|
74973
74900
|
["ST_SAVING", COMMON.slice()]
|
|
@@ -74996,7 +74923,6 @@ function create_gclass$1(gclass_name) {
|
|
|
74996
74923
|
["EV_SAVE_COLUMN", 0],
|
|
74997
74924
|
["EV_MOVE_COLUMN", 0],
|
|
74998
74925
|
["EV_UNDO_ORDER", 0],
|
|
74999
|
-
["EV_BUMP_VERSION", 0],
|
|
75000
74926
|
["EV_VALIDATE", 0],
|
|
75001
74927
|
["EV_EXPORT", 0],
|
|
75002
74928
|
["EV_IMPORT", 0],
|