wowok_agent 1.2.44 → 1.3.47
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/dist/call/arbitration.d.ts +13 -28
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +91 -84
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +31 -2
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +41 -3
- package/dist/call/base.js.map +1 -1
- package/dist/call/call.d.ts +6 -0
- package/dist/call/call.d.ts.map +1 -1
- package/dist/call/call.js.map +1 -1
- package/dist/call/demand.d.ts +9 -22
- package/dist/call/demand.d.ts.map +1 -1
- package/dist/call/demand.js +70 -78
- package/dist/call/demand.js.map +1 -1
- package/dist/call/machine.d.ts +35 -44
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +105 -115
- package/dist/call/machine.js.map +1 -1
- package/dist/call/object_permission.d.ts.map +1 -1
- package/dist/call/object_permission.js.map +1 -1
- package/dist/call/permission.d.ts +30 -18
- package/dist/call/permission.d.ts.map +1 -1
- package/dist/call/permission.js +39 -38
- package/dist/call/permission.js.map +1 -1
- package/dist/call/personal.d.ts +6 -6
- package/dist/call/personal.d.ts.map +1 -1
- package/dist/call/personal.js +11 -13
- package/dist/call/personal.js.map +1 -1
- package/dist/call/repository.d.ts +4 -12
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +49 -37
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +50 -70
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +187 -164
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +22 -26
- package/dist/call/treasury.d.ts.map +1 -1
- package/dist/call/treasury.js +74 -73
- package/dist/call/treasury.js.map +1 -1
- package/dist/common.d.ts +1 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +6 -0
- package/dist/common.js.map +1 -1
- package/dist/local/local.d.ts +1 -1
- package/dist/local/local.d.ts.map +1 -1
- package/dist/local/local.js +4 -1
- package/dist/local/local.js.map +1 -1
- package/dist/query/events.d.ts +1 -1
- package/dist/query/events.d.ts.map +1 -1
- package/dist/query/events.js +15 -9
- package/dist/query/events.js.map +1 -1
- package/dist/query/objects.d.ts +7 -2
- package/dist/query/objects.d.ts.map +1 -1
- package/dist/query/objects.js +8 -1
- package/dist/query/objects.js.map +1 -1
- package/package.json +4 -2
- package/src/call/arbitration.ts +117 -105
- package/src/call/base.ts +78 -10
- package/src/call/call.ts +6 -0
- package/src/call/demand.ts +77 -86
- package/src/call/machine.ts +119 -132
- package/src/call/object_permission.ts +1 -1
- package/src/call/permission.ts +68 -45
- package/src/call/personal.ts +18 -20
- package/src/call/repository.ts +54 -47
- package/src/call/service.ts +236 -197
- package/src/call/treasury.ts +96 -86
- package/src/common.ts +7 -1
- package/src/local/account.ts +1 -1
- package/src/local/local.ts +6 -2
- package/src/query/events.ts +12 -10
- package/src/query/objects.ts +18 -4
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/repository.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { TransactionBlock, PassportObject,
|
|
1
|
+
import { TransactionBlock, PassportObject, Errors, ERROR, Permission, PermissionIndex,
|
|
2
2
|
PermissionIndexType, Repository, Repository_Policy, Repository_Policy_Data, Repository_Policy_Data2,
|
|
3
|
-
Repository_Policy_Data_Remove, Repository_Policy_Mode,
|
|
3
|
+
Repository_Policy_Data_Remove, Repository_Policy_Mode, Repository_Value,
|
|
4
4
|
} from 'wowok';
|
|
5
|
-
import { CallBase, CallResult,
|
|
5
|
+
import { CallBase, CallResult, GetObjectExisted, GetObjectMain, GetObjectParam, ObjectMain, TypeNamedObjectWithPermission} from "./base.js";
|
|
6
6
|
import { LocalMark } from '../local/local.js';
|
|
7
7
|
import { ObjectRepository } from '../query/objects.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
11
11
|
export interface CallRepository_Data {
|
|
12
|
-
object?:
|
|
13
|
-
permission?: {address:string} | {namedNew?: Namedbject, description?:string};
|
|
12
|
+
object?: ObjectMain;
|
|
14
13
|
description?: string;
|
|
15
14
|
reference?: {op:'set' | 'add' | 'remove' ; addresses:string[]} | {op:'removeall'};
|
|
16
15
|
mode?: Repository_Policy_Mode; // default: 'Relax' (POLICY_MODE_FREE)
|
|
@@ -19,6 +18,9 @@ export interface CallRepository_Data {
|
|
|
19
18
|
}
|
|
20
19
|
export class CallRepository extends CallBase {
|
|
21
20
|
data: CallRepository_Data;
|
|
21
|
+
object_address: string | undefined = undefined;
|
|
22
|
+
permission_address: string | undefined = undefined;
|
|
23
|
+
|
|
22
24
|
constructor(data:CallRepository_Data) {
|
|
23
25
|
super();
|
|
24
26
|
this.data = data;
|
|
@@ -27,28 +29,24 @@ export class CallRepository extends CallBase {
|
|
|
27
29
|
async call(account?:string) : Promise<CallResult> {
|
|
28
30
|
var checkOwner = false;
|
|
29
31
|
const perms : PermissionIndexType[] = [];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
permission_address = (this.content as ObjectRepository).permission;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
32
|
+
this.object_address = (await LocalMark.Instance().get(GetObjectExisted(this.data?.object)))?.address;
|
|
33
|
+
if (this.object_address) {
|
|
34
|
+
await this.update_content('Repository', this.object_address);
|
|
35
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallRepository_Data.data.object:' + this.object_address);
|
|
36
|
+
this.permission_address = (this.content as ObjectRepository).permission;
|
|
37
|
+
} else {
|
|
38
|
+
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
39
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
40
|
+
}
|
|
43
41
|
|
|
44
|
-
if (permission_address) {
|
|
42
|
+
if (this.permission_address) {
|
|
45
43
|
if (!this.data?.object) {
|
|
46
44
|
perms.push(PermissionIndex.repository)
|
|
47
45
|
}
|
|
48
|
-
if (this.data?.description !== undefined && object_address) {
|
|
46
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
49
47
|
perms.push(PermissionIndex.repository_description)
|
|
50
48
|
}
|
|
51
|
-
if (this.data?.mode !== undefined && object_address) {
|
|
49
|
+
if (this.data?.mode !== undefined && this.object_address) {
|
|
52
50
|
perms.push(PermissionIndex.repository_mode)
|
|
53
51
|
}
|
|
54
52
|
if (this.data?.reference !== undefined) {
|
|
@@ -57,37 +55,28 @@ export class CallRepository extends CallBase {
|
|
|
57
55
|
if (this.data?.policy !== undefined) {
|
|
58
56
|
perms.push(PermissionIndex.repository_policies)
|
|
59
57
|
}
|
|
60
|
-
return await this.check_permission_and_call(permission_address, perms, [], checkOwner, undefined, account)
|
|
58
|
+
return await this.check_permission_and_call(this.permission_address, perms, [], checkOwner, undefined, account)
|
|
61
59
|
}
|
|
62
60
|
return await this.exec(account);
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
66
64
|
let obj : Repository | undefined ; let permission: any;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
await LocalMark.Instance().get_many_address(
|
|
70
|
-
[(this.data?.permission as any)?.address,
|
|
71
|
-
(this.data?.object as any)?.address]);
|
|
72
|
-
|
|
73
|
-
if (!object_address) {
|
|
74
|
-
if (!permission_address) {
|
|
75
|
-
const d = (this.data?.permission as any)?.description ?? '';
|
|
76
|
-
permission = Permission.New(txb, d);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
obj = Repository.New(txb, permission ? permission.get_object() : permission_address, this.data?.description??'', this.data?.mode, permission?undefined:passport)
|
|
65
|
+
if (this.object_address) {
|
|
66
|
+
obj = Repository.From(txb, this.permission_address!, this.object_address);
|
|
80
67
|
} else {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
ERROR(Errors.InvalidParam, 'CallRepository_Data.data.permission')
|
|
68
|
+
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
69
|
+
if (!this.permission_address) {
|
|
70
|
+
permission = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
|
|
85
71
|
}
|
|
72
|
+
|
|
73
|
+
obj = Repository.New(txb, permission ? permission.get_object() : this.permission_address, this.data?.description??'',
|
|
74
|
+
this.data.mode, permission?undefined:passport);
|
|
86
75
|
}
|
|
87
76
|
|
|
88
77
|
if (obj) {
|
|
89
78
|
const pst = permission?undefined:passport;
|
|
90
|
-
if (this.data?.description !== undefined && object_address) {
|
|
79
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
91
80
|
obj?.set_description(this.data.description, pst);
|
|
92
81
|
}
|
|
93
82
|
if (this.data?.reference !== undefined) {
|
|
@@ -105,7 +94,7 @@ export class CallRepository extends CallBase {
|
|
|
105
94
|
break;
|
|
106
95
|
}
|
|
107
96
|
}
|
|
108
|
-
if (this.data?.mode !== undefined && object_address) { //@ priority??
|
|
97
|
+
if (this.data?.mode !== undefined && this.object_address) { //@ priority??
|
|
109
98
|
obj?.set_policy_mode(this.data.mode, pst)
|
|
110
99
|
}
|
|
111
100
|
if (this.data?.policy !== undefined) {
|
|
@@ -134,22 +123,40 @@ export class CallRepository extends CallBase {
|
|
|
134
123
|
switch(this.data.data.op) {
|
|
135
124
|
case 'add':
|
|
136
125
|
if ((this.data.data?.data as any)?.key !== undefined) {
|
|
137
|
-
|
|
126
|
+
const d = (this.data.data.data as Repository_Policy_Data).data;
|
|
127
|
+
const add: Repository_Value[] = [];
|
|
128
|
+
for (let i=0; i<d.length; ++i) {
|
|
129
|
+
const addr = await LocalMark.Instance().get_address(d[i].address);
|
|
130
|
+
if (addr) {
|
|
131
|
+
add.push({address:addr, bcsBytes:d[i].bcsBytes});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
obj?.add_data({key:(this.data.data.data as Repository_Policy_Data).key, data:add, value_type:(this.data.data.data as Repository_Policy_Data).value_type});
|
|
138
135
|
} else if ((this.data.data?.data as any)?.address !== undefined) {
|
|
139
|
-
|
|
136
|
+
const d = this.data.data.data as Repository_Policy_Data2;
|
|
137
|
+
const addr = await LocalMark.Instance().get_address(d.address);
|
|
138
|
+
if (addr) {
|
|
139
|
+
obj?.add_data2({address:addr, data:d.data, value_type:d.value_type})
|
|
140
|
+
}
|
|
140
141
|
}
|
|
141
142
|
break;
|
|
142
143
|
case 'remove':
|
|
143
|
-
this.data.data.data.
|
|
144
|
+
for (let i=0; i<this.data.data.data.length; ++i) {
|
|
145
|
+
const addr = await LocalMark.Instance().get_address(this.data.data.data[i].address);
|
|
146
|
+
if (addr) {
|
|
147
|
+
obj?.remove(addr, this.data.data.data[i].key);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
144
150
|
break;
|
|
145
151
|
}
|
|
146
152
|
}
|
|
147
153
|
|
|
148
154
|
if (permission) {
|
|
149
|
-
|
|
155
|
+
const n = GetObjectMain(this.data?.object) as TypeNamedObjectWithPermission;
|
|
156
|
+
await this.new_with_mark('Permission', txb, permission.launch(), GetObjectParam(n?.permission), account);
|
|
150
157
|
}
|
|
151
|
-
if (!this.
|
|
152
|
-
await this.new_with_mark('Repository', txb, obj.launch(), (this.data?.object
|
|
158
|
+
if (!this.object_address) {
|
|
159
|
+
await this.new_with_mark('Repository', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
153
160
|
}
|
|
154
161
|
}
|
|
155
162
|
};
|