@fnet/cli 0.119.4 → 0.120.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fnet/cli",
3
- "version": "0.119.4",
3
+ "version": "0.120.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "template"
@@ -81,7 +81,8 @@ export default function Block(context){
81
81
  {% endif %}
82
82
  }
83
83
  catch(error){
84
- reject(error);
84
+ onError? onError(error) : reject(error);
85
+ {# reject(error); #}
85
86
  }
86
87
  });
87
88
  }
@@ -57,7 +57,7 @@ export default function Block(context) {
57
57
  if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
58
58
  return resolve(nextBlock);
59
59
 
60
- current=new nextBlock.toType({ parent:_this, engine, flow, caller:c});
60
+ current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, onError, error });
61
61
  currentArgs=nextBlock.withArgs;
62
62
 
63
63
  } while(true);
@@ -15,7 +15,7 @@ export default function Block(context){
15
15
 
16
16
  const raise = {{context.transform.raise | safe}};
17
17
 
18
- reject(new Error(raise?.message||raise||"Unknown error"));
18
+ onError? onError(new Error(raise?.message||raise||"Unknown error")) : reject(new Error(raise?.message||raise||"Unknown error"));
19
19
  });
20
20
  }
21
21
 
@@ -21,7 +21,7 @@ export default function Block(context){
21
21
  const { default: {{context.next.codeKey}} } = await import("./{{context.next.codeKey}}");
22
22
  {% endif %}
23
23
 
24
- let current=new {{context.next.codeKey}}({ parent:_this, engine, flow, caller:c });
24
+ let current=new {{context.next.codeKey}}({ parent:_this, engine, flow, caller:c ,onError, error });
25
25
  let currentArgs=args;
26
26
 
27
27
  do {
@@ -39,7 +39,7 @@ export default function Block(context){
39
39
  if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
40
40
  return resolve(nextBlock);
41
41
 
42
- current=new nextBlock.toType({ parent:_this, engine, flow, caller:c});
42
+ current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, onError, error });
43
43
  currentArgs=nextBlock.withArgs;
44
44
 
45
45
  } while(true);
@@ -1,8 +1,7 @@
1
+
1
2
  {% include "src/default/macros/block-header.js.njk" %}
2
3
 
3
- {% if not hasDefaultCondition %}
4
- {% include "src/default/macros/block-next-header.js.njk" %}
5
- {% endif %}
4
+ {# {% include "src/default/macros/block-next-header.js.njk" %} #}
6
5
 
7
6
  {% include "src/default/macros/block-modules-header.js.njk" %}
8
7
 
@@ -16,56 +15,53 @@
16
15
  export default function Block(context) {
17
16
 
18
17
  {% include "src/default/macros/block-body-header.js.njk" %}
19
-
18
+
20
19
  this.run= function (){
21
20
 
22
21
  const args=Array.from(arguments);
23
22
 
24
23
  return new Promise(async (resolve,reject)=>{
25
24
 
26
- {% include "src/default/macros/block-run-header.js.njk" %}
25
+ {% include "src/default/macros/block-run-header.js.njk" %}
27
26
 
28
- {% include "src/default/macros/page.js.njk" %}
27
+ {% include "src/default/macros/page.js.njk" %}
29
28
 
30
- {% include "src/default/macros/block-modules.js.njk" %}
31
-
32
- {% for child in childs %}
33
- {% if loop.first %}
34
- if ({{child.context.transform.condition | safe}})
35
- {% else %}
36
- {%if child.context.transform.condition %}
37
- else if ({{child.context.transform.condition | safe}})
38
- {% else %}
39
- else
40
- {% endif %}
41
- {% endif %}
42
- {
43
- {% if child.definition.dynamic %}
44
- // CHILD: {{child.indexKey}}
45
- const { default: {{child.codeKey}} } = await import("./{{child.codeKey}}");
29
+ {% include "src/default/macros/block-modules.js.njk" %}
30
+
31
+ try{
32
+
33
+ const onError=error=>{
34
+ {% if context.except.definition.dynamic %}
35
+ const { default: {{context.except.codeKey}} } = await import("./{{context.except.codeKey}}");
46
36
  {% endif %}
47
37
 
48
- const current=new {{child.codeKey}}({ parent:_this, engine, flow, caller:c });
38
+ const current=new {{context.except.codeKey}}({ parent:_this, engine, flow, caller:c , error });
49
39
 
50
40
  {% if workflow.parent.context.atom.doc.features.print_runners %}
51
41
  console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
52
42
  {% endif %}
53
43
 
54
- return resolve(await current.run.apply(current,args));
55
- }
56
- {% endfor%}
57
-
58
- {% if not hasDefaultCondition %}
59
- {% if context.transform.return %}
60
- resolve({type:'return',value: {{context.transform.return | safe}}});
61
- {% elseif context.next %}
62
- {% include "src/default/macros/block-next.js.njk" %}
63
- {% else %}
64
- resolve();
65
- {% endif %}
66
- {% endif %}
44
+ {# return resolve(await current.run.apply(current,args)); #}
45
+ current.run.apply(current,args).then(resolve);
46
+ };
47
+
48
+ {% if context.try.definition.dynamic %}
49
+ const { default: {{context.try.codeKey}} } = await import("./{{context.try.codeKey}}");
50
+ {% endif %}
51
+
52
+ const current=new {{context.try.codeKey}}({ parent:_this, engine, flow, caller:c ,onError, error });
53
+
54
+ {% if workflow.parent.context.atom.doc.features.print_runners %}
55
+ console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
56
+ {% endif %}
57
+
58
+ return resolve(await current.run.apply(current,args));
59
+ }
60
+ catch({{context.except.context.transform.as | safe}}){
61
+ throw new Error('Error must not reach here!');
62
+ }
67
63
  });
68
- }
64
+ }
69
65
 
70
66
  Object.freeze(this);
71
67
  }
@@ -29,7 +29,21 @@ export default function Block(context) {
29
29
  {% include "src/default/macros/block-modules.js.njk" %}
30
30
 
31
31
  try{
32
-
32
+
33
+ const onError=error=>{
34
+ {% if context.except.definition.dynamic %}
35
+ const { default: {{context.except.codeKey}} } = await import("./{{context.except.codeKey}}");
36
+ {% endif %}
37
+
38
+ const current=new {{context.except.codeKey}}({ parent:_this, engine, flow, caller:c, onError });
39
+
40
+ {% if workflow.parent.context.atom.doc.features.print_runners %}
41
+ console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
42
+ {% endif %}
43
+
44
+ return resolve(await current.run.apply(current,args));
45
+ };
46
+
33
47
  {% if context.try.definition.dynamic %}
34
48
  const { default: {{context.try.codeKey}} } = await import("./{{context.try.codeKey}}");
35
49
  {% endif %}
@@ -2,6 +2,6 @@ if (this.constructor !== Block) throw Error(Message.USE_CONSTRUCTOR);
2
2
 
3
3
  this.context=context;
4
4
 
5
- const { engine, flow, caller }=context || {};
5
+ const { engine, flow, caller, onError, error }=context || {};
6
6
 
7
7
  const _this=this;
@@ -12,6 +12,7 @@ return resolve ({
12
12
  fromType: _this.constructor,
13
13
  fromClosure: c,
14
14
  toType:{{context.next.codeKey}},
15
+ onError,
15
16
  {% if context.transform.nextArgs %}
16
17
  withArgs: {{context.transform.nextArgs | safe}},
17
18
  {% endif %}
@@ -81,7 +81,8 @@ export default function Block(context){
81
81
  {% endif %}
82
82
  }
83
83
  catch(error){
84
- reject(error);
84
+ onError? onError(error) : reject(error);
85
+ {# reject(error); #}
85
86
  }
86
87
  });
87
88
  }
@@ -57,7 +57,7 @@ export default function Block(context) {
57
57
  if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
58
58
  return resolve(nextBlock);
59
59
 
60
- current=new nextBlock.toType({ parent:_this, engine, flow, caller:c});
60
+ current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, onError, error });
61
61
  currentArgs=nextBlock.withArgs;
62
62
 
63
63
  } while(true);
@@ -15,7 +15,7 @@ export default function Block(context){
15
15
 
16
16
  const raise = {{context.transform.raise | safe}};
17
17
 
18
- reject(new Error(raise?.message||raise||"Unknown error"));
18
+ onError? onError(new Error(raise?.message||raise||"Unknown error")) : reject(new Error(raise?.message||raise||"Unknown error"));
19
19
  });
20
20
  }
21
21
 
@@ -21,7 +21,7 @@ export default function Block(context){
21
21
  const { default: {{context.next.codeKey}} } = await import("./{{context.next.codeKey}}");
22
22
  {% endif %}
23
23
 
24
- let current=new {{context.next.codeKey}}({ parent:_this, engine, flow, caller:c });
24
+ let current=new {{context.next.codeKey}}({ parent:_this, engine, flow, caller:c ,onError, error });
25
25
  let currentArgs=args;
26
26
 
27
27
  do {
@@ -39,7 +39,7 @@ export default function Block(context){
39
39
  if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
40
40
  return resolve(nextBlock);
41
41
 
42
- current=new nextBlock.toType({ parent:_this, engine, flow, caller:c});
42
+ current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, onError, error });
43
43
  currentArgs=nextBlock.withArgs;
44
44
 
45
45
  } while(true);
@@ -45,7 +45,7 @@ export default function Block(context) {
45
45
  const { default: {{child.codeKey}} } = await import("./{{child.codeKey}}");
46
46
  {% endif %}
47
47
 
48
- const current=new {{child.codeKey}}({ parent:_this, engine, flow, caller:c });
48
+ const current=new {{child.codeKey}}({ parent:_this, engine, flow, caller:c, onError });
49
49
 
50
50
  {% if workflow.parent.context.atom.doc.features.print_runners %}
51
51
  console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
@@ -30,11 +30,26 @@ export default function Block(context) {
30
30
 
31
31
  try{
32
32
 
33
+ const onError=error=>{
34
+ {% if context.except.definition.dynamic %}
35
+ const { default: {{context.except.codeKey}} } = await import("./{{context.except.codeKey}}");
36
+ {% endif %}
37
+
38
+ const current=new {{context.except.codeKey}}({ parent:_this, engine, flow, caller:c , error });
39
+
40
+ {% if workflow.parent.context.atom.doc.features.print_runners %}
41
+ console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
42
+ {% endif %}
43
+
44
+ {# return resolve(await current.run.apply(current,args)); #}
45
+ current.run.apply(current,args).then(resolve);
46
+ };
47
+
33
48
  {% if context.try.definition.dynamic %}
34
49
  const { default: {{context.try.codeKey}} } = await import("./{{context.try.codeKey}}");
35
50
  {% endif %}
36
51
 
37
- const current=new {{context.try.codeKey}}({ parent:_this, engine, flow, caller:c });
52
+ const current=new {{context.try.codeKey}}({ parent:_this, engine, flow, caller:c ,onError, error });
38
53
 
39
54
  {% if workflow.parent.context.atom.doc.features.print_runners %}
40
55
  console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
@@ -43,18 +58,7 @@ export default function Block(context) {
43
58
  return resolve(await current.run.apply(current,args));
44
59
  }
45
60
  catch({{context.except.context.transform.as | safe}}){
46
-
47
- {% if context.except.definition.dynamic %}
48
- const { default: {{context.except.codeKey}} } = await import("./{{context.except.codeKey}}");
49
- {% endif %}
50
-
51
- const current=new {{context.except.codeKey}}({ parent:_this, engine, flow, caller:c });
52
-
53
- {% if workflow.parent.context.atom.doc.features.print_runners %}
54
- console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
55
- {% endif %}
56
-
57
- return resolve(await current.run.apply(current,args));
61
+ throw new Error('Error must not reach here!');
58
62
  }
59
63
  });
60
64
  }
@@ -2,6 +2,6 @@ if (this.constructor !== Block) throw Error(Message.USE_CONSTRUCTOR);
2
2
 
3
3
  this.context=context;
4
4
 
5
- const { engine, flow, caller }=context || {};
5
+ const { engine, flow, caller, onError, error }=context || {};
6
6
 
7
7
  const _this=this;
@@ -12,6 +12,7 @@ return resolve ({
12
12
  fromType: _this.constructor,
13
13
  fromClosure: c,
14
14
  toType:{{context.next.codeKey}},
15
+ onError,
15
16
  {% if context.transform.nextArgs %}
16
17
  withArgs: {{context.transform.nextArgs | safe}},
17
18
  {% endif %}