@decaf-ts/for-fabric 0.1.74 → 0.1.76
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/cli-module.cjs +43 -13
- package/lib/cli-module.js.map +1 -1
- package/lib/cli-utils.cjs +10 -4
- package/lib/cli-utils.d.ts +2 -2
- package/lib/cli-utils.js.map +1 -1
- package/lib/client/FabricClientAdapter.cjs +36 -1
- package/lib/client/FabricClientAdapter.d.ts +12 -1
- package/lib/client/FabricClientAdapter.js.map +1 -1
- package/lib/client/FabricClientRepository.cjs +36 -0
- package/lib/client/FabricClientRepository.d.ts +7 -0
- package/lib/client/FabricClientRepository.js.map +1 -1
- package/lib/client/FabricClientStatement.cjs +321 -18
- package/lib/client/FabricClientStatement.d.ts +52 -1
- package/lib/client/FabricClientStatement.js.map +1 -1
- package/lib/client/collections/generation.cjs +7 -0
- package/lib/client/collections/generation.d.ts +2 -0
- package/lib/client/collections/generation.js.map +1 -1
- package/lib/client/fabric-fs.d.ts +1 -1
- package/lib/client/indexes/generation.cjs +37 -79
- package/lib/client/indexes/generation.d.ts +5 -12
- package/lib/client/indexes/generation.js.map +1 -1
- package/lib/client/utils.d.ts +1 -1
- package/lib/contract/Product.cjs +1 -1
- package/lib/contract/Product.js.map +1 -1
- package/lib/contract/SegregatedPrivateDocumentContract.cjs +30 -0
- package/lib/contract/SegregatedPrivateDocumentContract.d.ts +5 -0
- package/lib/contract/SegregatedPrivateDocumentContract.js.map +1 -0
- package/lib/contract/SegregatedSharedDocumentContract.cjs +30 -0
- package/lib/contract/SegregatedSharedDocumentContract.d.ts +5 -0
- package/lib/contract/SegregatedSharedDocumentContract.js.map +1 -0
- package/lib/contract/User.cjs +1 -1
- package/lib/contract/User.js.map +1 -1
- package/lib/contract/index.cjs +4 -0
- package/lib/contract/index.js.map +1 -1
- package/lib/contract/models/Market.cjs +1 -1
- package/lib/contract/models/Market.js.map +1 -1
- package/lib/contract/models/OtherProductShared.cjs +2 -2
- package/lib/contract/models/OtherProductShared.js.map +1 -1
- package/lib/contract/models/SegregatedDocument.cjs +94 -0
- package/lib/contract/models/SegregatedDocument.d.ts +18 -0
- package/lib/contract/models/SegregatedDocument.js.map +1 -0
- package/lib/contracts/ContractAdapter.cjs +177 -25
- package/lib/contracts/ContractAdapter.d.ts +8 -1
- package/lib/contracts/ContractAdapter.js.map +1 -1
- package/lib/contracts/ContractContext.cjs +29 -0
- package/lib/contracts/ContractContext.d.ts +16 -0
- package/lib/contracts/ContractContext.js.map +1 -1
- package/lib/contracts/FabricContractSequence.cjs +44 -0
- package/lib/contracts/FabricContractSequence.d.ts +10 -0
- package/lib/contracts/FabricContractSequence.js.map +1 -1
- package/lib/contracts/FabricContractStatement.cjs +1 -86
- package/lib/contracts/FabricContractStatement.d.ts +2 -4
- package/lib/contracts/FabricContractStatement.js.map +1 -1
- package/lib/contracts/crud/crud-contract.cjs +35 -0
- package/lib/contracts/crud/crud-contract.d.ts +7 -0
- package/lib/contracts/crud/crud-contract.js.map +1 -1
- package/lib/contracts/crud/serialized-crud-contract.cjs +63 -0
- package/lib/contracts/crud/serialized-crud-contract.d.ts +7 -0
- package/lib/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/contracts/types.d.ts +2 -1
- package/lib/esm/cli-module.js +45 -15
- package/lib/esm/cli-module.js.map +1 -1
- package/lib/esm/cli-utils.d.ts +2 -2
- package/lib/esm/cli-utils.js +10 -4
- package/lib/esm/cli-utils.js.map +1 -1
- package/lib/esm/client/FabricClientAdapter.d.ts +12 -1
- package/lib/esm/client/FabricClientAdapter.js +36 -1
- package/lib/esm/client/FabricClientAdapter.js.map +1 -1
- package/lib/esm/client/FabricClientRepository.d.ts +7 -0
- package/lib/esm/client/FabricClientRepository.js +36 -0
- package/lib/esm/client/FabricClientRepository.js.map +1 -1
- package/lib/esm/client/FabricClientStatement.d.ts +52 -1
- package/lib/esm/client/FabricClientStatement.js +323 -20
- package/lib/esm/client/FabricClientStatement.js.map +1 -1
- package/lib/esm/client/collections/generation.d.ts +2 -0
- package/lib/esm/client/collections/generation.js +6 -0
- package/lib/esm/client/collections/generation.js.map +1 -1
- package/lib/esm/client/fabric-fs.d.ts +1 -1
- package/lib/esm/client/indexes/generation.d.ts +5 -12
- package/lib/esm/client/indexes/generation.js +36 -80
- package/lib/esm/client/indexes/generation.js.map +1 -1
- package/lib/esm/client/utils.d.ts +1 -1
- package/lib/esm/contract/Product.js +1 -1
- package/lib/esm/contract/Product.js.map +1 -1
- package/lib/esm/contract/SegregatedPrivateDocumentContract.d.ts +5 -0
- package/lib/esm/contract/SegregatedPrivateDocumentContract.js +27 -0
- package/lib/esm/contract/SegregatedPrivateDocumentContract.js.map +1 -0
- package/lib/esm/contract/SegregatedSharedDocumentContract.d.ts +5 -0
- package/lib/esm/contract/SegregatedSharedDocumentContract.js +27 -0
- package/lib/esm/contract/SegregatedSharedDocumentContract.js.map +1 -0
- package/lib/esm/contract/User.js +1 -1
- package/lib/esm/contract/User.js.map +1 -1
- package/lib/esm/contract/index.js +4 -0
- package/lib/esm/contract/index.js.map +1 -1
- package/lib/esm/contract/models/Market.js +1 -1
- package/lib/esm/contract/models/Market.js.map +1 -1
- package/lib/esm/contract/models/OtherProductShared.js +4 -4
- package/lib/esm/contract/models/OtherProductShared.js.map +1 -1
- package/lib/esm/contract/models/SegregatedDocument.d.ts +18 -0
- package/lib/esm/contract/models/SegregatedDocument.js +91 -0
- package/lib/esm/contract/models/SegregatedDocument.js.map +1 -0
- package/lib/esm/contracts/ContractAdapter.d.ts +8 -1
- package/lib/esm/contracts/ContractAdapter.js +178 -26
- package/lib/esm/contracts/ContractAdapter.js.map +1 -1
- package/lib/esm/contracts/ContractContext.d.ts +16 -0
- package/lib/esm/contracts/ContractContext.js +29 -0
- package/lib/esm/contracts/ContractContext.js.map +1 -1
- package/lib/esm/contracts/FabricContractSequence.d.ts +10 -0
- package/lib/esm/contracts/FabricContractSequence.js +44 -0
- package/lib/esm/contracts/FabricContractSequence.js.map +1 -1
- package/lib/esm/contracts/FabricContractStatement.d.ts +2 -4
- package/lib/esm/contracts/FabricContractStatement.js +1 -86
- package/lib/esm/contracts/FabricContractStatement.js.map +1 -1
- package/lib/esm/contracts/crud/crud-contract.d.ts +7 -0
- package/lib/esm/contracts/crud/crud-contract.js +35 -0
- package/lib/esm/contracts/crud/crud-contract.js.map +1 -1
- package/lib/esm/contracts/crud/serialized-crud-contract.d.ts +7 -0
- package/lib/esm/contracts/crud/serialized-crud-contract.js +63 -0
- package/lib/esm/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/esm/contracts/types.d.ts +2 -1
- package/lib/esm/shared/decorators.d.ts +23 -4
- package/lib/esm/shared/decorators.js +147 -53
- package/lib/esm/shared/decorators.js.map +1 -1
- package/lib/esm/shared/overrides/overrides.js +20 -13
- package/lib/esm/shared/overrides/overrides.js.map +1 -1
- package/lib/esm/shared/types.d.ts +2 -0
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/shared/decorators.cjs +149 -53
- package/lib/shared/decorators.d.ts +23 -4
- package/lib/shared/decorators.js.map +1 -1
- package/lib/shared/overrides/overrides.cjs +20 -13
- package/lib/shared/overrides/overrides.js.map +1 -1
- package/lib/shared/types.d.ts +2 -0
- package/lib/version.cjs +1 -1
- package/lib/version.d.ts +1 -1
- package/package.json +3 -5
|
@@ -30,7 +30,7 @@ export declare class CoreUtils {
|
|
|
30
30
|
* @param {string|Buffer} contentOrPath - Path to a file on disk or an already-loaded Buffer
|
|
31
31
|
* @return {Promise<string|Uint8Array|Buffer>} The file content as a Buffer/string depending on reader
|
|
32
32
|
*/
|
|
33
|
-
static readFile(contentOrPath: string | Buffer): Promise<
|
|
33
|
+
static readFile(contentOrPath: string | Buffer): Promise<NonSharedBuffer>;
|
|
34
34
|
/**
|
|
35
35
|
* @description Create a Fabric CA User object with enrollment
|
|
36
36
|
* @summary Constructs a fabric-common User, sets a crypto suite, imports the provided private key, and sets enrollment with certificate and MSP ID.
|
|
@@ -19,7 +19,7 @@ let Product = class Product extends FabricIdentifiedBaseModel {
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
__decorate([
|
|
22
|
-
pk({ type:
|
|
22
|
+
pk({ type: Number, generated: true }),
|
|
23
23
|
__metadata("design:type", Number)
|
|
24
24
|
], Product.prototype, "productCode", void 0);
|
|
25
25
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Product.js","sourceRoot":"","sources":["../../../src/contract/Product.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAiB,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iCAA4B;AACpD,OAAO,EAAE,yBAAyB,EAAE,uDAAkD;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAKrC,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,yBAAyB;IAQpD,YAAY,IAAwB;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;CACF,CAAA;AATC;IADC,EAAE,CAAC,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"Product.js","sourceRoot":"","sources":["../../../src/contract/Product.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAiB,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iCAA4B;AACpD,OAAO,EAAE,yBAAyB,EAAE,uDAAkD;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAKrC,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,yBAAyB;IAQpD,YAAY,IAAwB;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;CACF,CAAA;AATC;IADC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;4CACjB;AAIrB;IAFC,MAAM,EAAE;IACR,QAAQ,EAAE;;6CACW;AANX,OAAO;IAHnB,IAAI,CAAC,aAAa,CAAC;IACnB,KAAK,EAAE;IACP,KAAK,EAAE;;GACK,OAAO,CAWnB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SerializedCrudContract } from "../contracts/crud/serialized-crud-contract";
|
|
2
|
+
import { SegregatedPrivateDocument } from "./models/SegregatedDocument";
|
|
3
|
+
export declare class SegregatedPrivateDocumentContract extends SerializedCrudContract<SegregatedPrivateDocument> {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 SegregatedPrivateDocumentContract_1;
|
|
11
|
+
import { Info } from "fabric-contract-api";
|
|
12
|
+
import { SerializedCrudContract } from "./../contracts/crud/serialized-crud-contract.js";
|
|
13
|
+
import { SegregatedPrivateDocument } from "./models/SegregatedDocument.js";
|
|
14
|
+
let SegregatedPrivateDocumentContract = SegregatedPrivateDocumentContract_1 = class SegregatedPrivateDocumentContract extends SerializedCrudContract {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(SegregatedPrivateDocumentContract_1.name, SegregatedPrivateDocument);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
SegregatedPrivateDocumentContract = SegregatedPrivateDocumentContract_1 = __decorate([
|
|
20
|
+
Info({
|
|
21
|
+
title: "SegregatedPrivateDocumentContract",
|
|
22
|
+
description: "Handles CRUD for documents split across segregated private collections.",
|
|
23
|
+
}),
|
|
24
|
+
__metadata("design:paramtypes", [])
|
|
25
|
+
], SegregatedPrivateDocumentContract);
|
|
26
|
+
export { SegregatedPrivateDocumentContract };
|
|
27
|
+
//# sourceMappingURL=SegregatedPrivateDocumentContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegregatedPrivateDocumentContract.js","sourceRoot":"","sources":["../../../src/contract/SegregatedPrivateDocumentContract.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,wDAAmD;AACpF,OAAO,EAAE,yBAAyB,EAAE,uCAAoC;AAMjE,IAAM,iCAAiC,yCAAvC,MAAM,iCAAkC,SAAQ,sBAEtD;IACC;QACE,KAAK,CACH,mCAAiC,CAAC,IAAI,EACtC,yBAAyB,CAC1B,CAAC;IACJ,CAAC;CACF,CAAA;AATY,iCAAiC;IAJ7C,IAAI,CAAC;QACJ,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EAAE,yEAAyE;KACvF,CAAC;;GACW,iCAAiC,CAS7C"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SerializedCrudContract } from "../contracts/crud/serialized-crud-contract";
|
|
2
|
+
import { SegregatedSharedDocument } from "./models/SegregatedDocument";
|
|
3
|
+
export declare class SegregatedSharedDocumentContract extends SerializedCrudContract<SegregatedSharedDocument> {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 SegregatedSharedDocumentContract_1;
|
|
11
|
+
import { Info } from "fabric-contract-api";
|
|
12
|
+
import { SerializedCrudContract } from "./../contracts/crud/serialized-crud-contract.js";
|
|
13
|
+
import { SegregatedSharedDocument } from "./models/SegregatedDocument.js";
|
|
14
|
+
let SegregatedSharedDocumentContract = SegregatedSharedDocumentContract_1 = class SegregatedSharedDocumentContract extends SerializedCrudContract {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(SegregatedSharedDocumentContract_1.name, SegregatedSharedDocument);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
SegregatedSharedDocumentContract = SegregatedSharedDocumentContract_1 = __decorate([
|
|
20
|
+
Info({
|
|
21
|
+
title: "SegregatedSharedDocumentContract",
|
|
22
|
+
description: "Handles CRUD for documents split across segregated shared collections.",
|
|
23
|
+
}),
|
|
24
|
+
__metadata("design:paramtypes", [])
|
|
25
|
+
], SegregatedSharedDocumentContract);
|
|
26
|
+
export { SegregatedSharedDocumentContract };
|
|
27
|
+
//# sourceMappingURL=SegregatedSharedDocumentContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegregatedSharedDocumentContract.js","sourceRoot":"","sources":["../../../src/contract/SegregatedSharedDocumentContract.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,wDAAmD;AACpF,OAAO,EAAE,wBAAwB,EAAE,uCAAoC;AAMhE,IAAM,gCAAgC,wCAAtC,MAAM,gCAAiC,SAAQ,sBAErD;IACC;QACE,KAAK,CACH,kCAAgC,CAAC,IAAI,EACrC,wBAAwB,CACzB,CAAC;IACJ,CAAC;CACF,CAAA;AATY,gCAAgC;IAJ5C,IAAI,CAAC;QACJ,KAAK,EAAE,kCAAkC;QACzC,WAAW,EAAE,wEAAwE;KACtF,CAAC;;GACW,gCAAgC,CAS5C"}
|
package/lib/esm/contract/User.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../src/contract/User.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iCAA4B;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAKrC,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,KAAK;IAO7B,YAAY,IAAqB;QAC/B,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;CACF,CAAA;AARC;IADC,EAAE,CAAC,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../src/contract/User.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iCAA4B;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAKrC,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,KAAK;IAO7B,YAAY,IAAqB;QAC/B,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;CACF,CAAA;AARC;IADC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;gCAC1B;AAGZ;IADC,MAAM,EAAE;;kCACK;AALH,IAAI;IAHhB,IAAI,CAAC,aAAa,CAAC;IACnB,KAAK,EAAE;IACP,KAAK,EAAE;;GACK,IAAI,CAUhB"}
|
|
@@ -5,11 +5,15 @@ import { BatchContract } from "./BatchContract.js";
|
|
|
5
5
|
import { UserContract } from "./UserContract.js";
|
|
6
6
|
import { AddressContract } from "./AddressContract.js";
|
|
7
7
|
import { OtherProductSharedContract } from "./OtherProductSharedContract.js";
|
|
8
|
+
import { SegregatedPrivateDocumentContract } from "./SegregatedPrivateDocumentContract.js";
|
|
9
|
+
import { SegregatedSharedDocumentContract } from "./SegregatedSharedDocumentContract.js";
|
|
8
10
|
export const contracts = [
|
|
9
11
|
ProductContract,
|
|
10
12
|
BatchContract,
|
|
11
13
|
UserContract,
|
|
12
14
|
AddressContract,
|
|
13
15
|
OtherProductSharedContract,
|
|
16
|
+
SegregatedPrivateDocumentContract,
|
|
17
|
+
SegregatedSharedDocumentContract,
|
|
14
18
|
];
|
|
15
19
|
//# 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,aAAa,EAAE,2BAAwB;AAChD,OAAO,EAAE,YAAY,EAAE,0BAAuB;AAC9C,OAAO,EAAE,eAAe,EAAE,6BAA0B;AACpD,OAAO,EAAE,0BAA0B,EAAE,wCAAqC;
|
|
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,aAAa,EAAE,2BAAwB;AAChD,OAAO,EAAE,YAAY,EAAE,0BAAuB;AAC9C,OAAO,EAAE,eAAe,EAAE,6BAA0B;AACpD,OAAO,EAAE,0BAA0B,EAAE,wCAAqC;AAC1E,OAAO,EAAE,iCAAiC,EAAE,+CAA4C;AACxF,OAAO,EAAE,gCAAgC,EAAE,8CAA2C;AAEtF,MAAM,CAAC,MAAM,SAAS,GAAwB;IAC5C,eAAe;IACf,aAAa;IACb,YAAY;IACZ,eAAe;IACf,0BAA0B;IAC1B,iCAAiC;IACjC,gCAAgC;CACjC,CAAC"}
|
|
@@ -21,7 +21,7 @@ let Market = class Market extends BaseIdentifiedModel {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
__decorate([
|
|
24
|
-
pk({ type:
|
|
24
|
+
pk({ type: String, generated: false }),
|
|
25
25
|
composed(["productCode", "marketId"], ":", true),
|
|
26
26
|
description("Unique identifier composed of product code and market ID."),
|
|
27
27
|
__metadata("design:type", String)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Market.js","sourceRoot":"","sources":["../../../../src/contract/models/Market.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EACL,SAAS,EACT,SAAS,EACT,KAAK,EACL,QAAQ,GACT,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,uBAAoB;AACzC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,IAAI,EAAE,kBAAe;AAC9B,OAAO,EAAE,aAAa,EAAE,gCAA2B;AAM5C,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,mBAAmB;IA2C7C,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CACF,CAAA;AA1CC;IAHC,EAAE,CAAC,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"Market.js","sourceRoot":"","sources":["../../../../src/contract/models/Market.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EACL,SAAS,EACT,SAAS,EACT,KAAK,EACL,QAAQ,GACT,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,uBAAoB;AACzC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,IAAI,EAAE,kBAAe;AAC9B,OAAO,EAAE,aAAa,EAAE,gCAA2B;AAM5C,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,mBAAmB;IA2C7C,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CACF,CAAA;AA1CC;IAHC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACtC,QAAQ,CAAC,CAAC,aAAa,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC;IAChD,WAAW,CAAC,2DAA2D,CAAC;;kCAC7D;AAQZ;IANC,MAAM,EAAE;IACR,QAAQ,EAAE;IACV,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC/C,WAAW,CACV,mEAAmE,CACpE;;wCACiB;AAKlB;IAHC,MAAM,EAAE;IACR,IAAI,EAAE;IACN,QAAQ,EAAE;;2CACU;AAQrB;IANC,MAAM,EAAE;IACR,SAAS,CAAC,CAAC,CAAC;IACZ,SAAS,CAAC,CAAC,CAAC;IACZ,WAAW,CACV,0EAA0E,CAC3E;;4CACqB;AAItB;IAFC,MAAM,EAAE;IACR,WAAW,CAAC,mDAAmD,CAAC;;uCAChD;AAMjB;IAJC,MAAM,EAAE;IACR,WAAW,CACV,sEAAsE,CACvE;;+CACwB;AAMzB;IAJC,MAAM,EAAE;IACR,WAAW,CACV,4EAA4E,CAC7E;;0CACmB;AAzCT,MAAM;IAJlB,WAAW,CAAC,uCAAuC,CAAC;IACpD,IAAI,CAAC,aAAa,CAAC;IACnB,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;IACxB,KAAK,EAAE;;GACK,MAAM,CA8ClB"}
|
|
@@ -8,13 +8,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { model, required } from "@decaf-ts/decorator-validation";
|
|
11
|
-
import { column, index, OrderDirection, pk, table
|
|
11
|
+
import { column, index, OrderDirection, pk, table } from "@decaf-ts/core";
|
|
12
12
|
// import {BlockOperations, OperationKeys, readonly} from "@decaf-ts/db-decorators";
|
|
13
13
|
import { uses } from "@decaf-ts/decoration";
|
|
14
14
|
import { BaseIdentifiedModel } from "./BaseIdentifiedModel.js";
|
|
15
15
|
import { gtin } from "./gtin.js";
|
|
16
16
|
import { audit } from "./decorators.js";
|
|
17
|
-
import { FabricFlavour, mirror,
|
|
17
|
+
import { FabricFlavour, mirror, NamespaceCollection, ownedBy, sharedData, } from "./../../shared/index.js";
|
|
18
18
|
import { version } from "@decaf-ts/db-decorators";
|
|
19
19
|
let OtherProductShared = class OtherProductShared extends BaseIdentifiedModel {
|
|
20
20
|
constructor(args) {
|
|
@@ -25,7 +25,7 @@ let OtherProductShared = class OtherProductShared extends BaseIdentifiedModel {
|
|
|
25
25
|
__decorate([
|
|
26
26
|
pk(),
|
|
27
27
|
gtin(),
|
|
28
|
-
mirror("
|
|
28
|
+
mirror("mirror-collection", (mspId) => mspId === "main-org"),
|
|
29
29
|
audit(OtherProductShared),
|
|
30
30
|
__metadata("design:type", String)
|
|
31
31
|
], OtherProductShared.prototype, "productCode", void 0);
|
|
@@ -60,7 +60,7 @@ __decorate([
|
|
|
60
60
|
__metadata("design:type", String)
|
|
61
61
|
], OtherProductShared.prototype, "ownedBy", void 0);
|
|
62
62
|
OtherProductShared = __decorate([
|
|
63
|
-
sharedData(
|
|
63
|
+
sharedData(NamespaceCollection("decaf-namespace")),
|
|
64
64
|
uses(FabricFlavour)
|
|
65
65
|
// @BlockOperations([OperationKeys.DELETE])
|
|
66
66
|
,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtherProductShared.js","sourceRoot":"","sources":["../../../../src/contract/models/OtherProductShared.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,
|
|
1
|
+
{"version":3,"file":"OtherProductShared.js","sourceRoot":"","sources":["../../../../src/contract/models/OtherProductShared.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC1E,oFAAoF;AACpF,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,IAAI,EAAE,kBAAe;AAC9B,OAAO,EAAE,KAAK,EAAE,wBAAqB;AACrC,OAAO,EACL,aAAa,EACb,MAAM,EACN,mBAAmB,EACnB,OAAO,EACP,UAAU,GACX,gCAA2B;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAO3C,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,mBAAmB;IAgEzD,YAAY,IAAmC;QAC7C,KAAK,CAAC,IAAI,CAAC,CAAC;QA3Cd,kBAAa,GAAY,KAAK,CAAC;IA4C/B,CAAC;CACF,CAAA;AA9DC;IAJC,EAAE,EAAE;IACJ,IAAI,EAAE;IACN,MAAM,CAAC,mBAAmB,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,KAAK,UAAU,CAAC;IACpE,KAAK,CAAC,kBAAkB,CAAC;;uDACL;AAKrB;IAHC,MAAM,EAAE;IACR,QAAQ,EAAE;IACV,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;;wDAC1B;AAKtB;IAHC,MAAM,EAAE;IACR,QAAQ,EAAE;IACV,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;;gEAClB;AAG9B;IADC,MAAM,EAAE;;gEACqB;AAI9B;IAFC,MAAM,EAAE;IACR,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;;yDACjB;AAsB/B;IADC,OAAO,EAAE;;mDACO;AAkBjB;IAFC,MAAM,EAAE;IACR,OAAO,EAAE;;mDACO;AA9DN,kBAAkB;IAL9B,UAAU,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IAClD,IAAI,CAAC,aAAa,CAAC;IACpB,2CAA2C;;IAC1C,KAAK,CAAC,sBAAsB,CAAC;IAC7B,KAAK,EAAE;;GACK,kBAAkB,CAmE9B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ModelArg } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import { BaseIdentifiedModel } from "./BaseIdentifiedModel";
|
|
3
|
+
export declare class SegregatedPrivateDocument extends BaseIdentifiedModel {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
privateNoteA?: string;
|
|
7
|
+
privateNoteB?: string;
|
|
8
|
+
owner?: string;
|
|
9
|
+
constructor(args?: ModelArg<SegregatedPrivateDocument>);
|
|
10
|
+
}
|
|
11
|
+
export declare class SegregatedSharedDocument extends BaseIdentifiedModel {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
sharedNoteA?: string;
|
|
15
|
+
sharedNoteB?: string;
|
|
16
|
+
owner?: string;
|
|
17
|
+
constructor(args?: ModelArg<SegregatedSharedDocument>);
|
|
18
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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, required } from "@decaf-ts/decorator-validation";
|
|
11
|
+
import { column, pk, table } from "@decaf-ts/core";
|
|
12
|
+
import { uses } from "@decaf-ts/decoration";
|
|
13
|
+
import { FabricFlavour, ownedBy, privateData, sharedData, } from "./../../shared/index.js";
|
|
14
|
+
import { BaseIdentifiedModel } from "./BaseIdentifiedModel.js";
|
|
15
|
+
const PRIVATE_COLLECTION_A = "segregatedPrivateCollectionA";
|
|
16
|
+
const PRIVATE_COLLECTION_B = "segregatedPrivateCollectionB";
|
|
17
|
+
const SHARED_COLLECTION_A = "segregatedSharedCollectionA";
|
|
18
|
+
const SHARED_COLLECTION_B = "segregatedSharedCollectionB";
|
|
19
|
+
let SegregatedPrivateDocument = class SegregatedPrivateDocument extends BaseIdentifiedModel {
|
|
20
|
+
constructor(args) {
|
|
21
|
+
super(args);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
__decorate([
|
|
25
|
+
pk(),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], SegregatedPrivateDocument.prototype, "id", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
column(),
|
|
30
|
+
required(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], SegregatedPrivateDocument.prototype, "title", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
column(),
|
|
35
|
+
privateData(PRIVATE_COLLECTION_A),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], SegregatedPrivateDocument.prototype, "privateNoteA", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
column(),
|
|
40
|
+
privateData(PRIVATE_COLLECTION_B),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], SegregatedPrivateDocument.prototype, "privateNoteB", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
column(),
|
|
45
|
+
ownedBy(),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], SegregatedPrivateDocument.prototype, "owner", void 0);
|
|
48
|
+
SegregatedPrivateDocument = __decorate([
|
|
49
|
+
uses(FabricFlavour),
|
|
50
|
+
table("segregated_private_document"),
|
|
51
|
+
model(),
|
|
52
|
+
__metadata("design:paramtypes", [Object])
|
|
53
|
+
], SegregatedPrivateDocument);
|
|
54
|
+
export { SegregatedPrivateDocument };
|
|
55
|
+
let SegregatedSharedDocument = class SegregatedSharedDocument extends BaseIdentifiedModel {
|
|
56
|
+
constructor(args) {
|
|
57
|
+
super(args);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
__decorate([
|
|
61
|
+
pk(),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], SegregatedSharedDocument.prototype, "id", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
column(),
|
|
66
|
+
required(),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], SegregatedSharedDocument.prototype, "name", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
column(),
|
|
71
|
+
sharedData(SHARED_COLLECTION_A),
|
|
72
|
+
__metadata("design:type", String)
|
|
73
|
+
], SegregatedSharedDocument.prototype, "sharedNoteA", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
column(),
|
|
76
|
+
sharedData(SHARED_COLLECTION_B),
|
|
77
|
+
__metadata("design:type", String)
|
|
78
|
+
], SegregatedSharedDocument.prototype, "sharedNoteB", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
column(),
|
|
81
|
+
ownedBy(),
|
|
82
|
+
__metadata("design:type", String)
|
|
83
|
+
], SegregatedSharedDocument.prototype, "owner", void 0);
|
|
84
|
+
SegregatedSharedDocument = __decorate([
|
|
85
|
+
uses(FabricFlavour),
|
|
86
|
+
table("segregated_shared_document"),
|
|
87
|
+
model(),
|
|
88
|
+
__metadata("design:paramtypes", [Object])
|
|
89
|
+
], SegregatedSharedDocument);
|
|
90
|
+
export { SegregatedSharedDocument };
|
|
91
|
+
//# sourceMappingURL=SegregatedDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegregatedDocument.js","sourceRoot":"","sources":["../../../../src/contract/models/SegregatedDocument.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,OAAO,EACP,WAAW,EACX,UAAU,GACX,gCAA2B;AAC5B,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAE5D,MAAM,oBAAoB,GAAG,8BAA8B,CAAC;AAC5D,MAAM,oBAAoB,GAAG,8BAA8B,CAAC;AAC5D,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAC1D,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAKnD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,mBAAmB;IAoBhE,YAAY,IAA0C;QACpD,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;CACF,CAAA;AArBC;IADC,EAAE,EAAE;;qDACO;AAIZ;IAFC,MAAM,EAAE;IACR,QAAQ,EAAE;;wDACI;AAIf;IAFC,MAAM,EAAE;IACR,WAAW,CAAC,oBAAoB,CAAC;;+DACZ;AAItB;IAFC,MAAM,EAAE;IACR,WAAW,CAAC,oBAAoB,CAAC;;+DACZ;AAItB;IAFC,MAAM,EAAE;IACR,OAAO,EAAE;;wDACK;AAlBJ,yBAAyB;IAHrC,IAAI,CAAC,aAAa,CAAC;IACnB,KAAK,CAAC,6BAA6B,CAAC;IACpC,KAAK,EAAE;;GACK,yBAAyB,CAuBrC;;AAKM,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,mBAAmB;IAoB/D,YAAY,IAAyC;QACnD,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;CACF,CAAA;AArBC;IADC,EAAE,EAAE;;oDACO;AAIZ;IAFC,MAAM,EAAE;IACR,QAAQ,EAAE;;sDACG;AAId;IAFC,MAAM,EAAE;IACR,UAAU,CAAC,mBAAmB,CAAC;;6DACX;AAIrB;IAFC,MAAM,EAAE;IACR,UAAU,CAAC,mBAAmB,CAAC;;6DACX;AAIrB;IAFC,MAAM,EAAE;IACR,OAAO,EAAE;;uDACK;AAlBJ,wBAAwB;IAHpC,IAAI,CAAC,aAAa,CAAC;IACnB,KAAK,CAAC,4BAA4B,CAAC;IACnC,KAAK,EAAE;;GACK,wBAAwB,CAuBpC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CouchDBAdapter, MangoQuery } from "@decaf-ts/for-couchdb";
|
|
1
|
+
import { CouchDBAdapter, MangoQuery, ViewResponse } 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";
|
|
@@ -151,8 +151,14 @@ export declare class FabricContractAdapter extends CouchDBAdapter<any, void, Fab
|
|
|
151
151
|
protected deleteState(id: string, context: FabricContractContext): Promise<void>;
|
|
152
152
|
forPrivate(collection: string): FabricContractAdapter;
|
|
153
153
|
protected putState(id: string, model: Record<string, any>, ctx: FabricContractContext): Promise<Record<string, any>>;
|
|
154
|
+
private flushSegregatedWrites;
|
|
155
|
+
private buildSegregatedPayload;
|
|
156
|
+
private mergeSegregatedReads;
|
|
157
|
+
private readPrivateRecord;
|
|
158
|
+
private deleteSegregatedCollections;
|
|
154
159
|
protected readState(id: string, ctx: FabricContractContext): Promise<any>;
|
|
155
160
|
protected queryResult(stub: ChaincodeStub, rawInput: any, ...args: ContextualArgs<FabricContractContext>): Promise<Iterators.StateQueryIterator>;
|
|
161
|
+
private createRowsIterator;
|
|
156
162
|
protected queryResultPaginated(stub: ChaincodeStub, rawInput: any, limit?: number, page?: number, bookmark?: string | number, ...args: any[]): Promise<StateQueryResponse<Iterators.StateQueryIterator>>;
|
|
157
163
|
protected mergeModels(results: Record<string, any>[]): Record<string, any>;
|
|
158
164
|
/**
|
|
@@ -236,6 +242,7 @@ export declare class FabricContractAdapter extends CouchDBAdapter<any, void, Fab
|
|
|
236
242
|
* FabricContractAdapter-->>Caller: results
|
|
237
243
|
*/
|
|
238
244
|
raw<R, D extends boolean>(rawInput: MangoQuery, docsOnly?: D, ...args: ContextualArgs<FabricContractContext>): Promise<RawResult<R, D>>;
|
|
245
|
+
view<R>(ddoc: string, viewName: string, options: Record<string, any>, ..._args: ContextualArgs<FabricContractContext>): Promise<ViewResponse<R>>;
|
|
239
246
|
Statement<M extends Model>(): FabricStatement<M, any>;
|
|
240
247
|
createAll<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType[], model: Record<string, any>[], ...args: ContextualArgs<FabricContractContext>): Promise<Record<string, any>[]>;
|
|
241
248
|
updateAll<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType[], model: Record<string, any>[], ...args: ContextualArgs<FabricContractContext>): Promise<Record<string, any>[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CouchDBAdapter, CouchDBKeys } from "@decaf-ts/for-couchdb";
|
|
1
|
+
import { CouchDBAdapter, CouchDBKeys, } from "@decaf-ts/for-couchdb";
|
|
2
2
|
import { Model, ValidationKeys } from "@decaf-ts/decorator-validation";
|
|
3
3
|
import { FabricContractContext } from "./ContractContext.js";
|
|
4
4
|
import { BadRequestError, ConflictError, InternalError, NotFoundError, onCreate, onCreateUpdate, SerializationError, } from "@decaf-ts/db-decorators";
|
|
@@ -169,6 +169,7 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
169
169
|
try {
|
|
170
170
|
const composedKey = ctx.stub.createCompositeKey(tableName, [String(id)]);
|
|
171
171
|
model = await this.readState(composedKey, ctx);
|
|
172
|
+
model = await this.mergeSegregatedReads(ctx, composedKey, model);
|
|
172
173
|
}
|
|
173
174
|
catch (e) {
|
|
174
175
|
throw this.parseError(e);
|
|
@@ -215,6 +216,7 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
215
216
|
model = await this.read(clazz, id, ...ctxArgs);
|
|
216
217
|
log.verbose(`deleting entry with pk ${id} from ${tableName} table`);
|
|
217
218
|
await this.deleteState(composedKey, ctx);
|
|
219
|
+
await this.deleteSegregatedCollections(ctx, composedKey);
|
|
218
220
|
}
|
|
219
221
|
catch (e) {
|
|
220
222
|
throw this.parseError(e);
|
|
@@ -223,7 +225,11 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
223
225
|
}
|
|
224
226
|
async deleteState(id, context) {
|
|
225
227
|
const { ctx } = this.logCtx([context], this.deleteState);
|
|
226
|
-
|
|
228
|
+
const collection = ctx.getOrUndefined("segregated");
|
|
229
|
+
if (collection)
|
|
230
|
+
await ctx.stub.deletePrivateData(collection, id);
|
|
231
|
+
else
|
|
232
|
+
await ctx.stub.deleteState(id);
|
|
227
233
|
}
|
|
228
234
|
forPrivate(collection) {
|
|
229
235
|
const toOverride = [
|
|
@@ -241,17 +247,30 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
241
247
|
async apply(fn, thisArg, argsList) {
|
|
242
248
|
switch (prop) {
|
|
243
249
|
case "putState": {
|
|
244
|
-
|
|
245
|
-
|
|
250
|
+
// putState signature: (id: string, model: Record<string, any>, ctx: FabricContractContext)
|
|
251
|
+
const [id, model, ctx] = argsList;
|
|
252
|
+
const data = Buffer.from(FabricContractAdapter.serializer.serialize(model, false));
|
|
253
|
+
await ctx.stub.putPrivateData(collection, id.toString(), data);
|
|
246
254
|
return model;
|
|
247
255
|
}
|
|
248
256
|
case "deleteState": {
|
|
249
|
-
|
|
250
|
-
|
|
257
|
+
// deleteState signature: (id: string, context: FabricContractContext)
|
|
258
|
+
const [id, ctx] = argsList;
|
|
259
|
+
await ctx.stub.deletePrivateData(collection, id.toString());
|
|
260
|
+
return;
|
|
251
261
|
}
|
|
252
262
|
case "readState": {
|
|
253
|
-
|
|
254
|
-
|
|
263
|
+
// readState signature: (id: string, ctx: FabricContractContext)
|
|
264
|
+
const [id, ctx] = argsList;
|
|
265
|
+
const data = await ctx.stub.getPrivateData(collection, id);
|
|
266
|
+
if (!data)
|
|
267
|
+
return "";
|
|
268
|
+
try {
|
|
269
|
+
return FabricContractAdapter.serializer.deserialize(data.toString("utf8"));
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
return data.toString("utf8");
|
|
273
|
+
}
|
|
255
274
|
}
|
|
256
275
|
case "queryResult": {
|
|
257
276
|
const [stub, rawInput] = argsList;
|
|
@@ -322,14 +341,98 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
322
341
|
catch (e) {
|
|
323
342
|
throw new SerializationError(`Failed to serialize record with id ${id}: ${e}`);
|
|
324
343
|
}
|
|
325
|
-
const collection = ctx.
|
|
326
|
-
if (collection)
|
|
344
|
+
const collection = ctx.getOrUndefined("segregated");
|
|
345
|
+
if (collection) {
|
|
327
346
|
await ctx.stub.putPrivateData(collection, id.toString(), data);
|
|
328
|
-
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
329
349
|
await ctx.stub.putState(id.toString(), data);
|
|
350
|
+
await this.flushSegregatedWrites(ctx, id);
|
|
351
|
+
}
|
|
330
352
|
log.silly(`state stored${collection ? ` in ${collection} collection` : ""} under id ${id}`);
|
|
331
353
|
return model;
|
|
332
354
|
}
|
|
355
|
+
async flushSegregatedWrites(ctx, id) {
|
|
356
|
+
const writes = ctx.getOrUndefined("segregateWrite");
|
|
357
|
+
if (!writes)
|
|
358
|
+
return;
|
|
359
|
+
for (const [collection, entries] of Object.entries(writes)) {
|
|
360
|
+
for (const entry of entries) {
|
|
361
|
+
const payload = this.buildSegregatedPayload(entry);
|
|
362
|
+
if (!payload)
|
|
363
|
+
continue;
|
|
364
|
+
const privateCtx = ctx.override({
|
|
365
|
+
segregated: collection,
|
|
366
|
+
});
|
|
367
|
+
await this.putState(id, payload, privateCtx);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
ctx.cache.remove("segregateWrite");
|
|
371
|
+
}
|
|
372
|
+
buildSegregatedPayload(entry) {
|
|
373
|
+
const payload = {};
|
|
374
|
+
if (entry.model) {
|
|
375
|
+
payload["$$table"] = Model.tableName(entry.model.constructor);
|
|
376
|
+
}
|
|
377
|
+
const merge = (source) => {
|
|
378
|
+
if (!source)
|
|
379
|
+
return;
|
|
380
|
+
Object.entries(source).forEach(([key, value]) => {
|
|
381
|
+
if (typeof value === "undefined")
|
|
382
|
+
return;
|
|
383
|
+
payload[key] = value;
|
|
384
|
+
});
|
|
385
|
+
};
|
|
386
|
+
merge(entry.privates);
|
|
387
|
+
merge(entry.shared);
|
|
388
|
+
merge(entry.transient);
|
|
389
|
+
if (!Object.keys(payload).length)
|
|
390
|
+
return null;
|
|
391
|
+
return payload;
|
|
392
|
+
}
|
|
393
|
+
async mergeSegregatedReads(ctx, id, model) {
|
|
394
|
+
const reads = ctx.getOrUndefined("segregateRead");
|
|
395
|
+
if (!reads?.length)
|
|
396
|
+
return model;
|
|
397
|
+
for (const collection of reads) {
|
|
398
|
+
const privateRecord = await this.readPrivateRecord(ctx, collection, id);
|
|
399
|
+
if (!privateRecord)
|
|
400
|
+
continue;
|
|
401
|
+
Object.entries(privateRecord).forEach(([key, value]) => {
|
|
402
|
+
if (typeof value === "undefined")
|
|
403
|
+
return;
|
|
404
|
+
model[key] = value;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
return model;
|
|
408
|
+
}
|
|
409
|
+
async readPrivateRecord(ctx, collection, id) {
|
|
410
|
+
const data = await ctx.stub.getPrivateData(collection, id);
|
|
411
|
+
if (!data)
|
|
412
|
+
return undefined;
|
|
413
|
+
const text = data.toString();
|
|
414
|
+
if (!text)
|
|
415
|
+
return undefined;
|
|
416
|
+
try {
|
|
417
|
+
return FabricContractAdapter.serializer.deserialize(text);
|
|
418
|
+
}
|
|
419
|
+
catch {
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
async deleteSegregatedCollections(ctx, id) {
|
|
424
|
+
const reads = ctx.getOrUndefined("segregateRead");
|
|
425
|
+
if (!reads?.length)
|
|
426
|
+
return;
|
|
427
|
+
for (const collection of reads) {
|
|
428
|
+
try {
|
|
429
|
+
await ctx.stub.deletePrivateData(collection, id);
|
|
430
|
+
}
|
|
431
|
+
catch {
|
|
432
|
+
// ignore missing private data
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
333
436
|
async readState(id, ctx) {
|
|
334
437
|
let result;
|
|
335
438
|
const { log } = this.logCtx([ctx], this.readState);
|
|
@@ -360,19 +463,56 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
360
463
|
res = await stub.getQueryResult(JSON.stringify(rawInput));
|
|
361
464
|
return res;
|
|
362
465
|
}
|
|
466
|
+
createRowsIterator(rows) {
|
|
467
|
+
let index = 0;
|
|
468
|
+
return {
|
|
469
|
+
// @ts-expect-error typeing of iterator?
|
|
470
|
+
async next() {
|
|
471
|
+
if (index < rows.length) {
|
|
472
|
+
const row = rows[index++];
|
|
473
|
+
return {
|
|
474
|
+
value: { key: row.key, value: row.value },
|
|
475
|
+
done: false,
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
return { done: true };
|
|
479
|
+
},
|
|
480
|
+
async close() {
|
|
481
|
+
// noop
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
}
|
|
363
485
|
async queryResultPaginated(stub, rawInput, limit = 250, page, bookmark, ...args) {
|
|
364
486
|
const { ctx } = this.logCtx(args, this.readState);
|
|
365
487
|
let res;
|
|
366
488
|
const collection = ctx.get("segregated");
|
|
367
489
|
if (collection) {
|
|
490
|
+
const clonedInput = JSON.parse(JSON.stringify(rawInput));
|
|
491
|
+
clonedInput.selector = clonedInput.selector || {};
|
|
368
492
|
if (bookmark)
|
|
369
|
-
|
|
370
|
-
const
|
|
493
|
+
clonedInput.selector._id = { $gt: bookmark.toString() };
|
|
494
|
+
const limitValue = typeof limit === "number" && limit > 0 ? limit : Number.MAX_VALUE;
|
|
495
|
+
const iterator = await stub.getPrivateDataQueryResult(collection, JSON.stringify(clonedInput));
|
|
496
|
+
const rows = [];
|
|
497
|
+
let lastKey = "";
|
|
498
|
+
while (rows.length < limitValue) {
|
|
499
|
+
const resRow = await iterator.next();
|
|
500
|
+
if (resRow.done)
|
|
501
|
+
break;
|
|
502
|
+
if (resRow.value && resRow.value.value) {
|
|
503
|
+
rows.push({
|
|
504
|
+
key: resRow.value.key,
|
|
505
|
+
value: resRow.value.value,
|
|
506
|
+
});
|
|
507
|
+
lastKey = resRow.value.key;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
await iterator.close();
|
|
371
511
|
res = {
|
|
372
|
-
iterator:
|
|
512
|
+
iterator: this.createRowsIterator(rows),
|
|
373
513
|
metadata: {
|
|
374
|
-
fetchedRecordsCount:
|
|
375
|
-
bookmark: "",
|
|
514
|
+
fetchedRecordsCount: rows.length,
|
|
515
|
+
bookmark: rows.length ? lastKey : "",
|
|
376
516
|
},
|
|
377
517
|
};
|
|
378
518
|
}
|
|
@@ -415,21 +555,22 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
415
555
|
let baseFlags = Object.assign({
|
|
416
556
|
segregated: false,
|
|
417
557
|
}, flags);
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
558
|
+
const stubFromFlags = flags.stub || flags.stub;
|
|
559
|
+
const identityFromFlags = flags.identity ||
|
|
560
|
+
flags.clientIdentity;
|
|
561
|
+
if (stubFromFlags && identityFromFlags) {
|
|
562
|
+
const txId = stubFromFlags.getTxID();
|
|
422
563
|
Object.assign(baseFlags, {
|
|
423
|
-
stub:
|
|
424
|
-
identity:
|
|
425
|
-
cert:
|
|
426
|
-
roles:
|
|
564
|
+
stub: stubFromFlags,
|
|
565
|
+
identity: identityFromFlags,
|
|
566
|
+
cert: identityFromFlags.getIDBytes().toString(),
|
|
567
|
+
roles: identityFromFlags.getAttributeValue("roles"),
|
|
427
568
|
logger: Logging.for(operation, {
|
|
428
569
|
logLevel: false,
|
|
429
570
|
timestamp: false,
|
|
430
|
-
correlationId:
|
|
571
|
+
correlationId: txId,
|
|
431
572
|
}, flags),
|
|
432
|
-
correlationId:
|
|
573
|
+
correlationId: txId,
|
|
433
574
|
});
|
|
434
575
|
}
|
|
435
576
|
else {
|
|
@@ -560,6 +701,17 @@ export class FabricContractAdapter extends CouchDBAdapter {
|
|
|
560
701
|
return resp.docs;
|
|
561
702
|
return resp;
|
|
562
703
|
}
|
|
704
|
+
async view(
|
|
705
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
706
|
+
ddoc,
|
|
707
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
708
|
+
viewName,
|
|
709
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
710
|
+
options,
|
|
711
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
712
|
+
..._args) {
|
|
713
|
+
throw new UnsupportedError("Fabric contracts do not support CouchDB views.");
|
|
714
|
+
}
|
|
563
715
|
Statement() {
|
|
564
716
|
return new FabricStatement(this);
|
|
565
717
|
}
|