eligius 1.0.16 → 1.0.18

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.
@@ -1,5 +1,4 @@
1
- import { TOperationData } from '.';
2
- import { TOperation } from './types';
1
+ import { TOperation, TOperationData } from './types';
3
2
  /**
4
3
  * This operation checks if the current loop should end or start the next iteration.
5
4
  *
@@ -0,0 +1,2 @@
1
+ import { TOperation } from './types';
2
+ export declare const endWhen: TOperation<{}>;
@@ -0,0 +1,35 @@
1
+ import { IResolvedOperation } from '../../configuration/types';
2
+ /**
3
+ * This function can be used to find the index of a matching operation within a list of operations.
4
+ *
5
+ * Given the array of operations:
6
+ * ```ts
7
+ * [
8
+ * {systemName:'name1'}, // index 0
9
+ * {systemName:'startLoop'}, // index 1
10
+ * {systemName:'name2'}, // index 2
11
+ * {systemName:'startLoop'} // index 3
12
+ * {systemName:'name3'} // index 4
13
+ * {systemName:'endLoop'} // index 5
14
+ * {systemName:'endLoop'} // index 6
15
+ * {systemName:'name3'} // index 7
16
+ * ]
17
+ * ```
18
+ *
19
+ * Given the startLoop instance at index 1, this function will return index 6. Given the startLoop at index 3, it will yield index 5.
20
+ *
21
+ * Returns true when the given operation.systemName equals the specified matchingName and the current counter value is zero.
22
+ *
23
+ * If the matchingName matches operation.systemName but the counter is greater than zero, the counter is decremented.
24
+ *
25
+ * If the operation.systemName equal self (the name of the operation that requires to find its match), then counter is incremented.
26
+ *
27
+ * @param this
28
+ * @param operation
29
+ * @returns
30
+ */
31
+ export declare function findMatchingOperationIndex(this: {
32
+ counter: number;
33
+ self: string;
34
+ matchingName: string;
35
+ }, operation: IResolvedOperation): boolean;
@@ -0,0 +1 @@
1
+ export declare function removeGlobal(name: string): void;
@@ -1,2 +1,2 @@
1
- import { TOperationData } from '../../operation/types';
2
- export declare function resolveEventArguments(operationData: TOperationData, eventArgs?: any[]): any[] | undefined;
1
+ import { IOperationContext, TOperationData } from '../../operation/types';
2
+ export declare function resolveEventArguments(operationData: TOperationData, operationContext: IOperationContext, eventArgs?: any[]): any[] | undefined;
@@ -1,3 +1,4 @@
1
+ import { IOperationContext } from '../types';
1
2
  /**
2
3
  * Resolves operation and global data property chains.
3
4
  *
@@ -10,4 +11,4 @@
10
11
  * @param propertyChainOrRegularObject A period delimited string, or just a regular object
11
12
  * @returns
12
13
  */
13
- export declare function resolveOperationOrGlobalDataPropertyChain(sourceObject: any, propertyChainOrRegularObject: string | any): any;
14
+ export declare function resolveExternalPropertyChain(sourceObject: any, operationContext: IOperationContext, propertyChainOrRegularObject: any): any;
@@ -1,2 +1,2 @@
1
- import { TOperationData } from '../../operation/types';
2
- export declare function resolvePropertyValues<T extends TOperationData>(operationData: T, properties: Record<string, any>): T;
1
+ import { IOperationContext, TOperationData } from '../../operation/types';
2
+ export declare function resolvePropertyValues<T extends TOperationData>(operationData: T, operationContext: IOperationContext, properties: Record<string, any>): T;
@@ -10,6 +10,7 @@ export { createElement } from './create-element';
10
10
  export { customFunction } from './custom-function';
11
11
  export { endAction } from './end-action';
12
12
  export { endLoop } from './end-loop';
13
+ export { endWhen } from './end-when';
13
14
  export { extendController } from './extend-controller';
14
15
  export { getControllerFromElement } from './get-controller-from-element';
15
16
  export { getControllerInstance } from './get-controller-instance';
@@ -20,6 +21,7 @@ export { invokeObjectMethod } from './invoke-object-method';
20
21
  export { loadJSON } from './load-json';
21
22
  export { log } from './log';
22
23
  export { math } from './math';
24
+ export { otherwise } from './otherwise';
23
25
  export { removeClass } from './remove-class';
24
26
  export { removeControllerFromElement } from './remove-controller-from-element';
25
27
  export { removeElement } from './remove-element';
@@ -39,3 +41,4 @@ export { toggleClass } from './toggle-class';
39
41
  export { toggleElement } from './toggle-element';
40
42
  export * from './types';
41
43
  export { wait } from './wait';
44
+ export { when } from './when';
@@ -0,0 +1,3 @@
1
+ import { IOperationMetadata } from './types';
2
+ declare function endWhen(): IOperationMetadata<never>;
3
+ export default endWhen;
@@ -10,6 +10,7 @@ export { default as createElement } from './create-element';
10
10
  export { default as customFunction } from './custom-function';
11
11
  export { default as endAction } from './end-action';
12
12
  export { default as endLoop } from './end-loop';
13
+ export { default as endWhen } from './end-when';
13
14
  export { default as extendController } from './extend-controller';
14
15
  export { default as getControllerFromElement } from './get-controller-from-element';
15
16
  export { default as getControllerInstance } from './get-controller-instance';
@@ -20,6 +21,7 @@ export { default as invokeObjectMethod } from './invoke-object-method';
20
21
  export { default as loadJSON } from './load-json';
21
22
  export { default as log } from './log';
22
23
  export { default as math } from './math';
24
+ export { default as otherwise } from './otherwise';
23
25
  export { default as removeClass } from './remove-class';
24
26
  export { default as removeControllerFromElement } from './remove-controller-from-element';
25
27
  export { default as removeElement } from './remove-element';
@@ -38,3 +40,4 @@ export { default as startLoop } from './start-loop';
38
40
  export { default as toggleClass } from './toggle-class';
39
41
  export { default as toggleElement } from './toggle-element';
40
42
  export { default as wait } from './wait';
43
+ export { default as when } from './when';
@@ -0,0 +1,3 @@
1
+ import { IOperationMetadata } from './types';
2
+ declare function otherwise(): IOperationMetadata<never>;
3
+ export default otherwise;
@@ -26,4 +26,4 @@ export interface IOperationMetadata<T> {
26
26
  properties?: TPropertiesMetadata<T>;
27
27
  outputProperties?: TPropertiesMetadata<T>;
28
28
  }
29
- export declare type TParameterTypes = 'ParameterType:htmlElementName' | 'ParameterType:className' | 'ParameterType:selector' | 'ParameterType:string' | 'ParameterType:number' | 'ParameterType:object' | 'ParameterType:boolean' | 'ParameterType:array' | 'ParameterType:eventTopic' | 'ParameterType:eventName' | 'ParameterType:systemName' | 'ParameterType:actionName' | 'ParameterType:controllerName' | 'ParameterType:dimensions' | 'ParameterType:dimensionsModifier' | 'ParameterType:url' | 'ParameterType:htmlContent' | 'ParameterType:labelId' | 'ParameterType:ImagePath' | 'ParameterType:QuadrantPosition' | 'ParameterType:jQuery';
29
+ export declare type TParameterTypes = 'ParameterType:htmlElementName' | 'ParameterType:className' | 'ParameterType:selector' | 'ParameterType:string' | 'ParameterType:number' | 'ParameterType:object' | 'ParameterType:boolean' | 'ParameterType:array' | 'ParameterType:eventTopic' | 'ParameterType:eventName' | 'ParameterType:systemName' | 'ParameterType:actionName' | 'ParameterType:controllerName' | 'ParameterType:dimensions' | 'ParameterType:dimensionsModifier' | 'ParameterType:url' | 'ParameterType:htmlContent' | 'ParameterType:labelId' | 'ParameterType:ImagePath' | 'ParameterType:QuadrantPosition' | 'ParameterType:jQuery' | 'ParameterType:expression';
@@ -0,0 +1,4 @@
1
+ import { IWhenOperationData } from '../../operation/when';
2
+ import { IOperationMetadata } from './types';
3
+ declare function wait(): IOperationMetadata<IWhenOperationData>;
4
+ export default wait;
@@ -0,0 +1,2 @@
1
+ import { TOperation } from './types';
2
+ export declare const otherwise: TOperation<{}>;
@@ -1,13 +1,12 @@
1
1
  import { TOperation } from './types';
2
2
  export declare type TStartLoopOperationData = {
3
3
  collection: any[] | string;
4
- currentItem: any;
5
4
  };
6
5
  /**
7
6
  * This operation starts a loop using the given collection.
8
7
  *
9
8
  * Each iteration the current item from the specified collection is
10
- * assigned to the `currentItem` property on the current operation data.
9
+ * assigned to the `currentItem` property on the operation context.
11
10
  *
12
11
  * @param operationData
13
12
  * @returns
@@ -1,13 +1,51 @@
1
+ import { IResolvedOperation } from '../configuration/types';
1
2
  import { IEventbus } from '../eventbus';
2
3
  export declare type TOperationData = Record<string, any>;
3
4
  export declare type TOperationResult<T = TOperationData> = Promise<T> | T;
4
5
  export interface IOperationContext {
6
+ /**
7
+ * When inside a loop, this is the current iteration of said loop
8
+ */
5
9
  loopIndex?: number;
10
+ /**
11
+ * The number of iterations for the current loop
12
+ */
6
13
  loopLength?: number;
7
- startIndex?: number;
14
+ /**
15
+ * The start index of the loop within the total number of operations
16
+ */
17
+ loopStartIndex?: number;
18
+ /**
19
+ * The end index of the loop within the total number of operations
20
+ */
21
+ loopEndIndex?: number;
22
+ /**
23
+ * Set this index to change the current item in the main operations loop
24
+ */
8
25
  newIndex?: number;
26
+ /**
27
+ * The current index with in the main operations loop
28
+ */
9
29
  currentIndex: number;
10
- skipNextOperation?: boolean;
30
+ /**
31
+ * The eventbus instance shared amongst actions and operations
32
+ */
11
33
  eventbus: IEventbus;
34
+ /**
35
+ * The list of operations that is currently being executed
36
+ */
37
+ operations: IResolvedOperation[];
38
+ /**
39
+ * The result of the last when evaluation, if any
40
+ */
41
+ whenEvaluation?: boolean;
42
+ /**
43
+ *
44
+ */
45
+ owner?: any;
46
+ /**
47
+ *
48
+ */
49
+ currentItem?: any;
12
50
  }
13
51
  export declare type TOperation<T = TOperationData> = (this: IOperationContext, operationData: T) => TOperationResult<T>;
@@ -1,8 +1,8 @@
1
1
  import { TOperation } from './types';
2
- /**
3
- *
4
- */
5
2
  export interface IWaitOperationData {
3
+ /**
4
+ * The amount of milliseconds the operation will wait for.
5
+ */
6
6
  milliseconds: number;
7
7
  }
8
8
  /**
@@ -0,0 +1,17 @@
1
+ import { TOperation } from './types';
2
+ declare type TOperator = '!=' | '==' | '>=' | '<=' | '>' | '<';
3
+ declare type TValue = `'${string}'` | number | `operationdata.${string}` | `globaldata.${string}`;
4
+ declare type TExpression = `${TValue}${TOperator}${TValue}`;
5
+ export interface IWhenOperationData {
6
+ expression: TExpression;
7
+ }
8
+ /**
9
+ * When the given expression evaluates to false, subsequent operations will be skipped
10
+ * until an `endWhen` operation is encountered.
11
+ * Practically, this mean an `if` statement control flow implementation in a list of operations.
12
+ *
13
+ * @param operationData
14
+ * @returns
15
+ */
16
+ export declare const when: TOperation<IWhenOperationData>;
17
+ export {};
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.16",
2
+ "version": "1.0.18",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "homepage": "https://rolandzwaga.github.io/eligius/",
@@ -16,6 +16,7 @@
16
16
  "dev": "dts watch",
17
17
  "build": "dts build",
18
18
  "test": "cross-env TS_NODE_PROJECT=tsconfig.test.json uvu -r ts-node/register -r jsdom-global/register src/test",
19
+ "test:watch": "watchlist src test -- yarn test",
19
20
  "check": "tsc --pretty --noEmit",
20
21
  "lint": "dts lint",
21
22
  "prepare": "dts build",
@@ -50,7 +51,7 @@
50
51
  "@types/jasmine": "4.3.0",
51
52
  "@types/jquery": "3.5.14",
52
53
  "@types/jsdom": "^20.0.0",
53
- "@types/node": "18.11.7",
54
+ "@types/node": "18.11.9",
54
55
  "@types/sinon": "10.0.13",
55
56
  "@types/uuid": "8.3.4",
56
57
  "acorn": "8.8.1",
@@ -64,7 +65,7 @@
64
65
  "fs-extra": "10.1.0",
65
66
  "husky": "8.0.1",
66
67
  "jquery": "3.6.1",
67
- "jsdom": "20.0.1",
68
+ "jsdom": "20.0.2",
68
69
  "jsdom-global": "3.0.2",
69
70
  "lottie-web": "5.9.6",
70
71
  "mediaelement": "5.1.0",
@@ -73,11 +74,12 @@
73
74
  "ts-morph": "16.0.0",
74
75
  "ts-node": "10.9.1",
75
76
  "tsconfig-paths": "4.1.0",
76
- "tslib": "2.4.0",
77
+ "tslib": "2.4.1",
77
78
  "typedoc": "0.23.19",
78
79
  "typedoc-plugin-missing-exports": "1.0.0",
79
80
  "typescript": "4.8.4",
80
- "uvu": "0.5.6"
81
+ "uvu": "0.5.6",
82
+ "watchlist": "0.3.1"
81
83
  },
82
84
  "peerDependencies": {
83
85
  "jquery": "3.6.1",