From 4ea2b1562e849ff570a384151a7ab16324b4c097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D0=B5=D0=BC?= Date: Fri, 1 Jul 2022 13:40:47 +0300 Subject: [PATCH] TD-330: Bump damsel (#20) * bumped to valitydev/damsel@03bbf48 * fixed after bump * updated workflow version * fixed fmt and linter * fixed * fixed * changed cache version * Revert "Auxiliary commit to revert individual files from 7f5eb344211ed6353bf5391b9d331ef2fc50ebf7" This reverts commit 8d9749077970f9b0759b777e90a35d188a3d669c. * fixed --- .env | 2 +- .github/workflows/erlang-checks.yaml | 3 +- .../include/claim_management.hrl | 72 +++++------ .../party_management/include/party_events.hrl | 2 +- apps/party_management/src/pm_accounting.erl | 2 +- apps/party_management/src/pm_cashflow.erl | 3 +- apps/party_management/src/pm_claim.erl | 19 +-- .../src/pm_claim_committer.erl | 20 ++-- .../src/pm_claim_committer_converter.erl | 6 +- .../src/pm_claim_committer_effect.erl | 13 +- .../src/pm_claim_committer_handler.erl | 6 +- .../src/pm_claim_committer_validator.erl | 5 +- apps/party_management/src/pm_claim_effect.erl | 7 +- apps/party_management/src/pm_contract.erl | 23 ++-- apps/party_management/src/pm_currency.erl | 6 +- apps/party_management/src/pm_datetime.erl | 8 +- apps/party_management/src/pm_domain.erl | 22 ++-- apps/party_management/src/pm_machine.erl | 4 +- apps/party_management/src/pm_party.erl | 21 ++-- .../src/pm_party_contractor.erl | 3 +- .../party_management/src/pm_party_handler.erl | 3 +- .../party_management/src/pm_party_machine.erl | 112 +++++++++--------- .../src/pm_payment_institution.erl | 5 - apps/party_management/src/pm_payout_tool.erl | 9 +- apps/party_management/src/pm_provider.erl | 4 +- apps/party_management/src/pm_ruleset.erl | 2 +- apps/party_management/src/pm_selector.erl | 5 +- apps/party_management/src/pm_varset.erl | 11 +- apps/party_management/src/pm_wallet.erl | 11 +- .../test/pm_claim_committer_SUITE.erl | 54 +++++---- apps/party_management/test/pm_ct_domain.erl | 10 +- apps/party_management/test/pm_ct_domain.hrl | 4 +- apps/party_management/test/pm_ct_fixture.erl | 8 +- apps/party_management/test/pm_ct_helper.erl | 6 +- .../test/pm_party_tests_SUITE.erl | 6 +- apps/pm_client/src/pm_client_event_poller.erl | 2 +- apps/pm_client/src/pm_client_party.erl | 30 ++--- apps/pm_proto/.gitignore | 4 +- apps/pm_proto/Makefile | 11 -- apps/pm_proto/include/dmsl_base_thrift.hrl | 1 - apps/pm_proto/include/dmsl_domain_thrift.hrl | 1 - .../dmsl_payment_processing_thrift.hrl | 1 - apps/pm_proto/proto/party_state.thrift | 2 +- apps/pm_proto/rebar.config | 28 +++-- apps/pm_proto/src/pm_proto.erl | 4 +- elvis.config | 2 +- rebar.config | 2 +- rebar.lock | 12 +- 48 files changed, 300 insertions(+), 297 deletions(-) delete mode 100644 apps/pm_proto/Makefile delete mode 100644 apps/pm_proto/include/dmsl_base_thrift.hrl delete mode 100644 apps/pm_proto/include/dmsl_domain_thrift.hrl delete mode 100644 apps/pm_proto/include/dmsl_payment_processing_thrift.hrl diff --git a/.env b/.env index 1c8ee03..d7c6f3f 100644 --- a/.env +++ b/.env @@ -4,4 +4,4 @@ SERVICE_NAME=party-management OTP_VERSION=24.2.0 REBAR_VERSION=3.18 -THRIFT_VERSION=0.14.2.2 +THRIFT_VERSION=0.14.2.3 diff --git a/.github/workflows/erlang-checks.yaml b/.github/workflows/erlang-checks.yaml index 4bb7abf..f08b691 100644 --- a/.github/workflows/erlang-checks.yaml +++ b/.github/workflows/erlang-checks.yaml @@ -30,10 +30,11 @@ jobs: run: name: Run checks needs: setup - uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.1 + uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.3 with: otp-version: ${{ needs.setup.outputs.otp-version }} rebar-version: ${{ needs.setup.outputs.rebar-version }} use-thrift: true thrift-version: ${{ needs.setup.outputs.thrift-version }} run-ct-with-compose: true + cache-version: v2 diff --git a/apps/party_management/include/claim_management.hrl b/apps/party_management/include/claim_management.hrl index 8cd77f6..b353a86 100644 --- a/apps/party_management/include/claim_management.hrl +++ b/apps/party_management/include/claim_management.hrl @@ -1,9 +1,9 @@ -ifndef(__pm_claim_management_hrl__). -define(__pm_claim_management_hrl__, included). --include_lib("damsel/include/dmsl_claim_management_thrift.hrl"). +-include_lib("damsel/include/dmsl_claimmgmt_thrift.hrl"). --define(cm_modification_unit(ModID, Timestamp, Mod, UserInfo), #claim_management_ModificationUnit{ +-define(cm_modification_unit(ModID, Timestamp, Mod, UserInfo), #claimmgmt_ModificationUnit{ modification_id = ModID, created_at = Timestamp, modification = Mod, @@ -21,7 +21,7 @@ %%% Contractor -define(cm_contractor_modification(ContractorID, Mod), - {contractor_modification, #claim_management_ContractorModificationUnit{ + {contractor_modification, #claimmgmt_ContractorModificationUnit{ id = ContractorID, modification = Mod }} @@ -42,7 +42,7 @@ %%% Contract -define(cm_contract_modification(ContractID, Mod), - {contract_modification, #claim_management_ContractModificationUnit{ + {contract_modification, #claimmgmt_ContractModificationUnit{ id = ContractID, modification = Mod }} @@ -53,11 +53,11 @@ ). -define(cm_contract_termination(Reason), - {termination, #claim_management_ContractTermination{reason = Reason}} + {termination, #claimmgmt_ContractTermination{reason = Reason}} ). -define(cm_payout_tool_modification(PayoutToolID, Mod), - {payout_tool_modification, #claim_management_PayoutToolModificationUnit{ + {payout_tool_modification, #claimmgmt_PayoutToolModificationUnit{ payout_tool_id = PayoutToolID, modification = Mod }} @@ -72,13 +72,13 @@ ). -define(cm_payout_schedule_modification(BusinessScheduleRef), - {payout_schedule_modification, #claim_management_ScheduleModification{ + {payout_schedule_modification, #claimmgmt_ScheduleModification{ schedule = BusinessScheduleRef }} ). -define(cm_cash_register_unit_creation(ID, Params), - {creation, #claim_management_CashRegisterParams{ + {creation, #claimmgmt_CashRegisterParams{ cash_register_provider_id = ID, cash_register_provider_params = Params }} @@ -93,7 +93,7 @@ ). -define(cm_adjustment_modification(ContractAdjustmentID, Mod), - {adjustment_modification, #claim_management_ContractAdjustmentModificationUnit{ + {adjustment_modification, #claimmgmt_ContractAdjustmentModificationUnit{ adjustment_id = ContractAdjustmentID, modification = Mod }} @@ -109,14 +109,14 @@ %%% Shop -define(cm_shop_modification(ShopID, Mod), - {shop_modification, #claim_management_ShopModificationUnit{ + {shop_modification, #claimmgmt_ShopModificationUnit{ id = ShopID, modification = Mod }} ). -define(cm_shop_contract_modification(ContractID, PayoutToolID), - {contract_modification, #claim_management_ShopContractModification{ + {contract_modification, #claimmgmt_ShopContractModification{ contract_id = ContractID, payout_tool_id = PayoutToolID }} @@ -127,7 +127,7 @@ ). -define(cm_shop_account_creation_params(CurrencyRef), - {shop_account_creation, #claim_management_ShopAccountParams{ + {shop_account_creation, #claimmgmt_ShopAccountParams{ currency = CurrencyRef }} ). @@ -141,18 +141,18 @@ %%% Wallet -define(cm_wallet_modification(ID, Modification), - {wallet_modification, #claim_management_WalletModificationUnit{id = ID, modification = Modification}} + {wallet_modification, #claimmgmt_WalletModificationUnit{id = ID, modification = Modification}} ). -define(cm_wallet_creation_params(Name, ContractID), - {creation, #claim_management_WalletParams{ + {creation, #claimmgmt_WalletParams{ name = Name, contract_id = ContractID }} ). -define(cm_wallet_account_creation_params(CurrencyRef), - {account_creation, #claim_management_WalletAccountParams{ + {account_creation, #claimmgmt_WalletAccountParams{ currency = CurrencyRef }} ). @@ -173,31 +173,31 @@ %%% Error --define(cm_invalid_party_changeset(Reason, InvalidChangeset), #claim_management_InvalidChangeset{ +-define(cm_invalid_party_changeset(Reason, InvalidChangeset), #claimmgmt_InvalidChangeset{ reason = {invalid_party_changeset, Reason}, invalid_changeset = InvalidChangeset }). -define(cm_invalid_shop(ID, Reason), - {invalid_shop, #claim_management_InvalidShop{id = ID, reason = Reason}} + {invalid_shop, #claimmgmt_InvalidShop{id = ID, reason = Reason}} ). -define(cm_invalid_shop_account_not_exists(ID), - ?cm_invalid_shop(ID, {account_not_exists, #claim_management_InvalidClaimConcreteReason{}}) + ?cm_invalid_shop(ID, {account_not_exists, #claimmgmt_InvalidClaimConcreteReason{}}) ). -define(cm_invalid_shop_not_exists(ID), - ?cm_invalid_shop(ID, {not_exists, #claim_management_InvalidClaimConcreteReason{}}) + ?cm_invalid_shop(ID, {not_exists, #claimmgmt_InvalidClaimConcreteReason{}}) ). -define(cm_invalid_shop_already_exists(ID), - ?cm_invalid_shop(ID, {already_exists, #claim_management_InvalidClaimConcreteReason{}}) + ?cm_invalid_shop(ID, {already_exists, #claimmgmt_InvalidClaimConcreteReason{}}) ). -define(cm_invalid_shop_contract_terms_violated(ID, ContractID, Terms), ?cm_invalid_shop( ID, - {contract_terms_violated, #claim_management_ContractTermsViolated{ + {contract_terms_violated, #claimmgmt_ContractTermsViolated{ contract_id = ContractID, terms = Terms }} @@ -211,7 +211,7 @@ -define(cm_invalid_shop_payout_tool_not_set_for_payouts(ID, Schedule), ?cm_invalid_shop_payout_tool( ID, - {not_set_for_payouts, #claim_management_PayoutToolNotSetForPayouts{ + {not_set_for_payouts, #claimmgmt_PayoutToolNotSetForPayouts{ payout_schedule = Schedule }} ) @@ -220,7 +220,7 @@ -define(cm_invalid_shop_payout_tool_currency_mismatch(ID, PayoutToolID, ShopAccountCurrency, PayoutToolCurrency), ?cm_invalid_shop_payout_tool( ID, - {currency_mismatch, #claim_management_PayoutToolCurrencyMismatch{ + {currency_mismatch, #claimmgmt_PayoutToolCurrencyMismatch{ shop_account_currency = ShopAccountCurrency, payout_tool_id = PayoutToolID, payout_tool_currency = PayoutToolCurrency @@ -231,7 +231,7 @@ -define(cm_invalid_shop_payout_tool_not_in_contract(ID, ContractID, PayoutToolID), ?cm_invalid_shop_payout_tool( ID, - {not_in_contract, #claim_management_PayoutToolNotInContract{ + {not_in_contract, #claimmgmt_PayoutToolNotInContract{ contract_id = ContractID, payout_tool_id = PayoutToolID }} @@ -239,15 +239,15 @@ ). -define(cm_invalid_contract(ID, Reason), - {invalid_contract, #claim_management_InvalidContract{id = ID, reason = Reason}} + {invalid_contract, #claimmgmt_InvalidContract{id = ID, reason = Reason}} ). -define(cm_invalid_contract_not_exists(ID), - ?cm_invalid_contract(ID, {not_exists, #claim_management_InvalidClaimConcreteReason{}}) + ?cm_invalid_contract(ID, {not_exists, #claimmgmt_InvalidClaimConcreteReason{}}) ). -define(cm_invalid_contract_already_exists(ID), - ?cm_invalid_contract(ID, {already_exists, #claim_management_InvalidClaimConcreteReason{}}) + ?cm_invalid_contract(ID, {already_exists, #claimmgmt_InvalidClaimConcreteReason{}}) ). -define(cm_invalid_contract_invalid_status_terminated(ID, T), @@ -255,41 +255,41 @@ ). -define(cm_invalid_contract_contractor_not_exists(ID, ContractorID), - ?cm_invalid_contract(ID, {contractor_not_exists, #claim_management_ContractorNotExists{id = ContractorID}}) + ?cm_invalid_contract(ID, {contractor_not_exists, #claimmgmt_ContractorNotExists{id = ContractorID}}) ). -define(cm_invalid_contractor(ID, Reason), - {invalid_contractor, #claim_management_InvalidContractor{id = ID, reason = Reason}} + {invalid_contractor, #claimmgmt_InvalidContractor{id = ID, reason = Reason}} ). -define(cm_invalid_contractor_not_exists(ID), - ?cm_invalid_contractor(ID, {not_exists, #claim_management_InvalidClaimConcreteReason{}}) + ?cm_invalid_contractor(ID, {not_exists, #claimmgmt_InvalidClaimConcreteReason{}}) ). -define(cm_invalid_contractor_already_exists(ID), - ?cm_invalid_contractor(ID, {already_exists, #claim_management_InvalidClaimConcreteReason{}}) + ?cm_invalid_contractor(ID, {already_exists, #claimmgmt_InvalidClaimConcreteReason{}}) ). -define(cm_invalid_wallet(ID, Reason), - {invalid_wallet, #claim_management_InvalidWallet{id = ID, reason = Reason}} + {invalid_wallet, #claimmgmt_InvalidWallet{id = ID, reason = Reason}} ). -define(cm_invalid_wallet_not_exists(ID), - ?cm_invalid_wallet(ID, {not_exists, #claim_management_InvalidClaimConcreteReason{}}) + ?cm_invalid_wallet(ID, {not_exists, #claimmgmt_InvalidClaimConcreteReason{}}) ). -define(cm_invalid_wallet_already_exists(ID), - ?cm_invalid_wallet(ID, {already_exists, #claim_management_InvalidClaimConcreteReason{}}) + ?cm_invalid_wallet(ID, {already_exists, #claimmgmt_InvalidClaimConcreteReason{}}) ). -define(cm_invalid_wallet_account_not_exists(ID), - ?cm_invalid_wallet(ID, {account_not_exists, #claim_management_InvalidClaimConcreteReason{}}) + ?cm_invalid_wallet(ID, {account_not_exists, #claimmgmt_InvalidClaimConcreteReason{}}) ). -define(cm_invalid_wallet_contract_terms_violated(ID, ContractID, Terms), ?cm_invalid_wallet( ID, - {contract_terms_violated, #claim_management_ContractTermsViolated{ + {contract_terms_violated, #claimmgmt_ContractTermsViolated{ contract_id = ContractID, terms = Terms }} diff --git a/apps/party_management/include/party_events.hrl b/apps/party_management/include/party_events.hrl index b40a2f7..e041920 100644 --- a/apps/party_management/include/party_events.hrl +++ b/apps/party_management/include/party_events.hrl @@ -1,7 +1,7 @@ -ifndef(__pm_party_events_hrl__). -define(__pm_party_events_hrl__, included). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -define(party_ev(PartyChanges), {party_changes, PartyChanges}). diff --git a/apps/party_management/src/pm_accounting.erl b/apps/party_management/src/pm_accounting.erl index 139d2a9..de64efd 100644 --- a/apps/party_management/src/pm_accounting.erl +++ b/apps/party_management/src/pm_accounting.erl @@ -4,7 +4,7 @@ -export([get_balance/1]). -export([create_account/1]). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -include_lib("damsel/include/dmsl_accounter_thrift.hrl"). -type amount() :: dmsl_domain_thrift:'Amount'(). diff --git a/apps/party_management/src/pm_cashflow.erl b/apps/party_management/src/pm_cashflow.erl index fa962c0..edbccbf 100644 --- a/apps/party_management/src/pm_cashflow.erl +++ b/apps/party_management/src/pm_cashflow.erl @@ -9,6 +9,7 @@ -module(pm_cashflow). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). +-include_lib("damsel/include/dmsl_base_thrift.hrl"). -type account() :: dmsl_domain_thrift:'CashFlowAccount'(). -type account_id() :: dmsl_domain_thrift:'AccountID'(). @@ -80,7 +81,7 @@ resolve_account(AccountType, AccountMap) -> {product, {Fun, CVs}} ). --define(rational(P, Q), #'Rational'{p = P, q = Q}). +-define(rational(P, Q), #base_Rational{p = P, q = Q}). compute_volume(?fixed(Cash), _Context) -> Cash; diff --git a/apps/party_management/src/pm_claim.erl b/apps/party_management/src/pm_claim.erl index 7d12209..da3113f 100644 --- a/apps/party_management/src/pm_claim.erl +++ b/apps/party_management/src/pm_claim.erl @@ -3,7 +3,8 @@ -include("party_events.hrl"). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_base_thrift.hrl"). -export([create/5]). -export([update/5]). @@ -30,11 +31,11 @@ %% Types --type claim() :: dmsl_payment_processing_thrift:'Claim'(). --type claim_id() :: dmsl_payment_processing_thrift:'ClaimID'(). --type claim_status() :: dmsl_payment_processing_thrift:'ClaimStatus'(). --type claim_revision() :: dmsl_payment_processing_thrift:'ClaimRevision'(). --type changeset() :: dmsl_payment_processing_thrift:'PartyChangeset'(). +-type claim() :: dmsl_payproc_thrift:'Claim'(). +-type claim_id() :: dmsl_payproc_thrift:'ClaimID'(). +-type claim_status() :: dmsl_payproc_thrift:'ClaimStatus'(). +-type claim_revision() :: dmsl_payproc_thrift:'ClaimRevision'(). +-type changeset() :: dmsl_payproc_thrift:'PartyChangeset'(). -type party() :: pm_party:party(). @@ -396,7 +397,7 @@ apply_wallet_effect(ID, Effect, Party) -> update_wallet({account_created, Account}, Wallet) -> Wallet#domain_Wallet{account = Account}. --spec raise_invalid_changeset(dmsl_payment_processing_thrift:'InvalidChangesetReason'()) -> no_return(). +-spec raise_invalid_changeset(dmsl_payproc_thrift:'InvalidChangesetReason'()) -> no_return(). raise_invalid_changeset(Reason) -> throw(#payproc_InvalidChangeset{reason = Reason}). @@ -489,7 +490,7 @@ assert_shop_change_applicable( _Party, _Revision ) when Account /= undefined -> - throw(#'InvalidRequest'{errors = [<<"Can't change shop's account">>]}); + throw(#base_InvalidRequest{errors = [<<"Can't change shop's account">>]}); assert_shop_change_applicable( _ID, {contract_modification, #payproc_ShopContractModification{contract_id = NewContractID}}, @@ -527,7 +528,7 @@ assert_wallet_change_applicable( {account_creation, _}, #domain_Wallet{account = Account} ) when Account /= undefined -> - throw(#'InvalidRequest'{errors = [<<"Can't change wallet's account">>]}); + throw(#base_InvalidRequest{errors = [<<"Can't change wallet's account">>]}); assert_wallet_change_applicable(_, _, _) -> ok. diff --git a/apps/party_management/src/pm_claim_committer.erl b/apps/party_management/src/pm_claim_committer.erl index 8efa0a0..22d0f1c 100644 --- a/apps/party_management/src/pm_claim_committer.erl +++ b/apps/party_management/src/pm_claim_committer.erl @@ -1,7 +1,9 @@ -module(pm_claim_committer). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). --include_lib("damsel/include/dmsl_claim_management_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_claimmgmt_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). +-include_lib("damsel/include/dmsl_base_thrift.hrl"). -include("claim_management.hrl"). -include("party_events.hrl"). @@ -13,10 +15,10 @@ -export([raise_invalid_changeset/2]). -type party() :: pm_party:party(). --type changeset() :: dmsl_claim_management_thrift:'ClaimChangeset'(). +-type changeset() :: dmsl_claimmgmt_thrift:'ClaimChangeset'(). -type timestamp() :: pm_datetime:timestamp(). -type revision() :: pm_domain:revision(). --type modification() :: dmsl_claim_management_thrift:'PartyModification'(). +-type modification() :: dmsl_claimmgmt_thrift:'PartyModification'(). -type modifications() :: [modification()]. -export_type([modification/0]). @@ -175,10 +177,10 @@ assert_shop_modification_applicable( _Revision, _PartyChange ) when Account /= undefined -> - throw(#'InvalidRequest'{errors = [<<"Can't change shop's account">>]}); + throw(#base_InvalidRequest{errors = [<<"Can't change shop's account">>]}); assert_shop_modification_applicable( _ID, - {contract_modification, #claim_management_ShopContractModification{contract_id = NewContractID}}, + {contract_modification, #claimmgmt_ShopContractModification{contract_id = NewContractID}}, #domain_Shop{contract_id = OldContractID}, Party, Revision, @@ -215,7 +217,7 @@ assert_wallet_modification_applicable( #domain_Wallet{account = Account}, _PartyChange ) when Account /= undefined -> - throw(#'InvalidRequest'{errors = [<<"Can't change wallet's account">>]}); + throw(#base_InvalidRequest{errors = [<<"Can't change wallet's account">>]}); assert_wallet_modification_applicable(_, _, _, _) -> ok. @@ -250,7 +252,7 @@ raise_invalid_payment_institution(ContractID, Ref, PartyChange) -> raise_invalid_changeset( ?cm_invalid_contract( ContractID, - {invalid_object_reference, #claim_management_InvalidObjectReference{ + {invalid_object_reference, #claimmgmt_InvalidObjectReference{ ref = make_optional_domain_ref(payment_institution, Ref) }} ), @@ -271,7 +273,7 @@ assert_modifications_acceptable(Modifications, Timestamp, Revision, Party0) -> erlang:raise(throw, build_invalid_party_changeset(Reason, Modifications), St) end. --spec raise_invalid_changeset(dmsl_claim_management_thrift:'InvalidChangesetReason'(), modifications()) -> no_return(). +-spec raise_invalid_changeset(dmsl_claimmgmt_thrift:'InvalidChangesetReason'(), modifications()) -> no_return(). raise_invalid_changeset(Reason, Modifications) -> throw(build_invalid_party_changeset(Reason, Modifications)). diff --git a/apps/party_management/src/pm_claim_committer_converter.erl b/apps/party_management/src/pm_claim_committer_converter.erl index dbb50b8..e0dfe4b 100644 --- a/apps/party_management/src/pm_claim_committer_converter.erl +++ b/apps/party_management/src/pm_claim_committer_converter.erl @@ -16,17 +16,17 @@ -module(pm_claim_committer_converter). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -include("party_events.hrl"). %% API -export([new_party_claim/4]). --type payproc_claim() :: dmsl_payment_processing_thrift:'Claim'(). +-type payproc_claim() :: dmsl_payproc_thrift:'Claim'(). -type timestamp() :: pm_datetime:timestamp(). -type revision() :: pm_domain:revision(). --type claim_id() :: dmsl_claim_management_thrift:'ClaimID'(). +-type claim_id() :: dmsl_claimmgmt_thrift:'ClaimID'(). -spec new_party_claim(claim_id(), revision(), timestamp(), timestamp()) -> payproc_claim(). new_party_claim(ID, Revision, CreatedAt, UpdatedAt) -> diff --git a/apps/party_management/src/pm_claim_committer_effect.erl b/apps/party_management/src/pm_claim_committer_effect.erl index bd8c628..133fd93 100644 --- a/apps/party_management/src/pm_claim_committer_effect.erl +++ b/apps/party_management/src/pm_claim_committer_effect.erl @@ -3,8 +3,9 @@ -include("claim_management.hrl"). -include("party_events.hrl"). --include_lib("damsel/include/dmsl_claim_management_thrift.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_claimmgmt_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). -export([make/3]). -export([make_safe/3]). @@ -20,11 +21,11 @@ -type modification() :: pm_claim_committer:modification(). -type modifications() :: pm_claim_committer:modifications(). --type effect() :: dmsl_payment_processing_thrift:'ClaimEffect'(). +-type effect() :: dmsl_payproc_thrift:'ClaimEffect'(). -type timestamp() :: pm_datetime:timestamp(). -type revision() :: pm_domain:revision(). -type party() :: pm_party:party(). --type effects() :: dmsl_payment_processing_thrift:'ClaimEffects'(). +-type effects() :: dmsl_payproc_thrift:'ClaimEffects'(). -spec make(modification(), timestamp(), revision()) -> effect() | no_return(). make(?cm_contractor_modification(ID, Modification), Timestamp, Revision) -> @@ -153,7 +154,7 @@ assert_valid_object_ref(Prefix, Ref, Revision) -> pm_domain:ref() ) -> no_return(). raise_invalid_object_ref(Prefix, Ref) -> - Ex = {invalid_object_reference, #claim_management_InvalidObjectReference{ref = Ref}}, + Ex = {invalid_object_reference, #claimmgmt_InvalidObjectReference{ref = Ref}}, raise_invalid_object_ref_(Prefix, Ex). -spec raise_invalid_object_ref_(term(), term()) -> no_return(). @@ -162,7 +163,7 @@ raise_invalid_object_ref_({shop, ID}, Ex) -> raise_invalid_object_ref_({contract, ID}, Ex) -> pm_claim_committer:raise_invalid_changeset(?cm_invalid_contract(ID, Ex), []). -create_shop_account(#claim_management_ShopAccountParams{currency = Currency}) -> +create_shop_account(#claimmgmt_ShopAccountParams{currency = Currency}) -> create_shop_account(Currency); create_shop_account(#domain_CurrencyRef{symbolic_code = SymbolicCode} = CurrencyRef) -> GuaranteeID = pm_accounting:create_account(SymbolicCode), diff --git a/apps/party_management/src/pm_claim_committer_handler.erl b/apps/party_management/src/pm_claim_committer_handler.erl index 643d3a3..5e98c45 100644 --- a/apps/party_management/src/pm_claim_committer_handler.erl +++ b/apps/party_management/src/pm_claim_committer_handler.erl @@ -1,7 +1,7 @@ -module(pm_claim_committer_handler). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). --include_lib("damsel/include/dmsl_claim_management_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_claimmgmt_thrift.hrl"). -behaviour(pm_woody_wrapper). @@ -24,5 +24,5 @@ call(PartyID, FunctionName, Args) -> pm_party_machine:call(PartyID, claim_committer, {'ClaimCommitter', FunctionName}, Args) catch throw:#payproc_PartyNotFound{} -> - erlang:throw(#claim_management_PartyNotFound{}) + erlang:throw(#claimmgmt_PartyNotFound{}) end. diff --git a/apps/party_management/src/pm_claim_committer_validator.erl b/apps/party_management/src/pm_claim_committer_validator.erl index 4cf7838..007bd4b 100644 --- a/apps/party_management/src/pm_claim_committer_validator.erl +++ b/apps/party_management/src/pm_claim_committer_validator.erl @@ -16,8 +16,9 @@ -module(pm_claim_committer_validator). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). --include_lib("damsel/include/dmsl_claim_management_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_claimmgmt_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). -include("claim_management.hrl"). -include("party_events.hrl"). diff --git a/apps/party_management/src/pm_claim_effect.erl b/apps/party_management/src/pm_claim_effect.erl index a2efc77..078bc23 100644 --- a/apps/party_management/src/pm_claim_effect.erl +++ b/apps/party_management/src/pm_claim_effect.erl @@ -2,7 +2,8 @@ -include("party_events.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). -export([make/3]). -export([make_safe/3]). @@ -11,8 +12,8 @@ %% Interface --type change() :: dmsl_payment_processing_thrift:'PartyModification'(). --type effect() :: dmsl_payment_processing_thrift:'ClaimEffect'(). +-type change() :: dmsl_payproc_thrift:'PartyModification'(). +-type effect() :: dmsl_payproc_thrift:'ClaimEffect'(). -type timestamp() :: pm_datetime:timestamp(). -type revision() :: pm_domain:revision(). diff --git a/apps/party_management/src/pm_contract.erl b/apps/party_management/src/pm_contract.erl index f9539c8..b86ea0d 100644 --- a/apps/party_management/src/pm_contract.erl +++ b/apps/party_management/src/pm_contract.erl @@ -1,7 +1,8 @@ -module(pm_contract). --include_lib("damsel/include/dmsl_claim_management_thrift.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_claimmgmt_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). %% @@ -23,13 +24,13 @@ -type contract() :: dmsl_domain_thrift:'Contract'(). -type contract_id() :: dmsl_domain_thrift:'ContractID'(). -type contract_params() :: - dmsl_payment_processing_thrift:'ContractParams'() | dmsl_claim_management_thrift:'ContractParams'(). + dmsl_payproc_thrift:'ContractParams'() | dmsl_claimmgmt_thrift:'ContractParams'(). -type contract_template() :: dmsl_domain_thrift:'ContractTemplate'(). -type adjustment() :: dmsl_domain_thrift:'ContractAdjustment'(). -type adjustment_id() :: dmsl_domain_thrift:'ContractAdjustmentID'(). -type adjustment_params() :: - dmsl_payment_processing_thrift:'ContractAdjustmentParams'() - | dmsl_claim_management_thrift:'ContractAdjustmentParams'(). + dmsl_payproc_thrift:'ContractAdjustmentParams'() + | dmsl_claimmgmt_thrift:'ContractAdjustmentParams'(). -type payout_tool() :: dmsl_domain_thrift:'PayoutTool'(). -type payout_tool_id() :: dmsl_domain_thrift:'PayoutToolID'(). -type category() :: dmsl_domain_thrift:'CategoryRef'(). @@ -68,8 +69,8 @@ create(ID, #payproc_ContractParams{} = Params, Timestamp, Revision) -> adjustments = [], payout_tools = [] }; -create(ID, #claim_management_ContractParams{} = Params, Timestamp, Revision) -> - #claim_management_ContractParams{ +create(ID, #claimmgmt_ContractParams{} = Params, Timestamp, Revision) -> + #claimmgmt_ContractParams{ contractor_id = ContractorID, template = TemplateRef, payment_institution = PaymentInstitutionRef @@ -130,8 +131,8 @@ create_adjustment(ID, #payproc_ContractAdjustmentParams{} = Params, Timestamp, R valid_until = instantiate_contract_lifetime_bound(ValidUntil, Timestamp), terms = TermSetHierarchyRef }; -create_adjustment(ID, #claim_management_ContractAdjustmentParams{} = Params, Timestamp, Revision) -> - #claim_management_ContractAdjustmentParams{ +create_adjustment(ID, #claimmgmt_ContractAdjustmentParams{} = Params, Timestamp, Revision) -> + #claimmgmt_ContractAdjustmentParams{ template = TemplateRef } = Params, #domain_ContractTemplate{ @@ -219,14 +220,14 @@ ensure_contract_creation_params( payment_institution = ValidRef }; ensure_contract_creation_params( - #claim_management_ContractParams{ + #claimmgmt_ContractParams{ template = TemplateRef, payment_institution = PaymentInstitutionRef } = Params, Revision ) -> ValidRef = ensure_payment_institution(PaymentInstitutionRef), - Params#claim_management_ContractParams{ + Params#claimmgmt_ContractParams{ template = ensure_contract_template(TemplateRef, ValidRef, Revision), payment_institution = ValidRef }. diff --git a/apps/party_management/src/pm_currency.erl b/apps/party_management/src/pm_currency.erl index 7b2b736..0aa5b7c 100644 --- a/apps/party_management/src/pm_currency.erl +++ b/apps/party_management/src/pm_currency.erl @@ -3,7 +3,9 @@ -module(pm_currency). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_base_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). -export([validate_currency/2]). @@ -17,7 +19,7 @@ validate_currency(Currency, Shop = #domain_Shop{}) -> validate_currency_(Currency, Currency) -> ok; validate_currency_(_, _) -> - throw(#'InvalidRequest'{errors = [<<"Invalid currency">>]}). + throw(#base_InvalidRequest{errors = [<<"Invalid currency">>]}). get_shop_currency(#domain_Shop{account = #domain_ShopAccount{currency = Currency}}) -> Currency. diff --git a/apps/party_management/src/pm_datetime.erl b/apps/party_management/src/pm_datetime.erl index 2571cf8..b72e934 100644 --- a/apps/party_management/src/pm_datetime.erl +++ b/apps/party_management/src/pm_datetime.erl @@ -44,10 +44,10 @@ compare(T1, T2) when is_binary(T1) andalso is_binary(T2) -> between(Timestamp, Start, End) -> LB = to_interval_bound(Start, inclusive), UB = to_interval_bound(End, inclusive), - between(Timestamp, #'TimestampInterval'{lower_bound = LB, upper_bound = UB}). + between(Timestamp, #base_TimestampInterval{lower_bound = LB, upper_bound = UB}). -spec between(timestamp(), timestamp_interval()) -> boolean(). -between(Timestamp, #'TimestampInterval'{lower_bound = LB, upper_bound = UB}) -> +between(Timestamp, #base_TimestampInterval{lower_bound = LB, upper_bound = UB}) -> check_bound(Timestamp, LB, later) andalso check_bound(Timestamp, UB, earlier). @@ -80,7 +80,7 @@ to_integer(Timestamp) -> to_interval_bound(undefined, _) -> undefined; to_interval_bound(Timestamp, BoundType) -> - #'TimestampIntervalBound'{bound_type = BoundType, bound_time = Timestamp}. + #base_TimestampIntervalBound{bound_type = BoundType, bound_time = Timestamp}. compare_int(T1, T2) -> case T1 > T2 of @@ -95,7 +95,7 @@ compare_int(T1, T2) -> -spec check_bound(timestamp(), timestamp_interval_bound(), later | earlier) -> boolean(). check_bound(_, undefined, _) -> true; -check_bound(Timestamp, #'TimestampIntervalBound'{bound_type = Type, bound_time = BoundTime}, Operator) -> +check_bound(Timestamp, #base_TimestampIntervalBound{bound_type = Type, bound_time = BoundTime}, Operator) -> case compare(Timestamp, BoundTime) of Operator -> true; diff --git a/apps/party_management/src/pm_domain.erl b/apps/party_management/src/pm_domain.erl index 8b58ef3..993b285 100644 --- a/apps/party_management/src/pm_domain.erl +++ b/apps/party_management/src/pm_domain.erl @@ -7,7 +7,7 @@ -module(pm_domain). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). --include_lib("damsel/include/dmsl_domain_config_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_conf_thrift.hrl"). %% @@ -41,7 +41,7 @@ get(Revision, Ref) -> try extract_data(dmt_client:checkout_object(Revision, Ref)) catch - throw:#'ObjectNotFound'{} -> + throw:#domain_conf_ObjectNotFound{} -> error({object_not_found, {Revision, Ref}}) end. @@ -50,7 +50,7 @@ find(Revision, Ref) -> try extract_data(dmt_client:checkout_object(Revision, Ref)) catch - throw:#'ObjectNotFound'{} -> + throw:#domain_conf_ObjectNotFound{} -> notfound end. @@ -60,7 +60,7 @@ exists(Revision, Ref) -> _ = dmt_client:checkout_object(Revision, Ref), true catch - throw:#'ObjectNotFound'{} -> + throw:#domain_conf_ObjectNotFound{} -> false end. @@ -75,9 +75,9 @@ commit(Revision, Commit) -> insert(Object) when not is_list(Object) -> insert([Object]); insert(Objects) -> - Commit = #'Commit'{ + Commit = #'domain_conf_Commit'{ ops = [ - {insert, #'InsertOp'{ + {insert, #'domain_conf_InsertOp'{ object = Object }} || Object <- Objects @@ -90,9 +90,9 @@ update(NewObject) when not is_list(NewObject) -> update([NewObject]); update(NewObjects) -> Revision = head(), - Commit = #'Commit'{ + Commit = #'domain_conf_Commit'{ ops = [ - {update, #'UpdateOp'{ + {update, #'domain_conf_UpdateOp'{ old_object = {Tag, {ObjectName, Ref, OldData}}, new_object = NewObject }} @@ -104,9 +104,9 @@ update(NewObjects) -> -spec remove([object()]) -> revision() | no_return(). remove(Objects) -> - Commit = #'Commit'{ + Commit = #'domain_conf_Commit'{ ops = [ - {remove, #'RemoveOp'{ + {remove, #'domain_conf_RemoveOp'{ object = Object }} || Object <- Objects @@ -116,5 +116,5 @@ remove(Objects) -> -spec cleanup() -> revision() | no_return(). cleanup() -> - #'Snapshot'{domain = Domain} = dmt_client:checkout(latest), + #'domain_conf_Snapshot'{domain = Domain} = dmt_client:checkout(latest), remove(maps:values(Domain)). diff --git a/apps/party_management/src/pm_machine.erl b/apps/party_management/src/pm_machine.erl index 4eca412..c5cb419 100644 --- a/apps/party_management/src/pm_machine.erl +++ b/apps/party_management/src/pm_machine.erl @@ -5,8 +5,7 @@ -type msgp() :: pm_msgpack_marshalling:msgpack_value(). -type id() :: mg_proto_base_thrift:'ID'(). --type tag() :: {tag, mg_proto_base_thrift:'Tag'()}. --type ref() :: id() | tag(). +-type ref() :: id(). -type ns() :: mg_proto_base_thrift:'Namespace'(). -type args() :: _. @@ -60,7 +59,6 @@ -export_type([id/0]). -export_type([ref/0]). --export_type([tag/0]). -export_type([ns/0]). -export_type([args/0]). -export_type([event_id/0]). diff --git a/apps/party_management/src/pm_party.erl b/apps/party_management/src/pm_party.erl index 1230adb..739bf17 100644 --- a/apps/party_management/src/pm_party.erl +++ b/apps/party_management/src/pm_party.erl @@ -11,8 +11,9 @@ -include("party_events.hrl"). --include_lib("damsel/include/dmsl_claim_management_thrift.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_claimmgmt_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). -include_lib("damsel/include/dmsl_accounter_thrift.hrl"). %% Party support functions @@ -68,7 +69,7 @@ -type contract_template() :: dmsl_domain_thrift:'ContractTemplate'(). -type shop() :: dmsl_domain_thrift:'Shop'(). -type shop_id() :: dmsl_domain_thrift:'ShopID'(). --type shop_params() :: dmsl_payment_processing_thrift:'ShopParams'() | dmsl_claim_management_thrift:'ShopParams'(). +-type shop_params() :: dmsl_payproc_thrift:'ShopParams'() | dmsl_claimmgmt_thrift:'ShopParams'(). -type wallet() :: dmsl_domain_thrift:'Wallet'(). -type wallet_id() :: dmsl_domain_thrift:'WalletID'(). @@ -157,17 +158,17 @@ create_shop(ID, #payproc_ShopParams{} = ShopParams, Timestamp) -> contract_id = ShopParams#payproc_ShopParams.contract_id, payout_tool_id = ShopParams#payproc_ShopParams.payout_tool_id }; -create_shop(ID, #claim_management_ShopParams{} = ShopParams, Timestamp) -> +create_shop(ID, #claimmgmt_ShopParams{} = ShopParams, Timestamp) -> #domain_Shop{ id = ID, created_at = Timestamp, blocking = ?unblocked(Timestamp), suspension = ?active(Timestamp), - category = ShopParams#claim_management_ShopParams.category, - details = ShopParams#claim_management_ShopParams.details, - location = ShopParams#claim_management_ShopParams.location, - contract_id = ShopParams#claim_management_ShopParams.contract_id, - payout_tool_id = ShopParams#claim_management_ShopParams.payout_tool_id + category = ShopParams#claimmgmt_ShopParams.category, + details = ShopParams#claimmgmt_ShopParams.details, + location = ShopParams#claimmgmt_ShopParams.location, + contract_id = ShopParams#claimmgmt_ShopParams.contract_id, + payout_tool_id = ShopParams#claimmgmt_ShopParams.payout_tool_id }. -spec get_shop(shop_id(), party()) -> shop() | undefined. @@ -203,7 +204,7 @@ get_shop_account(#domain_Shop{account = Account}) -> Account. -spec get_account_state(dmsl_accounter_thrift:'AccountID'(), party()) -> - dmsl_payment_processing_thrift:'AccountState'(). + dmsl_payproc_thrift:'AccountState'(). get_account_state(AccountID, Party) -> ok = ensure_account(AccountID, Party), Account = pm_accounting:get_account(AccountID), diff --git a/apps/party_management/src/pm_party_contractor.erl b/apps/party_management/src/pm_party_contractor.erl index aa1afe9..8149df1 100644 --- a/apps/party_management/src/pm_party_contractor.erl +++ b/apps/party_management/src/pm_party_contractor.erl @@ -1,6 +1,7 @@ -module(pm_party_contractor). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). %% diff --git a/apps/party_management/src/pm_party_handler.erl b/apps/party_management/src/pm_party_handler.erl index 2ab767e..998d0d5 100644 --- a/apps/party_management/src/pm_party_handler.erl +++ b/apps/party_management/src/pm_party_handler.erl @@ -1,6 +1,7 @@ -module(pm_party_handler). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). %% Woody handler called by pm_woody_wrapper diff --git a/apps/party_management/src/pm_party_machine.erl b/apps/party_management/src/pm_party_machine.erl index 26d6183..f5aa27c 100644 --- a/apps/party_management/src/pm_party_machine.erl +++ b/apps/party_management/src/pm_party_machine.erl @@ -3,8 +3,10 @@ -include("party_events.hrl"). -include("legacy_party_structures.hrl"). --include_lib("pm_proto/include/dmsl_party_state_thrift.hrl"). --include_lib("damsel/include/dmsl_claim_management_thrift.hrl"). +-include_lib("damsel/include/dmsl_claimmgmt_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("pm_proto/include/pm_state_thrift.hrl"). -include("claim_management.hrl"). @@ -39,7 +41,7 @@ -define(SNAPSHOT_STEP, 10). -define(CT_ERLANG_BINARY, <<"application/x-erlang-binary">>). --type st() :: #pm_State{}. +-type st() :: #state_State{}. -type call() :: pm_machine:thrift_call(). -type service_name() :: atom(). @@ -49,12 +51,12 @@ -type party_id() :: dmsl_domain_thrift:'PartyID'(). -type party_status() :: pm_party:party_status(). -type shop_id() :: dmsl_domain_thrift:'ShopID'(). --type claim_id() :: dmsl_payment_processing_thrift:'ClaimID'(). --type claim() :: dmsl_payment_processing_thrift:'Claim'(). +-type claim_id() :: dmsl_payproc_thrift:'ClaimID'(). +-type claim() :: dmsl_payproc_thrift:'Claim'(). -type meta() :: dmsl_domain_thrift:'PartyMeta'(). -type meta_ns() :: dmsl_domain_thrift:'PartyMetaNamespace'(). -type meta_data() :: dmsl_domain_thrift:'PartyMetaData'(). --type party_revision_param() :: dmsl_payment_processing_thrift:'PartyRevisionParam'(). +-type party_revision_param() :: dmsl_payproc_thrift:'PartyRevisionParam'(). -type party_revision() :: dmsl_domain_thrift:'PartyRevision'(). -type event_id() :: non_neg_integer(). @@ -84,7 +86,7 @@ namespace() -> -spec init(binary(), pm_machine:machine()) -> pm_machine:result(). init(EncodedPartyParams, #{id := ID}) -> - ParamsType = {struct, struct, {dmsl_payment_processing_thrift, 'PartyParams'}}, + ParamsType = {struct, struct, {dmsl_payproc_thrift, 'PartyParams'}}, PartyParams = pm_proto_utils:deserialize(ParamsType, EncodedPartyParams), scoper:scope( party, @@ -238,7 +240,7 @@ handle_call('RevokeClaim', {_PartyID, ID, ClaimRevision, Reason}, AuxSt, St) -> ); %% ClaimCommitter -handle_call('Accept', {_PartyID, #claim_management_Claim{changeset = Changeset}}, AuxSt, St) -> +handle_call('Accept', {_PartyID, #claimmgmt_Claim{changeset = Changeset}}, AuxSt, St) -> Party = get_st_party(St), Timestamp = pm_datetime:format_now(), Revision = pm_domain:head(), @@ -248,7 +250,7 @@ handle_call('Accept', {_PartyID, #claim_management_Claim{changeset = Changeset}} ok = pm_claim_committer:assert_modifications_acceptable(Modifications, Timestamp, Revision, Party), respond(ok, [], AuxSt, St); handle_call('Commit', {_PartyID, Claim}, AuxSt, St) -> - #claim_management_Claim{ + #claimmgmt_Claim{ id = ID, changeset = Changeset, revision = Revision, @@ -343,7 +345,7 @@ publish_party_event(Source, {ID, Dt, {Changes, _}}) -> %% -spec start(party_id(), Args :: term()) -> ok | no_return(). start(PartyID, PartyParams) -> - ParamsType = {struct, struct, {dmsl_payment_processing_thrift, 'PartyParams'}}, + ParamsType = {struct, struct, {dmsl_payproc_thrift, 'PartyParams'}}, EncodedPartyParams = pm_proto_utils:serialize(ParamsType, PartyParams), case pm_machine:start(?NS, PartyID, EncodedPartyParams) of {ok, _} -> @@ -363,7 +365,7 @@ get_state(PartyID) -> get_state(PartyID, []) -> %% No snapshots, so we need entire history Events = unwrap_events(get_history(PartyID, undefined, undefined, forward)), - merge_events(Events, #pm_State{}); + merge_events(Events, #state_State{}); get_state(PartyID, [FirstID | _]) -> History = get_history(PartyID, FirstID - 1, undefined, forward), Events = [FirstEvent | _] = unwrap_events(History), @@ -385,7 +387,7 @@ get_state_for_call(_, {St0, Events}, EventsAcc, AuxSt0) -> {St1, PartyRevisionIndex1} = build_revision_index( Events ++ EventsAcc, PartyRevisionIndex0, - pm_utils:select_defined(St0, #pm_State{}) + pm_utils:select_defined(St0, #state_State{}) ), AuxSt1 = set_party_revision_index(PartyRevisionIndex1, AuxSt0), {St1, AuxSt1}. @@ -398,7 +400,7 @@ parse_history([WrappedEvent | Others], EventsAcc) -> case unwrap_state(Event) of undefined -> parse_history(Others, [Event | EventsAcc]); - #pm_State{} = St -> + #state_State{} = St -> {St, [Event | EventsAcc]} end; parse_history([], EventsAcc) -> @@ -478,12 +480,12 @@ get_claim(ID, PartyID) -> -spec get_claims(party_id()) -> [claim()] | no_return(). get_claims(PartyID) -> - #pm_State{claims = Claims} = get_state(PartyID), + #state_State{claims = Claims} = get_state(PartyID), maps:values(Claims). -spec get_meta(party_id()) -> meta() | no_return(). get_meta(PartyID) -> - #pm_State{meta = Meta} = get_state(PartyID), + #state_State{meta = Meta} = get_state(PartyID), Meta. -spec get_metadata(meta_ns(), party_id()) -> meta_data() | no_return(). @@ -491,7 +493,7 @@ get_metadata(NS, PartyID) -> get_st_metadata(NS, get_state(PartyID)). -spec get_public_history(party_id(), integer() | undefined, non_neg_integer()) -> - [dmsl_payment_processing_thrift:'Event'()]. + [dmsl_payproc_thrift:'Event'()]. get_public_history(PartyID, AfterID, Limit) -> Events = unwrap_events(get_history(PartyID, AfterID, Limit)), [publish_party_event({party_id, PartyID}, Ev) || Ev <- Events]. @@ -568,16 +570,16 @@ map_history_error({error, notfound}) -> %% -get_st_party(#pm_State{party = Party}) -> +get_st_party(#state_State{party = Party}) -> Party. -get_next_party_revision(#pm_State{party = Party}) -> +get_next_party_revision(#state_State{party = Party}) -> Party#domain_Party.revision + 1. -get_st_claim(ID, #pm_State{claims = Claims}) -> +get_st_claim(ID, #state_State{claims = Claims}) -> assert_claim_exists(maps:get(ID, Claims, undefined)). -get_st_pending_claims(#pm_State{claims = Claims}) -> +get_st_pending_claims(#state_State{claims = Claims}) -> % TODO cache it during history collapse % Looks like little overhead, compared to previous version (based on maps:fold), % but I hope for small amount of pending claims simultaniously. @@ -591,7 +593,7 @@ get_st_pending_claims(#pm_State{claims = Claims}) -> ). -spec get_st_metadata(meta_ns(), st()) -> meta_data(). -get_st_metadata(NS, #pm_State{meta = Meta}) -> +get_st_metadata(NS, #state_State{meta = Meta}) -> case maps:get(NS, Meta, undefined) of MetaData when MetaData =/= undefined -> MetaData; @@ -601,9 +603,9 @@ get_st_metadata(NS, #pm_State{meta = Meta}) -> set_claim( #payproc_Claim{id = ID} = Claim, - #pm_State{claims = Claims} = St + #state_State{claims = Claims} = St ) -> - St#pm_State{claims = Claims#{ID => Claim}}. + St#state_State{claims = Claims#{ID => Claim}}. assert_claim_exists(Claim = #payproc_Claim{}) -> Claim; @@ -687,7 +689,7 @@ finalize_claim(Claim, Timestamp) -> Timestamp ). -get_next_claim_id(#pm_State{claims = Claims}) -> +get_next_claim_id(#state_State{claims = Claims}) -> % TODO cache sequences on history collapse lists:max([0 | maps:keys(Claims)]) + 1. @@ -695,7 +697,7 @@ apply_accepted_claim(Claim, St) -> case pm_claim:is_accepted(Claim) of true -> Party = pm_claim:apply(Claim, pm_datetime:format_now(), get_st_party(St)), - St#pm_State{party = Party}; + St#state_State{party = Party}; false -> St end. @@ -721,15 +723,15 @@ respond_w_exception(Exception) -> append_party_revision_index(Changes, St0, AuxSt) -> PartyRevisionIndex0 = get_party_revision_index(AuxSt), - LastEventID = St0#pm_State.last_event, + LastEventID = St0#state_State.last_event, % Brave prediction of next EventID )) - St1 = merge_party_changes(Changes, St0#pm_State{last_event = LastEventID + 1}), + St1 = merge_party_changes(Changes, St0#state_State{last_event = LastEventID + 1}), PartyRevisionIndex1 = update_party_revision_index(St1, PartyRevisionIndex0), set_party_revision_index(PartyRevisionIndex1, AuxSt). update_party_revision_index(St, PartyRevisionIndex) -> #domain_Party{revision = PartyRevision} = get_st_party(St), - EventID = St#pm_State.last_event, + EventID = St#state_State.last_event, {FromEventID, ToEventID} = get_party_revision_range(PartyRevision, PartyRevisionIndex), PartyRevisionIndex#{ PartyRevision => { @@ -780,23 +782,23 @@ get_limit(_ToEventID, []) -> -spec checkout_party(party_id(), party_revision_param()) -> {ok, st()} | {error, revision_not_found}. checkout_party(PartyID, {timestamp, Timestamp}) -> Events = unwrap_events(get_history(PartyID, undefined, undefined)), - checkout_history_by_timestamp(Events, Timestamp, #pm_State{}); + checkout_history_by_timestamp(Events, Timestamp, #state_State{}); checkout_party(PartyID, {revision, Revision}) -> checkout_cached_party_by_revision(PartyID, Revision). -checkout_history_by_timestamp([Ev | Rest], Timestamp, #pm_State{timestamp = PrevTimestamp} = St) -> +checkout_history_by_timestamp([Ev | Rest], Timestamp, #state_State{timestamp = PrevTimestamp} = St) -> St1 = merge_event(Ev, St), - EventTimestamp = St1#pm_State.timestamp, + EventTimestamp = St1#state_State.timestamp, case pm_datetime:compare(EventTimestamp, Timestamp) of later when PrevTimestamp =/= undefined -> - {ok, St#pm_State{timestamp = Timestamp}}; + {ok, St#state_State{timestamp = Timestamp}}; later when PrevTimestamp == undefined -> {error, revision_not_found}; _ -> checkout_history_by_timestamp(Rest, Timestamp, St1) end; checkout_history_by_timestamp([], Timestamp, St) -> - {ok, St#pm_State{timestamp = Timestamp}}. + {ok, St#state_State{timestamp = Timestamp}}. checkout_cached_party_by_revision(PartyID, Revision) -> case pm_party_cache:get_party(PartyID, Revision) of @@ -827,7 +829,7 @@ checkout_party_by_revision(PartyID, Revision) -> ReversedHistory = get_history(PartyID, FromEventID, Limit, backward), case parse_history(ReversedHistory) of {undefined, Events} -> - checkout_history_by_revision(Events, Revision, #pm_State{}); + checkout_history_by_revision(Events, Revision, #state_State{}); {St, Events} -> checkout_history_by_revision(Events, Revision, St) end. @@ -851,49 +853,49 @@ checkout_history_by_revision([], Revision, St) -> merge_events(Events, St) -> lists:foldl(fun merge_event/2, St, Events). -merge_event({ID, _Dt, {PartyChanges, _}}, #pm_State{last_event = LastEventID} = St) when +merge_event({ID, _Dt, {PartyChanges, _}}, #state_State{last_event = LastEventID} = St) when is_list(PartyChanges) andalso ID =:= LastEventID + 1 -> - merge_party_changes(PartyChanges, St#pm_State{last_event = ID}). + merge_party_changes(PartyChanges, St#state_State{last_event = ID}). merge_party_changes(Changes, St) -> lists:foldl(fun merge_party_change/2, St, Changes). merge_party_change(?party_created(PartyID, ContactInfo, Timestamp), St) -> - St#pm_State{ + St#state_State{ timestamp = Timestamp, party = pm_party:create_party(PartyID, ContactInfo, Timestamp) }; merge_party_change(?party_blocking(Blocking), St) -> Party = get_st_party(St), - St#pm_State{party = pm_party:blocking(Blocking, Party)}; + St#state_State{party = pm_party:blocking(Blocking, Party)}; merge_party_change(?revision_changed(Timestamp, Revision), St) -> Party = get_st_party(St), - St#pm_State{ + St#state_State{ timestamp = Timestamp, party = Party#domain_Party{revision = Revision} }; merge_party_change(?party_suspension(Suspension), St) -> Party = get_st_party(St), - St#pm_State{party = pm_party:suspension(Suspension, Party)}; -merge_party_change(?party_meta_set(NS, Data), #pm_State{meta = Meta} = St) -> + St#state_State{party = pm_party:suspension(Suspension, Party)}; +merge_party_change(?party_meta_set(NS, Data), #state_State{meta = Meta} = St) -> NewMeta = Meta#{NS => Data}, - St#pm_State{meta = NewMeta}; -merge_party_change(?party_meta_removed(NS), #pm_State{meta = Meta} = St) -> + St#state_State{meta = NewMeta}; +merge_party_change(?party_meta_removed(NS), #state_State{meta = Meta} = St) -> NewMeta = maps:remove(NS, Meta), - St#pm_State{meta = NewMeta}; + St#state_State{meta = NewMeta}; merge_party_change(?shop_blocking(ID, Blocking), St) -> Party = get_st_party(St), - St#pm_State{party = pm_party:shop_blocking(ID, Blocking, Party)}; + St#state_State{party = pm_party:shop_blocking(ID, Blocking, Party)}; merge_party_change(?shop_suspension(ID, Suspension), St) -> Party = get_st_party(St), - St#pm_State{party = pm_party:shop_suspension(ID, Suspension, Party)}; + St#state_State{party = pm_party:shop_suspension(ID, Suspension, Party)}; merge_party_change(?wallet_blocking(ID, Blocking), St) -> Party = get_st_party(St), - St#pm_State{party = pm_party:wallet_blocking(ID, Blocking, Party)}; + St#state_State{party = pm_party:wallet_blocking(ID, Blocking, Party)}; merge_party_change(?wallet_suspension(ID, Suspension), St) -> Party = get_st_party(St), - St#pm_State{party = pm_party:wallet_suspension(ID, Suspension, Party)}; + St#state_State{party = pm_party:wallet_suspension(ID, Suspension, Party)}; merge_party_change(?claim_created(Claim0), St) -> Claim = ensure_claim(Claim0), St1 = set_claim(Claim, St), @@ -1104,7 +1106,7 @@ get_template(TemplateRef, Revision) -> %% -try_attach_snapshot(Changes, AuxSt0, #pm_State{last_event = LastEventID} = St) when +try_attach_snapshot(Changes, AuxSt0, #state_State{last_event = LastEventID} = St) when LastEventID > 0 andalso LastEventID rem ?SNAPSHOT_STEP =:= 0 -> @@ -1142,7 +1144,7 @@ wrap_event_payload_w_snapshot(Changes, St) -> marshal_event_payload(FormatVsn, Changes, StateSnapshot). marshal_event_payload(FormatVsn, Changes, StateSnapshot) -> - Type = {struct, struct, {dmsl_payment_processing_thrift, 'PartyEventData'}}, + Type = {struct, struct, {dmsl_payproc_thrift, 'PartyEventData'}}, Bin = pm_proto_utils:serialize(Type, #payproc_PartyEventData{changes = Changes, state_snapshot = StateSnapshot}), #{ format_version => FormatVsn, @@ -1162,7 +1164,7 @@ unwrap_event_payload( FormatVsn, {bin, ThriftEncodedBin} ) when is_integer(FormatVsn) -> - Type = {struct, struct, {dmsl_payment_processing_thrift, 'PartyEventData'}}, + Type = {struct, struct, {dmsl_payproc_thrift, 'PartyEventData'}}, ?party_event_data(Changes, Snapshot) = pm_proto_utils:deserialize(Type, ThriftEncodedBin), {Changes, pm_maybe:apply(fun(S) -> {FormatVsn, S} end, Snapshot)}; %% TODO legacy support, will be removed after migration @@ -1186,7 +1188,7 @@ unwrap_state({_ID, _Dt, {_Changes, {FormatVsn, EncodedSt}}}) -> unwrap_state({_ID, _Dt, {_Changes, undefined}}) -> undefined. --define(STATE_THRIFT_TYPE, {struct, struct, {dmsl_party_state_thrift, 'State'}}). +-define(STATE_THRIFT_TYPE, {struct, struct, {pm_state_thrift, 'State'}}). encode_state(St) -> {?FORMAT_VERSION_THRIFT, {bin, pm_proto_utils:serialize(?STATE_THRIFT_TYPE, St)}}. @@ -1240,7 +1242,7 @@ transmute_event(V, V, Event) -> transmute_state(St) -> transmute_state(?PARTY_STATE_ERLBIN_VERSION, ?TOP_VERSION, St). --spec transmute_change(pos_integer(), pos_integer(), term()) -> dmsl_payment_processing_thrift:'PartyChange'(). +-spec transmute_change(pos_integer(), pos_integer(), term()) -> dmsl_payproc_thrift:'PartyChange'(). transmute_change( 1, 2, @@ -1296,7 +1298,7 @@ transmute_change(V1, _, C) when V1 >= 1, V1 < ?TOP_VERSION -> -spec transmute_state(pos_integer(), pos_integer(), _LegacyState) -> st(). transmute_state(V1, V2, ?legacy_st(Party, Timestamp, Claims, Meta, _, LastEventID)) -> - #pm_State{ + #state_State{ party = transmute_party(V1, V2, Party), timestamp = Timestamp, claims = maps:map(fun(_, C) -> transmute_claim(V1, V2, C) end, Claims), @@ -1951,7 +1953,7 @@ transmute_payout_schedule_ref(3, 4, undefined) -> -spec encode_decode_success_test_() -> _. encode_decode_success_test_() -> ?_assertEqual( - #pm_State{}, + #state_State{}, begin decode_state_format(?FORMAT_VERSION_ERLBIN, {bin, term_to_binary(?INITIAL_LEGACY_ST)}) end diff --git a/apps/party_management/src/pm_payment_institution.erl b/apps/party_management/src/pm_payment_institution.erl index d276b5c..172350d 100644 --- a/apps/party_management/src/pm_payment_institution.erl +++ b/apps/party_management/src/pm_payment_institution.erl @@ -42,11 +42,6 @@ reduce_payment_institution(PaymentInstitution, VS, Revision) -> VS, Revision ), - withdrawal_providers = reduce_if_defined( - PaymentInstitution#domain_PaymentInstitution.withdrawal_providers, - VS, - Revision - ), providers = reduce_if_defined( PaymentInstitution#domain_PaymentInstitution.providers, VS, diff --git a/apps/party_management/src/pm_payout_tool.erl b/apps/party_management/src/pm_payout_tool.erl index f0b1344..8d6b0f3 100644 --- a/apps/party_management/src/pm_payout_tool.erl +++ b/apps/party_management/src/pm_payout_tool.erl @@ -2,8 +2,9 @@ -module(pm_payout_tool). --include_lib("damsel/include/dmsl_claim_management_thrift.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_claimmgmt_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). %% @@ -14,7 +15,7 @@ -type payout_tool() :: dmsl_domain_thrift:'PayoutTool'(). -type payout_tool_id() :: dmsl_domain_thrift:'PayoutToolID'(). -type payout_tool_params() :: - dmsl_payment_processing_thrift:'PayoutToolParams'() | dmsl_claim_management_thrift:'PayoutToolParams'(). + dmsl_payproc_thrift:'PayoutToolParams'() | dmsl_claimmgmt_thrift:'PayoutToolParams'(). -type method() :: dmsl_domain_thrift:'PayoutMethodRef'(). -type timestamp() :: dmsl_base_thrift:'Timestamp'(). @@ -37,7 +38,7 @@ create( }; create( ID, - #claim_management_PayoutToolParams{ + #claimmgmt_PayoutToolParams{ currency = Currency, tool_info = ToolInfo }, diff --git a/apps/party_management/src/pm_provider.erl b/apps/party_management/src/pm_provider.erl index aa20552..e0869e0 100644 --- a/apps/party_management/src/pm_provider.erl +++ b/apps/party_management/src/pm_provider.erl @@ -1,7 +1,8 @@ -module(pm_provider). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). %% API -export([reduce_provider/3]). @@ -18,7 +19,6 @@ -spec reduce_provider(provider(), varset(), domain_revision()) -> provider(). reduce_provider(Provider, VS, Rev) -> Provider#domain_Provider{ - terminal = reduce_if_defined(Provider#domain_Provider.terminal, VS, Rev), terms = reduce_provision_term_set(Provider#domain_Provider.terms, VS, Rev) }. diff --git a/apps/party_management/src/pm_ruleset.erl b/apps/party_management/src/pm_ruleset.erl index 85240f9..71706b3 100644 --- a/apps/party_management/src/pm_ruleset.erl +++ b/apps/party_management/src/pm_ruleset.erl @@ -1,7 +1,7 @@ -module(pm_ruleset). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). %% API -export([reduce_payment_routing_ruleset/3]). diff --git a/apps/party_management/src/pm_selector.erl b/apps/party_management/src/pm_selector.erl index fba832f..baec5a3 100644 --- a/apps/party_management/src/pm_selector.erl +++ b/apps/party_management/src/pm_selector.erl @@ -20,12 +20,11 @@ | dmsl_domain_thrift:'CashFlowSelector'() | dmsl_domain_thrift:'PaymentMethodSelector'() | dmsl_domain_thrift:'ProviderSelector'() - | dmsl_domain_thrift:'TerminalSelector'() | dmsl_domain_thrift:'SystemAccountSetSelector'() | dmsl_domain_thrift:'ExternalAccountSetSelector'() | dmsl_domain_thrift:'HoldLifetimeSelector'() | dmsl_domain_thrift:'CashValueSelector'() - | dmsl_domain_thrift:'CumulativeLimitSelector'() + | dmsl_domain_thrift:'TurnoverLimitSelector'() | dmsl_domain_thrift:'TimeSpanSelector'() | dmsl_domain_thrift:'FeeSelector'() | dmsl_domain_thrift:'InspectorSelector'(). @@ -159,7 +158,7 @@ reduce_condition(C, VS, Rev) -> -ifdef(TEST). -include_lib("eunit/include/eunit.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -spec test() -> _. diff --git a/apps/party_management/src/pm_varset.erl b/apps/party_management/src/pm_varset.erl index 63bf582..be86ef3 100644 --- a/apps/party_management/src/pm_varset.erl +++ b/apps/party_management/src/pm_varset.erl @@ -1,6 +1,7 @@ -module(pm_varset). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). -export([encode_varset/1]). -export([decode_varset/2]). @@ -22,9 +23,9 @@ bin_data => dmsl_domain_thrift:'BinData'() }. --type encoded_varset() :: dmsl_payment_processing_thrift:'Varset'(). --type contract_terms_varset() :: dmsl_payment_processing_thrift:'ComputeContractTermsVarset'(). --type shop_terms_varset() :: dmsl_payment_processing_thrift:'ComputeShopTermsVarset'(). +-type encoded_varset() :: dmsl_payproc_thrift:'Varset'(). +-type contract_terms_varset() :: dmsl_payproc_thrift:'ComputeContractTermsVarset'(). +-type shop_terms_varset() :: dmsl_payproc_thrift:'ComputeShopTermsVarset'(). -spec encode_varset(varset()) -> encoded_varset(). encode_varset(Varset) -> @@ -107,7 +108,7 @@ encode_decode_test() -> payment_system = #domain_PaymentSystemRef{id = <<"visa">>} }} }, - payout_method => #domain_PayoutMethodRef{id = any}, + payout_method => #domain_PayoutMethodRef{id = russian_bank_account}, wallet_id => <<"wallet_id">>, shop_id => <<"shop_id">>, identification_level => full, diff --git a/apps/party_management/src/pm_wallet.erl b/apps/party_management/src/pm_wallet.erl index 1f9dba5..4f4cbed 100644 --- a/apps/party_management/src/pm_wallet.erl +++ b/apps/party_management/src/pm_wallet.erl @@ -3,7 +3,8 @@ -include("claim_management.hrl"). -include("party_events.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). %% @@ -16,10 +17,10 @@ -type wallet() :: dmsl_domain_thrift:'Wallet'(). -type wallet_id() :: dmsl_domain_thrift:'WalletID'(). -type wallet_params() :: - dmsl_payment_processing_thrift:'WalletParams'() | dmsl_claim_management_thrift:'WalletParams'(). + dmsl_payproc_thrift:'WalletParams'() | dmsl_claimmgmt_thrift:'WalletParams'(). -type wallet_account() :: dmsl_domain_thrift:'WalletAccount'(). -type wallet_account_params() :: - dmsl_payment_processing_thrift:'WalletAccountParams'() | dmsl_claim_management_thrift:'WalletAccountParams'(). + dmsl_payproc_thrift:'WalletAccountParams'() | dmsl_claimmgmt_thrift:'WalletAccountParams'(). -spec create(wallet_id(), wallet_params(), pm_datetime:timestamp()) -> wallet(). create( @@ -40,7 +41,7 @@ create( }; create( ID, - #claim_management_WalletParams{ + #claimmgmt_WalletParams{ name = Name, contract_id = ContractID }, @@ -65,7 +66,7 @@ create_account(#payproc_WalletAccountParams{currency = Currency}) -> settlement = SettlementID, payout = PayoutID }; -create_account(#claim_management_WalletAccountParams{currency = Currency}) -> +create_account(#claimmgmt_WalletAccountParams{currency = Currency}) -> SymbolicCode = Currency#domain_CurrencyRef.symbolic_code, SettlementID = pm_accounting:create_account(SymbolicCode), PayoutID = pm_accounting:create_account(SymbolicCode), diff --git a/apps/party_management/test/pm_claim_committer_SUITE.erl b/apps/party_management/test/pm_claim_committer_SUITE.erl index 6bf91b7..39874f2 100644 --- a/apps/party_management/test/pm_claim_committer_SUITE.erl +++ b/apps/party_management/test/pm_claim_committer_SUITE.erl @@ -3,7 +3,9 @@ -include("claim_management.hrl"). -include("pm_ct_domain.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). +-include_lib("damsel/include/dmsl_base_thrift.hrl"). -export([all/0]). -export([init_per_suite/1]). @@ -214,7 +216,7 @@ contract_adjustment_creation(C) -> PartyID = cfg(party_id, C), ContractID = ?REAL_CONTRACT_ID1, ID = <<"ADJ1">>, - AdjustmentParams = #claim_management_ContractAdjustmentParams{template = #domain_ContractTemplateRef{id = 2}}, + AdjustmentParams = #claimmgmt_ContractAdjustmentParams{template = #domain_ContractTemplateRef{id = 2}}, Modifications = [?cm_contract_modification(ContractID, ?cm_adjustment_creation(ID, AdjustmentParams))], Claim = claim(Modifications, PartyID), ok = accept_claim(Claim, C), @@ -281,7 +283,7 @@ shop_creation(C) -> ContractID = ?REAL_CONTRACT_ID1, ShopID = ?REAL_SHOP_ID, PayoutToolID1 = ?REAL_PAYOUT_TOOL_ID1, - ShopParams = #claim_management_ShopParams{ + ShopParams = #claimmgmt_ShopParams{ category = Category, location = Location, details = Details, @@ -289,7 +291,7 @@ shop_creation(C) -> payout_tool_id = PayoutToolID1 }, Schedule = ?bussched(1), - ScheduleParams = #claim_management_ScheduleModification{schedule = Schedule}, + ScheduleParams = #claimmgmt_ScheduleModification{schedule = Schedule}, Modifications = [ ?cm_shop_creation(ShopID, ShopParams), ?cm_shop_account_creation(ShopID, ?cur(<<"RUB">>)), @@ -321,8 +323,8 @@ shop_complex_modification(C) -> NewLocation = {url, <<"http://localhost">>}, PayoutToolID2 = ?REAL_PAYOUT_TOOL_ID2, Schedule = ?bussched(2), - ScheduleParams = #claim_management_ScheduleModification{schedule = Schedule}, - CashRegisterModificationUnit = #claim_management_CashRegisterModificationUnit{ + ScheduleParams = #claimmgmt_ScheduleModification{schedule = Schedule}, + CashRegisterModificationUnit = #claimmgmt_CashRegisterModificationUnit{ id = <<"1">>, modification = ?cm_cash_register_unit_creation(1, #{}) }, @@ -348,7 +350,7 @@ shop_complex_modification(C) -> -spec invalid_cash_register_modification(config()) -> _. invalid_cash_register_modification(C) -> PartyID = cfg(party_id, C), - CashRegisterModificationUnit = #claim_management_CashRegisterModificationUnit{ + CashRegisterModificationUnit = #claimmgmt_CashRegisterModificationUnit{ id = <<"1">>, modification = ?cm_cash_register_unit_creation(1, #{}) }, @@ -374,7 +376,7 @@ invalid_shop_payout_tool_not_in_contract(C) -> Location = {url, <<"https://example.com">>}, ContractID = ?REAL_CONTRACT_ID1, ShopID = ?REAL_SHOP_ID4, - ShopParams = #claim_management_ShopParams{ + ShopParams = #claimmgmt_ShopParams{ category = Category, location = Location, details = Details, @@ -382,7 +384,7 @@ invalid_shop_payout_tool_not_in_contract(C) -> payout_tool_id = ?REAL_PAYOUT_TOOL_ID1 }, Schedule = ?bussched(1), - ScheduleParams = #claim_management_ScheduleModification{schedule = Schedule}, + ScheduleParams = #claimmgmt_ScheduleModification{schedule = Schedule}, Modifications = [ ?cm_shop_creation(ShopID, ShopParams), ?cm_shop_account_creation(ShopID, ?cur(<<"USD">>)), @@ -409,7 +411,7 @@ invalid_shop_payout_tool_currency_mismatch(C) -> Location = {url, <<"https://example.com">>}, ContractID = ?REAL_CONTRACT_ID1, ShopID = ?REAL_SHOP_ID4, - ShopParams = #claim_management_ShopParams{ + ShopParams = #claimmgmt_ShopParams{ category = Category, location = Location, details = Details, @@ -417,7 +419,7 @@ invalid_shop_payout_tool_currency_mismatch(C) -> payout_tool_id = ?REAL_PAYOUT_TOOL_ID4 }, Schedule = ?bussched(1), - ScheduleParams = #claim_management_ScheduleModification{schedule = Schedule}, + ScheduleParams = #claimmgmt_ScheduleModification{schedule = Schedule}, Modifications = [ ?cm_shop_creation(ShopID, ShopParams), ?cm_shop_account_creation(ShopID, ?cur(<<"RUB">>)), @@ -436,7 +438,7 @@ shop_contract_modification(C) -> ShopID = ?REAL_SHOP_ID, ContractID = ?REAL_CONTRACT_ID2, PayoutToolID = ?REAL_PAYOUT_TOOL_ID1, - ShopContractParams = #claim_management_ShopContractModification{ + ShopContractParams = #claimmgmt_ShopContractModification{ contract_id = ContractID, payout_tool_id = PayoutToolID }, @@ -453,7 +455,7 @@ shop_contract_modification(C) -> contract_termination(C) -> PartyID = cfg(party_id, C), ContractID = ?REAL_CONTRACT_ID1, - Reason = #claim_management_ContractTermination{reason = <<"Because!">>}, + Reason = #claimmgmt_ContractTermination{reason = <<"Because!">>}, Modifications = [?cm_contract_modification(ContractID, {termination, Reason})], Claim = claim(Modifications, PartyID), ok = accept_claim(Claim, C), @@ -489,7 +491,7 @@ contract_already_exists(C) -> contract_already_terminated(C) -> ContractID = ?REAL_CONTRACT_ID1, PartyID = cfg(party_id, C), - Reason = #claim_management_ContractTermination{reason = <<"Because!">>}, + Reason = #claimmgmt_ContractTermination{reason = <<"Because!">>}, Mod = ?cm_contract_modification(ContractID, {termination, Reason}), Claim = claim([Mod], PartyID), {exception, @@ -506,14 +508,14 @@ shop_already_exists(C) -> }, ShopID = ?REAL_SHOP_ID, PartyID = cfg(party_id, C), - ShopParams = #claim_management_ShopParams{ + ShopParams = #claimmgmt_ShopParams{ category = ?cat(2), location = {url, <<"https://example.com">>}, details = Details, contract_id = ?REAL_CONTRACT_ID1, payout_tool_id = ?REAL_PAYOUT_TOOL_ID1 }, - ScheduleParams = #claim_management_ScheduleModification{schedule = ?bussched(1)}, + ScheduleParams = #claimmgmt_ScheduleModification{schedule = ?bussched(1)}, Mod = ?cm_shop_modification(ShopID, {creation, ShopParams}), Modifications = [ @@ -550,16 +552,16 @@ wallet_account_creation(C) -> %%% Internal functions claim(PartyModifications, PartyID) -> - UserInfo = #claim_management_UserInfo{ + UserInfo = #claimmgmt_UserInfo{ id = <<"test">>, email = <<"test@localhost">>, username = <<"test">>, - type = {internal_user, #claim_management_InternalUser{}} + type = {internal_user, #claimmgmt_InternalUser{}} }, - #claim_management_Claim{ + #claimmgmt_Claim{ id = id(), party_id = PartyID, - status = {pending, #claim_management_ClaimPending{}}, + status = {pending, #claimmgmt_ClaimPending{}}, changeset = [?cm_party_modification(id(), ts(), Mod, UserInfo) || Mod <- PartyModifications], revision = 1, created_at = ts() @@ -616,14 +618,14 @@ make_contract_params(ContractorID, TemplateRef) -> make_contract_params(ContractorID, TemplateRef, ?pinst(2)). make_contract_params(ContractorID, TemplateRef, PaymentInstitutionRef) -> - #claim_management_ContractParams{ + #claimmgmt_ContractParams{ contractor_id = ContractorID, template = TemplateRef, payment_institution = PaymentInstitutionRef }. make_payout_tool_params() -> - #claim_management_PayoutToolParams{ + #claimmgmt_PayoutToolParams{ currency = ?cur(<<"RUB">>), tool_info = {russian_bank_account, #domain_RussianBankAccount{ @@ -834,7 +836,7 @@ construct_domain_fixture() -> parent_terms = undefined, term_sets = [ #domain_TimedTermSet{ - action_time = #'TimestampInterval'{}, + action_time = #base_TimestampInterval{}, terms = TestTermSet } ] @@ -846,7 +848,7 @@ construct_domain_fixture() -> parent_terms = undefined, term_sets = [ #domain_TimedTermSet{ - action_time = #'TimestampInterval'{}, + action_time = #base_TimestampInterval{}, terms = DefaultTermSet } ] @@ -858,7 +860,7 @@ construct_domain_fixture() -> parent_terms = ?trms(2), term_sets = [ #domain_TimedTermSet{ - action_time = #'TimestampInterval'{}, + action_time = #base_TimestampInterval{}, terms = TermSet } ] @@ -870,7 +872,7 @@ construct_domain_fixture() -> parent_terms = ?trms(3), term_sets = [ #domain_TimedTermSet{ - action_time = #'TimestampInterval'{}, + action_time = #base_TimestampInterval{}, terms = #domain_TermSet{ payments = #domain_PaymentsServiceTerms{ currencies = diff --git a/apps/party_management/test/pm_ct_domain.erl b/apps/party_management/test/pm_ct_domain.erl index b22fc08..79b781f 100644 --- a/apps/party_management/test/pm_ct_domain.erl +++ b/apps/party_management/test/pm_ct_domain.erl @@ -1,6 +1,6 @@ -module(pm_ct_domain). --include_lib("damsel/include/dmsl_domain_config_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_conf_thrift.hrl"). -export([upsert/2]). -export([reset/1]). @@ -17,7 +17,7 @@ upsert(Revision, NewObject) when not is_list(NewObject) -> upsert(Revision, [NewObject]); upsert(Revision, NewObjects) -> - Commit = #'Commit'{ + Commit = #'domain_conf_Commit'{ ops = lists:foldl( fun(NewObject = {Tag, {ObjectName, Ref, NewData}}, Ops) -> case pm_domain:find(Revision, {Tag, Ref}) of @@ -25,14 +25,14 @@ upsert(Revision, NewObjects) -> Ops; notfound -> [ - {insert, #'InsertOp'{ + {insert, #'domain_conf_InsertOp'{ object = NewObject }} | Ops ]; OldData -> [ - {update, #'UpdateOp'{ + {update, #'domain_conf_UpdateOp'{ old_object = {Tag, {ObjectName, Ref, OldData}}, new_object = NewObject }} @@ -49,7 +49,7 @@ upsert(Revision, NewObjects) -> -spec reset(revision()) -> revision() | no_return(). reset(ToRevision) -> - #'Snapshot'{domain = Domain} = dmt_client:checkout(ToRevision), + #'domain_conf_Snapshot'{domain = Domain} = dmt_client:checkout(ToRevision), upsert(pm_domain:head(), maps:values(Domain)). -spec commit(revision(), dmt_client:commit()) -> ok | no_return(). diff --git a/apps/party_management/test/pm_ct_domain.hrl b/apps/party_management/test/pm_ct_domain.hrl index 8e4cc3d..46ad844 100644 --- a/apps/party_management/test/pm_ct_domain.hrl +++ b/apps/party_management/test/pm_ct_domain.hrl @@ -57,14 +57,14 @@ -define(share(P, Q, C), {share, #domain_CashVolumeShare{ - parts = #'Rational'{p = P, q = Q}, + parts = #base_Rational{p = P, q = Q}, 'of' = C }} ). -define(share(P, Q, C, RM), {share, #domain_CashVolumeShare{ - parts = #'Rational'{p = P, q = Q}, + parts = #base_Rational{p = P, q = Q}, 'of' = C, rounding_method = RM }} diff --git a/apps/party_management/test/pm_ct_fixture.erl b/apps/party_management/test/pm_ct_fixture.erl index eae67b6..7940e98 100644 --- a/apps/party_management/test/pm_ct_fixture.erl +++ b/apps/party_management/test/pm_ct_fixture.erl @@ -66,7 +66,7 @@ %% --define(EVERY, {every, #'ScheduleEvery'{}}). +-define(EVERY, {every, #'base_ScheduleEvery'{}}). %% @@ -115,8 +115,6 @@ construct_payment_method(?pmt(bank_card, ?token_bank_card(Name, _)) = Ref) -> construct_payment_method(Name, Ref); construct_payment_method(?pmt(bank_card, ?bank_card(Name)) = Ref) -> construct_payment_method(Name, Ref); -construct_payment_method(?pmt(_Type, Name) = Ref) when is_atom(Name) -> - construct_payment_method(Name, Ref); construct_payment_method(?pmt(_Type, #domain_BankCardPaymentMethod{} = Card) = Ref) -> construct_payment_method(Card#domain_BankCardPaymentMethod.payment_system, Ref). @@ -323,7 +321,7 @@ construct_business_schedule(Ref) -> ref = Ref, data = #domain_BusinessSchedule{ name = <<"Every day at 7:40">>, - schedule = #'Schedule'{ + schedule = #'base_Schedule'{ year = ?EVERY, month = ?EVERY, day_of_month = ?EVERY, @@ -354,7 +352,7 @@ construct_term_set_hierarchy(Ref, ParentRef, TermSet) -> parent_terms = ParentRef, term_sets = [ #domain_TimedTermSet{ - action_time = #'TimestampInterval'{}, + action_time = #base_TimestampInterval{}, terms = TermSet } ] diff --git a/apps/party_management/test/pm_ct_helper.erl b/apps/party_management/test/pm_ct_helper.erl index c5aa153..b4832da 100644 --- a/apps/party_management/test/pm_ct_helper.erl +++ b/apps/party_management/test/pm_ct_helper.erl @@ -169,7 +169,7 @@ create_client_w_context(WoodyCtx) -> %% --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -include_lib("party_management/include/party_events.hrl"). -type contract_id() :: dmsl_domain_thrift:'ContractID'(). @@ -320,7 +320,7 @@ get_first_payout_tool_id(ContractID, Client) -> -spec make_battle_ready_contract_params( dmsl_domain_thrift:'ContractTemplateRef'() | undefined, dmsl_domain_thrift:'PaymentInstitutionRef'() -) -> dmsl_payment_processing_thrift:'ContractParams'(). +) -> dmsl_payproc_thrift:'ContractParams'(). make_battle_ready_contract_params(TemplateRef, PaymentInstitutionRef) -> #payproc_ContractParams{ contractor = make_battle_ready_contractor(), @@ -349,7 +349,7 @@ make_battle_ready_contractor() -> russian_bank_account = BankAccount }}}. --spec make_battle_ready_payout_tool_params() -> dmsl_payment_processing_thrift:'PayoutToolParams'(). +-spec make_battle_ready_payout_tool_params() -> dmsl_payproc_thrift:'PayoutToolParams'(). make_battle_ready_payout_tool_params() -> #payproc_PayoutToolParams{ currency = ?cur(<<"RUB">>), diff --git a/apps/party_management/test/pm_party_tests_SUITE.erl b/apps/party_management/test/pm_party_tests_SUITE.erl index 117e5ed..69ca590 100644 --- a/apps/party_management/test/pm_party_tests_SUITE.erl +++ b/apps/party_management/test/pm_party_tests_SUITE.erl @@ -4,7 +4,9 @@ -include_lib("party_management/include/party_events.hrl"). -include_lib("common_test/include/ct.hrl"). -include_lib("stdlib/include/assert.hrl"). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_thrift.hrl"). +-include_lib("damsel/include/dmsl_base_thrift.hrl"). -export([all/0]). -export([groups/0]). @@ -2127,7 +2129,7 @@ construct_term_set_for_party(PartyID, Def) -> parent_terms = undefined, term_sets = [ #domain_TimedTermSet{ - action_time = #'TimestampInterval'{}, + action_time = #base_TimestampInterval{}, terms = TermSet } ] diff --git a/apps/pm_client/src/pm_client_event_poller.erl b/apps/pm_client/src/pm_client_event_poller.erl index 1fc1e60..8b19883 100644 --- a/apps/pm_client/src/pm_client_event_poller.erl +++ b/apps/pm_client/src/pm_client_event_poller.erl @@ -1,6 +1,6 @@ -module(pm_client_event_poller). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -export([new/2]). -export([poll/4]). diff --git a/apps/pm_client/src/pm_client_party.erl b/apps/pm_client/src/pm_client_party.erl index 0b9f46e..70265ff 100644 --- a/apps/pm_client/src/pm_client_party.erl +++ b/apps/pm_client/src/pm_client_party.erl @@ -1,6 +1,6 @@ -module(pm_client_party). --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). +-include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -export([start/2]). -export([stop/1]). @@ -64,25 +64,25 @@ %% -type party_id() :: dmsl_domain_thrift:'PartyID'(). --type party_params() :: dmsl_payment_processing_thrift:'PartyParams'(). +-type party_params() :: dmsl_payproc_thrift:'PartyParams'(). -type domain_revision() :: dmsl_domain_thrift:'DataRevision'(). -type contract_id() :: dmsl_domain_thrift:'ContractID'(). -type shop_id() :: dmsl_domain_thrift:'ShopID'(). --type claim_id() :: dmsl_payment_processing_thrift:'ClaimID'(). --type claim() :: dmsl_payment_processing_thrift:'Claim'(). --type claim_revision() :: dmsl_payment_processing_thrift:'ClaimRevision'(). --type changeset() :: dmsl_payment_processing_thrift:'PartyChangeset'(). +-type claim_id() :: dmsl_payproc_thrift:'ClaimID'(). +-type claim() :: dmsl_payproc_thrift:'Claim'(). +-type claim_revision() :: dmsl_payproc_thrift:'ClaimRevision'(). +-type changeset() :: dmsl_payproc_thrift:'PartyChangeset'(). -type shop_account_id() :: dmsl_domain_thrift:'AccountID'(). -type meta() :: dmsl_domain_thrift:'PartyMeta'(). -type meta_ns() :: dmsl_domain_thrift:'PartyMetaNamespace'(). -type meta_data() :: dmsl_domain_thrift:'PartyMetaData'(). -type timestamp() :: dmsl_base_thrift:'Timestamp'(). --type party_revision_param() :: dmsl_payment_processing_thrift:'PartyRevisionParam'(). +-type party_revision_param() :: dmsl_payproc_thrift:'PartyRevisionParam'(). -type payment_intitution_ref() :: dmsl_domain_thrift:'PaymentInstitutionRef'(). --type varset() :: dmsl_payment_processing_thrift:'Varset'(). --type contract_terms_varset() :: dmsl_payment_processing_thrift:'ComputeContractTermsVarset'(). --type shop_terms_varset() :: dmsl_payment_processing_thrift:'ComputeShopTermsVarset'(). +-type varset() :: dmsl_payproc_thrift:'Varset'(). +-type contract_terms_varset() :: dmsl_payproc_thrift:'ComputeContractTermsVarset'(). +-type shop_terms_varset() :: dmsl_payproc_thrift:'ComputeShopTermsVarset'(). -type provider_ref() :: dmsl_domain_thrift:'ProviderRef'(). -type terminal_ref() :: dmsl_domain_thrift:'TerminalRef'(). @@ -179,7 +179,7 @@ compute_payment_institution_terms(Ref, Varset, Client) -> compute_payment_institution(Ref, DomainRevision, Varset, Client) -> call(Client, 'ComputePaymentInstitution', [Ref, DomainRevision, Varset]). --spec compute_payout_cash_flow(dmsl_payment_processing_thrift:'PayoutParams'(), pid()) -> +-spec compute_payout_cash_flow(dmsl_payproc_thrift:'PayoutParams'(), pid()) -> dmsl_domain_thrift:'FinalCashFlow'() | woody_error:business_error(). compute_payout_cash_flow(Params, Client) -> call(Client, 'ComputePayoutCashFlow', with_party_id([Params])). @@ -189,7 +189,7 @@ get_shop(ID, Client) -> call(Client, 'GetShop', with_party_id([ID])). -spec get_shop_contract(shop_id(), pid()) -> - dmsl_payment_processing_thrift:'ShopContract'() | woody_error:business_error(). + dmsl_payproc_thrift:'ShopContract'() | woody_error:business_error(). get_shop_contract(ID, Client) -> call(Client, 'GetShopContract', with_party_id([ID])). @@ -243,7 +243,7 @@ revoke_claim(ID, Revision, Reason, Client) -> call(Client, 'RevokeClaim', with_party_id([ID, Revision, Reason])). -spec get_account_state(shop_account_id(), pid()) -> - dmsl_payment_processing_thrift:'AccountState'() | woody_error:business_error(). + dmsl_payproc_thrift:'AccountState'() | woody_error:business_error(). get_account_state(AccountID, Client) -> call(Client, 'GetAccountState', with_party_id([AccountID])). @@ -261,7 +261,7 @@ compute_provider(ProviderRef, Revision, Varset, Client) -> domain_revision(), varset() | undefined, pid() -) -> dmsl_payment_processing_thrift:'ProviderTerminal'() | woody_error:business_error(). +) -> dmsl_payproc_thrift:'ProviderTerminal'() | woody_error:business_error(). compute_provider_terminal(TerminalRef, Revision, Varset, Client) -> call(Client, 'ComputeProviderTerminal', [TerminalRef, Revision, Varset]). @@ -308,7 +308,7 @@ map_result_error({error, Error}) -> %% --type event() :: dmsl_payment_processing_thrift:'Event'(). +-type event() :: dmsl_payproc_thrift:'Event'(). -record(state, { party_id :: party_id(), diff --git a/apps/pm_proto/.gitignore b/apps/pm_proto/.gitignore index e687f8b..a819c2c 100644 --- a/apps/pm_proto/.gitignore +++ b/apps/pm_proto/.gitignore @@ -1,2 +1,2 @@ -/src/dmsl_party_state_thrift.?rl -/include/dmsl_party_state_thrift.hrl +/src/pm_state_thrift.?rl +/include/pm_state_thrift.hrl diff --git a/apps/pm_proto/Makefile b/apps/pm_proto/Makefile deleted file mode 100644 index 59259ae..0000000 --- a/apps/pm_proto/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -THRIFT ?= thrift -GEN := "erlang:scoped_typenames,app_prefix=dmsl" - -src/dmsl_%_thrift.erl src/dmsl_%_thrift.hrl: proto/%.thrift - $(THRIFT) --gen $(GEN) -I $(REBAR_DEPS_DIR) --out src/ $^ - -include/dmsl_%_thrift.hrl: src/dmsl_%_thrift.hrl - mv $^ $@ - -clean: - rm -vf src/dmsl_party_state_thrift.?rl include/dmsl_party_state_thrift.hrl diff --git a/apps/pm_proto/include/dmsl_base_thrift.hrl b/apps/pm_proto/include/dmsl_base_thrift.hrl deleted file mode 100644 index e62f13d..0000000 --- a/apps/pm_proto/include/dmsl_base_thrift.hrl +++ /dev/null @@ -1 +0,0 @@ --include_lib("damsel/include/dmsl_base_thrift.hrl"). diff --git a/apps/pm_proto/include/dmsl_domain_thrift.hrl b/apps/pm_proto/include/dmsl_domain_thrift.hrl deleted file mode 100644 index eef37fb..0000000 --- a/apps/pm_proto/include/dmsl_domain_thrift.hrl +++ /dev/null @@ -1 +0,0 @@ --include_lib("damsel/include/dmsl_domain_thrift.hrl"). diff --git a/apps/pm_proto/include/dmsl_payment_processing_thrift.hrl b/apps/pm_proto/include/dmsl_payment_processing_thrift.hrl deleted file mode 100644 index 1af1a79..0000000 --- a/apps/pm_proto/include/dmsl_payment_processing_thrift.hrl +++ /dev/null @@ -1 +0,0 @@ --include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). diff --git a/apps/pm_proto/proto/party_state.thrift b/apps/pm_proto/proto/party_state.thrift index 519c012..3a13506 100644 --- a/apps/pm_proto/proto/party_state.thrift +++ b/apps/pm_proto/proto/party_state.thrift @@ -2,7 +2,7 @@ include "damsel/proto/base.thrift" include "damsel/proto/domain.thrift" include "damsel/proto/payment_processing.thrift" -namespace erlang pm +namespace erlang pm.state /** * Party state. diff --git a/apps/pm_proto/rebar.config b/apps/pm_proto/rebar.config index 3e3707c..deb07bf 100644 --- a/apps/pm_proto/rebar.config +++ b/apps/pm_proto/rebar.config @@ -1,14 +1,18 @@ -% TODO -% This and stubs in `include/` are hacks designed to trick rebar3 to compile `party_state.thrift` -% as part of dmsl «namespace». This is currently not possible with rebar3_thrift_compiler plugin, -% primarily because underlying thrift `erlang` generator lacks consistent understanding of what -% namespace really is. This _should_ be possible though, we (prabably) need to: -% * intepret thrift namespace as Erlang module namespace, -% * drop `app_prefix` option, -% * disallow generating/compiling same thrift modules under multiple Erlang apps, -% * make generator non-recursive by default. +{deps, []}. -{pre_hooks, [ - {compile, "make src/dmsl_party_state_thrift.erl include/dmsl_party_state_thrift.hrl"}, - {clean, "make clean"} +{plugins, [ + {rebar3_thrift_compiler, + {git, "https://github.com/valitydev/rebar3_thrift_compiler.git", {tag, "0.4"}}} +]}. + +{provider_hooks, [ + {pre, [ + {compile, {thrift, compile}}, + {clean, {thrift, clean}} + ]} +]}. + +{thrift_compiler_opts, [ + {in_dir, "proto"}, + {gen, "erlang:app_namespaces"} ]}. diff --git a/apps/pm_proto/src/pm_proto.erl b/apps/pm_proto/src/pm_proto.erl index e70affb..b7938ac 100644 --- a/apps/pm_proto/src/pm_proto.erl +++ b/apps/pm_proto/src/pm_proto.erl @@ -17,9 +17,9 @@ -spec get_service(Name :: atom()) -> service(). get_service(claim_committer) -> - {dmsl_claim_management_thrift, 'ClaimCommitter'}; + {dmsl_claimmgmt_thrift, 'ClaimCommitter'}; get_service(party_management) -> - {dmsl_payment_processing_thrift, 'PartyManagement'}; + {dmsl_payproc_thrift, 'PartyManagement'}; get_service(accounter) -> {dmsl_accounter_thrift, 'Accounter'}; get_service(automaton) -> diff --git a/elvis.config b/elvis.config index 3ade929..7467542 100644 --- a/elvis.config +++ b/elvis.config @@ -5,7 +5,7 @@ #{ dirs => ["apps/*/**"], filter => "*.erl", - ignore => ["apps/pm_proto/(src|include)/dmsl_.*_thrift\.(e|h)rl"], + ignore => ["apps/pm_proto/(src|include)/.*_thrift\.(e|h)rl"], rules => [ {elvis_text_style, line_length, #{limit => 120, skip_comments => false}}, {elvis_text_style, no_tabs}, diff --git a/rebar.config b/rebar.config index 7320791..ae0ef0c 100644 --- a/rebar.config +++ b/rebar.config @@ -110,5 +110,5 @@ {erlfmt, [ {print_width, 120}, {files, ["apps/*/{src,include,test}/*.{hrl,erl}", "rebar.config", "elvis.config"]}, - {exclude_files, ["apps/pm_proto/{src,include}/dmsl_*_thrift.*rl"]} + {exclude_files, ["apps/pm_proto/{src,include}/*_thrift.*rl"]} ]}. diff --git a/rebar.lock b/rebar.lock index 4bada99..cf72b0e 100644 --- a/rebar.lock +++ b/rebar.lock @@ -9,15 +9,15 @@ {<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},2}, {<<"damsel">>, {git,"https://github.com/valitydev/damsel.git", - {ref,"3eae2029bbe08440836ef0acf6177815c1f66edd"}}, + {ref,"03bbf48194f81132743da79cdeed2b3e8ad9d155"}}, 0}, {<<"dmt_client">>, {git,"https://github.com/valitydev/dmt_client.git", - {ref,"e9b1961b96ce138a34f6cf9cebef6ddf66af1942"}}, + {ref,"899bd71161b4d483719987014be007d7bcf7cfc3"}}, 0}, {<<"dmt_core">>, - {git,"https://github.com/valitydev/dmt_core.git", - {ref,"910e20edbe03ae4645aa3923baea8054003753b5"}}, + {git,"https://github.com/valitydev/dmt-core.git", + {ref,"75841332fe0b40a77da0c12ea8d5dbb994da8e82"}}, 1}, {<<"erl_health">>, {git,"https://github.com/valitydev/erlang-health.git", @@ -34,13 +34,13 @@ {<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2}, {<<"mg_proto">>, {git,"https://github.com/valitydev/machinegun-proto.git", - {ref,"f533965771c168f3c6b61008958fb1366693476a"}}, + {ref,"a411c7d5d779389c70d2594eb4a28a916dce1721"}}, 0}, {<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},2}, {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.1">>},2}, {<<"payproc_errors">>, {git,"https://github.com/valitydev/payproc-errors-erlang.git", - {ref,"ebbfa3775c77d665f519d39ca9afa08c28d7733f"}}, + {ref,"a19e716966b7206e96fbd767661d6fd3bab3119d"}}, 0}, {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},2}, {<<"scoper">>,