nesoi 3.0.21 → 3.1.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.
Files changed (91) hide show
  1. package/lib/compiler/apps/monolyth/stages/2_build_typescript_stage.js +1 -0
  2. package/lib/compiler/apps/monolyth/stages/4_dump_modules_stage.js +8 -0
  3. package/lib/compiler/compiler.js +1 -1
  4. package/lib/compiler/elements/bucket.element.d.ts +3 -2
  5. package/lib/compiler/elements/bucket.element.js +86 -128
  6. package/lib/compiler/elements/element.js +4 -2
  7. package/lib/compiler/elements/externals.element.js +3 -0
  8. package/lib/compiler/elements/machine.element.js +2 -2
  9. package/lib/compiler/elements/message.element.js +35 -57
  10. package/lib/compiler/elements/queue.element.js +1 -1
  11. package/lib/compiler/helpers/dump_helpers.d.ts +5 -3
  12. package/lib/compiler/helpers/dump_helpers.js +43 -26
  13. package/lib/compiler/stages/4_build_schemas_stage.js +12 -0
  14. package/lib/compiler/stages/5_inject_ts_stage.js +4 -1
  15. package/lib/compiler/stages/7_dump_stage.js +7 -1
  16. package/lib/compiler/treeshake.js +4 -2
  17. package/lib/compiler/typescript/bridge/extract.js +37 -107
  18. package/lib/compiler/typescript/bridge/inject.d.ts +1 -1
  19. package/lib/compiler/typescript/bridge/inject.js +73 -45
  20. package/lib/compiler/typescript/bridge/organize.js +9 -5
  21. package/lib/compiler/typescript/typescript_compiler.d.ts +4 -6
  22. package/lib/compiler/typescript/typescript_compiler.js +139 -75
  23. package/lib/elements/blocks/block.builder.d.ts +1 -10
  24. package/lib/elements/blocks/block.builder.js +0 -32
  25. package/lib/elements/blocks/job/internal/resource_job.builder.d.ts +3 -21
  26. package/lib/elements/blocks/job/job.builder.d.ts +6 -20
  27. package/lib/elements/blocks/job/job.builder.js +0 -4
  28. package/lib/elements/blocks/machine/machine.builder.d.ts +5 -14
  29. package/lib/elements/blocks/machine/machine.builder.js +2 -2
  30. package/lib/elements/blocks/queue/queue.builder.d.ts +6 -15
  31. package/lib/elements/blocks/queue/queue.builder.js +2 -2
  32. package/lib/elements/edge/externals/externals.builder.d.ts +2 -0
  33. package/lib/elements/edge/externals/externals.builder.js +6 -1
  34. package/lib/elements/edge/externals/externals.schema.d.ts +2 -1
  35. package/lib/elements/edge/externals/externals.schema.js +3 -1
  36. package/lib/elements/entities/bucket/adapters/bucket_adapter.d.ts +1 -1
  37. package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.d.ts +7 -0
  38. package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.js +46 -36
  39. package/lib/elements/entities/bucket/adapters/memory.nql.js +1 -1
  40. package/lib/elements/entities/bucket/bucket.builder.d.ts +6 -4
  41. package/lib/elements/entities/bucket/bucket.js +42 -43
  42. package/lib/elements/entities/bucket/bucket.schema.d.ts +2 -1
  43. package/lib/elements/entities/bucket/cache/bucket_cache.d.ts +1 -4
  44. package/lib/elements/entities/bucket/graph/bucket_graph.infer.d.ts +7 -5
  45. package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.d.ts +2 -1
  46. package/lib/elements/entities/bucket/model/bucket_model.builder.d.ts +1 -1
  47. package/lib/elements/entities/bucket/model/bucket_model.convert.d.ts +1 -1
  48. package/lib/elements/entities/bucket/model/bucket_model.convert.js +4 -4
  49. package/lib/elements/entities/bucket/model/bucket_model.infer.d.ts +41 -9
  50. package/lib/elements/entities/bucket/model/bucket_model.schema.d.ts +8 -6
  51. package/lib/elements/entities/bucket/model/bucket_model.schema.js +184 -21
  52. package/lib/elements/entities/bucket/model/bucket_model_field.builder.d.ts +89 -56
  53. package/lib/elements/entities/bucket/model/bucket_model_field.builder.js +22 -30
  54. package/lib/elements/entities/bucket/query/nql.schema.d.ts +13 -10
  55. package/lib/elements/entities/bucket/query/nql_compiler.js +46 -21
  56. package/lib/elements/entities/bucket/view/bucket_view.builder.js +1 -1
  57. package/lib/elements/entities/bucket/view/bucket_view.d.ts +19 -0
  58. package/lib/elements/entities/bucket/view/bucket_view.js +230 -108
  59. package/lib/elements/entities/bucket/view/bucket_view.schema.d.ts +5 -10
  60. package/lib/elements/entities/bucket/view/bucket_view.schema.js +3 -5
  61. package/lib/elements/entities/bucket/view/bucket_view_field.builder.d.ts +16 -12
  62. package/lib/elements/entities/bucket/view/bucket_view_field.builder.js +55 -40
  63. package/lib/elements/entities/message/message.builder.d.ts +1 -11
  64. package/lib/elements/entities/message/message.infer.d.ts +6 -30
  65. package/lib/elements/entities/message/message.schema.js +2 -2
  66. package/lib/elements/entities/message/template/message_template.builder.js +1 -1
  67. package/lib/elements/entities/message/template/message_template.schema.d.ts +10 -15
  68. package/lib/elements/entities/message/template/message_template.schema.js +29 -12
  69. package/lib/elements/entities/message/template/message_template_field.builder.d.ts +45 -209
  70. package/lib/elements/entities/message/template/message_template_field.builder.js +69 -85
  71. package/lib/elements/entities/message/template/message_template_parser.js +52 -64
  72. package/lib/engine/apps/inline.app.js +1 -0
  73. package/lib/engine/data/trash.js +7 -7
  74. package/lib/engine/data/tree.d.ts +3 -0
  75. package/lib/engine/data/tree.js +36 -0
  76. package/lib/engine/space.js +1 -1
  77. package/lib/engine/transaction/trx_engine.config.d.ts +3 -2
  78. package/lib/engine/transaction/trx_engine.d.ts +9 -1
  79. package/lib/engine/transaction/trx_engine.js +52 -9
  80. package/lib/engine/util/deep.js +4 -0
  81. package/lib/engine/util/parse.d.ts +22 -14
  82. package/lib/engine/util/parse.js +20 -5
  83. package/lib/engine/util/type.d.ts +3 -0
  84. package/package.json +1 -1
  85. package/tools/joaquin/bucket.d.ts +9 -0
  86. package/tools/joaquin/bucket.js +49 -0
  87. package/tools/joaquin/message.d.ts +2 -1
  88. package/tools/joaquin/message.js +9 -2
  89. package/tools/joaquin/mock.d.ts +1 -0
  90. package/tools/joaquin/mock.js +13 -5
  91. package/tsconfig.build.tsbuildinfo +1 -1
@@ -88,6 +88,7 @@ class BuildTypescriptStage {
88
88
  }
89
89
  libPaths.forEach(lib => {
90
90
  lib = space_1.Space.relPath(compiler.space, lib);
91
+ // TODO: flatten sub-directory of modules
91
92
  replacePaths[lib] = path.resolve(dirs.build, lib);
92
93
  tsPaths['.nesoi/*'] = [space_1.Space.path(compiler.space, '.nesoi') + '/*'];
93
94
  tsPaths[lib + '/*'] = [space_1.Space.path(compiler.space, lib) + '/*'];
@@ -75,6 +75,14 @@ class DumpModulesStage {
75
75
  }
76
76
  str += '\n },';
77
77
  }
78
+ if (Object.keys(externals.messages).length) {
79
+ str += '\n messages: {';
80
+ for (const b in externals.messages) {
81
+ const dep = externals.messages[b];
82
+ str += `\n '${b}': ${JSON.stringify(dep, undefined, 2).replace(/\n/g, '\n ')},`;
83
+ }
84
+ str += '\n },';
85
+ }
78
86
  if (Object.keys(externals.jobs).length) {
79
87
  str += '\n jobs: {\n';
80
88
  for (const b in externals.jobs) {
@@ -14,9 +14,9 @@ const _4_build_schemas_stage_1 = require("./stages/4_build_schemas_stage");
14
14
  const _5_inject_ts_stage_1 = require("./stages/5_inject_ts_stage");
15
15
  const _6_build_elements_stage_1 = require("./stages/6_build_elements_stage");
16
16
  const _7_dump_stage_1 = require("./stages/7_dump_stage");
17
+ const _8_diagnose_stage_1 = require("./stages/8_diagnose_stage");
17
18
  const console_1 = __importDefault(require("../engine/util/console"));
18
19
  const log_1 = require("../engine/util/log");
19
- const _8_diagnose_stage_1 = require("./stages/8_diagnose_stage");
20
20
  const fs_1 = __importDefault(require("fs"));
21
21
  class Compiler {
22
22
  constructor(space, config) {
@@ -13,8 +13,9 @@ export declare class BucketElement extends Element<$Bucket> {
13
13
  };
14
14
  private buildModelFieldType;
15
15
  private buildCompositionType;
16
- buildModelType(fields?: $BucketModelFields): ObjTypeAsObj;
17
- buildModelFieldNamesType(model: ObjTypeAsObj, fields?: $BucketModelFields): Record<string, TypeAsObj>;
16
+ buildModelType(fields?: $BucketModelFields, singleLine?: boolean): ObjTypeAsObj;
17
+ buildModelpath(): Record<string, TypeAsObj>;
18
+ buildQuerypath(fields?: $BucketModelFields): Record<string, TypeAsObj>;
18
19
  private buildGraphType;
19
20
  private buildViewsType;
20
21
  private buildViewType;
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BucketElement = void 0;
4
+ const bucket_model_schema_1 = require("../../elements/entities/bucket/model/bucket_model.schema");
4
5
  const element_1 = require("./element");
5
6
  const name_helpers_1 = require("../helpers/name_helpers");
6
7
  const dependency_1 = require("../../engine/dependency");
7
- const tree_1 = require("../../engine/data/tree");
8
8
  const dump_helpers_1 = require("../helpers/dump_helpers");
9
9
  class BucketElement extends element_1.Element {
10
10
  // Prepare
11
11
  prepare() {
12
12
  this.schema['#data'] = element_1.Element.Any;
13
- this.schema['#fieldpath'] = element_1.Element.Any;
13
+ this.schema['#modelpath'] = element_1.Element.Any;
14
+ this.schema['#querypath'] = element_1.Element.Any;
14
15
  this.schema['#composition'] = element_1.Element.Any;
15
16
  this.schema['#defaults'] = element_1.Element.Any;
16
17
  this.prepareGraph(this.schema.graph.links);
@@ -34,9 +35,6 @@ class BucketElement extends element_1.Element {
34
35
  if (field.children) {
35
36
  this.prepareViewFields(field.children);
36
37
  }
37
- else {
38
- field.children = element_1.Element.Never;
39
- }
40
38
  });
41
39
  }
42
40
  // Imports
@@ -48,13 +46,16 @@ class BucketElement extends element_1.Element {
48
46
  buildType() {
49
47
  const model = this.buildModelType();
50
48
  const bucket = dump_helpers_1.DumpHelpers.dumpValueToType(this.schema, {
49
+ model: () => 'any', // = this.buildModelType(),
51
50
  graph: () => this.buildGraphType(),
52
- views: () => this.buildViewsType(model)
51
+ views: () => this.buildViewsType()
53
52
  });
54
- const fieldpaths = this.buildModelFieldNamesType(model);
53
+ const modelpath = this.buildModelpath();
54
+ const querypath = this.buildQuerypath();
55
55
  const composition = this.buildCompositionType();
56
56
  Object.assign(bucket, {
57
- '#fieldpath': fieldpaths,
57
+ '#modelpath': modelpath,
58
+ '#querypath': querypath,
58
59
  '#composition': composition,
59
60
  '#defaults': bucket.defaults || '{}',
60
61
  '#data': this.highName
@@ -64,7 +65,7 @@ class BucketElement extends element_1.Element {
64
65
  bucket
65
66
  };
66
67
  }
67
- buildModelFieldType(field, isUnion = false) {
68
+ buildModelFieldType(field, singleLine = false) {
68
69
  let type = 'unknown';
69
70
  if (field.type === 'boolean') {
70
71
  type = 'boolean';
@@ -90,10 +91,10 @@ class BucketElement extends element_1.Element {
90
91
  }
91
92
  }
92
93
  else if (Array.isArray(options)) {
93
- type = options.map(v => dump_helpers_1.DumpHelpers.dumpValueToType(v));
94
+ type = options.map(v => dump_helpers_1.DumpHelpers.dumpValueToType(v, undefined, singleLine));
94
95
  }
95
96
  else if (typeof options === 'object') {
96
- type = Object.values(options || []).map(v => dump_helpers_1.DumpHelpers.dumpValueToType(v));
97
+ type = Object.values(options || []).map(v => dump_helpers_1.DumpHelpers.dumpValueToType(v, undefined, singleLine));
97
98
  }
98
99
  }
99
100
  else if (field.type === 'file') {
@@ -109,47 +110,34 @@ class BucketElement extends element_1.Element {
109
110
  type = 'string';
110
111
  }
111
112
  else if (field.type === 'obj') {
112
- type = this.buildModelType(field.children);
113
+ type = this.buildModelType(field.children, singleLine);
113
114
  }
114
115
  else if (field.type === 'unknown') {
115
116
  type = 'unknown';
116
117
  }
117
118
  else if (field.type === 'dict') {
118
119
  type = this.buildModelType({
119
- '[x in string]': field.children.__dict
120
- });
120
+ '[x in string]': field.children['#']
121
+ }, singleLine);
121
122
  }
122
- if (field.or) {
123
- const orType = this.buildModelFieldType(field.or, true);
123
+ else if (field.type === 'list') {
124
+ type = this.buildModelFieldType(field.children['#']);
124
125
  if (typeof type === 'object') {
125
- type.__or = orType;
126
- }
127
- else if (typeof orType === 'object') {
128
- const nonObj = type;
129
- type = orType;
130
- type.__or = nonObj;
126
+ type.__array = true;
131
127
  }
132
128
  else {
133
- type = `${type} | ${orType}`;
129
+ type = `(${type})[]`;
134
130
  }
135
131
  }
136
- if (!isUnion) {
137
- if (!field.required && field.defaultValue === undefined) {
138
- if (typeof type === 'object') {
139
- type.__optional = true;
140
- }
141
- else {
142
- type = `(${type}) | undefined`;
143
- }
144
- }
145
- if (field.array) {
146
- if (typeof type === 'object') {
147
- type.__array = true;
148
- }
149
- else {
150
- type = `(${type})[]`;
151
- }
152
- }
132
+ else if (field.type === 'union') {
133
+ const types = Object.values(this.buildModelType(field.children, singleLine));
134
+ type = dump_helpers_1.DumpHelpers.dumpUnionType(types, singleLine);
135
+ }
136
+ if (!field.required) {
137
+ type = '('
138
+ + dump_helpers_1.DumpHelpers.dumpType(type, singleLine)
139
+ + ' | null | undefined'
140
+ + ')';
153
141
  }
154
142
  return type;
155
143
  }
@@ -167,31 +155,32 @@ class BucketElement extends element_1.Element {
167
155
  });
168
156
  return composition;
169
157
  }
170
- buildModelType(fields = this.schema.model.fields) {
158
+ buildModelType(fields = this.schema.model.fields, singleLine = false) {
171
159
  const model = {};
172
160
  Object.entries(fields).forEach(([key, field]) => {
173
- model[key] = this.buildModelFieldType(field);
161
+ model[key] = this.buildModelFieldType(field, singleLine);
174
162
  });
175
163
  return model;
176
164
  }
177
- buildModelFieldNamesType(model, fields = this.schema.model.fields) {
178
- const fieldPaths = {};
179
- Object.entries(fields).forEach(([key, field]) => {
180
- if (key === '__dict') {
181
- return;
182
- }
183
- fieldPaths[field.path] = model[key];
184
- if (field.children) {
185
- let nextFields = field.children;
186
- if ('__dict' in field.children) {
187
- nextFields = field.children.__dict.children;
188
- }
189
- if (nextFields) {
190
- Object.assign(fieldPaths, this.buildModelFieldNamesType(model[key], nextFields));
191
- }
192
- }
193
- });
194
- return fieldPaths;
165
+ buildModelpath() {
166
+ const modelpath = {
167
+ '[x: string]': 'any'
168
+ };
169
+ // const fields = $BucketModel.getModelpaths(this.schema.model);
170
+ // console.log({fields});
171
+ // for (const k in fields) {
172
+ // modelpath[k] = DumpHelpers.dumpUnionType(
173
+ // fields[k].map(field => this.buildModelFieldType(field, true))
174
+ // , true)
175
+ // console.log(k, modelpath[k]);
176
+ // }
177
+ return modelpath;
178
+ }
179
+ buildQuerypath(fields = this.schema.model.fields) {
180
+ const querypath = {
181
+ '[x: string]': 'any'
182
+ };
183
+ return querypath;
195
184
  }
196
185
  buildGraphType() {
197
186
  const links = {};
@@ -208,90 +197,59 @@ class BucketElement extends element_1.Element {
208
197
  links
209
198
  };
210
199
  }
211
- buildViewsType(model) {
200
+ buildViewsType() {
212
201
  const views = {};
213
202
  Object.entries(this.schema.views).forEach(([key, view]) => {
214
- views[key] = this.buildViewType(model, view.fields, key);
203
+ views[key] = this.buildViewType(view.fields, key);
215
204
  });
216
205
  return views;
217
206
  }
218
- buildViewType(model, schema, name) {
207
+ buildViewType(schema, name) {
219
208
  if (!schema) {
220
209
  return;
221
210
  }
222
- const fields = {};
223
- const data = {};
224
- Object.entries(schema).forEach(([key, field]) => {
225
- if (field.scope === 'model' && 'model' in field.value) {
226
- data[key] = tree_1.Tree.get(model, field.value.model.key, 0) || {};
227
- let children;
228
- if (field.type === 'obj') {
229
- children = field.children &&
230
- this.buildViewType(model, field.children, field.name);
231
- data[key] = Object.assign({}, data[key], children?.['#data']);
211
+ const buildFields = (fields) => {
212
+ const data = {};
213
+ for (const key in fields) {
214
+ const field = fields[key];
215
+ if (field.scope === 'model' && 'model' in field.meta) {
216
+ const modelFields = bucket_model_schema_1.$BucketModel.getField(this.schema.model, field.meta.model.path);
217
+ const types = [];
218
+ if (!field.children || '__raw' in field.children) {
219
+ types.push(dump_helpers_1.DumpHelpers.dumpUnionType(modelFields.map(f => this.buildModelFieldType(f))));
220
+ }
221
+ // Contains children
222
+ if (field.children) {
223
+ types.push(buildFields(field.children));
224
+ }
225
+ data[key] = dump_helpers_1.DumpHelpers.dumpIntersectionType(types);
232
226
  }
233
- fields[key] = {
234
- '#data': data[key],
235
- children: children?.fields
236
- };
237
- }
238
- else if (field.scope === 'graph' && 'graph' in field.value) {
239
- const link = this.schema.graph.links[field.value.graph.link];
240
- const bucket = dependency_1.$Dependency.typeName(link.bucket, this.module);
241
- if (field.value.graph.view) {
242
- data[key] = `${bucket}['views']['${field.value.graph.view}']['#data']${link.many ? '[]' : ''}${link.optional ? ' | undefined' : ''}`;
227
+ else if (field.scope === 'graph' && 'graph' in field.meta) {
228
+ const link = this.schema.graph.links[field.meta.graph.link];
229
+ const bucket = dependency_1.$Dependency.typeName(link.bucket, this.module);
230
+ if (field.meta.graph.view) {
231
+ data[key] = `${bucket}['views']['${field.meta.graph.view}']['#data']${link.many ? '[]' : ''}${link.optional ? ' | undefined' : ''}`;
232
+ }
233
+ else {
234
+ data[key] = `${bucket}['#data']${link.many ? '[]' : ''}${link.optional ? ' | undefined' : ''}`;
235
+ }
243
236
  }
244
- else {
245
- data[key] = `${bucket}['#data']${link.many ? '[]' : ''}${link.optional ? ' | undefined' : ''}`;
237
+ else if (field.scope === 'computed') {
238
+ data[key] = field['#data'];
246
239
  }
247
- fields[key] = {
248
- '#data': data[key],
249
- children: 'undefined'
250
- };
251
- }
252
- else if (field.scope === 'computed') {
253
- data[key] = field['#data'];
254
- fields[key] = {
255
- '#data': data[key],
256
- children: 'undefined'
257
- };
258
- }
259
- else if (field.scope === 'view' || field.scope === 'group') {
260
- const children = this.buildViewType(model, field.children, field.name);
261
- data[key] = children['#data'];
262
- fields[key] = {
263
- '#data': data[key],
264
- children: children.fields
265
- };
266
- }
267
- else if (field.scope === 'drive') {
268
- fields[key] = {
269
- '#data': 'string',
270
- children: 'undefined'
271
- };
272
- }
273
- const { children, ...f } = field;
274
- const type = dump_helpers_1.DumpHelpers.dumpValueToType(f, {
275
- $t: () => dump_helpers_1.DumpHelpers.dumpValueToType('bucket.view.field'),
276
- value: {
277
- model: v => ({
278
- key: dump_helpers_1.DumpHelpers.dumpValueToType(v.key),
279
- enumOptions: v.enumOptions ? dump_helpers_1.DumpHelpers.dumpValueToType(v.enumOptions) : 'undefined'
280
- }),
281
- graph: v => ({
282
- link: dump_helpers_1.DumpHelpers.dumpValueToType(v.link),
283
- view: v.view ? dump_helpers_1.DumpHelpers.dumpValueToType(v.view) : 'undefined'
284
- }),
285
- drive: v => dump_helpers_1.DumpHelpers.dumpValueToType(v)
240
+ else if (field.scope === 'view' || field.scope === 'group') {
241
+ const children = this.buildViewType(field.children, field.name);
242
+ data[key] = children['#data'];
286
243
  }
287
- });
288
- Object.assign(fields[key], type);
289
- });
244
+ }
245
+ return data;
246
+ };
247
+ const data = buildFields(schema);
290
248
  return {
291
249
  $t: dump_helpers_1.DumpHelpers.dumpValueToType('bucket.view'),
250
+ fields: 'any',
292
251
  '#data': data,
293
252
  name: dump_helpers_1.DumpHelpers.dumpValueToType(name),
294
- fields: 'any' // TODO: review if this might be needed
295
253
  };
296
254
  }
297
255
  // Dump
@@ -27,7 +27,8 @@ class Element {
27
27
  }
28
28
  bridgeImports() {
29
29
  let imports = '';
30
- for (const imp of this.bridge?.imports || []) {
30
+ const uniqueImports = new Set(this.bridge?.imports || []);
31
+ for (const imp of uniqueImports) {
31
32
  imports += imp + '\n';
32
33
  }
33
34
  return imports;
@@ -76,9 +77,10 @@ class Element {
76
77
  const msgName = name_helpers_1.NameHelpers.names(schema);
77
78
  return msgName.type;
78
79
  });
80
+ const _input = new Set(input);
79
81
  const output = schema['#output'] || this.makeOutputType(compiler, schema);
80
82
  return {
81
- input: input.length ? input.join(' | ') : 'never',
83
+ input: _input.size ? [..._input].join(' | ') : 'never',
82
84
  output
83
85
  };
84
86
  }
@@ -33,6 +33,9 @@ class ExternalsElement extends element_1.Element {
33
33
  Object.values(this.schema.buckets).forEach(ref => {
34
34
  externalModules.add(ref.module);
35
35
  });
36
+ Object.values(this.schema.messages).forEach(ref => {
37
+ externalModules.add(ref.module);
38
+ });
36
39
  Object.values(this.schema.jobs).forEach(ref => {
37
40
  externalModules.add(ref.module);
38
41
  });
@@ -81,7 +81,7 @@ class MachineElement extends element_1.Element {
81
81
  Object.entries(stateTransitions).forEach(([msg, msgTransitions]) => {
82
82
  type[state][msg] = [];
83
83
  Object.values(msgTransitions).forEach(transition => {
84
- const t = dump_helpers_1.DumpHelpers.dumpValueToType(transition, undefined, 4);
84
+ const t = dump_helpers_1.DumpHelpers.dumpValueToType(transition, undefined, undefined, 4);
85
85
  Object.assign(t, {
86
86
  '#authn': element_1.Element.makeAuthnType(transition.authn),
87
87
  '#input': element_1.Element.makeIOType(this.compiler, transition).input,
@@ -89,7 +89,7 @@ class MachineElement extends element_1.Element {
89
89
  });
90
90
  type[state][msg].push(t);
91
91
  });
92
- type[state][msg] = '[' + type[state][msg].map((v) => dump_helpers_1.DumpHelpers.dumpType(v, 4)).join(', ') + ']';
92
+ type[state][msg] = '[' + type[state][msg].map((v) => dump_helpers_1.DumpHelpers.dumpType(v, undefined, 4)).join(', ') + ']';
93
93
  });
94
94
  });
95
95
  return type;
@@ -124,76 +124,54 @@ class MessageElement extends element_1.Element {
124
124
  else if (field.type === 'dict') {
125
125
  const child = this.buildIO(field.children);
126
126
  input[key] = {
127
- '[x in string]': child.input.__dict
127
+ '[x in string]': child.input['#']
128
128
  };
129
129
  output[key] = {
130
- '[x in string]': child.output.__dict
130
+ '[x in string]': child.output['#']
131
131
  };
132
132
  }
133
- else if (field.type === 'msg') {
134
- input[key] = 'any';
135
- output[key] = 'any';
136
- }
137
- else {
138
- input[key] = 'unknown';
139
- output[key] = 'unknown';
140
- }
141
- if (field.or) {
142
- const orType = buildField(key, field.or, true);
133
+ else if (field.type === 'list') {
134
+ const child = this.buildIO(field.children);
135
+ input[key] = child.input['#'];
136
+ output[key] = child.output['#'];
143
137
  if (typeof input[key] === 'object') {
144
- input[key].__or = orType;
145
- }
146
- else if (typeof orType === 'object') {
147
- const nonObj = input[key];
148
- input[key] = orType;
149
- input[key].__or = nonObj;
138
+ input[key].__array = true;
150
139
  }
151
140
  else {
152
- input[key] = `${input[key]} | ${orType}`;
141
+ input[key] = `(${input[key]})[]`;
153
142
  }
154
143
  if (typeof output[key] === 'object') {
155
- output[key].__or = orType;
156
- }
157
- else if (typeof orType === 'object') {
158
- const nonObj = output[key];
159
- output[key] = orType;
160
- output[key].__or = nonObj;
144
+ output[key].__array = true;
161
145
  }
162
146
  else {
163
- output[key] = `${output[key]} | ${orType}`;
147
+ output[key] = `(${output[key]})[]`;
164
148
  }
165
149
  }
166
- if (!isUnion) {
167
- if (!field.required) {
168
- if (typeof input[key] === 'object') {
169
- input[key].__optional = true;
170
- }
171
- else {
172
- input[key] = `(${input[key]}) | undefined`;
173
- }
174
- if (field.defaultValue === undefined) {
175
- if (typeof output[key] === 'object') {
176
- output[key].__optional = true;
177
- }
178
- else {
179
- output[key] = `(${output[key]}) | undefined`;
180
- }
181
- }
182
- }
183
- if (field.array) {
184
- if (typeof input[key] === 'object') {
185
- input[key].__array = true;
186
- }
187
- else {
188
- input[key] = `(${input[key]})[]`;
189
- }
190
- if (typeof output[key] === 'object') {
191
- output[key].__array = true;
192
- }
193
- else {
194
- output[key] = `(${output[key]})[]`;
195
- }
196
- }
150
+ else if (field.type === 'union') {
151
+ const child = this.buildIO(field.children);
152
+ input[key] = '(' + Object.values(child.input).map(t => dump_helpers_1.DumpHelpers.dumpType(t)).join(' | ') + ')';
153
+ output[key] = '(' + Object.values(child.output).map(t => dump_helpers_1.DumpHelpers.dumpType(t)).join(' | ') + ')';
154
+ }
155
+ else if (field.type === 'msg') {
156
+ input[key] = 'any';
157
+ output[key] = 'any';
158
+ }
159
+ else {
160
+ input[key] = 'unknown';
161
+ output[key] = 'unknown';
162
+ }
163
+ if (!field.required || field.nullable) {
164
+ const inkey = field.type === 'id' ? `${key}_id` : key;
165
+ input[inkey] = '('
166
+ + dump_helpers_1.DumpHelpers.dumpType(input[inkey])
167
+ + (!field.required ? ' | undefined' : '')
168
+ + (field.nullable ? ' | null' : '')
169
+ + ')';
170
+ output[key] = '('
171
+ + dump_helpers_1.DumpHelpers.dumpType(output[key])
172
+ + ((!field.required && field.defaultValue === undefined) ? ' | undefined' : '')
173
+ + (field.nullable ? ' | null' : '')
174
+ + ')';
197
175
  }
198
176
  };
199
177
  Object.entries(fields).forEach(([key, field]) => {
@@ -6,7 +6,7 @@ const dump_helpers_1 = require("../helpers/dump_helpers");
6
6
  class QueueElement extends element_1.Element {
7
7
  prepare() {
8
8
  this.schema['#authn'] = element_1.Element.Any;
9
- this.schema['#input'] = element_1.Element.Any;
9
+ this.schema['#input'] = element_1.Element.Never;
10
10
  this.schema['#output'] = element_1.Element.Any;
11
11
  }
12
12
  buildType() {
@@ -3,9 +3,11 @@ type TransformTypes = {
3
3
  [x: string]: TransformTypes | ((v?: any) => TypeAsObj);
4
4
  };
5
5
  export declare class DumpHelpers {
6
- static dumpType(type: TypeAsObj, d?: number): string;
7
- static dumpSchema(val: any, d?: number): string;
6
+ static dumpUnionType(types: TypeAsObj[], singleLine?: boolean): string;
7
+ static dumpIntersectionType(types: TypeAsObj[], singleLine?: boolean): string;
8
+ static dumpType(type: TypeAsObj, singleLine?: boolean, d?: number): string;
9
+ static dumpSchema(val: any, singleLine?: boolean, d?: number): string;
8
10
  private static dumpFunction;
9
- static dumpValueToType(value: any, transform?: TransformTypes, d?: number): TypeAsObj;
11
+ static dumpValueToType(value: any, transform?: TransformTypes, singleLine?: boolean, d?: number): TypeAsObj;
10
12
  }
11
13
  export {};