nesoi 3.0.21 → 3.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.
Files changed (80) hide show
  1. package/lib/compiler/apps/monolyth/stages/4_dump_modules_stage.js +8 -0
  2. package/lib/compiler/compiler.js +1 -1
  3. package/lib/compiler/elements/bucket.element.d.ts +2 -1
  4. package/lib/compiler/elements/bucket.element.js +68 -122
  5. package/lib/compiler/elements/element.js +2 -1
  6. package/lib/compiler/elements/externals.element.js +3 -0
  7. package/lib/compiler/elements/message.element.js +34 -57
  8. package/lib/compiler/elements/queue.element.js +1 -1
  9. package/lib/compiler/helpers/dump_helpers.d.ts +2 -0
  10. package/lib/compiler/helpers/dump_helpers.js +12 -2
  11. package/lib/compiler/stages/4_build_schemas_stage.js +12 -0
  12. package/lib/compiler/stages/5_inject_ts_stage.js +4 -1
  13. package/lib/compiler/stages/7_dump_stage.js +7 -1
  14. package/lib/compiler/treeshake.js +4 -2
  15. package/lib/compiler/typescript/bridge/extract.js +37 -107
  16. package/lib/compiler/typescript/bridge/inject.d.ts +1 -1
  17. package/lib/compiler/typescript/bridge/inject.js +73 -45
  18. package/lib/compiler/typescript/bridge/organize.js +9 -5
  19. package/lib/compiler/typescript/typescript_compiler.d.ts +4 -6
  20. package/lib/compiler/typescript/typescript_compiler.js +139 -75
  21. package/lib/elements/blocks/block.builder.d.ts +1 -10
  22. package/lib/elements/blocks/block.builder.js +0 -32
  23. package/lib/elements/blocks/job/internal/resource_job.builder.d.ts +3 -21
  24. package/lib/elements/blocks/job/job.builder.d.ts +6 -20
  25. package/lib/elements/blocks/job/job.builder.js +0 -4
  26. package/lib/elements/blocks/machine/machine.builder.d.ts +5 -14
  27. package/lib/elements/blocks/machine/machine.builder.js +2 -2
  28. package/lib/elements/blocks/queue/queue.builder.d.ts +6 -15
  29. package/lib/elements/blocks/queue/queue.builder.js +2 -2
  30. package/lib/elements/edge/externals/externals.builder.d.ts +2 -0
  31. package/lib/elements/edge/externals/externals.builder.js +6 -1
  32. package/lib/elements/edge/externals/externals.schema.d.ts +2 -1
  33. package/lib/elements/edge/externals/externals.schema.js +3 -1
  34. package/lib/elements/entities/bucket/adapters/memory.nql.js +1 -1
  35. package/lib/elements/entities/bucket/bucket.builder.d.ts +6 -4
  36. package/lib/elements/entities/bucket/bucket.js +7 -16
  37. package/lib/elements/entities/bucket/bucket.schema.d.ts +2 -1
  38. package/lib/elements/entities/bucket/graph/bucket_graph.infer.d.ts +7 -5
  39. package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.d.ts +2 -1
  40. package/lib/elements/entities/bucket/model/bucket_model.builder.d.ts +1 -1
  41. package/lib/elements/entities/bucket/model/bucket_model.convert.d.ts +1 -1
  42. package/lib/elements/entities/bucket/model/bucket_model.convert.js +4 -4
  43. package/lib/elements/entities/bucket/model/bucket_model.infer.d.ts +45 -9
  44. package/lib/elements/entities/bucket/model/bucket_model.schema.d.ts +5 -6
  45. package/lib/elements/entities/bucket/model/bucket_model.schema.js +64 -21
  46. package/lib/elements/entities/bucket/model/bucket_model_field.builder.d.ts +88 -55
  47. package/lib/elements/entities/bucket/model/bucket_model_field.builder.js +22 -30
  48. package/lib/elements/entities/bucket/query/nql.schema.d.ts +13 -10
  49. package/lib/elements/entities/bucket/query/nql_compiler.js +46 -21
  50. package/lib/elements/entities/bucket/view/bucket_view.builder.js +1 -1
  51. package/lib/elements/entities/bucket/view/bucket_view.d.ts +19 -0
  52. package/lib/elements/entities/bucket/view/bucket_view.js +230 -108
  53. package/lib/elements/entities/bucket/view/bucket_view.schema.d.ts +5 -10
  54. package/lib/elements/entities/bucket/view/bucket_view.schema.js +3 -5
  55. package/lib/elements/entities/bucket/view/bucket_view_field.builder.d.ts +16 -12
  56. package/lib/elements/entities/bucket/view/bucket_view_field.builder.js +55 -40
  57. package/lib/elements/entities/message/message.builder.d.ts +1 -11
  58. package/lib/elements/entities/message/message.infer.d.ts +6 -30
  59. package/lib/elements/entities/message/message.schema.js +2 -2
  60. package/lib/elements/entities/message/template/message_template.builder.js +1 -1
  61. package/lib/elements/entities/message/template/message_template.schema.d.ts +10 -15
  62. package/lib/elements/entities/message/template/message_template.schema.js +29 -12
  63. package/lib/elements/entities/message/template/message_template_field.builder.d.ts +45 -209
  64. package/lib/elements/entities/message/template/message_template_field.builder.js +69 -85
  65. package/lib/elements/entities/message/template/message_template_parser.js +50 -65
  66. package/lib/engine/apps/inline.app.js +1 -0
  67. package/lib/engine/data/trash.js +7 -7
  68. package/lib/engine/data/tree.d.ts +3 -0
  69. package/lib/engine/data/tree.js +36 -0
  70. package/lib/engine/util/parse.d.ts +22 -14
  71. package/lib/engine/util/parse.js +18 -3
  72. package/lib/engine/util/type.d.ts +3 -0
  73. package/package.json +1 -1
  74. package/tools/joaquin/bucket.d.ts +9 -0
  75. package/tools/joaquin/bucket.js +49 -0
  76. package/tools/joaquin/message.d.ts +2 -1
  77. package/tools/joaquin/message.js +9 -2
  78. package/tools/joaquin/mock.d.ts +1 -0
  79. package/tools/joaquin/mock.js +13 -5
  80. package/tsconfig.build.tsbuildinfo +1 -1
@@ -45,9 +45,7 @@ class TSBridgeExtract {
45
45
  }
46
46
  return;
47
47
  }
48
- const imports = tsCompiler.extractImports(node.filepath, {
49
- ignore: [] // TODO: ignore space file
50
- });
48
+ const imports = tsCompiler.extractImports(node.filepath);
51
49
  if (imports.length) {
52
50
  log_1.Log.debug('compiler', 'bridge.extract', `Extracted TS imports from ${node.filepath}`, imports);
53
51
  }
@@ -103,141 +101,89 @@ class TSBridgeExtract {
103
101
  }
104
102
  if (node.builder.$b === 'message') {
105
103
  functions.push(...tsCompiler.query(node.filepath, {
106
- query: 'message.*.template.0.return.**.rule.0',
107
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
104
+ query: 'message.*.template.0.return.*.rule.0',
105
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
108
106
  }));
109
- }
110
- if (node.builder.$b === 'job') {
111
107
  functions.push(...tsCompiler.query(node.filepath, {
112
- query: 'job.*.messages.0.return.*.**.rule.0',
113
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
108
+ query: 'message.*.template.0.return.*.{~.#.*?}.rule.0',
109
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
114
110
  }));
111
+ }
112
+ if (node.builder.$b === 'job') {
115
113
  functions.push(...tsCompiler.query(node.filepath, {
116
- query: 'job.*.extra.0',
117
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
114
+ query: 'job.*.message.1.return.*.rule.0',
115
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
118
116
  }));
119
117
  functions.push(...tsCompiler.query(node.filepath, {
120
- query: 'job.*.assert.0',
121
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
118
+ query: 'job.*.message.1.return.*.{~.#.*?}.rule.0',
119
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
122
120
  }));
123
121
  functions.push(...tsCompiler.query(node.filepath, {
124
- query: 'job.*.method.0',
122
+ query: 'job.*.extra|assert|method.0',
125
123
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
126
124
  }));
127
125
  }
128
126
  if (node.builder.$b === 'resource') {
129
127
  functions.push(...tsCompiler.query(node.filepath, {
130
- query: 'resource.*.create.0.return.input.0.return.**.rule.0',
131
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
132
- }));
133
- functions.push(...tsCompiler.query(node.filepath, {
134
- query: 'resource.*.create.0.return.extra.0',
135
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
136
- }));
137
- functions.push(...tsCompiler.query(node.filepath, {
138
- query: 'resource.*.create.0.return.assert.0',
139
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
140
- }));
141
- functions.push(...tsCompiler.query(node.filepath, {
142
- query: 'resource.*.create.0.return.prepare.0',
143
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
128
+ query: 'resource.*.create.0.return.input.0.return.*.rule.0',
129
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
144
130
  }));
145
131
  functions.push(...tsCompiler.query(node.filepath, {
146
- query: 'resource.*.create.0.return.after.0',
147
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
132
+ query: 'resource.*.create.0.return.input.0.return.*.{~.#.*?}.rule.0',
133
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
148
134
  }));
149
135
  functions.push(...tsCompiler.query(node.filepath, {
150
- query: 'resource.*.update.0.return.input.0.return.**.rule.0',
136
+ query: 'resource.*.create.0.return.extra|assert|prepare|after.0',
151
137
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
152
138
  }));
153
139
  functions.push(...tsCompiler.query(node.filepath, {
154
- query: 'resource.*.update.0.return.extra.0',
155
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
140
+ query: 'resource.*.update.0.return.input.0.return.*.rule.0',
141
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
156
142
  }));
157
143
  functions.push(...tsCompiler.query(node.filepath, {
158
- query: 'resource.*.update.0.return.assert.0',
159
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
144
+ query: 'resource.*.update.0.return.input.0.return.*.{~.#.*?}.rule.0',
145
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
160
146
  }));
161
147
  functions.push(...tsCompiler.query(node.filepath, {
162
- query: 'resource.*.update.0.return.prepare.0',
148
+ query: 'resource.*.update.0.return.extra|assert|prepare|after.0',
163
149
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
164
150
  }));
165
151
  functions.push(...tsCompiler.query(node.filepath, {
166
- query: 'resource.*.update.0.return.after.0',
167
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
152
+ query: 'resource.*.delete.0.return.input.0.return.*.rule.0',
153
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
168
154
  }));
169
155
  functions.push(...tsCompiler.query(node.filepath, {
170
- query: 'resource.*.delete.0.return.input.0.return.**.rule.0',
171
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
172
- }));
173
- functions.push(...tsCompiler.query(node.filepath, {
174
- query: 'resource.*.delete.0.return.extra.0',
175
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
156
+ query: 'resource.*.delete.0.return.input.0.return.*.{~.#.*?}.rule.0',
157
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
176
158
  }));
177
159
  functions.push(...tsCompiler.query(node.filepath, {
178
- query: 'resource.*.delete.0.return.assert.0',
179
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
180
- }));
181
- functions.push(...tsCompiler.query(node.filepath, {
182
- query: 'resource.*.delete.0.return.prepare.0',
183
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
184
- }));
185
- functions.push(...tsCompiler.query(node.filepath, {
186
- query: 'resource.*.delete.0.return.after.0',
160
+ query: 'resource.*.delete.0.return.extra|assert|prepare|after.0',
187
161
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
188
162
  }));
189
163
  }
190
164
  if (node.builder.$b === 'machine') {
191
165
  functions.push(...tsCompiler.query(node.filepath, {
192
- query: 'machine.*.messages.0.return.*.**.rule.0',
193
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
166
+ query: 'machine.*.message.1.return.**.rule.0',
167
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
194
168
  }));
195
169
  functions.push(...tsCompiler.query(node.filepath, {
196
- query: 'machine.*.{state.1.return}.beforeEnter.0.return.extra.0',
197
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
170
+ query: 'machine.*.message.1.return.{**.obj.0}.**.rule.0',
171
+ expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression, ts.SyntaxKind.PropertyAccessExpression]
198
172
  }));
199
173
  functions.push(...tsCompiler.query(node.filepath, {
200
- query: 'machine.*.{state.1.return}.beforeEnter.0.return.assert.0',
174
+ query: 'machine.*.{state.1.return}.beforeEnter.0.return.extra|assert|method.0',
201
175
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
202
176
  }));
203
177
  functions.push(...tsCompiler.query(node.filepath, {
204
- query: 'machine.*.{state.1.return}.beforeEnter.0.return.method.0',
178
+ query: 'machine.*.{state.1.return}.afterEnter.0.return.extra|assert|method.0',
205
179
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
206
180
  }));
207
181
  functions.push(...tsCompiler.query(node.filepath, {
208
- query: 'machine.*.{state.1.return}.afterEnter.0.return.extra.0',
182
+ query: 'machine.*.{state.1.return}.beforeLeave.0.return.extra|assert|method.0',
209
183
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
210
184
  }));
211
185
  functions.push(...tsCompiler.query(node.filepath, {
212
- query: 'machine.*.{state.1.return}.afterEnter.0.return.assert.0',
213
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
214
- }));
215
- functions.push(...tsCompiler.query(node.filepath, {
216
- query: 'machine.*.{state.1.return}.afterEnter.0.return.method.0',
217
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
218
- }));
219
- functions.push(...tsCompiler.query(node.filepath, {
220
- query: 'machine.*.{state.1.return}.beforeLeave.0.return.extra.0',
221
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
222
- }));
223
- functions.push(...tsCompiler.query(node.filepath, {
224
- query: 'machine.*.{state.1.return}.beforeLeave.0.return.assert.0',
225
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
226
- }));
227
- functions.push(...tsCompiler.query(node.filepath, {
228
- query: 'machine.*.{state.1.return}.beforeLeave.0.return.method.0',
229
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
230
- }));
231
- functions.push(...tsCompiler.query(node.filepath, {
232
- query: 'machine.*.{state.1.return}.afterLeave.0.return.extra.0',
233
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
234
- }));
235
- functions.push(...tsCompiler.query(node.filepath, {
236
- query: 'machine.*.{state.1.return}.afterLeave.0.return.assert.0',
237
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
238
- }));
239
- functions.push(...tsCompiler.query(node.filepath, {
240
- query: 'machine.*.{state.1.return}.afterLeave.0.return.method.0',
186
+ query: 'machine.*.{state.1.return}.afterLeave.0.return.extra|assert|method.0',
241
187
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
242
188
  }));
243
189
  functions.push(...tsCompiler.query(node.filepath, {
@@ -249,27 +195,11 @@ class TSBridgeExtract {
249
195
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
250
196
  }));
251
197
  functions.push(...tsCompiler.query(node.filepath, {
252
- query: 'machine.*.{state.1.return}.transition.1.return.runJob.0.return.extra.0',
253
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
254
- }));
255
- functions.push(...tsCompiler.query(node.filepath, {
256
- query: 'machine.*.{state.1.return}.transition.1.return.{else.0.return}.runJob.0.return.extra.0',
257
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
258
- }));
259
- functions.push(...tsCompiler.query(node.filepath, {
260
- query: 'machine.*.{state.1.return}.transition.1.return.runJob.0.return.assert.0',
261
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
262
- }));
263
- functions.push(...tsCompiler.query(node.filepath, {
264
- query: 'machine.*.{state.1.return}.transition.1.return.{else.0.return}.runJob.0.return.assert.0',
265
- expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
266
- }));
267
- functions.push(...tsCompiler.query(node.filepath, {
268
- query: 'machine.*.{state.1.return}.transition.1.return.runJob.0.return.method.0',
198
+ query: 'machine.*.{state.1.return}.transition.1.return.runJob.0.return.extra|assert|method.0',
269
199
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
270
200
  }));
271
201
  functions.push(...tsCompiler.query(node.filepath, {
272
- query: 'machine.*.{state.1.return}.transition.1.return.{else.0.return}.runJob.0.return.method.0',
202
+ query: 'machine.*.{state.1.return}.transition.1.return.{else.0.return}.runJob.0.return.extra|assert|method.0',
273
203
  expectedKinds: [ts.SyntaxKind.FunctionExpression, ts.SyntaxKind.ArrowFunction, ts.SyntaxKind.Identifier, ts.SyntaxKind.CallExpression]
274
204
  }));
275
205
  }
@@ -1,7 +1,7 @@
1
1
  import { ResolvedBuilderNode } from "../../../engine/dependency";
2
2
  import { Compiler } from "../../compiler";
3
3
  export declare class TSBridgeInject {
4
- static inject(compiler: Compiler, nodes: ResolvedBuilderNode[]): void;
4
+ static inject(compiler: Compiler, nodes: ResolvedBuilderNode[], node: ResolvedBuilderNode): void;
5
5
  private static bucket;
6
6
  private static message;
7
7
  private static job;
@@ -2,40 +2,37 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TSBridgeInject = void 0;
4
4
  const log_1 = require("../../../engine/util/log");
5
+ const message_template_schema_1 = require("../../../elements/entities/message/template/message_template.schema");
5
6
  const name_helpers_1 = require("../../helpers/name_helpers");
6
7
  class TSBridgeInject {
7
- static inject(compiler, nodes) {
8
+ static inject(compiler, nodes, node) {
8
9
  const { tsCompiler } = compiler;
9
- nodes.forEach(node => {
10
- if (node.progressive)
10
+ if (node.progressive)
11
+ return;
12
+ log_1.Log.debug('compiler', 'bridge.inject', `Injecting TS code on ${node.tag}`);
13
+ const schema = node.schema;
14
+ if (schema.$t === 'bucket') {
15
+ const extract = node.bridge?.extract;
16
+ if (!extract)
11
17
  return;
12
- log_1.Log.debug('compiler', 'bridge.inject', `Injecting TS code on ${node.tag}`);
13
- const schema = node.schema;
14
- if (schema.$t === 'bucket') {
15
- const extract = node.bridge?.extract;
16
- if (!extract)
17
- return;
18
- this.bucket(compiler, extract, node);
19
- }
20
- if (schema.$t === 'message') {
21
- const extract = node.bridge?.extract;
22
- if (!extract)
23
- return;
24
- this.message(compiler, extract, node);
25
- }
26
- if (schema.$t === 'job') {
27
- const extract = node.bridge?.extract;
28
- if (!extract)
29
- return;
30
- this.job(compiler, extract, node);
31
- }
32
- if (schema.$t === 'machine') {
33
- const extract = node.bridge?.extract;
34
- if (!extract)
35
- return;
36
- this.machine(compiler, extract, node);
37
- }
38
- });
18
+ this.bucket(compiler, extract, node);
19
+ }
20
+ if (schema.$t === 'message') {
21
+ const extract = node.bridge?.extract;
22
+ this.message(compiler, extract, nodes, node);
23
+ }
24
+ if (schema.$t === 'job') {
25
+ const extract = node.bridge?.extract;
26
+ if (!extract)
27
+ return;
28
+ this.job(compiler, extract, node);
29
+ }
30
+ if (schema.$t === 'machine') {
31
+ const extract = node.bridge?.extract;
32
+ if (!extract)
33
+ return;
34
+ this.machine(compiler, extract, node);
35
+ }
39
36
  }
40
37
  static bucket(compiler, extract, node) {
41
38
  const { tsCompiler } = compiler;
@@ -47,7 +44,7 @@ class TSBridgeInject {
47
44
  prop.split('.').forEach(p => {
48
45
  f = f.children[p];
49
46
  });
50
- f.value.computed = { fn: {
47
+ f.meta.computed = { fn: {
51
48
  __fn: tsCompiler.getFnText(node),
52
49
  __fn_type: '(...args: any[]) => any', // TODO: evaluate
53
50
  } };
@@ -55,22 +52,53 @@ class TSBridgeInject {
55
52
  });
56
53
  });
57
54
  }
58
- static message(compiler, extract, node) {
55
+ static message(compiler, extract, nodes, node) {
59
56
  const { tsCompiler } = compiler;
60
57
  const schema = node.schema;
61
- const typeName = name_helpers_1.NameHelpers.names(schema).type;
62
- Object.entries(extract.rules).forEach(([prop, node]) => {
63
- let f = { children: schema.template.fields };
64
- let addr = '';
65
- prop.split('.').forEach(p => {
66
- f = f.children[p];
67
- addr += `['${p}${f.type === 'id' ? '_id' : ''}']`;
68
- });
69
- const type = `$MessageTemplateRule<${typeName}['#raw']${addr}, ${typeName}['#raw']>`;
70
- f.rules = node.map(fn => ({
71
- __fn: tsCompiler.getFnText(fn),
72
- __fn_type: '(...args: any[]) => any', // TODO: evaluate
73
- }));
58
+ const _extract = extract ? { rules: { ...extract.rules } } : { rules: {} };
59
+ // Step 1: Go through all .msg() fields of the message,
60
+ // and join the referenced extract into this.
61
+ message_template_schema_1.$MessageTemplate.forEachField(schema.template, (field, path) => {
62
+ if (!field.meta.msg)
63
+ return;
64
+ const ref = nodes.find(node => node.tag === field.meta.msg.tag);
65
+ if (!ref) {
66
+ throw new Error(`Unable to inject code from .msg() field, ${field.meta.msg.tag} not found`);
67
+ }
68
+ const refExtract = ref.bridge?.extract;
69
+ if (!refExtract)
70
+ return;
71
+ for (const key in refExtract.rules) {
72
+ const _path = path + '.' + key;
73
+ _extract.rules[_path] = refExtract.rules[key];
74
+ }
75
+ });
76
+ const getFields = (root, prop) => {
77
+ const path = prop.split('.');
78
+ let poll = [root];
79
+ for (const p of path) {
80
+ if (poll.length === 0)
81
+ break;
82
+ // Walk to next layer of fields by path
83
+ const next = [];
84
+ for (const n of poll) {
85
+ const child = n.children?.[p];
86
+ if (child) {
87
+ next.push(child);
88
+ }
89
+ }
90
+ poll = next;
91
+ }
92
+ return poll;
93
+ };
94
+ Object.entries(_extract?.rules || {}).forEach(([path, rules]) => {
95
+ const fields = getFields({ children: schema.template.fields }, path);
96
+ for (const field of fields) {
97
+ field.rules = rules.map(fn => ({
98
+ __fn: tsCompiler.getFnText(fn),
99
+ __fn_type: '(...args: any[]) => any',
100
+ }));
101
+ }
74
102
  });
75
103
  }
76
104
  static job(compiler, extract, node) {
@@ -57,21 +57,25 @@ class TSBridgeOrganize {
57
57
  }
58
58
  static message(organized, tag, path, node) {
59
59
  var _a, _b;
60
- const rule = path.match(/template▹0▹return▹([\w|\\.]+)▹rule▹0/);
60
+ const rule = path.match(/template▹0▹return▹(.+)▹rule▹0/);
61
61
  if (rule) {
62
62
  const [_, prop] = rule;
63
+ let path = prop.replace(/▹obj▹0▹/g, '.');
64
+ path = path.replace(/▹union▹/g, '.');
65
+ path = path.replace(/▹list▹0/g, '.#');
66
+ path = path.replace(/▹dict▹0/g, '.#');
63
67
  (_a = organized.messages)[tag] ?? (_a[tag] = { rules: {} });
64
- (_b = organized.messages[tag].rules)[prop] ?? (_b[prop] = []);
65
- organized.messages[tag].rules[prop].push(node);
68
+ (_b = organized.messages[tag].rules)[path] ?? (_b[path] = []);
69
+ organized.messages[tag].rules[path].push(node);
66
70
  return;
67
71
  }
68
72
  }
69
73
  static inlineMessage(organized, parentTag, path, node) {
70
- const message = path.match(/messages0▹return▹([\w|\\.]*)▹(.*)/);
74
+ const message = path.match(/message▹(@|\w+)▹1▹return▹(.*)/);
71
75
  if (message) {
72
76
  const [_, inlineName, path] = message;
73
77
  const parent = dependency_1.$Tag.parseOrFail(parentTag);
74
- const msgName = inlineName.length ? `${parent.name}.${inlineName}` : parent.name;
78
+ const msgName = inlineName === '@' ? parent.name : `${parent.name}.${inlineName}`;
75
79
  const msgTag = `${parent.module}::message:${msgName}`;
76
80
  const templatePath = `template▹0▹return▹${path}`;
77
81
  this.message(organized, msgTag, templatePath, node);
@@ -25,9 +25,7 @@ export declare class TypeScriptCompiler {
25
25
  /**
26
26
  * Extract all import nodes
27
27
  */
28
- extractImports(filepath: string, $?: {
29
- ignore?: string[];
30
- }): string[];
28
+ extractImports(filepath: string): string[];
31
29
  query(filepath: string, $: {
32
30
  query: string;
33
31
  expectedKinds: ts.SyntaxKind[];
@@ -43,11 +41,11 @@ export declare class TypeScriptCompiler {
43
41
  getNesoiSymbol(name: string, path: string): ts.Symbol;
44
42
  getPropPath(node: ts.PropertyAssignment): string;
45
43
  findAllNesoiBuilders(node: ts.Node): Partial<Record<BuilderType, Record<string, ts.Node>>>;
46
- findAll(node: ts.Node, predicate: (node: ts.Node) => ts.Node | undefined): ts.Node[];
44
+ findAll(node: ts.Node, predicate: (node: ts.Node) => ts.Node[] | undefined): ts.Node[];
47
45
  private findParent;
48
46
  private findInCallChain;
49
- private findCallsUntilRoot;
50
- private findCallsUntilLast;
47
+ private seekChainUntilLeaf;
48
+ private seekChainUntilRoot;
51
49
  private static logDiagnostics;
52
50
  static allFiles(dirPaths: string[]): string[];
53
51
  /**