nesoi 3.1.8 → 3.2.2

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 (74) hide show
  1. package/lib/compiler/apps/distributed/distributed_compiler.d.ts +31 -0
  2. package/lib/compiler/apps/distributed/distributed_compiler.js +121 -0
  3. package/lib/compiler/apps/distributed/stages/1_mkdir_stage.d.ts +15 -0
  4. package/lib/compiler/apps/distributed/stages/1_mkdir_stage.js +96 -0
  5. package/lib/compiler/apps/distributed/stages/2_build_typescript_stage.d.ts +15 -0
  6. package/lib/compiler/apps/distributed/stages/2_build_typescript_stage.js +174 -0
  7. package/lib/compiler/apps/distributed/stages/3_copy_types_stage.d.ts +15 -0
  8. package/lib/compiler/apps/distributed/stages/3_copy_types_stage.js +82 -0
  9. package/lib/compiler/apps/distributed/stages/4_dump_modules_stage.d.ts +16 -0
  10. package/lib/compiler/apps/distributed/stages/4_dump_modules_stage.js +182 -0
  11. package/lib/compiler/apps/distributed/stages/5_copy_static_stage.d.ts +0 -0
  12. package/lib/compiler/apps/distributed/stages/5_copy_static_stage.js +31 -0
  13. package/lib/compiler/apps/distributed/stages/6_dump_cli_stage.d.ts +0 -0
  14. package/lib/compiler/apps/distributed/stages/6_dump_cli_stage.js +34 -0
  15. package/lib/compiler/apps/distributed/stages/7_dump_package_json_stage.d.ts +0 -0
  16. package/lib/compiler/apps/distributed/stages/7_dump_package_json_stage.js +45 -0
  17. package/lib/compiler/elements/element.js +2 -2
  18. package/lib/compiler/index.d.ts +1 -0
  19. package/lib/compiler/index.js +3 -1
  20. package/lib/elements/blocks/block.builder.d.ts +1 -0
  21. package/lib/elements/blocks/block.builder.js +16 -1
  22. package/lib/elements/blocks/block.schema.d.ts +4 -1
  23. package/lib/elements/blocks/job/internal/resource_job.js +1 -1
  24. package/lib/elements/blocks/job/job.builder.d.ts +1 -0
  25. package/lib/elements/blocks/job/job.builder.js +2 -1
  26. package/lib/elements/blocks/resource/resource.builder.js +1 -1
  27. package/lib/elements/blocks/resource/resource.js +1 -0
  28. package/lib/elements/entities/bucket/adapters/bucket_adapter.d.ts +2 -2
  29. package/lib/elements/entities/bucket/adapters/bucket_adapter.js +2 -2
  30. package/lib/elements/entities/bucket/adapters/memory.nql.d.ts +1 -1
  31. package/lib/elements/entities/bucket/adapters/memory.nql.js +9 -5
  32. package/lib/elements/entities/bucket/bucket.d.ts +13 -2
  33. package/lib/elements/entities/bucket/bucket.js +47 -3
  34. package/lib/elements/entities/bucket/graph/bucket_graph.d.ts +11 -0
  35. package/lib/elements/entities/bucket/graph/bucket_graph.js +49 -2
  36. package/lib/elements/entities/bucket/model/bucket_model.schema.js +14 -11
  37. package/lib/elements/entities/bucket/query/nql_engine.d.ts +2 -2
  38. package/lib/elements/entities/bucket/query/nql_engine.js +8 -4
  39. package/lib/elements/entities/bucket/view/bucket_view.js +65 -12
  40. package/lib/engine/apps/app.config.d.ts +24 -30
  41. package/lib/engine/apps/app.config.js +11 -21
  42. package/lib/engine/apps/app.d.ts +6 -5
  43. package/lib/engine/apps/app.js +1 -1
  44. package/lib/engine/apps/distributed/distributed.app.config.d.ts +44 -0
  45. package/lib/engine/apps/distributed/distributed.app.config.js +36 -0
  46. package/lib/engine/apps/distributed/distributed.app.d.ts +30 -0
  47. package/lib/engine/apps/distributed/distributed.app.js +52 -0
  48. package/lib/engine/apps/distributed/distributed_node.app.d.ts +67 -0
  49. package/lib/engine/apps/distributed/distributed_node.app.js +191 -0
  50. package/lib/engine/apps/distributed/elements/distributed_job.d.ts +7 -0
  51. package/lib/engine/apps/distributed/elements/distributed_job.js +11 -0
  52. package/lib/engine/apps/distributed/inc/inc.client.d.ts +17 -0
  53. package/lib/engine/apps/distributed/inc/inc.client.js +105 -0
  54. package/lib/engine/apps/distributed/inc/inc.server.d.ts +19 -0
  55. package/lib/engine/apps/distributed/inc/inc.server.js +174 -0
  56. package/lib/engine/apps/distributed/inc/sandbox.d.ts +1 -0
  57. package/lib/engine/apps/distributed/inc/sandbox.js +24 -0
  58. package/lib/engine/apps/inline.app.d.ts +2 -2
  59. package/lib/engine/apps/inline.app.js +2 -2
  60. package/lib/engine/apps/monolyth/monolyth.app.d.ts +2 -2
  61. package/lib/engine/apps/monolyth/monolyth.app.js +1 -1
  62. package/lib/engine/module.d.ts +11 -1
  63. package/lib/engine/module.js +17 -4
  64. package/lib/engine/transaction/nodes/bucket.trx_node.d.ts +5 -0
  65. package/lib/engine/transaction/nodes/bucket.trx_node.js +10 -0
  66. package/lib/engine/transaction/nodes/bucket_query.trx_node.d.ts +2 -0
  67. package/lib/engine/transaction/nodes/bucket_query.trx_node.js +15 -4
  68. package/lib/engine/util/log.d.ts +1 -1
  69. package/lib/engine/util/log.js +3 -0
  70. package/package.json +1 -1
  71. package/tools/joaquin/bucket.d.ts +23 -3
  72. package/tools/joaquin/bucket.js +48 -20
  73. package/tools/joaquin/job.js +4 -4
  74. package/tsconfig.build.tsbuildinfo +1 -1
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const inc_server_1 = require("./inc.server");
4
+ const inc_client_1 = require("./inc.client");
5
+ const log_1 = require("../../../util/log");
6
+ log_1.Log.level = 'debug';
7
+ async function main() {
8
+ const server = new inc_server_1.INCServer({
9
+ name: 'mandala-alpha-1',
10
+ port: 2222
11
+ });
12
+ await server.start();
13
+ const client = new inc_client_1.INCClient({
14
+ name: 'mandala-beta-2',
15
+ server: {
16
+ host: 'localhost',
17
+ port: 2222
18
+ }
19
+ });
20
+ await client.start();
21
+ await client.send('Oi do cliente!');
22
+ await server.send(Object.keys(server.clients)[0], 'Oi do servidor!');
23
+ }
24
+ main();
@@ -4,7 +4,7 @@ import { IService } from './service';
4
4
  import { AnyTrxEngine } from '../transaction/trx_engine';
5
5
  import { AnyBuilder, AnyModule, Module } from '../module';
6
6
  import { AnyDaemon, Daemon } from '../daemon';
7
- import { AppConfigFactory } from './app.config';
7
+ import { AppConfigBuilder } from './app.config';
8
8
  /**
9
9
  * @category App
10
10
  */
@@ -45,7 +45,7 @@ export declare class InlineApp<S extends $Space, ModuleNames extends string = Mo
45
45
  protected linkAppValues(modules: Record<string, Module<S, $Module>>): void;
46
46
  modules<M extends ModuleName<S>>(modules: M[]): InlineApp<S, M & ModuleNames>;
47
47
  service<T extends IService>($: T): InlineApp<S, ModuleNames, Services & { [K in T["name"]]: T; }>;
48
- get config(): AppConfigFactory<S, ModuleNames, Services, typeof this>;
48
+ get config(): AppConfigBuilder<S, ModuleNames, Services, typeof this>;
49
49
  static package(app: InlineApp<any, any>, scripts: Record<string, string>, dependencies: Record<string, string>): {
50
50
  name: string;
51
51
  version: string;
@@ -73,7 +73,7 @@ class InlineApp extends app_1.App {
73
73
  for (const m in modules) {
74
74
  const module = modules[m];
75
75
  module.start(this, services);
76
- const trxConfig = this._config.trxEngine?.[m];
76
+ const trxConfig = this._config.modules?.[m]?.trx;
77
77
  const authn = {};
78
78
  for (const a in this._config?.authn || {}) {
79
79
  const prov = this._config.authn?.[a]?.();
@@ -158,7 +158,7 @@ class InlineApp extends app_1.App {
158
158
  return this;
159
159
  }
160
160
  get config() {
161
- return new app_config_1.AppConfigFactory(this);
161
+ return new app_config_1.AppConfigBuilder(this);
162
162
  }
163
163
  //
164
164
  static package(app, scripts, dependencies) {
@@ -4,7 +4,7 @@ import { InlineApp } from './../inline.app';
4
4
  import { AnyTrxEngine } from '../../transaction/trx_engine';
5
5
  import { Space } from '../../space';
6
6
  import { Daemon } from "../../daemon";
7
- import { AppConfigFactory } from '../app.config';
7
+ import { AppConfigBuilder } from '../app.config';
8
8
  /**
9
9
  * @category App
10
10
  * @subcategory Monolyth
@@ -20,7 +20,7 @@ export declare class MonolythApp<S extends $Space, ModuleNames extends string =
20
20
  remake(): Promise<void>;
21
21
  modules<M extends ModuleName<S>>(modules: M[]): MonolythApp<S, M & ModuleNames>;
22
22
  service<T extends IService>($: T): MonolythApp<S, ModuleNames, Services & { [K in T["name"]]: T; }>;
23
- get config(): AppConfigFactory<S, ModuleNames, Services, typeof this>;
23
+ get config(): AppConfigBuilder<S, ModuleNames, Services, typeof this>;
24
24
  }
25
25
  /**
26
26
  * @category App
@@ -101,7 +101,7 @@ class MonolythApp extends inline_app_1.InlineApp {
101
101
  return this;
102
102
  }
103
103
  get config() {
104
- return new app_config_1.AppConfigFactory(this);
104
+ return new app_config_1.AppConfigBuilder(this);
105
105
  }
106
106
  }
107
107
  exports.MonolythApp = MonolythApp;
@@ -4,7 +4,7 @@ import { AnyMessageBuilder } from "../elements/entities/message/message.builder"
4
4
  import { AnyBucketBuilder } from "../elements/entities/bucket/bucket.builder";
5
5
  import { AnyResourceBuilder } from "../elements/blocks/resource/resource.builder";
6
6
  import { AnyMachineBuilder } from "../elements/blocks/machine/machine.builder";
7
- import { Job } from "../elements/blocks/job/job";
7
+ import { AnyJob, Job } from "../elements/blocks/job/job";
8
8
  import { AnyJobBuilder } from "../elements/blocks/job/job.builder";
9
9
  import { MessageParser } from "../elements/entities/message/message_parser";
10
10
  import { $Message } from "../elements/entities/message/message.schema";
@@ -147,6 +147,16 @@ export declare class Module<S extends $Space, $ extends $Module> {
147
147
  messages?: $Dependency[];
148
148
  machines?: $Dependency[];
149
149
  }): this;
150
+ /**
151
+ * Include references for external elements on the module.
152
+ *
153
+ * @param daemon A `Daemon` instance
154
+ * @param dependencies: A dictionary of dependencies by element type
155
+ * @returns The `Module`, for call-chaining
156
+ */
157
+ injectRunners(elements: {
158
+ jobs?: Record<string, AnyJob>;
159
+ }): this;
150
160
  /**
151
161
  * Recursively find all files inside the module dir.
152
162
  *
@@ -224,6 +224,19 @@ class Module {
224
224
  });
225
225
  return this;
226
226
  }
227
+ /**
228
+ * Include references for external elements on the module.
229
+ *
230
+ * @param daemon A `Daemon` instance
231
+ * @param dependencies: A dictionary of dependencies by element type
232
+ * @returns The `Module`, for call-chaining
233
+ */
234
+ injectRunners(elements) {
235
+ Object.entries(elements.jobs || {}).forEach(([refName, job]) => {
236
+ this.jobs[refName] = job;
237
+ });
238
+ return this;
239
+ }
227
240
  // Treeshaking
228
241
  /**
229
242
  * Recursively find all files inside the module dir.
@@ -348,7 +361,7 @@ class Module {
348
361
  const info = app_1.App.getInfo(app);
349
362
  const config = info.config;
350
363
  Object.entries(this.schema.buckets).forEach(([name, schema]) => {
351
- const bucketConfig = config.buckets?.[this.name]?.[name];
364
+ const bucketConfig = config.modules?.[this.name]?.buckets?.[name];
352
365
  this.buckets[name] = new bucket_1.Bucket(this, schema, bucketConfig, services);
353
366
  });
354
367
  Object.entries(this.schema.messages).forEach(([name, schema]) => {
@@ -364,7 +377,7 @@ class Module {
364
377
  this.machines[name] = new machine_1.Machine(this, schema);
365
378
  });
366
379
  Object.entries(this.schema.controllers).forEach(([name, schema]) => {
367
- const controllerConfig = config.controllers?.[this.name]?.[name];
380
+ const controllerConfig = config.modules?.[this.name]?.controllers?.[name];
368
381
  this.controllers[name] = new controller_1.Controller(this, schema, controllerConfig, services);
369
382
  });
370
383
  Object.entries(this.schema.queues).forEach(([name, schema]) => {
@@ -374,8 +387,8 @@ class Module {
374
387
  this.topics[name] = new topic_1.Topic(this, schema);
375
388
  });
376
389
  this.nql = new nql_engine_1.NQL_Engine(this);
377
- if (config.trash?.[this.name]) {
378
- this.trash = new bucket_1.Bucket(this, trash_1.$TrashBucket, config.trash[this.name], services);
390
+ if (config.modules?.[this.name]?.trash) {
391
+ this.trash = new bucket_1.Bucket(this, trash_1.$TrashBucket, config.modules?.[this.name]?.trash, services);
379
392
  }
380
393
  }
381
394
  // Destroy
@@ -64,6 +64,11 @@ export declare class BucketTrxNode<M extends $Module, $ extends $Bucket> {
64
64
  * or `undefined` if the graph link doesn't resolve.
65
65
  */
66
66
  readLink<LinkName extends keyof $['graph']['links'], Link extends $['graph']['links'][LinkName], Obj extends Link['#bucket']['#data']>(id: $['#data']['id'], link: LinkName): Promise<Link['#many'] extends true ? Obj[] : (Obj | undefined)>;
67
+ /**
68
+ * Returns one or more objects referenced by the graph link,
69
+ * or `undefined` if the graph link doesn't resolve.
70
+ */
71
+ readManyLinks<LinkName extends keyof $['graph']['links'], Link extends $['graph']['links'][LinkName], Obj extends Link['#bucket']['#data']>(ids: $['#data']['id'][], link: LinkName): Promise<Link['#many'] extends true ? Obj[] : (Obj | undefined)>;
67
72
  /**
68
73
  * Returns one or more objects referenced by the graph link built with a view,
69
74
  * or `undefined` if the graph link doesn't resolve.
@@ -133,6 +133,16 @@ class BucketTrxNode {
133
133
  no_tenancy: !this.enableTenancy
134
134
  }));
135
135
  }
136
+ /**
137
+ * Returns one or more objects referenced by the graph link,
138
+ * or `undefined` if the graph link doesn't resolve.
139
+ */
140
+ async readManyLinks(ids, link) {
141
+ return this.wrap('readLinks', { ids, link }, trx => this.bucket.readManyLinks(trx, ids, link, {
142
+ silent: true,
143
+ no_tenancy: !this.enableTenancy
144
+ }));
145
+ }
136
146
  /**
137
147
  * Returns one or more objects referenced by the graph link built with a view,
138
148
  * or `undefined` if the graph link doesn't resolve.
@@ -14,8 +14,10 @@ export declare class BucketQueryTrxNode<M extends $Module, B extends $Bucket, V
14
14
  private query;
15
15
  private enableTenancy;
16
16
  private view?;
17
+ private _params?;
17
18
  constructor(trx: TrxNode<any, M, any>, bucket: Bucket<M, B>, query: NQL_AnyQuery, enableTenancy: boolean, view?: V | undefined);
18
19
  merge($: NQL_Query<M, B>): void;
20
+ params(value: Record<string, any>): this;
19
21
  first(): Promise<Obj | undefined>;
20
22
  firstOrFail(): Promise<Obj>;
21
23
  all(): Promise<Obj[]>;
@@ -14,6 +14,7 @@ class BucketQueryTrxNode {
14
14
  this.query = query;
15
15
  this.enableTenancy = enableTenancy;
16
16
  this.view = view;
17
+ this._params = [];
17
18
  }
18
19
  merge($) {
19
20
  const and = $['#and'];
@@ -24,6 +25,10 @@ class BucketQueryTrxNode {
24
25
  this.query['#and*'] = and; // TODO: make this a little better
25
26
  this.query['#or*'] = or; // TODO: make this a little better
26
27
  }
28
+ params(value) {
29
+ this._params = [value];
30
+ return this;
31
+ }
27
32
  async first() {
28
33
  await trx_node_1.TrxNode.open(this.trx, 'queryFirst', { schema: this.query, view: this.view });
29
34
  let results;
@@ -31,7 +36,8 @@ class BucketQueryTrxNode {
31
36
  results = await this.bucket.query(this.trx, this.query, {
32
37
  perPage: 1
33
38
  }, this.view, {
34
- no_tenancy: !this.enableTenancy
39
+ no_tenancy: !this.enableTenancy,
40
+ params: this._params
35
41
  });
36
42
  }
37
43
  catch (e) {
@@ -47,7 +53,8 @@ class BucketQueryTrxNode {
47
53
  let results;
48
54
  try {
49
55
  results = await this.bucket.query(this.trx, this.query, undefined, this.view, {
50
- no_tenancy: !this.enableTenancy
56
+ no_tenancy: !this.enableTenancy,
57
+ params: this._params
51
58
  });
52
59
  }
53
60
  catch (e) {
@@ -64,7 +71,9 @@ class BucketQueryTrxNode {
64
71
  await trx_node_1.TrxNode.open(this.trx, 'queryAll', { schema: this.query, view: this.view });
65
72
  let results;
66
73
  try {
67
- results = await this.bucket.query(this.trx, this.query, undefined, this.view);
74
+ results = await this.bucket.query(this.trx, this.query, undefined, this.view, {
75
+ params: this._params
76
+ });
68
77
  }
69
78
  catch (e) {
70
79
  throw await trx_node_1.TrxNode.error(this.trx, e); // Bucket unexpected error
@@ -81,7 +90,9 @@ class BucketQueryTrxNode {
81
90
  await trx_node_1.TrxNode.open(this.trx, 'queryPage', { schema: this.query, pagination, view: this.view });
82
91
  let result;
83
92
  try {
84
- result = await this.bucket.query(this.trx, this.query, pagination, this.view);
93
+ result = await this.bucket.query(this.trx, this.query, pagination, this.view, {
94
+ params: this._params
95
+ });
85
96
  }
86
97
  catch (e) {
87
98
  throw await trx_node_1.TrxNode.error(this.trx, e); // Bucket unexpected error
@@ -1,7 +1,7 @@
1
1
  import { $BlockType } from "../../elements/blocks/block.schema";
2
2
  declare const LogLevel: readonly ["off", "error", "warn", "info", "debug", "trace"];
3
3
  export type LogLevel = typeof LogLevel[number];
4
- export type LogScope = $BlockType | 'compiler' | 'trx' | 'daemon' | 'app' | 'module' | 'layer' | 'message' | 'bucket' | 'job' | 'resource' | 'controller' | 'queue' | 'topic' | 'constants' | 'externals';
4
+ export type LogScope = $BlockType | 'compiler' | 'trx' | 'daemon' | 'app' | 'module' | 'layer' | 'message' | 'bucket' | 'job' | 'resource' | 'controller' | 'queue' | 'topic' | 'constants' | 'externals' | 'nql' | 'inc.server' | 'inc.client';
5
5
  export declare function scopeTag(scope: LogScope, scope_id: string): string;
6
6
  export declare function anyScopeTag(scopeWithId: string): string;
7
7
  export declare class Log {
@@ -25,6 +25,9 @@ function scopeTag(scope, scope_id) {
25
25
  machine: 'lightblue',
26
26
  queue: 'lightblue',
27
27
  topic: 'lightblue',
28
+ nql: 'lightpurple',
29
+ 'inc.server': 'lightgreen',
30
+ 'inc.client': 'lightcyan',
28
31
  }[scope] || 'lightgray';
29
32
  return (0, string_1.colored)(`${scope}:${scope_id}`, color);
30
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nesoi",
3
- "version": "3.1.8",
3
+ "version": "3.2.2",
4
4
  "description": "Declarative framework for data-driven applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,9 +1,29 @@
1
- import { AnyBucketBuilder } from "../../src/elements/entities/bucket/bucket.builder";
1
+ import { AnyBucketBuilder, BucketBuilder } from "../../src/elements/entities/bucket/bucket.builder";
2
2
  import { NesoiError } from "../../src/engine/data/error";
3
3
  import { AnyBuilder } from "../../src/engine/module";
4
- export declare function expectBucket(def: (builder: AnyBucketBuilder) => any, inject?: AnyBuilder[]): {
4
+ export declare function givenBucket<Def>(name: string, def: (builder: AnyBucketBuilder) => any): {
5
+ builder: BucketBuilder<import("../../src/elements").$Space, import("../../src/elements").$Module, Omit<import("../../src/elements").$Bucket, "views"> & {
6
+ views: {};
7
+ }>;
8
+ data: Record<string, any>;
9
+ withData(mock: Record<string, any>): {
10
+ builder: BucketBuilder<import("../../src/elements").$Space, import("../../src/elements").$Module, Omit<import("../../src/elements").$Bucket, "views"> & {
11
+ views: {};
12
+ }>;
13
+ data: Record<string, any>;
14
+ withData(mock: Record<string, any>): /*elided*/ any;
15
+ };
16
+ };
17
+ export declare function expectBucket(def: (builder: AnyBucketBuilder) => any, inject?: (AnyBuilder | {
18
+ builder: AnyBucketBuilder;
19
+ data: Record<string, any>;
20
+ })[]): {
5
21
  toBuildOne(raw: Record<string, any>, view: string): {
6
- as(parsed: Record<string, any>): Promise<void>;
22
+ as(parsed: Record<string, any> | Record<string, any>[]): Promise<void>;
23
+ butFail(error: (...args: any[]) => NesoiError.BaseError): Promise<void>;
24
+ };
25
+ toBuildMany(raws: Record<string, any>[], view: string): {
26
+ as(parsed: Record<string, any> | Record<string, any>[]): Promise<void>;
7
27
  butFail(error: (...args: any[]) => NesoiError.BaseError): Promise<void>;
8
28
  };
9
29
  };
@@ -1,43 +1,71 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.givenBucket = givenBucket;
3
4
  exports.expectBucket = expectBucket;
4
5
  const bucket_builder_1 = require("../../src/elements/entities/bucket/bucket.builder");
5
6
  const inline_app_1 = require("../../src/engine/apps/inline.app");
7
+ const elements_1 = require("../../src/elements");
8
+ function givenBucket(name, def) {
9
+ const builder = new bucket_builder_1.BucketBuilder('test', name);
10
+ const data = {};
11
+ def(builder);
12
+ return {
13
+ builder,
14
+ data,
15
+ withData(mock) {
16
+ Object.assign(data, mock);
17
+ return this;
18
+ }
19
+ };
20
+ }
6
21
  function expectBucket(def, inject = []) {
7
22
  const builder = new bucket_builder_1.BucketBuilder('test', 'test');
8
23
  def(builder);
9
- const app = new inline_app_1.InlineApp('test', [...inject, builder]);
24
+ const injectBuilders = inject.map(i => 'builder' in i ? i.builder : i);
25
+ const app = new inline_app_1.InlineApp('test', [...injectBuilders, builder]);
26
+ // Configure buckets
27
+ const bucketConfig = {};
28
+ for (const i of inject) {
29
+ if (!('data' in i))
30
+ continue;
31
+ bucketConfig[i.builder.name] = {
32
+ adapter: (schema) => new elements_1.MemoryBucketAdapter(schema, i.data)
33
+ };
34
+ }
35
+ app.config.module('test', {
36
+ buckets: bucketConfig
37
+ });
10
38
  let promise;
11
39
  const step1 = {
12
40
  toBuildOne(raw, view) {
13
- promise = Promise.all([raw].map(raw => app.daemon().then(daemon => daemon.trx('test').run(trx => trx.bucket('test').buildOne(raw, view)))));
41
+ promise = () => app.daemon().then(daemon => daemon.trx('test').run(trx => trx.bucket('test').buildOne(raw, view)));
42
+ return step2;
43
+ },
44
+ toBuildMany(raws, view) {
45
+ promise = () => app.daemon().then(daemon => daemon.trx('test').run(trx => trx.bucket('test').buildMany(raws, view)));
14
46
  return step2;
15
47
  }
16
48
  };
17
49
  const step2 = {
18
50
  async as(parsed) {
19
- const status = await promise;
20
- status.forEach(st => {
21
- if (st.state === 'error') {
22
- console.log(st.summary());
23
- console.error(st.error?.data);
24
- console.error(st.error?.data?.unionErrors);
25
- console.error(st.error?.stack);
26
- }
27
- expect(st.state).toEqual('ok');
28
- expect(st.output)
29
- .toEqual(parsed);
30
- });
51
+ const status = await promise();
52
+ if (status.state === 'error') {
53
+ console.log(status.summary());
54
+ console.error(status.error?.data);
55
+ console.error(status.error?.data?.unionErrors);
56
+ console.error(status.error?.stack);
57
+ }
58
+ expect(status.state).toEqual('ok');
59
+ expect(status.output)
60
+ .toEqual(parsed);
31
61
  },
32
62
  async butFail(error) {
33
63
  const errorObj = error({});
34
64
  try {
35
- const status = await promise;
36
- status.forEach(st => {
37
- expect(st.state).toEqual('error');
38
- expect(st.error?.name)
39
- .toEqual(errorObj.name);
40
- });
65
+ const status = await promise();
66
+ expect(status.state).toEqual('error');
67
+ expect(status.error?.name)
68
+ .toEqual(errorObj.name);
41
69
  }
42
70
  catch (e) {
43
71
  expect(e.toString())
@@ -13,18 +13,18 @@ function expectJob(def) {
13
13
  const step1 = {
14
14
  onRaw(_raw) {
15
15
  raw = _raw;
16
- promise = app.daemon().then(daemon => daemon.trx('test').run(trx => trx.job('test').run(_raw)));
16
+ promise = () => app.daemon().then(daemon => daemon.trx('test').run(trx => trx.job('test').run(_raw)));
17
17
  return step2;
18
18
  },
19
19
  onMessage(_msg) {
20
20
  msg = _msg;
21
- promise = app.daemon().then(daemon => daemon.trx('test').run(trx => trx.job('test').forward(_msg)));
21
+ promise = () => app.daemon().then(daemon => daemon.trx('test').run(trx => trx.job('test').forward(_msg)));
22
22
  return step2;
23
23
  }
24
24
  };
25
25
  const step2 = {
26
26
  async toResolve(value) {
27
- const status = await promise;
27
+ const status = await promise();
28
28
  expect(status.state).toEqual('ok');
29
29
  expect(status.output)
30
30
  .toEqual(value({ raw, msg }));
@@ -32,7 +32,7 @@ function expectJob(def) {
32
32
  async toReject(error) {
33
33
  const errorObj = error({ raw, msg })({});
34
34
  try {
35
- const status = await promise;
35
+ const status = await promise();
36
36
  expect(status.state).toEqual('error');
37
37
  expect(status.error?.name)
38
38
  .toEqual(errorObj.name);