@omnia/velcron 8.0.136-dev → 8.0.138-dev

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/actions/Alert.js CHANGED
@@ -4,9 +4,7 @@ exports.alerter = void 0;
4
4
  exports.alerter = {
5
5
  name: "@alert",
6
6
  action: (action, value) => {
7
- //value = VelcronData.dataBind(action, value)
8
- //alert(value + nisse ? nisse : 'nullsiu');
9
7
  alert(`${value}`);
10
- return Promise.resolve(null);
8
+ action.promise.resolve(null);
11
9
  }
12
10
  };
package/actions/Array.js CHANGED
@@ -15,7 +15,7 @@ exports.arrayAppend = {
15
15
  else {
16
16
  existingArray.push(arrayToAppend);
17
17
  }
18
- return Promise.resolve(new ActionResults_1.SkipSetValue());
18
+ action.promise.resolve(new ActionResults_1.SkipSetValue());
19
19
  }
20
20
  };
21
21
  exports.arrayTake = {
@@ -24,6 +24,6 @@ exports.arrayTake = {
24
24
  takeTemplate = VelcronData_1.VelcronData.dataBind(action, takeTemplate);
25
25
  const take = parseInt(takeTemplate);
26
26
  arr = arr.slice(0, take);
27
- return Promise.resolve(arr);
27
+ action.promise.resolve(arr);
28
28
  }
29
29
  };
package/actions/Clone.js CHANGED
@@ -5,7 +5,6 @@ const stores_1 = require("../stores");
5
5
  exports.objClone = {
6
6
  name: "@clone",
7
7
  action: (action, objToClone) => {
8
- const path = action.path.replace("=", "").trim();
9
- return Promise.resolve(stores_1.ReactivitySystem.makeReactive(JSON.parse(JSON.stringify(objToClone))));
8
+ action.promise.resolve(stores_1.ReactivitySystem.makeReactive(JSON.parse(JSON.stringify(objToClone))));
10
9
  }
11
10
  };
package/actions/Date.js CHANGED
@@ -6,7 +6,7 @@ const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
6
6
  exports.dateFormat = {
7
7
  name: "@date.format",
8
8
  action: (action, value) => {
9
- return Promise.resolve((0, dayjs_1.default)().format(value));
9
+ return action.promise.resolve((0, dayjs_1.default)().format(value));
10
10
  }
11
11
  };
12
12
  exports.diff = {
@@ -16,7 +16,7 @@ exports.diff = {
16
16
  const futureDateTime = (0, dayjs_1.default)(date);
17
17
  const duration = past ? dayjs_1.default.duration(now.diff(futureDateTime)) : dayjs_1.default.duration(futureDateTime.diff(now));
18
18
  const expired = past ? false : duration.asMilliseconds() <= 0;
19
- return Promise.resolve({
19
+ action.promise.resolve({
20
20
  years: duration.years(),
21
21
  months: duration.months(),
22
22
  days: duration.days(),
@@ -11,9 +11,9 @@ exports.debounce = {
11
11
  value = VelcronData_1.VelcronData.dataBind(action, value);
12
12
  const bounceDelayTime = parseInt(value);
13
13
  if (!debounces[action.id]) {
14
- debounces[action.id] = debounceInternal(() => { Promise.resolve(); }, bounceDelayTime);
14
+ debounces[action.id] = debounceInternal(() => { action.promise.resolve(null); }, bounceDelayTime);
15
15
  }
16
- return debounces[action.id]();
16
+ //return debounces[action.id]();
17
17
  }
18
18
  };
19
19
  function debounceInternal(inner, ms = 0) {
package/actions/Delay.js CHANGED
@@ -7,8 +7,9 @@ exports.delay = {
7
7
  action: (action, value) => {
8
8
  value = VelcronData_1.VelcronData.dataBind(action, value);
9
9
  const delayTime = parseInt(value);
10
- return new Promise(function (resolve) {
11
- setTimeout(resolve.bind(null, null), delayTime);
12
- });
10
+ setTimeout(action.promise.resolve.bind(null, null), delayTime);
11
+ // return new Promise(function (resolve) {
12
+ // setTimeout(resolve.bind(null, null), delayTime);
13
+ // });
13
14
  }
14
15
  };
package/actions/Emit.js CHANGED
@@ -20,6 +20,6 @@ exports.emit = {
20
20
  else {
21
21
  parser_1.VelcronLogger.logActionError("There is no incoming event handlers registered");
22
22
  }
23
- return Promise.resolve(null);
23
+ return action.promise.resolve(null);
24
24
  }
25
25
  };
package/actions/Http.js CHANGED
@@ -5,28 +5,26 @@ const parser_1 = require("../parser");
5
5
  exports.httpGet = {
6
6
  name: "@http.get",
7
7
  action: (action, incomingUrl) => {
8
- return new Promise(function (resolve) {
9
- incomingUrl = parser_1.VelcronData.dataBind(action, incomingUrl);
10
- let requestInitLocal = { "method": "GET" };
11
- const hookResult = parser_1.VelcronActions.tryTriggerBeforeActionHook("http.get", { url: incomingUrl, requestInit: requestInitLocal });
12
- incomingUrl = hookResult?.url ?? incomingUrl;
13
- requestInitLocal = hookResult?.requestInit ?? requestInitLocal;
14
- fetch(incomingUrl, requestInitLocal)
15
- .then(async (response) => {
16
- const res = parser_1.VelcronActions.tryTriggerAfterActionHook("http.get", {
17
- json: await response.json(),
18
- response: response
19
- });
20
- return res.json;
21
- })
22
- .then((json) => {
23
- resolve(json);
24
- })
25
- .catch((error) => {
26
- //How do we handle errors?
27
- console.error("Velcron @http.get error occurred:", error);
28
- throw error;
8
+ incomingUrl = parser_1.VelcronData.dataBind(action, incomingUrl);
9
+ let requestInitLocal = { "method": "GET" };
10
+ const hookResult = parser_1.VelcronActions.tryTriggerBeforeActionHook("http.get", { url: incomingUrl, requestInit: requestInitLocal });
11
+ incomingUrl = hookResult?.url ?? incomingUrl;
12
+ requestInitLocal = hookResult?.requestInit ?? requestInitLocal;
13
+ fetch(incomingUrl, requestInitLocal)
14
+ .then(async (response) => {
15
+ const res = parser_1.VelcronActions.tryTriggerAfterActionHook("http.get", {
16
+ json: await response.json(),
17
+ response: response
29
18
  });
19
+ return res.json;
20
+ })
21
+ .then((json) => {
22
+ action.promise.resolve(json);
23
+ })
24
+ .catch((error) => {
25
+ //How do we handle errors?
26
+ console.error("Velcron @http.get error occurred:", error);
27
+ throw error;
30
28
  });
31
29
  }
32
30
  };
@@ -1,6 +1,6 @@
1
1
  import { VelcronActionWithAutoAwait } from "../models";
2
2
  export interface IActionHandler {
3
3
  name: string;
4
- action: (action: VelcronActionWithAutoAwait, ...parameters: any) => Promise<unknown>;
4
+ action: (action: VelcronActionWithAutoAwait, ...parameters: any) => void;
5
5
  dispose?: (action: VelcronActionWithAutoAwait) => () => void;
6
6
  }
package/actions/Log.js CHANGED
@@ -5,6 +5,6 @@ exports.logInfo = {
5
5
  name: "@log.info",
6
6
  action: (action, value) => {
7
7
  console.dir(value);
8
- return Promise.resolve(null);
8
+ return action.promise.resolve(null);
9
9
  }
10
10
  };
@@ -4,13 +4,11 @@ exports.msGraphGet = void 0;
4
4
  const VelcronData_1 = require("../parser/VelcronData");
5
5
  exports.msGraphGet = {
6
6
  name: "@msgraph.get",
7
- action: (action, value) => {
8
- return new Promise(async function (resolve) {
9
- //TODO Make it typed!
10
- const client = await window.omniaScriptApi.m365.graphClient;
11
- value = VelcronData_1.VelcronData.dataBind(action, value);
12
- const res = await client.get(value);
13
- resolve(res.data);
14
- });
7
+ action: async (action, value) => {
8
+ //TODO Make it typed!
9
+ const client = await window.omniaScriptApi.m365.graphClient;
10
+ value = VelcronData_1.VelcronData.dataBind(action, value);
11
+ const res = await client.get(value);
12
+ action.promise.resolve(res.data);
15
13
  }
16
14
  };
@@ -5,13 +5,11 @@ const VelcronData_1 = require("../parser/VelcronData");
5
5
  //TODO This should be pluggable from sharepoint package
6
6
  exports.msSp = {
7
7
  name: "@mssp.get",
8
- action: (action, value) => {
9
- return new Promise(async function (resolve) {
10
- //TODO Make it typed!
11
- const client = await window.omniaScriptApi.spfx.sharepointClient;
12
- value = VelcronData_1.VelcronData.dataBind(action, value);
13
- const res = await client.get(value);
14
- resolve(res.data);
15
- });
8
+ action: async (action, value) => {
9
+ //TODO Make it typed!
10
+ const client = await window.omniaScriptApi.spfx.sharepointClient;
11
+ value = VelcronData_1.VelcronData.dataBind(action, value);
12
+ const res = await client.get(value);
13
+ action.promise.resolve(res.data);
16
14
  }
17
15
  };
package/actions/Timer.js CHANGED
@@ -21,7 +21,7 @@ exports.timerCreate = {
21
21
  //TODO: action.rootContext[path] validate it to be Array<string>
22
22
  action.rootContext[path] = new TimerInstance(action.rootContext[path], action, interval, autostart, immediate);
23
23
  }
24
- return Promise.resolve(null);
24
+ action.promise.resolve(null);
25
25
  },
26
26
  dispose: (action) => {
27
27
  return () => {
@@ -39,7 +39,7 @@ exports.timerStart = {
39
39
  parser_1.VelcronLogger.logActionError(`Error in ${timerStartName} the timer does not exists. Did you use ${timerCreateName} to create the timer?`);
40
40
  }
41
41
  timer.start();
42
- return Promise.resolve(null);
42
+ action.promise.resolve(null);
43
43
  }
44
44
  };
45
45
  const timerStopName = "@timer.stop";
@@ -50,7 +50,7 @@ exports.timerStop = {
50
50
  parser_1.VelcronLogger.logActionError(`Error in ${timerStopName} the timer does not exists. Did you use ${timerCreateName} to create the timer?`);
51
51
  }
52
52
  timer.stop();
53
- return Promise.resolve(null);
53
+ action.promise.resolve(null);
54
54
  }
55
55
  };
56
56
  function getPath(path) {
@@ -39,6 +39,7 @@ export interface ComponentBlueprints extends Blueprints, BlueprintsReference {
39
39
  buttons?: ButtonBlueprints;
40
40
  tabs?: TabsBlueprints;
41
41
  blocks?: ChromeBlueprints;
42
+ icons?: IconBlueprints;
42
43
  }
43
44
  export interface SpacingBlueprint {
44
45
  layout: SpacingDefinition;
@@ -55,12 +56,18 @@ export declare enum VelcronBlueprintDefintionTypes {
55
56
  button = "button"
56
57
  }
57
58
  export interface Blueprint {
58
- type: VelcronBlueprintDefintionType | WebBlueprintItemDefintionType;
59
59
  }
60
60
  export interface SearchBoxBlueprint extends Blueprint {
61
61
  borderRadius?: BoxDimensions;
62
62
  variant?: "outlined" | "solo" | "regular" | "plain" | "underlined";
63
63
  }
64
+ export interface IconBlueprints extends Blueprints {
65
+ xs?: IconBlueprint;
66
+ s?: IconBlueprint;
67
+ m?: IconBlueprint;
68
+ l?: IconBlueprint;
69
+ xl?: IconBlueprint;
70
+ }
64
71
  export interface ButtonBlueprint extends Blueprint {
65
72
  padding?: Spacing;
66
73
  background?: BackgroundDefinition;
@@ -1,5 +1,6 @@
1
- import { Guid } from "../Guid";
1
+ import { GuidValue } from "../Guid";
2
2
  import { BoxDimensions, ComponentBlueprints, SpacingBlueprints, TypographyBlueprints } from "./Blueprints";
3
+ export type ThemeContextType = "default" | "admin" | "preview" | "color-context";
3
4
  export interface ColorTypeResult<resultType> {
4
5
  base: resultType;
5
6
  baseTone: resultType;
@@ -42,7 +43,7 @@ export interface ColorSchemas extends ColorSchemasReference {
42
43
  notification: ColorSchema;
43
44
  }
44
45
  export interface BlueprintsReference {
45
- id: Guid;
46
+ id: GuidValue;
46
47
  }
47
48
  export interface ColorSchemasReference {
48
49
  primary: BlueprintsReference;
@@ -58,7 +59,7 @@ export interface ColorSchemasReference {
58
59
  notification: BlueprintsReference;
59
60
  }
60
61
  export interface ThemeDefinitionReference {
61
- id: Guid;
62
+ id: GuidValue;
62
63
  name?: string;
63
64
  colors: ColorSchemasReference;
64
65
  typography: BlueprintsReference;
@@ -72,7 +73,7 @@ export interface ThemeDefinitionV2 extends ThemeDefinitionReference {
72
73
  components: ComponentBlueprints;
73
74
  }
74
75
  export interface ITemplateRegistration<TTemplateType = any> {
75
- id: Guid;
76
+ id: GuidValue;
76
77
  template: TTemplateType;
77
78
  hidden?: boolean;
78
79
  custom?: boolean;
@@ -1,8 +1,8 @@
1
- import { Guid } from "../Guid";
1
+ import { GuidValue } from "../Guid";
2
2
  export interface TypographyBlueprint {
3
3
  name: string;
4
4
  font?: {
5
- id: Guid;
5
+ id: GuidValue;
6
6
  family: string;
7
7
  cdn?: string;
8
8
  };
@@ -1,5 +1,5 @@
1
1
  import { DynamicState } from "../DynamicState";
2
- import { VelcronEvent, VelcronOnEditModeEvent, VelcronOnLoadEvent, VelcronOnSavingEvent } from "./VelcronEvents";
2
+ import { VelcronEvent, VelcronOnEditModeEvent, VelcronOnLoadEvent, VelcronOnPersistingStateEvent, VelcronOnSavingEvent } from "./VelcronEvents";
3
3
  /**
4
4
  * Velcron definition base
5
5
  */
@@ -73,7 +73,7 @@ export interface VelcronAppDefinition<TState extends DynamicState = DynamicState
73
73
  version?: string;
74
74
  name?: string;
75
75
  body?: Array<VelcronDefinition>;
76
- events?: VelcronOnLoadEvent & VelcronOnEditModeEvent & VelcronOnSavingEvent;
76
+ events?: VelcronOnLoadEvent & VelcronOnEditModeEvent & VelcronOnSavingEvent & VelcronOnPersistingStateEvent;
77
77
  actions?: {
78
78
  [name: string]: Array<string>;
79
79
  };
@@ -7,6 +7,10 @@ export type VelcronOnLoadEvent = {
7
7
  export type VelcronOnSavingEvent = {
8
8
  onSaving?: Array<string>;
9
9
  };
10
+ export type VelcronOnPersistingStateEvent = {
11
+ onPersistState?: Array<string>;
12
+ onRestoreState?: Array<string>;
13
+ };
10
14
  export type VelcronOnEditModeEvent = {
11
15
  onEditMode?: Array<string>;
12
16
  };
@@ -72,7 +72,12 @@ export interface VelcronRenderContextEventHandlers {
72
72
  emitting?: <T>(emitter: (i: T) => T) => T;
73
73
  }
74
74
  export interface VelcronRenderContextEventHandlersInstance extends VelcronRenderContextEventHandlers {
75
- emitOnSaved: EventHook<Future<void>>;
75
+ emitOnSaved: EventHook<void>;
76
+ emitOnSavedPromises: Array<Future<unknown>>;
77
+ emitOnPersistState: EventHook<Future<DynamicState>>;
78
+ emitOnPersistStatePromises: Array<Future<unknown>>;
79
+ emitOnRestoreState: EventHook<unknown>;
80
+ emitOnRestoreStatePromises: Array<Future<unknown>>;
76
81
  }
77
82
  export interface VelcronRenderContextHooks {
78
83
  dialogVisibilityChanged?: ((visible: boolean) => void);
@@ -87,6 +92,7 @@ export interface VelcronContainerRenderer {
87
92
  }
88
93
  export interface VelcronAction extends VelcronRenderContext {
89
94
  type: VelcronActionTypes;
95
+ rootPromises?: Array<Future<void>>;
90
96
  }
91
97
  export interface VelcronActionGetOrSetValue extends VelcronAction {
92
98
  value?: unknown;
@@ -97,6 +103,7 @@ export interface VelcronActionGetOrSetValue extends VelcronAction {
97
103
  export interface VelcronActionWithAutoAwait extends VelcronActionGetOrSetValue {
98
104
  nowait: boolean;
99
105
  action: string;
106
+ promise: Future<unknown>;
100
107
  }
101
108
  export interface VelcronActionWithCondition extends VelcronActionWithAutoAwait {
102
109
  condition: string;
@@ -3,8 +3,3 @@ export type VelcronPrimitiveType = string | number | boolean;
3
3
  export type VelcronArrayType<T> = Array<T>;
4
4
  export type VelcronObjectType<T extends Object> = T;
5
5
  export type VelcroncomponentArrayType = Array<VelcronDefinition>;
6
- export interface DeferredPromise<T> {
7
- promise: Promise<T>;
8
- resolve: (val: T) => void;
9
- reject: () => void;
10
- }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@omnia/velcron",
3
3
  "license": "MIT",
4
- "version": "8.0.136-dev",
4
+ "version": "8.0.138-dev",
5
5
  "description": "Provide Omnia Velcron Stuffs.",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,5 +1,6 @@
1
- import { VelcronAction, VelcronActionWithAutoAwait, VelcronRenderContext, DeferredPromise, VelcronActionHooks } from "../models";
1
+ import { VelcronAction, VelcronActionWithAutoAwait, VelcronRenderContext, VelcronActionHooks } from "../models";
2
2
  import { IActionHandler } from "../actions";
3
+ import { Future } from "internal/fx/shared";
3
4
  export declare class VelcronActions {
4
5
  static _actionHandlers: {
5
6
  [name: string]: IActionHandler;
@@ -10,7 +11,8 @@ export declare class VelcronActions {
10
11
  private static registeredBuiltInHandlers;
11
12
  static registerAction(handler: IActionHandler): void;
12
13
  static unregisterAction(name: string): void;
13
- static parseAndExecuteActions(templates: Array<string>, renderContext: VelcronRenderContext, customActionContext?: VelcronCustomActionExecutionContext): void;
14
+ static actionArrayToString(templates: Array<string>): string;
15
+ static parseAndExecuteActions(templates: Array<string>, renderContext: VelcronRenderContext, customActionContext?: VelcronCustomActionExecutionContext): Future<unknown>;
14
16
  static parseFunction(target: {
15
17
  [name: string]: Array<string>;
16
18
  }, template: string, renderContext: VelcronRenderContext, params: Array<VelcronActionParameterValue>, foundCb: (name: string, params: {}) => void): void;
@@ -39,6 +41,6 @@ interface VelcronCustomActionExecutionContext {
39
41
  customAction: VelcronAction | null;
40
42
  parentAction: VelcronAction | VelcronRenderContext;
41
43
  variables: object;
42
- returnValue: DeferredPromise<any>;
44
+ returnValue: Future<any>;
43
45
  }
44
46
  export {};
@@ -8,6 +8,7 @@ const VelcronData_1 = require("./VelcronData");
8
8
  const builtInHandlers = tslib_1.__importStar(require("../actions"));
9
9
  const ActionResults_1 = require("../actions/ActionResults");
10
10
  const VelcronLogger_1 = require("./VelcronLogger");
11
+ const shared_1 = require("internal/fx/shared");
11
12
  class VelcronActions {
12
13
  static { this._actionHandlers = {}; }
13
14
  static { this.actionHooks = {}; }
@@ -26,12 +27,7 @@ class VelcronActions {
26
27
  delete this._actionHandlers[name];
27
28
  }
28
29
  }
29
- static parseAndExecuteActions(templates, renderContext, customActionContext) {
30
- if (!templates) {
31
- VelcronLogger_1.VelcronLogger.logActionError("The event template is empty");
32
- return;
33
- }
34
- const actions = [];
30
+ static actionArrayToString(templates) {
35
31
  let template = "";
36
32
  let count = 1;
37
33
  templates.forEach((temp) => {
@@ -42,14 +38,34 @@ class VelcronActions {
42
38
  template = template + temp + (count === templates.length ? "" : " => ");
43
39
  count++;
44
40
  });
41
+ return template;
42
+ }
43
+ //TODO this might need to be added back together with other code in the file code marked "Sub Action Resolver"
44
+ //private static actionPromises: { [id: string]: Array<Future<void>> } = {};
45
+ static parseAndExecuteActions(templates, renderContext, customActionContext) {
46
+ if (!templates) {
47
+ VelcronLogger_1.VelcronLogger.logActionError("The event template is empty");
48
+ return;
49
+ }
50
+ let template = VelcronActions.actionArrayToString(templates);
51
+ const actions = [];
45
52
  const evIdEnd = template.indexOf(VelcronConstants_1.VelcronConstants.events.idTokenEnd);
46
53
  const evId = template.substring(VelcronConstants_1.VelcronConstants.events.idTokenStart.length, evIdEnd);
47
54
  template = template.substring(evIdEnd + 1);
55
+ //TODO this might need to be added back together with other code in the file code marked "Sub Action Resolver"
56
+ //let requiredPromises = 1;
48
57
  for (const partialTemplate of template.split("=>")) {
49
58
  if (partialTemplate) {
50
59
  const res = VelcronActions.getActionFromTemplate(partialTemplate, evId, renderContext, customActionContext);
51
60
  if (res) {
52
61
  actions.push(res);
62
+ //TODO this might need to be added back together with other code in the file code marked "Sub Action Resolver"
63
+ // if(!customActionContext && renderContext.actions){
64
+ // const depth = VelcronActions.resolveActionsDepth(partialTemplate, renderContext);
65
+ // if(depth > requiredPromises){
66
+ // requiredPromises = depth;
67
+ // }
68
+ // }
53
69
  }
54
70
  }
55
71
  }
@@ -60,9 +76,29 @@ class VelcronActions {
60
76
  VelcronData_1.VelcronData.setVariables(evId, customActionContext.variables);
61
77
  }
62
78
  }
79
+ else {
80
+ //TODO this might need to be added back together with other code in the file code marked "Sub Action Resolver"
81
+ // VelcronActions.actionPromises[evId] = [];
82
+ // for (let i = 0; i < requiredPromises; i++) {
83
+ // VelcronActions.actionPromises[evId].push(Future.new<void>());
84
+ // }
85
+ // Future.all(VelcronActions.actionPromises[evId]).then(() => {
86
+ // console.dir("All promises resolved loveliiiii");
87
+ // });
88
+ }
63
89
  VelcronActions.executeActions(actions, 0, customActionContext);
64
90
  //Clean up temp variables after execution
65
91
  VelcronData_1.VelcronData.deleteVariables(evId);
92
+ //The returned promise will resolved when all sub async actions are resolved
93
+ return shared_1.Future.all(actions.filter(p => p.promise).map(a => a.promise));
94
+ //TODO this might need to be added back together with other code in the file code marked "Sub Action Resolver"
95
+ // return Future.all((actions as Array<VelcronActionWithAutoAwait>).filter(p => p.promise).map(a => a.promise)).then(() => {
96
+ // const firstUnresolved = VelcronActions.actionPromises[customActionContext ? customActionContext.parentAction.id : evId].find(p => p && !p.resolved);
97
+ // if (firstUnresolved) {
98
+ // console.dir("RESOLVE");
99
+ // firstUnresolved.resolve();
100
+ // }
101
+ // }) as Future<void>;
66
102
  }
67
103
  }
68
104
  static parseFunction(target, template, renderContext, params, foundCb) {
@@ -182,27 +218,30 @@ class VelcronActions {
182
218
  }
183
219
  if (VelcronActions.valueIsAction(val)) {
184
220
  //Action e.g await @http.get('https://localhost:4455/api/weather')
185
- //All actions is auto awaited by default which i think should be the normal case
186
- //in a modern language :) you can use => nowait @http.get to not wait for the async
221
+ const castedResult = result;
222
+ castedResult.promise = shared_1.Future.new();
223
+ //All actions is auto awaited by default but you can use => nowait @http.get to not wait for the async
187
224
  //operation to complete.
188
- if (val.startsWith("nowait")) {
189
- result.nowait = true;
225
+ if (val.startsWith(VelcronConstants_1.VelcronConstants.async.noWaitToken)) {
226
+ castedResult.nowait = true;
227
+ castedResult.promise.resolve(null);
190
228
  val = val.substring(6);
191
229
  }
192
- result.type = models_1.VelcronActionTypes.promise;
193
- result.path = path;
194
- result.action = val;
195
- result.assignOperator = operator;
230
+ castedResult.type = models_1.VelcronActionTypes.promise;
231
+ castedResult.path = path;
232
+ castedResult.action = val;
233
+ castedResult.assignOperator = operator;
196
234
  }
197
235
  else if (partialTemplate.startsWith("return")) {
198
236
  result.type = models_1.VelcronActionTypes.returnsValue;
199
237
  result.value = partialTemplate.substring(6).trim();
200
238
  }
201
239
  else {
202
- result.type = models_1.VelcronActionTypes.getOrSetValue;
203
- result.path = path;
204
- result.value = val;
205
- result.assignOperator = operator;
240
+ const castedResult = result;
241
+ castedResult.type = models_1.VelcronActionTypes.getOrSetValue;
242
+ castedResult.path = path;
243
+ castedResult.value = val;
244
+ castedResult.assignOperator = operator;
206
245
  }
207
246
  }
208
247
  if (customActionContext?.parentAction) {
@@ -211,9 +250,11 @@ class VelcronActions {
211
250
  return result;
212
251
  }
213
252
  static valueIsAction(value) {
214
- return value.startsWith("@") || value.startsWith("await");
253
+ return value.startsWith("@") || value.startsWith(VelcronConstants_1.VelcronConstants.async.noWaitToken);
215
254
  }
216
255
  static executeActions(arr, x, customActionContext) {
256
+ //start a timer
257
+ //console.dir(arr);
217
258
  //The Callback approach is to be able to wait for a promise to be finished
218
259
  //before the loop continues = await support
219
260
  VelcronActions.executeAction(arr[x], (continueExecution) => {
@@ -261,7 +302,7 @@ class VelcronActions {
261
302
  }
262
303
  const val = awAction.action.substring(awAction.action.indexOf("(") + 1).replace(")", "").trim();
263
304
  const params = VelcronActions.extractParameterValues(val, awAction);
264
- let promise = null;
305
+ //let promise: Promise<any> | null = null;
265
306
  const actionName = awAction.action.substring(0, awAction.action.indexOf("(")).trim().toLowerCase();
266
307
  if (!VelcronActions.registeredBuiltInHandlers) {
267
308
  Object.keys(builtInHandlers).forEach((key) => {
@@ -277,7 +318,7 @@ class VelcronActions {
277
318
  let hasCustomActionValue = false;
278
319
  if (VelcronActions._actionHandlers[actionName]) {
279
320
  //Built in handler
280
- promise = VelcronActions._actionHandlers[actionName].action(awAction, ...paramValues);
321
+ VelcronActions._actionHandlers[actionName].action(awAction, ...paramValues);
281
322
  if (VelcronActions._actionHandlers[actionName].dispose) {
282
323
  awAction.disposers.push(VelcronActions._actionHandlers[actionName].dispose(awAction));
283
324
  }
@@ -294,15 +335,15 @@ class VelcronActions {
294
335
  parentAction: awAction,
295
336
  customAction: null,
296
337
  variables: params,
297
- returnValue: VelcronData_1.VelcronData.createDeferredPromise()
338
+ returnValue: shared_1.Future.new()
298
339
  };
299
340
  VelcronActions.parseAndExecuteActions(acArr, awAction, customActionContext);
300
- promise = customActionContext.returnValue.promise;
341
+ awAction.promise = customActionContext.returnValue;
301
342
  hasCustomActionValue = true;
302
343
  });
303
344
  }
304
- if (!awAction.nowait && promise || hasCustomActionValue && promise) {
305
- promise.then((val) => {
345
+ if (!awAction.nowait && awAction.promise || hasCustomActionValue && awAction.promise) {
346
+ awAction.promise.then((val) => {
306
347
  let continueExecution = true;
307
348
  //If action returns StopProcedingActions class in promise we will not continue executing actions
308
349
  if (val && val instanceof ActionResults_1.CancelProcedingActions) {
@@ -374,6 +415,29 @@ class VelcronActions {
374
415
  }
375
416
  return args;
376
417
  }
418
+ //TODO this might need to be added back together with other code in the file code marked "Sub Action Resolver"
419
+ // private static resolveActionsDepth(template, renderContext, currentDepth = 0) {
420
+ // let maxDepth = currentDepth;
421
+ // if (renderContext && renderContext.actions) {
422
+ // for (const fullActionKey of Object.keys(renderContext.actions)) {
423
+ // // Trim the action key to its base name (up to the first parenthesis)
424
+ // const actionBaseName = fullActionKey.includes("(") ? fullActionKey.substring(0, fullActionKey.indexOf("(") + 1) : fullActionKey;
425
+ // // Check if this base action name is present in the template string
426
+ // if (template.includes(actionBaseName)) {
427
+ // // Increment depth for the current action
428
+ // const newDepth = currentDepth + 1;
429
+ // maxDepth = Math.max(maxDepth, newDepth);
430
+ // // Resolve nested actions if present
431
+ // const nestedTemplate = VelcronActions.actionArrayToString(renderContext.actions[fullActionKey]);
432
+ // if (nestedTemplate && typeof nestedTemplate === "string") {
433
+ // const nestedMaxDepth = VelcronActions.resolveActionsDepth(nestedTemplate, renderContext, newDepth);
434
+ // maxDepth = Math.max(maxDepth, nestedMaxDepth);
435
+ // }
436
+ // }
437
+ // }
438
+ // }
439
+ // return maxDepth;
440
+ // }
377
441
  static extractParameterValues(template, action) {
378
442
  const params = [];
379
443
  let hasMoreParams = true;
@@ -40,4 +40,7 @@ export declare const VelcronConstants: {
40
40
  context: {
41
41
  thisToken: string;
42
42
  };
43
+ async: {
44
+ noWaitToken: string;
45
+ };
43
46
  };
@@ -42,5 +42,8 @@ exports.VelcronConstants = {
42
42
  },
43
43
  context: {
44
44
  thisToken: "$this"
45
+ },
46
+ async: {
47
+ noWaitToken: "nowait",
45
48
  }
46
49
  };
@@ -1,4 +1,4 @@
1
- import { VelcronRenderContext, DeferredPromise, VelcronBindableProp } from "../models";
1
+ import { VelcronRenderContext, VelcronBindableProp } from "../models";
2
2
  import { VelcronAppDefinition, VelcronDefinition } from "..";
3
3
  export interface ParseResult<T> {
4
4
  is: boolean;
@@ -32,7 +32,6 @@ export declare class VelcronData {
32
32
  static ensureKeys(ui: VelcronDefinition | VelcronAppDefinition, generateNewKeys?: boolean): void;
33
33
  static removeKeys(ui: VelcronDefinition | VelcronAppDefinition): void;
34
34
  static generateId(): string;
35
- static createDeferredPromise<T>(): DeferredPromise<T>;
36
35
  }
37
36
  interface ExtendArray extends Array<any> {
38
37
  take: (amount: number) => Array<any>;
@@ -631,12 +631,5 @@ class VelcronData {
631
631
  const secondPart = (Math.random() * 46656) | 0;
632
632
  return (("000" + firstPart.toString(36)).slice(-3) + ("000" + secondPart.toString(36)).slice(-3)).toString();
633
633
  }
634
- static createDeferredPromise() {
635
- let resolve, reject;
636
- const promise = new Promise((res, rej) => {
637
- [resolve, reject] = [res, rej];
638
- });
639
- return { promise, reject, resolve };
640
- }
641
634
  }
642
635
  exports.VelcronData = VelcronData;