@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.
Files changed (73) hide show
  1. package/CollectionPolicyCustomVisitor.js +544 -0
  2. package/CollectionPolicyDecompiler.js +131 -0
  3. package/CollectionPolicyErrorLexerListener.js +23 -0
  4. package/CollectionPolicyErrorListener.js +22 -0
  5. package/README.md +398 -0
  6. package/TransitionEventArgsMatchUtil.js +79 -0
  7. package/gen/CollectionPolicyLexer.js +705 -0
  8. package/gen/CollectionPolicyListener.js +672 -0
  9. package/gen/CollectionPolicyParser.js +7301 -0
  10. package/gen/CollectionPolicyVisitor.js +454 -0
  11. package/gen/LexToken.js +680 -0
  12. package/index.js +53 -0
  13. package/indexTest.js +23 -0
  14. package/package.json +32 -0
  15. package/resources/event_definition.json +169 -0
  16. package/resources/function_definite.json +79 -0
  17. package/resources/test/CalculatorTest.json +26 -0
  18. package/resources/test/FunctionHelperTest.json +21 -0
  19. package/resources/variable_definite.json +10 -0
  20. package/resources/zhaojn.json +68 -0
  21. package/resources/zhaojn.sc +8 -0
  22. package/src/calculator/ExpArgsGroupCalculator.ts +34 -0
  23. package/src/calculator/ExpBooleanCalculator.ts +77 -0
  24. package/src/calculator/ExpCalculator.ts +68 -0
  25. package/src/calculator/ExpCollectionCalculator.ts +0 -0
  26. package/src/calculator/ExpConditionCalculator.ts +43 -0
  27. package/src/function-executor/FunctionHandle.ts +45 -0
  28. package/src/function-executor/api/FunctionApiExecutor.ts +11 -0
  29. package/src/function-executor/fun/FunctionFunExecutor.ts +31 -0
  30. package/src/function-executor/kit/FunctionKitExecutor.ts +11 -0
  31. package/src/function-executor/query/FunctionQueryExecutor.ts +11 -0
  32. package/src/function-executor/time/FunctionTimeExecutor.ts +11 -0
  33. package/src/helper/ExpHelper.ts +66 -0
  34. package/src/helper/FunctionHelper.ts +97 -0
  35. package/src/helper/PolicyHelper.ts +99 -0
  36. package/src/interface/Calculator.ts +6 -0
  37. package/src/interface/DefaultFunctionInvoke.ts +12 -0
  38. package/src/interface/FunctionInvoke.ts +6 -0
  39. package/src/interface/VarContextCapable.ts +3 -0
  40. package/src/model/AssignmentClauseInfo.ts +3 -0
  41. package/src/model/exp/EntityInfo.ts +7 -0
  42. package/src/model/exp/Exp.ts +5 -0
  43. package/src/model/exp/ExpAtom.ts +5 -0
  44. package/src/model/exp/ExpOp.ts +8 -0
  45. package/src/model/exp/ExpParen.ts +6 -0
  46. package/src/model/exp/ExpSigned.ts +7 -0
  47. package/src/model/exp/FunctionCallInfo.ts +13 -0
  48. package/src/model/exp/NumberInfo.ts +6 -0
  49. package/src/model/exp/StringInfo.ts +6 -0
  50. package/src/model/exp/VariableChainInfo.ts +7 -0
  51. package/src/model/exp-args-group/ExpArgsGroup.ts +10 -0
  52. package/src/model/exp-boolean/BooleanInfo.ts +6 -0
  53. package/src/model/exp-boolean/ExpBoolean.ts +5 -0
  54. package/src/model/exp-boolean/ExpBooleanAtom.ts +5 -0
  55. package/src/model/exp-boolean/ExpBooleanOpCollection.ts +8 -0
  56. package/src/model/exp-boolean/ExpBooleanOpCompare.ts +9 -0
  57. package/src/model/exp-boolean/ExpBooleanOpLogic.ts +8 -0
  58. package/src/model/exp-boolean/ExpBooleanParen.ts +6 -0
  59. package/src/model/exp-collection/ExpCollection.ts +10 -0
  60. package/src/model/exp-condition/ExpCondition.ts +12 -0
  61. package/src/model/policy/ActionInfo.ts +23 -0
  62. package/src/model/policy/EventInfo.ts +13 -0
  63. package/src/model/policy/PolicyInfo.ts +20 -0
  64. package/src/model/policy/VarDeclarationInfo.ts +8 -0
  65. package/test/calculator/CalculatorTest.test.ts +13 -0
  66. package/test/function/FunAddElements.ts +9 -0
  67. package/test/function/FunctionFunExecutorTest.test.ts +11 -0
  68. package/test/function/FunctionHandleTest.test.ts +9 -0
  69. package/test/helper/ExpHelperTest.test.ts +7 -0
  70. package/test/helper/FunctionHelperTest.test.ts +16 -0
  71. package/test/helper/PolicyHelperTest.test.ts +14 -0
  72. package/test/tsconfig.test.json +6 -0
  73. 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,8 @@
1
+ export interface VarDeclarationInfo {
2
+ type: "varGlobal" | "varMacro" | "expCustom" | "varAssigment" | "varInitial";
3
+ content: string;
4
+ varName: string;
5
+ paramList?: string[];
6
+ varValue: string;
7
+ varValueObj: any;
8
+ }
@@ -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,9 @@
1
+ import {DefaultFunctionInvoke} from "../../src/interface/DefaultFunctionInvoke";
2
+
3
+ export class FunAddElements extends DefaultFunctionInvoke {
4
+
5
+ invoke(functionName: string, args: any[]): any {
6
+ args[0].push(...args[1]);
7
+ return args[0];
8
+ }
9
+ }
@@ -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,7 @@
1
+ import * as fs from "fs";
2
+ import {PolicyHelper} from "../../src/helper/PolicyHelper";
3
+
4
+ describe("test/helper/ExpHelperTest.test.ts", () => {
5
+ it("getExpValue", async () => {
6
+ });
7
+ });
@@ -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
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "ts-node": {
4
+ "transpileOnly": true
5
+ }
6
+ }
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
+ }