@decaf-ts/for-fabric 0.9.0 → 0.10.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/lib/cjs/bin/cli.cjs +3 -2
- package/lib/cjs/bin/cli.cjs.map +1 -0
- package/lib/cjs/cli-module.cjs +26 -25
- package/lib/cjs/cli-module.cjs.map +1 -0
- package/lib/cjs/cli-utils.cjs +5 -5
- package/lib/cjs/cli-utils.cjs.map +1 -0
- package/lib/cjs/client/FabricClientAdapter.cjs +46 -40
- package/lib/cjs/client/FabricClientAdapter.cjs.map +1 -0
- package/lib/cjs/client/FabricClientDispatch.cjs +8 -7
- package/lib/cjs/client/FabricClientDispatch.cjs.map +1 -0
- package/lib/cjs/client/FabricClientPaginator.cjs +1 -0
- package/lib/cjs/client/FabricClientPaginator.cjs.map +1 -0
- package/lib/cjs/client/FabricClientRepository.cjs +4 -3
- package/lib/cjs/client/FabricClientRepository.cjs.map +1 -0
- package/lib/cjs/client/FabricClientStatement.cjs +1 -0
- package/lib/cjs/client/FabricClientStatement.cjs.map +1 -0
- package/lib/cjs/client/collections/generation.cjs +3 -2
- package/lib/cjs/client/collections/generation.cjs.map +1 -0
- package/lib/cjs/client/collections/index.cjs +1 -0
- package/lib/cjs/client/collections/index.cjs.map +1 -0
- package/lib/cjs/client/constants.cjs +1 -0
- package/lib/cjs/client/constants.cjs.map +1 -0
- package/lib/cjs/client/crypto.cjs +12 -13
- package/lib/cjs/client/crypto.cjs.map +1 -0
- package/lib/cjs/client/erc20/FabricERC20ClientRepository.cjs +7 -6
- package/lib/cjs/client/erc20/FabricERC20ClientRepository.cjs.map +1 -0
- package/lib/cjs/client/erc20/index.cjs +1 -0
- package/lib/cjs/client/erc20/index.cjs.map +1 -0
- package/lib/cjs/client/fabric-fs.cjs +1 -0
- package/lib/cjs/client/fabric-fs.cjs.map +1 -0
- package/lib/cjs/client/fabric-hsm.cjs +3 -2
- package/lib/cjs/client/fabric-hsm.cjs.map +1 -0
- package/lib/cjs/client/ids/id-extraction.cjs +1 -0
- package/lib/cjs/client/ids/id-extraction.cjs.map +1 -0
- package/lib/cjs/client/ids/index.cjs +1 -0
- package/lib/cjs/client/ids/index.cjs.map +1 -0
- package/lib/cjs/client/index.cjs +10 -9
- package/lib/cjs/client/index.cjs.map +1 -0
- package/lib/cjs/client/indexes/generation.cjs +1 -0
- package/lib/cjs/client/indexes/generation.cjs.map +1 -0
- package/lib/cjs/client/indexes/index.cjs +1 -0
- package/lib/cjs/client/indexes/index.cjs.map +1 -0
- package/lib/cjs/client/logging.cjs +1 -0
- package/lib/cjs/client/logging.cjs.map +1 -0
- package/lib/cjs/client/services/FabricEnrollmentService.cjs +17 -32
- package/lib/cjs/client/services/FabricEnrollmentService.cjs.map +1 -0
- package/lib/cjs/client/services/FabricIdentityService.cjs +15 -14
- package/lib/cjs/client/services/FabricIdentityService.cjs.map +1 -0
- package/lib/cjs/client/services/RegistrationRequestBuilder.cjs +11 -5
- package/lib/cjs/client/services/RegistrationRequestBuilder.cjs.map +1 -0
- package/lib/cjs/client/services/constants.cjs +2 -9
- package/lib/cjs/client/services/constants.cjs.map +1 -0
- package/lib/cjs/client/services/index.cjs +1 -0
- package/lib/cjs/client/services/index.cjs.map +1 -0
- package/lib/cjs/client/types.cjs +1 -0
- package/lib/cjs/client/types.cjs.map +1 -0
- package/lib/cjs/client/utils.cjs +1 -0
- package/lib/cjs/client/utils.cjs.map +1 -0
- package/lib/cjs/contract/Address.cjs +14 -8
- package/lib/cjs/contract/Address.cjs.map +1 -0
- package/lib/cjs/contract/AddressContract.cjs +15 -9
- package/lib/cjs/contract/AddressContract.cjs.map +1 -0
- package/lib/cjs/contract/AuditContract.cjs +15 -9
- package/lib/cjs/contract/AuditContract.cjs.map +1 -0
- package/lib/cjs/contract/BatchContract.cjs +15 -9
- package/lib/cjs/contract/BatchContract.cjs.map +1 -0
- package/lib/cjs/contract/MarketContract.cjs +15 -9
- package/lib/cjs/contract/MarketContract.cjs.map +1 -0
- package/lib/cjs/contract/OtherAuditContract.cjs +15 -9
- package/lib/cjs/contract/OtherAuditContract.cjs.map +1 -0
- package/lib/cjs/contract/OtherBatchContract.cjs +15 -9
- package/lib/cjs/contract/OtherBatchContract.cjs.map +1 -0
- package/lib/cjs/contract/OtherMarketContract.cjs +15 -9
- package/lib/cjs/contract/OtherMarketContract.cjs.map +1 -0
- package/lib/cjs/contract/OtherProductContract.cjs +15 -9
- package/lib/cjs/contract/OtherProductContract.cjs.map +1 -0
- package/lib/cjs/contract/OtherProductImageContract.cjs +15 -9
- package/lib/cjs/contract/OtherProductImageContract.cjs.map +1 -0
- package/lib/cjs/contract/OtherProductSharedContract.cjs +15 -9
- package/lib/cjs/contract/OtherProductSharedContract.cjs.map +1 -0
- package/lib/cjs/contract/OtherProductStrengthContract.cjs +15 -9
- package/lib/cjs/contract/OtherProductStrengthContract.cjs.map +1 -0
- package/lib/cjs/contract/Product.cjs +15 -9
- package/lib/cjs/contract/Product.cjs.map +1 -0
- package/lib/cjs/contract/ProductContract.cjs +15 -9
- package/lib/cjs/contract/ProductContract.cjs.map +1 -0
- package/lib/cjs/contract/ProductStrengthContract.cjs +15 -9
- package/lib/cjs/contract/ProductStrengthContract.cjs.map +1 -0
- package/lib/cjs/contract/SegregatedPrivateDocumentContract.cjs +15 -9
- package/lib/cjs/contract/SegregatedPrivateDocumentContract.cjs.map +1 -0
- package/lib/cjs/contract/SegregatedSharedDocumentContract.cjs +15 -9
- package/lib/cjs/contract/SegregatedSharedDocumentContract.cjs.map +1 -0
- package/lib/cjs/contract/User.cjs +13 -7
- package/lib/cjs/contract/User.cjs.map +1 -0
- package/lib/cjs/contract/UserContract.cjs +15 -9
- package/lib/cjs/contract/UserContract.cjs.map +1 -0
- package/lib/cjs/contract/index.cjs +31 -30
- package/lib/cjs/contract/index.cjs.map +1 -0
- package/lib/cjs/contract/logging-context.cjs +1 -0
- package/lib/cjs/contract/logging-context.cjs.map +1 -0
- package/lib/cjs/contract/models/Audit.cjs +17 -11
- package/lib/cjs/contract/models/Audit.cjs.map +1 -0
- package/lib/cjs/contract/models/BaseIdentifiedModel.cjs +15 -9
- package/lib/cjs/contract/models/BaseIdentifiedModel.cjs.map +1 -0
- package/lib/cjs/contract/models/BaseModel.cjs +13 -7
- package/lib/cjs/contract/models/BaseModel.cjs.map +1 -0
- package/lib/cjs/contract/models/Batch.cjs +24 -18
- package/lib/cjs/contract/models/Batch.cjs.map +1 -0
- package/lib/cjs/contract/models/GtinOwner.cjs +18 -12
- package/lib/cjs/contract/models/GtinOwner.cjs.map +1 -0
- package/lib/cjs/contract/models/History.cjs +15 -9
- package/lib/cjs/contract/models/History.cjs.map +1 -0
- package/lib/cjs/contract/models/Leaflet.cjs +25 -19
- package/lib/cjs/contract/models/Leaflet.cjs.map +1 -0
- package/lib/cjs/contract/models/LeafletFile.cjs +19 -13
- package/lib/cjs/contract/models/LeafletFile.cjs.map +1 -0
- package/lib/cjs/contract/models/Market.cjs +19 -13
- package/lib/cjs/contract/models/Market.cjs.map +1 -0
- package/lib/cjs/contract/models/OtherAudit.cjs +20 -14
- package/lib/cjs/contract/models/OtherAudit.cjs.map +1 -0
- package/lib/cjs/contract/models/OtherBatchShared.cjs +27 -21
- package/lib/cjs/contract/models/OtherBatchShared.cjs.map +1 -0
- package/lib/cjs/contract/models/OtherLeaflet.cjs +27 -21
- package/lib/cjs/contract/models/OtherLeaflet.cjs.map +1 -0
- package/lib/cjs/contract/models/OtherLeafletFile.cjs +18 -12
- package/lib/cjs/contract/models/OtherLeafletFile.cjs.map +1 -0
- package/lib/cjs/contract/models/OtherMarket.cjs +21 -15
- package/lib/cjs/contract/models/OtherMarket.cjs.map +1 -0
- package/lib/cjs/contract/models/OtherProduct.cjs +24 -18
- package/lib/cjs/contract/models/OtherProduct.cjs.map +1 -0
- package/lib/cjs/contract/models/OtherProductImage.cjs +22 -16
- package/lib/cjs/contract/models/OtherProductImage.cjs.map +1 -0
- package/lib/cjs/contract/models/OtherProductShared.cjs +32 -26
- package/lib/cjs/contract/models/OtherProductShared.cjs.map +1 -0
- package/lib/cjs/contract/models/OtherProductStrength.cjs +21 -15
- package/lib/cjs/contract/models/OtherProductStrength.cjs.map +1 -0
- package/lib/cjs/contract/models/Product.cjs +24 -18
- package/lib/cjs/contract/models/Product.cjs.map +1 -0
- package/lib/cjs/contract/models/ProductStrength.cjs +19 -13
- package/lib/cjs/contract/models/ProductStrength.cjs.map +1 -0
- package/lib/cjs/contract/models/SegregatedDocument.cjs +23 -17
- package/lib/cjs/contract/models/SegregatedDocument.cjs.map +1 -0
- package/lib/cjs/contract/models/constants.cjs +3 -4
- package/lib/cjs/contract/models/constants.cjs.map +1 -0
- package/lib/cjs/contract/models/decorators-private.cjs +11 -10
- package/lib/cjs/contract/models/decorators-private.cjs.map +1 -0
- package/lib/cjs/contract/models/decorators.cjs +13 -12
- package/lib/cjs/contract/models/decorators.cjs.map +1 -0
- package/lib/cjs/contract/models/gtin.cjs +13 -7
- package/lib/cjs/contract/models/gtin.cjs.map +1 -0
- package/lib/cjs/contract/models/history-dec.cjs +11 -10
- package/lib/cjs/contract/models/history-dec.cjs.map +1 -0
- package/lib/cjs/contracts/ContractAdapter.cjs +27 -26
- package/lib/cjs/contracts/ContractAdapter.cjs.map +1 -0
- package/lib/cjs/contracts/ContractContext.cjs +1 -0
- package/lib/cjs/contracts/ContractContext.cjs.map +1 -0
- package/lib/cjs/contracts/FabricContractDispatch.cjs +1 -0
- package/lib/cjs/contracts/FabricContractDispatch.cjs.map +1 -0
- package/lib/cjs/contracts/FabricContractPaginator.cjs +5 -4
- package/lib/cjs/contracts/FabricContractPaginator.cjs.map +1 -0
- package/lib/cjs/contracts/FabricContractRepository.cjs +8 -7
- package/lib/cjs/contracts/FabricContractRepository.cjs.map +1 -0
- package/lib/cjs/contracts/FabricContractRepositoryObservableHandler.cjs +3 -2
- package/lib/cjs/contracts/FabricContractRepositoryObservableHandler.cjs.map +1 -0
- package/lib/cjs/contracts/FabricContractSequence.cjs +1 -0
- package/lib/cjs/contracts/FabricContractSequence.cjs.map +1 -0
- package/lib/cjs/contracts/FabricContractStatement.cjs +5 -4
- package/lib/cjs/contracts/FabricContractStatement.cjs.map +1 -0
- package/lib/cjs/contracts/MigrationContract.cjs +20 -14
- package/lib/cjs/contracts/MigrationContract.cjs.map +1 -0
- package/lib/cjs/contracts/PrivateSequence.cjs +11 -5
- package/lib/cjs/contracts/PrivateSequence.cjs.map +1 -0
- package/lib/cjs/contracts/auth/decorators.cjs +3 -2
- package/lib/cjs/contracts/auth/decorators.cjs.map +1 -0
- package/lib/cjs/contracts/auth/index.cjs +1 -0
- package/lib/cjs/contracts/auth/index.cjs.map +1 -0
- package/lib/cjs/contracts/crud/crud-contract.cjs +12 -11
- package/lib/cjs/contracts/crud/crud-contract.cjs.map +1 -0
- package/lib/cjs/contracts/crud/index.cjs +1 -0
- package/lib/cjs/contracts/crud/index.cjs.map +1 -0
- package/lib/cjs/contracts/crud/serialized-crud-contract.cjs +13 -7
- package/lib/cjs/contracts/crud/serialized-crud-contract.cjs.map +1 -0
- package/lib/cjs/contracts/erc20/erc20contract.cjs +53 -47
- package/lib/cjs/contracts/erc20/erc20contract.cjs.map +1 -0
- package/lib/cjs/contracts/erc20/index.cjs +3 -2
- package/lib/cjs/contracts/erc20/index.cjs.map +1 -0
- package/lib/cjs/contracts/erc20/models.cjs +11 -5
- package/lib/cjs/contracts/erc20/models.cjs.map +1 -0
- package/lib/cjs/contracts/index.cjs +1 -0
- package/lib/cjs/contracts/index.cjs.map +1 -0
- package/lib/cjs/contracts/logging.cjs +4 -3
- package/lib/cjs/contracts/logging.cjs.map +1 -0
- package/lib/cjs/contracts/overrides.cjs +3 -2
- package/lib/cjs/contracts/overrides.cjs.map +1 -0
- package/lib/cjs/contracts/types.cjs +1 -0
- package/lib/cjs/contracts/types.cjs.map +1 -0
- package/lib/cjs/contracts/uuid.cjs +1 -0
- package/lib/cjs/contracts/uuid.cjs.map +1 -0
- package/lib/cjs/index.cjs +6 -5
- package/lib/cjs/index.cjs.map +1 -0
- package/lib/cjs/shared/ClientSerializer.cjs +1 -0
- package/lib/cjs/shared/ClientSerializer.cjs.map +1 -0
- package/lib/cjs/shared/DeterministicSerializer.cjs +1 -0
- package/lib/cjs/shared/DeterministicSerializer.cjs.map +1 -0
- package/lib/cjs/shared/SimpleDeterministicSerializer.cjs +3 -2
- package/lib/cjs/shared/SimpleDeterministicSerializer.cjs.map +1 -0
- package/lib/cjs/shared/constants.cjs +3 -18
- package/lib/cjs/shared/constants.cjs.map +1 -0
- package/lib/cjs/shared/decorators.cjs +14 -13
- package/lib/cjs/shared/decorators.cjs.map +1 -0
- package/lib/cjs/shared/erc20/erc20-constants.cjs +2 -9
- package/lib/cjs/shared/erc20/erc20-constants.cjs.map +1 -0
- package/lib/cjs/shared/erc20/index.cjs +1 -0
- package/lib/cjs/shared/erc20/index.cjs.map +1 -0
- package/lib/cjs/shared/errors.cjs +1 -0
- package/lib/cjs/shared/errors.cjs.map +1 -0
- package/lib/cjs/shared/events.cjs +1 -0
- package/lib/cjs/shared/events.cjs.map +1 -0
- package/lib/cjs/shared/fabric-types.cjs +1 -0
- package/lib/cjs/shared/fabric-types.cjs.map +1 -0
- package/lib/cjs/shared/index.cjs +1 -0
- package/lib/cjs/shared/index.cjs.map +1 -0
- package/lib/cjs/shared/interfaces/Checkable.cjs +1 -0
- package/lib/cjs/shared/interfaces/Checkable.cjs.map +1 -0
- package/lib/cjs/shared/interfaces/index.cjs +1 -0
- package/lib/cjs/shared/interfaces/index.cjs.map +1 -0
- package/lib/cjs/shared/math.cjs +4 -3
- package/lib/cjs/shared/math.cjs.map +1 -0
- package/lib/cjs/shared/model/FabricBaseModel.cjs +13 -7
- package/lib/cjs/shared/model/FabricBaseModel.cjs.map +1 -0
- package/lib/cjs/shared/model/FabricIdentifiedBaseModel.cjs +15 -9
- package/lib/cjs/shared/model/FabricIdentifiedBaseModel.cjs.map +1 -0
- package/lib/cjs/shared/model/Identity.cjs +16 -10
- package/lib/cjs/shared/model/Identity.cjs.map +1 -0
- package/lib/cjs/shared/model/IdentityCredentials.cjs +11 -5
- package/lib/cjs/shared/model/IdentityCredentials.cjs.map +1 -0
- package/lib/cjs/shared/model/index.cjs +1 -0
- package/lib/cjs/shared/model/index.cjs.map +1 -0
- package/lib/cjs/shared/overrides/Model.cjs +1 -0
- package/lib/cjs/shared/overrides/Model.cjs.map +1 -0
- package/lib/cjs/shared/overrides/index.cjs +1 -0
- package/lib/cjs/shared/overrides/index.cjs.map +1 -0
- package/lib/cjs/shared/overrides/overrides.cjs +11 -10
- package/lib/cjs/shared/overrides/overrides.cjs.map +1 -0
- package/lib/cjs/shared/types.cjs +1 -0
- package/lib/cjs/shared/types.cjs.map +1 -0
- package/lib/cjs/version.cjs +2 -1
- package/lib/cjs/version.cjs.map +1 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/bin/cli.d.cts +1 -0
- package/lib/types/bin/cli.d.mts +1 -0
- package/lib/types/cli-module.d.cts +3 -0
- package/lib/types/cli-module.d.mts +3 -0
- package/lib/types/cli-utils.d.cts +21 -0
- package/lib/types/cli-utils.d.mts +21 -0
- package/lib/types/client/FabricClientAdapter.d.cts +404 -0
- package/lib/types/client/FabricClientAdapter.d.mts +404 -0
- package/lib/types/client/FabricClientDispatch.d.cts +133 -0
- package/lib/types/client/FabricClientDispatch.d.mts +133 -0
- package/lib/types/client/FabricClientPaginator.d.cts +12 -0
- package/lib/types/client/FabricClientPaginator.d.mts +12 -0
- package/lib/types/client/FabricClientRepository.d.cts +71 -0
- package/lib/types/client/FabricClientRepository.d.mts +71 -0
- package/lib/types/client/FabricClientStatement.d.cts +64 -0
- package/lib/types/client/FabricClientStatement.d.mts +64 -0
- package/lib/types/client/collections/generation.d.cts +46 -0
- package/lib/types/client/collections/generation.d.mts +46 -0
- package/lib/types/client/collections/index.d.cts +1 -0
- package/lib/types/client/collections/index.d.mts +1 -0
- package/lib/types/client/constants.d.cts +2 -0
- package/lib/types/client/constants.d.mts +2 -0
- package/lib/types/client/crypto.d.cts +107 -0
- package/lib/types/client/crypto.d.mts +107 -0
- package/lib/types/client/erc20/FabricERC20ClientRepository.d.cts +254 -0
- package/lib/types/client/erc20/FabricERC20ClientRepository.d.mts +254 -0
- package/lib/types/client/erc20/index.d.cts +1 -0
- package/lib/types/client/erc20/index.d.mts +1 -0
- package/lib/types/client/fabric-fs.d.cts +92 -0
- package/lib/types/client/fabric-fs.d.mts +92 -0
- package/lib/types/client/fabric-hsm.d.cts +24 -0
- package/lib/types/client/fabric-hsm.d.mts +24 -0
- package/lib/types/client/ids/id-extraction.d.cts +4 -0
- package/lib/types/client/ids/id-extraction.d.mts +4 -0
- package/lib/types/client/ids/index.d.cts +1 -0
- package/lib/types/client/ids/index.d.mts +1 -0
- package/lib/types/client/index.d.cts +23 -0
- package/lib/types/client/index.d.mts +23 -0
- package/lib/types/client/indexes/generation.d.cts +10 -0
- package/lib/types/client/indexes/generation.d.mts +10 -0
- package/lib/types/client/indexes/index.d.cts +1 -0
- package/lib/types/client/indexes/index.d.mts +1 -0
- package/lib/types/client/logging.d.cts +60 -0
- package/lib/types/client/logging.d.mts +60 -0
- package/lib/types/client/services/FabricEnrollmentService.d.cts +176 -0
- package/lib/types/client/services/FabricEnrollmentService.d.mts +176 -0
- package/lib/types/client/services/FabricIdentityService.d.cts +98 -0
- package/lib/types/client/services/FabricIdentityService.d.mts +98 -0
- package/lib/types/client/services/RegistrationRequestBuilder.d.cts +19 -0
- package/lib/types/client/services/RegistrationRequestBuilder.d.mts +19 -0
- package/lib/types/client/services/constants.d.cts +15 -0
- package/lib/types/client/services/constants.d.mts +15 -0
- package/lib/types/client/services/index.d.cts +4 -0
- package/lib/types/client/services/index.d.mts +4 -0
- package/lib/types/client/types.d.cts +20 -0
- package/lib/types/client/types.d.mts +20 -0
- package/lib/types/client/utils.d.cts +71 -0
- package/lib/types/client/utils.d.mts +71 -0
- package/lib/types/contract/Address.d.cts +13 -0
- package/lib/types/contract/Address.d.mts +13 -0
- package/lib/types/contract/AddressContract.d.cts +5 -0
- package/lib/types/contract/AddressContract.d.mts +5 -0
- package/lib/types/contract/AuditContract.d.cts +5 -0
- package/lib/types/contract/AuditContract.d.mts +5 -0
- package/lib/types/contract/BatchContract.d.cts +5 -0
- package/lib/types/contract/BatchContract.d.mts +5 -0
- package/lib/types/contract/MarketContract.d.cts +5 -0
- package/lib/types/contract/MarketContract.d.mts +5 -0
- package/lib/types/contract/OtherAuditContract.d.cts +5 -0
- package/lib/types/contract/OtherAuditContract.d.mts +5 -0
- package/lib/types/contract/OtherBatchContract.d.cts +5 -0
- package/lib/types/contract/OtherBatchContract.d.mts +5 -0
- package/lib/types/contract/OtherMarketContract.d.cts +5 -0
- package/lib/types/contract/OtherMarketContract.d.mts +5 -0
- package/lib/types/contract/OtherProductContract.d.cts +5 -0
- package/lib/types/contract/OtherProductContract.d.mts +5 -0
- package/lib/types/contract/OtherProductImageContract.d.cts +5 -0
- package/lib/types/contract/OtherProductImageContract.d.mts +5 -0
- package/lib/types/contract/OtherProductSharedContract.d.cts +5 -0
- package/lib/types/contract/OtherProductSharedContract.d.mts +5 -0
- package/lib/types/contract/OtherProductStrengthContract.d.cts +5 -0
- package/lib/types/contract/OtherProductStrengthContract.d.mts +5 -0
- package/lib/types/contract/Product.d.cts +7 -0
- package/lib/types/contract/Product.d.mts +7 -0
- package/lib/types/contract/ProductContract.d.cts +5 -0
- package/lib/types/contract/ProductContract.d.mts +5 -0
- package/lib/types/contract/ProductStrengthContract.d.cts +5 -0
- package/lib/types/contract/ProductStrengthContract.d.mts +5 -0
- package/lib/types/contract/SegregatedPrivateDocumentContract.d.cts +5 -0
- package/lib/types/contract/SegregatedPrivateDocumentContract.d.mts +5 -0
- package/lib/types/contract/SegregatedSharedDocumentContract.d.cts +5 -0
- package/lib/types/contract/SegregatedSharedDocumentContract.d.mts +5 -0
- package/lib/types/contract/User.d.cts +7 -0
- package/lib/types/contract/User.d.mts +7 -0
- package/lib/types/contract/UserContract.d.cts +5 -0
- package/lib/types/contract/UserContract.d.mts +5 -0
- package/lib/types/contract/index.d.cts +2 -0
- package/lib/types/contract/index.d.mts +2 -0
- package/lib/types/contract/logging-context.d.cts +8 -0
- package/lib/types/contract/logging-context.d.mts +8 -0
- package/lib/types/contract/models/Audit.d.cts +13 -0
- package/lib/types/contract/models/Audit.d.mts +13 -0
- package/lib/types/contract/models/BaseIdentifiedModel.d.cts +7 -0
- package/lib/types/contract/models/BaseIdentifiedModel.d.mts +7 -0
- package/lib/types/contract/models/BaseModel.d.cts +7 -0
- package/lib/types/contract/models/BaseModel.d.mts +7 -0
- package/lib/types/contract/models/Batch.d.cts +18 -0
- package/lib/types/contract/models/Batch.d.mts +18 -0
- package/lib/types/contract/models/GtinOwner.d.cts +8 -0
- package/lib/types/contract/models/GtinOwner.d.mts +8 -0
- package/lib/types/contract/models/History.d.cts +9 -0
- package/lib/types/contract/models/History.d.mts +9 -0
- package/lib/types/contract/models/Leaflet.d.cts +12 -0
- package/lib/types/contract/models/Leaflet.d.mts +12 -0
- package/lib/types/contract/models/LeafletFile.d.cts +9 -0
- package/lib/types/contract/models/LeafletFile.d.mts +9 -0
- package/lib/types/contract/models/Market.d.cts +12 -0
- package/lib/types/contract/models/Market.d.mts +12 -0
- package/lib/types/contract/models/OtherAudit.d.cts +15 -0
- package/lib/types/contract/models/OtherAudit.d.mts +15 -0
- package/lib/types/contract/models/OtherBatchShared.d.cts +18 -0
- package/lib/types/contract/models/OtherBatchShared.d.mts +18 -0
- package/lib/types/contract/models/OtherLeaflet.d.cts +16 -0
- package/lib/types/contract/models/OtherLeaflet.d.mts +16 -0
- package/lib/types/contract/models/OtherLeafletFile.d.cts +10 -0
- package/lib/types/contract/models/OtherLeafletFile.d.mts +10 -0
- package/lib/types/contract/models/OtherMarket.d.cts +13 -0
- package/lib/types/contract/models/OtherMarket.d.mts +13 -0
- package/lib/types/contract/models/OtherProduct.d.cts +12 -0
- package/lib/types/contract/models/OtherProduct.d.mts +12 -0
- package/lib/types/contract/models/OtherProductImage.d.cts +9 -0
- package/lib/types/contract/models/OtherProductImage.d.mts +9 -0
- package/lib/types/contract/models/OtherProductShared.d.cts +18 -0
- package/lib/types/contract/models/OtherProductShared.d.mts +18 -0
- package/lib/types/contract/models/OtherProductStrength.d.cts +12 -0
- package/lib/types/contract/models/OtherProductStrength.d.mts +12 -0
- package/lib/types/contract/models/Product.d.cts +15 -0
- package/lib/types/contract/models/Product.d.mts +15 -0
- package/lib/types/contract/models/ProductStrength.d.cts +11 -0
- package/lib/types/contract/models/ProductStrength.d.mts +11 -0
- package/lib/types/contract/models/SegregatedDocument.d.cts +18 -0
- package/lib/types/contract/models/SegregatedDocument.d.mts +18 -0
- package/lib/types/contract/models/constants.d.cts +24 -0
- package/lib/types/contract/models/constants.d.mts +24 -0
- package/lib/types/contract/models/decorators-private.d.cts +16 -0
- package/lib/types/contract/models/decorators-private.d.mts +16 -0
- package/lib/types/contract/models/decorators.d.cts +28 -0
- package/lib/types/contract/models/decorators.d.mts +28 -0
- package/lib/types/contract/models/gtin.d.cts +8 -0
- package/lib/types/contract/models/gtin.d.mts +8 -0
- package/lib/types/contract/models/history-dec.d.cts +6 -0
- package/lib/types/contract/models/history-dec.d.mts +6 -0
- package/lib/types/contracts/ContractAdapter.d.cts +287 -0
- package/lib/types/contracts/ContractAdapter.d.mts +287 -0
- package/lib/types/contracts/ContractContext.d.cts +89 -0
- package/lib/types/contracts/ContractContext.d.mts +89 -0
- package/lib/types/contracts/FabricContractDispatch.d.cts +7 -0
- package/lib/types/contracts/FabricContractDispatch.d.mts +7 -0
- package/lib/types/contracts/FabricContractPaginator.d.cts +105 -0
- package/lib/types/contracts/FabricContractPaginator.d.mts +105 -0
- package/lib/types/contracts/FabricContractRepository.d.cts +119 -0
- package/lib/types/contracts/FabricContractRepository.d.mts +119 -0
- package/lib/types/contracts/FabricContractRepositoryObservableHandler.d.cts +62 -0
- package/lib/types/contracts/FabricContractRepositoryObservableHandler.d.mts +62 -0
- package/lib/types/contracts/FabricContractSequence.d.cts +87 -0
- package/lib/types/contracts/FabricContractSequence.d.mts +87 -0
- package/lib/types/contracts/FabricContractStatement.d.cts +36 -0
- package/lib/types/contracts/FabricContractStatement.d.mts +36 -0
- package/lib/types/contracts/MigrationContract.d.cts +22 -0
- package/lib/types/contracts/MigrationContract.d.mts +22 -0
- package/lib/types/contracts/PrivateSequence.d.cts +15 -0
- package/lib/types/contracts/PrivateSequence.d.mts +15 -0
- package/lib/types/contracts/auth/decorators.d.cts +6 -0
- package/lib/types/contracts/auth/decorators.d.mts +6 -0
- package/lib/types/contracts/auth/index.d.cts +1 -0
- package/lib/types/contracts/auth/index.d.mts +1 -0
- package/lib/types/contracts/crud/crud-contract.d.cts +199 -0
- package/lib/types/contracts/crud/crud-contract.d.mts +199 -0
- package/lib/types/contracts/crud/index.d.cts +2 -0
- package/lib/types/contracts/crud/index.d.mts +2 -0
- package/lib/types/contracts/crud/serialized-crud-contract.d.cts +42 -0
- package/lib/types/contracts/crud/serialized-crud-contract.d.mts +42 -0
- package/lib/types/contracts/erc20/erc20contract.d.cts +152 -0
- package/lib/types/contracts/erc20/erc20contract.d.mts +152 -0
- package/lib/types/contracts/erc20/index.d.cts +2 -0
- package/lib/types/contracts/erc20/index.d.mts +2 -0
- package/lib/types/contracts/erc20/models.d.cts +114 -0
- package/lib/types/contracts/erc20/models.d.mts +114 -0
- package/lib/types/contracts/index.d.cts +20 -0
- package/lib/types/contracts/index.d.mts +20 -0
- package/lib/types/contracts/logging.d.cts +54 -0
- package/lib/types/contracts/logging.d.mts +54 -0
- package/lib/types/contracts/overrides.d.cts +1 -0
- package/lib/types/contracts/overrides.d.mts +1 -0
- package/lib/types/contracts/types.d.cts +38 -0
- package/lib/types/contracts/types.d.mts +38 -0
- package/lib/types/contracts/uuid.d.cts +2 -0
- package/lib/types/contracts/uuid.d.mts +2 -0
- package/lib/types/index.d.cts +8 -0
- package/lib/types/index.d.mts +8 -0
- package/lib/types/shared/ClientSerializer.d.cts +52 -0
- package/lib/types/shared/ClientSerializer.d.mts +52 -0
- package/lib/types/shared/DeterministicSerializer.d.cts +47 -0
- package/lib/types/shared/DeterministicSerializer.d.mts +47 -0
- package/lib/types/shared/SimpleDeterministicSerializer.d.cts +7 -0
- package/lib/types/shared/SimpleDeterministicSerializer.d.mts +7 -0
- package/lib/types/shared/constants.d.cts +35 -0
- package/lib/types/shared/constants.d.mts +35 -0
- package/lib/types/shared/decorators.d.cts +81 -0
- package/lib/types/shared/decorators.d.mts +81 -0
- package/lib/types/shared/erc20/erc20-constants.d.cts +25 -0
- package/lib/types/shared/erc20/erc20-constants.d.mts +25 -0
- package/lib/types/shared/erc20/index.d.cts +1 -0
- package/lib/types/shared/erc20/index.d.mts +1 -0
- package/lib/types/shared/errors.d.cts +140 -0
- package/lib/types/shared/errors.d.mts +140 -0
- package/lib/types/shared/events.d.cts +37 -0
- package/lib/types/shared/events.d.mts +37 -0
- package/lib/types/shared/fabric-types.d.cts +32 -0
- package/lib/types/shared/fabric-types.d.mts +32 -0
- package/lib/types/shared/index.d.cts +21 -0
- package/lib/types/shared/index.d.mts +21 -0
- package/lib/types/shared/interfaces/Checkable.d.cts +23 -0
- package/lib/types/shared/interfaces/Checkable.d.mts +23 -0
- package/lib/types/shared/interfaces/index.d.cts +1 -0
- package/lib/types/shared/interfaces/index.d.mts +1 -0
- package/lib/types/shared/math.d.cts +34 -0
- package/lib/types/shared/math.d.mts +34 -0
- package/lib/types/shared/model/FabricBaseModel.d.cts +7 -0
- package/lib/types/shared/model/FabricBaseModel.d.mts +7 -0
- package/lib/types/shared/model/FabricIdentifiedBaseModel.d.cts +7 -0
- package/lib/types/shared/model/FabricIdentifiedBaseModel.d.mts +7 -0
- package/lib/types/shared/model/Identity.d.cts +42 -0
- package/lib/types/shared/model/Identity.d.mts +42 -0
- package/lib/types/shared/model/IdentityCredentials.d.cts +41 -0
- package/lib/types/shared/model/IdentityCredentials.d.mts +41 -0
- package/lib/types/shared/model/index.d.cts +4 -0
- package/lib/types/shared/model/index.d.mts +4 -0
- package/lib/types/shared/overrides/Model.d.cts +22 -0
- package/lib/types/shared/overrides/Model.d.mts +22 -0
- package/lib/types/shared/overrides/index.d.cts +2 -0
- package/lib/types/shared/overrides/index.d.mts +2 -0
- package/lib/types/shared/overrides/overrides.d.cts +1 -0
- package/lib/types/shared/overrides/overrides.d.mts +1 -0
- package/lib/types/shared/types.d.cts +125 -0
- package/lib/types/shared/types.d.mts +125 -0
- package/lib/types/version.d.cts +2 -0
- package/lib/types/version.d.mts +2 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +10 -10
- package/lib/cjs/bin/cli.js.map +0 -1
- package/lib/cjs/cli-module.js.map +0 -1
- package/lib/cjs/cli-utils.js.map +0 -1
- package/lib/cjs/client/FabricClientAdapter.js.map +0 -1
- package/lib/cjs/client/FabricClientDispatch.js.map +0 -1
- package/lib/cjs/client/FabricClientPaginator.js.map +0 -1
- package/lib/cjs/client/FabricClientRepository.js.map +0 -1
- package/lib/cjs/client/FabricClientStatement.js.map +0 -1
- package/lib/cjs/client/collections/generation.js.map +0 -1
- package/lib/cjs/client/collections/index.js.map +0 -1
- package/lib/cjs/client/constants.js.map +0 -1
- package/lib/cjs/client/crypto.js.map +0 -1
- package/lib/cjs/client/erc20/FabricERC20ClientRepository.js.map +0 -1
- package/lib/cjs/client/erc20/index.js.map +0 -1
- package/lib/cjs/client/fabric-fs.js.map +0 -1
- package/lib/cjs/client/fabric-hsm.js.map +0 -1
- package/lib/cjs/client/ids/id-extraction.js.map +0 -1
- package/lib/cjs/client/ids/index.js.map +0 -1
- package/lib/cjs/client/index.js.map +0 -1
- package/lib/cjs/client/indexes/generation.js.map +0 -1
- package/lib/cjs/client/indexes/index.js.map +0 -1
- package/lib/cjs/client/logging.js.map +0 -1
- package/lib/cjs/client/services/FabricEnrollmentService.js.map +0 -1
- package/lib/cjs/client/services/FabricIdentityService.js.map +0 -1
- package/lib/cjs/client/services/RegistrationRequestBuilder.js.map +0 -1
- package/lib/cjs/client/services/constants.js.map +0 -1
- package/lib/cjs/client/services/index.js.map +0 -1
- package/lib/cjs/client/types.js.map +0 -1
- package/lib/cjs/client/utils.js.map +0 -1
- package/lib/cjs/contract/Address.js.map +0 -1
- package/lib/cjs/contract/AddressContract.js.map +0 -1
- package/lib/cjs/contract/AuditContract.js.map +0 -1
- package/lib/cjs/contract/BatchContract.js.map +0 -1
- package/lib/cjs/contract/MarketContract.js.map +0 -1
- package/lib/cjs/contract/OtherAuditContract.js.map +0 -1
- package/lib/cjs/contract/OtherBatchContract.js.map +0 -1
- package/lib/cjs/contract/OtherMarketContract.js.map +0 -1
- package/lib/cjs/contract/OtherProductContract.js.map +0 -1
- package/lib/cjs/contract/OtherProductImageContract.js.map +0 -1
- package/lib/cjs/contract/OtherProductSharedContract.js.map +0 -1
- package/lib/cjs/contract/OtherProductStrengthContract.js.map +0 -1
- package/lib/cjs/contract/Product.js.map +0 -1
- package/lib/cjs/contract/ProductContract.js.map +0 -1
- package/lib/cjs/contract/ProductStrengthContract.js.map +0 -1
- package/lib/cjs/contract/SegregatedPrivateDocumentContract.js.map +0 -1
- package/lib/cjs/contract/SegregatedSharedDocumentContract.js.map +0 -1
- package/lib/cjs/contract/User.js.map +0 -1
- package/lib/cjs/contract/UserContract.js.map +0 -1
- package/lib/cjs/contract/index.js.map +0 -1
- package/lib/cjs/contract/logging-context.js.map +0 -1
- package/lib/cjs/contract/models/Audit.js.map +0 -1
- package/lib/cjs/contract/models/BaseIdentifiedModel.js.map +0 -1
- package/lib/cjs/contract/models/BaseModel.js.map +0 -1
- package/lib/cjs/contract/models/Batch.js.map +0 -1
- package/lib/cjs/contract/models/GtinOwner.js.map +0 -1
- package/lib/cjs/contract/models/History.js.map +0 -1
- package/lib/cjs/contract/models/Leaflet.js.map +0 -1
- package/lib/cjs/contract/models/LeafletFile.js.map +0 -1
- package/lib/cjs/contract/models/Market.js.map +0 -1
- package/lib/cjs/contract/models/OtherAudit.js.map +0 -1
- package/lib/cjs/contract/models/OtherBatchShared.js.map +0 -1
- package/lib/cjs/contract/models/OtherLeaflet.js.map +0 -1
- package/lib/cjs/contract/models/OtherLeafletFile.js.map +0 -1
- package/lib/cjs/contract/models/OtherMarket.js.map +0 -1
- package/lib/cjs/contract/models/OtherProduct.js.map +0 -1
- package/lib/cjs/contract/models/OtherProductImage.js.map +0 -1
- package/lib/cjs/contract/models/OtherProductShared.js.map +0 -1
- package/lib/cjs/contract/models/OtherProductStrength.js.map +0 -1
- package/lib/cjs/contract/models/Product.js.map +0 -1
- package/lib/cjs/contract/models/ProductStrength.js.map +0 -1
- package/lib/cjs/contract/models/SegregatedDocument.js.map +0 -1
- package/lib/cjs/contract/models/constants.js.map +0 -1
- package/lib/cjs/contract/models/decorators-private.js.map +0 -1
- package/lib/cjs/contract/models/decorators.js.map +0 -1
- package/lib/cjs/contract/models/gtin.js.map +0 -1
- package/lib/cjs/contract/models/history-dec.js.map +0 -1
- package/lib/cjs/contracts/ContractAdapter.js.map +0 -1
- package/lib/cjs/contracts/ContractContext.js.map +0 -1
- package/lib/cjs/contracts/FabricContractDispatch.js.map +0 -1
- package/lib/cjs/contracts/FabricContractPaginator.js.map +0 -1
- package/lib/cjs/contracts/FabricContractRepository.js.map +0 -1
- package/lib/cjs/contracts/FabricContractRepositoryObservableHandler.js.map +0 -1
- package/lib/cjs/contracts/FabricContractSequence.js.map +0 -1
- package/lib/cjs/contracts/FabricContractStatement.js.map +0 -1
- package/lib/cjs/contracts/MigrationContract.js.map +0 -1
- package/lib/cjs/contracts/PrivateSequence.js.map +0 -1
- package/lib/cjs/contracts/auth/decorators.js.map +0 -1
- package/lib/cjs/contracts/auth/index.js.map +0 -1
- package/lib/cjs/contracts/crud/crud-contract.js.map +0 -1
- package/lib/cjs/contracts/crud/index.js.map +0 -1
- package/lib/cjs/contracts/crud/serialized-crud-contract.js.map +0 -1
- package/lib/cjs/contracts/erc20/erc20contract.js.map +0 -1
- package/lib/cjs/contracts/erc20/index.js.map +0 -1
- package/lib/cjs/contracts/erc20/models.js.map +0 -1
- package/lib/cjs/contracts/index.js.map +0 -1
- package/lib/cjs/contracts/logging.js.map +0 -1
- package/lib/cjs/contracts/overrides.js.map +0 -1
- package/lib/cjs/contracts/types.js.map +0 -1
- package/lib/cjs/contracts/uuid.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/shared/ClientSerializer.js.map +0 -1
- package/lib/cjs/shared/DeterministicSerializer.js.map +0 -1
- package/lib/cjs/shared/SimpleDeterministicSerializer.js.map +0 -1
- package/lib/cjs/shared/constants.js.map +0 -1
- package/lib/cjs/shared/decorators.js.map +0 -1
- package/lib/cjs/shared/erc20/erc20-constants.js.map +0 -1
- package/lib/cjs/shared/erc20/index.js.map +0 -1
- package/lib/cjs/shared/errors.js.map +0 -1
- package/lib/cjs/shared/events.js.map +0 -1
- package/lib/cjs/shared/fabric-types.js.map +0 -1
- package/lib/cjs/shared/index.js.map +0 -1
- package/lib/cjs/shared/interfaces/Checkable.js.map +0 -1
- package/lib/cjs/shared/interfaces/index.js.map +0 -1
- package/lib/cjs/shared/math.js.map +0 -1
- package/lib/cjs/shared/model/FabricBaseModel.js.map +0 -1
- package/lib/cjs/shared/model/FabricIdentifiedBaseModel.js.map +0 -1
- package/lib/cjs/shared/model/Identity.js.map +0 -1
- package/lib/cjs/shared/model/IdentityCredentials.js.map +0 -1
- package/lib/cjs/shared/model/index.js.map +0 -1
- package/lib/cjs/shared/overrides/Model.js.map +0 -1
- package/lib/cjs/shared/overrides/index.js.map +0 -1
- package/lib/cjs/shared/overrides/overrides.js.map +0 -1
- package/lib/cjs/shared/types.js.map +0 -1
- package/lib/cjs/version.js.map +0 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import "../../shared/overrides";
|
|
2
|
+
import { FabricContextualizedArgs, FabricContractAdapter } from "../ContractAdapter.cjs";
|
|
3
|
+
import { Context as Ctx, Contract } from "fabric-contract-api";
|
|
4
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
+
import { AllOperationKeys, Condition, ContextualArgs, DirectionLimitOffset, EventIds, MaybeContextualArg, MethodOrOperation, Observer, OrderDirection, PersistenceObserver, SerializedPage } from "@decaf-ts/core";
|
|
6
|
+
import { FabricContractRepository } from "../FabricContractRepository.cjs";
|
|
7
|
+
import { DeterministicSerializer } from "../../shared/DeterministicSerializer.cjs";
|
|
8
|
+
import { MangoQuery } from "@decaf-ts/for-couchdb";
|
|
9
|
+
import { Checkable, healthcheck } from "../../shared/interfaces/Checkable.cjs";
|
|
10
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
11
|
+
import { FabricContractContext } from "../ContractContext.cjs";
|
|
12
|
+
import { PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
13
|
+
/**
|
|
14
|
+
* @description Base contract class for CRUD operations in Fabric chaincode
|
|
15
|
+
* @summary Provides standard create, read, update, and delete operations for models in Fabric chaincode
|
|
16
|
+
* @template M - Type extending Model
|
|
17
|
+
* @class FabricCrudContract
|
|
18
|
+
* @extends {Contract}
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Define a model
|
|
22
|
+
* @table('assets')
|
|
23
|
+
* class Asset extends Model {
|
|
24
|
+
* @id()
|
|
25
|
+
* id: string;
|
|
26
|
+
*
|
|
27
|
+
* @property()
|
|
28
|
+
* data: string;
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* // Create a contract that extends FabricCrudContract
|
|
32
|
+
* export class AssetContract extends FabricCrudContract<Asset> {
|
|
33
|
+
* constructor() {
|
|
34
|
+
* super('AssetContract', Asset);
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* // Add custom methods as needed
|
|
38
|
+
* async getAssetHistory(ctx: Context, id: string): Promise<any[]> {
|
|
39
|
+
* // Custom implementation
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
* @mermaid
|
|
44
|
+
* sequenceDiagram
|
|
45
|
+
* participant Client
|
|
46
|
+
* participant Contract
|
|
47
|
+
* participant Repository
|
|
48
|
+
* participant Adapter
|
|
49
|
+
* participant StateDB
|
|
50
|
+
*
|
|
51
|
+
* Client->>Contract: create(ctx, model)
|
|
52
|
+
* Contract->>Repository: repository(ctx)
|
|
53
|
+
* Contract->>Repository: create(model, ctx)
|
|
54
|
+
* Repository->>Adapter: create(tableName, id, record, transient, ctx)
|
|
55
|
+
* Adapter->>StateDB: putState(id, serializedData)
|
|
56
|
+
* StateDB-->>Adapter: Success
|
|
57
|
+
* Adapter-->>Repository: record
|
|
58
|
+
* Repository-->>Contract: model
|
|
59
|
+
* Contract-->>Client: model
|
|
60
|
+
*/
|
|
61
|
+
export declare abstract class FabricCrudContract<M extends Model> extends Contract implements Checkable, PersistenceObserver<FabricContractContext>, Observer<[
|
|
62
|
+
table: Constructor<M> | string,
|
|
63
|
+
event: AllOperationKeys,
|
|
64
|
+
id: EventIds,
|
|
65
|
+
...args: ContextualArgs<FabricContractContext>
|
|
66
|
+
]> {
|
|
67
|
+
protected readonly clazz: Constructor<M>;
|
|
68
|
+
/**
|
|
69
|
+
* @description Shared adapter instance for all contract instances
|
|
70
|
+
*/
|
|
71
|
+
protected static adapter: FabricContractAdapter;
|
|
72
|
+
protected static readonly serializer: DeterministicSerializer<Model<false>>;
|
|
73
|
+
protected initialized: boolean;
|
|
74
|
+
private _repo?;
|
|
75
|
+
protected get repo(): FabricContractRepository<M>;
|
|
76
|
+
/**
|
|
77
|
+
* @description Creates a new FabricCrudContract instance
|
|
78
|
+
* @summary Initializes a contract with a name and model class
|
|
79
|
+
* @param {string} name - The name of the contract
|
|
80
|
+
* @param {Constructor<M>} clazz - The model constructor
|
|
81
|
+
*/
|
|
82
|
+
protected constructor(name: string, clazz: Constructor<M>);
|
|
83
|
+
refresh(table: Constructor<M> | string, event: AllOperationKeys, id: EventIds, ...args: ContextualArgs<FabricContractContext>): Promise<void>;
|
|
84
|
+
listBy(ctx: Ctx | FabricContractContext, key: string | keyof M, order: string, ...args: any[]): Promise<M[] | string>;
|
|
85
|
+
paginateBy(ctx: Ctx | FabricContractContext, key: string | keyof M, order: string, ref?: Omit<DirectionLimitOffset, "direction"> | string, ...args: any[]): Promise<SerializedPage<M> | string>;
|
|
86
|
+
page(ctx: Ctx | FabricContractContext, value: string, direction?: string | OrderDirection, ref?: Omit<DirectionLimitOffset, "direction"> | string, ...args: any[]): Promise<SerializedPage<M> | string>;
|
|
87
|
+
findOneBy(ctx: Ctx | FabricContractContext, key: string | keyof M, value: any, ...args: any[]): Promise<M | string>;
|
|
88
|
+
statement(ctx: Ctx | FabricContractContext, method: string, ...args: any[]): Promise<any>;
|
|
89
|
+
countOf(ctx: Ctx | FabricContractContext, key?: string | keyof M, ...args: any[]): Promise<number | string>;
|
|
90
|
+
maxOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<M[keyof M] | string>;
|
|
91
|
+
minOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<M[keyof M] | string>;
|
|
92
|
+
avgOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<number | string>;
|
|
93
|
+
sumOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<number | string>;
|
|
94
|
+
distinctOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<M[keyof M][] | string>;
|
|
95
|
+
groupOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<Record<string, M[]> | string>;
|
|
96
|
+
/**
|
|
97
|
+
* @description Creates a single model in the state database
|
|
98
|
+
* @summary Delegates to the repository's create method
|
|
99
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
100
|
+
* @param {M} model - The model to create
|
|
101
|
+
* @param {...any[]} args - Additional arguments
|
|
102
|
+
* @return {Promise<M>} Promise resolving to the created model
|
|
103
|
+
*/
|
|
104
|
+
create(context: Ctx | FabricContractContext, model: string | M, ...args: any[]): Promise<string | M>;
|
|
105
|
+
/**
|
|
106
|
+
* @description Reads a single model from the state database
|
|
107
|
+
* @summary Delegates to the repository's read method
|
|
108
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
109
|
+
* @param {string | number} key - The key of the model to read
|
|
110
|
+
* @param {...any[]} args - Additional arguments
|
|
111
|
+
* @return {Promise<M>} Promise resolving to the retrieved model
|
|
112
|
+
*/
|
|
113
|
+
read(ctx: Ctx | FabricContractContext, key: PrimaryKeyType | string, ...args: any[]): Promise<M | string>;
|
|
114
|
+
protected getTransientData(ctx: FabricContractContext): any;
|
|
115
|
+
/**
|
|
116
|
+
* @description Updates a single model in the state database
|
|
117
|
+
* @summary Delegates to the repository's update method
|
|
118
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
119
|
+
* @param {M} model - The model to update
|
|
120
|
+
* @param {...any[]} args - Additional arguments
|
|
121
|
+
* @return {Promise<M>} Promise resolving to the updated model
|
|
122
|
+
*/
|
|
123
|
+
update(context: Ctx | FabricContractContext, model: string | M, ...args: any[]): Promise<string | M>;
|
|
124
|
+
/**
|
|
125
|
+
* @description Deletes a single model from the state database
|
|
126
|
+
* @summary Delegates to the repository's delete method
|
|
127
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
128
|
+
* @param {string | number} key - The key of the model to delete
|
|
129
|
+
* @param {...any[]} args - Additional arguments
|
|
130
|
+
* @return {Promise<M>} Promise resolving to the deleted model
|
|
131
|
+
*/
|
|
132
|
+
delete(ctx: Ctx | FabricContractContext, key: PrimaryKeyType | string, ...args: any[]): Promise<M | string>;
|
|
133
|
+
/**
|
|
134
|
+
* @description Deletes multiple models from the state database
|
|
135
|
+
* @summary Delegates to the repository's deleteAll method
|
|
136
|
+
* @param {string[] | number[]} keys - The keys of the models to delete
|
|
137
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
138
|
+
* @param {...any[]} args - Additional arguments
|
|
139
|
+
* @return {Promise<M[]>} Promise resolving to the deleted models
|
|
140
|
+
*/
|
|
141
|
+
deleteAll(ctx: Ctx | FabricContractContext, keys: PrimaryKeyType[] | string, ...args: any[]): Promise<M[] | string>;
|
|
142
|
+
/**
|
|
143
|
+
* @description Reads multiple models from the state database
|
|
144
|
+
* @summary Delegates to the repository's readAll method
|
|
145
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
146
|
+
* @param {string[] | number[]} keys - The keys of the models to read
|
|
147
|
+
* @param {...any[]} args - Additional arguments
|
|
148
|
+
* @return {Promise<M[]>} Promise resolving to the retrieved models
|
|
149
|
+
*/
|
|
150
|
+
readAll(ctx: Ctx | FabricContractContext, keys: PrimaryKeyType[] | string, ...args: any[]): Promise<M[] | string>;
|
|
151
|
+
/**
|
|
152
|
+
* @description Updates multiple models in the state database
|
|
153
|
+
* @summary Delegates to the repository's updateAll method
|
|
154
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
155
|
+
* @param {M[]} models - The models to update
|
|
156
|
+
* @param {...any[]} args - Additional arguments
|
|
157
|
+
* @return {Promise<M[]>} Promise resolving to the updated models
|
|
158
|
+
*/
|
|
159
|
+
updateAll(context: Ctx | FabricContractContext, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
160
|
+
/**
|
|
161
|
+
* @description Executes a query with the specified conditions and options.
|
|
162
|
+
* @summary Provides a simplified way to query the database with common query parameters.
|
|
163
|
+
* @param {Condition<M>} condition - The condition to filter records.
|
|
164
|
+
* @param orderBy - The field to order results by.
|
|
165
|
+
* @param {OrderDirection} [order=OrderDirection.ASC] - The sort direction.
|
|
166
|
+
* @param {OrderDirection} [order=OrderDirection.ASC] - The sort direction.
|
|
167
|
+
* @param {number} [limit] - Optional maximum number of results to return.
|
|
168
|
+
* @param {number} [skip] - Optional number of results to skip.
|
|
169
|
+
* @return {Promise<M[]>} The query results as model instances.
|
|
170
|
+
*/
|
|
171
|
+
query(context: Ctx | FabricContractContext, condition: Condition<M> | string, orderBy: string | keyof M, order?: OrderDirection | string, limit?: number, skip?: number, ...args: any[]): Promise<M[] | string>;
|
|
172
|
+
/**
|
|
173
|
+
* @description Executes a raw query against the state database
|
|
174
|
+
* @summary Delegates to the repository's raw method
|
|
175
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
176
|
+
* @param {any} rawInput - The query to execute
|
|
177
|
+
* @param {boolean} docsOnly - Whether to return only documents
|
|
178
|
+
* @param {...any[]} args - Additional arguments
|
|
179
|
+
* @return {Promise<any>} Promise resolving to the query results
|
|
180
|
+
*/
|
|
181
|
+
raw(ctx: Ctx | FabricContractContext, rawInput: MangoQuery, docsOnly: boolean, ...args: any[]): Promise<any>;
|
|
182
|
+
protected serialize(model: M): string;
|
|
183
|
+
protected deserialize<M extends Model>(str: string): M;
|
|
184
|
+
protected init(ctx: Ctx | FabricContractContext): Promise<void>;
|
|
185
|
+
healthcheck(ctx: Ctx | FabricContractContext): Promise<string | healthcheck>;
|
|
186
|
+
/**
|
|
187
|
+
* @description Creates multiple models in the state database
|
|
188
|
+
* @summary Delegates to the repository's createAll method
|
|
189
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
190
|
+
* @param {M[]} models - The models to create
|
|
191
|
+
* @param {...any[]} args - Additional arguments
|
|
192
|
+
* @return {Promise<M[]>} Promise resolving to the created models
|
|
193
|
+
*/
|
|
194
|
+
createAll(context: Ctx | FabricContractContext, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
195
|
+
protected ensureMirrorWritePermissions(ctx: FabricContractContext): void;
|
|
196
|
+
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD): FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>;
|
|
197
|
+
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD, allowCreate: false): FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>;
|
|
198
|
+
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD, allowCreate: true): Promise<FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>>;
|
|
199
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import "../../shared/overrides";
|
|
2
|
+
import { FabricContextualizedArgs, FabricContractAdapter } from "../ContractAdapter.js";
|
|
3
|
+
import { Context as Ctx, Contract } from "fabric-contract-api";
|
|
4
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
+
import { AllOperationKeys, Condition, ContextualArgs, DirectionLimitOffset, EventIds, MaybeContextualArg, MethodOrOperation, Observer, OrderDirection, PersistenceObserver, SerializedPage } from "@decaf-ts/core";
|
|
6
|
+
import { FabricContractRepository } from "../FabricContractRepository.js";
|
|
7
|
+
import { DeterministicSerializer } from "../../shared/DeterministicSerializer.js";
|
|
8
|
+
import { MangoQuery } from "@decaf-ts/for-couchdb";
|
|
9
|
+
import { Checkable, healthcheck } from "../../shared/interfaces/Checkable.js";
|
|
10
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
11
|
+
import { FabricContractContext } from "../ContractContext.js";
|
|
12
|
+
import { PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
13
|
+
/**
|
|
14
|
+
* @description Base contract class for CRUD operations in Fabric chaincode
|
|
15
|
+
* @summary Provides standard create, read, update, and delete operations for models in Fabric chaincode
|
|
16
|
+
* @template M - Type extending Model
|
|
17
|
+
* @class FabricCrudContract
|
|
18
|
+
* @extends {Contract}
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Define a model
|
|
22
|
+
* @table('assets')
|
|
23
|
+
* class Asset extends Model {
|
|
24
|
+
* @id()
|
|
25
|
+
* id: string;
|
|
26
|
+
*
|
|
27
|
+
* @property()
|
|
28
|
+
* data: string;
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* // Create a contract that extends FabricCrudContract
|
|
32
|
+
* export class AssetContract extends FabricCrudContract<Asset> {
|
|
33
|
+
* constructor() {
|
|
34
|
+
* super('AssetContract', Asset);
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* // Add custom methods as needed
|
|
38
|
+
* async getAssetHistory(ctx: Context, id: string): Promise<any[]> {
|
|
39
|
+
* // Custom implementation
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
* @mermaid
|
|
44
|
+
* sequenceDiagram
|
|
45
|
+
* participant Client
|
|
46
|
+
* participant Contract
|
|
47
|
+
* participant Repository
|
|
48
|
+
* participant Adapter
|
|
49
|
+
* participant StateDB
|
|
50
|
+
*
|
|
51
|
+
* Client->>Contract: create(ctx, model)
|
|
52
|
+
* Contract->>Repository: repository(ctx)
|
|
53
|
+
* Contract->>Repository: create(model, ctx)
|
|
54
|
+
* Repository->>Adapter: create(tableName, id, record, transient, ctx)
|
|
55
|
+
* Adapter->>StateDB: putState(id, serializedData)
|
|
56
|
+
* StateDB-->>Adapter: Success
|
|
57
|
+
* Adapter-->>Repository: record
|
|
58
|
+
* Repository-->>Contract: model
|
|
59
|
+
* Contract-->>Client: model
|
|
60
|
+
*/
|
|
61
|
+
export declare abstract class FabricCrudContract<M extends Model> extends Contract implements Checkable, PersistenceObserver<FabricContractContext>, Observer<[
|
|
62
|
+
table: Constructor<M> | string,
|
|
63
|
+
event: AllOperationKeys,
|
|
64
|
+
id: EventIds,
|
|
65
|
+
...args: ContextualArgs<FabricContractContext>
|
|
66
|
+
]> {
|
|
67
|
+
protected readonly clazz: Constructor<M>;
|
|
68
|
+
/**
|
|
69
|
+
* @description Shared adapter instance for all contract instances
|
|
70
|
+
*/
|
|
71
|
+
protected static adapter: FabricContractAdapter;
|
|
72
|
+
protected static readonly serializer: DeterministicSerializer<Model<false>>;
|
|
73
|
+
protected initialized: boolean;
|
|
74
|
+
private _repo?;
|
|
75
|
+
protected get repo(): FabricContractRepository<M>;
|
|
76
|
+
/**
|
|
77
|
+
* @description Creates a new FabricCrudContract instance
|
|
78
|
+
* @summary Initializes a contract with a name and model class
|
|
79
|
+
* @param {string} name - The name of the contract
|
|
80
|
+
* @param {Constructor<M>} clazz - The model constructor
|
|
81
|
+
*/
|
|
82
|
+
protected constructor(name: string, clazz: Constructor<M>);
|
|
83
|
+
refresh(table: Constructor<M> | string, event: AllOperationKeys, id: EventIds, ...args: ContextualArgs<FabricContractContext>): Promise<void>;
|
|
84
|
+
listBy(ctx: Ctx | FabricContractContext, key: string | keyof M, order: string, ...args: any[]): Promise<M[] | string>;
|
|
85
|
+
paginateBy(ctx: Ctx | FabricContractContext, key: string | keyof M, order: string, ref?: Omit<DirectionLimitOffset, "direction"> | string, ...args: any[]): Promise<SerializedPage<M> | string>;
|
|
86
|
+
page(ctx: Ctx | FabricContractContext, value: string, direction?: string | OrderDirection, ref?: Omit<DirectionLimitOffset, "direction"> | string, ...args: any[]): Promise<SerializedPage<M> | string>;
|
|
87
|
+
findOneBy(ctx: Ctx | FabricContractContext, key: string | keyof M, value: any, ...args: any[]): Promise<M | string>;
|
|
88
|
+
statement(ctx: Ctx | FabricContractContext, method: string, ...args: any[]): Promise<any>;
|
|
89
|
+
countOf(ctx: Ctx | FabricContractContext, key?: string | keyof M, ...args: any[]): Promise<number | string>;
|
|
90
|
+
maxOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<M[keyof M] | string>;
|
|
91
|
+
minOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<M[keyof M] | string>;
|
|
92
|
+
avgOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<number | string>;
|
|
93
|
+
sumOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<number | string>;
|
|
94
|
+
distinctOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<M[keyof M][] | string>;
|
|
95
|
+
groupOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<Record<string, M[]> | string>;
|
|
96
|
+
/**
|
|
97
|
+
* @description Creates a single model in the state database
|
|
98
|
+
* @summary Delegates to the repository's create method
|
|
99
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
100
|
+
* @param {M} model - The model to create
|
|
101
|
+
* @param {...any[]} args - Additional arguments
|
|
102
|
+
* @return {Promise<M>} Promise resolving to the created model
|
|
103
|
+
*/
|
|
104
|
+
create(context: Ctx | FabricContractContext, model: string | M, ...args: any[]): Promise<string | M>;
|
|
105
|
+
/**
|
|
106
|
+
* @description Reads a single model from the state database
|
|
107
|
+
* @summary Delegates to the repository's read method
|
|
108
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
109
|
+
* @param {string | number} key - The key of the model to read
|
|
110
|
+
* @param {...any[]} args - Additional arguments
|
|
111
|
+
* @return {Promise<M>} Promise resolving to the retrieved model
|
|
112
|
+
*/
|
|
113
|
+
read(ctx: Ctx | FabricContractContext, key: PrimaryKeyType | string, ...args: any[]): Promise<M | string>;
|
|
114
|
+
protected getTransientData(ctx: FabricContractContext): any;
|
|
115
|
+
/**
|
|
116
|
+
* @description Updates a single model in the state database
|
|
117
|
+
* @summary Delegates to the repository's update method
|
|
118
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
119
|
+
* @param {M} model - The model to update
|
|
120
|
+
* @param {...any[]} args - Additional arguments
|
|
121
|
+
* @return {Promise<M>} Promise resolving to the updated model
|
|
122
|
+
*/
|
|
123
|
+
update(context: Ctx | FabricContractContext, model: string | M, ...args: any[]): Promise<string | M>;
|
|
124
|
+
/**
|
|
125
|
+
* @description Deletes a single model from the state database
|
|
126
|
+
* @summary Delegates to the repository's delete method
|
|
127
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
128
|
+
* @param {string | number} key - The key of the model to delete
|
|
129
|
+
* @param {...any[]} args - Additional arguments
|
|
130
|
+
* @return {Promise<M>} Promise resolving to the deleted model
|
|
131
|
+
*/
|
|
132
|
+
delete(ctx: Ctx | FabricContractContext, key: PrimaryKeyType | string, ...args: any[]): Promise<M | string>;
|
|
133
|
+
/**
|
|
134
|
+
* @description Deletes multiple models from the state database
|
|
135
|
+
* @summary Delegates to the repository's deleteAll method
|
|
136
|
+
* @param {string[] | number[]} keys - The keys of the models to delete
|
|
137
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
138
|
+
* @param {...any[]} args - Additional arguments
|
|
139
|
+
* @return {Promise<M[]>} Promise resolving to the deleted models
|
|
140
|
+
*/
|
|
141
|
+
deleteAll(ctx: Ctx | FabricContractContext, keys: PrimaryKeyType[] | string, ...args: any[]): Promise<M[] | string>;
|
|
142
|
+
/**
|
|
143
|
+
* @description Reads multiple models from the state database
|
|
144
|
+
* @summary Delegates to the repository's readAll method
|
|
145
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
146
|
+
* @param {string[] | number[]} keys - The keys of the models to read
|
|
147
|
+
* @param {...any[]} args - Additional arguments
|
|
148
|
+
* @return {Promise<M[]>} Promise resolving to the retrieved models
|
|
149
|
+
*/
|
|
150
|
+
readAll(ctx: Ctx | FabricContractContext, keys: PrimaryKeyType[] | string, ...args: any[]): Promise<M[] | string>;
|
|
151
|
+
/**
|
|
152
|
+
* @description Updates multiple models in the state database
|
|
153
|
+
* @summary Delegates to the repository's updateAll method
|
|
154
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
155
|
+
* @param {M[]} models - The models to update
|
|
156
|
+
* @param {...any[]} args - Additional arguments
|
|
157
|
+
* @return {Promise<M[]>} Promise resolving to the updated models
|
|
158
|
+
*/
|
|
159
|
+
updateAll(context: Ctx | FabricContractContext, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
160
|
+
/**
|
|
161
|
+
* @description Executes a query with the specified conditions and options.
|
|
162
|
+
* @summary Provides a simplified way to query the database with common query parameters.
|
|
163
|
+
* @param {Condition<M>} condition - The condition to filter records.
|
|
164
|
+
* @param orderBy - The field to order results by.
|
|
165
|
+
* @param {OrderDirection} [order=OrderDirection.ASC] - The sort direction.
|
|
166
|
+
* @param {OrderDirection} [order=OrderDirection.ASC] - The sort direction.
|
|
167
|
+
* @param {number} [limit] - Optional maximum number of results to return.
|
|
168
|
+
* @param {number} [skip] - Optional number of results to skip.
|
|
169
|
+
* @return {Promise<M[]>} The query results as model instances.
|
|
170
|
+
*/
|
|
171
|
+
query(context: Ctx | FabricContractContext, condition: Condition<M> | string, orderBy: string | keyof M, order?: OrderDirection | string, limit?: number, skip?: number, ...args: any[]): Promise<M[] | string>;
|
|
172
|
+
/**
|
|
173
|
+
* @description Executes a raw query against the state database
|
|
174
|
+
* @summary Delegates to the repository's raw method
|
|
175
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
176
|
+
* @param {any} rawInput - The query to execute
|
|
177
|
+
* @param {boolean} docsOnly - Whether to return only documents
|
|
178
|
+
* @param {...any[]} args - Additional arguments
|
|
179
|
+
* @return {Promise<any>} Promise resolving to the query results
|
|
180
|
+
*/
|
|
181
|
+
raw(ctx: Ctx | FabricContractContext, rawInput: MangoQuery, docsOnly: boolean, ...args: any[]): Promise<any>;
|
|
182
|
+
protected serialize(model: M): string;
|
|
183
|
+
protected deserialize<M extends Model>(str: string): M;
|
|
184
|
+
protected init(ctx: Ctx | FabricContractContext): Promise<void>;
|
|
185
|
+
healthcheck(ctx: Ctx | FabricContractContext): Promise<string | healthcheck>;
|
|
186
|
+
/**
|
|
187
|
+
* @description Creates multiple models in the state database
|
|
188
|
+
* @summary Delegates to the repository's createAll method
|
|
189
|
+
* @param {Ctx} ctx - The Fabric chaincode context
|
|
190
|
+
* @param {M[]} models - The models to create
|
|
191
|
+
* @param {...any[]} args - Additional arguments
|
|
192
|
+
* @return {Promise<M[]>} Promise resolving to the created models
|
|
193
|
+
*/
|
|
194
|
+
createAll(context: Ctx | FabricContractContext, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
195
|
+
protected ensureMirrorWritePermissions(ctx: FabricContractContext): void;
|
|
196
|
+
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD): FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>;
|
|
197
|
+
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD, allowCreate: false): FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>;
|
|
198
|
+
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD, allowCreate: true): Promise<FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>>;
|
|
199
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FabricCrudContract } from "./crud-contract.cjs";
|
|
2
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
+
import { Context as Ctx } from "fabric-contract-api";
|
|
4
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
+
/**
|
|
6
|
+
* @description CRUD contract variant that serializes/deserializes payloads
|
|
7
|
+
* @summary Exposes the same CRUD operations as FabricCrudContract but takes and returns JSON strings to facilitate simple client interactions.
|
|
8
|
+
* @template M - Model type handled by this contract
|
|
9
|
+
* @param {string} name - The contract name
|
|
10
|
+
* @param {Constructor<M>} clazz - The model constructor used to instantiate models from JSON
|
|
11
|
+
* @return {void}
|
|
12
|
+
* @class SerializedCrudContract
|
|
13
|
+
* @example
|
|
14
|
+
* const contract = new SerializedCrudContract<MyModel>('MyModelContract', MyModel);
|
|
15
|
+
* // Client submits JSON string payloads and receives JSON string responses
|
|
16
|
+
*/
|
|
17
|
+
export declare class SerializedCrudContract<M extends Model> extends FabricCrudContract<M> {
|
|
18
|
+
constructor(name: string, clazz: Constructor<M>);
|
|
19
|
+
create(ctx: Ctx, model: string): Promise<string>;
|
|
20
|
+
read(ctx: Ctx, key: string): Promise<string>;
|
|
21
|
+
update(ctx: Ctx, model: string): Promise<string>;
|
|
22
|
+
delete(ctx: Ctx, key: string): Promise<string>;
|
|
23
|
+
deleteAll(ctx: Ctx, keys: string): Promise<string>;
|
|
24
|
+
readAll(ctx: Ctx, keys: string): Promise<string>;
|
|
25
|
+
updateAll(ctx: Ctx, models: string): Promise<string>;
|
|
26
|
+
statement(ctx: Ctx, method: string, args: string): Promise<string>;
|
|
27
|
+
listBy(ctx: Ctx, key: string, order: string): Promise<string>;
|
|
28
|
+
paginateBy(ctx: Ctx, key: string, order: string, ref: string): Promise<string>;
|
|
29
|
+
page(ctx: Ctx, value: string, direction: string, ref: string): Promise<string>;
|
|
30
|
+
findOneBy(ctx: Ctx, key: string, value: string): Promise<string>;
|
|
31
|
+
query(ctx: Ctx, condition: string, orderBy: string, order: string, limit?: number, skip?: number): Promise<string>;
|
|
32
|
+
init(ctx: Ctx): Promise<void>;
|
|
33
|
+
healthcheck(ctx: Ctx): Promise<string>;
|
|
34
|
+
createAll(context: Ctx, models: string): Promise<string>;
|
|
35
|
+
countOf(ctx: Ctx, key?: string): Promise<string>;
|
|
36
|
+
maxOf(ctx: Ctx, key: string): Promise<string>;
|
|
37
|
+
minOf(ctx: Ctx, key: string): Promise<string>;
|
|
38
|
+
avgOf(ctx: Ctx, key: string): Promise<string>;
|
|
39
|
+
sumOf(ctx: Ctx, key: string): Promise<string>;
|
|
40
|
+
distinctOf(ctx: Ctx, key: string): Promise<string>;
|
|
41
|
+
groupOf(ctx: Ctx, key: string): Promise<string>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FabricCrudContract } from "./crud-contract.js";
|
|
2
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
+
import { Context as Ctx } from "fabric-contract-api";
|
|
4
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
+
/**
|
|
6
|
+
* @description CRUD contract variant that serializes/deserializes payloads
|
|
7
|
+
* @summary Exposes the same CRUD operations as FabricCrudContract but takes and returns JSON strings to facilitate simple client interactions.
|
|
8
|
+
* @template M - Model type handled by this contract
|
|
9
|
+
* @param {string} name - The contract name
|
|
10
|
+
* @param {Constructor<M>} clazz - The model constructor used to instantiate models from JSON
|
|
11
|
+
* @return {void}
|
|
12
|
+
* @class SerializedCrudContract
|
|
13
|
+
* @example
|
|
14
|
+
* const contract = new SerializedCrudContract<MyModel>('MyModelContract', MyModel);
|
|
15
|
+
* // Client submits JSON string payloads and receives JSON string responses
|
|
16
|
+
*/
|
|
17
|
+
export declare class SerializedCrudContract<M extends Model> extends FabricCrudContract<M> {
|
|
18
|
+
constructor(name: string, clazz: Constructor<M>);
|
|
19
|
+
create(ctx: Ctx, model: string): Promise<string>;
|
|
20
|
+
read(ctx: Ctx, key: string): Promise<string>;
|
|
21
|
+
update(ctx: Ctx, model: string): Promise<string>;
|
|
22
|
+
delete(ctx: Ctx, key: string): Promise<string>;
|
|
23
|
+
deleteAll(ctx: Ctx, keys: string): Promise<string>;
|
|
24
|
+
readAll(ctx: Ctx, keys: string): Promise<string>;
|
|
25
|
+
updateAll(ctx: Ctx, models: string): Promise<string>;
|
|
26
|
+
statement(ctx: Ctx, method: string, args: string): Promise<string>;
|
|
27
|
+
listBy(ctx: Ctx, key: string, order: string): Promise<string>;
|
|
28
|
+
paginateBy(ctx: Ctx, key: string, order: string, ref: string): Promise<string>;
|
|
29
|
+
page(ctx: Ctx, value: string, direction: string, ref: string): Promise<string>;
|
|
30
|
+
findOneBy(ctx: Ctx, key: string, value: string): Promise<string>;
|
|
31
|
+
query(ctx: Ctx, condition: string, orderBy: string, order: string, limit?: number, skip?: number): Promise<string>;
|
|
32
|
+
init(ctx: Ctx): Promise<void>;
|
|
33
|
+
healthcheck(ctx: Ctx): Promise<string>;
|
|
34
|
+
createAll(context: Ctx, models: string): Promise<string>;
|
|
35
|
+
countOf(ctx: Ctx, key?: string): Promise<string>;
|
|
36
|
+
maxOf(ctx: Ctx, key: string): Promise<string>;
|
|
37
|
+
minOf(ctx: Ctx, key: string): Promise<string>;
|
|
38
|
+
avgOf(ctx: Ctx, key: string): Promise<string>;
|
|
39
|
+
sumOf(ctx: Ctx, key: string): Promise<string>;
|
|
40
|
+
distinctOf(ctx: Ctx, key: string): Promise<string>;
|
|
41
|
+
groupOf(ctx: Ctx, key: string): Promise<string>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Context } from "fabric-contract-api";
|
|
2
|
+
import { Allowance, ERC20Token, ERC20Wallet } from "./models.cjs";
|
|
3
|
+
import type { FabricContractContext } from "../ContractContext.cjs";
|
|
4
|
+
import { FabricCrudContract } from "../crud/crud-contract.cjs";
|
|
5
|
+
/**
|
|
6
|
+
* @description ERC20 token contract base for Hyperledger Fabric
|
|
7
|
+
* @summary Implements ERC20-like token logic using repositories and adapters, providing standard token operations such as balance queries, transfers, approvals, minting and burning.
|
|
8
|
+
* @param {string} name - The contract name used to scope token identity
|
|
9
|
+
* @note https://eips.ethereum.org/EIPS/eip-20
|
|
10
|
+
* @return {void}
|
|
11
|
+
* @class FabricERC20Contract
|
|
12
|
+
* @example
|
|
13
|
+
* class MyTokenContract extends FabricERC20Contract {
|
|
14
|
+
* constructor() { super('MyToken'); }
|
|
15
|
+
* }
|
|
16
|
+
* // The contract exposes methods like Transfer, Approve, Mint, Burn, etc.
|
|
17
|
+
* @mermaid
|
|
18
|
+
* sequenceDiagram
|
|
19
|
+
* participant Client
|
|
20
|
+
* participant Contract
|
|
21
|
+
* participant WalletRepo
|
|
22
|
+
* participant TokenRepo
|
|
23
|
+
* participant Ledger
|
|
24
|
+
* Client->>Contract: Transfer(ctx, to, value)
|
|
25
|
+
* Contract->>WalletRepo: read(from)
|
|
26
|
+
* Contract->>WalletRepo: read(to)
|
|
27
|
+
* Contract->>Ledger: putState(updated balances)
|
|
28
|
+
* Contract-->>Client: success
|
|
29
|
+
*/
|
|
30
|
+
export declare abstract class FabricERC20Contract extends FabricCrudContract<ERC20Wallet> {
|
|
31
|
+
private walletRepository;
|
|
32
|
+
private tokenRepository;
|
|
33
|
+
private allowanceRepository;
|
|
34
|
+
protected constructor(name: string);
|
|
35
|
+
TokenName(context: Context): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Return the symbol of the token. E.g. “HIX”.
|
|
38
|
+
*
|
|
39
|
+
* @param {Context} context the transaction context
|
|
40
|
+
* @returns {String} Returns the symbol of the token
|
|
41
|
+
*/
|
|
42
|
+
Symbol(context: Context): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Return the number of decimals the token uses
|
|
45
|
+
* e.g. 8, means to divide the token amount by 100000000 to get its user representation.
|
|
46
|
+
*
|
|
47
|
+
* @param {Context} context the transaction context
|
|
48
|
+
* @returns {Number} Returns the number of decimals
|
|
49
|
+
*/
|
|
50
|
+
Decimals(context: Context): Promise<number>;
|
|
51
|
+
/**
|
|
52
|
+
* Return the total token supply.
|
|
53
|
+
*
|
|
54
|
+
* @param {Context} context the transaction context
|
|
55
|
+
* @returns {Number} Returns the total token supply
|
|
56
|
+
*/
|
|
57
|
+
TotalSupply(context: Context): Promise<number>;
|
|
58
|
+
/**
|
|
59
|
+
* BalanceOf returns the balance of the given account.
|
|
60
|
+
*
|
|
61
|
+
* @param {Context} ctx the transaction context
|
|
62
|
+
* @param {String} owner The owner from which the balance will be retrieved
|
|
63
|
+
* @returns {Number} Returns the account balance
|
|
64
|
+
*/
|
|
65
|
+
BalanceOf(context: Context, owner: string): Promise<number>;
|
|
66
|
+
/**
|
|
67
|
+
* @summary Transfer transfers tokens from client account to recipient account.
|
|
68
|
+
* @description recipient account must be a valid clientID as returned by the ClientAccountID() function.
|
|
69
|
+
*
|
|
70
|
+
* @param {Context} context the transaction context
|
|
71
|
+
* @param {String} to The recipient
|
|
72
|
+
* @param {number} value The amount of token to be transferred
|
|
73
|
+
*
|
|
74
|
+
* @returns {Boolean} Return whether the transfer was successful or not
|
|
75
|
+
*/
|
|
76
|
+
Transfer(context: Context, to: string, value: number): Promise<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* Transfer `value` amount of tokens from `from` to `to`.
|
|
79
|
+
*
|
|
80
|
+
* @param {Context} context the transaction context
|
|
81
|
+
* @param {String} from The sender
|
|
82
|
+
* @param {String} to The recipient
|
|
83
|
+
* @param {number} value The amount of token to be transferred
|
|
84
|
+
* @returns {Boolean} Return whether the transfer was successful or not
|
|
85
|
+
*/
|
|
86
|
+
TransferFrom(context: Context, from: string, to: string, value: number): Promise<boolean>;
|
|
87
|
+
_transfer(from: string, to: string, value: number, ctx: FabricContractContext): Promise<boolean>;
|
|
88
|
+
/**
|
|
89
|
+
* Allows `spender` to spend `value` amount of tokens from the owner. New Approve calls override the previous allowance.
|
|
90
|
+
* @note https://eips.ethereum.org/EIPS/eip-20
|
|
91
|
+
*
|
|
92
|
+
* @param {Context} ctx the transaction context
|
|
93
|
+
* @param {String} spender The spender
|
|
94
|
+
* @param {number} value The amount of tokens to be approved for transfer
|
|
95
|
+
* @returns {Boolean} Return whether the approval was successful or not
|
|
96
|
+
*/
|
|
97
|
+
Approve(context: Context, spender: string, value: number): Promise<boolean>;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the amount of tokens which ` ` is allowed to withdraw from `owner`.
|
|
100
|
+
*
|
|
101
|
+
* @param {Context} ctx the transaction context
|
|
102
|
+
* @param {String} owner The owner of tokens
|
|
103
|
+
* @param {String} spender The spender who are able to transfer the tokens
|
|
104
|
+
* @returns {number} Return the amount of remaining tokens allowed to spent
|
|
105
|
+
*/
|
|
106
|
+
Allowance(context: Context, owner: string, spender: string): Promise<number>;
|
|
107
|
+
_getAllowance(owner: string, spender: string, ctx: FabricContractContext): Promise<Allowance>;
|
|
108
|
+
/**
|
|
109
|
+
* Set optional infomation for a token.
|
|
110
|
+
*
|
|
111
|
+
* @param {Context} ctx the transaction context
|
|
112
|
+
* @param {String} name The name of the token
|
|
113
|
+
* @param {String} symbol The symbol of the token
|
|
114
|
+
* @param {String} decimals The decimals of the token
|
|
115
|
+
* @param {String} totalSupply The totalSupply of the token
|
|
116
|
+
*/
|
|
117
|
+
Initialize(context: Context, token: ERC20Token): Promise<boolean>;
|
|
118
|
+
CheckInitialized(context: Context): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Mint creates new tokens and adds them to minter's account balance
|
|
121
|
+
*
|
|
122
|
+
* @param {Context} context the transaction context
|
|
123
|
+
* @param {number} amount amount of tokens to be minted
|
|
124
|
+
* @returns {Object} The balance
|
|
125
|
+
*/
|
|
126
|
+
Mint(context: Context, amount: number): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Burn redeem tokens from minter's account balance
|
|
129
|
+
*
|
|
130
|
+
* @param {Context} context the transaction context
|
|
131
|
+
* @param {number} amount amount of tokens to be burned
|
|
132
|
+
* @returns {Object} The balance
|
|
133
|
+
*/
|
|
134
|
+
Burn(context: Context, amount: number): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* BurnFrom redeem tokens from account allowence and balance
|
|
137
|
+
*
|
|
138
|
+
* @param {Context} context the transaction context
|
|
139
|
+
* @param {number} account account from where tokens will be burned
|
|
140
|
+
* @param {number} amount amount of tokens to be burned
|
|
141
|
+
* @returns {Object} The balance
|
|
142
|
+
*/
|
|
143
|
+
BurnFrom(context: Context, account: string, amount: number): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* ClientAccountBalance returns the balance of the requesting client's account.
|
|
146
|
+
*
|
|
147
|
+
* @param {Context} context the transaction context
|
|
148
|
+
* @returns {Number} Returns the account balance
|
|
149
|
+
*/
|
|
150
|
+
ClientAccountBalance(context: Context): Promise<number>;
|
|
151
|
+
ClientAccountID(context: Context): Promise<string>;
|
|
152
|
+
}
|