@omnia/velcron 7.0.380-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/README.md +6 -0
- package/actions/ActionResults.d.ts +4 -0
- package/actions/ActionResults.js +14 -0
- package/actions/Alert.d.ts +2 -0
- package/actions/Alert.js +12 -0
- package/actions/Array.d.ts +3 -0
- package/actions/Array.js +22 -0
- package/actions/Debounce.d.ts +2 -0
- package/actions/Debounce.js +43 -0
- package/actions/Delay.d.ts +2 -0
- package/actions/Delay.js +14 -0
- package/actions/Http.d.ts +2 -0
- package/actions/Http.js +15 -0
- package/actions/IActionHandler.d.ts +5 -0
- package/actions/IActionHandler.js +2 -0
- package/actions/Log.d.ts +2 -0
- package/actions/Log.js +10 -0
- package/actions/MsGraph.d.ts +2 -0
- package/actions/MsGraph.js +16 -0
- package/actions/MsSharePoint.d.ts +2 -0
- package/actions/MsSharePoint.js +17 -0
- package/actions/index.d.ts +10 -0
- package/actions/index.js +13 -0
- package/index.d.ts +3 -0
- package/index.js +6 -0
- package/models/Enums.d.ts +53 -0
- package/models/Enums.js +66 -0
- package/models/VelcronDefinitions.d.ts +213 -0
- package/models/VelcronDefinitions.js +2 -0
- package/models/VelcronDescriptors.d.ts +34 -0
- package/models/VelcronDescriptors.js +2 -0
- package/models/VelcronEvents.d.ts +16 -0
- package/models/VelcronEvents.js +2 -0
- package/models/VelcronTypes.d.ts +10 -0
- package/models/VelcronTypes.js +2 -0
- package/models/ViewModelAndContext.d.ts +4 -0
- package/models/ViewModelAndContext.js +2 -0
- package/models/index.d.ts +6 -0
- package/models/index.js +9 -0
- package/package.json +27 -0
- package/parser/TextValue.d.ts +4 -0
- package/parser/TextValue.js +9 -0
- package/parser/VelcronActions.d.ts +36 -0
- package/parser/VelcronActions.js +445 -0
- package/parser/VelcronConstants.d.ts +28 -0
- package/parser/VelcronConstants.js +31 -0
- package/parser/VelcronData.d.ts +39 -0
- package/parser/VelcronData.js +628 -0
- package/parser/VelcronLogger.d.ts +6 -0
- package/parser/VelcronLogger.js +18 -0
- package/parser/VelcronRenderers.d.ts +10 -0
- package/parser/VelcronRenderers.js +114 -0
- package/parser/VelcronStyles.d.ts +8 -0
- package/parser/VelcronStyles.js +121 -0
- package/parser/index.d.ts +7 -0
- package/parser/index.js +10 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { VelcronDefinition } from "./VelcronDefinitions";
|
|
2
|
+
export declare type VelcronPrimitiveType = string | number | boolean;
|
|
3
|
+
export declare type VelcronArrayType<T> = Array<T>;
|
|
4
|
+
export declare type VelcronObjectType<T extends Object> = T;
|
|
5
|
+
export declare type VelcroncomponentArrayType = Array<VelcronDefinition>;
|
|
6
|
+
export interface DeferredPromise<T> {
|
|
7
|
+
promise: Promise<T>;
|
|
8
|
+
resolve: (val: T) => void;
|
|
9
|
+
reject: () => void;
|
|
10
|
+
}
|
package/models/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./VelcronDefinitions"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./ViewModelAndContext"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./VelcronDescriptors"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./VelcronEvents"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./VelcronTypes"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./Enums"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@omnia/velcron",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"version": "7.0.380-dev",
|
|
5
|
+
"description": "Provide Omnia Velcron Stuffs.",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/preciofishbone/OmniaFx"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"omnia",
|
|
15
|
+
"omniafx",
|
|
16
|
+
"extension",
|
|
17
|
+
"office365",
|
|
18
|
+
"sharepoint"
|
|
19
|
+
],
|
|
20
|
+
"author": "Precio Fishbone",
|
|
21
|
+
"dependencies": {},
|
|
22
|
+
"typings": "./index.d.ts",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/preciofishbone/OmniaFx/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/preciofishbone/OmniaFx#readme"
|
|
27
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { VelcronAction, VelcronActionWithAutoAwait, VelcronRenderContext, DeferredPromise } from "../models";
|
|
2
|
+
import { IActionHandler } from "../actions";
|
|
3
|
+
export declare class VelcronActions {
|
|
4
|
+
static _actionHandlers: {
|
|
5
|
+
[name: string]: IActionHandler;
|
|
6
|
+
} | null;
|
|
7
|
+
static registerAction(name: string, handler: IActionHandler): void;
|
|
8
|
+
static parseAndExecuteActions(templates: Array<string>, renderContext: VelcronRenderContext, customActionContext?: VelcronCustomActionExecutionContext): void;
|
|
9
|
+
static parseFunction(target: {
|
|
10
|
+
[name: string]: [];
|
|
11
|
+
}, template: string, renderContext: VelcronRenderContext, params: Array<VelcronActionParameterValue>, foundCb: (name: string, params: {}) => void): void;
|
|
12
|
+
static getActionFromTemplate(partialTemplate: string, eventId: string, renderContext: VelcronRenderContext, customActionContext?: VelcronCustomActionExecutionContext): VelcronAction;
|
|
13
|
+
static valueIsAction(value: string): boolean;
|
|
14
|
+
static executeActions(arr: any, x: any, customActionContext?: VelcronCustomActionExecutionContext): void;
|
|
15
|
+
static executeAction(awAction: VelcronActionWithAutoAwait, callback: (continueExecution: boolean) => void): void;
|
|
16
|
+
static dataBindComputed(renderContext: VelcronRenderContext, template: string): string;
|
|
17
|
+
static parseAndExecuteComputed(renderContext: VelcronRenderContext, template: string): string;
|
|
18
|
+
private static extractParameterValues;
|
|
19
|
+
}
|
|
20
|
+
interface VelcronActionParameterValue {
|
|
21
|
+
dataType: VelcronActionParameterDataType;
|
|
22
|
+
value: any;
|
|
23
|
+
}
|
|
24
|
+
export declare enum VelcronActionParameterDataType {
|
|
25
|
+
text = 0,
|
|
26
|
+
number = 1,
|
|
27
|
+
boolean = 2,
|
|
28
|
+
pointer = 3
|
|
29
|
+
}
|
|
30
|
+
interface VelcronCustomActionExecutionContext {
|
|
31
|
+
customAction: VelcronAction | null;
|
|
32
|
+
parentAction: VelcronAction | VelcronRenderContext;
|
|
33
|
+
variables: object;
|
|
34
|
+
returnValue: DeferredPromise<any>;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VelcronActionParameterDataType = exports.VelcronActions = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const VelcronConstants_1 = require("./VelcronConstants");
|
|
7
|
+
const VelcronData_1 = require("./VelcronData");
|
|
8
|
+
const builtInHandlers = tslib_1.__importStar(require("../actions"));
|
|
9
|
+
const ActionResults_1 = require("../actions/ActionResults");
|
|
10
|
+
const VelcronLogger_1 = require("./VelcronLogger");
|
|
11
|
+
class VelcronActions {
|
|
12
|
+
static registerAction(name, handler) {
|
|
13
|
+
name = name.toLowerCase();
|
|
14
|
+
if (this._actionHandlers && this._actionHandlers[name]) {
|
|
15
|
+
VelcronLogger_1.VelcronLogger.logActionError(`The action handler with name ${name} is already registered`);
|
|
16
|
+
}
|
|
17
|
+
else if (this._actionHandlers) {
|
|
18
|
+
this._actionHandlers[name] = handler;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
static parseAndExecuteActions(templates, renderContext, customActionContext) {
|
|
22
|
+
if (!templates) {
|
|
23
|
+
VelcronLogger_1.VelcronLogger.logActionError("The event template is empty");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const actions = [];
|
|
27
|
+
let template = "";
|
|
28
|
+
let count = 1;
|
|
29
|
+
templates.forEach((temp) => {
|
|
30
|
+
temp = temp.trim();
|
|
31
|
+
if (temp.startsWith("=>")) {
|
|
32
|
+
temp = temp.substring(2);
|
|
33
|
+
}
|
|
34
|
+
template = template + temp + (count === templates.length ? "" : " => ");
|
|
35
|
+
count++;
|
|
36
|
+
});
|
|
37
|
+
const evIdEnd = template.indexOf(VelcronConstants_1.VelcronConstants.events.idTokenEnd);
|
|
38
|
+
const evId = template.substring(VelcronConstants_1.VelcronConstants.events.idTokenStart.length, evIdEnd);
|
|
39
|
+
template = template.substring(evIdEnd + 1);
|
|
40
|
+
for (const partialTemplate of template.split("=>")) {
|
|
41
|
+
if (partialTemplate) {
|
|
42
|
+
const res = VelcronActions.getActionFromTemplate(partialTemplate, evId, renderContext, customActionContext);
|
|
43
|
+
if (res) {
|
|
44
|
+
actions.push(res);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (actions.length > 0) {
|
|
49
|
+
if (customActionContext) {
|
|
50
|
+
customActionContext.customAction = renderContext;
|
|
51
|
+
if (customActionContext.variables) {
|
|
52
|
+
VelcronData_1.VelcronData.setVariables(evId, customActionContext.variables);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
VelcronActions.executeActions(actions, 0, customActionContext);
|
|
56
|
+
//Clean up temp variables after execution
|
|
57
|
+
VelcronData_1.VelcronData.deleteVariables(evId);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
static parseFunction(target, template, renderContext, params, foundCb) {
|
|
61
|
+
//Supports parsing Action or Computed functions
|
|
62
|
+
let actionExists = false;
|
|
63
|
+
//Support custom actions
|
|
64
|
+
if (target) {
|
|
65
|
+
Object.keys(target).forEach((acName) => {
|
|
66
|
+
const actionMustMatch = `${template}(`;
|
|
67
|
+
if (actionMustMatch === acName.substring(0, actionMustMatch.length)) {
|
|
68
|
+
actionExists = true;
|
|
69
|
+
let actionName = acName;
|
|
70
|
+
const funcParams = {};
|
|
71
|
+
if (actionName.indexOf("(")) {
|
|
72
|
+
//Action having params @myAction(text,isTrue)
|
|
73
|
+
actionName = acName.substring(0, actionName.indexOf("("));
|
|
74
|
+
const paramTemplate = acName.substring(actionName.length + 1).replace(")", "");
|
|
75
|
+
if (paramTemplate.indexOf(",")) {
|
|
76
|
+
const par = paramTemplate.split(",");
|
|
77
|
+
let index = 0;
|
|
78
|
+
par.forEach((parVal) => {
|
|
79
|
+
parVal = parVal.replace(" /g", "").replace("\"/g", "");
|
|
80
|
+
parVal = parVal.trim();
|
|
81
|
+
if (funcParams[parVal]) {
|
|
82
|
+
VelcronLogger_1.VelcronLogger.logActionError(`A parameter with name ${parVal} on action with name ${actionName} already exists. Parameters must be unique`);
|
|
83
|
+
}
|
|
84
|
+
funcParams[parVal] = params[index];
|
|
85
|
+
index++;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (template.indexOf(actionName.substring(1)) > -1) {
|
|
90
|
+
foundCb(acName, funcParams);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (!actionExists) {
|
|
96
|
+
VelcronLogger_1.VelcronLogger.logActionError(`Cant find a built-in action, custom action or computed matching name ${template}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
static getActionFromTemplate(partialTemplate, eventId, renderContext, customActionContext) {
|
|
100
|
+
let path = "";
|
|
101
|
+
let val = "";
|
|
102
|
+
const result = {
|
|
103
|
+
id: eventId,
|
|
104
|
+
type: models_1.VelcronActionTypes.getOrSetValue,
|
|
105
|
+
rootContext: renderContext.rootContext,
|
|
106
|
+
currentContext: renderContext.currentContext,
|
|
107
|
+
actions: renderContext.actions
|
|
108
|
+
};
|
|
109
|
+
partialTemplate = partialTemplate.trim();
|
|
110
|
+
if (partialTemplate.trim() === "") {
|
|
111
|
+
throw "partialTemplate is empty";
|
|
112
|
+
}
|
|
113
|
+
//Handle conditional actions e.g unsplashCurrentPage === 1 ? $state.unsplash = res : $state.unsplash.results = @arrayAppend(res.results)
|
|
114
|
+
let pattern = /\?(?=([^']*'[^']*')*[^']*$)/;
|
|
115
|
+
let re = new RegExp(pattern);
|
|
116
|
+
let match = re.exec(partialTemplate);
|
|
117
|
+
//If we have ? its a conditional but if we have =? its not
|
|
118
|
+
if (match && partialTemplate.substring(match.index - 1, match.index) !== "=") {
|
|
119
|
+
result.type = models_1.VelcronActionTypes.condition;
|
|
120
|
+
result.condition = partialTemplate.substring(0, match.index);
|
|
121
|
+
//var res = false//VelcronData.evaluateBoolean(evalBoolean, renderContext);
|
|
122
|
+
const questionMarkIndex = match.index;
|
|
123
|
+
const subActions = partialTemplate.substring(questionMarkIndex + 1);
|
|
124
|
+
pattern = /\:(?=([^']*'[^']*')*[^']*$)/;
|
|
125
|
+
re = new RegExp(pattern);
|
|
126
|
+
match = re.exec(subActions);
|
|
127
|
+
if (match) {
|
|
128
|
+
//Take the second in the conditional match : othervalue = bla
|
|
129
|
+
result.trueAction =
|
|
130
|
+
VelcronActions.getActionFromTemplate(subActions.substring(1, match.index), eventId, renderContext);
|
|
131
|
+
result.falseAction =
|
|
132
|
+
VelcronActions.getActionFromTemplate(subActions.substring(match.index + 1), eventId, renderContext);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
result.trueAction =
|
|
136
|
+
VelcronActions.getActionFromTemplate(subActions, eventId, renderContext);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (result.type !== models_1.VelcronActionTypes.condition) {
|
|
140
|
+
let operator = null;
|
|
141
|
+
if (!VelcronActions.valueIsAction(partialTemplate)) {
|
|
142
|
+
let assignOpIndex = -1;
|
|
143
|
+
let length = 2;
|
|
144
|
+
if (partialTemplate.indexOf(models_1.AssignOperators.plusEquals) > -1) {
|
|
145
|
+
assignOpIndex = partialTemplate.indexOf(models_1.AssignOperators.plusEquals);
|
|
146
|
+
}
|
|
147
|
+
else if (partialTemplate.indexOf(models_1.AssignOperators.equalsPlus) > -1) {
|
|
148
|
+
assignOpIndex = partialTemplate.indexOf(models_1.AssignOperators.equalsPlus);
|
|
149
|
+
}
|
|
150
|
+
else if (partialTemplate.indexOf(models_1.AssignOperators.equalsQuestion) > -1) {
|
|
151
|
+
assignOpIndex = partialTemplate.indexOf(models_1.AssignOperators.equalsQuestion);
|
|
152
|
+
}
|
|
153
|
+
else if (partialTemplate.indexOf(models_1.AssignOperators.equalsExclamation) > -1) {
|
|
154
|
+
assignOpIndex = partialTemplate.indexOf(models_1.AssignOperators.equalsExclamation);
|
|
155
|
+
}
|
|
156
|
+
else if (partialTemplate.indexOf(models_1.AssignOperators.equals) > -1) {
|
|
157
|
+
length = 1;
|
|
158
|
+
assignOpIndex = partialTemplate.indexOf(models_1.AssignOperators.equals);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
path = partialTemplate;
|
|
162
|
+
}
|
|
163
|
+
if (assignOpIndex > -1) {
|
|
164
|
+
//Direct assignment e.g ${loading} = true
|
|
165
|
+
path = partialTemplate.substring(0, assignOpIndex + length).trim();
|
|
166
|
+
val = partialTemplate.substring(assignOpIndex + length).trim();
|
|
167
|
+
operator = partialTemplate.substring(assignOpIndex, assignOpIndex + length);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
path = partialTemplate;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
//Not setting a var just calling an action like await @delay(5000)
|
|
175
|
+
val = partialTemplate;
|
|
176
|
+
}
|
|
177
|
+
if (VelcronActions.valueIsAction(val)) {
|
|
178
|
+
//Action e.g await @http.get('https://localhost:4455/api/weather')
|
|
179
|
+
//All actions is auto awaited by default which i think should be the normal case
|
|
180
|
+
//in a modern language :) you can use => nowait @http.get to not wait for the async
|
|
181
|
+
//operation to complete.
|
|
182
|
+
if (val.startsWith("nowait")) {
|
|
183
|
+
result.nowait = true;
|
|
184
|
+
val = val.substring(6);
|
|
185
|
+
}
|
|
186
|
+
result.type = models_1.VelcronActionTypes.promise;
|
|
187
|
+
result.path = path;
|
|
188
|
+
result.action = val;
|
|
189
|
+
result.assignOperator = operator;
|
|
190
|
+
}
|
|
191
|
+
else if (partialTemplate.startsWith("return")) {
|
|
192
|
+
result.type = models_1.VelcronActionTypes.returnsValue;
|
|
193
|
+
result.value = partialTemplate.substring(6).trim();
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
result.type = models_1.VelcronActionTypes.getOrSetValue;
|
|
197
|
+
result.path = path;
|
|
198
|
+
result.value = val;
|
|
199
|
+
result.assignOperator = operator;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (customActionContext?.parentAction) {
|
|
203
|
+
result.parent = customActionContext.parentAction;
|
|
204
|
+
}
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
static valueIsAction(value) {
|
|
208
|
+
return value.startsWith("@") || value.startsWith("await");
|
|
209
|
+
}
|
|
210
|
+
static executeActions(arr, x, customActionContext) {
|
|
211
|
+
//The Callback approach is to be able to wait for a promise to be finished
|
|
212
|
+
//before the loop continues = await support
|
|
213
|
+
VelcronActions.executeAction(arr[x], (continueExecution) => {
|
|
214
|
+
if (continueExecution) {
|
|
215
|
+
x++;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
x = arr.length;
|
|
219
|
+
}
|
|
220
|
+
if (x < arr.length) {
|
|
221
|
+
VelcronActions.executeActions(arr, x, customActionContext);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
//To support waiting for custom actions to finish before continueing
|
|
225
|
+
if (customActionContext && customActionContext.customAction) {
|
|
226
|
+
const returnVal = VelcronData_1.VelcronData.getVariable(VelcronConstants_1.VelcronConstants.events.returnValueVariableName, customActionContext.customAction);
|
|
227
|
+
if (returnVal.is) {
|
|
228
|
+
customActionContext.returnValue.resolve(returnVal.value);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
customActionContext.returnValue.resolve(null);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
static executeAction(awAction, callback) {
|
|
238
|
+
//Handles actions and support async using callback of promise
|
|
239
|
+
if (awAction.type === models_1.VelcronActionTypes.condition) {
|
|
240
|
+
const awAc = awAction;
|
|
241
|
+
const res = VelcronData_1.VelcronData.evaluateBoolean(awAc.condition, awAc);
|
|
242
|
+
if (res) {
|
|
243
|
+
awAction = awAc.trueAction;
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
awAction = awAc.falseAction;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (awAction.action) {
|
|
250
|
+
if (!awAction.action.endsWith(")")) {
|
|
251
|
+
throw (`Velcron error parsing action: ${awAction.action} it must end with a close parenthesis)`);
|
|
252
|
+
}
|
|
253
|
+
if ((awAction.action.split("(").length - 1) + (awAction.action.split(")").length - 1) !== 2) {
|
|
254
|
+
throw ("Actions must not contain more then 2 parenthesis, e.g @delay(5000)");
|
|
255
|
+
}
|
|
256
|
+
const val = awAction.action.substring(awAction.action.indexOf("(") + 1).replace(")", "").trim();
|
|
257
|
+
const params = VelcronActions.extractParameterValues(val, awAction);
|
|
258
|
+
let promise = null;
|
|
259
|
+
const actionName = awAction.action.substring(0, awAction.action.indexOf("(")).trim().toLowerCase();
|
|
260
|
+
//promise = VelcronActions.runHandler(awAction, actionName, params);
|
|
261
|
+
if (!VelcronActions._actionHandlers) {
|
|
262
|
+
VelcronActions._actionHandlers = {};
|
|
263
|
+
Object.keys(builtInHandlers).forEach((key) => {
|
|
264
|
+
const handler = builtInHandlers[key];
|
|
265
|
+
if (handler && handler.name && VelcronActions._actionHandlers) {
|
|
266
|
+
VelcronActions._actionHandlers[handler.name] = handler;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
const paramValues = [];
|
|
271
|
+
params.forEach(param => paramValues.push(param.value));
|
|
272
|
+
let hasCustomActionValue = false;
|
|
273
|
+
if (VelcronActions._actionHandlers[actionName]) {
|
|
274
|
+
//Built in handler
|
|
275
|
+
promise = VelcronActions._actionHandlers[actionName].action(awAction, ...paramValues);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
//Custom handler
|
|
279
|
+
VelcronActions.parseFunction(awAction.actions, actionName, awAction, paramValues, (acName, params) => {
|
|
280
|
+
if (!acName.startsWith("@")) {
|
|
281
|
+
throw "Custom action names must start with @";
|
|
282
|
+
}
|
|
283
|
+
const acArr = awAction.actions[acName];
|
|
284
|
+
acArr[0] = VelcronData_1.VelcronData.ensureEventId(acArr[0]);
|
|
285
|
+
const customActionContext = {
|
|
286
|
+
parentAction: awAction,
|
|
287
|
+
customAction: null,
|
|
288
|
+
variables: params,
|
|
289
|
+
returnValue: VelcronData_1.VelcronData.createDeferredPromise()
|
|
290
|
+
};
|
|
291
|
+
VelcronActions.parseAndExecuteActions(acArr, awAction, customActionContext);
|
|
292
|
+
promise = customActionContext.returnValue.promise;
|
|
293
|
+
hasCustomActionValue = true;
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
if (!awAction.nowait && promise || hasCustomActionValue && promise) {
|
|
297
|
+
promise.then((val) => {
|
|
298
|
+
let continueExecution = true;
|
|
299
|
+
//If action returns StopProcedingActions class in promise we will not continue executing actions
|
|
300
|
+
if (val && val instanceof ActionResults_1.CancelProcedingActions) {
|
|
301
|
+
continueExecution = false;
|
|
302
|
+
}
|
|
303
|
+
else if (val && val instanceof ActionResults_1.SkipSetValue) {
|
|
304
|
+
//Dont run evaluateSet, it has bee done inside the action
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
if (val) {
|
|
308
|
+
VelcronData_1.VelcronData.evaluateSet(awAction.path, val, awAction);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
callback(continueExecution);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
callback(true);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
else if (awAction.type === models_1.VelcronActionTypes.returnsValue) {
|
|
319
|
+
VelcronData_1.VelcronData.evaluateSet(VelcronConstants_1.VelcronConstants.events.returnValueVariableName, awAction.value, awAction);
|
|
320
|
+
callback(true);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
VelcronData_1.VelcronData.evaluateSet(awAction.path, awAction.value, awAction);
|
|
324
|
+
callback(true);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
static dataBindComputed(renderContext, template) {
|
|
328
|
+
if (typeof template === typeof undefined || template === null) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
let text = VelcronActions.parseAndExecuteComputed(renderContext, template);
|
|
332
|
+
text = VelcronData_1.VelcronData.dataBind(renderContext, text);
|
|
333
|
+
return text;
|
|
334
|
+
}
|
|
335
|
+
static parseAndExecuteComputed(renderContext, template) {
|
|
336
|
+
VelcronData_1.VelcronData.getTokens(template).forEach(token => {
|
|
337
|
+
const paramValues = [];
|
|
338
|
+
VelcronActions.parseFunction(renderContext.computed, token, renderContext, paramValues, (acName, params) => {
|
|
339
|
+
const funcContent = renderContext.computed[acName];
|
|
340
|
+
Object.keys(params).forEach((key) => {
|
|
341
|
+
params[key] = "currentCtx";
|
|
342
|
+
});
|
|
343
|
+
const toReplace = VelcronConstants_1.VelcronConstants.properties.tokenStart + token + VelcronConstants_1.VelcronConstants.properties.tokenEnd;
|
|
344
|
+
funcContent.forEach((c) => {
|
|
345
|
+
//const toEval = `return ${c}`;
|
|
346
|
+
const result = VelcronData_1.VelcronData.evauluateJs(c, renderContext, params);
|
|
347
|
+
template = template.replace(toReplace, result);
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
return template;
|
|
352
|
+
}
|
|
353
|
+
static extractParameterValues(template, action) {
|
|
354
|
+
const params = [];
|
|
355
|
+
let hasMoreParams = true;
|
|
356
|
+
let badCodeDetection = 0;
|
|
357
|
+
if (!template) {
|
|
358
|
+
return params;
|
|
359
|
+
}
|
|
360
|
+
while (hasMoreParams) {
|
|
361
|
+
template = template.trim();
|
|
362
|
+
if (template.startsWith(",")) {
|
|
363
|
+
template = template.substring(1);
|
|
364
|
+
}
|
|
365
|
+
template = template.trim();
|
|
366
|
+
if (template.startsWith("'")) {
|
|
367
|
+
//String parameter
|
|
368
|
+
template = template.substring(1);
|
|
369
|
+
if (template.indexOf("'") > -1) {
|
|
370
|
+
const subVal = template.substring(0, template.indexOf("'"));
|
|
371
|
+
params.push({ dataType: 0, value: VelcronData_1.VelcronData.dataBind(action, subVal) });
|
|
372
|
+
template = template.substring(subVal.length + 2);
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
VelcronLogger_1.VelcronLogger.logActionError(`Found an action parameter with a opening ' indicating string but did not find the ending ' on parameter: ${template}`);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
let subVal = template;
|
|
380
|
+
let castedValue;
|
|
381
|
+
if (subVal.indexOf("'") > -1 || subVal.indexOf(",") > -1) {
|
|
382
|
+
subVal = subVal.substring(0, subVal.indexOf(","));
|
|
383
|
+
}
|
|
384
|
+
let dataType;
|
|
385
|
+
subVal = subVal.trim();
|
|
386
|
+
if (VelcronData_1.VelcronData.isNumber(subVal)) {
|
|
387
|
+
dataType = VelcronActionParameterDataType.number;
|
|
388
|
+
castedValue = Number.parseInt(subVal);
|
|
389
|
+
}
|
|
390
|
+
else if (VelcronData_1.VelcronData.tryParseBoolean(subVal).is) {
|
|
391
|
+
dataType = VelcronActionParameterDataType.boolean;
|
|
392
|
+
castedValue = VelcronData_1.VelcronData.tryParseBoolean(subVal).value;
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
//Variable or DataContext binding
|
|
396
|
+
dataType = VelcronActionParameterDataType.pointer;
|
|
397
|
+
castedValue = subVal;
|
|
398
|
+
let rootName = "";
|
|
399
|
+
let procedingPath = "";
|
|
400
|
+
if (castedValue.indexOf(".") > -1) {
|
|
401
|
+
rootName = castedValue.substring(0, castedValue.indexOf("."));
|
|
402
|
+
procedingPath = castedValue.substring(castedValue.indexOf(".") + 1);
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
rootName = castedValue;
|
|
406
|
+
}
|
|
407
|
+
const isVar = VelcronData_1.VelcronData.getVariable(rootName, action);
|
|
408
|
+
if (isVar.is) {
|
|
409
|
+
//Its a variable
|
|
410
|
+
if (procedingPath) {
|
|
411
|
+
castedValue = VelcronData_1.VelcronData.getOrSetObjectByPath(isVar.value, procedingPath);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
castedValue = isVar.value;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
//Try get it from ViewModel
|
|
419
|
+
castedValue = VelcronData_1.VelcronData.getOrSetObjectByPathUsingRenderContext(action, castedValue);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
params.push({ dataType: dataType, value: castedValue });
|
|
423
|
+
template = template.substring(subVal.length);
|
|
424
|
+
}
|
|
425
|
+
if (template.length < 2) {
|
|
426
|
+
hasMoreParams = false;
|
|
427
|
+
}
|
|
428
|
+
if (badCodeDetection > 50) {
|
|
429
|
+
hasMoreParams = false;
|
|
430
|
+
VelcronLogger_1.VelcronLogger.logActionError("Bad parameter code detected! If you see this error please contact Andii :)");
|
|
431
|
+
}
|
|
432
|
+
badCodeDetection++;
|
|
433
|
+
}
|
|
434
|
+
return params;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
exports.VelcronActions = VelcronActions;
|
|
438
|
+
VelcronActions._actionHandlers = null;
|
|
439
|
+
var VelcronActionParameterDataType;
|
|
440
|
+
(function (VelcronActionParameterDataType) {
|
|
441
|
+
VelcronActionParameterDataType[VelcronActionParameterDataType["text"] = 0] = "text";
|
|
442
|
+
VelcronActionParameterDataType[VelcronActionParameterDataType["number"] = 1] = "number";
|
|
443
|
+
VelcronActionParameterDataType[VelcronActionParameterDataType["boolean"] = 2] = "boolean";
|
|
444
|
+
VelcronActionParameterDataType[VelcronActionParameterDataType["pointer"] = 3] = "pointer";
|
|
445
|
+
})(VelcronActionParameterDataType = exports.VelcronActionParameterDataType || (exports.VelcronActionParameterDataType = {}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const VelcronConstants: {
|
|
2
|
+
components: {
|
|
3
|
+
app: string;
|
|
4
|
+
view: string;
|
|
5
|
+
card: string;
|
|
6
|
+
text: string;
|
|
7
|
+
image: string;
|
|
8
|
+
button: string;
|
|
9
|
+
textInput: string;
|
|
10
|
+
progressCircle: string;
|
|
11
|
+
webView: string;
|
|
12
|
+
dialog: string;
|
|
13
|
+
section: string;
|
|
14
|
+
icon: string;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
idTokenStart: string;
|
|
18
|
+
idTokenEnd: string;
|
|
19
|
+
returnValueVariableName: string;
|
|
20
|
+
};
|
|
21
|
+
state: {
|
|
22
|
+
stateRootToken: string;
|
|
23
|
+
};
|
|
24
|
+
properties: {
|
|
25
|
+
tokenStart: string;
|
|
26
|
+
tokenEnd: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VelcronConstants = void 0;
|
|
4
|
+
exports.VelcronConstants = {
|
|
5
|
+
components: {
|
|
6
|
+
app: "App",
|
|
7
|
+
view: "View",
|
|
8
|
+
card: "Card",
|
|
9
|
+
text: "Text",
|
|
10
|
+
image: "Image",
|
|
11
|
+
button: "Button",
|
|
12
|
+
textInput: "TextInput",
|
|
13
|
+
progressCircle: "ProgressCircle",
|
|
14
|
+
webView: "WebView",
|
|
15
|
+
dialog: "Dialog",
|
|
16
|
+
section: "Section",
|
|
17
|
+
icon: "Icon"
|
|
18
|
+
},
|
|
19
|
+
events: {
|
|
20
|
+
idTokenStart: "$ev{",
|
|
21
|
+
idTokenEnd: "}",
|
|
22
|
+
returnValueVariableName: "$returnValue"
|
|
23
|
+
},
|
|
24
|
+
state: {
|
|
25
|
+
stateRootToken: "$state"
|
|
26
|
+
},
|
|
27
|
+
properties: {
|
|
28
|
+
tokenStart: "${",
|
|
29
|
+
tokenEnd: "}"
|
|
30
|
+
}
|
|
31
|
+
};
|