@freelog/freelog-cg-collection 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CollectionPolicyCustomVisitor.js +544 -0
- package/CollectionPolicyDecompiler.js +131 -0
- package/CollectionPolicyErrorLexerListener.js +23 -0
- package/CollectionPolicyErrorListener.js +22 -0
- package/README.md +398 -0
- package/TransitionEventArgsMatchUtil.js +79 -0
- package/gen/CollectionPolicyLexer.js +705 -0
- package/gen/CollectionPolicyListener.js +672 -0
- package/gen/CollectionPolicyParser.js +7301 -0
- package/gen/CollectionPolicyVisitor.js +454 -0
- package/gen/LexToken.js +680 -0
- package/index.js +53 -0
- package/indexTest.js +23 -0
- package/package.json +32 -0
- package/resources/event_definition.json +169 -0
- package/resources/function_definite.json +79 -0
- package/resources/test/CalculatorTest.json +26 -0
- package/resources/test/FunctionHelperTest.json +21 -0
- package/resources/variable_definite.json +10 -0
- package/resources/zhaojn.json +68 -0
- package/resources/zhaojn.sc +8 -0
- package/src/calculator/ExpArgsGroupCalculator.ts +34 -0
- package/src/calculator/ExpBooleanCalculator.ts +77 -0
- package/src/calculator/ExpCalculator.ts +68 -0
- package/src/calculator/ExpCollectionCalculator.ts +0 -0
- package/src/calculator/ExpConditionCalculator.ts +43 -0
- package/src/function-executor/FunctionHandle.ts +45 -0
- package/src/function-executor/api/FunctionApiExecutor.ts +11 -0
- package/src/function-executor/fun/FunctionFunExecutor.ts +31 -0
- package/src/function-executor/kit/FunctionKitExecutor.ts +11 -0
- package/src/function-executor/query/FunctionQueryExecutor.ts +11 -0
- package/src/function-executor/time/FunctionTimeExecutor.ts +11 -0
- package/src/helper/ExpHelper.ts +66 -0
- package/src/helper/FunctionHelper.ts +97 -0
- package/src/helper/PolicyHelper.ts +99 -0
- package/src/interface/Calculator.ts +6 -0
- package/src/interface/DefaultFunctionInvoke.ts +12 -0
- package/src/interface/FunctionInvoke.ts +6 -0
- package/src/interface/VarContextCapable.ts +3 -0
- package/src/model/AssignmentClauseInfo.ts +3 -0
- package/src/model/exp/EntityInfo.ts +7 -0
- package/src/model/exp/Exp.ts +5 -0
- package/src/model/exp/ExpAtom.ts +5 -0
- package/src/model/exp/ExpOp.ts +8 -0
- package/src/model/exp/ExpParen.ts +6 -0
- package/src/model/exp/ExpSigned.ts +7 -0
- package/src/model/exp/FunctionCallInfo.ts +13 -0
- package/src/model/exp/NumberInfo.ts +6 -0
- package/src/model/exp/StringInfo.ts +6 -0
- package/src/model/exp/VariableChainInfo.ts +7 -0
- package/src/model/exp-args-group/ExpArgsGroup.ts +10 -0
- package/src/model/exp-boolean/BooleanInfo.ts +6 -0
- package/src/model/exp-boolean/ExpBoolean.ts +5 -0
- package/src/model/exp-boolean/ExpBooleanAtom.ts +5 -0
- package/src/model/exp-boolean/ExpBooleanOpCollection.ts +8 -0
- package/src/model/exp-boolean/ExpBooleanOpCompare.ts +9 -0
- package/src/model/exp-boolean/ExpBooleanOpLogic.ts +8 -0
- package/src/model/exp-boolean/ExpBooleanParen.ts +6 -0
- package/src/model/exp-collection/ExpCollection.ts +10 -0
- package/src/model/exp-condition/ExpCondition.ts +12 -0
- package/src/model/policy/ActionInfo.ts +23 -0
- package/src/model/policy/EventInfo.ts +13 -0
- package/src/model/policy/PolicyInfo.ts +20 -0
- package/src/model/policy/VarDeclarationInfo.ts +8 -0
- package/test/calculator/CalculatorTest.test.ts +13 -0
- package/test/function/FunAddElements.ts +9 -0
- package/test/function/FunctionFunExecutorTest.test.ts +11 -0
- package/test/function/FunctionHandleTest.test.ts +9 -0
- package/test/helper/ExpHelperTest.test.ts +7 -0
- package/test/helper/FunctionHelperTest.test.ts +16 -0
- package/test/helper/PolicyHelperTest.test.ts +14 -0
- package/test/tsconfig.test.json +6 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {FunctionCallInfo} from "../exp/FunctionCallInfo";
|
|
2
|
+
import {AssignmentClauseInfo} from "../AssignmentClauseInfo";
|
|
3
|
+
|
|
4
|
+
export interface ActionInfo {
|
|
5
|
+
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ActionFunctionCall extends ActionInfo {
|
|
9
|
+
type: "functionCall";
|
|
10
|
+
content: string;
|
|
11
|
+
actionObj: FunctionCallInfo;
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ActionVarAssignment extends ActionInfo {
|
|
16
|
+
type: "varAssignment";
|
|
17
|
+
content: string;
|
|
18
|
+
actionObj: {
|
|
19
|
+
varName: string;
|
|
20
|
+
varValue: string;
|
|
21
|
+
varValueObj: AssignmentClauseInfo;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {AssignmentClauseInfo} from "../AssignmentClauseInfo";
|
|
2
|
+
|
|
3
|
+
export interface EventInfo {
|
|
4
|
+
type: "normal" | "terminate";
|
|
5
|
+
content: string;
|
|
6
|
+
eventName: string;
|
|
7
|
+
eventPath?: string;
|
|
8
|
+
eventParamList?: [{
|
|
9
|
+
paramName?: string;
|
|
10
|
+
paramValue: string;
|
|
11
|
+
paramValueObj: AssignmentClauseInfo;
|
|
12
|
+
}];
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {VarDeclarationInfo} from "./VarDeclarationInfo";
|
|
2
|
+
import {EventInfo} from "./EventInfo";
|
|
3
|
+
import {AssignmentClauseInfo} from "../AssignmentClauseInfo";
|
|
4
|
+
|
|
5
|
+
export interface PolicyInfo {
|
|
6
|
+
audienceSection: {
|
|
7
|
+
audiences: string[];
|
|
8
|
+
conditions: [{
|
|
9
|
+
paramName?: string;
|
|
10
|
+
paramValue: string;
|
|
11
|
+
paramValueObj: AssignmentClauseInfo;
|
|
12
|
+
}];
|
|
13
|
+
};
|
|
14
|
+
varDeclarationList: VarDeclarationInfo[];
|
|
15
|
+
stateMachine: [{
|
|
16
|
+
stateName: string;
|
|
17
|
+
assignments: VarDeclarationInfo[];
|
|
18
|
+
events: EventInfo[];
|
|
19
|
+
}];
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import {ExpCalculator} from "../../src/calculator/ExpCalculator";
|
|
3
|
+
|
|
4
|
+
describe("test/calculator/CalculatorTest.test.ts", () => {
|
|
5
|
+
it("expOp", async () => {
|
|
6
|
+
let source = JSON.parse(fs.readFileSync("./resources/test/CalculatorTest.json", "utf-8"))
|
|
7
|
+
|
|
8
|
+
let expCalculator = new ExpCalculator();
|
|
9
|
+
|
|
10
|
+
let result = expCalculator.calculateExpOp(source.varValueObj, null);
|
|
11
|
+
console.log(result);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {FunctionFunExecutor} from "../../src/function-executor/fun/FunctionFunExecutor";
|
|
2
|
+
import {FunAddElements} from "./FunAddElements";
|
|
3
|
+
|
|
4
|
+
describe("test/function/FunctionFunExecutorTest.test.ts", () => {
|
|
5
|
+
it("invoke", async () => {
|
|
6
|
+
let functionFunExecutor = new FunctionFunExecutor();
|
|
7
|
+
functionFunExecutor.addExecutor("fun.addElements", new FunAddElements());
|
|
8
|
+
let result = functionFunExecutor.invoke("fun.addElements", [[1, 2], [3]]);
|
|
9
|
+
console.log(result);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {FunctionHandle} from "../../src/function-executor/FunctionHandle";
|
|
2
|
+
|
|
3
|
+
describe("test/function/FunctionHandleTest.test.ts", () => {
|
|
4
|
+
it("invoke", async () => {
|
|
5
|
+
let functionHandle = new FunctionHandle();
|
|
6
|
+
let result = functionHandle.invoke("Kit.Max", [1, 2]);
|
|
7
|
+
console.log(result);
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import {FunctionHelper} from "../../src/helper/FunctionHelper";
|
|
3
|
+
import {ExpHelper} from "../../src/helper/ExpHelper";
|
|
4
|
+
|
|
5
|
+
describe("test/helper/FunctionHelperTest.test.ts", () => {
|
|
6
|
+
it("init", async () => {
|
|
7
|
+
let source = JSON.parse(fs.readFileSync("./resources/test/FunctionHelperTest.json", "utf-8"))
|
|
8
|
+
|
|
9
|
+
let funcHelper = new FunctionHelper();
|
|
10
|
+
let expHelper = new ExpHelper();
|
|
11
|
+
funcHelper.setExpHelper(expHelper);
|
|
12
|
+
|
|
13
|
+
let result = funcHelper.getFunctionValue(source, null);
|
|
14
|
+
console.log(result);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import {PolicyHelper} from "../../src/helper/PolicyHelper";
|
|
3
|
+
|
|
4
|
+
describe("test/helper/PolicyHelperTest.test.ts", () => {
|
|
5
|
+
it("init", async () => {
|
|
6
|
+
let source = JSON.parse(fs.readFileSync("./resources/zhaojn.json", "utf-8"))
|
|
7
|
+
|
|
8
|
+
let policyHelper = new PolicyHelper(source);
|
|
9
|
+
|
|
10
|
+
await policyHelper.init(policyHelper);
|
|
11
|
+
|
|
12
|
+
console.log(policyHelper.getVarGlobalList());
|
|
13
|
+
});
|
|
14
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compileOnSave": true,
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2018",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"emitDecoratorMetadata": true,
|
|
9
|
+
"inlineSourceMap":true,
|
|
10
|
+
"noImplicitThis": true,
|
|
11
|
+
"noUnusedLocals": false,
|
|
12
|
+
"stripInternal": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"pretty": true,
|
|
15
|
+
"declaration": true,
|
|
16
|
+
"typeRoots": [ "./typings", "./node_modules/@types"],
|
|
17
|
+
"outDir": "dist"
|
|
18
|
+
},
|
|
19
|
+
"exclude": [
|
|
20
|
+
"dist",
|
|
21
|
+
"node_modules",
|
|
22
|
+
"test"
|
|
23
|
+
]
|
|
24
|
+
}
|