From 2381a53334dfc04d037720747892c48e9c84a8e1 Mon Sep 17 00:00:00 2001 From: andylamax Date: Thu, 7 Oct 2021 17:14:01 +0300 Subject: [PATCH 1/6] [[BF133]](https://github.com/picortex/bitframe/issues/133) Made the FormFeedback States easily reusable. Doesn't have to be consumed directly from the SDK --- CHANGELOG.md | 4 + Release.md | 115 ------------------ .../presenters/feedbacks/FormFeedback.kt | 12 +- .../signup/IndividualFormFields.kt | 3 +- .../authentication/signup/SignUpState.kt | 3 +- 5 files changed, 17 insertions(+), 120 deletions(-) delete mode 100644 Release.md diff --git a/CHANGELOG.md b/CHANGELOG.md index dfe51e3a..0776aecf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,10 @@ - [[BF92]](https://github.com/picortex/bitframe/issues/92) Fixed sign in validation bug for empty sign in credentials - [[BF93]](https://github.com/picortex/bitframe/issues/93) Attach Universal testing to cover future bugs +## Bitframe Presenters + +- [[BF133]](https://github.com/picortex/bitframe/issues/133) Made the FormFeedback States easily reusable. Doesn't have to be consumed directly from the SDK + ## Bitframe Test Containers - [[BF96]](https://github.com/picortex/bitframe/issues/96) Make PiMonitor bitframe containers multiplatform diff --git a/Release.md b/Release.md deleted file mode 100644 index e357b954..00000000 --- a/Release.md +++ /dev/null @@ -1,115 +0,0 @@ -# Akkounts Version 0.0.30 - -## Introduction - -Since we have been faced with new challenges of regulating our API requests we had to find a way to regulate our API -from our side. This called for a change in approach for API designs. - -Akkounts 0.0.30 has introduced new ways to configure and yet easily use this approach of ours - -## Getting Started - -### QueryRegulator - -These queries are will be regulated by a class called a `QueryRegulator`. - -1. Assuming you have added the Sage dependencies as instructed on the readme, before ay instantiation we need to - implement a `QueryCountStore`. A `QueryCountStore` should be able to save and load a `QueryCount` which will be used - by the `SageService` to manage the `QueryCounts` and enforce regulations as dictated by - -```java -public class QueryCountStoreImpl implements QueryCountStore { - public QueryCountStoreImpl(/*dependencies here*/) { - - } - - @NotNull - @Override - public Later save(@NotNull QueryCount count) { - return new Later<>((resolve, reject) -> { - // save the count here and return it - resolve.apply(count); - }); - } - - @NotNull - @Override - public Later load(@NotNull String requesterId) { - return new Later<>((resolve, reject) -> { - QueryCount qc = retrieveQueryCount(); // implement this - resolve.apply(qc); - }); - } -} -``` - -2. Create a `Policy` that will be enforced by a query regulator. For example, if we need to be able to allow a maximum - of 2 requests per day, you can do this - -```java -class Demo { - Policy policy = new Policy(2, new Period(1, TimeUnit.DAYS)); - // . . . -} -``` - -3. Now you are ready to instantiate a `QueryRegulator` - -```java -class Demo { - // . . . - QueryCountStore store = new QueryCountStoreImpl(); - QueryRegulator regulator = new QueryRegulator(store, policy); -} -``` - -## Getting Started With Sage - -Sage's main entry point is `SageService`, in favor of Sage and can be shown bellow - -```java -public class SageServiceJavaTest { - private final String apiKey = "{391BC618-64AF-472B-B8C6-76A4EDE2A4A1}"; - private final String companyId = "13956"; - private final OwnerData owner = new OwnerData("", ""); - private final Credentials credentials = new Credentials( - "support@picortex.com", - "daub4foc!BIRN.teab", - apiKey, - companyId - ); - private final Policy policy = new Policy(2, new Period(2, TimeUnit.MINUTES)); - private final QueryCountStore store = new StubStore(); - private final QueryRegulator regulator = new QueryRegulator(store, policy); - private final SageService service = new SageService( - Environment.TEST, owner, credentials, regulator - ); - - @Test - @Ignore - public void should_successfully_get_a_valid_balance_sheet() { - service.balanceSheet(new LocalDate(2021, 3, 31)).then(sheet -> { - System.out.println(sheet); - return null; - }, err -> { - System.out.println("Error here"); - System.out.println(err.getMessage()); - return null; - }).wait(); - } - - @Test - @Ignore - public void should_successfuly_get_a_valid_income_statement() { - LocalDate from = new LocalDate(2021, 1, 1); - LocalDate to = new LocalDate(2021, 1, 31); - service.incomeStatement(from, to).then(statement -> { - System.out.println(statement); - return null; - }, err -> { - System.out.println(err.getMessage()); - return null; - }).wait(); - } -} -``` \ No newline at end of file diff --git a/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/feedbacks/FormFeedback.kt b/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/feedbacks/FormFeedback.kt index 1cbfb503..1cc502a9 100644 --- a/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/feedbacks/FormFeedback.kt +++ b/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/feedbacks/FormFeedback.kt @@ -5,12 +5,18 @@ package bitframe.presenters.feedbacks import kotlin.js.JsExport sealed class FormFeedback(open val message: String) { - data class Loading(override val message: String) : FormFeedback(message) + data class Loading(override val message: String) : FormFeedback(message) { + val loading = true + } data class Failure( val cause: Throwable, override val message: String = cause.message ?: "Unknown failure" - ) : FormFeedback(message) + ) : FormFeedback(message) { + val failure = true + } - data class Success(override val message: String) : FormFeedback(message) + data class Success(override val message: String) : FormFeedback(message) { + val success = true + } } \ No newline at end of file diff --git a/pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/IndividualFormFields.kt b/pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/IndividualFormFields.kt index 51cffbb6..fb03e90e 100644 --- a/pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/IndividualFormFields.kt +++ b/pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/IndividualFormFields.kt @@ -1,10 +1,11 @@ +@file:JsExport + package pimonitor.authentication.signup import bitframe.presenters.fields.ButtonInputField import bitframe.presenters.fields.TextInputField import kotlin.js.JsExport -@JsExport data class IndividualFormFields( val title: String = "Enter your personal information", val name: TextInputField = TextInputField( diff --git a/pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/SignUpState.kt b/pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/SignUpState.kt index eb7c128b..225c2dd5 100644 --- a/pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/SignUpState.kt +++ b/pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/SignUpState.kt @@ -1,8 +1,9 @@ +@file:JsExport + package pimonitor.authentication.signup import kotlin.js.JsExport -@JsExport sealed class SignUpState { data class Loading(val message: String) : SignUpState() From 3b775b438e6b13be37ba6ec15dcc36d182fd5e33 Mon Sep 17 00:00:00 2001 From: andylamax Date: Thu, 7 Oct 2021 17:18:47 +0300 Subject: [PATCH 2/6] Updated changelog --- CHANGELOG.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0776aecf..4315ebc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,11 +42,13 @@ - [[BF100]](https://github.com/picortex/bitframe/issues/100) Cache gradle for faster CI builds -## Dependencies +## Libs/Tools Dependency Changes -- Bumped kotlin to 1.5.31 from 1.5.30 -- Bumped ksp to 1.5.31-1.0.0 from 1.5.30-1.0.0 -- Bumped asoft foundation from 1.4.0 to 1.4.11 +| Lib/Tool | Prev version | Current version| +|----------|--------------|----------------| +| Kotlin | 1.5.30 | 1.5.31 | +| KSP | 1.5.30-1.0.0 | 1.5.31-1.0.0 | +| asoft foundation | 1.4.0| 1.4.11 | # 0.0.28 From ef6294c7a91f27a7e047ef181178f055907ce2ce Mon Sep 17 00:00:00 2001 From: andylamax Date: Fri, 8 Oct 2021 02:57:09 +0300 Subject: [PATCH 3/6] [[PM127]](https://github.com/picortex/bitframe/issues/127) Re authored the SignUpService to accommodate the new designs --- CHANGELOG.md | 1 + .../presenters/fields/DropDownInputField.kt | 19 ++++ .../browser/react/build.gradle.kts | 6 +- .../authentication/signup/IndividualForm.kt | 1 + .../authentication/signup/OrganisationForm.kt | 1 + .../pimonitor/authentication/signup/SignUp.kt | 4 +- .../sdks/full/build.gradle.kts | 1 + .../signup/BusinessFormFields.kt | 23 +++++ .../signup/BusinessFormFieldsUtils.kt | 8 ++ .../signup/IndividualFormFields.kt | 31 +++---- .../signup/IndividualFormFieldsUtils.kt | 7 ++ .../authentication/signup/SignUpIntent.kt | 15 ++-- .../authentication/signup/SignUpState.kt | 16 ++-- .../authentication/signup/SignUpStateUtils.kt | 30 +++++++ .../authentication/signup/SignUpViewModel.kt | 79 +++++------------ .../signup/legacy/IndividualFormFields.kt | 32 +++++++ .../{ => legacy}/OrganisationFormFields.kt | 3 +- .../signup/legacy/SignUpIntent.kt | 15 ++++ .../signup/legacy/SignUpState.kt | 23 +++++ .../signup/legacy/SignUpViewModel.kt | 85 ++++++++++++++++++ .../kotlin/core/signup/SignUpViewModelTest.kt | 88 +++++++++++++++++++ .../kotlin/integration/ExhaustionTest.kt | 11 --- .../signup/SignUpViewModelIntegrationTest.kt | 23 +++++ ...Sign_Up_As_An_Individual_ViewModel_Test.kt | 11 ++- ...gn_Up_As_An_Organisation_ViewModel_Test.kt | 10 +-- .../commonTest/kotlin/unit/ExhaustionTest.kt | 11 --- .../unit/signup/SignUpViewModelUnitTest.kt | 19 ++++ .../signup/exports/SignUpScope.kt | 6 +- .../pi-monitor-daos/core/build.gradle.kts | 26 ++++++ .../core/karma.config.d/timeout.js | 8 ++ .../kotlin/pimonitor/monitors/MonitorDao.kt | 7 ++ .../pimonitor/monitors}/SignUpParams.kt | 8 +- .../pimonitor/monitors/SignUpParamsUtils.kt | 19 ++++ .../pi-monitor-daos/inmemory/build.gradle.kts | 26 ++++++ .../inmemory/karma.config.d/timeout.js | 8 ++ .../pimonitor/monitors/MonitorDaoInMemory.kt | 34 +++++++ .../pi-monitor-services/core/build.gradle.kts | 2 +- .../authentication/signup/SignUpService.kt | 25 ++++++ .../signup/SignUpServiceImpl.kt | 29 ++++-- .../signup/SignUpServiceKtor.kt | 1 + .../pi-monitor-services/stub/build.gradle.kts | 1 + .../kotlin/pimonitor/PiMonitorServiceStub.kt | 3 +- settings.gradle.kts | 2 + 43 files changed, 636 insertions(+), 142 deletions(-) create mode 100644 bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/DropDownInputField.kt create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/BusinessFormFields.kt create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/BusinessFormFieldsUtils.kt create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/IndividualFormFieldsUtils.kt create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/SignUpStateUtils.kt create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/legacy/IndividualFormFields.kt rename pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/{ => legacy}/OrganisationFormFields.kt (89%) create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/legacy/SignUpIntent.kt create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/legacy/SignUpState.kt create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonMain/kotlin/pimonitor/authentication/signup/legacy/SignUpViewModel.kt create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonTest/kotlin/core/signup/SignUpViewModelTest.kt delete mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonTest/kotlin/integration/ExhaustionTest.kt create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonTest/kotlin/integration/signup/SignUpViewModelIntegrationTest.kt rename pi-monitor/pi-monitor-client/sdks/full/src/commonTest/kotlin/integration/signup/{ => legacy}/Sign_Up_As_An_Individual_ViewModel_Test.kt (79%) rename pi-monitor/pi-monitor-client/sdks/full/src/commonTest/kotlin/integration/signup/{ => legacy}/Sign_Up_As_An_Organisation_ViewModel_Test.kt (84%) delete mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonTest/kotlin/unit/ExhaustionTest.kt create mode 100644 pi-monitor/pi-monitor-client/sdks/full/src/commonTest/kotlin/unit/signup/SignUpViewModelUnitTest.kt create mode 100644 pi-monitor/pi-monitor-daos/core/build.gradle.kts create mode 100644 pi-monitor/pi-monitor-daos/core/karma.config.d/timeout.js create mode 100644 pi-monitor/pi-monitor-daos/core/src/commonMain/kotlin/pimonitor/monitors/MonitorDao.kt rename pi-monitor/{pi-monitor-services/core/src/commonMain/kotlin/pimonitor/authentication/signup => pi-monitor-daos/core/src/commonMain/kotlin/pimonitor/monitors}/SignUpParams.kt (72%) create mode 100644 pi-monitor/pi-monitor-daos/core/src/commonMain/kotlin/pimonitor/monitors/SignUpParamsUtils.kt create mode 100644 pi-monitor/pi-monitor-daos/inmemory/build.gradle.kts create mode 100644 pi-monitor/pi-monitor-daos/inmemory/karma.config.d/timeout.js create mode 100644 pi-monitor/pi-monitor-daos/inmemory/src/commonMain/kotlin/pimonitor/monitors/MonitorDaoInMemory.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 4315ebc4..31073e33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## PiMonitor Client SDK Core +- [[PM127]](https://github.com/picortex/bitframe/issues/127) Re authored the SignUpService to accommodate the new designs - [[PM103]](https://github.com/picortex/bitframe/issues/103) Moved SignUpTest to commonMain ## PiMonitor Client Browser Web diff --git a/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/DropDownInputField.kt b/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/DropDownInputField.kt new file mode 100644 index 00000000..55e65dc4 --- /dev/null +++ b/bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/DropDownInputField.kt @@ -0,0 +1,19 @@ +@file:JsExport + +package bitframe.presenters.fields + +import kotlin.js.JsExport +import kotlin.js.JsName + +data class DropDownInputField( + val options: List