@freelog/freelog-cg-collection 1.2.11 → 1.2.13

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,6 @@
1
1
  // 所有人都可以签该策略,所以身份信息不在签约时判定,下面的echoSubject = echoSubject和echoPolicyId = echoCorePolicyId可以不写,因为它需要和labels一起使用,来判断某用户组是否有某标签
2
2
  FOR USER(echoSubject = echoSubject, echoPolicyId = echoCorePolicyId, labels = ["vip1"])
3
+ USE &Contract(subject = Echo.<连载小说的会员>, policyId = echoCorePolicyId, licensee = contract.licensee) AS membership
3
4
 
4
5
  labels0 = Query.EchoService.Labels({"subject":echoSubject, "policyId":echoCorePolicyId, "licensee":contract.licensee})
5
6
 
@@ -7,7 +8,7 @@ echoSubject <- Echo.<连载小说的会员>
7
8
 
8
9
  echoCorePolicyId = "xxx连载小说会员的主策略ID"
9
10
 
10
- unitPrice <- 1
11
+ unitPrice <- (+1)
11
12
 
12
13
  setUnlocked = []
13
14
 
@@ -15,13 +16,17 @@ setTemp = []
15
16
 
16
17
  setFree = []
17
18
 
19
+ defExpr s2CalculateExpr(sumAmounts, discount1, discount2) = [
20
+ sumAmounts greater 10000 : discount1 * (sumAmounts - 10000) + discount2 * 7500,
21
+ sumAmounts greater 2500 and sumAmounts lessOrEqual 10000 : discount2 * (sumAmounts - 2500),
22
+ 0]
23
+
18
24
  Initial None:
19
25
  let labels = Query.EchoService.Labels({"subject":echoSubject, "licensee":contract.licensee})
20
26
  // Event.Void("vip1" in labels) -> AUTH_VIP1
21
27
  // Event.Void(not ("vip1" in labels)) -> AUTH_MEMBER
22
28
  // Event.Echo.Labels({"subject":echoSubject, "licensee":contract.licensee, "label":"vip1"}) -> AUTH_VIP1
23
29
  Event.Void(not ("vip2" in labels)) -> AUTH_MEMBER{fun.setLabel({"label":"vip2", "ttl":7200})}
24
- Event.Time.Relative(1, "minute") -> AUTH_MEMBER{fun.setLabel({"label":"vip1", "ttl":1800})}
25
30
 
26
31
  AUTH_MEMBER Partial{setUnlocked, setTemp}:
27
32
  Event.Transaction.Pay(amount = unitPrice, elemsNum = 1) -> AUTH_MEMBER{fun.addElements(setUnlocked, contract.licenseeSelectedElems, false)}
@@ -29,12 +34,12 @@ AUTH_MEMBER Partial{setUnlocked, setTemp}:
29
34
  Event.Custom.AcceptEvent({"title":"MembershipChange", "subject":echoSubject, "label":"vip1"}) -> AUTH_VIP1
30
35
 
31
36
  Event.Custom.WatchAD(elemsNum = 1) -> AUTH_MEMBER{fun.addElements(setTemp, contract.licenseeSelectedElems, false)}
32
- // Event.Time.Schedule(Time.AddTime(Time.GetTime(Time.Now(), "day"), 1, "day")) -> AUTH_MEMBER{fun.clearElems(setTemp)}
33
- Event.Time.Relative(2, "minute") -> FINISH
37
+ Event.Time.Schedule(Time.AddTime(Time.GetTime(Time.Now(), "day"), 1, "day")) -> AUTH_MEMBER{fun.clearElems(setTemp)}
34
38
 
35
39
  AUTH_VIP1 Partial{setUnlocked, setTemp, setFree}:
36
40
  let a = 1
37
41
  let b = []
42
+ a = 3
38
43
  Event.Transaction.Pay(amount = unitPrice * 0.75, elemsNum = 1) -> AUTH_VIP1{fun.addElements(setUnlocked, contract.licenseeSelectedElems, false)}
39
44
  Event.Transaction.Pay(amount = unitPrice * 10 * 0.6, elemsNum = 10) -> AUTH_VIP1{fun.addElements(setUnlocked, contract.licenseeSelectedElems, false)}
40
45
  Event.Custom.AcceptEvent({"title":"MembershipChange", "subject":echoSubject, "label":"member"}) -> AUTH_MEMBER
@@ -51,5 +56,5 @@ FREE_UNLOCK_ROUTE None[elems]:
51
56
  Event.Void(freeUnlockedSize < 4) -> AUTH_VIP1{fun.addElements(setFree, elems, false)}
52
57
  Event.Void(freeUnlockedSize >= 4) -> AUTH_VIP1
53
58
 
54
- FINISH:
55
- terminate
59
+ ABC:
60
+ terminate
@@ -1,125 +1,73 @@
1
1
  {
2
- "audienceInfo": {
2
+ "state_machine": {
3
3
  "audiences": [
4
- "USER"
5
- ],
6
- "condition": {
7
- "echoSubject": {
8
- "expType": "entity",
9
- "entityType": "Echo",
10
- "entityName": "连载小说的会员",
11
- "variableChainList": []
12
- },
13
- "echoPolicyId": "xxx连载小说会员的主策略ID",
14
- "labels": [
15
- "vip1"
16
- ]
17
- }
18
- },
19
- "varContractDeclarationList": [],
20
- "varGlobalList": [
21
- {
22
- "varName": "policy.subject",
23
- "varValue": {
24
- "expType": "entity",
25
- "entityType": "Resource",
26
- "entityName": "12345676789/haohaoxuexi"
27
- }
28
- },
29
- {
30
- "varName": "policy.policyId",
31
- "varValue": "694e2a95b5a8cc1a4ca11924"
32
- },
33
- {
34
- "varName": "contract.contractId",
35
- "varValue": "69a6a68490e845dce6b08e05"
36
- },
37
- {
38
- "varName": "contract.licensee",
39
- "varValue": {
40
- "expType": "entity",
41
- "entityType": "User",
42
- "entityName": "zhaojn"
43
- }
44
- },
45
- {
46
- "varName": "contract.licenseeOwner",
47
- "varValue": {
48
- "expType": "entity",
49
- "entityType": "User",
50
- "entityName": "zhaojn"
51
- }
52
- },
53
- {
54
- "varName": "contract.licenseeSelectedElems",
55
- "varValue": []
56
- },
57
- {
58
- "varName": "echoCorePolicyId",
59
- "varValue": "xxx连载小说会员的主策略ID"
60
- },
61
- {
62
- "varName": "labels0",
63
- "varValue": [
64
- "vip1"
65
- ]
66
- },
67
- {
68
- "varName": "setUnlocked",
69
- "varValue": []
70
- },
71
- {
72
- "varName": "setTemp",
73
- "varValue": []
74
- },
75
- {
76
- "varName": "setFree",
77
- "varValue": []
78
- }
79
- ],
80
- "currentStateInfo": {
81
- "currentState": "Initial",
82
- "currentServiceState": "None",
83
- "serviceStateCollection": [],
84
- "varLocalAtStateList": [],
85
- "varLocalCurrentStateList": [
86
4
  {
87
- "varName": "labels",
88
- "varValue": [
89
- "vip1"
90
- ]
5
+ "name": "public",
6
+ "type": "public"
91
7
  }
92
8
  ],
93
- "currentEventInfos": [
94
- {
95
- "eventType": "normal",
96
- "eventCode": "V101",
97
- "eventName": "Void",
98
- "eventId": "b3449b02",
99
- "varLocalAtEventList": [
100
- {
101
- "varName": "condition",
102
- "varValue": true
103
- }
104
- ]
105
- },
106
- {
107
- "eventType": "normal",
108
- "eventCode": "T201",
109
- "eventPath": "Time",
110
- "eventName": "Relative",
111
- "eventId": "04e9cfdc",
112
- "varLocalAtEventList": [
9
+ "subjectIcon": {},
10
+ "declarations": {
11
+ "serviceStates": [
12
+ {
13
+ "name": "active",
14
+ "type": "authorization"
15
+ }
16
+ ]
17
+ },
18
+ "states": {
19
+ "initial": {
20
+ "transitions": [
113
21
  {
114
- "varName": "elapsed",
115
- "varValue": 1
22
+ "toState": "auth",
23
+ "service": "freelog",
24
+ "name": "TransactionEvent",
25
+ "args": {
26
+ "amount": 1.9,
27
+ "account": "self.account"
28
+ },
29
+ "code": "S201",
30
+ "description": "one time transaction",
31
+ "isSingleton": true,
32
+ "id": "a2da448a"
116
33
  },
117
34
  {
118
- "varName": "timeUnit",
119
- "varValue": "minute"
35
+ "toState": "finish",
36
+ "service": "freelog",
37
+ "name": "TimeEvent",
38
+ "args": {
39
+ "dateTime": "2024-12-31 00:00"
40
+ },
41
+ "code": "A102",
42
+ "description": "fired on a pre-determined time",
43
+ "isSingleton": false,
44
+ "id": "c656f9cb"
120
45
  }
46
+ ],
47
+ "serviceStates": [],
48
+ "isInitial": true
49
+ },
50
+ "auth": {
51
+ "transitions": [],
52
+ "serviceStates": [
53
+ "active"
121
54
  ]
55
+ },
56
+ "finish": {
57
+ "transitions": [],
58
+ "serviceStates": []
122
59
  }
123
- ]
124
- }
60
+ },
61
+ "description": {
62
+ "symbolArgs": {
63
+ "envArgs": [
64
+ "self.account"
65
+ ]
66
+ }
67
+ }
68
+ },
69
+ "warnings": [],
70
+ "warningObjects": [],
71
+ "errors": [],
72
+ "errorObjects": []
125
73
  }
@@ -0,0 +1,76 @@
1
+ {
2
+ "audienceSection": {
3
+ "conditions": [],
4
+ "audiences": [
5
+ "PUBLIC"
6
+ ]
7
+ },
8
+ "contractDeclarationSection": {
9
+ "contractDeclarations": []
10
+ },
11
+ "varDeclarationList": [],
12
+ "stateMachine": [
13
+ {
14
+ "stateName": "Initial",
15
+ "serviceStateSection": {},
16
+ "events": [
17
+ {
18
+ "type": "normal",
19
+ "eventName": "Pay",
20
+ "eventPath": "Transaction",
21
+ "eventParamList": [
22
+ {
23
+ "paramValueObj": {
24
+ "expType": "number",
25
+ "value": 1.9
26
+ }
27
+ },
28
+ {
29
+ "paramValueObj": {
30
+ "expType": "number",
31
+ "value": 1
32
+ }
33
+ }
34
+ ],
35
+ "toState": "auth"
36
+ },
37
+ {
38
+ "type": "normal",
39
+ "eventName": "Schedule",
40
+ "eventPath": "Time",
41
+ "eventParamList": [
42
+ {
43
+ "paramValueObj": {
44
+ "expType": "string",
45
+ "value": "2024-12-31 00:00"
46
+ }
47
+ }
48
+ ],
49
+ "toState": "finish"
50
+ }
51
+ ]
52
+ },
53
+ {
54
+ "stateName": "auth",
55
+ "serviceStateSection": {
56
+ "serviceState": "Permit"
57
+ },
58
+ "events": [
59
+ {
60
+ "type": "terminate",
61
+ "eventName": "terminate"
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ "stateName": "finish",
67
+ "serviceStateSection": {},
68
+ "events": [
69
+ {
70
+ "type": "terminate",
71
+ "eventName": "terminate"
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ }
@@ -252,6 +252,7 @@ export class PolicyHelper implements VarContextCapable<any>, Calculator, Functio
252
252
  eventPath: eventInfo.eventPath,
253
253
  eventName: eventInfo.eventName,
254
254
  eventId: eventInfo.eventId,
255
+ toState: eventInfo.toState,
255
256
  varLocalAtEventList: varLocalAtEventList
256
257
  });
257
258
  }
@@ -5,9 +5,9 @@ export interface FunctionCallInfo extends Exp {
5
5
  expType: "functionCall";
6
6
  varChain?: string;
7
7
  funcName: string;
8
- paramList: [{
8
+ paramList: {
9
9
  paramName?: string;
10
10
  paramValue: string;
11
11
  paramValueObj: AssignmentClauseInfo;
12
- }];
12
+ }[];
13
13
  }
@@ -3,10 +3,10 @@ import {ExpBoolean} from "../exp-boolean/ExpBoolean";
3
3
 
4
4
  export interface ExpCondition extends AssignmentClauseInfo {
5
5
  expType: "expCondition";
6
- paramList: [{
6
+ paramList: {
7
7
  paramCondition?: string;
8
8
  paramConditionObj?: ExpBoolean;
9
9
  paramValue: string;
10
10
  paramValueObj: any;
11
- }];
11
+ }[];
12
12
  }
@@ -2,7 +2,7 @@ import {FunctionCallInfo} from "../exp/FunctionCallInfo";
2
2
  import {AssignmentClauseInfo} from "../AssignmentClauseInfo";
3
3
 
4
4
  export interface ActionInfo {
5
-
5
+ type: string;
6
6
  }
7
7
 
8
8
  export interface ActionFunctionCall extends ActionInfo {
@@ -4,27 +4,33 @@ import {AssignmentClauseInfo} from "../AssignmentClauseInfo";
4
4
  import {ContractDeclarationInfo} from "./ContractDeclarationInfo";
5
5
 
6
6
  export interface PolicyInfo {
7
- audienceSection: {
8
- audiences: string[];
9
- conditions: [{
10
- paramName?: string;
11
- paramValue: string;
12
- paramValueObj: AssignmentClauseInfo;
13
- content: string;
14
- }];
15
- };
16
- contractDeclarationSection: {
17
- contractDeclarations: ContractDeclarationInfo[];
18
- };
7
+ audienceSection: AudienceSection;
8
+ contractDeclarationSection: ContractDeclarationSection;
19
9
  varDeclarationList: VarDeclarationInfo[];
20
- stateMachine: [{
21
- stateName: string;
22
- assignments: VarDeclarationInfo[];
23
- events: EventInfo[];
24
- serviceStateSection?: {
25
- serviceState?: string;
26
- serviceStateCollection?: string[];
27
- };
28
- stateContextArgs?: string[];
29
- }];
10
+ stateMachine: StateInfo[];
11
+ }
12
+
13
+ export interface AudienceSection {
14
+ audiences: string[];
15
+ conditions: {
16
+ paramName?: string;
17
+ paramValue: string;
18
+ paramValueObj: AssignmentClauseInfo;
19
+ content: string;
20
+ }[];
30
21
  }
22
+
23
+ export interface ContractDeclarationSection {
24
+ contractDeclarations: ContractDeclarationInfo[];
25
+ }
26
+
27
+ export interface StateInfo {
28
+ stateName: string;
29
+ assignments: VarDeclarationInfo[];
30
+ events: EventInfo[];
31
+ serviceStateSection?: {
32
+ serviceState?: string;
33
+ serviceStateCollection?: string[];
34
+ };
35
+ stateContextArgs?: string[];
36
+ }