@decaf-ts/for-fabric 0.5.7 → 0.7.0
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,1193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FabricContractAdapter = void 0;
|
|
4
|
+
exports.createdByOnFabricCreateUpdate = createdByOnFabricCreateUpdate;
|
|
5
|
+
const for_couchdb_1 = require("@decaf-ts/for-couchdb");
|
|
6
|
+
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
7
|
+
const ContractContext_1 = require("./ContractContext.cjs");
|
|
8
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
9
|
+
const fabric_contract_api_1 = require("fabric-contract-api");
|
|
10
|
+
const logging_1 = require("@decaf-ts/logging");
|
|
11
|
+
const core_1 = require("@decaf-ts/core");
|
|
12
|
+
const FabricContractRepository_1 = require("./FabricContractRepository.cjs");
|
|
13
|
+
const FabricContractStatement_1 = require("./FabricContractStatement.cjs");
|
|
14
|
+
const FabricContractSequence_1 = require("./FabricContractSequence.cjs");
|
|
15
|
+
const constants_1 = require("./../shared/constants.cjs");
|
|
16
|
+
const SimpleDeterministicSerializer_1 = require("./../shared/SimpleDeterministicSerializer.cjs");
|
|
17
|
+
const decoration_1 = require("@decaf-ts/decoration");
|
|
18
|
+
const FabricContractPaginator_1 = require("./FabricContractPaginator.cjs");
|
|
19
|
+
const errors_1 = require("./../shared/errors.cjs");
|
|
20
|
+
const FabricContractDispatch_1 = require("./FabricContractDispatch.cjs");
|
|
21
|
+
/**
|
|
22
|
+
* @description Sets the creator or updater field in a model based on the user in the context
|
|
23
|
+
* @summary Callback function used in decorators to automatically set the created_by or updated_by fields
|
|
24
|
+
* with the username from the context when a document is created or updated
|
|
25
|
+
* @template M - Type extending Model
|
|
26
|
+
* @template R - Type extending NanoRepository<M>
|
|
27
|
+
* @template V - Type extending RelationsMetadata
|
|
28
|
+
* @param {R} this - The repository instance
|
|
29
|
+
* @param {FabricContractContext} context - The operation context containing user information
|
|
30
|
+
* @param {V} data - The relation metadata
|
|
31
|
+
* @param {string} key - The property key to set with the username
|
|
32
|
+
* @param {M} model - The model instance being created or updated
|
|
33
|
+
* @return {Promise<void>} A promise that resolves when the operation is complete
|
|
34
|
+
* @function createdByOnFabricCreateUpdate
|
|
35
|
+
* @memberOf module:fabric.contracts
|
|
36
|
+
* @mermaid
|
|
37
|
+
* sequenceDiagram
|
|
38
|
+
* participant F as createdByOnNanoCreateUpdate
|
|
39
|
+
* participant C as Context
|
|
40
|
+
* participant M as Model
|
|
41
|
+
* F->>C: get("user")
|
|
42
|
+
* C-->>F: user object
|
|
43
|
+
* F->>M: set key to user.name
|
|
44
|
+
* Note over F: If no user in context
|
|
45
|
+
* F-->>F: throw UnsupportedError
|
|
46
|
+
*/
|
|
47
|
+
async function createdByOnFabricCreateUpdate(context, data, key, model) {
|
|
48
|
+
try {
|
|
49
|
+
const user = context.get("identity");
|
|
50
|
+
model[key] = user.getID();
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
throw new core_1.UnsupportedError("No User found in context. Please provide a user in the context");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @description Adapter for Hyperledger Fabric chaincode state database operations
|
|
59
|
+
* @summary Provides a CouchDB-like interface for interacting with the Fabric state database from within a chaincode contract
|
|
60
|
+
* @template void - No configuration needed for contract adapter
|
|
61
|
+
* @template FabricContractFlags - Flags specific to Fabric contract operations
|
|
62
|
+
* @template FabricContractContext - Context type for Fabric contract operations
|
|
63
|
+
* @class FabricContractAdapter
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* // In a Fabric chaincode contract class
|
|
67
|
+
* import { FabricContractAdapter } from '@decaf-ts/for-fabric';
|
|
68
|
+
*
|
|
69
|
+
* export class MyContract extends Contract {
|
|
70
|
+
* private adapter = new FabricContractAdapter();
|
|
71
|
+
*
|
|
72
|
+
* @Transaction()
|
|
73
|
+
* async createAsset(ctx: Context, id: string, data: string): Promise<void> {
|
|
74
|
+
* const model = { id, data, timestamp: Date.now() };
|
|
75
|
+
* await this.adapter.create('assets', id, model, {}, { stub: ctx.stub });
|
|
76
|
+
* }
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
* @mermaid
|
|
80
|
+
* sequenceDiagram
|
|
81
|
+
* participant Contract
|
|
82
|
+
* participant FabricContractAdapter
|
|
83
|
+
* participant Stub
|
|
84
|
+
* participant StateDB
|
|
85
|
+
*
|
|
86
|
+
* Contract->>FabricContractAdapter: create(tableName, id, model, transient, ctx)
|
|
87
|
+
* FabricContractAdapter->>FabricContractAdapter: Serialize model to JSON
|
|
88
|
+
* FabricContractAdapter->>Stub: putState(id, serializedData)
|
|
89
|
+
* Stub->>StateDB: Write data
|
|
90
|
+
* StateDB-->>Stub: Success
|
|
91
|
+
* Stub-->>FabricContractAdapter: Success
|
|
92
|
+
* FabricContractAdapter-->>Contract: model
|
|
93
|
+
*/
|
|
94
|
+
class FabricContractAdapter extends for_couchdb_1.CouchDBAdapter {
|
|
95
|
+
static { this.PRIVATE_BOOKMARK_PREFIX = "__dcf_pvtbm__"; }
|
|
96
|
+
static parseSyntheticPrivateBookmark(bookmark) {
|
|
97
|
+
if (typeof bookmark !== "string")
|
|
98
|
+
return undefined;
|
|
99
|
+
if (!bookmark.startsWith(FabricContractAdapter.PRIVATE_BOOKMARK_PREFIX))
|
|
100
|
+
return undefined;
|
|
101
|
+
const raw = bookmark.slice(FabricContractAdapter.PRIVATE_BOOKMARK_PREFIX.length);
|
|
102
|
+
const parsed = Number(raw);
|
|
103
|
+
return Number.isInteger(parsed) && parsed >= 0 ? parsed : undefined;
|
|
104
|
+
}
|
|
105
|
+
static buildSyntheticPrivateBookmark(offset) {
|
|
106
|
+
return `${FabricContractAdapter.PRIVATE_BOOKMARK_PREFIX}${offset}`;
|
|
107
|
+
}
|
|
108
|
+
getClient() {
|
|
109
|
+
throw new core_1.UnsupportedError("Client is not supported in Fabric contracts");
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* @description Text decoder for converting binary data to strings
|
|
113
|
+
*/
|
|
114
|
+
static { this.textDecoder = new TextDecoder("utf8"); }
|
|
115
|
+
static { this.serializer = new SimpleDeterministicSerializer_1.SimpleDeterministicSerializer(); }
|
|
116
|
+
/**
|
|
117
|
+
* @description Context constructor for this adapter
|
|
118
|
+
* @summary Overrides the base Context constructor with FabricContractContext
|
|
119
|
+
*/
|
|
120
|
+
get Context() {
|
|
121
|
+
return ContractContext_1.FabricContractContext;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @description Gets the repository constructor for this adapter
|
|
125
|
+
* @summary Returns the FabricContractRepository constructor for creating repositories
|
|
126
|
+
* @template M - Type extending Model
|
|
127
|
+
* @return {Constructor<Repository<M, MangoQuery, FabricContractAdapter, FabricContractFlags, FabricContractContext>>} The repository constructor
|
|
128
|
+
*/
|
|
129
|
+
repository() {
|
|
130
|
+
return FabricContractRepository_1.FabricContractRepository;
|
|
131
|
+
}
|
|
132
|
+
Paginator(query, size, clazz) {
|
|
133
|
+
return new FabricContractPaginator_1.FabricContractPaginator(this, query, size, clazz);
|
|
134
|
+
}
|
|
135
|
+
async Sequence(options) {
|
|
136
|
+
return new FabricContractSequence_1.FabricContractSequence(options, this);
|
|
137
|
+
}
|
|
138
|
+
Dispatch() {
|
|
139
|
+
return new FabricContractDispatch_1.FabricContractDispatch();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @description Creates a new FabricContractAdapter instance
|
|
143
|
+
* @summary Initializes an adapter for interacting with the Fabric state database
|
|
144
|
+
* @param {void} scope - Not used in this adapter
|
|
145
|
+
* @param {string} [alias] - Optional alias for the adapter instance
|
|
146
|
+
*/
|
|
147
|
+
constructor(scope, alias) {
|
|
148
|
+
super(scope, constants_1.FabricFlavour, alias);
|
|
149
|
+
}
|
|
150
|
+
for(config, ...args) {
|
|
151
|
+
return super.for(config, ...args);
|
|
152
|
+
}
|
|
153
|
+
getModelDefaults(clazz) {
|
|
154
|
+
const m = new clazz();
|
|
155
|
+
return (decoration_1.Metadata.properties(clazz) || []).reduce((acc, p) => {
|
|
156
|
+
if (typeof m[p] !== "undefined")
|
|
157
|
+
acc[p] = m[p];
|
|
158
|
+
return acc;
|
|
159
|
+
}, {});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @description Creates a record in the state database
|
|
163
|
+
* @summary Serializes a model and stores it in the Fabric state database
|
|
164
|
+
* @param {string} tableName - The name of the table/collection
|
|
165
|
+
* @param {string | number} id - The record identifier
|
|
166
|
+
* @param {Record<string, any>} model - The record data
|
|
167
|
+
* @param {Record<string, any>} transient - Transient data (not used in this implementation)
|
|
168
|
+
* @param {...any[]} args - Additional arguments, including the chaincode stub and logger
|
|
169
|
+
* @return {Promise<Record<string, any>>} Promise resolving to the created record
|
|
170
|
+
*/
|
|
171
|
+
async create(clazz, id, model, ...args) {
|
|
172
|
+
const { ctx, log } = this.logCtx(args, this.create);
|
|
173
|
+
this.enforceMirrorAuthorization(clazz, ctx);
|
|
174
|
+
log.info(`in ADAPTER create with args ${args}`);
|
|
175
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
176
|
+
const composedKey = ctx.stub.createCompositeKey(tableName, [String(id)]);
|
|
177
|
+
const mirrorCollection = ctx.getOrUndefined("mirrorCollection");
|
|
178
|
+
const fullySegregated = ctx.isFullySegregated && !mirrorCollection;
|
|
179
|
+
if (!mirrorCollection) {
|
|
180
|
+
let existing;
|
|
181
|
+
try {
|
|
182
|
+
existing = await this.readState(composedKey, ctx);
|
|
183
|
+
}
|
|
184
|
+
catch (e) {
|
|
185
|
+
// eslint-disable-next-line no-ex-assign
|
|
186
|
+
e = this.parseError(e);
|
|
187
|
+
if (!(e instanceof db_decorators_1.NotFoundError))
|
|
188
|
+
throw e;
|
|
189
|
+
}
|
|
190
|
+
if (existing)
|
|
191
|
+
throw new db_decorators_1.ConflictError(`record with id ${id} in table ${tableName} already exists`);
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
log.info(`adding entry to ${tableName} table with pk ${id}`);
|
|
195
|
+
if (mirrorCollection) {
|
|
196
|
+
model = await this.forPrivate(mirrorCollection).putState(composedKey, model, ctx);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
const defaults = this.getModelDefaults(clazz);
|
|
200
|
+
// handle public data if not fully segregated
|
|
201
|
+
if (!fullySegregated) {
|
|
202
|
+
if (Object.keys(model).filter((k) => {
|
|
203
|
+
if (k === for_couchdb_1.CouchDBKeys.TABLE)
|
|
204
|
+
return false;
|
|
205
|
+
return !(defaults &&
|
|
206
|
+
k in defaults &&
|
|
207
|
+
defaults[k] === model[k]);
|
|
208
|
+
}).length)
|
|
209
|
+
model = await this.putState(composedKey, model, ctx);
|
|
210
|
+
}
|
|
211
|
+
// handle segregated writes
|
|
212
|
+
const data = ctx.getFromChildren("segregatedData");
|
|
213
|
+
if (data) {
|
|
214
|
+
for (const collection in data) {
|
|
215
|
+
Object.assign(model, await this.forPrivate(collection).putState(composedKey, data[collection][id], ctx));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (e) {
|
|
221
|
+
throw this.parseError(e);
|
|
222
|
+
}
|
|
223
|
+
return model;
|
|
224
|
+
}
|
|
225
|
+
async createAll(tableName, id, model, ...args) {
|
|
226
|
+
if (id.length !== model.length)
|
|
227
|
+
throw new db_decorators_1.InternalError("Ids and models must have the same length");
|
|
228
|
+
const { log, ctxArgs } = this.logCtx(args, this.createAll);
|
|
229
|
+
const tableLabel = decorator_validation_1.Model.tableName(tableName);
|
|
230
|
+
log.debug(`Creating ${id.length} entries ${tableLabel} table`);
|
|
231
|
+
return Promise.all(id.map((i, count) => this.create(tableName, i, model[count], ...ctxArgs)));
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @description Reads a record from the state database
|
|
235
|
+
* @summary Retrieves and deserializes a record from the Fabric state database
|
|
236
|
+
* @param {string} tableName - The name of the table/collection
|
|
237
|
+
* @param {string | number} id - The record identifier
|
|
238
|
+
* @param {...any[]} args - Additional arguments, including the chaincode stub and logger
|
|
239
|
+
* @return {Promise<Record<string, any>>} Promise resolving to the retrieved record
|
|
240
|
+
*/
|
|
241
|
+
async read(clazz, id, ...args) {
|
|
242
|
+
const { ctx, log } = this.logCtx(args, this.read);
|
|
243
|
+
log.info(`in ADAPTER read with args ${args}`);
|
|
244
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
245
|
+
const composedKey = ctx.stub.createCompositeKey(tableName, [String(id)]);
|
|
246
|
+
const mirrorCollection = ctx.getOrUndefined("mirrorCollection");
|
|
247
|
+
const isMirror = ctx.getOrUndefined("mirror");
|
|
248
|
+
if (isMirror && mirrorCollection) {
|
|
249
|
+
try {
|
|
250
|
+
return await this.forPrivate(mirrorCollection).readState(composedKey, ctx);
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
throw this.parseError(e);
|
|
254
|
+
}
|
|
255
|
+
finally {
|
|
256
|
+
ctx.put("mirror", undefined);
|
|
257
|
+
ctx.put("mirrorCollection", undefined);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
let model;
|
|
261
|
+
try {
|
|
262
|
+
model = ctx.isFullySegregated
|
|
263
|
+
? {}
|
|
264
|
+
: await this.readState(composedKey, ctx);
|
|
265
|
+
}
|
|
266
|
+
catch (e) {
|
|
267
|
+
throw this.parseError(e);
|
|
268
|
+
}
|
|
269
|
+
const readCollections = new Set([
|
|
270
|
+
...(ctx.getReadCollections() || []),
|
|
271
|
+
...(ctx.consumeReadCollections() || []),
|
|
272
|
+
]);
|
|
273
|
+
for (const col of readCollections) {
|
|
274
|
+
try {
|
|
275
|
+
Object.assign(model, await this.forPrivate(col).readState(composedKey, ctx));
|
|
276
|
+
}
|
|
277
|
+
catch (e) {
|
|
278
|
+
const parsed = this.parseError(e);
|
|
279
|
+
if (parsed instanceof db_decorators_1.NotFoundError)
|
|
280
|
+
continue;
|
|
281
|
+
throw parsed;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (!Object.keys(model).length) {
|
|
285
|
+
throw new db_decorators_1.NotFoundError(`record with id ${id} in table ${tableName} does not exist`);
|
|
286
|
+
}
|
|
287
|
+
return model;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* @description Retrieves multiple records from the database
|
|
291
|
+
* @summary Fetches multiple records with the given IDs from the specified table
|
|
292
|
+
* @param {string} tableName - The name of the table to read from
|
|
293
|
+
* @param id - The identifiers of the records to retrieve
|
|
294
|
+
* @param {...any[]} args - Additional arguments specific to the adapter implementation
|
|
295
|
+
* @return A promise that resolves to an array of retrieved records
|
|
296
|
+
*/
|
|
297
|
+
async readAll(clazz, id, ...args) {
|
|
298
|
+
const { log, ctx } = this.logCtx(args, this.readAll);
|
|
299
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
300
|
+
log.debug(`Reading ${id.length} entries ${tableName} table`);
|
|
301
|
+
const breakOnSingleFailure = ctx.get("breakOnSingleFailureInBulk") ?? true;
|
|
302
|
+
const continueOnError = !breakOnSingleFailure;
|
|
303
|
+
const mirrorCollection = ctx.getOrUndefined("mirrorCollection");
|
|
304
|
+
const isMirror = ctx.getOrUndefined("mirror");
|
|
305
|
+
const readMirror = async (clazz, id, ...args) => {
|
|
306
|
+
if (!mirrorCollection)
|
|
307
|
+
throw new db_decorators_1.BadRequestError("Missing mirror collection for mirror read");
|
|
308
|
+
try {
|
|
309
|
+
const { ctx, log } = this.logCtx(args, readMirror);
|
|
310
|
+
log.info(`in ADAPTER read with args ${args}`);
|
|
311
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
312
|
+
const composedKey = ctx.stub.createCompositeKey(tableName, [
|
|
313
|
+
String(id),
|
|
314
|
+
]);
|
|
315
|
+
return await this.forPrivate(mirrorCollection).readState(composedKey, ctx);
|
|
316
|
+
}
|
|
317
|
+
catch (e) {
|
|
318
|
+
throw this.parseError(e);
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
try {
|
|
322
|
+
const tasks = id.map((i) => () => isMirror && mirrorCollection
|
|
323
|
+
? readMirror(clazz, i, ...args, ctx.override({ noEmitSingle: true }))
|
|
324
|
+
: this.read(clazz, i, ...args, ctx.override({ noEmitSingle: true })));
|
|
325
|
+
const rawResult = continueOnError
|
|
326
|
+
? await (0, core_1.promiseSequence)(tasks, true)
|
|
327
|
+
: await (0, core_1.promiseSequence)(tasks);
|
|
328
|
+
return (0, core_1.resolveBulkSequenceResult)(rawResult, continueOnError, log, db_decorators_1.BulkCrudOperationKeys.READ_ALL);
|
|
329
|
+
}
|
|
330
|
+
catch (e) {
|
|
331
|
+
throw this.parseError(e);
|
|
332
|
+
}
|
|
333
|
+
finally {
|
|
334
|
+
ctx.put("mirror", undefined);
|
|
335
|
+
ctx.put("mirrorCollection", undefined);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* @description Updates a record in the state database
|
|
340
|
+
* @summary Serializes a model and updates it in the Fabric state database
|
|
341
|
+
* @param {string} tableName - The name of the table/collection
|
|
342
|
+
* @param {string | number} id - The record identifier
|
|
343
|
+
* @param {Record<string, any>} model - The updated record data
|
|
344
|
+
* @param {Record<string, any>} transient - Transient data (not used in this implementation)
|
|
345
|
+
* @param {...any[]} args - Additional arguments, including the chaincode stub and logger
|
|
346
|
+
* @return {Promise<Record<string, any>>} Promise resolving to the updated record
|
|
347
|
+
*/
|
|
348
|
+
async update(clazz, id, model, ...args) {
|
|
349
|
+
const { ctx, log } = this.logCtx(args, this.update);
|
|
350
|
+
this.enforceMirrorAuthorization(clazz, ctx);
|
|
351
|
+
log.info(`in ADAPTER update with args ${args}`);
|
|
352
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
353
|
+
const composedKey = ctx.stub.createCompositeKey(tableName, [String(id)]);
|
|
354
|
+
const mirrorCollection = ctx.getOrUndefined("mirrorCollection");
|
|
355
|
+
try {
|
|
356
|
+
log.info(`updating entry in ${tableName} table with pk ${id}`);
|
|
357
|
+
if (mirrorCollection) {
|
|
358
|
+
model = await this.forPrivate(mirrorCollection).putState(composedKey, model, ctx);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
const defaults = this.getModelDefaults(clazz);
|
|
362
|
+
// handle public data
|
|
363
|
+
if (Object.keys(model).filter((k) => {
|
|
364
|
+
if (k === for_couchdb_1.CouchDBKeys.TABLE)
|
|
365
|
+
return false;
|
|
366
|
+
return !(defaults &&
|
|
367
|
+
k in defaults &&
|
|
368
|
+
defaults[k] === model[k]);
|
|
369
|
+
}).length)
|
|
370
|
+
model = await this.putState(composedKey, model, ctx);
|
|
371
|
+
// handle segregated writes
|
|
372
|
+
const data = ctx.getFromChildren("segregatedData");
|
|
373
|
+
if (data) {
|
|
374
|
+
for (const collection in data) {
|
|
375
|
+
Object.assign(model, await this.forPrivate(collection).putState(composedKey, data[collection][id], ctx));
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
catch (e) {
|
|
381
|
+
throw this.parseError(e);
|
|
382
|
+
}
|
|
383
|
+
return model;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* @description Deletes a record from the state database
|
|
387
|
+
* @summary Retrieves a record and then removes it from the Fabric state database
|
|
388
|
+
* @param {string} tableName - The name of the table/collection
|
|
389
|
+
* @param {string | number} id - The record identifier to delete
|
|
390
|
+
* @param {...any[]} args - Additional arguments, including the chaincode stub and logger
|
|
391
|
+
* @return {Promise<Record<string, any>>} Promise resolving to the deleted record
|
|
392
|
+
*/
|
|
393
|
+
async delete(clazz, id, ...args) {
|
|
394
|
+
const { ctx, log } = this.logCtx(args, this.delete);
|
|
395
|
+
this.enforceMirrorAuthorization(clazz, ctx);
|
|
396
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
397
|
+
const composedKey = ctx.stub.createCompositeKey(tableName, [String(id)]);
|
|
398
|
+
const mirrorCollection = ctx.getOrUndefined("mirrorCollection");
|
|
399
|
+
let model;
|
|
400
|
+
if (mirrorCollection) {
|
|
401
|
+
try {
|
|
402
|
+
model = await this.forPrivate(mirrorCollection).readState(composedKey, ctx);
|
|
403
|
+
await this.forPrivate(mirrorCollection).deleteState(composedKey, ctx);
|
|
404
|
+
}
|
|
405
|
+
catch (e) {
|
|
406
|
+
throw this.parseError(e);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
try {
|
|
411
|
+
model = ctx.isFullySegregated
|
|
412
|
+
? {}
|
|
413
|
+
: await this.readState(composedKey, ctx);
|
|
414
|
+
if (!ctx.isFullySegregated) {
|
|
415
|
+
log.debug(`Deleting entry ${composedKey} from public ledger`);
|
|
416
|
+
await this.deleteState(composedKey, ctx);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
catch (e) {
|
|
420
|
+
throw this.parseError(e);
|
|
421
|
+
}
|
|
422
|
+
const collections = ctx.getReadCollections();
|
|
423
|
+
if (collections && collections.length) {
|
|
424
|
+
for (const col of collections) {
|
|
425
|
+
log.debug(`ensuring collection ${col} has entry for id ${composedKey} before deleting`);
|
|
426
|
+
Object.assign(model, await this.forPrivate(col).readState(composedKey, ctx));
|
|
427
|
+
log.debug(`Deleting private collection ${col} entry for id ${composedKey}`);
|
|
428
|
+
await this.forPrivate(col).deleteState(composedKey, ctx);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return model;
|
|
433
|
+
}
|
|
434
|
+
async deleteState(id, context) {
|
|
435
|
+
await context.stub.deleteState(id);
|
|
436
|
+
}
|
|
437
|
+
forPrivate(collection) {
|
|
438
|
+
const toOverride = [
|
|
439
|
+
this.putState,
|
|
440
|
+
this.readState,
|
|
441
|
+
this.deleteState,
|
|
442
|
+
this.queryResult,
|
|
443
|
+
this.queryResultPaginated,
|
|
444
|
+
].map((fn) => fn.name);
|
|
445
|
+
return new Proxy(this, {
|
|
446
|
+
get(target, prop, receiver) {
|
|
447
|
+
if (!toOverride.includes(prop))
|
|
448
|
+
return Reflect.get(target, prop, receiver);
|
|
449
|
+
return new Proxy(target[prop], {
|
|
450
|
+
async apply(fn, thisArg, argsList) {
|
|
451
|
+
switch (prop) {
|
|
452
|
+
case "putState": {
|
|
453
|
+
// putState signature: (id: string, model: Record<string, any>, ctx: FabricContractContext)
|
|
454
|
+
const [id, model, ctx] = argsList;
|
|
455
|
+
const log = ctx.logger.for(prop);
|
|
456
|
+
log.debug(`Private write to ${collection} for ${id.toString()}`);
|
|
457
|
+
const data = Buffer.from(FabricContractAdapter.serializer.serialize(model, false));
|
|
458
|
+
await ctx.stub.putPrivateData(collection, id.toString(), data);
|
|
459
|
+
return model;
|
|
460
|
+
}
|
|
461
|
+
case "deleteState": {
|
|
462
|
+
// deleteState signature: (id: string, context: FabricContractContext)
|
|
463
|
+
const [id, ctx] = argsList;
|
|
464
|
+
const log = ctx.logger.for(prop);
|
|
465
|
+
log.debug(`Private delete on ${collection} for ${id.toString()}`);
|
|
466
|
+
await ctx.stub.deletePrivateData(collection, id.toString());
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
case "readState": {
|
|
470
|
+
// readState signature: (id: string, ctx: FabricContractContext)
|
|
471
|
+
const [id, ctx] = argsList;
|
|
472
|
+
const log = ctx.logger.for(prop);
|
|
473
|
+
log.debug(`Private read from ${collection} for ${id.toString()}`);
|
|
474
|
+
const data = await ctx.stub.getPrivateData(collection, id);
|
|
475
|
+
if (!data || !data.toString().length)
|
|
476
|
+
throw new db_decorators_1.NotFoundError(`Record with id ${id} not found`);
|
|
477
|
+
try {
|
|
478
|
+
return FabricContractAdapter.serializer.deserialize(data.toString("utf8"));
|
|
479
|
+
}
|
|
480
|
+
catch {
|
|
481
|
+
return data.toString("utf8");
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
case "queryResult": {
|
|
485
|
+
const [stub, rawInput, ...args] = argsList;
|
|
486
|
+
const { log } = thisArg["logCtx"](args, prop);
|
|
487
|
+
try {
|
|
488
|
+
log.debug(`Querying collection ${collection} for ${JSON.stringify(rawInput)}`);
|
|
489
|
+
const res = await stub.getPrivateDataQueryResult(collection, JSON.stringify(rawInput));
|
|
490
|
+
log.verbose(`iterator from collection ${collection} received`);
|
|
491
|
+
return res.iterator || res;
|
|
492
|
+
}
|
|
493
|
+
catch (e) {
|
|
494
|
+
log.error(e);
|
|
495
|
+
return [];
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
case "queryResultPaginated": {
|
|
499
|
+
const [stub, rawInput, limit, skip, bookmark, ...args] = argsList;
|
|
500
|
+
const { log } = thisArg["logCtx"](args, prop);
|
|
501
|
+
const pageSize = Math.max(1, Number(limit) || 250);
|
|
502
|
+
const query = { ...rawInput };
|
|
503
|
+
const skipValue = Number(skip);
|
|
504
|
+
const parsedSkip = Number.isInteger(skipValue) && skipValue >= 0
|
|
505
|
+
? skipValue
|
|
506
|
+
: undefined;
|
|
507
|
+
const syntheticOffset = FabricContractAdapter.parseSyntheticPrivateBookmark(bookmark) ??
|
|
508
|
+
parsedSkip ??
|
|
509
|
+
0;
|
|
510
|
+
const hasOpaqueBookmark = bookmark !== undefined &&
|
|
511
|
+
bookmark !== null &&
|
|
512
|
+
bookmark !== "" &&
|
|
513
|
+
typeof bookmark === "string" &&
|
|
514
|
+
!bookmark.startsWith(FabricContractAdapter.PRIVATE_BOOKMARK_PREFIX);
|
|
515
|
+
// Keep the query CouchDB-compatible and let Fabric/CouchDB own bookmark semantics.
|
|
516
|
+
// Synthetic mode fetches one extra record to detect whether a next page exists.
|
|
517
|
+
query.limit = hasOpaqueBookmark ? pageSize : pageSize + 1;
|
|
518
|
+
if (hasOpaqueBookmark) {
|
|
519
|
+
query.bookmark = bookmark.toString();
|
|
520
|
+
delete query.skip;
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
delete query.bookmark;
|
|
524
|
+
if (syntheticOffset > 0) {
|
|
525
|
+
query.skip = syntheticOffset;
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
delete query.skip;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
log.debug(`Querying collection ${collection} for ${JSON.stringify(query)}`);
|
|
532
|
+
const response = await stub.getPrivateDataQueryResult(collection, JSON.stringify(query));
|
|
533
|
+
const iterator = (response.iterator ||
|
|
534
|
+
response);
|
|
535
|
+
const responseMetadata = response.metadata || iterator.metadata || {};
|
|
536
|
+
const responseBookmark = typeof responseMetadata.bookmark === "string"
|
|
537
|
+
? responseMetadata.bookmark
|
|
538
|
+
: "";
|
|
539
|
+
log.verbose(`iterator from collection ${collection} received`);
|
|
540
|
+
const paged = [];
|
|
541
|
+
let hasMore = false;
|
|
542
|
+
try {
|
|
543
|
+
while (true) {
|
|
544
|
+
const res = await iterator.next();
|
|
545
|
+
if (res.done)
|
|
546
|
+
break;
|
|
547
|
+
if (res.value && res.value.value) {
|
|
548
|
+
const key = res.value.key;
|
|
549
|
+
if (paged.length < pageSize) {
|
|
550
|
+
paged.push({
|
|
551
|
+
key,
|
|
552
|
+
value: Buffer.isBuffer(res.value.value)
|
|
553
|
+
? res.value.value
|
|
554
|
+
: Buffer.from(res.value.value.toString("utf8")),
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
hasMore = true;
|
|
559
|
+
break; // early exit
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
finally {
|
|
565
|
+
await iterator.close();
|
|
566
|
+
}
|
|
567
|
+
// Wrap the page in an async iterator for resultIterator()
|
|
568
|
+
let idx = 0;
|
|
569
|
+
const arrayIterator = {
|
|
570
|
+
async next() {
|
|
571
|
+
if (idx < paged.length) {
|
|
572
|
+
return { value: paged[idx++], done: false };
|
|
573
|
+
}
|
|
574
|
+
return { value: undefined, done: true };
|
|
575
|
+
},
|
|
576
|
+
async close() { },
|
|
577
|
+
};
|
|
578
|
+
return {
|
|
579
|
+
iterator: arrayIterator,
|
|
580
|
+
metadata: {
|
|
581
|
+
fetchedRecordsCount: paged.length,
|
|
582
|
+
bookmark: responseBookmark ||
|
|
583
|
+
(hasMore
|
|
584
|
+
? FabricContractAdapter.buildSyntheticPrivateBookmark(syntheticOffset + paged.length)
|
|
585
|
+
: ""),
|
|
586
|
+
},
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
default:
|
|
590
|
+
throw new db_decorators_1.InternalError(`Unsupported method override ${String(prop)}`);
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
});
|
|
594
|
+
},
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
async putState(id, model, ctx) {
|
|
598
|
+
let data;
|
|
599
|
+
try {
|
|
600
|
+
data = Buffer.from(FabricContractAdapter.serializer.serialize(model, false));
|
|
601
|
+
}
|
|
602
|
+
catch (e) {
|
|
603
|
+
throw new db_decorators_1.SerializationError(`Failed to serialize record with id ${id}: ${e}`);
|
|
604
|
+
}
|
|
605
|
+
await ctx.stub.putState(id.toString(), data);
|
|
606
|
+
return model;
|
|
607
|
+
}
|
|
608
|
+
async readState(id, ctx) {
|
|
609
|
+
let result;
|
|
610
|
+
const { log } = this.logCtx([ctx], this.readState);
|
|
611
|
+
const res = (await ctx.stub.getState(id.toString())).toString();
|
|
612
|
+
if (!res)
|
|
613
|
+
throw new db_decorators_1.NotFoundError(`Record with id ${id} not found`);
|
|
614
|
+
log.silly(`state retrieved under id ${id}`);
|
|
615
|
+
try {
|
|
616
|
+
result = FabricContractAdapter.serializer.deserialize(res.toString());
|
|
617
|
+
}
|
|
618
|
+
catch (e) {
|
|
619
|
+
throw new db_decorators_1.SerializationError(`Failed to parse record: ${e}`);
|
|
620
|
+
}
|
|
621
|
+
return result;
|
|
622
|
+
}
|
|
623
|
+
async queryResult(stub, rawInput,
|
|
624
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
625
|
+
...args) {
|
|
626
|
+
return stub.getQueryResult(JSON.stringify(rawInput));
|
|
627
|
+
}
|
|
628
|
+
async queryResultPaginated(stub, rawInput, limit = 250, page, bookmark,
|
|
629
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
630
|
+
...args) {
|
|
631
|
+
return stub.getQueryResultWithPagination(JSON.stringify(rawInput), limit, bookmark?.toString());
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* @description Decodes binary data to string
|
|
635
|
+
* @summary Converts a Uint8Array to a string using UTF-8 encoding
|
|
636
|
+
* @param {Uint8Array} buffer - The binary data to decode
|
|
637
|
+
* @return {string} The decoded string
|
|
638
|
+
*/
|
|
639
|
+
decode(buffer) {
|
|
640
|
+
return FabricContractAdapter.textDecoder.decode(buffer);
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* @description Creates operation flags for Fabric contract operations
|
|
644
|
+
* @summary Merges default flags with Fabric-specific context information
|
|
645
|
+
* @template M - Type extending Model
|
|
646
|
+
* @param {OperationKeys} operation - The operation being performed
|
|
647
|
+
* @param {Constructor<M>} model - The model constructor
|
|
648
|
+
* @param {Partial<FabricContractFlags>} flags - Partial flags to merge with defaults
|
|
649
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
650
|
+
* @return {FabricContractFlags} The merged flags
|
|
651
|
+
*/
|
|
652
|
+
async flags(operation, model, flags) {
|
|
653
|
+
let baseFlags = {
|
|
654
|
+
segregated: false,
|
|
655
|
+
rebuildWithTransient: false,
|
|
656
|
+
fullySegregated: false,
|
|
657
|
+
};
|
|
658
|
+
if (flags instanceof ContractContext_1.FabricContractContext || flags instanceof core_1.Context) {
|
|
659
|
+
flags = flags.toOverrides();
|
|
660
|
+
}
|
|
661
|
+
baseFlags = Object.assign(baseFlags, flags);
|
|
662
|
+
const stubFromFlags = flags.stub || flags.stub;
|
|
663
|
+
const identityFromFlags = flags.identity ||
|
|
664
|
+
flags.clientIdentity;
|
|
665
|
+
if (stubFromFlags && identityFromFlags) {
|
|
666
|
+
const txId = stubFromFlags.getTxID();
|
|
667
|
+
Object.assign(baseFlags, {
|
|
668
|
+
stub: stubFromFlags,
|
|
669
|
+
identity: identityFromFlags,
|
|
670
|
+
cert: identityFromFlags.getIDBytes().toString(),
|
|
671
|
+
roles: identityFromFlags.getAttributeValue("roles"),
|
|
672
|
+
logger: logging_1.Logging.for(operation, {
|
|
673
|
+
logLevel: false,
|
|
674
|
+
timestamp: false,
|
|
675
|
+
correlationId: txId,
|
|
676
|
+
}, flags),
|
|
677
|
+
correlationId: txId,
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
baseFlags = Object.assign(baseFlags, flags || {});
|
|
682
|
+
}
|
|
683
|
+
return (await super.flags(operation, model, baseFlags));
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* @description Creates an index for a model
|
|
687
|
+
* @summary This method is not implemented for Fabric contracts and returns a resolved promise
|
|
688
|
+
* @template M - Type extending Model
|
|
689
|
+
* @param {Constructor<M>} models - The model constructor
|
|
690
|
+
* @return {Promise<void>} Promise that resolves immediately
|
|
691
|
+
*/
|
|
692
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
693
|
+
index(models) {
|
|
694
|
+
return Promise.resolve(undefined);
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* @description Processes results from a state query iterator
|
|
698
|
+
* @summary Iterates through query results and converts them to a structured format
|
|
699
|
+
* @param {Logger} log - Logger instance for debugging
|
|
700
|
+
* @param {Iterators.StateQueryIterator} iterator - The state query iterator
|
|
701
|
+
* @param {boolean} [isHistory=false] - Whether this is a history query
|
|
702
|
+
* @return {Promise<any[]>} Promise resolving to an array of processed results
|
|
703
|
+
* @mermaid
|
|
704
|
+
* sequenceDiagram
|
|
705
|
+
* participant Caller
|
|
706
|
+
* participant ResultIterator
|
|
707
|
+
* participant Iterator
|
|
708
|
+
*
|
|
709
|
+
* Caller->>ResultIterator: resultIterator(log, iterator, isHistory)
|
|
710
|
+
* loop Until done
|
|
711
|
+
* ResultIterator->>Iterator: next()
|
|
712
|
+
* Iterator-->>ResultIterator: { value, done }
|
|
713
|
+
* alt Has value
|
|
714
|
+
* ResultIterator->>ResultIterator: Process value based on isHistory
|
|
715
|
+
* ResultIterator->>ResultIterator: Add to results array
|
|
716
|
+
* end
|
|
717
|
+
* end
|
|
718
|
+
* ResultIterator->>Iterator: close()
|
|
719
|
+
* ResultIterator-->>Caller: allResults
|
|
720
|
+
*/
|
|
721
|
+
async resultIterator(log, iterator, isHistory = false) {
|
|
722
|
+
const allResults = [];
|
|
723
|
+
let res = await iterator.next();
|
|
724
|
+
while (!res.done) {
|
|
725
|
+
if (res.value && res.value.value.toString()) {
|
|
726
|
+
let jsonRes = {};
|
|
727
|
+
log.debug(res.value.value.toString("utf8"));
|
|
728
|
+
if (isHistory /* && isHistory === true*/) {
|
|
729
|
+
jsonRes.TxId = res.value.txId;
|
|
730
|
+
jsonRes.Timestamp = res.value.timestamp;
|
|
731
|
+
try {
|
|
732
|
+
jsonRes.Value = JSON.parse(res.value.value.toString("utf8"));
|
|
733
|
+
}
|
|
734
|
+
catch (err) {
|
|
735
|
+
log.error(err);
|
|
736
|
+
jsonRes.Value = res.value.value.toString("utf8");
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
else {
|
|
740
|
+
try {
|
|
741
|
+
jsonRes = JSON.parse(res.value.value.toString("utf8"));
|
|
742
|
+
}
|
|
743
|
+
catch (err) {
|
|
744
|
+
log.error(err);
|
|
745
|
+
jsonRes = res.value.value.toString("utf8");
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
allResults.push(jsonRes);
|
|
749
|
+
}
|
|
750
|
+
res = await iterator.next();
|
|
751
|
+
}
|
|
752
|
+
log.debug(`Closing iterator after ${allResults.length} results`);
|
|
753
|
+
await iterator.close();
|
|
754
|
+
return allResults;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* @description Executes a raw query against the state database
|
|
758
|
+
* @summary Performs a rich query using CouchDB syntax against the Fabric state database
|
|
759
|
+
* @template R - The return type
|
|
760
|
+
* @param {MangoQuery} rawInput - The Mango Query to execute
|
|
761
|
+
* @param {boolean} docsOnly - Whether to return only documents (not used in this implementation)
|
|
762
|
+
* @param {...any[]} args - Additional arguments, including the chaincode stub and logger
|
|
763
|
+
* @return {Promise<R>} Promise resolving to the query results
|
|
764
|
+
* @mermaid
|
|
765
|
+
* sequenceDiagram
|
|
766
|
+
* participant Caller
|
|
767
|
+
* participant FabricContractAdapter
|
|
768
|
+
* participant Stub
|
|
769
|
+
* participant StateDB
|
|
770
|
+
*
|
|
771
|
+
* Caller->>FabricContractAdapter: raw(rawInput, docsOnly, ctx)
|
|
772
|
+
* FabricContractAdapter->>FabricContractAdapter: Extract limit and skip
|
|
773
|
+
* alt With pagination
|
|
774
|
+
* FabricContractAdapter->>Stub: getQueryResultWithPagination(query, limit, skip)
|
|
775
|
+
* else Without pagination
|
|
776
|
+
* FabricContractAdapter->>Stub: getQueryResult(query)
|
|
777
|
+
* end
|
|
778
|
+
* Stub->>StateDB: Execute query
|
|
779
|
+
* StateDB-->>Stub: Iterator
|
|
780
|
+
* Stub-->>FabricContractAdapter: Iterator
|
|
781
|
+
* FabricContractAdapter->>FabricContractAdapter: resultIterator(log, iterator)
|
|
782
|
+
* FabricContractAdapter-->>Caller: results
|
|
783
|
+
*/
|
|
784
|
+
async raw(rawInput, docsOnly = true, ...args) {
|
|
785
|
+
const { log, ctx, ctxArgs } = this.logCtx(args, this.raw);
|
|
786
|
+
const enableSegregates = !args.length || args[0] !== true;
|
|
787
|
+
const fullySegregated = enableSegregates && ctx.isFullySegregated;
|
|
788
|
+
const { skip, limit } = rawInput;
|
|
789
|
+
const bookmark = rawInput["bookmark"];
|
|
790
|
+
const paginationActive = Boolean(limit || skip || bookmark);
|
|
791
|
+
let resp = { docs: [], bookmark: undefined };
|
|
792
|
+
// Query public state only when the model is NOT fully segregated
|
|
793
|
+
if (!fullySegregated) {
|
|
794
|
+
let iterator;
|
|
795
|
+
if (limit || skip) {
|
|
796
|
+
delete rawInput["limit"];
|
|
797
|
+
delete rawInput["skip"];
|
|
798
|
+
log.debug(`Retrieving public paginated iterator: limit: ${limit}/ skip: ${skip}`);
|
|
799
|
+
const response = (await this.queryResultPaginated(ctx.stub, rawInput, limit || Number.MAX_VALUE, skip?.toString(), bookmark, ...[ctx]));
|
|
800
|
+
resp.bookmark = response.metadata.bookmark;
|
|
801
|
+
iterator = response.iterator;
|
|
802
|
+
log.debug(`Retrieved public paging iterator`);
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
log.debug("Retrieving listing public iterator");
|
|
806
|
+
iterator = (await this.queryResult(ctx.stub, rawInput, ctx));
|
|
807
|
+
}
|
|
808
|
+
log.debug(`Retrieved public listing iterator`);
|
|
809
|
+
resp.docs = (await this.resultIterator(log, iterator));
|
|
810
|
+
log.debug(`returning ${Array.isArray(resp.docs) ? resp.docs.length : 1} results`);
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
// For fully segregated models, strip pagination fields from rawInput
|
|
814
|
+
// so the segregated query below can re-apply them cleanly
|
|
815
|
+
if (limit || skip) {
|
|
816
|
+
delete rawInput["limit"];
|
|
817
|
+
delete rawInput["skip"];
|
|
818
|
+
}
|
|
819
|
+
log.debug("Skipping public state query (fully segregated model)");
|
|
820
|
+
}
|
|
821
|
+
const collections = enableSegregates ? ctx.getReadCollections() : undefined;
|
|
822
|
+
if (collections && collections.length) {
|
|
823
|
+
// Build a fresh input with limit/skip/bookmark restored
|
|
824
|
+
const segregatedInput = { ...rawInput };
|
|
825
|
+
if (limit)
|
|
826
|
+
segregatedInput.limit = limit;
|
|
827
|
+
if (skip)
|
|
828
|
+
segregatedInput.skip = skip;
|
|
829
|
+
if (bookmark)
|
|
830
|
+
segregatedInput["bookmark"] = bookmark;
|
|
831
|
+
const segregated = [];
|
|
832
|
+
for (const collection of collections) {
|
|
833
|
+
log.debug(`Querying from ${collection}`);
|
|
834
|
+
const fromCols = await this.forPrivate(collection).raw({ ...segregatedInput }, false, true, ...ctxArgs);
|
|
835
|
+
log.verbose(`received ${fromCols.length} from ${collection}`);
|
|
836
|
+
segregated.push(fromCols);
|
|
837
|
+
}
|
|
838
|
+
if (paginationActive) {
|
|
839
|
+
// For paginated flows, keep source selection deterministic so
|
|
840
|
+
// externally generated opaque bookmarks stay valid across pages.
|
|
841
|
+
if (fullySegregated) {
|
|
842
|
+
resp = segregated[0] || resp;
|
|
843
|
+
}
|
|
844
|
+
else if (!resp.docs?.length && segregated.length) {
|
|
845
|
+
// Preserve public-state priority for mixed models, but allow a
|
|
846
|
+
// stable fallback when public query returns no docs.
|
|
847
|
+
resp = segregated[0];
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
// Non-paginated reads can still prefer the richest response.
|
|
852
|
+
resp = segregated.reduce((acc, curr) => {
|
|
853
|
+
if (!acc)
|
|
854
|
+
return curr;
|
|
855
|
+
if (curr.docs && curr.docs.length >= acc?.docs.length)
|
|
856
|
+
return curr;
|
|
857
|
+
return acc;
|
|
858
|
+
}, resp);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
if (docsOnly) {
|
|
862
|
+
return resp.docs;
|
|
863
|
+
}
|
|
864
|
+
return resp;
|
|
865
|
+
}
|
|
866
|
+
async view(
|
|
867
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
868
|
+
ddoc,
|
|
869
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
870
|
+
viewName,
|
|
871
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
872
|
+
options,
|
|
873
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
874
|
+
..._args) {
|
|
875
|
+
throw new core_1.UnsupportedError("Fabric contracts do not support CouchDB views.");
|
|
876
|
+
}
|
|
877
|
+
Statement(overrides) {
|
|
878
|
+
return new FabricContractStatement_1.FabricStatement(this, overrides);
|
|
879
|
+
}
|
|
880
|
+
async updateAll(tableName, id, model, ...args) {
|
|
881
|
+
if (id.length !== model.length)
|
|
882
|
+
throw new db_decorators_1.InternalError("Ids and models must have the same length");
|
|
883
|
+
const { log, ctxArgs } = this.logCtx(args, this.updateAll);
|
|
884
|
+
const tableLabel = decorator_validation_1.Model.tableName(tableName);
|
|
885
|
+
log.debug(`Updating ${id.length} entries ${tableLabel} table`);
|
|
886
|
+
return Promise.all(id.map((i, count) => this.update(tableName, i, model[count], ...ctxArgs)));
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
*
|
|
890
|
+
* @param model
|
|
891
|
+
* @param {string} pk
|
|
892
|
+
* @param args
|
|
893
|
+
*/
|
|
894
|
+
prepare(model, ...args) {
|
|
895
|
+
const { log, ctx } = this.logCtx(args, this.prepare);
|
|
896
|
+
const split = decorator_validation_1.Model.segregate(model);
|
|
897
|
+
const tableName = decorator_validation_1.Model.tableName(model.constructor);
|
|
898
|
+
const pk = decorator_validation_1.Model.pk(model.constructor);
|
|
899
|
+
const id = model[pk];
|
|
900
|
+
const isMirror = ctx.getOrUndefined("mirror");
|
|
901
|
+
const mapToRecord = function (obj, keysOverride) {
|
|
902
|
+
if (keysOverride)
|
|
903
|
+
keysOverride = [...new Set([...keysOverride, pk])];
|
|
904
|
+
const result = Object.entries(obj).reduce((accum, [key, val]) => {
|
|
905
|
+
if (typeof val === "undefined")
|
|
906
|
+
return accum;
|
|
907
|
+
if (keysOverride && !keysOverride.includes(key))
|
|
908
|
+
return accum;
|
|
909
|
+
const mappedProp = decorator_validation_1.Model.columnName(model, key);
|
|
910
|
+
if (this.isReserved(mappedProp))
|
|
911
|
+
throw new db_decorators_1.InternalError(`Property name ${mappedProp} is reserved`);
|
|
912
|
+
val = val instanceof Date ? new Date(val) : val;
|
|
913
|
+
accum[mappedProp] = val;
|
|
914
|
+
return accum;
|
|
915
|
+
}, {});
|
|
916
|
+
if (Object.keys(result).filter((k) => Boolean(result[k])).length) {
|
|
917
|
+
// Add table identifier
|
|
918
|
+
result[for_couchdb_1.CouchDBKeys.TABLE] = tableName;
|
|
919
|
+
}
|
|
920
|
+
return result;
|
|
921
|
+
}.bind(this);
|
|
922
|
+
log.silly(`Preparing record for ${tableName} table with pk ${model[pk]}`);
|
|
923
|
+
const segregatedWriteKeys = ctx.getSegregatedWrites();
|
|
924
|
+
const segregatedWrites = {};
|
|
925
|
+
// Only apply segregated writes when the current model actually has a transient split.
|
|
926
|
+
// The same FabricContractContext can be reused across nested operations (for example
|
|
927
|
+
// sequence upserts during persistent version generation). In those cases, we must not
|
|
928
|
+
// attempt to apply parent-model segregated write keys to unrelated models.
|
|
929
|
+
if (segregatedWriteKeys && split.transient && typeof split.transient === "object") {
|
|
930
|
+
for (const collection in segregatedWriteKeys) {
|
|
931
|
+
segregatedWrites[collection] = segregatedWrites[collection] || {};
|
|
932
|
+
segregatedWrites[collection][id] = mapToRecord(ctx.getOrUndefined("forceSegregateWrite")
|
|
933
|
+
? split.model
|
|
934
|
+
: (split.transient || {}), segregatedWriteKeys[collection]);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
// In mirror mode, the record should contain ALL model properties (full copy)
|
|
938
|
+
const record = isMirror ? mapToRecord(model) : mapToRecord(split.model);
|
|
939
|
+
return {
|
|
940
|
+
record,
|
|
941
|
+
id: model[pk],
|
|
942
|
+
transient: !isMirror && split.transient && Object.keys(split.transient).length
|
|
943
|
+
? mapToRecord(split.transient)
|
|
944
|
+
: undefined,
|
|
945
|
+
segregated: isMirror ? undefined : segregatedWrites,
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
revert(obj, clazz, id, transient, ...args) {
|
|
949
|
+
const { log, ctx } = this.logCtx(args, this.revert);
|
|
950
|
+
const ob = {};
|
|
951
|
+
const pk = decorator_validation_1.Model.pk(clazz);
|
|
952
|
+
const pkProps = decorator_validation_1.Model.pkProps(clazz);
|
|
953
|
+
if (pkProps?.type === Number && typeof id === "string") {
|
|
954
|
+
id = Number(id);
|
|
955
|
+
}
|
|
956
|
+
ob[pk] = id;
|
|
957
|
+
log.silly(`Rebuilding model ${clazz.name} id ${id}`);
|
|
958
|
+
function mapToModel(r) {
|
|
959
|
+
const m = (typeof clazz === "string" ? decorator_validation_1.Model.build(ob, clazz) : new clazz(ob));
|
|
960
|
+
const attributes = decorator_validation_1.Model.getAttributes(clazz);
|
|
961
|
+
const keys = attributes.length ? attributes : Object.keys(m);
|
|
962
|
+
return keys
|
|
963
|
+
.filter((k) => k !== pk)
|
|
964
|
+
.reduce((accum, key) => {
|
|
965
|
+
accum[key] =
|
|
966
|
+
r[decorator_validation_1.Model.columnName(accum, key)];
|
|
967
|
+
return accum;
|
|
968
|
+
}, m);
|
|
969
|
+
}
|
|
970
|
+
let result = mapToModel(obj);
|
|
971
|
+
if (transient && !this.shouldRebuildWithTransient(ctx)) {
|
|
972
|
+
log.debug(`filtering transient properties: ${Object.keys(transient).join(", ")}`);
|
|
973
|
+
result = Object.entries(result).reduce((acc, [key, v]) => {
|
|
974
|
+
if (key === pk || !(key in transient)) {
|
|
975
|
+
acc[key] = v;
|
|
976
|
+
}
|
|
977
|
+
return acc;
|
|
978
|
+
}, new clazz());
|
|
979
|
+
}
|
|
980
|
+
return result;
|
|
981
|
+
}
|
|
982
|
+
shouldRebuildWithTransient(ctx) {
|
|
983
|
+
if (!ctx)
|
|
984
|
+
return false;
|
|
985
|
+
if (ctx.getOrUndefined("rebuildWithTransient"))
|
|
986
|
+
return true;
|
|
987
|
+
const operation = ctx.getOrUndefined("operation");
|
|
988
|
+
if (!operation)
|
|
989
|
+
return true;
|
|
990
|
+
const op = operation.toString().toLowerCase();
|
|
991
|
+
return !core_1.TransactionOperationKeys.map((k) => k.toLowerCase()).includes(op);
|
|
992
|
+
}
|
|
993
|
+
getContextMsp(context) {
|
|
994
|
+
const identity = context.get("identity");
|
|
995
|
+
if (!identity)
|
|
996
|
+
return undefined;
|
|
997
|
+
if (typeof identity === "string")
|
|
998
|
+
return identity;
|
|
999
|
+
try {
|
|
1000
|
+
return identity.getMSPID();
|
|
1001
|
+
}
|
|
1002
|
+
catch {
|
|
1003
|
+
return undefined;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
enforceMirrorAuthorization(clazz, ctx) {
|
|
1007
|
+
const mirrorMeta = decorator_validation_1.Model.mirroredAt(clazz);
|
|
1008
|
+
if (!mirrorMeta)
|
|
1009
|
+
return;
|
|
1010
|
+
const msp = this.getContextMsp(ctx);
|
|
1011
|
+
if (!msp)
|
|
1012
|
+
return;
|
|
1013
|
+
if (msp === mirrorMeta.mspId ||
|
|
1014
|
+
(mirrorMeta.condition && mirrorMeta.condition(msp))) {
|
|
1015
|
+
throw new core_1.AuthorizationError(`Organization ${msp} is not authorized to modify mirrored data`);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
createPrefix(tableName, id, model, ...args) {
|
|
1019
|
+
const { ctxArgs } = this.logCtx(args, this.createPrefix);
|
|
1020
|
+
const record = {};
|
|
1021
|
+
record[for_couchdb_1.CouchDBKeys.TABLE] = decorator_validation_1.Model.tableName(tableName);
|
|
1022
|
+
Object.assign(record, model);
|
|
1023
|
+
return [tableName, id, record, ...ctxArgs];
|
|
1024
|
+
}
|
|
1025
|
+
updatePrefix(tableName, id, model, ...args) {
|
|
1026
|
+
const { ctxArgs } = this.logCtx(args, this.updatePrefix);
|
|
1027
|
+
const record = {};
|
|
1028
|
+
record[for_couchdb_1.CouchDBKeys.TABLE] = decorator_validation_1.Model.tableName(tableName);
|
|
1029
|
+
Object.assign(record, model);
|
|
1030
|
+
return [tableName, id, record, ...ctxArgs];
|
|
1031
|
+
}
|
|
1032
|
+
createAllPrefix(tableName, ids, models, ...args) {
|
|
1033
|
+
if (ids.length !== models.length)
|
|
1034
|
+
throw new db_decorators_1.InternalError("Ids and models must have the same length");
|
|
1035
|
+
const ctx = args.pop();
|
|
1036
|
+
const records = ids.map((id, count) => {
|
|
1037
|
+
const record = {};
|
|
1038
|
+
record[for_couchdb_1.CouchDBKeys.TABLE] = decorator_validation_1.Model.tableName(tableName);
|
|
1039
|
+
Object.assign(record, models[count]);
|
|
1040
|
+
return record;
|
|
1041
|
+
});
|
|
1042
|
+
return [tableName, ids, records, ctx];
|
|
1043
|
+
}
|
|
1044
|
+
updateAllPrefix(tableName, ids, models, ...args) {
|
|
1045
|
+
if (ids.length !== models.length)
|
|
1046
|
+
throw new db_decorators_1.InternalError("Ids and models must have the same length");
|
|
1047
|
+
const ctx = args.pop();
|
|
1048
|
+
const records = ids.map((id, count) => {
|
|
1049
|
+
const record = {};
|
|
1050
|
+
record[for_couchdb_1.CouchDBKeys.TABLE] = decorator_validation_1.Model.tableName(tableName);
|
|
1051
|
+
Object.assign(record, models[count]);
|
|
1052
|
+
return record;
|
|
1053
|
+
});
|
|
1054
|
+
return [tableName, ids, records, ctx];
|
|
1055
|
+
}
|
|
1056
|
+
parseError(err, reason) {
|
|
1057
|
+
return FabricContractAdapter.parseError(reason || err);
|
|
1058
|
+
}
|
|
1059
|
+
logCtx(args, operation, allowCreate = false, overrides) {
|
|
1060
|
+
if (!allowCreate)
|
|
1061
|
+
return super.logCtx(args, operation, allowCreate, overrides);
|
|
1062
|
+
return super.logCtx
|
|
1063
|
+
.call(this, args, operation, allowCreate, overrides)
|
|
1064
|
+
.then((res) => {
|
|
1065
|
+
if (!(res.ctx instanceof ContractContext_1.FabricContractContext))
|
|
1066
|
+
throw new db_decorators_1.InternalError(`Invalid context binding`);
|
|
1067
|
+
return Object.assign(res, {
|
|
1068
|
+
stub: res.ctx.stub,
|
|
1069
|
+
identity: res.ctx.identity,
|
|
1070
|
+
});
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
async updateObservers(table, event, id, ...args) {
|
|
1074
|
+
if (!this.observerHandler)
|
|
1075
|
+
throw new db_decorators_1.InternalError("ObserverHandler not initialized. Did you register any observables?");
|
|
1076
|
+
const { ctx, ctxArgs } = this.logCtx(args, this.updateObservers);
|
|
1077
|
+
if (ctx.isFullySegregated)
|
|
1078
|
+
return;
|
|
1079
|
+
if (ctx.getOrUndefined("noEmit"))
|
|
1080
|
+
return;
|
|
1081
|
+
if (!ctx.stub)
|
|
1082
|
+
return;
|
|
1083
|
+
const isBulk = Array.isArray(id);
|
|
1084
|
+
const emitSingle = !ctx.getOrUndefined("noEmitSingle");
|
|
1085
|
+
const emitBulk = !ctx.getOrUndefined("noEmitBulk");
|
|
1086
|
+
if ((isBulk && emitBulk) || (!isBulk && emitSingle)) {
|
|
1087
|
+
// Pass the MSP owner from stub and the result payload (if any) in the
|
|
1088
|
+
// positions the handler expects: (table, event, id, owner?, payload?, ctx)
|
|
1089
|
+
const mspId = ctx.stub.getMspID ? ctx.stub.getMspID() : undefined;
|
|
1090
|
+
const nonCtxArgs = ctxArgs.slice(0, -1); // everything before ctx
|
|
1091
|
+
const payload = nonCtxArgs.length > 0 ? nonCtxArgs[0] : undefined;
|
|
1092
|
+
await this.observerHandler.updateObservers(table, event, id, mspId, payload, ctx);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
static parseError(err) {
|
|
1096
|
+
// if (
|
|
1097
|
+
// MISSING_PRIVATE_DATA_REGEX.test(
|
|
1098
|
+
// typeof err === "string" ? err : err.message
|
|
1099
|
+
// )
|
|
1100
|
+
// )
|
|
1101
|
+
// return new UnauthorizedPrivateDataAccess(err) as E;
|
|
1102
|
+
const msg = typeof err === "string" ? err : err.message;
|
|
1103
|
+
if (msg.includes(db_decorators_1.NotFoundError.name))
|
|
1104
|
+
return new db_decorators_1.NotFoundError(err);
|
|
1105
|
+
if (msg.includes(db_decorators_1.ConflictError.name))
|
|
1106
|
+
return new db_decorators_1.ConflictError(err);
|
|
1107
|
+
if (msg.includes(db_decorators_1.BadRequestError.name))
|
|
1108
|
+
return new db_decorators_1.BadRequestError(err);
|
|
1109
|
+
if (msg.includes(core_1.QueryError.name))
|
|
1110
|
+
return new core_1.QueryError(err);
|
|
1111
|
+
if (msg.includes(core_1.PagingError.name))
|
|
1112
|
+
return new core_1.PagingError(err);
|
|
1113
|
+
if (msg.includes(core_1.UnsupportedError.name))
|
|
1114
|
+
return new core_1.UnsupportedError(err);
|
|
1115
|
+
if (msg.includes(core_1.MigrationError.name))
|
|
1116
|
+
return new core_1.MigrationError(err);
|
|
1117
|
+
if (msg.includes(core_1.ObserverError.name))
|
|
1118
|
+
return new core_1.ObserverError(err);
|
|
1119
|
+
if (msg.includes(core_1.AuthorizationError.name))
|
|
1120
|
+
return new core_1.AuthorizationError(err);
|
|
1121
|
+
if (msg.includes(core_1.ForbiddenError.name))
|
|
1122
|
+
return new core_1.ForbiddenError(err);
|
|
1123
|
+
if (msg.includes(core_1.ConnectionError.name))
|
|
1124
|
+
return new core_1.ConnectionError(err);
|
|
1125
|
+
if (msg.includes(db_decorators_1.SerializationError.name))
|
|
1126
|
+
return new db_decorators_1.SerializationError(err);
|
|
1127
|
+
if (msg.includes("no ledger context"))
|
|
1128
|
+
return new errors_1.MissingContextError(`No context found. this can be caused by debugging: ${msg}`);
|
|
1129
|
+
return new db_decorators_1.InternalError(err);
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* @description Static method for decoration overrides
|
|
1133
|
+
* @summary Overrides/extends decaf decoration with Fabric-specific functionality
|
|
1134
|
+
* @static
|
|
1135
|
+
* @override
|
|
1136
|
+
* @return {void}
|
|
1137
|
+
*/
|
|
1138
|
+
static decoration() {
|
|
1139
|
+
super.decoration();
|
|
1140
|
+
decoration_1.Decoration.flavouredAs(constants_1.FabricFlavour)
|
|
1141
|
+
.for(core_1.PersistenceKeys.CREATED_BY)
|
|
1142
|
+
.define({
|
|
1143
|
+
decorator: function createdBy() {
|
|
1144
|
+
return (0, decoration_1.apply)((0, db_decorators_1.onCreate)(createdByOnFabricCreateUpdate), (0, decoration_1.propMetadata)(core_1.PersistenceKeys.CREATED_BY, {}));
|
|
1145
|
+
},
|
|
1146
|
+
})
|
|
1147
|
+
.apply();
|
|
1148
|
+
decoration_1.Decoration.flavouredAs(constants_1.FabricFlavour)
|
|
1149
|
+
.for(core_1.PersistenceKeys.UPDATED_BY)
|
|
1150
|
+
.define({
|
|
1151
|
+
decorator: function createdBy() {
|
|
1152
|
+
return (0, decoration_1.apply)((0, db_decorators_1.onCreateUpdate)(createdByOnFabricCreateUpdate), (0, decoration_1.propMetadata)(core_1.PersistenceKeys.UPDATED_BY, {}));
|
|
1153
|
+
},
|
|
1154
|
+
})
|
|
1155
|
+
.apply();
|
|
1156
|
+
decoration_1.Decoration.flavouredAs(constants_1.FabricFlavour)
|
|
1157
|
+
.for(core_1.PersistenceKeys.COLUMN)
|
|
1158
|
+
.extend((0, fabric_contract_api_1.Property)())
|
|
1159
|
+
.apply();
|
|
1160
|
+
decoration_1.Decoration.flavouredAs(constants_1.FabricFlavour)
|
|
1161
|
+
.for(decorator_validation_1.ValidationKeys.DATE)
|
|
1162
|
+
.extend(function fabricProperty() {
|
|
1163
|
+
return (target, prop) => {
|
|
1164
|
+
(0, fabric_contract_api_1.Property)(prop, "string:date")(target, prop);
|
|
1165
|
+
};
|
|
1166
|
+
});
|
|
1167
|
+
decoration_1.Decoration.flavouredAs(constants_1.FabricFlavour)
|
|
1168
|
+
.for(core_1.PersistenceKeys.TABLE)
|
|
1169
|
+
.extend(function table(obj) {
|
|
1170
|
+
const chain = [];
|
|
1171
|
+
let current = typeof obj === "function"
|
|
1172
|
+
? decoration_1.Metadata.constr(obj)
|
|
1173
|
+
: decoration_1.Metadata.constr(obj.constructor);
|
|
1174
|
+
while (current && current !== Object && current.prototype) {
|
|
1175
|
+
chain.push(current);
|
|
1176
|
+
current = Object.getPrototypeOf(current);
|
|
1177
|
+
}
|
|
1178
|
+
console.log(chain.map((c) => c.name || c));
|
|
1179
|
+
// Apply from the base class down to the decorated class
|
|
1180
|
+
while (chain.length > 0) {
|
|
1181
|
+
const constructor = chain.pop();
|
|
1182
|
+
console.log(`Calling on ${constructor.name}`);
|
|
1183
|
+
(0, fabric_contract_api_1.Object)()(constructor);
|
|
1184
|
+
}
|
|
1185
|
+
return (0, fabric_contract_api_1.Object)()(obj);
|
|
1186
|
+
})
|
|
1187
|
+
.apply();
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
exports.FabricContractAdapter = FabricContractAdapter;
|
|
1191
|
+
FabricContractAdapter.decoration();
|
|
1192
|
+
core_1.Adapter.setCurrent(constants_1.FabricFlavour);
|
|
1193
|
+
//# sourceMappingURL=ContractAdapter.js.map
|