@voxgig/system 1.14.0 → 1.15.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/dist/lib/utility.js +31 -30
- package/dist/lib/utility.js.map +1 -1
- package/lib/utility.ts +31 -31
- package/package.json +1 -1
package/dist/lib/utility.js
CHANGED
|
@@ -34,19 +34,18 @@ function listmsgs(point) {
|
|
|
34
34
|
});
|
|
35
35
|
return msgs;
|
|
36
36
|
}
|
|
37
|
-
// A message definition declares its pattern as a LIST
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
// validates the declared shape with (see its producer/msg.ts).
|
|
37
|
+
// A message definition declares its pattern as a LIST, so it is told apart
|
|
38
|
+
// from a chain node - whose values are always maps, the next pattern level or
|
|
39
|
+
// the '$' leaf - even when spelled `pat:`. Same discriminator @voxgig/model
|
|
40
|
+
// validates the declared shape with.
|
|
42
41
|
function ismsgdef(val) {
|
|
43
42
|
return null != val && 'object' === typeof val &&
|
|
44
43
|
!Array.isArray(val) && Array.isArray(val.pat);
|
|
45
44
|
}
|
|
46
|
-
// The pattern pairs of a
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
45
|
+
// The pattern pairs of a definition, in the walker's path form. A malformed
|
|
46
|
+
// pair is skipped rather than thrown on: @voxgig/model fails the build on
|
|
47
|
+
// those, so one reaching here means the model came from somewhere else, and
|
|
48
|
+
// dropping it degrades better than crashing srv startup.
|
|
50
49
|
function msgdefpath(def) {
|
|
51
50
|
let path = [];
|
|
52
51
|
for (let pair of def.pat) {
|
|
@@ -61,22 +60,29 @@ function msgdefpath(def) {
|
|
|
61
60
|
return path;
|
|
62
61
|
}
|
|
63
62
|
function walkmsgs(point, path, handle) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
// and
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
// THE DECLARED SHAPE: main.msg is a LIST of definitions, each carrying its
|
|
64
|
+
// pattern as data rather than as its position in the tree.
|
|
65
|
+
//
|
|
66
|
+
// A list rather than a map keyed by message name, because a gateway proxy
|
|
67
|
+
// and the message it forwards to necessarily share their last pattern pair
|
|
68
|
+
// (aim:web,on:todo,save:item proxies aim:todo,save:item), so any key derived
|
|
69
|
+
// from that pair would collide and the two could not both be declared. A
|
|
70
|
+
// list has no key, so the question never arises - and the action file still
|
|
71
|
+
// comes from the last pair, or from `file`, exactly as before.
|
|
72
|
+
if (Array.isArray(point)) {
|
|
73
|
+
for (let def of point) {
|
|
74
|
+
if (ismsgdef(def)) {
|
|
75
|
+
let meta = { ...def };
|
|
76
|
+
delete meta.pat;
|
|
77
|
+
handle(path.concat(msgdefpath(def)), meta);
|
|
78
|
+
}
|
|
78
79
|
}
|
|
80
|
+
return;
|
|
79
81
|
}
|
|
82
|
+
// THE LEGACY CHAIN: the nesting is the pattern, consumed two levels at a
|
|
83
|
+
// time, with '$' carrying the metadata. Unchanged.
|
|
84
|
+
let points = 'object' === typeof point ?
|
|
85
|
+
Object.entries(point).filter(entry => !entry[0].includes('$')) : [];
|
|
80
86
|
for (let step of points) {
|
|
81
87
|
let key = step[0];
|
|
82
88
|
// TODO: capture error log if step[1] empty (key with no vals)
|
|
@@ -84,13 +90,8 @@ function walkmsgs(point, path, handle) {
|
|
|
84
90
|
walkmsgs(step[1][val], path.concat([[key, val]]), handle);
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
|
-
// if any $ meta props, or
|
|
88
|
-
|
|
89
|
-
// This asks about ENTRIES, not the chain nodes among them: a node holding
|
|
90
|
-
// only declared-shape definitions is a container, and must not also emit a
|
|
91
|
-
// patternless message of its own. With no definitions present the two are
|
|
92
|
-
// the same set, so legacy models walk exactly as before.
|
|
93
|
-
if (0 === entries.length || point.$) {
|
|
93
|
+
// if any $ meta props, or no points, we found a msg
|
|
94
|
+
if (0 === points.length || point.$) {
|
|
94
95
|
const meta = point.$ || {};
|
|
95
96
|
handle(path, meta);
|
|
96
97
|
}
|
package/dist/lib/utility.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../lib/utility.ts"],"names":[],"mappings":";AAAA,+CAA+C;;;;;;AAO/C,2CAAqC;AAIrC,oDAA2B;AAG3B,yCAAyC;AACzC,SAAS,OAAO,CAAC,GAAwB,EAAE,KAA0B;IACnE,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACxC,MAAM,MAAM,GAAG,IAAA,gBAAM,EAAC,EAAE,CAAC,CAAA;IACzB,OAAO,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAA;IAEzD,yDAAyD;IACzD,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IAClD,MAAM,OAAO,GAAU,EAAE,CAAA;IACzB,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAC1B,CAAC,CAAC,CAAC,IAAI,CAAC,GAAI,MAAM;SACf,IAAI,CAAC,GAAG,CAAC;SACT,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAW,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;IAEnD,OAAO,OAAO,CAAA;AAChB,CAAC;AAGD,SAAS,QAAQ,CAAC,KAA2B;IAC3C,IAAI,IAAI,IAAI,KAAK;QAAE,OAAO,EAAE,CAAA;IAC5B,IAAI,IAAI,GAAU,EAAE,CAAA;IAEpB,QA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C,CAAC,EAAE,IAAI,CAAC,CAAA;YAC5C,CAAC;QACH,CAAC;QACD,OAAM;IACR,CAAC;IAED,yEAAyE;IACzE,mDAAmD;IACnD,IAAI,MAAM,GAAG,QAAQ,KAAK,OAAO,KAAK,CAAC,CAAC;QACtC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACrE,KAAK,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;QACxB,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,8DAA8D;QAC9D,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;QAC3D,CAAC;IACH,CAAC;IAED,oDAAoD;IACpD,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAA;QAC1B,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACpB,CAAC;AACH,CAAC;AAID,MAAM,OAAO,GAAG;IACd,OAAO;IACP,QAAQ;IACR,IAAI,EAAE,aAAI,CAAC,IAA2C;CACvD,CAAA;QAIC,OAAO"}
|
package/lib/utility.ts
CHANGED
|
@@ -49,21 +49,20 @@ function listmsgs(point?: Record<string, any>): Msg[] {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
// A message definition declares its pattern as a LIST
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
// validates the declared shape with (see its producer/msg.ts).
|
|
52
|
+
// A message definition declares its pattern as a LIST, so it is told apart
|
|
53
|
+
// from a chain node - whose values are always maps, the next pattern level or
|
|
54
|
+
// the '$' leaf - even when spelled `pat:`. Same discriminator @voxgig/model
|
|
55
|
+
// validates the declared shape with.
|
|
57
56
|
function ismsgdef(val: any): boolean {
|
|
58
57
|
return null != val && 'object' === typeof val &&
|
|
59
58
|
!Array.isArray(val) && Array.isArray(val.pat)
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
|
|
63
|
-
// The pattern pairs of a
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
62
|
+
// The pattern pairs of a definition, in the walker's path form. A malformed
|
|
63
|
+
// pair is skipped rather than thrown on: @voxgig/model fails the build on
|
|
64
|
+
// those, so one reaching here means the model came from somewhere else, and
|
|
65
|
+
// dropping it degrades better than crashing srv startup.
|
|
67
66
|
function msgdefpath(def: Record<string, any>): string[][] {
|
|
68
67
|
let path: string[][] = []
|
|
69
68
|
|
|
@@ -86,24 +85,30 @@ function walkmsgs(
|
|
|
86
85
|
path: string[][],
|
|
87
86
|
handle: (path: string[][], meta: any) => void) {
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// A
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
88
|
+
// THE DECLARED SHAPE: main.msg is a LIST of definitions, each carrying its
|
|
89
|
+
// pattern as data rather than as its position in the tree.
|
|
90
|
+
//
|
|
91
|
+
// A list rather than a map keyed by message name, because a gateway proxy
|
|
92
|
+
// and the message it forwards to necessarily share their last pattern pair
|
|
93
|
+
// (aim:web,on:todo,save:item proxies aim:todo,save:item), so any key derived
|
|
94
|
+
// from that pair would collide and the two could not both be declared. A
|
|
95
|
+
// list has no key, so the question never arises - and the action file still
|
|
96
|
+
// comes from the last pair, or from `file`, exactly as before.
|
|
97
|
+
if (Array.isArray(point)) {
|
|
98
|
+
for (let def of point) {
|
|
99
|
+
if (ismsgdef(def)) {
|
|
100
|
+
let meta = { ...def }
|
|
101
|
+
delete meta.pat
|
|
102
|
+
handle(path.concat(msgdefpath(def)), meta)
|
|
103
|
+
}
|
|
104
104
|
}
|
|
105
|
+
return
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
// THE LEGACY CHAIN: the nesting is the pattern, consumed two levels at a
|
|
109
|
+
// time, with '$' carrying the metadata. Unchanged.
|
|
110
|
+
let points = 'object' === typeof point ?
|
|
111
|
+
Object.entries(point).filter(entry => !entry[0].includes('$')) : []
|
|
107
112
|
for (let step of points) {
|
|
108
113
|
let key = step[0]
|
|
109
114
|
// TODO: capture error log if step[1] empty (key with no vals)
|
|
@@ -112,13 +117,8 @@ function walkmsgs(
|
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
|
|
115
|
-
// if any $ meta props, or
|
|
116
|
-
|
|
117
|
-
// This asks about ENTRIES, not the chain nodes among them: a node holding
|
|
118
|
-
// only declared-shape definitions is a container, and must not also emit a
|
|
119
|
-
// patternless message of its own. With no definitions present the two are
|
|
120
|
-
// the same set, so legacy models walk exactly as before.
|
|
121
|
-
if (0 === entries.length || point.$) {
|
|
120
|
+
// if any $ meta props, or no points, we found a msg
|
|
121
|
+
if (0 === points.length || point.$) {
|
|
122
122
|
const meta = point.$ || {}
|
|
123
123
|
handle(path, meta)
|
|
124
124
|
}
|