@decaf-ts/for-fabric 0.5.7 → 0.7.1
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 +2 -3797
- package/dist/for-fabric.cjs.map +1 -0
- package/dist/for-fabric.js +2 -3901
- package/dist/for-fabric.js.map +1 -0
- package/lib/cjs/bin/cli.cjs +9 -0
- package/lib/cjs/bin/cli.js.map +1 -0
- package/lib/cjs/cli-module.cjs +479 -0
- package/lib/cjs/cli-module.js.map +1 -0
- package/lib/cjs/cli-utils.cjs +309 -0
- package/lib/cjs/cli-utils.js.map +1 -0
- package/lib/cjs/client/FabricClientAdapter.cjs +1362 -0
- package/lib/cjs/client/FabricClientAdapter.js.map +1 -0
- package/lib/cjs/client/FabricClientDispatch.cjs +290 -0
- package/lib/cjs/client/FabricClientDispatch.js.map +1 -0
- package/lib/cjs/client/FabricClientPaginator.cjs +21 -0
- package/lib/cjs/client/FabricClientPaginator.js.map +1 -0
- package/lib/cjs/client/FabricClientRepository.cjs +259 -0
- package/lib/cjs/client/FabricClientRepository.js.map +1 -0
- package/lib/cjs/client/FabricClientStatement.cjs +451 -0
- package/lib/cjs/client/FabricClientStatement.js.map +1 -0
- package/lib/cjs/client/collections/generation.cjs +113 -0
- package/lib/cjs/client/collections/generation.js.map +1 -0
- package/lib/{client/indexes → cjs/client/collections}/index.cjs +1 -1
- package/lib/cjs/client/collections/index.js.map +1 -0
- package/lib/cjs/client/constants.cjs +16 -0
- package/lib/cjs/client/constants.js.map +1 -0
- package/lib/cjs/client/crypto.cjs +368 -0
- package/lib/cjs/client/crypto.js.map +1 -0
- package/lib/{esm/client/erc20/FabricERC20ClientRepository.d.ts → cjs/client/erc20/FabricERC20ClientRepository.cjs} +139 -30
- package/lib/cjs/client/erc20/FabricERC20ClientRepository.js.map +1 -0
- package/lib/{client → cjs/client}/erc20/index.cjs +1 -1
- package/lib/cjs/client/erc20/index.js.map +1 -0
- package/lib/cjs/client/fabric-fs.cjs +234 -0
- package/lib/cjs/client/fabric-fs.js.map +1 -0
- package/lib/cjs/client/fabric-hsm.cjs +165 -0
- package/lib/cjs/client/fabric-hsm.js.map +1 -0
- package/lib/cjs/client/ids/id-extraction.cjs +30 -0
- package/lib/cjs/client/ids/id-extraction.js.map +1 -0
- package/lib/{client → cjs/client}/ids/index.cjs +1 -1
- package/lib/cjs/client/ids/index.js.map +1 -0
- package/lib/{client → cjs/client}/index.cjs +1 -1
- package/lib/cjs/client/index.js.map +1 -0
- package/lib/cjs/client/indexes/generation.cjs +95 -0
- package/lib/cjs/client/indexes/generation.js.map +1 -0
- package/lib/{client/collections → cjs/client/indexes}/index.cjs +1 -1
- package/lib/cjs/client/indexes/index.js.map +1 -0
- package/lib/{esm/client/logging.d.ts → cjs/client/logging.cjs} +51 -9
- package/lib/cjs/client/logging.js.map +1 -0
- package/lib/cjs/client/services/FabricEnrollmentService.cjs +363 -0
- package/lib/cjs/client/services/FabricEnrollmentService.js.map +1 -0
- package/lib/cjs/client/services/FabricIdentityService.cjs +324 -0
- package/lib/cjs/client/services/FabricIdentityService.js.map +1 -0
- package/lib/cjs/client/services/RegistrationRequestBuilder.cjs +91 -0
- package/lib/cjs/client/services/RegistrationRequestBuilder.js.map +1 -0
- package/lib/{esm/client/services/constants.d.ts → cjs/client/services/constants.cjs} +10 -5
- package/lib/cjs/client/services/constants.js.map +1 -0
- package/lib/cjs/client/services/index.cjs +21 -0
- package/lib/cjs/client/services/index.js.map +1 -0
- package/lib/cjs/client/types.cjs +3 -0
- package/lib/cjs/client/types.js.map +1 -0
- package/lib/cjs/client/utils.cjs +262 -0
- package/lib/cjs/client/utils.js.map +1 -0
- package/lib/{contract → cjs/contract}/Address.cjs +1 -1
- package/lib/cjs/contract/Address.js.map +1 -0
- package/lib/{contract → cjs/contract}/AddressContract.cjs +1 -1
- package/lib/cjs/contract/AddressContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/AuditContract.cjs +1 -1
- package/lib/cjs/contract/AuditContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/BatchContract.cjs +1 -1
- package/lib/cjs/contract/BatchContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/MarketContract.cjs +1 -1
- package/lib/cjs/contract/MarketContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/OtherAuditContract.cjs +1 -1
- package/lib/cjs/contract/OtherAuditContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/OtherBatchContract.cjs +1 -1
- package/lib/cjs/contract/OtherBatchContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/OtherMarketContract.cjs +1 -1
- package/lib/cjs/contract/OtherMarketContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/OtherProductContract.cjs +1 -1
- package/lib/cjs/contract/OtherProductContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/OtherProductImageContract.cjs +1 -1
- package/lib/cjs/contract/OtherProductImageContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/OtherProductSharedContract.cjs +1 -1
- package/lib/cjs/contract/OtherProductSharedContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/OtherProductStrengthContract.cjs +1 -1
- package/lib/cjs/contract/OtherProductStrengthContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/Product.cjs +1 -1
- package/lib/cjs/contract/Product.js.map +1 -0
- package/lib/{contract → cjs/contract}/ProductContract.cjs +1 -1
- package/lib/cjs/contract/ProductContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/ProductStrengthContract.cjs +1 -1
- package/lib/cjs/contract/ProductStrengthContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/SegregatedPrivateDocumentContract.cjs +1 -1
- package/lib/cjs/contract/SegregatedPrivateDocumentContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/SegregatedSharedDocumentContract.cjs +1 -1
- package/lib/cjs/contract/SegregatedSharedDocumentContract.js.map +1 -0
- package/lib/{contract → cjs/contract}/User.cjs +1 -1
- package/lib/cjs/contract/User.js.map +1 -0
- package/lib/{contract → cjs/contract}/UserContract.cjs +1 -1
- package/lib/cjs/contract/UserContract.js.map +1 -0
- package/lib/cjs/contract/index.cjs +36 -0
- package/lib/cjs/contract/index.js.map +1 -0
- package/lib/cjs/contract/logging-context.cjs +77 -0
- package/lib/cjs/contract/logging-context.js.map +1 -0
- package/lib/cjs/contract/models/Audit.cjs +106 -0
- package/lib/cjs/contract/models/Audit.js.map +1 -0
- package/lib/{contract → cjs/contract}/models/BaseIdentifiedModel.cjs +1 -1
- package/lib/cjs/contract/models/BaseIdentifiedModel.js.map +1 -0
- package/lib/{contract → cjs/contract}/models/BaseModel.cjs +1 -1
- package/lib/cjs/contract/models/BaseModel.js.map +1 -0
- package/lib/cjs/contract/models/Batch.cjs +174 -0
- package/lib/cjs/contract/models/Batch.js.map +1 -0
- package/lib/cjs/contract/models/GtinOwner.cjs +59 -0
- package/lib/cjs/contract/models/GtinOwner.js.map +1 -0
- package/lib/cjs/contract/models/History.cjs +75 -0
- package/lib/cjs/contract/models/History.js.map +1 -0
- package/lib/cjs/contract/models/Leaflet.cjs +95 -0
- package/lib/cjs/contract/models/Leaflet.js.map +1 -0
- package/lib/cjs/contract/models/LeafletFile.cjs +58 -0
- package/lib/cjs/contract/models/LeafletFile.js.map +1 -0
- package/lib/cjs/contract/models/Market.cjs +75 -0
- package/lib/cjs/contract/models/Market.js.map +1 -0
- package/lib/cjs/contract/models/OtherAudit.cjs +118 -0
- package/lib/cjs/contract/models/OtherAudit.js.map +1 -0
- package/lib/cjs/contract/models/OtherBatchShared.cjs +127 -0
- package/lib/cjs/contract/models/OtherBatchShared.js.map +1 -0
- package/lib/cjs/contract/models/OtherLeaflet.cjs +115 -0
- package/lib/cjs/contract/models/OtherLeaflet.js.map +1 -0
- package/lib/cjs/contract/models/OtherLeafletFile.cjs +65 -0
- package/lib/cjs/contract/models/OtherLeafletFile.js.map +1 -0
- package/lib/cjs/contract/models/OtherMarket.cjs +84 -0
- package/lib/cjs/contract/models/OtherMarket.js.map +1 -0
- package/lib/cjs/contract/models/OtherProduct.cjs +77 -0
- package/lib/cjs/contract/models/OtherProduct.js.map +1 -0
- package/lib/cjs/contract/models/OtherProductImage.cjs +59 -0
- package/lib/cjs/contract/models/OtherProductImage.js.map +1 -0
- package/lib/cjs/contract/models/OtherProductShared.cjs +99 -0
- package/lib/cjs/contract/models/OtherProductShared.js.map +1 -0
- package/lib/cjs/contract/models/OtherProductStrength.cjs +87 -0
- package/lib/cjs/contract/models/OtherProductStrength.js.map +1 -0
- package/lib/cjs/contract/models/Product.cjs +78 -0
- package/lib/cjs/contract/models/Product.js.map +1 -0
- package/lib/cjs/contract/models/ProductStrength.cjs +78 -0
- package/lib/cjs/contract/models/ProductStrength.js.map +1 -0
- package/lib/{contract → cjs/contract}/models/SegregatedDocument.cjs +1 -1
- package/lib/cjs/contract/models/SegregatedDocument.js.map +1 -0
- package/lib/cjs/contract/models/constants.cjs +30 -0
- package/lib/cjs/contract/models/constants.js.map +1 -0
- package/lib/cjs/contract/models/decorators-private.cjs +158 -0
- package/lib/cjs/contract/models/decorators-private.js.map +1 -0
- package/lib/cjs/contract/models/decorators.cjs +182 -0
- package/lib/cjs/contract/models/decorators.js.map +1 -0
- package/lib/cjs/contract/models/gtin.cjs +88 -0
- package/lib/cjs/contract/models/gtin.js.map +1 -0
- package/lib/cjs/contract/models/history-dec.cjs +83 -0
- package/lib/cjs/contract/models/history-dec.js.map +1 -0
- package/lib/cjs/contracts/ContractAdapter.cjs +1193 -0
- package/lib/cjs/contracts/ContractAdapter.js.map +1 -0
- package/lib/cjs/contracts/ContractContext.cjs +157 -0
- package/lib/cjs/contracts/ContractContext.js.map +1 -0
- package/lib/cjs/contracts/FabricContractDispatch.cjs +79 -0
- package/lib/cjs/contracts/FabricContractDispatch.js.map +1 -0
- package/lib/{esm/contracts/FabricContractPaginator.d.ts → cjs/contracts/FabricContractPaginator.cjs} +77 -9
- package/lib/cjs/contracts/FabricContractPaginator.js.map +1 -0
- package/lib/cjs/contracts/FabricContractRepository.cjs +322 -0
- package/lib/cjs/contracts/FabricContractRepository.js.map +1 -0
- package/lib/{esm/contracts/FabricContractRepositoryObservableHandler.d.ts → cjs/contracts/FabricContractRepositoryObservableHandler.cjs} +42 -8
- package/lib/cjs/contracts/FabricContractRepositoryObservableHandler.js.map +1 -0
- package/lib/cjs/contracts/FabricContractSequence.cjs +338 -0
- package/lib/cjs/contracts/FabricContractSequence.js.map +1 -0
- package/lib/cjs/contracts/FabricContractStatement.cjs +180 -0
- package/lib/cjs/contracts/FabricContractStatement.js.map +1 -0
- package/lib/cjs/contracts/MigrationContract.cjs +147 -0
- package/lib/cjs/contracts/MigrationContract.js.map +1 -0
- package/lib/{contracts → cjs/contracts}/PrivateSequence.cjs +1 -1
- package/lib/cjs/contracts/PrivateSequence.js.map +1 -0
- package/lib/cjs/contracts/auth/decorators.cjs +84 -0
- package/lib/cjs/contracts/auth/decorators.js.map +1 -0
- package/lib/{contracts → cjs/contracts}/auth/index.cjs +1 -1
- package/lib/cjs/contracts/auth/index.js.map +1 -0
- package/lib/cjs/contracts/crud/crud-contract.cjs +416 -0
- package/lib/cjs/contracts/crud/crud-contract.js.map +1 -0
- package/lib/{contracts → cjs/contracts}/crud/index.cjs +1 -1
- package/lib/cjs/contracts/crud/index.js.map +1 -0
- package/lib/cjs/contracts/crud/serialized-crud-contract.cjs +284 -0
- package/lib/cjs/contracts/crud/serialized-crud-contract.js.map +1 -0
- package/lib/cjs/contracts/erc20/erc20contract.cjs +581 -0
- package/lib/cjs/contracts/erc20/erc20contract.js.map +1 -0
- package/lib/cjs/contracts/erc20/index.cjs +21 -0
- package/lib/cjs/contracts/erc20/index.js.map +1 -0
- package/lib/cjs/contracts/erc20/models.cjs +209 -0
- package/lib/cjs/contracts/erc20/models.js.map +1 -0
- package/lib/{contracts → cjs/contracts}/index.cjs +1 -1
- package/lib/cjs/contracts/index.js.map +1 -0
- package/lib/cjs/contracts/logging.cjs +118 -0
- package/lib/cjs/contracts/logging.js.map +1 -0
- package/lib/cjs/contracts/overrides.cjs +8 -0
- package/lib/cjs/contracts/overrides.js.map +1 -0
- package/lib/cjs/contracts/types.cjs +3 -0
- package/lib/cjs/contracts/types.js.map +1 -0
- package/lib/cjs/contracts/uuid.cjs +75 -0
- package/lib/cjs/contracts/uuid.js.map +1 -0
- package/lib/{index.cjs → cjs/index.cjs} +1 -1
- package/lib/cjs/index.js.map +1 -0
- package/lib/{shared/ClientSerializer.d.ts → cjs/shared/ClientSerializer.cjs} +35 -6
- package/lib/cjs/shared/ClientSerializer.js.map +1 -0
- package/lib/cjs/shared/DeterministicSerializer.cjs +106 -0
- package/lib/cjs/shared/DeterministicSerializer.js.map +1 -0
- package/lib/cjs/shared/SimpleDeterministicSerializer.cjs +69 -0
- package/lib/cjs/shared/SimpleDeterministicSerializer.js.map +1 -0
- package/lib/{shared/constants.d.ts → cjs/shared/constants.cjs} +18 -12
- package/lib/cjs/shared/constants.js.map +1 -0
- package/lib/cjs/shared/decorators.cjs +595 -0
- package/lib/cjs/shared/decorators.js.map +1 -0
- package/lib/{shared/erc20/erc20-constants.d.ts → cjs/shared/erc20/erc20-constants.cjs} +9 -4
- package/lib/cjs/shared/erc20/erc20-constants.js.map +1 -0
- package/lib/{shared → cjs/shared}/erc20/index.cjs +1 -1
- package/lib/cjs/shared/erc20/index.js.map +1 -0
- package/lib/cjs/shared/errors.cjs +190 -0
- package/lib/cjs/shared/errors.js.map +1 -0
- package/lib/{shared/events.d.ts → cjs/shared/events.cjs} +21 -7
- package/lib/cjs/shared/events.js.map +1 -0
- package/lib/cjs/shared/fabric-types.cjs +3 -0
- package/lib/cjs/shared/fabric-types.js.map +1 -0
- package/lib/{shared → cjs/shared}/index.cjs +1 -1
- package/lib/cjs/shared/index.js.map +1 -0
- package/lib/cjs/shared/interfaces/Checkable.cjs +3 -0
- package/lib/cjs/shared/interfaces/Checkable.js.map +1 -0
- package/lib/{shared → cjs/shared}/interfaces/index.cjs +1 -1
- package/lib/cjs/shared/interfaces/index.js.map +1 -0
- package/lib/cjs/shared/math.cjs +66 -0
- package/lib/cjs/shared/math.js.map +1 -0
- package/lib/{shared → cjs/shared}/model/FabricBaseModel.cjs +1 -1
- package/lib/cjs/shared/model/FabricBaseModel.js.map +1 -0
- package/lib/{shared → cjs/shared}/model/FabricIdentifiedBaseModel.cjs +1 -1
- package/lib/cjs/shared/model/FabricIdentifiedBaseModel.js.map +1 -0
- package/lib/cjs/shared/model/Identity.cjs +71 -0
- package/lib/cjs/shared/model/Identity.js.map +1 -0
- package/lib/cjs/shared/model/IdentityCredentials.cjs +66 -0
- package/lib/cjs/shared/model/IdentityCredentials.js.map +1 -0
- package/lib/cjs/shared/model/index.cjs +21 -0
- package/lib/cjs/shared/model/index.js.map +1 -0
- package/lib/cjs/shared/overrides/Model.cjs +4 -0
- package/lib/cjs/shared/overrides/Model.js.map +1 -0
- package/lib/{shared → cjs/shared}/overrides/index.cjs +1 -1
- package/lib/cjs/shared/overrides/index.js.map +1 -0
- package/lib/cjs/shared/overrides/overrides.cjs +93 -0
- package/lib/cjs/shared/overrides/overrides.js.map +1 -0
- package/lib/cjs/shared/types.cjs +3 -0
- package/lib/cjs/shared/types.js.map +1 -0
- package/lib/cjs/version.cjs +8 -0
- package/lib/cjs/version.js.map +1 -0
- package/lib/esm/bin/cli.js +1 -1
- package/lib/esm/bin/cli.js.map +1 -0
- package/lib/esm/cli-module.js +1 -1
- package/lib/esm/cli-module.js.map +1 -0
- package/lib/esm/cli-utils.js +1 -1
- package/lib/esm/cli-utils.js.map +1 -0
- package/lib/esm/client/FabricClientAdapter.js +1 -1
- package/lib/esm/client/FabricClientAdapter.js.map +1 -0
- package/lib/esm/client/FabricClientDispatch.js +1 -1
- package/lib/esm/client/FabricClientDispatch.js.map +1 -0
- package/lib/esm/client/FabricClientPaginator.js +1 -1
- package/lib/esm/client/FabricClientPaginator.js.map +1 -0
- package/lib/esm/client/FabricClientRepository.js +1 -1
- package/lib/esm/client/FabricClientRepository.js.map +1 -0
- package/lib/esm/client/FabricClientStatement.js +1 -1
- package/lib/esm/client/FabricClientStatement.js.map +1 -0
- package/lib/esm/client/collections/generation.js +1 -1
- package/lib/esm/client/collections/generation.js.map +1 -0
- package/lib/esm/client/collections/index.js +1 -1
- package/lib/esm/client/collections/index.js.map +1 -0
- package/lib/esm/client/constants.js +1 -1
- package/lib/esm/client/constants.js.map +1 -0
- package/lib/esm/client/crypto.js +1 -1
- package/lib/esm/client/crypto.js.map +1 -0
- package/lib/esm/client/erc20/FabricERC20ClientRepository.js +1 -1
- package/lib/esm/client/erc20/FabricERC20ClientRepository.js.map +1 -0
- package/lib/esm/client/erc20/index.js +1 -1
- package/lib/esm/client/erc20/index.js.map +1 -0
- package/lib/esm/client/fabric-fs.js +1 -1
- package/lib/esm/client/fabric-fs.js.map +1 -0
- package/lib/esm/client/fabric-hsm.js +1 -1
- package/lib/esm/client/fabric-hsm.js.map +1 -0
- package/lib/esm/client/ids/id-extraction.js +1 -1
- package/lib/esm/client/ids/id-extraction.js.map +1 -0
- package/lib/esm/client/ids/index.js +1 -1
- package/lib/esm/client/ids/index.js.map +1 -0
- package/lib/esm/client/index.js +1 -1
- package/lib/esm/client/index.js.map +1 -0
- package/lib/esm/client/indexes/generation.js +1 -1
- package/lib/esm/client/indexes/generation.js.map +1 -0
- package/lib/esm/client/indexes/index.js +1 -1
- package/lib/esm/client/indexes/index.js.map +1 -0
- package/lib/esm/client/logging.js +1 -1
- package/lib/esm/client/logging.js.map +1 -0
- package/lib/esm/client/services/FabricEnrollmentService.js +1 -1
- package/lib/esm/client/services/FabricEnrollmentService.js.map +1 -0
- package/lib/esm/client/services/FabricIdentityService.js +1 -1
- package/lib/esm/client/services/FabricIdentityService.js.map +1 -0
- package/lib/esm/client/services/RegistrationRequestBuilder.js +1 -1
- package/lib/esm/client/services/RegistrationRequestBuilder.js.map +1 -0
- package/lib/esm/client/services/constants.js +1 -1
- package/lib/esm/client/services/constants.js.map +1 -0
- package/lib/esm/client/services/index.js +1 -1
- package/lib/esm/client/services/index.js.map +1 -0
- package/lib/esm/client/types.js +1 -1
- package/lib/esm/client/types.js.map +1 -0
- package/lib/esm/client/utils.js +1 -1
- package/lib/esm/client/utils.js.map +1 -0
- package/lib/esm/contract/Address.js +1 -1
- package/lib/esm/contract/Address.js.map +1 -0
- package/lib/esm/contract/AddressContract.js +1 -1
- package/lib/esm/contract/AddressContract.js.map +1 -0
- package/lib/esm/contract/AuditContract.js +1 -1
- package/lib/esm/contract/AuditContract.js.map +1 -0
- package/lib/esm/contract/BatchContract.js +1 -1
- package/lib/esm/contract/BatchContract.js.map +1 -0
- package/lib/esm/contract/MarketContract.js +1 -1
- package/lib/esm/contract/MarketContract.js.map +1 -0
- package/lib/esm/contract/OtherAuditContract.js +1 -1
- package/lib/esm/contract/OtherAuditContract.js.map +1 -0
- package/lib/esm/contract/OtherBatchContract.js +1 -1
- package/lib/esm/contract/OtherBatchContract.js.map +1 -0
- package/lib/esm/contract/OtherMarketContract.js +1 -1
- package/lib/esm/contract/OtherMarketContract.js.map +1 -0
- package/lib/esm/contract/OtherProductContract.js +1 -1
- package/lib/esm/contract/OtherProductContract.js.map +1 -0
- package/lib/esm/contract/OtherProductImageContract.js +1 -1
- package/lib/esm/contract/OtherProductImageContract.js.map +1 -0
- package/lib/esm/contract/OtherProductSharedContract.js +1 -1
- package/lib/esm/contract/OtherProductSharedContract.js.map +1 -0
- package/lib/esm/contract/OtherProductStrengthContract.js +1 -1
- package/lib/esm/contract/OtherProductStrengthContract.js.map +1 -0
- package/lib/esm/contract/Product.js +1 -1
- package/lib/esm/contract/Product.js.map +1 -0
- package/lib/esm/contract/ProductContract.js +1 -1
- package/lib/esm/contract/ProductContract.js.map +1 -0
- package/lib/esm/contract/ProductStrengthContract.js +1 -1
- package/lib/esm/contract/ProductStrengthContract.js.map +1 -0
- package/lib/esm/contract/SegregatedPrivateDocumentContract.js +1 -1
- package/lib/esm/contract/SegregatedPrivateDocumentContract.js.map +1 -0
- package/lib/esm/contract/SegregatedSharedDocumentContract.js +1 -1
- 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 -0
- package/lib/esm/contract/UserContract.js +1 -1
- package/lib/esm/contract/UserContract.js.map +1 -0
- package/lib/esm/contract/index.js +1 -1
- package/lib/esm/contract/index.js.map +1 -0
- package/lib/esm/contract/logging-context.js +1 -1
- package/lib/esm/contract/logging-context.js.map +1 -0
- package/lib/esm/contract/models/Audit.js +1 -1
- package/lib/esm/contract/models/Audit.js.map +1 -0
- package/lib/esm/contract/models/BaseIdentifiedModel.js +1 -1
- package/lib/esm/contract/models/BaseIdentifiedModel.js.map +1 -0
- package/lib/esm/contract/models/BaseModel.js +1 -1
- package/lib/esm/contract/models/BaseModel.js.map +1 -0
- package/lib/esm/contract/models/Batch.js +1 -1
- package/lib/esm/contract/models/Batch.js.map +1 -0
- package/lib/esm/contract/models/GtinOwner.js +1 -1
- package/lib/esm/contract/models/GtinOwner.js.map +1 -0
- package/lib/esm/contract/models/History.js +1 -1
- package/lib/esm/contract/models/History.js.map +1 -0
- package/lib/esm/contract/models/Leaflet.js +1 -1
- package/lib/esm/contract/models/Leaflet.js.map +1 -0
- package/lib/esm/contract/models/LeafletFile.js +1 -1
- package/lib/esm/contract/models/LeafletFile.js.map +1 -0
- package/lib/esm/contract/models/Market.js +1 -1
- package/lib/esm/contract/models/Market.js.map +1 -0
- package/lib/esm/contract/models/OtherAudit.js +1 -1
- package/lib/esm/contract/models/OtherAudit.js.map +1 -0
- package/lib/esm/contract/models/OtherBatchShared.js +1 -1
- package/lib/esm/contract/models/OtherBatchShared.js.map +1 -0
- package/lib/esm/contract/models/OtherLeaflet.js +1 -1
- package/lib/esm/contract/models/OtherLeaflet.js.map +1 -0
- package/lib/esm/contract/models/OtherLeafletFile.js +1 -1
- package/lib/esm/contract/models/OtherLeafletFile.js.map +1 -0
- package/lib/esm/contract/models/OtherMarket.js +1 -1
- package/lib/esm/contract/models/OtherMarket.js.map +1 -0
- package/lib/esm/contract/models/OtherProduct.js +1 -1
- package/lib/esm/contract/models/OtherProduct.js.map +1 -0
- package/lib/esm/contract/models/OtherProductImage.js +1 -1
- package/lib/esm/contract/models/OtherProductImage.js.map +1 -0
- package/lib/esm/contract/models/OtherProductShared.js +1 -1
- package/lib/esm/contract/models/OtherProductShared.js.map +1 -0
- package/lib/esm/contract/models/OtherProductStrength.js +1 -1
- package/lib/esm/contract/models/OtherProductStrength.js.map +1 -0
- package/lib/esm/contract/models/Product.js +1 -1
- package/lib/esm/contract/models/Product.js.map +1 -0
- package/lib/esm/contract/models/ProductStrength.js +1 -1
- package/lib/esm/contract/models/ProductStrength.js.map +1 -0
- package/lib/esm/contract/models/SegregatedDocument.js +1 -1
- package/lib/esm/contract/models/SegregatedDocument.js.map +1 -0
- package/lib/esm/contract/models/constants.js +1 -1
- package/lib/esm/contract/models/constants.js.map +1 -0
- package/lib/esm/contract/models/decorators-private.js +1 -1
- package/lib/esm/contract/models/decorators-private.js.map +1 -0
- package/lib/esm/contract/models/decorators.js +1 -1
- package/lib/esm/contract/models/decorators.js.map +1 -0
- package/lib/esm/contract/models/gtin.js +1 -1
- package/lib/esm/contract/models/gtin.js.map +1 -0
- package/lib/esm/contract/models/history-dec.js +1 -1
- package/lib/esm/contract/models/history-dec.js.map +1 -0
- package/lib/esm/contracts/ContractAdapter.js +1 -1
- package/lib/esm/contracts/ContractAdapter.js.map +1 -0
- package/lib/esm/contracts/ContractContext.js +1 -1
- package/lib/esm/contracts/ContractContext.js.map +1 -0
- package/lib/esm/contracts/FabricContractDispatch.js +1 -1
- package/lib/esm/contracts/FabricContractDispatch.js.map +1 -0
- package/lib/esm/contracts/FabricContractPaginator.js +1 -1
- package/lib/esm/contracts/FabricContractPaginator.js.map +1 -0
- package/lib/esm/contracts/FabricContractRepository.js +1 -1
- package/lib/esm/contracts/FabricContractRepository.js.map +1 -0
- package/lib/esm/contracts/FabricContractRepositoryObservableHandler.js +1 -1
- package/lib/esm/contracts/FabricContractRepositoryObservableHandler.js.map +1 -0
- package/lib/esm/contracts/FabricContractSequence.js +1 -1
- package/lib/esm/contracts/FabricContractSequence.js.map +1 -0
- package/lib/esm/contracts/FabricContractStatement.js +1 -1
- package/lib/esm/contracts/FabricContractStatement.js.map +1 -0
- package/lib/esm/contracts/MigrationContract.js +1 -1
- package/lib/esm/contracts/MigrationContract.js.map +1 -0
- package/lib/esm/contracts/PrivateSequence.js +1 -1
- package/lib/esm/contracts/PrivateSequence.js.map +1 -0
- package/lib/esm/contracts/auth/decorators.js +1 -1
- package/lib/esm/contracts/auth/decorators.js.map +1 -0
- package/lib/esm/contracts/auth/index.js +1 -1
- package/lib/esm/contracts/auth/index.js.map +1 -0
- package/lib/esm/contracts/crud/crud-contract.js +1 -1
- package/lib/esm/contracts/crud/crud-contract.js.map +1 -0
- package/lib/esm/contracts/crud/index.js +1 -1
- package/lib/esm/contracts/crud/index.js.map +1 -0
- package/lib/esm/contracts/crud/serialized-crud-contract.js +1 -1
- package/lib/esm/contracts/crud/serialized-crud-contract.js.map +1 -0
- package/lib/esm/contracts/erc20/erc20contract.js +1 -1
- package/lib/esm/contracts/erc20/erc20contract.js.map +1 -0
- package/lib/esm/contracts/erc20/index.js +1 -1
- package/lib/esm/contracts/erc20/index.js.map +1 -0
- package/lib/esm/contracts/erc20/models.js +1 -1
- package/lib/esm/contracts/erc20/models.js.map +1 -0
- package/lib/esm/contracts/index.js +1 -1
- package/lib/esm/contracts/index.js.map +1 -0
- package/lib/esm/contracts/logging.js +1 -1
- package/lib/esm/contracts/logging.js.map +1 -0
- package/lib/esm/contracts/overrides.js +1 -1
- package/lib/esm/contracts/overrides.js.map +1 -0
- package/lib/esm/contracts/types.js +1 -1
- package/lib/esm/contracts/types.js.map +1 -0
- package/lib/esm/contracts/uuid.js +1 -1
- package/lib/esm/contracts/uuid.js.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/shared/ClientSerializer.js +1 -1
- package/lib/esm/shared/ClientSerializer.js.map +1 -0
- package/lib/esm/shared/DeterministicSerializer.js +1 -1
- package/lib/esm/shared/DeterministicSerializer.js.map +1 -0
- package/lib/esm/shared/SimpleDeterministicSerializer.js +1 -1
- package/lib/esm/shared/SimpleDeterministicSerializer.js.map +1 -0
- package/lib/esm/shared/constants.js +1 -1
- package/lib/esm/shared/constants.js.map +1 -0
- package/lib/esm/shared/decorators.js +1 -1
- package/lib/esm/shared/decorators.js.map +1 -0
- package/lib/esm/shared/erc20/erc20-constants.js +1 -1
- package/lib/esm/shared/erc20/erc20-constants.js.map +1 -0
- package/lib/esm/shared/erc20/index.js +1 -1
- package/lib/esm/shared/erc20/index.js.map +1 -0
- package/lib/esm/shared/errors.js +1 -1
- package/lib/esm/shared/errors.js.map +1 -0
- package/lib/esm/shared/events.js +1 -1
- package/lib/esm/shared/events.js.map +1 -0
- package/lib/esm/shared/fabric-types.js +1 -1
- package/lib/esm/shared/fabric-types.js.map +1 -0
- package/lib/esm/shared/index.js +1 -1
- package/lib/esm/shared/index.js.map +1 -0
- package/lib/esm/shared/interfaces/Checkable.js +1 -1
- package/lib/esm/shared/interfaces/Checkable.js.map +1 -0
- package/lib/esm/shared/interfaces/index.js +1 -1
- package/lib/esm/shared/interfaces/index.js.map +1 -0
- package/lib/esm/shared/math.js +1 -1
- package/lib/esm/shared/math.js.map +1 -0
- package/lib/esm/shared/model/FabricBaseModel.js +1 -1
- package/lib/esm/shared/model/FabricBaseModel.js.map +1 -0
- package/lib/esm/shared/model/FabricIdentifiedBaseModel.js +1 -1
- package/lib/esm/shared/model/FabricIdentifiedBaseModel.js.map +1 -0
- package/lib/esm/shared/model/Identity.js +1 -1
- package/lib/esm/shared/model/Identity.js.map +1 -0
- package/lib/esm/shared/model/IdentityCredentials.js +1 -1
- package/lib/esm/shared/model/IdentityCredentials.js.map +1 -0
- package/lib/esm/shared/model/index.js +1 -1
- package/lib/esm/shared/model/index.js.map +1 -0
- package/lib/esm/shared/overrides/Model.js +1 -1
- package/lib/esm/shared/overrides/Model.js.map +1 -0
- package/lib/esm/shared/overrides/index.js +1 -1
- package/lib/esm/shared/overrides/index.js.map +1 -0
- package/lib/esm/shared/overrides/overrides.js +1 -1
- package/lib/esm/shared/overrides/overrides.js.map +1 -0
- package/lib/esm/shared/types.js +1 -1
- package/lib/esm/shared/types.js.map +1 -0
- package/lib/esm/version.js +2 -2
- package/lib/esm/version.js.map +1 -0
- package/lib/{esm → types}/version.d.ts +1 -1
- package/package.json +22 -18
- package/lib/bin/cli.cjs +0 -9
- package/lib/cli-module.cjs +0 -479
- package/lib/cli-utils.cjs +0 -309
- package/lib/client/FabricClientAdapter.cjs +0 -1362
- package/lib/client/FabricClientDispatch.cjs +0 -290
- package/lib/client/FabricClientPaginator.cjs +0 -21
- package/lib/client/FabricClientRepository.cjs +0 -259
- package/lib/client/FabricClientStatement.cjs +0 -451
- package/lib/client/collections/generation.cjs +0 -113
- package/lib/client/constants.cjs +0 -16
- package/lib/client/crypto.cjs +0 -368
- package/lib/client/erc20/FabricERC20ClientRepository.cjs +0 -363
- package/lib/client/fabric-fs.cjs +0 -234
- package/lib/client/fabric-hsm.cjs +0 -165
- package/lib/client/ids/id-extraction.cjs +0 -30
- package/lib/client/indexes/generation.cjs +0 -95
- package/lib/client/logging.cjs +0 -102
- package/lib/client/services/FabricEnrollmentService.cjs +0 -363
- package/lib/client/services/FabricIdentityService.cjs +0 -324
- package/lib/client/services/RegistrationRequestBuilder.cjs +0 -91
- package/lib/client/services/constants.cjs +0 -20
- package/lib/client/services/index.cjs +0 -21
- package/lib/client/types.cjs +0 -3
- package/lib/client/utils.cjs +0 -262
- package/lib/contract/index.cjs +0 -36
- package/lib/contract/logging-context.cjs +0 -77
- package/lib/contract/models/Audit.cjs +0 -106
- package/lib/contract/models/Batch.cjs +0 -174
- package/lib/contract/models/GtinOwner.cjs +0 -59
- package/lib/contract/models/History.cjs +0 -75
- package/lib/contract/models/Leaflet.cjs +0 -95
- package/lib/contract/models/LeafletFile.cjs +0 -58
- package/lib/contract/models/Market.cjs +0 -75
- package/lib/contract/models/OtherAudit.cjs +0 -118
- package/lib/contract/models/OtherBatchShared.cjs +0 -127
- package/lib/contract/models/OtherLeaflet.cjs +0 -115
- package/lib/contract/models/OtherLeafletFile.cjs +0 -65
- package/lib/contract/models/OtherMarket.cjs +0 -84
- package/lib/contract/models/OtherProduct.cjs +0 -77
- package/lib/contract/models/OtherProductImage.cjs +0 -59
- package/lib/contract/models/OtherProductShared.cjs +0 -99
- package/lib/contract/models/OtherProductStrength.cjs +0 -87
- package/lib/contract/models/Product.cjs +0 -78
- package/lib/contract/models/ProductStrength.cjs +0 -78
- package/lib/contract/models/constants.cjs +0 -30
- package/lib/contract/models/decorators-private.cjs +0 -158
- package/lib/contract/models/decorators.cjs +0 -182
- package/lib/contract/models/gtin.cjs +0 -88
- package/lib/contract/models/history-dec.cjs +0 -83
- package/lib/contracts/ContractAdapter.cjs +0 -1193
- package/lib/contracts/ContractContext.cjs +0 -157
- package/lib/contracts/FabricContractDispatch.cjs +0 -79
- package/lib/contracts/FabricContractPaginator.cjs +0 -173
- package/lib/contracts/FabricContractRepository.cjs +0 -322
- package/lib/contracts/FabricContractRepositoryObservableHandler.cjs +0 -96
- package/lib/contracts/FabricContractSequence.cjs +0 -338
- package/lib/contracts/FabricContractStatement.cjs +0 -180
- package/lib/contracts/MigrationContract.cjs +0 -147
- package/lib/contracts/auth/decorators.cjs +0 -84
- package/lib/contracts/crud/crud-contract.cjs +0 -416
- package/lib/contracts/crud/serialized-crud-contract.cjs +0 -284
- package/lib/contracts/erc20/erc20contract.cjs +0 -581
- package/lib/contracts/erc20/index.cjs +0 -21
- package/lib/contracts/erc20/models.cjs +0 -209
- package/lib/contracts/logging.cjs +0 -118
- package/lib/contracts/overrides.cjs +0 -8
- package/lib/contracts/types.cjs +0 -3
- package/lib/contracts/uuid.cjs +0 -75
- package/lib/esm/bin/cli.d.ts +0 -1
- package/lib/esm/cli-module.d.ts +0 -3
- package/lib/esm/cli-utils.d.ts +0 -21
- package/lib/esm/client/FabricClientAdapter.d.ts +0 -404
- package/lib/esm/client/FabricClientDispatch.d.ts +0 -133
- package/lib/esm/client/FabricClientPaginator.d.ts +0 -12
- package/lib/esm/client/FabricClientRepository.d.ts +0 -71
- package/lib/esm/client/FabricClientStatement.d.ts +0 -64
- package/lib/esm/client/collections/generation.d.ts +0 -46
- package/lib/esm/client/collections/index.d.ts +0 -1
- package/lib/esm/client/constants.d.ts +0 -2
- package/lib/esm/client/crypto.d.ts +0 -107
- package/lib/esm/client/erc20/index.d.ts +0 -1
- package/lib/esm/client/fabric-fs.d.ts +0 -92
- package/lib/esm/client/fabric-hsm.d.ts +0 -24
- package/lib/esm/client/ids/id-extraction.d.ts +0 -4
- package/lib/esm/client/ids/index.d.ts +0 -1
- package/lib/esm/client/index.d.ts +0 -23
- package/lib/esm/client/indexes/generation.d.ts +0 -10
- package/lib/esm/client/indexes/index.d.ts +0 -1
- package/lib/esm/client/services/FabricEnrollmentService.d.ts +0 -176
- package/lib/esm/client/services/FabricIdentityService.d.ts +0 -98
- package/lib/esm/client/services/RegistrationRequestBuilder.d.ts +0 -19
- package/lib/esm/client/services/index.d.ts +0 -4
- package/lib/esm/client/types.d.ts +0 -20
- package/lib/esm/client/utils.d.ts +0 -71
- package/lib/esm/contract/Address.d.ts +0 -13
- package/lib/esm/contract/AddressContract.d.ts +0 -5
- package/lib/esm/contract/AuditContract.d.ts +0 -5
- package/lib/esm/contract/BatchContract.d.ts +0 -5
- package/lib/esm/contract/MarketContract.d.ts +0 -5
- package/lib/esm/contract/OtherAuditContract.d.ts +0 -5
- package/lib/esm/contract/OtherBatchContract.d.ts +0 -5
- package/lib/esm/contract/OtherMarketContract.d.ts +0 -5
- package/lib/esm/contract/OtherProductContract.d.ts +0 -5
- package/lib/esm/contract/OtherProductImageContract.d.ts +0 -5
- package/lib/esm/contract/OtherProductSharedContract.d.ts +0 -5
- package/lib/esm/contract/OtherProductStrengthContract.d.ts +0 -5
- package/lib/esm/contract/Product.d.ts +0 -7
- package/lib/esm/contract/ProductContract.d.ts +0 -5
- package/lib/esm/contract/ProductStrengthContract.d.ts +0 -5
- package/lib/esm/contract/SegregatedPrivateDocumentContract.d.ts +0 -5
- package/lib/esm/contract/SegregatedSharedDocumentContract.d.ts +0 -5
- package/lib/esm/contract/User.d.ts +0 -7
- package/lib/esm/contract/UserContract.d.ts +0 -5
- package/lib/esm/contract/index.d.ts +0 -2
- package/lib/esm/contract/logging-context.d.ts +0 -8
- package/lib/esm/contract/models/Audit.d.ts +0 -13
- package/lib/esm/contract/models/BaseIdentifiedModel.d.ts +0 -7
- package/lib/esm/contract/models/BaseModel.d.ts +0 -7
- package/lib/esm/contract/models/Batch.d.ts +0 -18
- package/lib/esm/contract/models/GtinOwner.d.ts +0 -8
- package/lib/esm/contract/models/History.d.ts +0 -9
- package/lib/esm/contract/models/Leaflet.d.ts +0 -12
- package/lib/esm/contract/models/LeafletFile.d.ts +0 -9
- package/lib/esm/contract/models/Market.d.ts +0 -12
- package/lib/esm/contract/models/OtherAudit.d.ts +0 -15
- package/lib/esm/contract/models/OtherBatchShared.d.ts +0 -18
- package/lib/esm/contract/models/OtherLeaflet.d.ts +0 -16
- package/lib/esm/contract/models/OtherLeafletFile.d.ts +0 -10
- package/lib/esm/contract/models/OtherMarket.d.ts +0 -13
- package/lib/esm/contract/models/OtherProduct.d.ts +0 -12
- package/lib/esm/contract/models/OtherProductImage.d.ts +0 -9
- package/lib/esm/contract/models/OtherProductShared.d.ts +0 -18
- package/lib/esm/contract/models/OtherProductStrength.d.ts +0 -12
- package/lib/esm/contract/models/Product.d.ts +0 -15
- package/lib/esm/contract/models/ProductStrength.d.ts +0 -11
- package/lib/esm/contract/models/SegregatedDocument.d.ts +0 -18
- package/lib/esm/contract/models/constants.d.ts +0 -24
- package/lib/esm/contract/models/decorators-private.d.ts +0 -16
- package/lib/esm/contract/models/decorators.d.ts +0 -28
- package/lib/esm/contract/models/gtin.d.ts +0 -8
- package/lib/esm/contract/models/history-dec.d.ts +0 -6
- package/lib/esm/contracts/ContractAdapter.d.ts +0 -287
- package/lib/esm/contracts/ContractContext.d.ts +0 -89
- package/lib/esm/contracts/FabricContractDispatch.d.ts +0 -7
- package/lib/esm/contracts/FabricContractRepository.d.ts +0 -119
- package/lib/esm/contracts/FabricContractSequence.d.ts +0 -87
- package/lib/esm/contracts/FabricContractStatement.d.ts +0 -36
- package/lib/esm/contracts/MigrationContract.d.ts +0 -22
- package/lib/esm/contracts/PrivateSequence.d.ts +0 -15
- package/lib/esm/contracts/auth/decorators.d.ts +0 -6
- package/lib/esm/contracts/auth/index.d.ts +0 -1
- package/lib/esm/contracts/crud/crud-contract.d.ts +0 -199
- package/lib/esm/contracts/crud/index.d.ts +0 -2
- package/lib/esm/contracts/crud/serialized-crud-contract.d.ts +0 -42
- package/lib/esm/contracts/erc20/erc20contract.d.ts +0 -152
- package/lib/esm/contracts/erc20/index.d.ts +0 -2
- package/lib/esm/contracts/erc20/models.d.ts +0 -114
- package/lib/esm/contracts/index.d.ts +0 -19
- package/lib/esm/contracts/logging.d.ts +0 -54
- package/lib/esm/contracts/types.d.ts +0 -38
- package/lib/esm/contracts/uuid.d.ts +0 -2
- package/lib/esm/shared/overrides/overrides.d.ts +0 -1
- package/lib/index.d.ts +0 -8
- package/lib/shared/ClientSerializer.cjs +0 -81
- package/lib/shared/DeterministicSerializer.cjs +0 -106
- package/lib/shared/DeterministicSerializer.d.ts +0 -47
- package/lib/shared/SimpleDeterministicSerializer.cjs +0 -69
- package/lib/shared/SimpleDeterministicSerializer.d.ts +0 -7
- package/lib/shared/constants.cjs +0 -41
- package/lib/shared/decorators.cjs +0 -595
- package/lib/shared/decorators.d.ts +0 -81
- package/lib/shared/erc20/erc20-constants.cjs +0 -30
- package/lib/shared/erc20/index.d.ts +0 -1
- package/lib/shared/errors.cjs +0 -190
- package/lib/shared/errors.d.ts +0 -140
- package/lib/shared/events.cjs +0 -51
- package/lib/shared/fabric-types.cjs +0 -3
- package/lib/shared/fabric-types.d.ts +0 -32
- package/lib/shared/index.d.ts +0 -20
- package/lib/shared/interfaces/Checkable.cjs +0 -3
- package/lib/shared/interfaces/Checkable.d.ts +0 -23
- package/lib/shared/interfaces/index.d.ts +0 -1
- package/lib/shared/math.cjs +0 -66
- package/lib/shared/math.d.ts +0 -34
- package/lib/shared/model/FabricBaseModel.d.ts +0 -7
- package/lib/shared/model/FabricIdentifiedBaseModel.d.ts +0 -7
- package/lib/shared/model/Identity.cjs +0 -71
- package/lib/shared/model/Identity.d.ts +0 -42
- package/lib/shared/model/IdentityCredentials.cjs +0 -66
- package/lib/shared/model/IdentityCredentials.d.ts +0 -41
- package/lib/shared/model/index.cjs +0 -21
- package/lib/shared/model/index.d.ts +0 -4
- package/lib/shared/overrides/Model.cjs +0 -4
- package/lib/shared/overrides/Model.d.ts +0 -22
- package/lib/shared/overrides/index.d.ts +0 -2
- package/lib/shared/overrides/overrides.cjs +0 -93
- package/lib/shared/overrides/overrides.d.ts +0 -1
- package/lib/shared/types.cjs +0 -3
- package/lib/shared/types.d.ts +0 -125
- package/lib/version.cjs +0 -8
- package/lib/version.d.ts +0 -2
- /package/lib/{bin → types/bin}/cli.d.ts +0 -0
- /package/lib/{cli-module.d.ts → types/cli-module.d.ts} +0 -0
- /package/lib/{cli-utils.d.ts → types/cli-utils.d.ts} +0 -0
- /package/lib/{client → types/client}/FabricClientAdapter.d.ts +0 -0
- /package/lib/{client → types/client}/FabricClientDispatch.d.ts +0 -0
- /package/lib/{client → types/client}/FabricClientPaginator.d.ts +0 -0
- /package/lib/{client → types/client}/FabricClientRepository.d.ts +0 -0
- /package/lib/{client → types/client}/FabricClientStatement.d.ts +0 -0
- /package/lib/{client → types/client}/collections/generation.d.ts +0 -0
- /package/lib/{client → types/client}/collections/index.d.ts +0 -0
- /package/lib/{client → types/client}/constants.d.ts +0 -0
- /package/lib/{client → types/client}/crypto.d.ts +0 -0
- /package/lib/{client → types/client}/erc20/FabricERC20ClientRepository.d.ts +0 -0
- /package/lib/{client → types/client}/erc20/index.d.ts +0 -0
- /package/lib/{client → types/client}/fabric-fs.d.ts +0 -0
- /package/lib/{client → types/client}/fabric-hsm.d.ts +0 -0
- /package/lib/{client → types/client}/ids/id-extraction.d.ts +0 -0
- /package/lib/{client → types/client}/ids/index.d.ts +0 -0
- /package/lib/{client → types/client}/index.d.ts +0 -0
- /package/lib/{client → types/client}/indexes/generation.d.ts +0 -0
- /package/lib/{client → types/client}/indexes/index.d.ts +0 -0
- /package/lib/{client → types/client}/logging.d.ts +0 -0
- /package/lib/{client → types/client}/services/FabricEnrollmentService.d.ts +0 -0
- /package/lib/{client → types/client}/services/FabricIdentityService.d.ts +0 -0
- /package/lib/{client → types/client}/services/RegistrationRequestBuilder.d.ts +0 -0
- /package/lib/{client → types/client}/services/constants.d.ts +0 -0
- /package/lib/{client → types/client}/services/index.d.ts +0 -0
- /package/lib/{client → types/client}/types.d.ts +0 -0
- /package/lib/{client → types/client}/utils.d.ts +0 -0
- /package/lib/{contract → types/contract}/Address.d.ts +0 -0
- /package/lib/{contract → types/contract}/AddressContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/AuditContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/BatchContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/MarketContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/OtherAuditContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/OtherBatchContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/OtherMarketContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/OtherProductContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/OtherProductImageContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/OtherProductSharedContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/OtherProductStrengthContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/Product.d.ts +0 -0
- /package/lib/{contract → types/contract}/ProductContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/ProductStrengthContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/SegregatedPrivateDocumentContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/SegregatedSharedDocumentContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/User.d.ts +0 -0
- /package/lib/{contract → types/contract}/UserContract.d.ts +0 -0
- /package/lib/{contract → types/contract}/index.d.ts +0 -0
- /package/lib/{contract → types/contract}/logging-context.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/Audit.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/BaseIdentifiedModel.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/BaseModel.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/Batch.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/GtinOwner.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/History.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/Leaflet.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/LeafletFile.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/Market.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/OtherAudit.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/OtherBatchShared.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/OtherLeaflet.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/OtherLeafletFile.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/OtherMarket.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/OtherProduct.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/OtherProductImage.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/OtherProductShared.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/OtherProductStrength.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/Product.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/ProductStrength.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/SegregatedDocument.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/constants.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/decorators-private.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/decorators.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/gtin.d.ts +0 -0
- /package/lib/{contract → types/contract}/models/history-dec.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/ContractAdapter.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/ContractContext.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/FabricContractDispatch.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/FabricContractPaginator.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/FabricContractRepository.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/FabricContractRepositoryObservableHandler.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/FabricContractSequence.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/FabricContractStatement.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/MigrationContract.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/PrivateSequence.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/auth/decorators.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/auth/index.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/crud/crud-contract.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/crud/index.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/crud/serialized-crud-contract.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/erc20/erc20contract.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/erc20/index.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/erc20/models.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/index.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/logging.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/overrides.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/types.d.ts +0 -0
- /package/lib/{contracts → types/contracts}/uuid.d.ts +0 -0
- /package/lib/{esm → types}/index.d.ts +0 -0
- /package/lib/{esm → types}/shared/ClientSerializer.d.ts +0 -0
- /package/lib/{esm → types}/shared/DeterministicSerializer.d.ts +0 -0
- /package/lib/{esm → types}/shared/SimpleDeterministicSerializer.d.ts +0 -0
- /package/lib/{esm → types}/shared/constants.d.ts +0 -0
- /package/lib/{esm → types}/shared/decorators.d.ts +0 -0
- /package/lib/{esm → types}/shared/erc20/erc20-constants.d.ts +0 -0
- /package/lib/{esm → types}/shared/erc20/index.d.ts +0 -0
- /package/lib/{esm → types}/shared/errors.d.ts +0 -0
- /package/lib/{esm → types}/shared/events.d.ts +0 -0
- /package/lib/{esm → types}/shared/fabric-types.d.ts +0 -0
- /package/lib/{esm → types}/shared/index.d.ts +0 -0
- /package/lib/{esm → types}/shared/interfaces/Checkable.d.ts +0 -0
- /package/lib/{esm → types}/shared/interfaces/index.d.ts +0 -0
- /package/lib/{esm → types}/shared/math.d.ts +0 -0
- /package/lib/{esm → types}/shared/model/FabricBaseModel.d.ts +0 -0
- /package/lib/{esm → types}/shared/model/FabricIdentifiedBaseModel.d.ts +0 -0
- /package/lib/{esm → types}/shared/model/Identity.d.ts +0 -0
- /package/lib/{esm → types}/shared/model/IdentityCredentials.d.ts +0 -0
- /package/lib/{esm → types}/shared/model/index.d.ts +0 -0
- /package/lib/{esm → types}/shared/overrides/Model.d.ts +0 -0
- /package/lib/{esm → types}/shared/overrides/index.d.ts +0 -0
- /package/lib/{esm/contracts → types/shared/overrides}/overrides.d.ts +0 -0
- /package/lib/{esm → types}/shared/types.d.ts +0 -0
|
@@ -0,0 +1,1362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
var _a;
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.FabricClientAdapter = void 0;
|
|
50
|
+
require("./../shared/overrides/index.cjs");
|
|
51
|
+
const for_couchdb_1 = require("@decaf-ts/for-couchdb");
|
|
52
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
53
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
54
|
+
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
55
|
+
const logging_1 = require("@decaf-ts/logging");
|
|
56
|
+
const fabric_gateway_1 = require("@hyperledger/fabric-gateway");
|
|
57
|
+
const fabric_network_1 = require("fabric-network");
|
|
58
|
+
const fabric_fs_1 = require("./fabric-fs.cjs");
|
|
59
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
60
|
+
const core_1 = require("@decaf-ts/core");
|
|
61
|
+
const constants_1 = require("./../shared/constants.cjs");
|
|
62
|
+
const ClientSerializer_1 = require("./../shared/ClientSerializer.cjs");
|
|
63
|
+
const FabricClientStatement_1 = require("./FabricClientStatement.cjs");
|
|
64
|
+
const FabricClientPaginator_1 = require("./FabricClientPaginator.cjs");
|
|
65
|
+
const FabricClientRepository_1 = require("./FabricClientRepository.cjs");
|
|
66
|
+
const errors_1 = require("./../shared/errors.cjs");
|
|
67
|
+
const constants_2 = require("./constants.cjs");
|
|
68
|
+
const fs_1 = __importDefault(require("fs"));
|
|
69
|
+
const crypto_1 = require("./crypto.cjs");
|
|
70
|
+
const id_extraction_1 = require("./ids/id-extraction.cjs");
|
|
71
|
+
/**
|
|
72
|
+
* @description Adapter for interacting with Hyperledger Fabric networks
|
|
73
|
+
* @summary The FabricAdapter extends CouchDBAdapter to provide a seamless interface for interacting with Hyperledger Fabric networks.
|
|
74
|
+
* It handles connection management, transaction submission, and CRUD operations against Fabric chaincode.
|
|
75
|
+
* @template PeerConfig - Configuration type for connecting to a Fabric peer
|
|
76
|
+
* @template FabricFlags - Flags specific to Fabric operations
|
|
77
|
+
* @template Context<FabricFlags> - Context type containing Fabric-specific flags
|
|
78
|
+
* @param config - Configuration for connecting to a Fabric peer
|
|
79
|
+
* @param alias - Optional alias for the adapter instance
|
|
80
|
+
* @class FabricClientAdapter
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* // Create a new FabricAdapter instance
|
|
84
|
+
* const config: PeerConfig = {
|
|
85
|
+
* mspId: 'Org1MSP',
|
|
86
|
+
* peerEndpoint: 'localhost:7051',
|
|
87
|
+
* channelName: 'mychannel',
|
|
88
|
+
* chaincodeName: 'mycc',
|
|
89
|
+
* contractName: 'mycontract',
|
|
90
|
+
* tlsCertPath: '/path/to/tls/cert',
|
|
91
|
+
* certDirectoryPath: '/path/to/cert/dir',
|
|
92
|
+
* keyDirectoryPath: '/path/to/key/dir'
|
|
93
|
+
* };
|
|
94
|
+
*
|
|
95
|
+
* const adapter = new FabricAdapter(config, 'org1-adapter');
|
|
96
|
+
*
|
|
97
|
+
* // Use the adapter to interact with the Fabric network
|
|
98
|
+
* const result = await adapter.read('users', 'user1', mySerializer);
|
|
99
|
+
* ```
|
|
100
|
+
* @mermaid
|
|
101
|
+
* sequenceDiagram
|
|
102
|
+
* participant Client
|
|
103
|
+
* participant FabricAdapter
|
|
104
|
+
* participant Gateway
|
|
105
|
+
* participant Network
|
|
106
|
+
* participant Contract
|
|
107
|
+
* participant Chaincode
|
|
108
|
+
*
|
|
109
|
+
* Client->>FabricAdapter: create(tableName, id, model, transient, serializer)
|
|
110
|
+
* FabricAdapter->>FabricAdapter: submitTransaction(OperationKeys.CREATE, [serializedModel], transient)
|
|
111
|
+
* FabricAdapter->>Gateway: connect()
|
|
112
|
+
* Gateway->>Network: getNetwork(channelName)
|
|
113
|
+
* Network->>Contract: getContract(chaincodeName, contractName)
|
|
114
|
+
* FabricAdapter->>Contract: submit(api, proposalOptions)
|
|
115
|
+
* Contract->>Chaincode: invoke
|
|
116
|
+
* Chaincode-->>Contract: response
|
|
117
|
+
* Contract-->>FabricAdapter: result
|
|
118
|
+
* FabricAdapter->>FabricAdapter: decode(result)
|
|
119
|
+
* FabricAdapter->>FabricAdapter: serializer.deserialize(decodedResult)
|
|
120
|
+
* FabricAdapter-->>Client: deserializedResult
|
|
121
|
+
*/
|
|
122
|
+
class FabricClientAdapter extends core_1.Adapter {
|
|
123
|
+
/**
|
|
124
|
+
* @description Static text decoder for converting Uint8Array to string
|
|
125
|
+
*/
|
|
126
|
+
static { this.decoder = new TextDecoder("utf8"); }
|
|
127
|
+
static { this.serializer = new ClientSerializer_1.ClientSerializer(); }
|
|
128
|
+
static { this.log = logging_1.Logging.for(FabricClientAdapter); }
|
|
129
|
+
/**
|
|
130
|
+
* @description Creates a new FabricAdapter instance
|
|
131
|
+
* @summary Initializes a new adapter for interacting with a Hyperledger Fabric network
|
|
132
|
+
* @param {PeerConfig} config - Configuration for connecting to a Fabric peer
|
|
133
|
+
* @param {string} [alias] - Optional alias for the adapter instance
|
|
134
|
+
*/
|
|
135
|
+
constructor(config, alias) {
|
|
136
|
+
super(Object.assign({}, constants_2.DefaultFabricClientFlags, config), constants_1.FabricFlavour, alias);
|
|
137
|
+
this.serializer = FabricClientAdapter.serializer;
|
|
138
|
+
}
|
|
139
|
+
Statement(overrides) {
|
|
140
|
+
return new FabricClientStatement_1.FabricClientStatement(this, overrides);
|
|
141
|
+
}
|
|
142
|
+
Paginator(query, size, clazz) {
|
|
143
|
+
return new FabricClientPaginator_1.FabricClientPaginator(this, query, size, clazz);
|
|
144
|
+
}
|
|
145
|
+
async flags(operation, model, flags, ...args) {
|
|
146
|
+
const mergedFlags = Object.assign({}, this.config, flags);
|
|
147
|
+
const f = Object.assign(await super.flags(operation, model, mergedFlags, ...args));
|
|
148
|
+
return f;
|
|
149
|
+
}
|
|
150
|
+
async context(operation, overrides, model, ...args) {
|
|
151
|
+
const log = this.log.for(this.context);
|
|
152
|
+
log.silly(`creating new context for ${operation} operation on ${model ? (Array.isArray(model) ? model.map((m) => decorator_validation_1.Model.tableName(m)) : decorator_validation_1.Model.tableName(model)) : "no"} table ${overrides && Object.keys(overrides) ? Object.keys(overrides).length : "no"} with flag overrides`);
|
|
153
|
+
let ctx = args.pop();
|
|
154
|
+
if (typeof ctx !== "undefined" && !(ctx instanceof core_1.Context)) {
|
|
155
|
+
args.push(ctx);
|
|
156
|
+
ctx = undefined;
|
|
157
|
+
}
|
|
158
|
+
overrides = ctx
|
|
159
|
+
? Object.assign({}, ctx.toOverrides(), overrides)
|
|
160
|
+
: overrides;
|
|
161
|
+
const flags = await this.flags(typeof operation === "string" ? operation : operation.name, model, overrides, ...[...args, ctx].filter(Boolean));
|
|
162
|
+
if (ctx) {
|
|
163
|
+
if (!(ctx instanceof this.Context)) {
|
|
164
|
+
const newCtx = new this.Context().accumulate({
|
|
165
|
+
...ctx["cache"],
|
|
166
|
+
...flags,
|
|
167
|
+
parentContext: ctx,
|
|
168
|
+
});
|
|
169
|
+
ctx.accumulate({
|
|
170
|
+
childContexts: [
|
|
171
|
+
...(ctx.getOrUndefined("childContexts") || []),
|
|
172
|
+
newCtx,
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
return newCtx;
|
|
176
|
+
}
|
|
177
|
+
const currentOp = ctx.getOrUndefined("operation");
|
|
178
|
+
const currentModel = ctx.getOrUndefined("affectedTables");
|
|
179
|
+
if (!currentOp ||
|
|
180
|
+
currentOp !== operation ||
|
|
181
|
+
(model && model !== currentModel)) {
|
|
182
|
+
const newCtx = new this.Context().accumulate({
|
|
183
|
+
...ctx["cache"],
|
|
184
|
+
...flags,
|
|
185
|
+
parentContext: ctx,
|
|
186
|
+
});
|
|
187
|
+
ctx.accumulate({
|
|
188
|
+
childContexts: [
|
|
189
|
+
...(ctx.getOrUndefined("childContexts") || []),
|
|
190
|
+
newCtx,
|
|
191
|
+
],
|
|
192
|
+
});
|
|
193
|
+
return newCtx;
|
|
194
|
+
}
|
|
195
|
+
return ctx.accumulate(flags);
|
|
196
|
+
}
|
|
197
|
+
return new this.Context().accumulate({
|
|
198
|
+
...flags,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* @description Decodes a Uint8Array to a string
|
|
203
|
+
* @summary Converts binary data received from Fabric to a string using UTF-8 encoding
|
|
204
|
+
* @param {Uint8Array} data - The binary data to decode
|
|
205
|
+
* @return {string} The decoded string
|
|
206
|
+
*/
|
|
207
|
+
decode(data) {
|
|
208
|
+
return FabricClientAdapter.decoder.decode(data);
|
|
209
|
+
}
|
|
210
|
+
repository() {
|
|
211
|
+
return FabricClientRepository_1.FabricClientRepository;
|
|
212
|
+
}
|
|
213
|
+
createPrefix(clazz, id, model, ...args) {
|
|
214
|
+
const { ctxArgs } = this.logCtx(args, this.createPrefix);
|
|
215
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
216
|
+
const record = {};
|
|
217
|
+
record[for_couchdb_1.CouchDBKeys.TABLE] = tableName;
|
|
218
|
+
Object.assign(record, model);
|
|
219
|
+
return [clazz, id, record, ...ctxArgs];
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* @description Prepares multiple records for creation
|
|
223
|
+
* @summary Adds necessary CouchDB fields to multiple records before creation
|
|
224
|
+
* @param {string} tableName - The name of the table
|
|
225
|
+
* @param {string[]|number[]} ids - The IDs of the records
|
|
226
|
+
* @param models - The models to prepare
|
|
227
|
+
* @return A tuple containing the tableName, ids, and prepared records
|
|
228
|
+
* @throws {InternalError} If ids and models arrays have different lengths
|
|
229
|
+
*/
|
|
230
|
+
createAllPrefix(clazz, ids, models, ...args) {
|
|
231
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
232
|
+
if (ids.length !== models.length)
|
|
233
|
+
throw new db_decorators_1.InternalError("Ids and models must have the same length");
|
|
234
|
+
const { ctxArgs } = this.logCtx(args, this.createAllPrefix);
|
|
235
|
+
const records = ids.map((id, count) => {
|
|
236
|
+
const record = {};
|
|
237
|
+
record[for_couchdb_1.CouchDBKeys.TABLE] = tableName;
|
|
238
|
+
Object.assign(record, models[count]);
|
|
239
|
+
return record;
|
|
240
|
+
});
|
|
241
|
+
return [clazz, ids, records, ...ctxArgs];
|
|
242
|
+
}
|
|
243
|
+
updateAllPrefix(clazz, ids, models, ...args) {
|
|
244
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
245
|
+
if (ids.length !== models.length)
|
|
246
|
+
throw new db_decorators_1.InternalError("Ids and models must have the same length");
|
|
247
|
+
const { ctxArgs } = this.logCtx(args, this.updateAllPrefix);
|
|
248
|
+
const records = ids.map(() => {
|
|
249
|
+
const record = {};
|
|
250
|
+
record[for_couchdb_1.CouchDBKeys.TABLE] = tableName;
|
|
251
|
+
return record;
|
|
252
|
+
});
|
|
253
|
+
return [clazz, ids, records, ...ctxArgs];
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* @description Creates multiple records in a single transaction
|
|
257
|
+
* @summary Submits a transaction to create multiple records in the Fabric ledger
|
|
258
|
+
* @param {string} tableName - The name of the table/collection
|
|
259
|
+
* @param {string[] | number[]} ids - Array of record identifiers
|
|
260
|
+
* @param {Array<Record<string, any>>} models - Array of record data
|
|
261
|
+
* @param {Record<string, any>} transient - Transient data for the transaction
|
|
262
|
+
* @return {Promise<Array<Record<string, any>>>} Promise resolving to the created records
|
|
263
|
+
*/
|
|
264
|
+
async createAll(clazz, ids, models, ...args) {
|
|
265
|
+
if (ids.length !== models.length)
|
|
266
|
+
throw new db_decorators_1.InternalError("Ids and models must have the same length");
|
|
267
|
+
//HERE!
|
|
268
|
+
const ctxArgs = [...args];
|
|
269
|
+
const transient = ctxArgs.shift();
|
|
270
|
+
const { log, ctx } = this.logCtx(ctxArgs, this.createAll);
|
|
271
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
272
|
+
log.info(`adding ${ids.length} entries to ${tableName} table`);
|
|
273
|
+
log.verbose(`pks: ${ids}`);
|
|
274
|
+
const hasTransient = transient && Object.keys(transient).length > 0;
|
|
275
|
+
const needsFullPayload = hasTransient || this.shouldForceGatewayHydration(ctx);
|
|
276
|
+
const transientPayload = hasTransient ? { [tableName]: transient } : {};
|
|
277
|
+
const result = await this.submitTransaction(ctx, db_decorators_1.BulkCrudOperationKeys.CREATE_ALL, [
|
|
278
|
+
JSON.stringify(models.map((m) => this.serializer.serialize(m, clazz.name))),
|
|
279
|
+
], transientPayload, this.getEndorsingOrganizations(ctx), clazz.name);
|
|
280
|
+
let res;
|
|
281
|
+
try {
|
|
282
|
+
res = JSON.parse(this.decode(result)).map((r) => JSON.parse(r));
|
|
283
|
+
}
|
|
284
|
+
catch (e) {
|
|
285
|
+
throw new db_decorators_1.SerializationError(e);
|
|
286
|
+
}
|
|
287
|
+
if (this.shouldRefreshAfterWrite(clazz, ctx, needsFullPayload, res[0][decorator_validation_1.Model.pk(clazz)] || ids[0])) {
|
|
288
|
+
return this.readAll(clazz, (0, id_extraction_1.extractIds)(clazz, models.map((m, i) => decorator_validation_1.Model.merge(Object.assign({}, m, transient[i] || {}), res[i])), ids), ctx);
|
|
289
|
+
}
|
|
290
|
+
return res;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* @description Reads multiple records in a single transaction
|
|
294
|
+
* @summary Submits a transaction to read multiple records from the Fabric ledger
|
|
295
|
+
* @param {string} tableName - The name of the table/collection
|
|
296
|
+
* @param {string[] | number[]} ids - Array of record identifiers to read
|
|
297
|
+
* @return {Promise<Array<Record<string, any>>>} Promise resolving to the retrieved records
|
|
298
|
+
*/
|
|
299
|
+
async readAll(clazz, ids, ...args) {
|
|
300
|
+
const { log, ctx } = this.logCtx(args, this.readAll);
|
|
301
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
302
|
+
log.info(`reading ${ids.length} entries to ${tableName} table`);
|
|
303
|
+
log.verbose(`pks: ${ids}`);
|
|
304
|
+
const result = await this.evaluateTransaction(ctx, db_decorators_1.BulkCrudOperationKeys.READ_ALL, [JSON.stringify(ids)], undefined, undefined, clazz.name);
|
|
305
|
+
try {
|
|
306
|
+
return JSON.parse(this.decode(result)).map((r) => JSON.parse(r));
|
|
307
|
+
}
|
|
308
|
+
catch (e) {
|
|
309
|
+
throw new db_decorators_1.SerializationError(e);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* @description Updates multiple records in a single transaction
|
|
314
|
+
* @summary Submits a transaction to update multiple records in the Fabric ledger
|
|
315
|
+
* @param {string} tableName - The name of the table/collection
|
|
316
|
+
* @param {string[] | number[]} ids - Array of record identifiers
|
|
317
|
+
* @param {Array<Record<string, any>>} models - Array of updated record data
|
|
318
|
+
* @param {Record<string, any>} transient - Transient data for the transaction
|
|
319
|
+
* @return {Promise<Array<Record<string, any>>>} Promise resolving to the updated records
|
|
320
|
+
*/
|
|
321
|
+
async updateAll(clazz, ids, models, ...args) {
|
|
322
|
+
if (ids.length !== models.length)
|
|
323
|
+
throw new db_decorators_1.InternalError("Ids and models must have the same length");
|
|
324
|
+
const ctxArgs = [...args];
|
|
325
|
+
const transient = ctxArgs.shift();
|
|
326
|
+
const { log, ctx } = this.logCtx(ctxArgs, this.updateAll);
|
|
327
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
328
|
+
log.info(`updating ${ids.length} entries to ${tableName} table`);
|
|
329
|
+
log.verbose(`pks: ${ids}`);
|
|
330
|
+
const hasTransient = transient && Object.keys(transient).length > 0;
|
|
331
|
+
const needsFullPayload = hasTransient || this.shouldForceGatewayHydration(ctx);
|
|
332
|
+
const transientPayload = hasTransient ? { [tableName]: transient } : {};
|
|
333
|
+
const result = await this.submitTransaction(ctx, db_decorators_1.BulkCrudOperationKeys.UPDATE_ALL, [
|
|
334
|
+
JSON.stringify(models.map((m) => this.serializer.serialize(m, clazz.name))),
|
|
335
|
+
], transientPayload, this.getEndorsingOrganizations(ctx), clazz.name);
|
|
336
|
+
let res;
|
|
337
|
+
try {
|
|
338
|
+
res = JSON.parse(this.decode(result)).map((r) => JSON.parse(r));
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
throw new db_decorators_1.SerializationError(e);
|
|
342
|
+
}
|
|
343
|
+
if (this.shouldRefreshAfterWrite(clazz, ctx, needsFullPayload, ids[0])) {
|
|
344
|
+
return this.readAll(clazz, (0, id_extraction_1.extractIds)(clazz, models.map((m, i) => decorator_validation_1.Model.merge(Object.assign({}, m, transient[i] || {}), res[i])), ids), ctx);
|
|
345
|
+
}
|
|
346
|
+
return res;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* @description Deletes multiple records in a single transaction
|
|
350
|
+
* @summary Submits a transaction to delete multiple records from the Fabric ledger
|
|
351
|
+
* @param {string} tableName - The name of the table/collection
|
|
352
|
+
* @param {Array<string | number | bigint>} ids - Array of record identifiers to delete
|
|
353
|
+
* @param {Serializer<any>} serializer - Serializer for the model data
|
|
354
|
+
* @return {Promise<Array<Record<string, any>>>} Promise resolving to the deleted records
|
|
355
|
+
*/
|
|
356
|
+
async deleteAll(clazz, ids, ...args) {
|
|
357
|
+
const { log, ctx, ctxArgs } = this.logCtx(args, this.deleteAll);
|
|
358
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
359
|
+
const needsFullPayload = decorator_validation_1.Model.isTransient(clazz) || this.shouldForceGatewayHydration(ctx);
|
|
360
|
+
let result;
|
|
361
|
+
const shouldHydrate = this.shouldRefreshAfterWrite(clazz, ctx, needsFullPayload, ids[0]);
|
|
362
|
+
if (shouldHydrate) {
|
|
363
|
+
result = await this.readAll(clazz, ids, ...ctxArgs);
|
|
364
|
+
}
|
|
365
|
+
log.info(`deleting ${ids.length} entries to ${tableName} table`);
|
|
366
|
+
log.verbose(`pks: ${ids}`);
|
|
367
|
+
const res = await this.submitTransaction(ctx, db_decorators_1.BulkCrudOperationKeys.DELETE_ALL, [JSON.stringify(ids)], undefined, this.getEndorsingOrganizations(ctx), clazz.name);
|
|
368
|
+
try {
|
|
369
|
+
return shouldHydrate
|
|
370
|
+
? result
|
|
371
|
+
: JSON.parse(this.decode(res)).map((r) => JSON.parse(r));
|
|
372
|
+
}
|
|
373
|
+
catch (e) {
|
|
374
|
+
throw new db_decorators_1.SerializationError(e);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* @description Prepares a model for persistence
|
|
379
|
+
* @summary Converts a model instance into a format suitable for database storage,
|
|
380
|
+
* handling column mapping and separating transient properties
|
|
381
|
+
* @template M - The model type
|
|
382
|
+
* @param {M} model - The model instance to prepare
|
|
383
|
+
* @param pk - The primary key property name
|
|
384
|
+
* @return The prepared data
|
|
385
|
+
*/
|
|
386
|
+
prepare(model, ...args) {
|
|
387
|
+
const { log, ctx } = this.logCtx(args, this.prepare);
|
|
388
|
+
const split = decorator_validation_1.Model.segregate(model);
|
|
389
|
+
if (model[core_1.PersistenceKeys.METADATA]) {
|
|
390
|
+
log.silly(`Passing along persistence metadata for ${model[core_1.PersistenceKeys.METADATA]}`);
|
|
391
|
+
Object.defineProperty(split.model, core_1.PersistenceKeys.METADATA, {
|
|
392
|
+
enumerable: false,
|
|
393
|
+
writable: false,
|
|
394
|
+
configurable: true,
|
|
395
|
+
value: model[core_1.PersistenceKeys.METADATA],
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
const mirrorMeta = decorator_validation_1.Model.mirroredAt(model);
|
|
399
|
+
if (mirrorMeta) {
|
|
400
|
+
const mirrorMsp = mirrorMeta.mspId;
|
|
401
|
+
if (!mirrorMsp)
|
|
402
|
+
throw new db_decorators_1.InternalError(`No mirror MSP could be found`);
|
|
403
|
+
let msps = this.getEndorsingOrganizations(ctx) || [];
|
|
404
|
+
msps = Array.isArray(msps) ? msps : [msps];
|
|
405
|
+
const merged = [...new Set([...msps, mirrorMsp])];
|
|
406
|
+
ctx.accumulate({
|
|
407
|
+
endorsingOrgs: merged,
|
|
408
|
+
endorsingOrganizations: merged,
|
|
409
|
+
legacy: true,
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
record: split.model,
|
|
414
|
+
model: split.model,
|
|
415
|
+
id: model[decorator_validation_1.Model.pk(model.constructor)],
|
|
416
|
+
transient: split.transient,
|
|
417
|
+
privates: split.privates,
|
|
418
|
+
shared: split.shared,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
revert(obj, clazz, id, transient, ...args) {
|
|
422
|
+
const { log, ctx } = this.logCtx(args, this.revert);
|
|
423
|
+
if (transient &&
|
|
424
|
+
this.shouldRebuildWithTransient(ctx, ctx.getOrUndefined("operation"))) {
|
|
425
|
+
log.verbose(`re-adding transient properties: ${Object.keys(transient).join(", ")}`);
|
|
426
|
+
Object.entries(transient)
|
|
427
|
+
.filter(([, v]) => typeof v !== "undefined")
|
|
428
|
+
.forEach(([key, val]) => {
|
|
429
|
+
if (key in obj && obj[key] !== undefined)
|
|
430
|
+
log.warn(`overwriting existing ${key}. if this is not a default value, this may pose a problem`);
|
|
431
|
+
obj[key] = val;
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
const result = new clazz(obj);
|
|
435
|
+
return result;
|
|
436
|
+
}
|
|
437
|
+
shouldRebuildWithTransient(ctx, operation) {
|
|
438
|
+
if (!ctx)
|
|
439
|
+
return false;
|
|
440
|
+
if (ctx.getOrUndefined("rebuildWithTransient"))
|
|
441
|
+
return true;
|
|
442
|
+
const childRebuild = typeof ctx.getFromChildren === "function"
|
|
443
|
+
? ctx.getFromChildren("rebuildWithTransient")
|
|
444
|
+
: undefined;
|
|
445
|
+
if (childRebuild)
|
|
446
|
+
return true;
|
|
447
|
+
const resolvedOp = this.resolveOperation(ctx, operation);
|
|
448
|
+
if (!resolvedOp)
|
|
449
|
+
return false;
|
|
450
|
+
const op = resolvedOp.toString().toLowerCase();
|
|
451
|
+
return (op.includes("read") ||
|
|
452
|
+
op.includes("find") ||
|
|
453
|
+
op.includes("query") ||
|
|
454
|
+
op.includes("statement") ||
|
|
455
|
+
op.includes("page"));
|
|
456
|
+
}
|
|
457
|
+
resolveOperation(ctx, operation) {
|
|
458
|
+
if (operation)
|
|
459
|
+
return operation;
|
|
460
|
+
if (typeof ctx.getFromChildren === "function") {
|
|
461
|
+
return ctx.getFromChildren("operation");
|
|
462
|
+
}
|
|
463
|
+
return undefined;
|
|
464
|
+
}
|
|
465
|
+
shouldRefreshAfterWrite(clazz, ctx, hasTransient, id) {
|
|
466
|
+
if (!hasTransient)
|
|
467
|
+
return false;
|
|
468
|
+
const pk = decorator_validation_1.Model.pk(clazz);
|
|
469
|
+
const composed = decorator_validation_1.Model.composed(clazz, pk);
|
|
470
|
+
const generated = decorator_validation_1.Model.generated(clazz, pk);
|
|
471
|
+
const hasId = id !== undefined && id !== null;
|
|
472
|
+
if (!hasId && composed)
|
|
473
|
+
return true;
|
|
474
|
+
if (!hasId && generated) {
|
|
475
|
+
ctx.logger.warn(`Cannot refresh record with private generated primary key`);
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
return hasId;
|
|
479
|
+
}
|
|
480
|
+
getEndorsingOrganizations(ctx) {
|
|
481
|
+
const direct = ctx.getOrUndefined("endorsingOrgs") ||
|
|
482
|
+
ctx.getOrUndefined("endorsingOrgs");
|
|
483
|
+
if (direct && direct.length)
|
|
484
|
+
return direct;
|
|
485
|
+
return (ctx.getFromChildren("endorsingOrgs") ||
|
|
486
|
+
ctx.getFromChildren("endorsingOrgs"));
|
|
487
|
+
}
|
|
488
|
+
shouldForceGatewayHydration(
|
|
489
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
490
|
+
ctx) {
|
|
491
|
+
return !!this.config.allowGatewayOverride;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* @description Creates a single record
|
|
495
|
+
* @summary Submits a transaction to create a record in the Fabric ledger
|
|
496
|
+
* @param {string} tableName - The name of the table/collection
|
|
497
|
+
* @param {string | number} id - The record identifier
|
|
498
|
+
* @param {Record<string, any>} model - The record data
|
|
499
|
+
* @param {Record<string, any>} transient - Transient data for the transaction
|
|
500
|
+
* @return {Promise<Record<string, any>>} Promise resolving to the created record
|
|
501
|
+
*/
|
|
502
|
+
async create(clazz, id, model, transient = {}, ...args) {
|
|
503
|
+
const ctxArgs = [...args];
|
|
504
|
+
const { log, ctx } = this.logCtx(ctxArgs, this.create);
|
|
505
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
506
|
+
log.verbose(`adding entry to ${tableName} table`);
|
|
507
|
+
log.debug(`pk: ${id}`);
|
|
508
|
+
const hasTransient = transient && Object.keys(transient).length > 0;
|
|
509
|
+
const needsFullPayload = hasTransient || this.shouldForceGatewayHydration(ctx);
|
|
510
|
+
const transientPayload = hasTransient ? { [tableName]: transient } : {};
|
|
511
|
+
const result = await this.submitTransaction(ctx, db_decorators_1.OperationKeys.CREATE, [this.serializer.serialize(model, clazz.name)], transientPayload, this.getEndorsingOrganizations(ctx), clazz.name);
|
|
512
|
+
const deserialized = this.serializer.deserialize(this.decode(result));
|
|
513
|
+
if (this.shouldRefreshAfterWrite(clazz, ctx, needsFullPayload, id)) {
|
|
514
|
+
return this.read(clazz, (0, id_extraction_1.extractIds)(clazz, decorator_validation_1.Model.merge(Object.assign({}, model, transient || {}), deserialized, clazz), id), ctx);
|
|
515
|
+
}
|
|
516
|
+
return deserialized;
|
|
517
|
+
}
|
|
518
|
+
async healthcheck(clazz, ...args) {
|
|
519
|
+
const { log, ctx } = this.logCtx(args, this.healthcheck);
|
|
520
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
521
|
+
log.verbose(`reading entry from ${tableName} table`);
|
|
522
|
+
const result = await this.evaluateTransaction(ctx, "healthcheck", [], undefined, undefined, clazz.name);
|
|
523
|
+
return JSON.parse(this.decode(result));
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* @description Reads a single record
|
|
527
|
+
* @summary Evaluates a transaction to read a record from the Fabric ledger
|
|
528
|
+
* @param {string} tableName - The name of the table/collection
|
|
529
|
+
* @param {string | number} id - The record identifier
|
|
530
|
+
* @return {Promise<Record<string, any>>} Promise resolving to the retrieved record
|
|
531
|
+
*/
|
|
532
|
+
async read(clazz, id, ...args) {
|
|
533
|
+
const { log, ctx } = this.logCtx(args, this.read);
|
|
534
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
535
|
+
log.verbose(`reading entry from ${tableName} table`);
|
|
536
|
+
log.debug(`pk: ${id}`);
|
|
537
|
+
const result = await this.evaluateTransaction(ctx, db_decorators_1.OperationKeys.READ, [id.toString()], undefined, undefined, clazz.name);
|
|
538
|
+
return this.serializer.deserialize(this.decode(result));
|
|
539
|
+
}
|
|
540
|
+
updatePrefix(clazz, id, model, ...args) {
|
|
541
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
542
|
+
const { ctxArgs } = this.logCtx(args, this.updatePrefix);
|
|
543
|
+
const record = {};
|
|
544
|
+
record[for_couchdb_1.CouchDBKeys.TABLE] = tableName;
|
|
545
|
+
// record[CouchDBKeys.ID] = this.generateId(tableName, id);
|
|
546
|
+
Object.assign(record, model);
|
|
547
|
+
return [clazz, id, record, ...ctxArgs];
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* @description Updates a single record
|
|
551
|
+
* @summary Submits a transaction to update a record in the Fabric ledger
|
|
552
|
+
* @param {string} tableName - The name of the table/collection
|
|
553
|
+
* @param {string | number} id - The record identifier
|
|
554
|
+
* @param {Record<string, any>} model - The updated record data
|
|
555
|
+
* @param {Record<string, any>} transient - Transient data for the transaction
|
|
556
|
+
* @return {Promise<Record<string, any>>} Promise resolving to the updated record
|
|
557
|
+
*/
|
|
558
|
+
async update(clazz, id, model, transient = {}, ...args) {
|
|
559
|
+
const ctxArgs = [...args];
|
|
560
|
+
const { log, ctx } = this.logCtx(ctxArgs, this.update);
|
|
561
|
+
log.info(`CLIENT UPDATE class : ${typeof clazz}`);
|
|
562
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
563
|
+
log.verbose(`updating entry to ${tableName} table`);
|
|
564
|
+
log.debug(`pk: ${id}`);
|
|
565
|
+
const hasTransient = transient && Object.keys(transient).length > 0;
|
|
566
|
+
const needsFullPayload = hasTransient || this.shouldForceGatewayHydration(ctx);
|
|
567
|
+
const transientPayload = hasTransient ? { [tableName]: transient } : {};
|
|
568
|
+
const result = await this.submitTransaction(ctx, db_decorators_1.OperationKeys.UPDATE, [this.serializer.serialize(model, clazz.name || clazz)], // TODO should be receving class but is receiving string
|
|
569
|
+
transientPayload, this.getEndorsingOrganizations(ctx), clazz.name);
|
|
570
|
+
const deserialized = this.serializer.deserialize(this.decode(result));
|
|
571
|
+
if (this.shouldRefreshAfterWrite(clazz, ctx, needsFullPayload, id)) {
|
|
572
|
+
return this.read(clazz, (0, id_extraction_1.extractIds)(clazz, decorator_validation_1.Model.merge(Object.assign({}, model, transient || {}), deserialized, clazz), id), ctx);
|
|
573
|
+
}
|
|
574
|
+
return deserialized;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* @description Deletes a single record
|
|
578
|
+
* @summary Submits a transaction to delete a record from the Fabric ledger
|
|
579
|
+
* @param {string} tableName - The name of the table/collection
|
|
580
|
+
* @param {string | number} id - The record identifier to delete
|
|
581
|
+
* @return {Promise<Record<string, any>>} Promise resolving to the deleted record
|
|
582
|
+
*/
|
|
583
|
+
async delete(clazz, id, ...args) {
|
|
584
|
+
const { log, ctx } = this.logCtx(args, this.delete);
|
|
585
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
586
|
+
const needsFullPayload = decorator_validation_1.Model.isTransient(clazz) || this.shouldForceGatewayHydration(ctx);
|
|
587
|
+
let result;
|
|
588
|
+
const shouldHydrate = this.shouldRefreshAfterWrite(clazz, ctx, needsFullPayload, id);
|
|
589
|
+
if (shouldHydrate) {
|
|
590
|
+
result = await this.read(clazz, id, ctx);
|
|
591
|
+
}
|
|
592
|
+
log.verbose(`deleting entry from ${tableName} table`);
|
|
593
|
+
log.debug(`pk: ${id}`);
|
|
594
|
+
const res = await this.submitTransaction(ctx, db_decorators_1.OperationKeys.DELETE, [id.toString()], undefined, this.getEndorsingOrganizations(ctx), clazz.name);
|
|
595
|
+
return shouldHydrate
|
|
596
|
+
? result
|
|
597
|
+
: this.serializer.deserialize(this.decode(res));
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* @description Executes a raw query against the Fabric ledger
|
|
601
|
+
* @summary Evaluates a transaction to perform a query using Mango Query syntax
|
|
602
|
+
* @template V - The return type
|
|
603
|
+
* @param {MangoQuery} rawInput - The Mango Query to execute
|
|
604
|
+
* @param {boolean} process - Whether to process the result
|
|
605
|
+
* @return {Promise<V>} Promise resolving to the query result
|
|
606
|
+
* @mermaid
|
|
607
|
+
* sequenceDiagram
|
|
608
|
+
* participant Client
|
|
609
|
+
* participant FabricAdapter
|
|
610
|
+
* participant Contract
|
|
611
|
+
* participant Chaincode
|
|
612
|
+
*
|
|
613
|
+
* Client->>FabricAdapter: raw(rawInput, process)
|
|
614
|
+
* FabricAdapter->>FabricAdapter: JSON.stringify(rawInput)
|
|
615
|
+
* FabricAdapter->>FabricAdapter: evaluateTransaction("query", [input])
|
|
616
|
+
* FabricAdapter->>Contract: evaluate("query", proposalOptions)
|
|
617
|
+
* Contract->>Chaincode: invoke
|
|
618
|
+
* Chaincode-->>Contract: response
|
|
619
|
+
* Contract-->>FabricAdapter: result
|
|
620
|
+
* FabricAdapter->>FabricAdapter: JSON.parse(decode(result))
|
|
621
|
+
* FabricAdapter->>FabricAdapter: Process result based on type
|
|
622
|
+
* FabricAdapter-->>Client: processed result
|
|
623
|
+
*/
|
|
624
|
+
async raw(rawInput, docsOnly = true, clazz, ...args) {
|
|
625
|
+
const { log, ctx } = this.logCtx(args, this.raw);
|
|
626
|
+
const tableName = clazz.name;
|
|
627
|
+
log.info(`Performing raw statement on table ${decorator_validation_1.Model.tableName(clazz)}`);
|
|
628
|
+
let transactionResult;
|
|
629
|
+
try {
|
|
630
|
+
transactionResult = await this.evaluateTransaction(ctx, "raw", [JSON.stringify(rawInput), docsOnly], undefined, undefined, tableName);
|
|
631
|
+
}
|
|
632
|
+
catch (e) {
|
|
633
|
+
throw this.parseError(e);
|
|
634
|
+
}
|
|
635
|
+
let result;
|
|
636
|
+
try {
|
|
637
|
+
result = JSON.parse(this.decode(transactionResult));
|
|
638
|
+
}
|
|
639
|
+
catch (e) {
|
|
640
|
+
throw new db_decorators_1.SerializationError(`Failed to process result: ${e}`);
|
|
641
|
+
}
|
|
642
|
+
const parseRecord = (record) => {
|
|
643
|
+
if (decorator_validation_1.Model.isModel(record))
|
|
644
|
+
return decorator_validation_1.Model.build(record);
|
|
645
|
+
return record;
|
|
646
|
+
};
|
|
647
|
+
if (Array.isArray(result)) {
|
|
648
|
+
if (!result.length)
|
|
649
|
+
return result;
|
|
650
|
+
const el = result[0];
|
|
651
|
+
if (decorator_validation_1.Model.isModel(el))
|
|
652
|
+
// if the first one is a model, all are models
|
|
653
|
+
return result.map((el) => decorator_validation_1.Model.build(el));
|
|
654
|
+
return result;
|
|
655
|
+
}
|
|
656
|
+
return parseRecord(result);
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* @description Executes a CouchDB view query against the Fabric chaincode
|
|
660
|
+
* @summary Evaluates a transaction to query a design document view
|
|
661
|
+
* @template R - The view response type
|
|
662
|
+
* @param {string} ddoc - Design document name
|
|
663
|
+
* @param {string} viewName - View name
|
|
664
|
+
* @param {Record<string, any>} options - View query options
|
|
665
|
+
* @param {...ContextualArgs<Context<FabricClientFlags>>} args - Optional contextual arguments
|
|
666
|
+
* @return {Promise<ViewResponse<R>>} The view response
|
|
667
|
+
*/
|
|
668
|
+
async view(ddoc, viewName, options, ...args) {
|
|
669
|
+
const { log, ctx } = this.logCtx(args, this.view);
|
|
670
|
+
log.info(`Querying view ${ddoc}/${viewName}`);
|
|
671
|
+
let transactionResult;
|
|
672
|
+
try {
|
|
673
|
+
transactionResult = await this.evaluateTransaction(ctx, "view", [ddoc, viewName, JSON.stringify(options)], undefined, undefined, undefined);
|
|
674
|
+
}
|
|
675
|
+
catch (e) {
|
|
676
|
+
throw this.parseError(e);
|
|
677
|
+
}
|
|
678
|
+
let result;
|
|
679
|
+
try {
|
|
680
|
+
result = JSON.parse(this.decode(transactionResult));
|
|
681
|
+
}
|
|
682
|
+
catch (e) {
|
|
683
|
+
throw new db_decorators_1.SerializationError(`Failed to process view result: ${e}`);
|
|
684
|
+
}
|
|
685
|
+
return result;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* @description Gets or creates a gRPC client for the Fabric peer
|
|
689
|
+
* @summary Returns a cached client or creates a new one if none exists
|
|
690
|
+
* @return {Promise<Client>} Promise resolving to the gRPC client
|
|
691
|
+
*/
|
|
692
|
+
getClient() {
|
|
693
|
+
if (!this._client)
|
|
694
|
+
this._client = FabricClientAdapter.getClient(this.config);
|
|
695
|
+
return this._client;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* @description Gets a Gateway instance for the Fabric network
|
|
699
|
+
* @summary Creates a new Gateway instance using the current client
|
|
700
|
+
* @return {Promise<Gateway>} Promise resolving to the Gateway instance
|
|
701
|
+
*/
|
|
702
|
+
async Gateway(ctx) {
|
|
703
|
+
return FabricClientAdapter.getGateway(ctx, this.config, this.client);
|
|
704
|
+
}
|
|
705
|
+
getContractName(className) {
|
|
706
|
+
if (!className)
|
|
707
|
+
return undefined;
|
|
708
|
+
return `${className}Contract`;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* @description Gets a Contract instance for the Fabric chaincode
|
|
712
|
+
* @summary Creates a new Contract instance using the current Gateway
|
|
713
|
+
* @return {Promise<Contrakt>} Promise resolving to the Contract instance
|
|
714
|
+
*/
|
|
715
|
+
async Contract(ctx, contractName) {
|
|
716
|
+
return FabricClientAdapter.getContract(await this.Gateway(ctx), this.config, contractName);
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* @description Executes a transaction on the Fabric network
|
|
720
|
+
* @summary Submits or evaluates a transaction on the Fabric chaincode
|
|
721
|
+
* @param {string} api - The chaincode function to call
|
|
722
|
+
* @param {boolean} submit - Whether to submit (true) or evaluate (false) the transaction
|
|
723
|
+
* @param {any[]} [args] - Arguments to pass to the chaincode function
|
|
724
|
+
* @param {Record<string, string>} [transientData] - Transient data for the transaction
|
|
725
|
+
* @param {Array<string>} [endorsingOrganizations] - Organizations that must endorse the transaction
|
|
726
|
+
* @return {Promise<Uint8Array>} Promise resolving to the transaction result
|
|
727
|
+
* @mermaid
|
|
728
|
+
* sequenceDiagram
|
|
729
|
+
* participant FabricAdapter
|
|
730
|
+
* participant Gateway
|
|
731
|
+
* participant Contract
|
|
732
|
+
* participant Chaincode
|
|
733
|
+
*
|
|
734
|
+
* FabricAdapter->>Gateway: connect()
|
|
735
|
+
* FabricAdapter->>Contract: getContract()
|
|
736
|
+
* alt submit transaction
|
|
737
|
+
* FabricAdapter->>Contract: submit(api, proposalOptions)
|
|
738
|
+
* else evaluate transaction
|
|
739
|
+
* FabricAdapter->>Contract: evaluate(api, proposalOptions)
|
|
740
|
+
* end
|
|
741
|
+
* Contract->>Chaincode: invoke
|
|
742
|
+
* Chaincode-->>Contract: response
|
|
743
|
+
* Contract-->>FabricAdapter: result
|
|
744
|
+
* FabricAdapter->>Gateway: close()
|
|
745
|
+
*/
|
|
746
|
+
async transaction(ctx, api, submit = true, args, transientData = {}, endorsingOrganizations, className) {
|
|
747
|
+
const log = this.log.for(this.transaction);
|
|
748
|
+
const gateway = await this.Gateway(ctx);
|
|
749
|
+
try {
|
|
750
|
+
const contract = await this.Contract(ctx, this.getContractName(className));
|
|
751
|
+
log.verbose(`${submit ? "Submit" : "Evaluate"}ting transaction ${this.getContractName(className) || this.config.contractName}.${api}`);
|
|
752
|
+
log.debug(`args: ${args?.map((a) => a.toString()).join("\n") || "none"}`);
|
|
753
|
+
const method = submit ? contract.submit : contract.evaluate;
|
|
754
|
+
endorsingOrganizations = endorsingOrganizations?.length
|
|
755
|
+
? endorsingOrganizations
|
|
756
|
+
: undefined;
|
|
757
|
+
const proposalOptions = {
|
|
758
|
+
arguments: args || [],
|
|
759
|
+
transientData: Object.entries(transientData).reduce((acc, [key, val]) => {
|
|
760
|
+
acc[key] = JSON.stringify(val);
|
|
761
|
+
return acc;
|
|
762
|
+
}, {}),
|
|
763
|
+
endorsingOrganizations: ctx.getOrUndefined("allowManualEndorsingOrgs")
|
|
764
|
+
? endorsingOrganizations || undefined
|
|
765
|
+
: undefined, // mspId list
|
|
766
|
+
};
|
|
767
|
+
return await method.call(contract, api, proposalOptions);
|
|
768
|
+
}
|
|
769
|
+
catch (e) {
|
|
770
|
+
throw this.parseError(e);
|
|
771
|
+
}
|
|
772
|
+
finally {
|
|
773
|
+
this.log.debug(`Closing ${this.config.mspId} gateway connection`);
|
|
774
|
+
gateway.close();
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
shouldUseLegacyGateway(ctx) {
|
|
778
|
+
return !!ctx.getOrUndefined("legacy") && !!this.config.allowGatewayOverride;
|
|
779
|
+
}
|
|
780
|
+
prepareLegacyArgs(args) {
|
|
781
|
+
return (args || []).map((arg) => typeof arg === "string" ? arg : JSON.stringify(arg));
|
|
782
|
+
}
|
|
783
|
+
buildLegacyTransient(transientData) {
|
|
784
|
+
if (!transientData)
|
|
785
|
+
return undefined;
|
|
786
|
+
const entries = Object.entries(transientData);
|
|
787
|
+
if (!entries.length)
|
|
788
|
+
return undefined;
|
|
789
|
+
const map = {};
|
|
790
|
+
for (const [key, value] of entries) {
|
|
791
|
+
map[key] = Buffer.from(JSON.stringify(value));
|
|
792
|
+
}
|
|
793
|
+
return map;
|
|
794
|
+
}
|
|
795
|
+
resolveLegacyMspCount() {
|
|
796
|
+
const configured = this.config.legacyMspCount ?? 1;
|
|
797
|
+
const parsed = Number(configured);
|
|
798
|
+
if (!Number.isFinite(parsed) || parsed < 1)
|
|
799
|
+
return 1;
|
|
800
|
+
return Math.floor(parsed);
|
|
801
|
+
}
|
|
802
|
+
pickLegacyCandidates(candidates, limit) {
|
|
803
|
+
if (!candidates.length || limit <= 0)
|
|
804
|
+
return [];
|
|
805
|
+
const available = [...candidates];
|
|
806
|
+
const target = Math.min(limit, available.length);
|
|
807
|
+
const picked = [];
|
|
808
|
+
while (picked.length < target && available.length) {
|
|
809
|
+
const idx = Math.floor(Math.random() * available.length);
|
|
810
|
+
const [selection] = available.splice(idx, 1);
|
|
811
|
+
if (selection) {
|
|
812
|
+
picked.push(selection);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return picked;
|
|
816
|
+
}
|
|
817
|
+
buildLegacyPeerConfigs(ctx) {
|
|
818
|
+
const peers = [
|
|
819
|
+
{
|
|
820
|
+
mspId: this.config.mspId,
|
|
821
|
+
peerEndpoint: this.config.peerEndpoint,
|
|
822
|
+
peerHostAlias: this.config.peerHostAlias,
|
|
823
|
+
tlsCert: this.config.tlsCert,
|
|
824
|
+
},
|
|
825
|
+
];
|
|
826
|
+
let endorsingOrgs = this.getEndorsingOrganizations(ctx) || [];
|
|
827
|
+
endorsingOrgs = Array.isArray(endorsingOrgs)
|
|
828
|
+
? endorsingOrgs
|
|
829
|
+
: [endorsingOrgs];
|
|
830
|
+
const endorsers = endorsingOrgs.filter((org) => Boolean(org)) || [];
|
|
831
|
+
const extras = endorsers.filter((org) => org !== this.config.mspId);
|
|
832
|
+
if (!extras.length)
|
|
833
|
+
return peers;
|
|
834
|
+
const map = this.config.mspMap;
|
|
835
|
+
const legacyCount = this.resolveLegacyMspCount();
|
|
836
|
+
for (const msp of extras) {
|
|
837
|
+
const candidates = map?.[msp];
|
|
838
|
+
if (!candidates?.length) {
|
|
839
|
+
throw new core_1.UnsupportedError(`No peer mapping available for MSP ${msp}. Provide it via config.mspMap`);
|
|
840
|
+
}
|
|
841
|
+
const selections = this.pickLegacyCandidates(candidates, legacyCount);
|
|
842
|
+
if (!selections.length) {
|
|
843
|
+
throw new core_1.UnsupportedError(`No valid peer mapping available for MSP ${msp}. Provide it via config.mspMap`);
|
|
844
|
+
}
|
|
845
|
+
for (const choice of selections) {
|
|
846
|
+
if (!choice.endpoint) {
|
|
847
|
+
throw new core_1.UnsupportedError(`Invalid peer mapping for MSP ${msp}: missing endpoint`);
|
|
848
|
+
}
|
|
849
|
+
peers.push({
|
|
850
|
+
mspId: msp,
|
|
851
|
+
peerEndpoint: choice.endpoint,
|
|
852
|
+
peerHostAlias: choice.alias,
|
|
853
|
+
tlsCert: choice.tlsCert || this.config.tlsCert,
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return peers;
|
|
858
|
+
}
|
|
859
|
+
async submitLegacyWithExplicitEndorsers(ctx, fcn, args, transientMap, peerConfigs, className) {
|
|
860
|
+
const log = this.log.for(this.submitLegacyWithExplicitEndorsers);
|
|
861
|
+
const peers = this.normalizeLegacyPeers(peerConfigs);
|
|
862
|
+
const identityMaterial = await this.resolveLegacyIdentityMaterial();
|
|
863
|
+
const wallet = await fabric_network_1.Wallets.newInMemoryWallet();
|
|
864
|
+
const identityLabel = `${this.config.mspId}-legacy`;
|
|
865
|
+
await wallet.put(identityLabel, {
|
|
866
|
+
credentials: {
|
|
867
|
+
certificate: identityMaterial.certificate,
|
|
868
|
+
privateKey: identityMaterial.privateKey,
|
|
869
|
+
},
|
|
870
|
+
mspId: this.config.mspId,
|
|
871
|
+
type: "X.509",
|
|
872
|
+
});
|
|
873
|
+
const connectionProfile = await this.buildLegacyConnectionProfile(peers);
|
|
874
|
+
const gateway = new fabric_network_1.Gateway();
|
|
875
|
+
try {
|
|
876
|
+
await gateway.connect(connectionProfile, {
|
|
877
|
+
identity: identityLabel,
|
|
878
|
+
wallet,
|
|
879
|
+
discovery: {
|
|
880
|
+
enabled: true,
|
|
881
|
+
asLocalhost: this.shouldTreatPeersAsLocalhost(peers),
|
|
882
|
+
},
|
|
883
|
+
tlsInfo: {
|
|
884
|
+
certificate: identityMaterial.certificate,
|
|
885
|
+
key: identityMaterial.privateKey,
|
|
886
|
+
},
|
|
887
|
+
});
|
|
888
|
+
const network = await gateway.getNetwork(this.config.channel);
|
|
889
|
+
const contract = network.getContract(this.config.chaincodeName, this.getContractName(className));
|
|
890
|
+
const transaction = contract.createTransaction(fcn);
|
|
891
|
+
if (transientMap) {
|
|
892
|
+
transaction.setTransient(transientMap);
|
|
893
|
+
}
|
|
894
|
+
const endorsers = peers
|
|
895
|
+
.map((peer) => network.getChannel().getEndorser(peer.name))
|
|
896
|
+
.filter((endorser) => Boolean(endorser));
|
|
897
|
+
if (endorsers.length) {
|
|
898
|
+
transaction.setEndorsingPeers(endorsers);
|
|
899
|
+
}
|
|
900
|
+
log.verbose(`Legacy submitting ${this.getContractName(className) || this.config.contractName}.${fcn} via peers ${peers.map((p) => p.peerEndpoint).join(", ")}`);
|
|
901
|
+
const result = await transaction.submit(...args);
|
|
902
|
+
return Uint8Array.from(result);
|
|
903
|
+
}
|
|
904
|
+
catch (e) {
|
|
905
|
+
throw this.parseError(e);
|
|
906
|
+
}
|
|
907
|
+
finally {
|
|
908
|
+
gateway.disconnect();
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
normalizeLegacyPeers(peers) {
|
|
912
|
+
const deduped = new Map();
|
|
913
|
+
const addPeer = (peer) => {
|
|
914
|
+
const key = `${peer.peerEndpoint}|${peer.peerHostAlias || ""}`;
|
|
915
|
+
if (deduped.has(key))
|
|
916
|
+
return;
|
|
917
|
+
const name = `peer-${peer.mspId}-${deduped.size}`;
|
|
918
|
+
deduped.set(key, {
|
|
919
|
+
...peer,
|
|
920
|
+
name,
|
|
921
|
+
});
|
|
922
|
+
};
|
|
923
|
+
peers.forEach(addPeer);
|
|
924
|
+
addPeer({
|
|
925
|
+
mspId: this.config.mspId,
|
|
926
|
+
peerEndpoint: this.config.peerEndpoint,
|
|
927
|
+
peerHostAlias: this.config.peerHostAlias,
|
|
928
|
+
});
|
|
929
|
+
return Array.from(deduped.values());
|
|
930
|
+
}
|
|
931
|
+
async resolveLegacyIdentityMaterial() {
|
|
932
|
+
const certificate = await this.readPemInput(this.config.certCertOrDirectoryPath);
|
|
933
|
+
const privateKey = await this.readPemInput(this.config.keyCertOrDirectoryPath);
|
|
934
|
+
return { certificate, privateKey };
|
|
935
|
+
}
|
|
936
|
+
async buildLegacyConnectionProfile(peers) {
|
|
937
|
+
const peerEntries = {};
|
|
938
|
+
const channelPeers = {};
|
|
939
|
+
const orgs = {};
|
|
940
|
+
for (const peer of peers) {
|
|
941
|
+
const tlsPem = await this.readPemInput(peer.tlsCert || this.config.tlsCert);
|
|
942
|
+
const hostname = peer.peerHostAlias || this.extractHost(peer.peerEndpoint);
|
|
943
|
+
peerEntries[peer.name] = {
|
|
944
|
+
url: this.ensureGrpcUrl(peer.peerEndpoint),
|
|
945
|
+
tlsCACerts: { pem: tlsPem },
|
|
946
|
+
grpcOptions: {
|
|
947
|
+
"ssl-target-name-override": hostname,
|
|
948
|
+
hostnameOverride: hostname,
|
|
949
|
+
},
|
|
950
|
+
};
|
|
951
|
+
channelPeers[peer.name] = {
|
|
952
|
+
endorsingPeer: true,
|
|
953
|
+
chaincodeQuery: true,
|
|
954
|
+
ledgerQuery: true,
|
|
955
|
+
eventSource: true,
|
|
956
|
+
};
|
|
957
|
+
orgs[peer.mspId] = orgs[peer.mspId] || {
|
|
958
|
+
mspid: peer.mspId,
|
|
959
|
+
peers: [],
|
|
960
|
+
};
|
|
961
|
+
orgs[peer.mspId].peers.push(peer.name);
|
|
962
|
+
}
|
|
963
|
+
return {
|
|
964
|
+
name: "legacy-manual",
|
|
965
|
+
version: "1.0.0",
|
|
966
|
+
client: {
|
|
967
|
+
organization: this.config.mspId,
|
|
968
|
+
},
|
|
969
|
+
organizations: orgs,
|
|
970
|
+
peers: peerEntries,
|
|
971
|
+
orderers: {},
|
|
972
|
+
channels: {
|
|
973
|
+
[this.config.channel]: {
|
|
974
|
+
peers: channelPeers,
|
|
975
|
+
},
|
|
976
|
+
},
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
shouldTreatPeersAsLocalhost(peers) {
|
|
980
|
+
return peers.every((peer) => this.isLocalEndpoint(peer.peerEndpoint));
|
|
981
|
+
}
|
|
982
|
+
isLocalEndpoint(endpoint) {
|
|
983
|
+
const host = this.extractHost(endpoint).toLowerCase();
|
|
984
|
+
return host === "localhost" || host === "127.0.0.1";
|
|
985
|
+
}
|
|
986
|
+
extractHost(endpoint) {
|
|
987
|
+
const sanitized = endpoint.replace(/^grpcs?:\/\//, "");
|
|
988
|
+
return sanitized.split(":")[0];
|
|
989
|
+
}
|
|
990
|
+
ensureGrpcUrl(endpoint) {
|
|
991
|
+
if (/^grpcs?:\/\//i.test(endpoint))
|
|
992
|
+
return endpoint;
|
|
993
|
+
return `grpcs://${endpoint}`;
|
|
994
|
+
}
|
|
995
|
+
async readPemInput(source) {
|
|
996
|
+
if (!source)
|
|
997
|
+
throw new db_decorators_1.InternalError("Missing certificate or key material");
|
|
998
|
+
if (Buffer.isBuffer(source))
|
|
999
|
+
return source.toString("utf8");
|
|
1000
|
+
const trimmed = source.trim();
|
|
1001
|
+
if (/-----BEGIN [A-Z ]+-----/.test(trimmed))
|
|
1002
|
+
return trimmed;
|
|
1003
|
+
const stats = await fs_1.default.promises.stat(source).catch(() => undefined);
|
|
1004
|
+
if (stats?.isDirectory()) {
|
|
1005
|
+
return await (0, fabric_fs_1.getFirstDirFileNameContent)(source);
|
|
1006
|
+
}
|
|
1007
|
+
return (await (0, fabric_fs_1.readFile)(source)).toString();
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* @description Parses an error into a BaseError
|
|
1011
|
+
* @summary Converts any error into a standardized BaseError
|
|
1012
|
+
* @param {Error | string} err - The error to parse
|
|
1013
|
+
* @param {string} [reason] - Optional reason for the error
|
|
1014
|
+
* @return {BaseError} The parsed error
|
|
1015
|
+
*/
|
|
1016
|
+
parseError(err) {
|
|
1017
|
+
return FabricClientAdapter.parseError(err);
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* @description Submits a transaction to the Fabric network
|
|
1021
|
+
* @summary Executes a transaction that modifies the ledger state
|
|
1022
|
+
* @param {string} api - The chaincode function to call
|
|
1023
|
+
* @param {any[]} [args] - Arguments to pass to the chaincode function
|
|
1024
|
+
* @param {Record<string, string>} [transientData] - Transient data for the transaction
|
|
1025
|
+
* @param {Array<string>} [endorsingOrganizations] - Organizations that must endorse the transaction
|
|
1026
|
+
* @return {Promise<Uint8Array>} Promise resolving to the transaction result
|
|
1027
|
+
*/
|
|
1028
|
+
async submitTransaction(ctx, api, args, transientData, endorsingOrganizations, className) {
|
|
1029
|
+
if (this.shouldUseLegacyGateway(ctx)) {
|
|
1030
|
+
const legacyArgs = this.prepareLegacyArgs(args);
|
|
1031
|
+
const transientMap = this.buildLegacyTransient(transientData);
|
|
1032
|
+
const peerConfigs = this.buildLegacyPeerConfigs(ctx);
|
|
1033
|
+
return this.submitLegacyWithExplicitEndorsers(ctx, api, legacyArgs, transientMap, peerConfigs, className);
|
|
1034
|
+
}
|
|
1035
|
+
return this.transaction(ctx, api, true, args, transientData, endorsingOrganizations, className);
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* @description Evaluates a transaction on the Fabric network
|
|
1039
|
+
* @summary Executes a transaction that does not modify the ledger state
|
|
1040
|
+
* @param {string} api - The chaincode function to call
|
|
1041
|
+
* @param {any[]} [args] - Arguments to pass to the chaincode function
|
|
1042
|
+
* @param {Record<string, string>} [transientData] - Transient data for the transaction
|
|
1043
|
+
* @param {Array<string>} [endorsingOrganizations] - Organizations that must endorse the transaction
|
|
1044
|
+
* @return {Promise<Uint8Array>} Promise resolving to the transaction result
|
|
1045
|
+
*/
|
|
1046
|
+
async evaluateTransaction(ctx, api, args, transientData, endorsingOrganizations, className) {
|
|
1047
|
+
return this.transaction(ctx, api, false, args, transientData, endorsingOrganizations, className);
|
|
1048
|
+
}
|
|
1049
|
+
async migrate(reference, ...args) {
|
|
1050
|
+
const { ctxArgs } = (await this.logCtx([args], core_1.PersistenceKeys.MIGRATION, true)).for(this.migrate);
|
|
1051
|
+
return this.submitTransaction(ctxArgs[0], "migrate", [reference, args], undefined, undefined);
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* @description Shuts down the connection to the Fabric network
|
|
1055
|
+
* @summary Closes the active dispatch (which in turn closes any gateway
|
|
1056
|
+
* event subscription) via the base class, then closes the gRPC client.
|
|
1057
|
+
* Works correctly regardless of whether `syntheticEvents` is enabled.
|
|
1058
|
+
* @return {Promise<void>} Promise that resolves when all connections are closed
|
|
1059
|
+
*/
|
|
1060
|
+
async shutdown(...args) {
|
|
1061
|
+
// Base class handles dispatch.close() internally.
|
|
1062
|
+
await super.shutdown(...args);
|
|
1063
|
+
if (this.client) {
|
|
1064
|
+
this.log.verbose(`Closing ${this.config.mspId} gateway client`);
|
|
1065
|
+
this.client.close();
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* @description Gets a Contract instance from a Gateway
|
|
1070
|
+
* @summary Retrieves a chaincode contract from the specified network
|
|
1071
|
+
* @param {Gateway} gateway - The Gateway instance
|
|
1072
|
+
* @param {PeerConfig} config - The peer configuration
|
|
1073
|
+
* @return {Contrakt} The Contract instance
|
|
1074
|
+
*/
|
|
1075
|
+
static getContract(gateway, config, contractName) {
|
|
1076
|
+
const log = this.log.for(this.getContract);
|
|
1077
|
+
const network = this.getNetwork(gateway, config.channel);
|
|
1078
|
+
let contract;
|
|
1079
|
+
try {
|
|
1080
|
+
log.debug(`Retrieving chaincode ${config.chaincodeName} contract ${contractName || config.contractName} from network ${config.channel}`);
|
|
1081
|
+
contractName = contractName ? contractName : config.contractName;
|
|
1082
|
+
contract = network.getContract(config.chaincodeName, contractName);
|
|
1083
|
+
}
|
|
1084
|
+
catch (e) {
|
|
1085
|
+
throw this.parseError(e);
|
|
1086
|
+
}
|
|
1087
|
+
return contract;
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* @description Gets a Network instance from a Gateway
|
|
1091
|
+
* @summary Connects to a specific channel on the Fabric network
|
|
1092
|
+
* @param {Gateway} gateway - The Gateway instance
|
|
1093
|
+
* @param {string} channelName - The name of the channel to connect to
|
|
1094
|
+
* @return {Network} The Network instance
|
|
1095
|
+
*/
|
|
1096
|
+
static getNetwork(gateway, channelName) {
|
|
1097
|
+
const log = logging_1.Logging.for(this.getNetwork);
|
|
1098
|
+
let network;
|
|
1099
|
+
try {
|
|
1100
|
+
log.debug(`Connecting to channel ${channelName}`);
|
|
1101
|
+
network = gateway.getNetwork(channelName);
|
|
1102
|
+
}
|
|
1103
|
+
catch (e) {
|
|
1104
|
+
throw this.parseError(e);
|
|
1105
|
+
}
|
|
1106
|
+
return network;
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* @description Gets a Gateway instance for connecting to the Fabric network
|
|
1110
|
+
* @summary Creates a Gateway using the provided configuration and client
|
|
1111
|
+
* @param {PeerConfig} config - The peer configuration
|
|
1112
|
+
* @param {Client} [client] - Optional gRPC client, will be created if not provided
|
|
1113
|
+
* @return {Promise<Gateway>} Promise resolving to the Gateway instance
|
|
1114
|
+
*/
|
|
1115
|
+
static async getGateway(ctx, config, client) {
|
|
1116
|
+
return (await this.getConnection(client || (await this.getClient(config)), config, ctx));
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* @description Creates a gRPC client for connecting to a Fabric peer
|
|
1120
|
+
* @summary Initializes a client with TLS credentials for secure communication
|
|
1121
|
+
* @param {PeerConfig} config - The peer configuration
|
|
1122
|
+
* @return {Client} Promise resolving to the gRPC client
|
|
1123
|
+
*/
|
|
1124
|
+
static getClient(config) {
|
|
1125
|
+
const log = this.log.for(this.getClient);
|
|
1126
|
+
log.debug(`generating TLS credentials for msp ${config.mspId}`);
|
|
1127
|
+
let pathOrCert = config.tlsCert;
|
|
1128
|
+
if (typeof pathOrCert === "string") {
|
|
1129
|
+
if (pathOrCert.match(/-----BEGIN (CERTIFICATE|KEY|PRIVATE KEY)-----.+?-----END \1-----$/gms)) {
|
|
1130
|
+
pathOrCert = Buffer.from(pathOrCert, "utf8");
|
|
1131
|
+
}
|
|
1132
|
+
else {
|
|
1133
|
+
try {
|
|
1134
|
+
pathOrCert = Buffer.from(fs_1.default.readFileSync(pathOrCert, "utf8"));
|
|
1135
|
+
}
|
|
1136
|
+
catch (e) {
|
|
1137
|
+
throw new db_decorators_1.InternalError(`Failed to read the tls certificate from ${pathOrCert}: ${e}`);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
const tlsCredentials = grpc.credentials.createSsl(pathOrCert);
|
|
1142
|
+
log.debug(`generating Gateway Client for url ${config.peerEndpoint}`);
|
|
1143
|
+
return new grpc_js_1.Client(config.peerEndpoint, tlsCredentials, {
|
|
1144
|
+
"grpc.max_receive_message_length": (config.sizeLimit || 15) * 1024 * 1024,
|
|
1145
|
+
"grpc.max_send_message_length": (config.sizeLimit || 15) * 1024 * 1024,
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* @description Establishes a connection to the Fabric network
|
|
1150
|
+
* @summary Creates a Gateway connection with identity and signer
|
|
1151
|
+
* @param {Client} client - The gRPC client
|
|
1152
|
+
* @param {PeerConfig} config - The peer configuration
|
|
1153
|
+
* @return {Promise<Gateway>} Promise resolving to the connected Gateway
|
|
1154
|
+
* @mermaid
|
|
1155
|
+
* sequenceDiagram
|
|
1156
|
+
* participant Caller
|
|
1157
|
+
* participant FabricAdapter
|
|
1158
|
+
* participant Identity
|
|
1159
|
+
* participant Signer
|
|
1160
|
+
* participant Gateway
|
|
1161
|
+
*
|
|
1162
|
+
* Caller->>FabricAdapter: getConnection(client, config)
|
|
1163
|
+
* FabricAdapter->>Identity: getIdentity(mspId, certDirectoryPath)
|
|
1164
|
+
* Identity-->>FabricAdapter: identity
|
|
1165
|
+
* FabricAdapter->>Signer: getSigner(keyDirectoryPath)
|
|
1166
|
+
* Signer-->>FabricAdapter: signer
|
|
1167
|
+
* FabricAdapter->>FabricAdapter: Create ConnectOptions
|
|
1168
|
+
* FabricAdapter->>Gateway: connect(options)
|
|
1169
|
+
* Gateway-->>FabricAdapter: gateway
|
|
1170
|
+
* FabricAdapter-->>Caller: gateway
|
|
1171
|
+
*/
|
|
1172
|
+
static async getConnection(client, config, ctx) {
|
|
1173
|
+
const log = logging_1.Logging.for(this.getConnection);
|
|
1174
|
+
log.debug(`Retrieving Peer Identity for ${config.mspId} under ${config.certCertOrDirectoryPath}`);
|
|
1175
|
+
const identity = await (0, fabric_fs_1.getIdentity)(config.mspId, config.certCertOrDirectoryPath);
|
|
1176
|
+
try {
|
|
1177
|
+
log.debug(`preparing transaction signer for ${crypto_1.CryptoUtils.fabricIdFromCertificate(identity.credentials.toString())}`);
|
|
1178
|
+
}
|
|
1179
|
+
catch (e) {
|
|
1180
|
+
log.error(`Failed to extract Fabric ID from certificate`, e);
|
|
1181
|
+
}
|
|
1182
|
+
let signer;
|
|
1183
|
+
const close = () => { };
|
|
1184
|
+
if (!config.hsm) {
|
|
1185
|
+
signer = await (0, fabric_fs_1.getSigner)(config.keyCertOrDirectoryPath);
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
// const hsm = new HSMSignerFactoryCustom(config.hsm.library);
|
|
1189
|
+
// const identifier = hsm.getSKIFromCertificatePath(
|
|
1190
|
+
// config.certCertOrDirectoryPath as any
|
|
1191
|
+
// );
|
|
1192
|
+
// const pkcs11Signer = hsm.newSigner({
|
|
1193
|
+
// label: config.hsm.tokenLabel as string,
|
|
1194
|
+
// pin: String(config.hsm.pin) as string,
|
|
1195
|
+
// identifier: identifier,
|
|
1196
|
+
// // userType: 1 /*CKU_USER */,
|
|
1197
|
+
// });
|
|
1198
|
+
// signer = pkcs11Signer.signer;
|
|
1199
|
+
// close = pkcs11Signer.close;
|
|
1200
|
+
throw new core_1.UnsupportedError("HSM NOT IMPLEMENTED");
|
|
1201
|
+
}
|
|
1202
|
+
const options = {
|
|
1203
|
+
client,
|
|
1204
|
+
identity: identity,
|
|
1205
|
+
signer: signer,
|
|
1206
|
+
// Default timeouts for different gRPC calls
|
|
1207
|
+
evaluateOptions: () => {
|
|
1208
|
+
return { deadline: Date.now() + 1000 * ctx.get("evaluateTimeout") }; // defaults to 5 seconds
|
|
1209
|
+
},
|
|
1210
|
+
endorseOptions: () => {
|
|
1211
|
+
return { deadline: Date.now() + 1000 * ctx.get("endorseTimeout") }; // defaults to 15 seconds
|
|
1212
|
+
},
|
|
1213
|
+
submitOptions: () => {
|
|
1214
|
+
return { deadline: Date.now() + 1000 * ctx.get("submitTimeout") }; // defaults to 5 seconds
|
|
1215
|
+
},
|
|
1216
|
+
commitStatusOptions: () => {
|
|
1217
|
+
return { deadline: Date.now() + 1000 * ctx.get("commitTimeout") }; // defaults to 1 minute
|
|
1218
|
+
},
|
|
1219
|
+
};
|
|
1220
|
+
log.debug(`Connecting to ${config.mspId}`);
|
|
1221
|
+
const gateway = (0, fabric_gateway_1.connect)(options);
|
|
1222
|
+
// TODO: replace?
|
|
1223
|
+
if (config.hsm) {
|
|
1224
|
+
gateway.close = new Proxy(gateway.close, {
|
|
1225
|
+
apply(target, thisArg, argArray) {
|
|
1226
|
+
Reflect.apply(target, thisArg, argArray);
|
|
1227
|
+
close();
|
|
1228
|
+
},
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
return gateway;
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* @description Creates a new Dispatch instance for the Fabric client.
|
|
1235
|
+
* @summary This function is responsible for creating a new FabricClientDispatch instance that can be used to interact with the Fabric network.
|
|
1236
|
+
* @returns {Dispatch} A new Dispatch instance configured for the Fabric client.
|
|
1237
|
+
* @remarks The Dispatch instance is used to encapsulate the logic for interacting with the Fabric network, such as submitting transactions or querying data.
|
|
1238
|
+
* @example
|
|
1239
|
+
* const fabricDispatch = fabricClientAdapter.Dispatch();
|
|
1240
|
+
* fabricDispatch.submitTransaction('createProduct', { name: 'Product A', price: 100 });
|
|
1241
|
+
*/
|
|
1242
|
+
Dispatch() {
|
|
1243
|
+
return new FabricClientAdapter["_baseDispatch"](this.client);
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* @description Parses an error into a BaseError
|
|
1247
|
+
* @summary Converts any error into a standardized BaseError using the parent class implementation
|
|
1248
|
+
* @param {Error | string} err - The error to parse
|
|
1249
|
+
* @param {string} [reason] - Optional reason for the error
|
|
1250
|
+
* @return {BaseError} The parsed error
|
|
1251
|
+
*/
|
|
1252
|
+
static parseError(err) {
|
|
1253
|
+
// if (
|
|
1254
|
+
// MISSING_PRIVATE_DATA_REGEX.test(
|
|
1255
|
+
// typeof err === "string" ? err : err.message
|
|
1256
|
+
// )
|
|
1257
|
+
// )
|
|
1258
|
+
// return new UnauthorizedPrivateDataAccess(err) as E;
|
|
1259
|
+
let msg = typeof err === "string" ? err : err.message;
|
|
1260
|
+
if (err instanceof fabric_gateway_1.GatewayError && err.details.length && err.code === 10) {
|
|
1261
|
+
msg = `${err.details[0].message}`;
|
|
1262
|
+
}
|
|
1263
|
+
if (err instanceof fabric_gateway_1.EndorseError &&
|
|
1264
|
+
err.details.length &&
|
|
1265
|
+
err.code === 10 &&
|
|
1266
|
+
err.details[0].message?.includes(core_1.UnsupportedError.name)) {
|
|
1267
|
+
msg = `${err.details[0].message}`;
|
|
1268
|
+
}
|
|
1269
|
+
if (msg.includes("MVCC_READ_CONFLICT"))
|
|
1270
|
+
return new errors_1.MvccReadConflictError(err);
|
|
1271
|
+
if (msg.includes("DEADLINE_EXCEEDED"))
|
|
1272
|
+
return new errors_1.TransactionTimeoutError(err);
|
|
1273
|
+
if (msg.includes("ENDORSEMENT_POLICY_FAILURE"))
|
|
1274
|
+
return new errors_1.EndorsementPolicyError(err);
|
|
1275
|
+
if (msg.includes("PHANTOM_READ_CONFLICT"))
|
|
1276
|
+
return new errors_1.PhantomReadConflictError(err);
|
|
1277
|
+
if (err instanceof Error && err.code) {
|
|
1278
|
+
switch (err.code) {
|
|
1279
|
+
case 9:
|
|
1280
|
+
return new errors_1.EndorsementError(err);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
if (msg.includes(db_decorators_1.ValidationError.name))
|
|
1284
|
+
return new db_decorators_1.ValidationError(err);
|
|
1285
|
+
if (msg.includes(db_decorators_1.NotFoundError.name))
|
|
1286
|
+
return new db_decorators_1.NotFoundError(err);
|
|
1287
|
+
if (msg.includes(db_decorators_1.ConflictError.name))
|
|
1288
|
+
return new db_decorators_1.ConflictError(err);
|
|
1289
|
+
if (msg.includes(db_decorators_1.BadRequestError.name))
|
|
1290
|
+
return new db_decorators_1.BadRequestError(err);
|
|
1291
|
+
if (msg.includes(core_1.QueryError.name))
|
|
1292
|
+
return new core_1.QueryError(err);
|
|
1293
|
+
if (msg.includes(core_1.PagingError.name))
|
|
1294
|
+
return new core_1.PagingError(err);
|
|
1295
|
+
if (msg.includes(core_1.UnsupportedError.name))
|
|
1296
|
+
return new core_1.UnsupportedError(err);
|
|
1297
|
+
if (msg.includes(core_1.MigrationError.name))
|
|
1298
|
+
return new core_1.MigrationError(err);
|
|
1299
|
+
if (msg.includes(core_1.ObserverError.name))
|
|
1300
|
+
return new core_1.ObserverError(err);
|
|
1301
|
+
if (msg.includes(core_1.AuthorizationError.name))
|
|
1302
|
+
return new core_1.AuthorizationError(err);
|
|
1303
|
+
if (msg.includes(core_1.ForbiddenError.name))
|
|
1304
|
+
return new core_1.ForbiddenError(err);
|
|
1305
|
+
if (msg.includes(core_1.ConnectionError.name))
|
|
1306
|
+
return new core_1.ConnectionError(err);
|
|
1307
|
+
if (msg.includes(db_decorators_1.SerializationError.name))
|
|
1308
|
+
return new db_decorators_1.SerializationError(err);
|
|
1309
|
+
return new db_decorators_1.InternalError(err);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
exports.FabricClientAdapter = FabricClientAdapter;
|
|
1313
|
+
__decorate([
|
|
1314
|
+
(0, logging_1.debug)(),
|
|
1315
|
+
(0, logging_1.final)(),
|
|
1316
|
+
__metadata("design:type", Function),
|
|
1317
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object, core_1.Context]),
|
|
1318
|
+
__metadata("design:returntype", Promise)
|
|
1319
|
+
], FabricClientAdapter.prototype, "create", null);
|
|
1320
|
+
__decorate([
|
|
1321
|
+
(0, logging_1.debug)(),
|
|
1322
|
+
(0, logging_1.final)(),
|
|
1323
|
+
__metadata("design:type", Function),
|
|
1324
|
+
__metadata("design:paramtypes", [Object, core_1.Context]),
|
|
1325
|
+
__metadata("design:returntype", Promise)
|
|
1326
|
+
], FabricClientAdapter.prototype, "healthcheck", null);
|
|
1327
|
+
__decorate([
|
|
1328
|
+
(0, logging_1.debug)(),
|
|
1329
|
+
(0, logging_1.final)(),
|
|
1330
|
+
__metadata("design:type", Function),
|
|
1331
|
+
__metadata("design:paramtypes", [Object, Object, core_1.Context]),
|
|
1332
|
+
__metadata("design:returntype", Promise)
|
|
1333
|
+
], FabricClientAdapter.prototype, "read", null);
|
|
1334
|
+
__decorate([
|
|
1335
|
+
(0, logging_1.debug)(),
|
|
1336
|
+
(0, logging_1.final)(),
|
|
1337
|
+
__metadata("design:type", Function),
|
|
1338
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object, core_1.Context]),
|
|
1339
|
+
__metadata("design:returntype", Promise)
|
|
1340
|
+
], FabricClientAdapter.prototype, "update", null);
|
|
1341
|
+
__decorate([
|
|
1342
|
+
(0, logging_1.debug)(),
|
|
1343
|
+
(0, logging_1.final)(),
|
|
1344
|
+
__metadata("design:type", Function),
|
|
1345
|
+
__metadata("design:paramtypes", [Object, Object, core_1.Context]),
|
|
1346
|
+
__metadata("design:returntype", Promise)
|
|
1347
|
+
], FabricClientAdapter.prototype, "delete", null);
|
|
1348
|
+
__decorate([
|
|
1349
|
+
(0, logging_1.debug)(),
|
|
1350
|
+
__metadata("design:type", Function),
|
|
1351
|
+
__metadata("design:paramtypes", [Object, typeof (_a = typeof D !== "undefined" && D) === "function" ? _a : Object, Object, core_1.Context]),
|
|
1352
|
+
__metadata("design:returntype", Promise)
|
|
1353
|
+
], FabricClientAdapter.prototype, "raw", null);
|
|
1354
|
+
__decorate([
|
|
1355
|
+
(0, logging_1.debug)(),
|
|
1356
|
+
__metadata("design:type", Function),
|
|
1357
|
+
__metadata("design:paramtypes", [String, String, Object, core_1.Context]),
|
|
1358
|
+
__metadata("design:returntype", Promise)
|
|
1359
|
+
], FabricClientAdapter.prototype, "view", null);
|
|
1360
|
+
FabricClientAdapter.decoration();
|
|
1361
|
+
core_1.Adapter.setCurrent(constants_1.FabricFlavour);
|
|
1362
|
+
//# sourceMappingURL=FabricClientAdapter.js.map
|