@kynesyslabs/demosdk 1.1.5 → 1.1.7
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 +0 -4
- package/build/demoswork/executor/conditionalExecutor.d.ts +3 -0
- package/build/demoswork/executor/conditionalExecutor.js +30 -0
- package/build/demoswork/executor/conditionalExecutor.js.map +1 -0
- package/build/demoswork/executor/index.d.ts +2 -0
- package/build/demoswork/executor/index.js +26 -0
- package/build/demoswork/executor/index.js.map +1 -0
- package/build/demoswork/executor/stepexecutor.d.ts +18 -0
- package/build/demoswork/executor/stepexecutor.js +53 -0
- package/build/demoswork/executor/stepexecutor.js.map +1 -0
- package/build/demoswork/index.d.ts +0 -0
- package/build/demoswork/index.js +3 -0
- package/build/demoswork/index.js.map +1 -0
- package/build/demoswork/operations/conditional.d.ts +18 -0
- package/build/demoswork/operations/conditional.js +90 -0
- package/build/demoswork/operations/conditional.js.map +1 -0
- package/build/demoswork/operations/index.d.ts +10 -0
- package/build/demoswork/operations/index.js +22 -0
- package/build/demoswork/operations/index.js.map +1 -0
- package/build/demoswork/utils.d.ts +30 -0
- package/build/demoswork/utils.js +72 -0
- package/build/demoswork/utils.js.map +1 -0
- package/build/demoswork/validator/index.d.ts +7 -0
- package/build/demoswork/validator/index.js +13 -0
- package/build/demoswork/validator/index.js.map +1 -0
- package/build/demoswork/validator/steps.validator.d.ts +8 -0
- package/build/demoswork/validator/steps.validator.js +52 -0
- package/build/demoswork/validator/steps.validator.js.map +1 -0
- package/build/demoswork/work.d.ts +12 -0
- package/build/demoswork/work.js +56 -0
- package/build/demoswork/work.js.map +1 -0
- package/build/demoswork/workstep.d.ts +63 -0
- package/build/demoswork/workstep.js +93 -0
- package/build/demoswork/workstep.js.map +1 -0
- package/build/demoswork/xmscript.d.ts +1 -0
- package/build/demoswork/xmscript.js +10 -0
- package/build/demoswork/xmscript.js.map +1 -0
- package/build/multichain/core/ibc.js +2 -16
- package/build/multichain/core/ibc.js.map +1 -1
- package/build/multichain/core/multiversx.d.ts +5 -5
- package/build/multichain/core/multiversx.js +13 -79
- package/build/multichain/core/multiversx.js.map +1 -1
- package/build/multichain/core/solana.js +2 -6
- package/build/multichain/core/solana.js.map +1 -1
- package/build/multichain/core/types/SolanaPhantomProvider.d.ts +25 -0
- package/build/multichain/core/types/SolanaPhantomProvider.js +5 -0
- package/build/multichain/core/types/SolanaPhantomProvider.js.map +1 -0
- package/build/multichain/core/types/interfaces.d.ts +6 -0
- package/build/multichain/core/xrp.js +0 -8
- package/build/multichain/core/xrp.js.map +1 -1
- package/build/multichain/websdk/multiversx.d.ts +5 -4
- package/build/multichain/websdk/multiversx.js +15 -3
- package/build/multichain/websdk/multiversx.js.map +1 -1
- package/build/multichain/websdk/solana.d.ts +15 -0
- package/build/multichain/websdk/solana.js +82 -1
- package/build/multichain/websdk/solana.js.map +1 -1
- package/build/types/demoswork/index.d.ts +14 -0
- package/build/types/demoswork/index.js +3 -0
- package/build/types/demoswork/index.js.map +1 -0
- package/build/types/demoswork/operations.d.ts +10 -0
- package/build/types/demoswork/operations.js +3 -0
- package/build/types/demoswork/operations.js.map +1 -0
- package/build/types/demoswork/steps.d.ts +54 -0
- package/build/types/demoswork/steps.js +18 -0
- package/build/types/demoswork/steps.js.map +1 -0
- package/build/types/demoswork/types.d.ts +4 -0
- package/build/types/demoswork/types.js +8 -0
- package/build/types/demoswork/types.js.map +1 -0
- package/build/types/demoswork/web2.d.ts +4 -0
- package/build/types/demoswork/web2.js +3 -0
- package/build/types/demoswork/web2.js.map +1 -0
- package/build/utils/pprint.d.ts +5 -0
- package/build/utils/pprint.js +15 -0
- package/build/utils/pprint.js.map +1 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
const stepexecutor_1 = require("./stepexecutor");
|
|
5
|
+
async function default_1(work, operation) {
|
|
6
|
+
for (const condition of operation.conditions) {
|
|
7
|
+
// INFO: operator will be null if the value is pre-computed
|
|
8
|
+
// or if the condition is an else block
|
|
9
|
+
if (condition.operator === null) {
|
|
10
|
+
// else condition block has no value
|
|
11
|
+
if (condition.value === null) {
|
|
12
|
+
await (0, stepexecutor_1.executeStep)(work, condition.do.uid);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
// Pro-computed value
|
|
16
|
+
if (condition.value) {
|
|
17
|
+
await (0, stepexecutor_1.executeStep)(work, condition.do.uid);
|
|
18
|
+
}
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const result = await (0, stepexecutor_1.getStepResult)(work, condition.stepUID);
|
|
22
|
+
const resolvedValue = (0, utils_1.getValue)(result, condition.key);
|
|
23
|
+
console.log(`Comparing resolved value: ${resolvedValue}, with condition value: ${condition.value}, using operator: ${condition.operator}`);
|
|
24
|
+
if ((0, utils_1.compare)(resolvedValue, condition.value, condition.operator)) {
|
|
25
|
+
await (0, stepexecutor_1.executeStep)(work, condition.do.uid);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = default_1;
|
|
30
|
+
//# sourceMappingURL=conditionalExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditionalExecutor.js","sourceRoot":"","sources":["../../../../src/demoswork/executor/conditionalExecutor.ts"],"names":[],"mappings":";;AACA,oCAA4C;AAC5C,iDAA2D;AAG5C,KAAK,oBAAW,IAAe,EAAE,SAA4B;IACxE,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QAC3C,2DAA2D;QAC3D,uCAAuC;QACvC,IAAI,SAAS,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC9B,oCAAoC;YACpC,IAAI,SAAS,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC3B,MAAM,IAAA,0BAAW,EAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;gBACzC,SAAQ;YACZ,CAAC;YAED,qBAAqB;YACrB,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;gBAClB,MAAM,IAAA,0BAAW,EAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;YAC7C,CAAC;YACD,SAAQ;QACZ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAA,4BAAa,EAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;QAC3D,MAAM,aAAa,GAAG,IAAA,gBAAQ,EAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;QAErD,OAAO,CAAC,GAAG,CACP,6BAA6B,aAAa,2BAA2B,SAAS,CAAC,KAAK,qBAAqB,SAAS,CAAC,QAAQ,EAAE,CAChI,CAAA;QAED,IAAI,IAAA,eAAO,EAAC,aAAa,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9D,MAAM,IAAA,0BAAW,EAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;QAC7C,CAAC;IACL,CAAC;AACL,CAAC;AA7BD,4BA6BC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const conditionalExecutor_1 = __importDefault(require("./conditionalExecutor"));
|
|
7
|
+
async function default_1(work) {
|
|
8
|
+
// TODO! Rewrite forEach to for...of
|
|
9
|
+
for (const operationUID of work.script.operationOrder) {
|
|
10
|
+
const operation = work.script.operations[operationUID];
|
|
11
|
+
if (!operation) {
|
|
12
|
+
throw new Error(`Operation with UID ${operationUID} not found in the XMScript`);
|
|
13
|
+
}
|
|
14
|
+
switch (operation.operationType) {
|
|
15
|
+
case "conditional":
|
|
16
|
+
console.log("Executing conditional operation with UID:", operationUID);
|
|
17
|
+
await (0, conditionalExecutor_1.default)(work, operation);
|
|
18
|
+
break;
|
|
19
|
+
default:
|
|
20
|
+
throw new Error("Unknown operation type" + operation.operationType);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return work.results;
|
|
24
|
+
}
|
|
25
|
+
exports.default = default_1;
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/demoswork/executor/index.ts"],"names":[],"mappings":";;;;;AAKA,gFAAsD;AAEvC,KAAK,oBAAW,IAAe;IAC1C,oCAAoC;IACpC,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QACpD,MAAM,SAAS,GAAoB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;QAEvE,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACX,sBAAsB,YAAY,4BAA4B,CACjE,CAAA;QACL,CAAC;QAED,QAAQ,SAAS,CAAC,aAAa,EAAE,CAAC;YAC9B,KAAK,aAAa;gBACd,OAAO,CAAC,GAAG,CACP,2CAA2C,EAC3C,YAAY,CACf,CAAA;gBACD,MAAM,IAAA,6BAAkB,EAAC,IAAI,EAAE,SAA8B,CAAC,CAAA;gBAC9D,MAAK;YAET;gBACI,MAAM,IAAI,KAAK,CACX,wBAAwB,GAAG,SAAS,CAAC,aAAa,CACrD,CAAA;QACT,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAA;AACvB,CAAC;AA5BD,4BA4BC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DemosWork } from "../work";
|
|
2
|
+
/**
|
|
3
|
+
* Execute a step and write the output to the work instance.
|
|
4
|
+
*
|
|
5
|
+
* @param work The work instance
|
|
6
|
+
* @param stepUID The UID of the step to execute
|
|
7
|
+
* @returns The result of the step
|
|
8
|
+
*/
|
|
9
|
+
export declare function executeStep(work: DemosWork, stepUID: string): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Get the result of a step from the work instance.
|
|
12
|
+
* If not found, execute the step and return the result.
|
|
13
|
+
*
|
|
14
|
+
* @param work The work instance
|
|
15
|
+
* @param stepUID The step UID
|
|
16
|
+
* @returns The result of the step
|
|
17
|
+
*/
|
|
18
|
+
export declare function getStepResult(work: DemosWork, stepUID: string): Promise<any>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStepResult = exports.executeStep = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Execute a step and write the output to the work instance.
|
|
6
|
+
*
|
|
7
|
+
* @param work The work instance
|
|
8
|
+
* @param stepUID The UID of the step to execute
|
|
9
|
+
* @returns The result of the step
|
|
10
|
+
*/
|
|
11
|
+
async function executeStep(work, stepUID) {
|
|
12
|
+
// INFO: Execute the step here and write the output to the work instance.
|
|
13
|
+
// Process:
|
|
14
|
+
// 1. Find the step from work.steps map
|
|
15
|
+
// 2. Determine the type of the step
|
|
16
|
+
// 3. Route execution to the appropriate executor function (TODO)
|
|
17
|
+
// 4. Write the output to the work instance
|
|
18
|
+
// REVIEW: Which is better?
|
|
19
|
+
// Pass the work instance to this function and write the output to the work instance from here,
|
|
20
|
+
// OR:
|
|
21
|
+
// Pass the actual step to this function and return the output to the caller?
|
|
22
|
+
console.log("Executing step", stepUID);
|
|
23
|
+
work.results[stepUID] = {
|
|
24
|
+
output: {
|
|
25
|
+
result: "error",
|
|
26
|
+
statusCode: 200,
|
|
27
|
+
payload: {
|
|
28
|
+
message: "Hello, World!",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
return work.results[stepUID];
|
|
33
|
+
}
|
|
34
|
+
exports.executeStep = executeStep;
|
|
35
|
+
/**
|
|
36
|
+
* Get the result of a step from the work instance.
|
|
37
|
+
* If not found, execute the step and return the result.
|
|
38
|
+
*
|
|
39
|
+
* @param work The work instance
|
|
40
|
+
* @param stepUID The step UID
|
|
41
|
+
* @returns The result of the step
|
|
42
|
+
*/
|
|
43
|
+
async function getStepResult(work, stepUID) {
|
|
44
|
+
let result = work.results[stepUID];
|
|
45
|
+
if (result) {
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
// INFO: If the step result is not found, execute the step
|
|
49
|
+
console.log(`Step with UID ${stepUID} not found in work results. Executing it now.`);
|
|
50
|
+
return await executeStep(work, stepUID);
|
|
51
|
+
}
|
|
52
|
+
exports.getStepResult = getStepResult;
|
|
53
|
+
//# sourceMappingURL=stepexecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepexecutor.js","sourceRoot":"","sources":["../../../../src/demoswork/executor/stepexecutor.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACI,KAAK,UAAU,WAAW,CAAC,IAAe,EAAE,OAAe;IAC9D,yEAAyE;IACzE,WAAW;IACX,uCAAuC;IACvC,oCAAoC;IACpC,iEAAiE;IACjE,2CAA2C;IAE3C,2BAA2B;IAC3B,+FAA+F;IAC/F,MAAM;IACN,6EAA6E;IAE7E,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IACtC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG;QACpB,MAAM,EAAE;YACJ,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,GAAG;YACf,OAAO,EAAE;gBACL,OAAO,EAAE,eAAe;aAC3B;SACJ;KACJ,CAAA;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC;AAzBD,kCAyBC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,aAAa,CAAC,IAAe,EAAE,OAAe;IAChE,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAElC,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,0DAA0D;IAC1D,OAAO,CAAC,GAAG,CACP,iBAAiB,OAAO,+CAA+C,CAC1E,CAAA;IACD,OAAO,MAAM,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AAC3C,CAAC;AAZD,sCAYC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/demoswork/index.ts"],"names":[],"mappings":";AAAA,+BAA+B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Operation } from ".";
|
|
2
|
+
import { WorkStep } from "../workstep";
|
|
3
|
+
import { DemoScript } from "../../types/demoswork";
|
|
4
|
+
import { OperationType } from "../../types/demoswork/operations";
|
|
5
|
+
import { Conditional as C, Condition } from "../../types/demoswork/steps";
|
|
6
|
+
export declare class Conditional extends Operation {
|
|
7
|
+
operationScript: {
|
|
8
|
+
operationUID: string;
|
|
9
|
+
operationType: OperationType;
|
|
10
|
+
conditions: C[];
|
|
11
|
+
};
|
|
12
|
+
constructor(script: DemoScript, condition: boolean | Condition);
|
|
13
|
+
appendCondition(condition: boolean | Condition): number;
|
|
14
|
+
writeToScript(): void;
|
|
15
|
+
then(step: WorkStep): any;
|
|
16
|
+
elif(condition: boolean | Condition): any;
|
|
17
|
+
else(step: WorkStep): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Conditional = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
class Conditional extends _1.Operation {
|
|
6
|
+
// INFO: A condition can be a boolean (pre-computed) or a condition object (to be computed on runtime)
|
|
7
|
+
// REVIEW: if the condition is a boolean false, then it will never be executed. So, can we omit it from the script?
|
|
8
|
+
constructor(script, condition) {
|
|
9
|
+
super(script);
|
|
10
|
+
this.operationScript.operationType = "conditional";
|
|
11
|
+
if (typeof condition === "object") {
|
|
12
|
+
console.log("inside conditional", condition);
|
|
13
|
+
this.addStep(condition.step);
|
|
14
|
+
}
|
|
15
|
+
this.operationScript = {
|
|
16
|
+
...this.operationScript,
|
|
17
|
+
conditions: [],
|
|
18
|
+
};
|
|
19
|
+
this.appendCondition(condition);
|
|
20
|
+
this.writeToScript();
|
|
21
|
+
}
|
|
22
|
+
appendCondition(condition) {
|
|
23
|
+
// INFO: If the condition is a boolean, create a value only condition
|
|
24
|
+
if (typeof condition === "boolean") {
|
|
25
|
+
return this.operationScript.conditions.push({
|
|
26
|
+
operator: null,
|
|
27
|
+
key: null,
|
|
28
|
+
value: condition,
|
|
29
|
+
stepUID: null,
|
|
30
|
+
do: null,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// INFO: If the condition is an object, create a condition object
|
|
34
|
+
return this.operationScript.conditions.push({
|
|
35
|
+
operator: condition.operator,
|
|
36
|
+
key: condition.key,
|
|
37
|
+
value: condition.value,
|
|
38
|
+
stepUID: condition.step.workUID,
|
|
39
|
+
do: {
|
|
40
|
+
type: "step",
|
|
41
|
+
uid: null,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
writeToScript() {
|
|
46
|
+
this.script.operations[this.operationScript.operationUID] =
|
|
47
|
+
this.operationScript;
|
|
48
|
+
this.script.operationOrder.add(this.operationScript.operationUID);
|
|
49
|
+
// TODO: Remove all step outputs
|
|
50
|
+
}
|
|
51
|
+
then(step) {
|
|
52
|
+
this.addStep(step);
|
|
53
|
+
const op_length = this.operationScript.conditions.length;
|
|
54
|
+
this.operationScript.conditions[op_length - 1].do = {
|
|
55
|
+
type: "step",
|
|
56
|
+
uid: step.workUID,
|
|
57
|
+
};
|
|
58
|
+
this.writeToScript();
|
|
59
|
+
return {
|
|
60
|
+
elif: this.elif.bind(this),
|
|
61
|
+
else: this.else.bind(this),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
elif(condition) {
|
|
65
|
+
if (typeof condition === "object") {
|
|
66
|
+
console.log("inside conditional", condition);
|
|
67
|
+
this.addStep(condition.step);
|
|
68
|
+
}
|
|
69
|
+
this.appendCondition(condition);
|
|
70
|
+
return {
|
|
71
|
+
then: this.then.bind(this),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
else(step) {
|
|
75
|
+
this.addStep(step);
|
|
76
|
+
this.operationScript.conditions.push({
|
|
77
|
+
operator: null,
|
|
78
|
+
key: null,
|
|
79
|
+
value: null,
|
|
80
|
+
stepUID: null,
|
|
81
|
+
do: {
|
|
82
|
+
type: "step",
|
|
83
|
+
uid: step.workUID,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
this.writeToScript();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.Conditional = Conditional;
|
|
90
|
+
//# sourceMappingURL=conditional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../../../src/demoswork/operations/conditional.ts"],"names":[],"mappings":";;;AAAA,wBAA6B;AAS7B,MAAa,WAAY,SAAQ,YAAS;IAOtC,sGAAsG;IACtG,mHAAmH;IACnH,YAAY,MAAkB,EAAE,SAA8B;QAC1D,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,IAAI,CAAC,eAAe,CAAC,aAAa,GAAG,aAAa,CAAA;QAElD,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAA;YAC5C,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC;QAED,IAAI,CAAC,eAAe,GAAG;YACnB,GAAG,IAAI,CAAC,eAAe;YACvB,UA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,IAAI,EAAE,MAAM;YACZ,GAAG,EAAE,IAAI,CAAC,OAAO;SACpB,CAAA;QACD,IAAI,CAAC,aAAa,EAAE,CAAA;QAEpB,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1B,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SAC7B,CAAA;IACL,CAAC;IAED,IAAI,CAAC,SAA8B;QAC/B,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAA;YAC5C,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;QAE/B,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SAC7B,CAAA;IACL,CAAC;IAED,IAAI,CAAC,IAAc;QACf,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAClB,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC;YACjC,QAAQ,EAAE,IAAI;YACd,GAAG,EAAE,IAAI;YACT,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;YACb,EAAE,EAAE;gBACA,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,IAAI,CAAC,OAAO;aACpB;SACJ,CAAC,CAAA;QAEF,IAAI,CAAC,aAAa,EAAE,CAAA;IACxB,CAAC;CACJ;AApGD,kCAoGC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DemoScript } from "../../types/demoswork";
|
|
2
|
+
import { OperationScript } from "../../types/demoswork/operations";
|
|
3
|
+
import { WorkStep } from "../workstep";
|
|
4
|
+
export declare class Operation {
|
|
5
|
+
script: DemoScript;
|
|
6
|
+
operationScript: OperationScript;
|
|
7
|
+
constructor(script: DemoScript);
|
|
8
|
+
addStep(step: WorkStep): void;
|
|
9
|
+
execute(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Operation = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
class Operation {
|
|
6
|
+
constructor(script) {
|
|
7
|
+
this.operationScript = {
|
|
8
|
+
operationUID: "",
|
|
9
|
+
operationType: "",
|
|
10
|
+
};
|
|
11
|
+
this.script = script;
|
|
12
|
+
this.operationScript.operationUID = (0, utils_1.getNewUID)();
|
|
13
|
+
}
|
|
14
|
+
addStep(step) {
|
|
15
|
+
this.script.steps[step.workUID] = step;
|
|
16
|
+
}
|
|
17
|
+
execute() {
|
|
18
|
+
throw new Error("Method not implemented.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.Operation = Operation;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/demoswork/operations/index.ts"],"names":[],"mappings":";;;AAGA,oCAAoC;AAGpC,MAAa,SAAS;IAOlB,YAAY,MAAkB;QAL9B,oBAAe,GAAoB;YAC/B,YAAY,EAAE,EAAE;YAChB,aAAa,EAAiB,EAAE;SACnC,CAAA;QAGG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,eAAe,CAAC,YAAY,GAAG,IAAA,iBAAS,GAAE,CAAA;IACnD,CAAC;IAED,OAAO,CAAC,IAAc;QAClB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;IAC1C,CAAC;IAED,OAAO;QACH,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;CACJ;AAnBD,8BAmBC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { operators } from "../types/demoswork/types";
|
|
2
|
+
import { stepKeys } from "../types/demoswork/steps";
|
|
3
|
+
import { WorkStep } from "./workstep";
|
|
4
|
+
export declare function getNewUID(): any;
|
|
5
|
+
export declare function equalTo(step: WorkStep, key: stepKeys, value: any): {
|
|
6
|
+
step: WorkStep;
|
|
7
|
+
operator: operators;
|
|
8
|
+
key: "output.result" | "output.hash";
|
|
9
|
+
value: any;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Get the value of a property given a path in an object.
|
|
13
|
+
* The path should be a string of property names separated by dots.
|
|
14
|
+
*
|
|
15
|
+
* @param obj The object to traverse
|
|
16
|
+
* @param path The path of the property to get
|
|
17
|
+
* @returns The value of the property at the path
|
|
18
|
+
*
|
|
19
|
+
* @example getValue(myObject, "nested.property")
|
|
20
|
+
*/
|
|
21
|
+
export declare function getValue(obj: Object, path: string): Object;
|
|
22
|
+
/**
|
|
23
|
+
* Compare two values using the specified operator
|
|
24
|
+
*
|
|
25
|
+
* @param a First value
|
|
26
|
+
* @param b Second value
|
|
27
|
+
* @param operator Comparison operator
|
|
28
|
+
* @returns The result of the comparison (boolean)
|
|
29
|
+
*/
|
|
30
|
+
export declare function compare(a: any, b: any, operator: string, validate_only?: boolean): boolean;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compare = exports.getValue = exports.equalTo = exports.getNewUID = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
function getNewUID() {
|
|
6
|
+
return (0, uuid_1.v4)();
|
|
7
|
+
}
|
|
8
|
+
exports.getNewUID = getNewUID;
|
|
9
|
+
function equalTo(step, key, value) {
|
|
10
|
+
return {
|
|
11
|
+
step,
|
|
12
|
+
operator: "==",
|
|
13
|
+
key,
|
|
14
|
+
value,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.equalTo = equalTo;
|
|
18
|
+
/**
|
|
19
|
+
* Get the value of a property given a path in an object.
|
|
20
|
+
* The path should be a string of property names separated by dots.
|
|
21
|
+
*
|
|
22
|
+
* @param obj The object to traverse
|
|
23
|
+
* @param path The path of the property to get
|
|
24
|
+
* @returns The value of the property at the path
|
|
25
|
+
*
|
|
26
|
+
* @example getValue(myObject, "nested.property")
|
|
27
|
+
*/
|
|
28
|
+
function getValue(obj, path) {
|
|
29
|
+
// Split the path string into an array of property names
|
|
30
|
+
const properties = path.split(".");
|
|
31
|
+
// Traverse the object using the property names
|
|
32
|
+
let value = obj;
|
|
33
|
+
for (const prop of properties) {
|
|
34
|
+
if (value && typeof value === "object") {
|
|
35
|
+
value = value[prop];
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return undefined; // Return undefined if the property doesn't exist
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
exports.getValue = getValue;
|
|
44
|
+
/**
|
|
45
|
+
* Compare two values using the specified operator
|
|
46
|
+
*
|
|
47
|
+
* @param a First value
|
|
48
|
+
* @param b Second value
|
|
49
|
+
* @param operator Comparison operator
|
|
50
|
+
* @returns The result of the comparison (boolean)
|
|
51
|
+
*/
|
|
52
|
+
function compare(a, b, operator, validate_only = false) {
|
|
53
|
+
const operations = {
|
|
54
|
+
">": (a, b) => a > b,
|
|
55
|
+
">=": (a, b) => a >= b,
|
|
56
|
+
"<": (a, b) => a < b,
|
|
57
|
+
"<=": (a, b) => a <= b,
|
|
58
|
+
"==": (a, b) => a == b,
|
|
59
|
+
"===": (a, b) => a === b,
|
|
60
|
+
"!=": (a, b) => a != b,
|
|
61
|
+
"!==": (a, b) => a !== b,
|
|
62
|
+
};
|
|
63
|
+
if (!operations.hasOwnProperty(operator)) {
|
|
64
|
+
throw new Error("Invalid operator:" + operator);
|
|
65
|
+
}
|
|
66
|
+
if (validate_only) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return operations[operator](a, b);
|
|
70
|
+
}
|
|
71
|
+
exports.compare = compare;
|
|
72
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/demoswork/utils.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAMnC,SAAgB,SAAS;IACrB,OAAO,IAAA,SAAM,GAAE,CAAA;AACnB,CAAC;AAFD,8BAEC;AAED,SAAgB,OAAO,CAAC,IAAc,EAAE,GAAa,EAAE,KAAU;IAC7D,OAAO;QACH,IAAI;QACJ,QAAQ,EAAa,IAAI;QACzB,GAAG;QACH,KAAK;KACR,CAAA;AACL,CAAC;AAPD,0BAOC;AAED;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,IAAY;IAC9C,wDAAwD;IACxD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAElC,+CAA+C;IAC/C,IAAI,KAAK,GAAG,GAAG,CAAA;IAEf,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC5B,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;QACvB,CAAC;aAAM,CAAC;YACJ,OAAO,SAAS,CAAA,CAAC,iDAAiD;QACtE,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAA;AAChB,CAAC;AAhBD,4BAgBC;AAED;;;;;;;GAOG;AACH,SAAgB,OAAO,CACnB,CAAM,EACN,CAAM,EACN,QAAgB,EAChB,gBAAyB,KAAK;IAE9B,MAAM,UAAU,GAAG;QACf,GAAG,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;QAC9B,IAAI,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;QAChC,GAAG,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;QAC9B,IAAI,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;QAChC,IAAI,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;QAChC,KAAK,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;QAClC,IAAI,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;QAChC,KAAK,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;KACrC,CAAA;IAED,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,QAAQ,CAAC,CAAA;IACnD,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAChB,OAAO,IAAI,CAAA;IACf,CAAC;IAED,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACrC,CAAC;AA1BD,0BA0BC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const steps_validator_1 = require("./steps.validator");
|
|
4
|
+
/**
|
|
5
|
+
* Validates a work script. Checks for common errors.
|
|
6
|
+
*
|
|
7
|
+
* @param work The work script to validate
|
|
8
|
+
*/
|
|
9
|
+
function default_1(script) {
|
|
10
|
+
(0, steps_validator_1.noUnusedSteps)(script);
|
|
11
|
+
}
|
|
12
|
+
exports.default = default_1;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/demoswork/validator/index.ts"],"names":[],"mappings":";;AACA,uDAAkD;AAElD;;;;GAIG;AACH,mBAAyB,MAAkB;IACvC,IAAA,+BAAa,EAAC,MAAM,CAAC,CAAA;AACzB,CAAC;AAFD,4BAEC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DemoScript } from "../../types/demoswork";
|
|
2
|
+
/**
|
|
3
|
+
* Assert that all steps in the script are consumed by operations
|
|
4
|
+
*
|
|
5
|
+
* @param script The work script to validate
|
|
6
|
+
* @returns true if all steps are used, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export declare function noUnusedSteps(script: DemoScript): void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noUnusedSteps = void 0;
|
|
4
|
+
function getConditionalScriptSteps(script) {
|
|
5
|
+
let steps = new Set();
|
|
6
|
+
// INFO: Loop through all conditions and add the step to the set
|
|
7
|
+
script.conditions.forEach(condition => {
|
|
8
|
+
if (condition.stepUID) {
|
|
9
|
+
steps.add(condition.stepUID);
|
|
10
|
+
}
|
|
11
|
+
steps.add(condition.do.uid);
|
|
12
|
+
});
|
|
13
|
+
return steps;
|
|
14
|
+
}
|
|
15
|
+
function collectAllSteps(script) {
|
|
16
|
+
let steps = new Set();
|
|
17
|
+
Object.keys(script.operations).forEach(opUID => {
|
|
18
|
+
let operation = script.operations[opUID];
|
|
19
|
+
switch (operation.operationType) {
|
|
20
|
+
case "conditional":
|
|
21
|
+
let conditonalSteps = getConditionalScriptSteps(operation);
|
|
22
|
+
let scriptSteps = new Set(Object.keys(script.steps));
|
|
23
|
+
// INFO: Assert that all steps in the conditional
|
|
24
|
+
// script are included in the final script
|
|
25
|
+
let diff = new Set(Array.from(conditonalSteps).filter(x => !scriptSteps.has(x)));
|
|
26
|
+
if (diff.size > 0) {
|
|
27
|
+
throw new Error(`Steps ${[...diff]} not included in final script`);
|
|
28
|
+
}
|
|
29
|
+
steps = new Set([...steps, ...conditonalSteps]);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return steps;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Assert that all steps in the script are consumed by operations
|
|
37
|
+
*
|
|
38
|
+
* @param script The work script to validate
|
|
39
|
+
* @returns true if all steps are used, false otherwise
|
|
40
|
+
*/
|
|
41
|
+
function noUnusedSteps(script) {
|
|
42
|
+
// NOTES: Collect all steps in the script
|
|
43
|
+
// and compare them to the script steps
|
|
44
|
+
let steps = collectAllSteps(script);
|
|
45
|
+
let scriptSteps = new Set(Object.keys(script.steps));
|
|
46
|
+
let diff = new Set(Array.from(scriptSteps).filter(x => !steps.has(x)));
|
|
47
|
+
if (diff.size > 0) {
|
|
48
|
+
throw new Error(`Steps ${[...diff]} not used in script`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.noUnusedSteps = noUnusedSteps;
|
|
52
|
+
//# sourceMappingURL=steps.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps.validator.js","sourceRoot":"","sources":["../../../../src/demoswork/validator/steps.validator.ts"],"names":[],"mappings":";;;AAGA,SAAS,yBAAyB,CAAC,MAAyB;IACxD,IAAI,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAE7B,gEAAgE;IAChE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAClC,IAAI,SAAS,CAAC,OAAO,EAAC,CAAC;YACnB,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QAChC,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AAChB,CAAC;AAED,SAAS,eAAe,CAAC,MAAkB;IACvC,IAAI,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAE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AC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEtE,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,CAAA;IAC5D,CAAC;AACL,CAAC;AAXD,sCAWC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DemoScript } from "../types/demoswork";
|
|
2
|
+
import { Condition } from "../types/demoswork/steps";
|
|
3
|
+
import { Conditional } from "./operations/conditional";
|
|
4
|
+
export declare class DemosWork {
|
|
5
|
+
script: DemoScript;
|
|
6
|
+
results: Record<string, any>;
|
|
7
|
+
if(condition: boolean | Condition): Conditional;
|
|
8
|
+
validate(script: DemoScript): void;
|
|
9
|
+
fromJSON(script: DemoScript): this;
|
|
10
|
+
execute(): Promise<Record<string, any>>;
|
|
11
|
+
toJSON(): DemoScript;
|
|
12
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DemosWork = void 0;
|
|
7
|
+
const pprint_1 = __importDefault(require("../utils/pprint"));
|
|
8
|
+
const executor_1 = __importDefault(require("./executor"));
|
|
9
|
+
const conditional_1 = require("./operations/conditional");
|
|
10
|
+
const validator_1 = __importDefault(require("./validator"));
|
|
11
|
+
class DemosWork {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.script = {
|
|
14
|
+
operationOrder: new Set(),
|
|
15
|
+
operations: {},
|
|
16
|
+
steps: {},
|
|
17
|
+
};
|
|
18
|
+
// INFO: Step results indexed by stepUID
|
|
19
|
+
this.results = {};
|
|
20
|
+
}
|
|
21
|
+
if(condition) {
|
|
22
|
+
return new conditional_1.Conditional(this.script, condition);
|
|
23
|
+
}
|
|
24
|
+
validate(script) {
|
|
25
|
+
(0, validator_1.default)(script);
|
|
26
|
+
}
|
|
27
|
+
fromJSON(script) {
|
|
28
|
+
let newscript = script;
|
|
29
|
+
(0, pprint_1.default)(newscript.operationOrder);
|
|
30
|
+
newscript.operationOrder = new Set(script.operationOrder);
|
|
31
|
+
this.script = script;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
async execute() {
|
|
35
|
+
return await (0, executor_1.default)(this);
|
|
36
|
+
}
|
|
37
|
+
toJSON() {
|
|
38
|
+
let script = this.script;
|
|
39
|
+
// @ts-expect-error
|
|
40
|
+
// convert set to array
|
|
41
|
+
script.operationOrder = [...script.operationOrder];
|
|
42
|
+
// remove all step outputs
|
|
43
|
+
for (const stepUID in script.steps) {
|
|
44
|
+
delete script.steps[stepUID].output;
|
|
45
|
+
delete script.steps[stepUID].workUID;
|
|
46
|
+
}
|
|
47
|
+
// remove all operation uids
|
|
48
|
+
for (const opUID in script.operations) {
|
|
49
|
+
delete script.operations[opUID].operationUID;
|
|
50
|
+
}
|
|
51
|
+
this.validate(script);
|
|
52
|
+
return script;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.DemosWork = DemosWork;
|
|
56
|
+
//# sourceMappingURL=work.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work.js","sourceRoot":"","sources":["../../../src/demoswork/work.ts"],"names":[],"mappings":";;;;;;AAEA,4DAAmC;AACnC,0DAAsC;AACtC,0DAAsD;AACtD,4DAAqC;AAErC,MAAa,SAAS;IAAtB;QACI,WAAM,GAAe;YACjB,cAAc,EAAE,IAAI,GAAG,EAAU;YACjC,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,EAAE;SACZ,CAAA;QACD,wCAAwC;QACxC,YAAO,GAAwB,EAAE,CAAA;IA2CrC,CAAC;IAzCG,EAAE,CA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