@voxgig/system 1.2.0 → 1.3.1

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/system.ts CHANGED
@@ -13,6 +13,8 @@ import { Utility } from './lib/utility'
13
13
 
14
14
  import { MakeSrv } from './srv/make'
15
15
 
16
+ import { addEntity, addSrv, addMsg, addFields, resolveModelFiles } from './lib/add'
17
+
16
18
 
17
19
 
18
20
  const { srvmsgs, deep } = Utility
@@ -45,12 +47,32 @@ function gubuify(params: any, Gubu: any) {
45
47
  if (null == params) {
46
48
  return params
47
49
  }
50
+ return Gubu(gubuify_spec(params, Gubu))
51
+ }
52
+
53
+
54
+ // Convert model param values into a gubu spec. The '$$': 'Open' marker
55
+ // (same convention as entity valid) makes an object open: additional
56
+ // properties are allowed. Without it gubu objects are closed, which made
57
+ // open message params inexpressible in the model. Nested specs stay raw
58
+ // (builder results, not Gubu instances) so attributes like openness
59
+ // compose into the parent shape.
60
+ function gubuify_spec(params: any, Gubu: any): any {
61
+ if (null == params) {
62
+ return params
63
+ }
64
+
65
+ let open = false
66
+ if ('Open' === params['$$']) {
67
+ open = true
68
+ delete params['$$']
69
+ }
48
70
 
49
71
  for (let pn in params) {
50
72
  let m = null
51
73
  let pv = params[pn]
52
74
  if ('object' === typeof pv) {
53
- params[pn] = gubuify(pv, Gubu)
75
+ params[pn] = gubuify_spec(pv, Gubu)
54
76
  }
55
77
  else if (
56
78
  'string' === typeof pv &&
@@ -63,11 +85,8 @@ function gubuify(params: any, Gubu: any) {
63
85
  params[png] = pv
64
86
  delete params[pn]
65
87
  }
66
- else {
67
- params[pn] = Gubu(pv)
68
- }
69
88
  }
70
- return Gubu(params)
89
+ return open ? Gubu.Open(params) : params
71
90
  }
72
91
 
73
92
 
@@ -197,7 +216,16 @@ export type {
197
216
  Msg
198
217
  }
199
218
 
219
+ const Add = {
220
+ entity: addEntity,
221
+ srv: addSrv,
222
+ msg: addMsg,
223
+ fields: addFields,
224
+ resolveModelFiles,
225
+ }
226
+
200
227
  export {
228
+ Add,
201
229
  gubuify,
202
230
  System,
203
231
  MakeSrv,