@decaf-ts/for-fabric 0.1.22 → 0.1.24
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/for-fabric.cjs +1 -1
- package/dist/for-fabric.cjs.map +1 -1
- package/dist/for-fabric.js +1 -1
- package/dist/for-fabric.js.map +1 -1
- package/lib/client/FabricClientAdapter.cjs +39 -61
- package/lib/client/FabricClientAdapter.d.ts +28 -42
- package/lib/client/FabricClientAdapter.js.map +1 -1
- package/lib/client/FabricClientDispatch.cjs +1 -3
- package/lib/client/FabricClientDispatch.d.ts +6 -5
- package/lib/client/FabricClientDispatch.js.map +1 -1
- package/lib/client/FabricClientPaginator.cjs +5 -56
- package/lib/client/FabricClientPaginator.d.ts +6 -6
- package/lib/client/FabricClientPaginator.js.map +1 -1
- package/lib/client/FabricClientRepository.cjs +50 -103
- package/lib/client/FabricClientRepository.d.ts +21 -17
- package/lib/client/FabricClientRepository.js.map +1 -1
- package/lib/client/FabricClientStatement.cjs +7 -97
- package/lib/client/FabricClientStatement.d.ts +6 -7
- package/lib/client/FabricClientStatement.js.map +1 -1
- package/lib/client/erc20/FabricERC20ClientRepository.d.ts +5 -5
- package/lib/client/erc20/FabricERC20ClientRepository.js.map +1 -1
- package/lib/client/fabric-fs.d.ts +1 -1
- package/lib/client/services/FabricEnrollmentService.d.ts +1 -1
- package/lib/contract/Address.cjs +73 -0
- package/lib/contract/Address.d.ts +13 -0
- package/lib/contract/Address.js.map +1 -0
- package/lib/contract/AddressContract.cjs +34 -0
- package/lib/contract/AddressContract.d.ts +5 -0
- package/lib/contract/AddressContract.js.map +1 -0
- package/lib/contract/index.cjs +6 -1
- package/lib/contract/index.js.map +1 -1
- package/lib/contracts/ContractAdapter.cjs +53 -20
- package/lib/contracts/ContractAdapter.d.ts +3 -3
- package/lib/contracts/ContractAdapter.js.map +1 -1
- package/lib/contracts/ContractContext.cjs +2 -2
- package/lib/contracts/ContractContext.d.ts +1 -1
- package/lib/contracts/ContractContext.js.map +1 -1
- package/lib/contracts/FabricContractRepository.js.map +1 -1
- package/lib/contracts/crud/crud-contract.cjs +14 -0
- package/lib/contracts/crud/crud-contract.d.ts +15 -4
- package/lib/contracts/crud/crud-contract.js.map +1 -1
- package/lib/contracts/crud/serialized-crud-contract.cjs +58 -8
- package/lib/contracts/crud/serialized-crud-contract.d.ts +6 -2
- package/lib/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/contracts/types.d.ts +2 -2
- package/lib/esm/client/FabricClientAdapter.d.ts +28 -42
- package/lib/esm/client/FabricClientAdapter.js +39 -60
- package/lib/esm/client/FabricClientAdapter.js.map +1 -1
- package/lib/esm/client/FabricClientDispatch.d.ts +6 -5
- package/lib/esm/client/FabricClientDispatch.js +3 -5
- package/lib/esm/client/FabricClientDispatch.js.map +1 -1
- package/lib/esm/client/FabricClientPaginator.d.ts +6 -6
- package/lib/esm/client/FabricClientPaginator.js +6 -57
- package/lib/esm/client/FabricClientPaginator.js.map +1 -1
- package/lib/esm/client/FabricClientRepository.d.ts +21 -17
- package/lib/esm/client/FabricClientRepository.js +50 -103
- package/lib/esm/client/FabricClientRepository.js.map +1 -1
- package/lib/esm/client/FabricClientStatement.d.ts +6 -7
- package/lib/esm/client/FabricClientStatement.js +8 -98
- package/lib/esm/client/FabricClientStatement.js.map +1 -1
- package/lib/esm/client/erc20/FabricERC20ClientRepository.d.ts +5 -5
- package/lib/esm/client/erc20/FabricERC20ClientRepository.js.map +1 -1
- package/lib/esm/client/fabric-fs.d.ts +1 -1
- package/lib/esm/client/services/FabricEnrollmentService.d.ts +1 -1
- package/lib/esm/contract/Address.d.ts +13 -0
- package/lib/esm/contract/Address.js +70 -0
- package/lib/esm/contract/Address.js.map +1 -0
- package/lib/esm/contract/AddressContract.d.ts +5 -0
- package/lib/esm/contract/AddressContract.js +31 -0
- package/lib/esm/contract/AddressContract.js.map +1 -0
- package/lib/esm/contract/index.js +6 -1
- package/lib/esm/contract/index.js.map +1 -1
- package/lib/esm/contracts/ContractAdapter.d.ts +3 -3
- package/lib/esm/contracts/ContractAdapter.js +53 -20
- package/lib/esm/contracts/ContractAdapter.js.map +1 -1
- package/lib/esm/contracts/ContractContext.d.ts +1 -1
- package/lib/esm/contracts/ContractContext.js +1 -1
- package/lib/esm/contracts/ContractContext.js.map +1 -1
- package/lib/esm/contracts/FabricContractRepository.js.map +1 -1
- package/lib/esm/contracts/crud/crud-contract.d.ts +15 -4
- package/lib/esm/contracts/crud/crud-contract.js +17 -3
- package/lib/esm/contracts/crud/crud-contract.js.map +1 -1
- package/lib/esm/contracts/crud/serialized-crud-contract.d.ts +6 -2
- package/lib/esm/contracts/crud/serialized-crud-contract.js +58 -8
- package/lib/esm/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/esm/contracts/types.d.ts +2 -2
- package/lib/esm/shared/decorators.d.ts +7 -8
- package/lib/esm/shared/decorators.js +74 -59
- package/lib/esm/shared/decorators.js.map +1 -1
- package/lib/esm/shared/errors.d.ts +3 -0
- package/lib/esm/shared/errors.js +5 -0
- package/lib/esm/shared/errors.js.map +1 -1
- package/lib/esm/shared/overrides/overrides.js +39 -38
- package/lib/esm/shared/overrides/overrides.js.map +1 -1
- package/lib/esm/shared/types.d.ts +5 -9
- package/lib/esm/shared/utils.d.ts +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/shared/decorators.cjs +71 -56
- package/lib/shared/decorators.d.ts +7 -8
- package/lib/shared/decorators.js.map +1 -1
- package/lib/shared/errors.cjs +7 -1
- package/lib/shared/errors.d.ts +3 -0
- package/lib/shared/errors.js.map +1 -1
- package/lib/shared/overrides/overrides.cjs +39 -38
- package/lib/shared/overrides/overrides.js.map +1 -1
- package/lib/shared/types.d.ts +5 -9
- package/lib/shared/utils.d.ts +1 -1
- package/lib/version.cjs +1 -1
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
- package/lib/client/types.cjs +0 -3
- package/lib/client/types.d.ts +0 -7
- package/lib/client/types.js.map +0 -1
- package/lib/esm/client/types.d.ts +0 -7
- package/lib/esm/client/types.js +0 -2
- package/lib/esm/client/types.js.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AdapterFlags, Condition, Statement } from "@decaf-ts/core";
|
|
2
2
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
-
import { FabricQuery } from "./types";
|
|
4
3
|
import { FabricClientAdapter } from "./FabricClientAdapter";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
protected parseCondition(condition: Condition<M
|
|
4
|
+
import { MangoQuery } from "@decaf-ts/for-couchdb";
|
|
5
|
+
export declare class FabricClientStatement<M extends Model, R> extends Statement<M, FabricClientAdapter, R, MangoQuery> {
|
|
6
|
+
constructor(adapter: FabricClientAdapter, overrides?: Partial<AdapterFlags>);
|
|
7
|
+
protected build(): MangoQuery;
|
|
8
|
+
protected parseCondition(condition: Condition<M>, ...args: any[]): MangoQuery;
|
|
10
9
|
}
|
|
@@ -1,107 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { toCamelCase } from "@decaf-ts/logging";
|
|
3
|
-
import { FabricClientPaginator } from "./FabricClientPaginator.js";
|
|
4
|
-
import { InternalError } from "@decaf-ts/db-decorators";
|
|
1
|
+
import { Statement, UnsupportedError, } from "@decaf-ts/core";
|
|
5
2
|
export class FabricClientStatement extends Statement {
|
|
6
|
-
constructor(adapter) {
|
|
7
|
-
super(adapter);
|
|
3
|
+
constructor(adapter, overrides) {
|
|
4
|
+
super(adapter, overrides);
|
|
8
5
|
}
|
|
9
6
|
build() {
|
|
10
|
-
|
|
11
|
-
const args = [];
|
|
12
|
-
const params = {};
|
|
13
|
-
if (this.whereCondition) {
|
|
14
|
-
const parsed = this.parseCondition(this.whereCondition);
|
|
15
|
-
method.push(parsed.method);
|
|
16
|
-
if (parsed.args && parsed.args.length)
|
|
17
|
-
args.push(...parsed.args);
|
|
18
|
-
}
|
|
19
|
-
if (this.selectSelector)
|
|
20
|
-
method.push(QueryClause.SELECT, this.selectSelector.join(` ${QueryClause.AND.toLowerCase()} `));
|
|
21
|
-
if (this.orderBySelector)
|
|
22
|
-
method.push(QueryClause.ORDER_BY, ...this.orderBySelector);
|
|
23
|
-
if (this.groupBySelector)
|
|
24
|
-
method.push(QueryClause.GROUP_BY, this.groupBySelector);
|
|
25
|
-
if (this.limitSelector)
|
|
26
|
-
params.limit = this.limitSelector;
|
|
27
|
-
if (this.offsetSelector) {
|
|
28
|
-
params.skip = this.offsetSelector;
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
class: this.fromSelector,
|
|
32
|
-
method: toCamelCase(method.join(" ")),
|
|
33
|
-
args: args,
|
|
34
|
-
params: Object.keys(params).length ? params : undefined,
|
|
35
|
-
};
|
|
7
|
+
throw new UnsupportedError(`This method is only called is prepared statements are not used. If so, a dedicated implementation for the native queries used is required`);
|
|
36
8
|
}
|
|
37
|
-
|
|
9
|
+
parseCondition(
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
+
condition,
|
|
38
12
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
13
|
...args) {
|
|
40
|
-
|
|
41
|
-
const query = this.build();
|
|
42
|
-
return new FabricClientPaginator(this.adapter, query, size, this.fromSelector);
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
throw new InternalError(e);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
parseCondition(condition) {
|
|
49
|
-
// @ts-expect-error accessing protected properties
|
|
50
|
-
// eslint-disable-next-line prefer-const
|
|
51
|
-
let { attr1, operator, comparison } = condition;
|
|
52
|
-
const result = {};
|
|
53
|
-
switch (operator) {
|
|
54
|
-
case GroupOperator.AND:
|
|
55
|
-
case GroupOperator.OR: {
|
|
56
|
-
let side1 = attr1, side2 = comparison;
|
|
57
|
-
if (typeof attr1 !== "string") {
|
|
58
|
-
const condition1 = this.parseCondition(attr1);
|
|
59
|
-
side1 = condition1.method;
|
|
60
|
-
result.args = [...(result.args || []), ...(condition1.args || [])];
|
|
61
|
-
}
|
|
62
|
-
if (comparison instanceof Condition) {
|
|
63
|
-
const condition2 = this.parseCondition(comparison);
|
|
64
|
-
side2 = condition2.method;
|
|
65
|
-
result.args = [...(result.args || []), ...(condition2.args || [])];
|
|
66
|
-
}
|
|
67
|
-
result.method = `${side1} ${operator.toLowerCase()} ${side2}`;
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
case Operator.EQUAL:
|
|
71
|
-
result.method = attr1;
|
|
72
|
-
result.args = [...(result.args || []), comparison];
|
|
73
|
-
break;
|
|
74
|
-
case Operator.DIFFERENT:
|
|
75
|
-
result.method = `${attr1} diff`;
|
|
76
|
-
result.args = [...(result.args || []), comparison];
|
|
77
|
-
break;
|
|
78
|
-
case Operator.REGEXP:
|
|
79
|
-
result.method = `${attr1} matches`;
|
|
80
|
-
result.args = [...(result.args || []), comparison];
|
|
81
|
-
break;
|
|
82
|
-
case Operator.BIGGER:
|
|
83
|
-
result.method = `${attr1} bigger`;
|
|
84
|
-
result.args = [...(result.args || []), comparison];
|
|
85
|
-
break;
|
|
86
|
-
case Operator.BIGGER_EQ:
|
|
87
|
-
result.method = `${attr1} bigger than equal`;
|
|
88
|
-
break;
|
|
89
|
-
case Operator.SMALLER:
|
|
90
|
-
result.method = `${attr1} less`;
|
|
91
|
-
result.args = [...(result.args || []), comparison];
|
|
92
|
-
break;
|
|
93
|
-
case Operator.SMALLER_EQ:
|
|
94
|
-
result.method = `${attr1} less than equal`;
|
|
95
|
-
result.args = [...(result.args || []), comparison];
|
|
96
|
-
break;
|
|
97
|
-
case Operator.IN:
|
|
98
|
-
result.method = `${attr1} in`;
|
|
99
|
-
result.args = [...(result.args || []), comparison];
|
|
100
|
-
break;
|
|
101
|
-
default:
|
|
102
|
-
throw new QueryError(`Unsupported operator ${operator}`);
|
|
103
|
-
}
|
|
104
|
-
return result;
|
|
14
|
+
throw new UnsupportedError(`This method is only called is prepared statements are not used. Is so, a dedicated implementation for the native queries used is required`);
|
|
105
15
|
}
|
|
106
16
|
}
|
|
107
17
|
//# sourceMappingURL=FabricClientStatement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FabricClientStatement.js","sourceRoot":"","sources":["../../../src/client/FabricClientStatement.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FabricClientStatement.js","sourceRoot":"","sources":["../../../src/client/FabricClientStatement.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EACT,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAKxB,MAAM,OAAO,qBAA0C,SAAQ,SAK9D;IACC,YAAY,OAA4B,EAAE,SAAiC;QACzE,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC5B,CAAC;IAEkB,KAAK;QACtB,MAAM,IAAI,gBAAgB,CACxB,2IAA2I,CAC5I,CAAC;IACJ,CAAC;IAEkB,cAAc;IAC/B,6DAA6D;IAC7D,SAAuB;IACvB,6DAA6D;IAC7D,GAAG,IAAW;QAEd,MAAM,IAAI,gBAAgB,CACxB,2IAA2I,CAC5I,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { FabricClientRepository } from "../FabricClientRepository";
|
|
2
2
|
import { ERC20Token, ERC20Wallet } from "../../contracts/erc20/models";
|
|
3
3
|
import { Model, Serializer } from "@decaf-ts/decorator-validation";
|
|
4
|
-
import { FabricClientAdapter
|
|
5
|
-
import { ContextualArgs, EventIds } from "@decaf-ts/core";
|
|
4
|
+
import { FabricClientAdapter } from "../FabricClientAdapter";
|
|
5
|
+
import { ContextOf, ContextualArgs, EventIds } from "@decaf-ts/core";
|
|
6
6
|
import { BulkCrudOperationKeys, OperationKeys } from "@decaf-ts/db-decorators";
|
|
7
7
|
import { Constructor } from "@decaf-ts/decoration";
|
|
8
8
|
/**
|
|
9
9
|
* Repository for interacting with ERC20 contracts on a Hyperledger Fabric network.
|
|
10
10
|
* Extends the base FabricClientRepository class and utilizes the ClientSerializer for data serialization.
|
|
11
11
|
*/
|
|
12
|
-
export declare class FabricERC20ClientRepository extends FabricClientRepository<ERC20Wallet> {
|
|
12
|
+
export declare class FabricERC20ClientRepository<A extends FabricClientAdapter> extends FabricClientRepository<ERC20Wallet, A> {
|
|
13
13
|
private static serializer;
|
|
14
14
|
protected readonly serializer: Serializer<any>;
|
|
15
15
|
private static decoder;
|
|
@@ -23,7 +23,7 @@ export declare class FabricERC20ClientRepository extends FabricClientRepository<
|
|
|
23
23
|
* @return {Promise<void>} A promise that resolves when all observers have been notified.
|
|
24
24
|
* @throws {InternalError} If the observer handler is not initialized.
|
|
25
25
|
*/
|
|
26
|
-
updateObservers<M extends Model>(table: Constructor<M> | string, event: OperationKeys | BulkCrudOperationKeys | string, id: EventIds, ...args: ContextualArgs<
|
|
26
|
+
updateObservers<M extends Model>(table: Constructor<M> | string, event: OperationKeys | BulkCrudOperationKeys | string, id: EventIds, ...args: ContextualArgs<ContextOf<A>>): Promise<void>;
|
|
27
27
|
/**
|
|
28
28
|
* Decodes a Uint8Array into a string using the TextDecoder.
|
|
29
29
|
*
|
|
@@ -31,7 +31,7 @@ export declare class FabricERC20ClientRepository extends FabricClientRepository<
|
|
|
31
31
|
* @returns The decoded string.
|
|
32
32
|
*/
|
|
33
33
|
decode(data: Uint8Array): string;
|
|
34
|
-
constructor(adapter?:
|
|
34
|
+
constructor(adapter?: A);
|
|
35
35
|
/**
|
|
36
36
|
* Retrieves the name of the ERC20 token.
|
|
37
37
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FabricERC20ClientRepository.js","sourceRoot":"","sources":["../../../../src/client/erc20/FabricERC20ClientRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,uCAAkC;AACnE,OAAO,EAAc,WAAW,EAAE,0CAAqC;AACvE,OAAO,EAAE,KAAK,EAAc,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"FabricERC20ClientRepository.js","sourceRoot":"","sources":["../../../../src/client/erc20/FabricERC20ClientRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,uCAAkC;AACnE,OAAO,EAAc,WAAW,EAAE,0CAAqC;AACvE,OAAO,EAAE,KAAK,EAAc,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,2CAAsC;AACjE,OAAO,EAAuC,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAEL,aAAa,GAEd,MAAM,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,MAAM,OAAO,2BAEX,SAAQ,sBAAsC;aAC/B,eAAU,GAAG,IAAI,gBAAgB,EAAE,AAAzB,CAA0B;aAKpC,YAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,AAA1B,CAA2B;IAEjD;;;;;;;;;OASG;IACM,KAAK,CAAC,eAAe,CAC5B,KAA8B,EAC9B,KAAqD,EACrD,EAAY,EACZ,GAAG,IAAkC;QAErC,IAAI,CAAC,IAAI,CAAC,eAAe;YACvB,MAAM,IAAI,aAAa,CACrB,oEAAoE,CACrE,CAAC;QACJ,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACjE,GAAG,CAAC,OAAO,CACT,YAAY,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,kBAAkB,IAAI,EAAE,CACjE,CAAC;QAEF,KAAK,GAAG,CACN,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CACnC,CAAC;QACpB,IAAI,QAAuC,CAAC;QAE5C,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YAC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IACH,KAAK,CAAC,IAAI,CAAC,MAAc;QACvB,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,IAAI,CAAC,MAAc;QACvB,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAe,EAAE,MAAc;QAC5C,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,EAAE;YAC/C,OAAO;YACP,MAAM,CAAC,QAAQ,EAAE;SAClB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,oBAAoB;QACxB,MAAM,wBAAwB,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CACrE,sBAAsB,CACvB,CAAC;QAEF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,eAAe;QACnB,MAAM,eAAe,GACnB,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACtC,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare function contentOfLoadFile(contentOrPath: string | Uint8Array, fi
|
|
|
18
18
|
* @function readFile
|
|
19
19
|
* @memberOf module:for-fabric.client
|
|
20
20
|
*/
|
|
21
|
-
export declare function readFile(contentOrPath: string | Buffer): Promise<
|
|
21
|
+
export declare function readFile(contentOrPath: string | Buffer): Promise<Buffer<ArrayBufferLike>>;
|
|
22
22
|
/**
|
|
23
23
|
* @description Creates a Certificate Authority user
|
|
24
24
|
* @summary Initializes a user with the given credentials for interacting with a Fabric CA
|
|
@@ -115,7 +115,7 @@ export declare class FabricEnrollmentService extends LoggedClass {
|
|
|
115
115
|
* @return {Promise<FabricIdentity[]>} The list of identities registered in the CA.
|
|
116
116
|
*/
|
|
117
117
|
getIdentities(): Promise<FabricIdentity[]>;
|
|
118
|
-
protected parseError(e: Error):
|
|
118
|
+
protected parseError(e: Error): AuthorizationError | ConflictError;
|
|
119
119
|
/**
|
|
120
120
|
* @description Retrieve affiliations from the CA.
|
|
121
121
|
* @summary Queries the CA for the list of affiliations available under the configured CA.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Model, type ModelArg } from "@decaf-ts/decorator-validation";
|
|
2
|
+
export declare class Address extends Model {
|
|
3
|
+
id: number;
|
|
4
|
+
city: string;
|
|
5
|
+
street: string;
|
|
6
|
+
number: number;
|
|
7
|
+
createdAt: Date;
|
|
8
|
+
updatedAt: Date;
|
|
9
|
+
createdBy: string;
|
|
10
|
+
updatedBy: string;
|
|
11
|
+
msp: string;
|
|
12
|
+
constructor(arg?: ModelArg<Address>);
|
|
13
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { model, Model, required, } from "@decaf-ts/decorator-validation";
|
|
11
|
+
import { column, createdAt, pk, table, createdBy, updatedAt, updatedBy, } from "@decaf-ts/core";
|
|
12
|
+
import { uses } from "@decaf-ts/decoration";
|
|
13
|
+
import { FabricFlavour, ownedBy } from "./../shared/index.js";
|
|
14
|
+
let Address = class Address extends Model {
|
|
15
|
+
constructor(arg) {
|
|
16
|
+
super(arg);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
__decorate([
|
|
20
|
+
pk(),
|
|
21
|
+
__metadata("design:type", Number)
|
|
22
|
+
], Address.prototype, "id", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
column(),
|
|
25
|
+
required(),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], Address.prototype, "city", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
column(),
|
|
30
|
+
required(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], Address.prototype, "street", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
column(),
|
|
35
|
+
required(),
|
|
36
|
+
__metadata("design:type", Number)
|
|
37
|
+
], Address.prototype, "number", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
column(),
|
|
40
|
+
createdAt(),
|
|
41
|
+
__metadata("design:type", Date)
|
|
42
|
+
], Address.prototype, "createdAt", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
column(),
|
|
45
|
+
updatedAt(),
|
|
46
|
+
__metadata("design:type", Date)
|
|
47
|
+
], Address.prototype, "updatedAt", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
column(),
|
|
50
|
+
createdBy(),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], Address.prototype, "createdBy", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
column(),
|
|
55
|
+
updatedBy(),
|
|
56
|
+
__metadata("design:type", String)
|
|
57
|
+
], Address.prototype, "updatedBy", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
column(),
|
|
60
|
+
ownedBy(),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], Address.prototype, "msp", void 0);
|
|
63
|
+
Address = __decorate([
|
|
64
|
+
uses(FabricFlavour),
|
|
65
|
+
table(),
|
|
66
|
+
model(),
|
|
67
|
+
__metadata("design:paramtypes", [Object])
|
|
68
|
+
], Address);
|
|
69
|
+
export { Address };
|
|
70
|
+
//# sourceMappingURL=Address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Address.js","sourceRoot":"","sources":["../../../src/contract/Address.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,KAAK,EACL,KAAK,EAEL,QAAQ,GACT,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,MAAM,EACN,SAAS,EACT,EAAE,EACF,KAAK,EACL,SAAS,EACT,SAAS,EACT,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,6BAAwB;AAKlD,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,KAAK;IAoChC,YAAY,GAAuB;QACjC,KAAK,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;CACF,CAAA;AArCC;IADC,EAAE,EAAE;;mCACO;AAIZ;IAFC,MAAM,EAAE;IACR,QAAQ,EAAE;;qCACG;AAId;IAFC,MAAM,EAAE;IACR,QAAQ,EAAE;;uCACK;AAIhB;IAFC,MAAM,EAAE;IACR,QAAQ,EAAE;;uCACK;AAIhB;IAFC,MAAM,EAAE;IACR,SAAS,EAAE;8BACA,IAAI;0CAAC;AAIjB;IAFC,MAAM,EAAE;IACR,SAAS,EAAE;8BACA,IAAI;0CAAC;AAIjB;IAFC,MAAM,EAAE;IACR,SAAS,EAAE;;0CACO;AAInB;IAFC,MAAM,EAAE;IACR,SAAS,EAAE;;0CACO;AAInB;IAFC,MAAM,EAAE;IACR,OAAO,EAAE;;oCACG;AAlCF,OAAO;IAHnB,IAAI,CAAC,aAAa,CAAC;IACnB,KAAK,EAAE;IACP,KAAK,EAAE;;GACK,OAAO,CAuCnB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var AddressContract_1;
|
|
11
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
12
|
+
import { Info, Object as FabricObject } from "fabric-contract-api";
|
|
13
|
+
import { BaseModel } from "@decaf-ts/core";
|
|
14
|
+
import { SerializedCrudContract } from "./../contracts/crud/serialized-crud-contract.js";
|
|
15
|
+
import { Address } from "./Address.js";
|
|
16
|
+
FabricObject()(Model);
|
|
17
|
+
FabricObject()(BaseModel);
|
|
18
|
+
let AddressContract = AddressContract_1 = class AddressContract extends SerializedCrudContract {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(AddressContract_1.name, Address);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
AddressContract = AddressContract_1 = __decorate([
|
|
24
|
+
Info({
|
|
25
|
+
title: "AddressContract",
|
|
26
|
+
description: "Contract managing the Addresses",
|
|
27
|
+
}),
|
|
28
|
+
__metadata("design:paramtypes", [])
|
|
29
|
+
], AddressContract);
|
|
30
|
+
export { AddressContract };
|
|
31
|
+
//# sourceMappingURL=AddressContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddressContract.js","sourceRoot":"","sources":["../../../src/contract/AddressContract.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,wDAAmD;AACpF,OAAO,EAAE,OAAO,EAAE,qBAAkB;AAEpC,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC;AACtB,YAAY,EAAE,CAAC,SAAS,CAAC,CAAC;AAMnB,IAAM,eAAe,uBAArB,MAAM,eAAgB,SAAQ,sBAA+B;IAClE;QACE,KAAK,CAAC,iBAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;CACF,CAAA;AAJY,eAAe;IAJ3B,IAAI,CAAC;QACJ,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,iCAAiC;KAC/C,CAAC;;GACW,eAAe,CAI3B"}
|
|
@@ -2,5 +2,10 @@ import { FabricCrudContract } from "./../contracts/crud/crud-contract.js";
|
|
|
2
2
|
console.log(FabricCrudContract.name);
|
|
3
3
|
import { ProductContract } from "./ProductContract.js";
|
|
4
4
|
import { UserContract } from "./UserContract.js";
|
|
5
|
-
|
|
5
|
+
import { AddressContract } from "./AddressContract.js";
|
|
6
|
+
export const contracts = [
|
|
7
|
+
ProductContract,
|
|
8
|
+
UserContract,
|
|
9
|
+
AddressContract,
|
|
10
|
+
];
|
|
6
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,6CAAwC;AACrE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,6BAA0B;AACpD,OAAO,EAAE,YAAY,EAAE,0BAAuB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,6CAAwC;AACrE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,6BAA0B;AACpD,OAAO,EAAE,YAAY,EAAE,0BAAuB;AAC9C,OAAO,EAAE,eAAe,EAAE,6BAA0B;AAEpD,MAAM,CAAC,MAAM,SAAS,GAAwB;IAC5C,eAAe;IACf,YAAY;IACZ,eAAe;CAChB,CAAC"}
|
|
@@ -2,10 +2,10 @@ import { CouchDBAdapter, MangoQuery } from "@decaf-ts/for-couchdb";
|
|
|
2
2
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
3
|
import { FabricContractFlags } from "./types";
|
|
4
4
|
import { FabricContractContext } from "./ContractContext";
|
|
5
|
-
import { BaseError,
|
|
5
|
+
import { BaseError, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
6
6
|
import { Context as Ctx } from "fabric-contract-api";
|
|
7
7
|
import { Logger } from "@decaf-ts/logging";
|
|
8
|
-
import { RelationsMetadata, SequenceOptions, Adapter, PreparedModel, Repository, ContextualizedArgs } from "@decaf-ts/core";
|
|
8
|
+
import { RelationsMetadata, SequenceOptions, Adapter, PreparedModel, Repository, ContextualizedArgs, Context, RawResult } from "@decaf-ts/core";
|
|
9
9
|
import type { ContextualArgs, MaybeContextualArg } from "@decaf-ts/core";
|
|
10
10
|
import { FabricContractRepository } from "./FabricContractRepository";
|
|
11
11
|
import { ChaincodeStub, ClientIdentity, Iterators, StateQueryResponse } from "fabric-shim-api";
|
|
@@ -259,7 +259,7 @@ export declare class FabricContractAdapter extends CouchDBAdapter<any, void, Fab
|
|
|
259
259
|
* FabricContractAdapter->>FabricContractAdapter: resultIterator(log, iterator)
|
|
260
260
|
* FabricContractAdapter-->>Caller: results
|
|
261
261
|
*/
|
|
262
|
-
raw<R>(rawInput: MangoQuery, ...args: ContextualArgs<FabricContractContext>): Promise<R
|
|
262
|
+
raw<R, D extends boolean>(rawInput: MangoQuery, docsOnly?: D, ...args: ContextualArgs<FabricContractContext>): Promise<RawResult<R, D>>;
|
|
263
263
|
Statement<M extends Model>(): FabricStatement<M, any>;
|
|
264
264
|
createAll<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType[], model: Record<string, any>[], ...args: ContextualArgs<FabricContractContext>): Promise<Record<string, any>[]>;
|
|
265
265
|
updateAll<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType[], model: Record<string, any>[], ...args: ContextualArgs<FabricContractContext>): Promise<Record<string, any>[]>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CouchDBAdapter, CouchDBKeys } from "@decaf-ts/for-couchdb";
|
|
2
2
|
import { list, Model, required, type } from "@decaf-ts/decorator-validation";
|
|
3
3
|
import { FabricContractContext } from "./ContractContext.js";
|
|
4
|
-
import { afterAny, BadRequestError, ConflictError,
|
|
4
|
+
import { afterAny, BadRequestError, ConflictError, DBKeys, InternalError, NotFoundError, onCreate, onCreateUpdate, onDelete, onUpdate, readonly, SerializationError, } from "@decaf-ts/db-decorators";
|
|
5
5
|
import { Object as FabricObject, Property as FabricProperty, } from "fabric-contract-api";
|
|
6
|
-
import { PersistenceKeys, UnsupportedError, Adapter, oneToManyOnUpdate, relation, QueryError, PagingError, MigrationError, ObserverError, AuthorizationError, ForbiddenError, ConnectionError, } from "@decaf-ts/core";
|
|
6
|
+
import { PersistenceKeys, UnsupportedError, Adapter, oneToManyOnUpdate, relation, QueryError, PagingError, MigrationError, ObserverError, AuthorizationError, ForbiddenError, ConnectionError, Context, } from "@decaf-ts/core";
|
|
7
7
|
import { FabricContractRepository } from "./FabricContractRepository.js";
|
|
8
8
|
import { FabricStatement } from "./FabricContractStatement.js";
|
|
9
9
|
import { FabricFlavour } from "./../shared/constants.js";
|
|
@@ -364,17 +364,26 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
364
364
|
catch (e) {
|
|
365
365
|
throw new SerializationError(`Failed to serialize record with id ${id}: ${e}`);
|
|
366
366
|
}
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
const collection = ctx.get("segregated");
|
|
368
|
+
if (collection)
|
|
369
|
+
await stub.putPrivateData(collection, id.toString(), data);
|
|
370
|
+
else
|
|
371
|
+
await stub.putState(id.toString(), data);
|
|
372
|
+
log.silly(`state stored${collection ? ` in ${collection} collection` : ""} under id ${id}`);
|
|
369
373
|
return model;
|
|
370
374
|
}
|
|
371
375
|
async readState(id, ctx) {
|
|
372
376
|
let result;
|
|
373
377
|
const { stub, log } = this.logCtx([ctx], this.readState);
|
|
374
|
-
|
|
378
|
+
let res;
|
|
379
|
+
const collection = ctx.get("segregated");
|
|
380
|
+
if (collection)
|
|
381
|
+
res = (await stub.getPrivateData(collection, id.toString())).toString();
|
|
382
|
+
else
|
|
383
|
+
res = (await stub.getState(id.toString())).toString();
|
|
375
384
|
if (!res)
|
|
376
|
-
throw new NotFoundError(`Record with id ${id} not found`);
|
|
377
|
-
log.silly(`
|
|
385
|
+
throw new NotFoundError(`Record with id ${id}${collection ? ` in ${collection} collection` : ""} not found`);
|
|
386
|
+
log.silly(`state retrieved from${collection ? ` ${collection} collection` : ""} under id ${id}`);
|
|
378
387
|
try {
|
|
379
388
|
result = FabricContractAdapter.serializer.deserialize(res.toString());
|
|
380
389
|
}
|
|
@@ -383,15 +392,37 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
383
392
|
}
|
|
384
393
|
return result;
|
|
385
394
|
}
|
|
386
|
-
async queryResult(stub, rawInput,
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
return
|
|
395
|
+
async queryResult(stub, rawInput, ...args) {
|
|
396
|
+
const { ctx } = this.logCtx(args, this.readState);
|
|
397
|
+
let res;
|
|
398
|
+
const collection = ctx.get("segregated");
|
|
399
|
+
if (collection)
|
|
400
|
+
res = await stub.getPrivateDataQueryResult(collection, JSON.stringify(rawInput));
|
|
401
|
+
else
|
|
402
|
+
res = await stub.getQueryResult(JSON.stringify(rawInput));
|
|
403
|
+
return res;
|
|
404
|
+
}
|
|
405
|
+
async queryResultPaginated(stub, rawInput, limit = 250, skip, ...args) {
|
|
406
|
+
const { ctx } = this.logCtx(args, this.readState);
|
|
407
|
+
let res;
|
|
408
|
+
const collection = ctx.get("segregated");
|
|
409
|
+
if (collection) {
|
|
410
|
+
rawInput.selector = {
|
|
411
|
+
...rawInput.selector,
|
|
412
|
+
_id: skip ? { $gt: skip.toString() } : { $gte: "" },
|
|
413
|
+
};
|
|
414
|
+
const it = await stub.getPrivateDataQueryResult(collection, JSON.stringify(rawInput));
|
|
415
|
+
res = {
|
|
416
|
+
iterator: it,
|
|
417
|
+
metadata: {
|
|
418
|
+
fetchedRecordsCount: limit,
|
|
419
|
+
bookmark: "",
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
else
|
|
424
|
+
res = await stub.getQueryResultWithPagination(JSON.stringify(rawInput), limit, skip?.toString());
|
|
425
|
+
return res;
|
|
395
426
|
}
|
|
396
427
|
mergeModels(results) {
|
|
397
428
|
const extract = (model) => Object.entries(model).reduce((accum, [key, val]) => {
|
|
@@ -427,6 +458,7 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
427
458
|
async flags(operation, model, flags, ctx, ...args) {
|
|
428
459
|
const baseFlags = {
|
|
429
460
|
stub: ctx.stub,
|
|
461
|
+
segregated: false,
|
|
430
462
|
};
|
|
431
463
|
if (ctx instanceof FabricContractContext) {
|
|
432
464
|
Object.assign(baseFlags, {
|
|
@@ -544,9 +576,10 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
544
576
|
* FabricContractAdapter->>FabricContractAdapter: resultIterator(log, iterator)
|
|
545
577
|
* FabricContractAdapter-->>Caller: results
|
|
546
578
|
*/
|
|
547
|
-
async raw(rawInput,
|
|
548
|
-
|
|
549
|
-
|
|
579
|
+
async raw(rawInput,
|
|
580
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
581
|
+
docsOnly = true, ...args) {
|
|
582
|
+
const { log, stub } = this.logCtx(args, this.raw);
|
|
550
583
|
const { skip, limit } = rawInput;
|
|
551
584
|
let iterator;
|
|
552
585
|
if (limit || skip) {
|
|
@@ -562,7 +595,7 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
562
595
|
}
|
|
563
596
|
log.debug("Iterator acquired");
|
|
564
597
|
const results = (await this.resultIterator(log, iterator));
|
|
565
|
-
log.debug(`returning {
|
|
598
|
+
log.debug(`returning ${Array.isArray(results) ? results.length : 1} results`);
|
|
566
599
|
return results;
|
|
567
600
|
}
|
|
568
601
|
Statement() {
|