From c11183fd42effa930850f5bb8363a6ab7c3ec570 Mon Sep 17 00:00:00 2001 From: Uraz Akgultan Date: Wed, 11 Oct 2023 01:17:38 +0200 Subject: [PATCH] chore: migrate Nanoflow Actions to nanoflow-commons repo for better modularity --- .../nanoflow-actions-native/CHANGELOG.md | 118 ---------- .../jsActions/nanoflow-actions-native/LICENSE | 202 ------------------ .../nanoflow-actions-native/README.md | 1 - .../nanoflow-actions-native/package.json | 39 ---- .../src/client/GetRemoteUrl.ts | 19 -- .../src/client/HideProgress.ts | 29 --- .../src/client/IsConnectedToServer.ts | 25 --- .../src/client/RefreshEntity.ts | 29 --- .../src/client/RefreshObject.ts | 29 --- .../src/client/Reload.ts | 23 -- .../src/client/ShowConfirmation.ts | 61 ------ .../src/client/ShowProgress.ts | 31 --- .../src/client/SignIn.ts | 38 ---- .../src/client/SignOut.ts | 28 --- .../src/client/ToggleSidebar.ts | 29 --- .../src/datetime/TimeBetween.ts | 68 ------ .../src/external/CallPhoneNumber.ts | 53 ----- .../src/external/DraftEmail.ts | 78 ------- .../src/external/NavigateTo.ts | 84 -------- .../src/external/OpenMap.ts | 84 -------- .../src/external/OpenURL.ts | 52 ----- .../src/external/SendTextMessage.ts | 54 ----- .../src/external/Share.ts | 72 ------- .../src/geolocation/Geocode.ts | 139 ------------ .../src/geolocation/GetCurrentLocation.ts | 137 ------------ .../GetCurrentLocationMinimumAccuracy.ts | 179 ---------------- .../geolocation/GetStraightLineDistance.ts | 74 ------- .../geolocation/RequestLocationPermission.ts | 160 -------------- .../src/geolocation/ReverseGeocode.ts | 131 ------------ .../local-storage/ClearCachedSessionData.ts | 25 --- .../src/local-storage/ClearLocalStorage.ts | 25 --- .../src/local-storage/GetStorageItemObject.ts | 117 ---------- .../local-storage/GetStorageItemObjectList.ts | 115 ---------- .../src/local-storage/GetStorageItemString.ts | 46 ---- .../src/local-storage/RemoveStorageItem.ts | 39 ---- .../src/local-storage/SetStorageItemObject.ts | 58 ----- .../local-storage/SetStorageItemObjectList.ts | 58 ----- .../src/local-storage/SetStorageItemString.ts | 45 ---- .../src/local-storage/StorageItemExists.ts | 40 ---- .../src/other/Base64Decode.ts | 21 -- .../src/other/Base64DecodeToImage.ts | 36 ---- .../src/other/Base64Encode.ts | 21 -- .../src/other/FindObjectWithGUID.ts | 26 --- .../src/other/GenerateUniqueID.ts | 73 ------- .../src/other/GetGuid.ts | 25 --- .../src/other/GetObjectByGuid.ts | 41 ---- .../src/other/GetPlatform.ts | 28 --- .../nanoflow-actions-native/src/other/Wait.ts | 28 --- .../nanoflow-actions-native/tsconfig.json | 18 -- .../typings/Geolocation.d.ts | 22 -- .../typings/StorageValue.d.ts | 4 - .../nanoflow-actions-native/typings/mx.d.ts | 15 -- .../typings/navigator.d.ts | 8 - .../typings/react-native-geocoder.d.ts | 36 ---- .../typings/window.d.ts | 20 -- scripts/release/README.md | 8 +- scripts/release/createNativeModules.js | 32 +-- scripts/test/e2e-native.js | 2 +- yarn.lock | 40 ---- 59 files changed, 6 insertions(+), 3132 deletions(-) delete mode 100644 packages/jsActions/nanoflow-actions-native/CHANGELOG.md delete mode 100644 packages/jsActions/nanoflow-actions-native/LICENSE delete mode 100644 packages/jsActions/nanoflow-actions-native/README.md delete mode 100644 packages/jsActions/nanoflow-actions-native/package.json delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/GetRemoteUrl.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/HideProgress.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/IsConnectedToServer.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/RefreshEntity.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/RefreshObject.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/Reload.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/ShowConfirmation.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/ShowProgress.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/SignIn.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/SignOut.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/client/ToggleSidebar.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/datetime/TimeBetween.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/external/CallPhoneNumber.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/external/DraftEmail.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/external/NavigateTo.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/external/OpenMap.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/external/OpenURL.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/external/SendTextMessage.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/external/Share.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/geolocation/Geocode.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/geolocation/GetCurrentLocation.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/geolocation/GetCurrentLocationMinimumAccuracy.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/geolocation/GetStraightLineDistance.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/geolocation/RequestLocationPermission.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/geolocation/ReverseGeocode.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/local-storage/ClearCachedSessionData.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/local-storage/ClearLocalStorage.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemObject.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemObjectList.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemString.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/local-storage/RemoveStorageItem.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemObject.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemObjectList.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemString.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/local-storage/StorageItemExists.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/other/Base64Decode.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/other/Base64DecodeToImage.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/other/Base64Encode.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/other/FindObjectWithGUID.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/other/GenerateUniqueID.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/other/GetGuid.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/other/GetObjectByGuid.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/other/GetPlatform.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/src/other/Wait.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/tsconfig.json delete mode 100644 packages/jsActions/nanoflow-actions-native/typings/Geolocation.d.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/typings/StorageValue.d.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/typings/mx.d.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/typings/navigator.d.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/typings/react-native-geocoder.d.ts delete mode 100644 packages/jsActions/nanoflow-actions-native/typings/window.d.ts diff --git a/packages/jsActions/nanoflow-actions-native/CHANGELOG.md b/packages/jsActions/nanoflow-actions-native/CHANGELOG.md deleted file mode 100644 index b7e081410..000000000 --- a/packages/jsActions/nanoflow-actions-native/CHANGELOG.md +++ /dev/null @@ -1,118 +0,0 @@ -# Changelog - -All notable changes to this widget will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -## [4.0.0] Nanoflow Commons - 2023-6-9 - -### Added - -- We changed the JS actions and widgets icons. - -## [3.0.0] Native Mobile Resources - 2023-3-28 - -- We made widgets compatible with React Native 0.70.7 - -## [2.6.1] Nanoflow Commons - 2022-9-23 - -### Fixed - -- We fixed issue with Base64 actions throwing error - -## [2.6.0] Nanoflow Commons - 2022-8-31 - -### Breaking - -- We removed next actions: - - SetCookie (will be available in Web Actions module) - - ReadCookie (will be available in Web Actions module) - - SetFavicon (will be available in Web Actions module) - - ScrollToClass - - AddMilliseconds - - AddTime -- "Is connected" action is renamed to "Is connected to server" -- Parameter names are changed for next actions: - - Base64Decode - - Base64DecodeToImage - - Base64Encode - - GetStraightLineDistance -- New "Enum_DistanceUnit" enum is introduce for GetStraightLineDistance action - -## [2.5.0] Nanoflow Commons - 2022-7-25 - -### Added - -- We introduced a new set of actions: - - AddMilliseconds - - AddTime - - Base64Decode - - Base64DecodeToImage - - Base64Encode - - ClearLocalStorage - - FindObjectWithGUID - - GetCurrentLocation - - GetRemoteUrl - - GetStraightLineDistance - - IsConnected - - ReadCookie - - ScrollToClass - - SetCookie - - SetFavicon - - TimeBetween - -## [2.4.0] Nanoflow Commons - 2022-6-28 - -### Added - -- We introduced a new [Clear cached session data] action to clear the cached session data from local storage. -- We introdcued a new [Reload] action that reloads the app. - -### Breaking - -- [Clear cached session data] action would only be compatible with Mendix client `9.14` or above. - -## [2.3.1] Nanoflow Commons - 2022-3-22 - -### Fixed - -- Reduce module size by removing unused dependencies. This should speed up interaction with Team Server. - -## [2.3.0] Nanoflow Commons - 2022-3-9 - -### Fixed - -- We fixed the timeout error while getting the current location. -- We fixed a timeout issue while getting the current location with minimum accuracy. - -### Breaking - -- iOS: We changed the library that uses [android.location API](https://developer.android.com/reference/android/location/package-summary), to the new library that uses the [Google Location Services API](https://developer.android.com/training/location/). Regarding this change, you should use `Request location permission` action before using `Get current location` and `Get current location with minimum accuracy` action. -- Get current location with minimum accuracy: For good user experience, disable the nanoflow during action using property `Disabled during action` if you’re using `Call a nanoflow button` to run JS Action `Get current location with minimum accuracy`. - -## [2.2.0] Nanoflow Commons - 2022-2-21 - -### Added - -- We introduce a new `Get current location with minimum accuracy` action to acquire more precise locations. -- Dark theme icons for JS Actions - -### Fixed - -- We fixed a bug where the `Speed` was not being defined while using `Get current location` action. -- We removed some unwanted files from the module. - -## [2.1.2] Nanoflow Commons - 2021-10-25 - -### Fixed - -- We fixed a problem with toggle sidebar action when executed in Native apps. -- We removed some unwanted files from the module. - -## [2.1.0] Nanoflow Commons - 2021-9-28 - -### Added - -- We added a toolbox tile image for all JS actions in Studio & Studio Pro. diff --git a/packages/jsActions/nanoflow-actions-native/LICENSE b/packages/jsActions/nanoflow-actions-native/LICENSE deleted file mode 100644 index 564e56569..000000000 --- a/packages/jsActions/nanoflow-actions-native/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2019 Mendix BV - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - \ No newline at end of file diff --git a/packages/jsActions/nanoflow-actions-native/README.md b/packages/jsActions/nanoflow-actions-native/README.md deleted file mode 100644 index b3a9b2ab5..000000000 --- a/packages/jsActions/nanoflow-actions-native/README.md +++ /dev/null @@ -1 +0,0 @@ -Please see [Nanoflow Commons](https://docs.mendix.com/appstore/modules/nanoflow-commons) in the Mendix documentation for details. diff --git a/packages/jsActions/nanoflow-actions-native/package.json b/packages/jsActions/nanoflow-actions-native/package.json deleted file mode 100644 index 1bcd88117..000000000 --- a/packages/jsActions/nanoflow-actions-native/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "nanoflow-actions-native", - "moduleName": "Nanoflow Commons", - "version": "4.0.0", - "license": "Apache-2.0", - "copyright": "© Mendix Technology BV 2022. All rights reserved.", - "repository": { - "type": "git", - "url": "https://github.com/mendix/native-widgets.git" - }, - "marketplace": { - "minimumMXVersion": "10.0.0.8352", - "marketplaceId": 109515 - }, - "testProject": { - "githubUrl": "https://github.com/mendix/native-mobile-resources", - "branchName": "main" - }, - "scripts": { - "start": "rollup --config ../../../configs/jsactions/rollup.config.js --watch --configProject nanoflowcommons", - "build": "rollup --config ../../../configs/jsactions/rollup.config.js --configProject nanoflowcommons", - "lint": "eslint --config ../../../.eslintrc.js --ext .jsx,.js,.ts,.tsx src/", - "release": "yarn build", - "release:marketplace": "node ../../../scripts/release/marketplaceRelease.js" - }, - "dependencies": { - "@react-native-community/async-storage": "1.12.1", - "@react-native-community/geolocation": "2.0.2", - "invariant": "^2.2.4", - "js-base64": "~3.7.2", - "react-native-geocoder": "0.5.0", - "react-native-geolocation-service": "5.2.0" - }, - "devDependencies": { - "@mendix/pluggable-widgets-tools": "^9.0.0", - "eslint": "^7.20.0", - "rollup": "^2.68.0" - } -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/GetRemoteUrl.ts b/packages/jsActions/nanoflow-actions-native/src/client/GetRemoteUrl.ts deleted file mode 100644 index 1c1ae7a9e..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/GetRemoteUrl.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @returns {Promise.} - */ -export async function GetRemoteUrl(): Promise { - // BEGIN USER CODE - return mx.remoteUrl; - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/HideProgress.ts b/packages/jsActions/nanoflow-actions-native/src/client/HideProgress.ts deleted file mode 100644 index 6f7ba9869..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/HideProgress.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Big } from "big.js"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Hides a loading dialog. - * @param {Big} identifier - This field is required. - * @returns {Promise.} - */ -export async function HideProgress(identifier?: Big): Promise { - // BEGIN USER CODE - - if (identifier == null) { - return Promise.reject(new Error("Input parameter 'Identifier' is required")); - } - - mx.ui.hideProgress(Number(identifier)); - return Promise.resolve(); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/IsConnectedToServer.ts b/packages/jsActions/nanoflow-actions-native/src/client/IsConnectedToServer.ts deleted file mode 100644 index 6b47b7bda..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/IsConnectedToServer.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @returns {Promise.} - */ -export async function IsConnectedToServer(): Promise { - // BEGIN USER CODE - try { - const response = await fetch(mx.remoteUrl); - return response.ok; - } catch (err) { - console.error(err); - return false; - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/RefreshEntity.ts b/packages/jsActions/nanoflow-actions-native/src/client/RefreshEntity.ts deleted file mode 100644 index 6c02a6c41..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/RefreshEntity.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @param {string} entityToRefresh - Entity which will be refreshed. - * @returns {Promise.} - */ -export async function RefreshEntity(entityToRefresh: string) { - // BEGIN USER CODE - if (!entityToRefresh) { - return Promise.reject(new Error("EntityToRefresh parameter is required")); - } - - return new Promise(resolve => { - mx.data.update({ - entity: entityToRefresh, - callback: () => resolve(true) - }); - }); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/RefreshObject.ts b/packages/jsActions/nanoflow-actions-native/src/client/RefreshObject.ts deleted file mode 100644 index dce64f130..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/RefreshObject.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @param {MxObject} objectToRefresh - Object which will be refreshed. - * @returns {Promise.} - */ -export async function RefreshObject(objectToRefresh: mendix.lib.MxObject) { - // BEGIN USER CODE - if (!objectToRefresh) { - return Promise.reject(new Error("ObjectToRefresh parameter is required")); - } - - return new Promise(resolve => { - mx.data.update({ - guid: objectToRefresh.getGuid(), - callback: () => resolve(true) - }); - }); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/Reload.ts b/packages/jsActions/nanoflow-actions-native/src/client/Reload.ts deleted file mode 100644 index 1b3d55071..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/Reload.ts +++ /dev/null @@ -1,23 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @returns {Promise.} - */ -export async function Reload(): Promise { - // BEGIN USER CODE - mx.reload(); - return new Promise(() => { - // Never resolve this pormise to ensure that the next action in the nanoflow (if any) - // will not be executed before the actual reload is happended. - }); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/ShowConfirmation.ts b/packages/jsActions/nanoflow-actions-native/src/client/ShowConfirmation.ts deleted file mode 100644 index 8b883dde6..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/ShowConfirmation.ts +++ /dev/null @@ -1,61 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import ReactNative from "react-native"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Shows a confirmation dialog during the execution of a nanoflow, to make perform actions based on the user input. - * @param {string} titleCaption - Set to empty to use default text 'Confirmation'. (Only for native) - * @param {string} question - This field is required. - * @param {string} cancelButtonCaption - Set to empty to use default text 'Cancel'. - * @param {string} proceedButtonCaption - Set to empty to use default text 'OK'. - * @returns {Promise.} - */ -export async function ShowConfirmation( - titleCaption?: string, - question?: string, - cancelButtonCaption?: string, - proceedButtonCaption?: string -): Promise { - // BEGIN USER CODE - - if (!question) { - return Promise.reject(new Error("Input parameter 'Question' is required")); - } - - const cancel = cancelButtonCaption || "Cancel"; - const proceed = proceedButtonCaption || "OK"; - const title = titleCaption || "Confirmation"; - - // Native platform - if (navigator && navigator.product === "ReactNative") { - const Alert: typeof ReactNative.Alert = require("react-native").Alert; - - return new Promise(resolve => { - Alert.alert(title, question, [ - { text: cancel, onPress: () => resolve(false), style: "cancel" }, - { text: proceed, onPress: () => resolve(true) } - ]); - }); - } - - // Other platforms - return new Promise(resolve => { - mx.ui.confirmation({ - content: question, - proceed, - cancel, - handler: () => resolve(true), - onCancel: () => resolve(false) - } as any); - }); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/ShowProgress.ts b/packages/jsActions/nanoflow-actions-native/src/client/ShowProgress.ts deleted file mode 100644 index bf4a3259d..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/ShowProgress.ts +++ /dev/null @@ -1,31 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Big } from "big.js"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Shows a loading dialog. - * - * Returns an identifier that can be used to close the dialog. - * @param {string} message - The text to show while loading. - * @param {boolean} blocking - Block the user interface immediately. - * @returns {Promise.} - */ -export async function ShowProgress(message?: string, blocking?: boolean): Promise { - // BEGIN USER CODE - - const id = mx.ui.showProgress(message, blocking); - if (id !== undefined) { - return Promise.resolve(new Big(id)); - } - return Promise.reject(new Error("Could not open the loading dialog")); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/SignIn.ts b/packages/jsActions/nanoflow-actions-native/src/client/SignIn.ts deleted file mode 100644 index 6021a3e37..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/SignIn.ts +++ /dev/null @@ -1,38 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Big } from "big.js"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Tries to login using a username and password. - * - * Returns an HTTP response status code, for example: - * - 200 when the login succeeds - * - 401 when the entered username or password is incorrect - * - 0 when the network connection is unavailable - * - * @param {string} username - This field is required. - * @param {string} password - This field is required. - * @returns {Promise.} - */ -export async function SignIn(username?: string, password?: string): Promise { - // BEGIN USER CODE - if (!username || !password) { - return Promise.resolve(new Big(401)); - } - - return new Promise(resolve => { - const onSuccess = (): void => resolve(new Big(200)); - const onError = (error: { status: number }): void => resolve(new Big(error.status)); - - mx.login(username, password, onSuccess, onError as any); - }); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/SignOut.ts b/packages/jsActions/nanoflow-actions-native/src/client/SignOut.ts deleted file mode 100644 index 5a4e2c340..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/SignOut.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * If the user is logged in, logs out the user and restarts the client. - * - * If the user is not logged in, the return value is false. - * - * @returns {Promise.} - */ -export async function SignOut(): Promise { - // BEGIN USER CODE - if (!mx.session.isGuest()) { - mx.logout(); - return Promise.resolve(true); - } - - return Promise.resolve(false); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/client/ToggleSidebar.ts b/packages/jsActions/nanoflow-actions-native/src/client/ToggleSidebar.ts deleted file mode 100644 index ae2c474da..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/client/ToggleSidebar.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Toggle the sidebar. - * @returns {Promise.} - */ -export async function ToggleSidebar(): Promise { - // BEGIN USER CODE - - mx.ui.toggleSidebar(); - - // Web platform - if (window && !(navigator && navigator.product === "ReactNative")) { - document.dispatchEvent(new CustomEvent("toggleSidebar")); - } - - return Promise.resolve(); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/datetime/TimeBetween.ts b/packages/jsActions/nanoflow-actions-native/src/datetime/TimeBetween.ts deleted file mode 100644 index 061b91017..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/datetime/TimeBetween.ts +++ /dev/null @@ -1,68 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Big } from "big.js"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -type UnitOfTime = "MILLISECOND" | "SECOND" | "MINUTE" | "HOUR" | "DAY"; - -/** - * TimeBetween - * The TimeBetween function calculates the difference between the input Date and times in milliseconds, seconds, minutes, hours or days, depending on the ENUM_UnitOfTime provided. - * - * Input Parameters - * startDate: DateTime - * endDate: DateTime - * unitOfTime: ENUM_UnitOfTime - * - * Output - * The action will return the difference between the two dates, as a Decimal, measured in milliseconds, seconds, minutes, hours or days, depending on the value of ENUM_UnitOfTime. - * @param {Date} startDate - * @param {Date} endDate - * @param {"MILLISECOND"|"SECOND"|"MINUTE"|"HOUR"|"DAY"} unitOfTime - * @returns {Promise.} - */ -export async function TimeBetween(startDate: Date, endDate: Date, unitOfTime: UnitOfTime): Promise { - // BEGIN USER CODE - - if (startDate == null) { - throw new Error("Required field: startDate"); - } - - if (endDate == null) { - throw new Error("Required field: endDate"); - } - - if (unitOfTime == null) { - throw new Error("Required field: unitOfTime"); - } - - const difference = endDate.getTime() - startDate.getTime(); - - function getDiff(difference: number, unit: UnitOfTime): number { - switch (unit) { - case "MILLISECOND": - return difference; - case "SECOND": - return difference / 1000; - case "MINUTE": - return difference / 60000; - case "HOUR": - return difference / 3600000; - case "DAY": - return difference / 86400000; - default: - throw new Error("Unit of time not supported: " + unit); - } - } - - return new Big(getDiff(difference, unitOfTime)); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/external/CallPhoneNumber.ts b/packages/jsActions/nanoflow-actions-native/src/external/CallPhoneNumber.ts deleted file mode 100644 index f305bc7db..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/external/CallPhoneNumber.ts +++ /dev/null @@ -1,53 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import ReactNative from "react-native"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @param {string} phoneNumber - This field is required. - * @returns {Promise.} - */ -export async function CallPhoneNumber(phoneNumber?: string): Promise { - // BEGIN USER CODE - - if (!phoneNumber) { - return Promise.reject(new Error("Input parameter 'Phone number' is required")); - } - - const url = `tel:${encodeURI(phoneNumber)}`; - - // Native platform - if (navigator && navigator.product === "ReactNative") { - const Linking: typeof ReactNative.Linking = require("react-native").Linking; - - return Linking.canOpenURL(url).then(supported => { - if (!supported) { - return false; - } - return Linking.openURL(url).then(() => true); - }); - } - - // Hybrid platform - if (window && window.cordova) { - window.open(url, "_system"); - return Promise.resolve(true); - } - - // Web platform - if (window) { - window.location.href = url; - return Promise.resolve(true); - } - - return Promise.resolve(false); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/external/DraftEmail.ts b/packages/jsActions/nanoflow-actions-native/src/external/DraftEmail.ts deleted file mode 100644 index 3d106e812..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/external/DraftEmail.ts +++ /dev/null @@ -1,78 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import ReactNative from "react-native"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Start drafting an email in the platform specified email client. This might work differently for each user depending on their platform and local configuration. - * @param {string} recipient - The recipient, or recipients, separated by comma's. - * @param {string} cc - The Carbon Copy recipient, or recipients, separated by comma's. - * @param {string} bcc - The Blind Carbon Copy recipient, or recipients, separated by comma's. - * @param {string} subject - * @param {string} body - * @returns {Promise.} - */ -export async function DraftEmail( - recipient?: string, - cc?: string, - bcc?: string, - subject?: string, - body?: string -): Promise { - // BEGIN USER CODE - - let url = "mailto:"; - if (recipient) { - url += `${encodeURI(recipient)}?`; - } - if (cc) { - url += `cc=${encodeURIComponent(cc)}&`; - } - if (bcc) { - url += `bcc=${encodeURIComponent(bcc)}&`; - } - if (subject) { - url += `subject=${encodeURIComponent(subject)}&`; - } - if (body) { - url += `body=${encodeURIComponent(body)}&`; - } - - // Remove the last '?' or '&' - url = url.slice(0, -1); - - // Native platform - if (navigator && navigator.product === "ReactNative") { - const Linking: typeof ReactNative.Linking = require("react-native").Linking; - - return Linking.canOpenURL(url).then(supported => { - if (!supported) { - return false; - } - return Linking.openURL(url).then(() => true); - }); - } - - // Hybrid platform - if (window && window.cordova) { - window.open(url, "_system"); - return Promise.resolve(true); - } - - // Web platform - if (window) { - window.location.href = url; - return Promise.resolve(true); - } - - return Promise.resolve(false); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/external/NavigateTo.ts b/packages/jsActions/nanoflow-actions-native/src/external/NavigateTo.ts deleted file mode 100644 index d85978a23..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/external/NavigateTo.ts +++ /dev/null @@ -1,84 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import ReactNative from "react-native"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Opens a navigation application on your device or a web browser showing Google Maps directions. - * @param {string} location - This field is required. - * @returns {Promise.} - */ -export async function NavigateTo(location?: string): Promise { - // BEGIN USER CODE - - if (!location) { - return Promise.reject(new Error("Input parameter 'Location' is required")); - } - - location = encodeURIComponent(location); - const iosUrl = `maps://maps.apple.com/?daddr=${location}`; - const androidUrl = `google.navigation:q=${location}`; - const webUrl = `https://maps.google.com/maps?daddr=${location}`; - - // Native platform - if (navigator && navigator.product === "ReactNative") { - const Linking: typeof ReactNative.Linking = require("react-native").Linking; - const Platform: typeof ReactNative.Platform = require("react-native").Platform; - - const url = Platform.select({ - ios: iosUrl, - default: androidUrl - }); - - return Linking.canOpenURL(url).then(supported => { - if (!supported) { - return false; - } - return Linking.openURL(url).then(() => true); - }); - } - - // Hybrid or mobile web platform - if (window && window.navigator.userAgent) { - // iOS platform - if (/iPad|iPhone|iPod/i.test(window.navigator.userAgent)) { - openUrl(iosUrl); - return Promise.resolve(true); - } - - // Android platform - if (/android|sink/i.test(window.navigator.userAgent)) { - openUrl(androidUrl); - return Promise.resolve(true); - } - } - - // Desktop web or other platform - if (window) { - window.location.href = webUrl; - return Promise.resolve(true); - } - - return Promise.resolve(false); - - function openUrl(url: string): void { - // Hybrid platform - if (window && window.cordova) { - window.open(url, "_system"); - } - - // Mobile web platform - if (window) { - window.location.href = url; - } - } - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/external/OpenMap.ts b/packages/jsActions/nanoflow-actions-native/src/external/OpenMap.ts deleted file mode 100644 index ff637725b..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/external/OpenMap.ts +++ /dev/null @@ -1,84 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import ReactNative from "react-native"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Opens a map application on your device or a web browser showing Google Maps. - * @param {string} location - This field is required. - * @returns {Promise.} - */ -export async function OpenMap(location?: string): Promise { - // BEGIN USER CODE - - if (!location) { - return Promise.reject(new Error("Input parameter 'Location' is required")); - } - - location = encodeURIComponent(location); - const iosUrl = `maps://maps.apple.com/?q=${location}`; - const androidUrl = `geo:0,0?q=${location}`; - const webUrl = `https://maps.google.com/maps?q=${location}`; - - // Native platform - if (navigator && navigator.product === "ReactNative") { - const Linking: typeof ReactNative.Linking = require("react-native").Linking; - const Platform: typeof ReactNative.Platform = require("react-native").Platform; - - const url = Platform.select({ - ios: iosUrl, - default: androidUrl - }); - - return Linking.canOpenURL(url).then(supported => { - if (!supported) { - return false; - } - return Linking.openURL(url).then(() => true); - }); - } - - // Hybrid or mobile web platform - if (window && window.navigator.userAgent) { - // iOS platform - if (/iPad|iPhone|iPod/i.test(window.navigator.userAgent)) { - openUrl(iosUrl); - return Promise.resolve(true); - } - - // Android platform - if (/android|sink/i.test(window.navigator.userAgent)) { - openUrl(androidUrl); - return Promise.resolve(true); - } - } - - // Desktop web or other platform - if (window) { - window.location.href = webUrl; - return Promise.resolve(true); - } - - return Promise.resolve(false); - - function openUrl(url: string): void { - // Hybrid platform - if (window && window.cordova) { - window.open(url, "_system"); - } - - // Mobile web platform - if (window) { - window.location.href = url; - } - } - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/external/OpenURL.ts b/packages/jsActions/nanoflow-actions-native/src/external/OpenURL.ts deleted file mode 100644 index 99921ba41..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/external/OpenURL.ts +++ /dev/null @@ -1,52 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import ReactNative from "react-native"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Opens the provided URL in the web browser. - * @param {string} url - This field is required. - * @returns {Promise.} - */ -export async function OpenURL(url?: string): Promise { - // BEGIN USER CODE - - if (!url) { - return Promise.reject(new Error("Input parameter 'Url' is required")); - } - - // Native platform - if (navigator && navigator.product === "ReactNative") { - const Linking: typeof ReactNative.Linking = require("react-native").Linking; - - return Linking.canOpenURL(url).then(supported => { - if (!supported) { - return false; - } - return Linking.openURL(url).then(() => true); - }); - } - - // Hybrid platform - if (window && window.cordova) { - window.open(url, "_system"); - return Promise.resolve(true); - } - - // Web platform - if (window) { - window.location.href = url; - return Promise.resolve(true); - } - - return Promise.resolve(false); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/external/SendTextMessage.ts b/packages/jsActions/nanoflow-actions-native/src/external/SendTextMessage.ts deleted file mode 100644 index ab6549514..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/external/SendTextMessage.ts +++ /dev/null @@ -1,54 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import ReactNative from "react-native"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Launches the text messaging app on your device. - * @param {string} phoneNumber - This field is required. - * @returns {Promise.} - */ -export async function SendTextMessage(phoneNumber?: string): Promise { - // BEGIN USER CODE - - if (!phoneNumber) { - return Promise.reject(new Error("Input parameter 'Phone number' is required")); - } - - const url = `sms:${encodeURI(phoneNumber)}`; - - // Native platform - if (navigator && navigator.product === "ReactNative") { - const Linking: typeof ReactNative.Linking = require("react-native").Linking; - - return Linking.canOpenURL(url).then(supported => { - if (!supported) { - return false; - } - return Linking.openURL(url).then(() => true); - }); - } - - // Hybrid platform - if (window && window.cordova) { - window.open(url, "_system"); - return Promise.resolve(true); - } - - // Web platform - if (window) { - window.location.href = url; - return Promise.resolve(true); - } - - return Promise.resolve(false); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/external/Share.ts b/packages/jsActions/nanoflow-actions-native/src/external/Share.ts deleted file mode 100644 index 8d6b88125..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/external/Share.ts +++ /dev/null @@ -1,72 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import ReactNative from "react-native"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Action to invoke the native sharing mechanism of the device. - * @param {string} url - The url to share. - * @param {string} text - The text to share. - * @param {string} title - Title of the message to share. Only some share targets use this value. - * @returns {Promise.} - */ -export async function Share(url?: string, text?: string, title?: string): Promise { - // BEGIN USER CODE - - if (!text && !url) { - return Promise.reject(new Error("It is required to provide at least one of input parameters 'Text' and 'Url'")); - } - - // Native platform - // Documentation https://facebook.github.io/react-native/docs/share - if (navigator && navigator.product === "ReactNative") { - const RNShare: typeof ReactNative.Share = require("react-native").Share; - - const content = - url && text ? { message: text + "\n" + url, title } : url ? { url, title } : { message: text!, title }; - - return RNShare.share(content).then(result => { - if (result.action === RNShare.dismissedAction) { - return false; - } - return true; - }); - } - - // Web platform - // Documentation https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share - if (navigator && navigator.share) { - return navigator.share({ url, text, title }).then(() => true); - } - - // Hybrid platform - // Documentation https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin - if (window && window.plugins && window.plugins.socialsharing) { - return new Promise((resolve, reject) => { - window!.plugins!.socialsharing!.shareWithOptions( - { - message: text, - subject: title, - url - }, - result => resolve(result.completed), - errorMessage => reject(new Error(errorMessage)) - ); - }); - } - - if (document && document.location && document.location.protocol === "http:") { - return Promise.reject(new Error("This action requires a secure https: connection")); - } - - return Promise.reject(new Error("This action is not supported by this browser")); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/geolocation/Geocode.ts b/packages/jsActions/nanoflow-actions-native/src/geolocation/Geocode.ts deleted file mode 100644 index 8b4a93a36..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/geolocation/Geocode.ts +++ /dev/null @@ -1,139 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import Geodecoder from "react-native-geocoder"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -type GeocodingProvider = "Google" | "Geocodio" | "LocationIQ" | "MapQuest"; - -/** - * Geocoding is the process of converting addresses (like a street address) into geographic coordinates (latitude and longitude), which you can use to place markers on a map, or position the map. - * @param {string} address - This field is required. - * @param {"NanoflowCommons.GeocodingProvider.Google"|"NanoflowCommons.GeocodingProvider.Geocodio"|"NanoflowCommons.GeocodingProvider.LocationIQ"|"NanoflowCommons.GeocodingProvider.MapQuest"} geocodingProvider - This field is required for use on web. - * @param {string} providerApiKey - This field is required for use on web. Note that the keys are accessible by the end users and should be protected in other ways; for example with a domain name restriction. - * @returns {Promise.} - */ -export async function Geocode( - address?: string, - geocodingProvider?: GeocodingProvider, - providerApiKey?: string -): Promise { - // BEGIN USER CODE - /** - * Documentation: - * - Native: https://github.com/devfd/react-native-geocoder - * - Google: https://developers.google.com/maps/documentation/geocoding/intro#GeocodingRequests - * - Geocodio: https://www.geocod.io/docs/#geocoding - * - LocationIQ: https://locationiq.com/docs-html/index.html#search-forward-geocoding - * - MapQuest: https://developer.mapquest.com/documentation/open/geocoding-api/address/get/ - */ - - if (!address) { - return Promise.reject(new Error("Input parameter 'Address' is required")); - } - - if (navigator && navigator.product === "ReactNative") { - return Geodecoder.geocodeAddress(address).then(results => { - if (results.length === 0) { - return Promise.reject(new Error("No results found")); - } - return createMxObject(String(results[0].position.lat), String(results[0].position.lng)); - }); - } - - if (!geocodingProvider) { - return Promise.reject(new Error("Input parameter 'Geocoding provider' is required for use on web")); - } - - if (!providerApiKey) { - return Promise.reject(new Error("Input parameter 'Provider api key' is required for use on web")); - } - - const url = getApiUrl(geocodingProvider, address, providerApiKey); - - return fetch(url) - .then(response => - response.json().catch(() => - response.text().then(text => { - return Promise.reject(new Error(text)); - }) - ) - ) - .then(response => getLatLong(geocodingProvider, response)) - .then(latLong => createMxObject(latLong[0], latLong[1])) - .catch(error => Promise.reject(error)); - - function getApiUrl(provider: GeocodingProvider, query: string, key: string): string { - query = encodeURIComponent(query); - key = encodeURIComponent(key); - - switch (provider) { - case "Google": - return `https://maps.googleapis.com/maps/api/geocode/json?address=${query}&key=${key}`; - case "Geocodio": - return `https://api.geocod.io/v1.3/geocode?q=${query}&api_key=${key}`; - case "LocationIQ": - return `https://eu1.locationiq.com/v1/search.php?format=json&q=${query}&key=${key}`; - case "MapQuest": - return `https://open.mapquestapi.com/geocoding/v1/address?location=${query}&key=${key}`; - } - } - - function getLatLong(provider: GeocodingProvider, response: any): [string, string] { - switch (provider) { - case "Google": - if (response.status !== "OK") { - throw new Error(response.error_message); - } - return [response.results[0].geometry.location.lat, response.results[0].geometry.location.lng]; - case "Geocodio": - if (response.error) { - throw new Error(response.error); - } - if (response.results.length === 0) { - throw new Error("No results found"); - } - return [response.results[0].location.lat, response.results[0].location.lng]; - case "LocationIQ": - if (response.error) { - throw new Error(response.error); - } - if (response.length === 0) { - throw new Error("No results found"); - } - return [response[0].lat, response[0].lon]; - case "MapQuest": - if (response.info.statuscode !== 0) { - throw new Error(response.info.messages.join(", ")); - } - if (response.results.length === 0) { - throw new Error("No results found"); - } - return [response.results[0].locations[0].latLng.lat, response.results[0].locations[0].latLng.lng]; - } - } - - function createMxObject(lat: string, long: string): Promise { - return new Promise((resolve, reject) => { - mx.data.create({ - entity: "NanoflowCommons.Position", - callback: mxObject => { - mxObject.set("Latitude", lat); - mxObject.set("Longitude", long); - resolve(mxObject); - }, - error: () => { - reject(new Error("Could not create 'NanoflowCommons.Position' object to store coordinates")); - } - }); - }); - } - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/geolocation/GetCurrentLocation.ts b/packages/jsActions/nanoflow-actions-native/src/geolocation/GetCurrentLocation.ts deleted file mode 100644 index e1689e6b3..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/geolocation/GetCurrentLocation.ts +++ /dev/null @@ -1,137 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Big } from "big.js"; -import Geolocation, { - GeolocationError, - GeolocationOptions, - GeolocationResponse, - GeolocationStatic -} from "@react-native-community/geolocation"; - -import type { Platform, NativeModules } from "react-native"; -import type { GeoError, GeoPosition, GeoOptions } from "../../typings/Geolocation"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * This action retrieves the current geographical position of a user/device. - * - * Since this can compromise privacy, the position is not available unless the user approves it. The web browser will request the permission at the first time the location is requested. When denied by the user it will not prompt a second time. - * - * On hybrid and native platforms the permission should be requested with the `RequestLocationPermission` action. - * - * Best practices: - * https://developers.google.com/web/fundamentals/native-hardware/user-location/ - * @param {Big} timeout - The maximum length of time (in milliseconds) the device is allowed to take in order to return a location. If empty, there is no timeout. - * @param {Big} maximumAge - The maximum age (in milliseconds) of a possible cached position that is acceptable to return. If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. By default the device will always return a cached position regardless of its age. - * @param {boolean} highAccuracy - Use a higher accuracy method to determine the current location. Setting this to false saves battery life. - * @returns {Promise.} - */ -export async function GetCurrentLocation( - timeout?: Big, - maximumAge?: Big, - highAccuracy?: boolean -): Promise { - // BEGIN USER CODE - - let reactNativeModule: { NativeModules: typeof NativeModules; Platform: typeof Platform } | undefined; - let geolocationModule: - | Geolocation - | GeolocationStatic - | typeof import("react-native-geolocation-service") - | undefined; - - if (navigator && navigator.product === "ReactNative") { - reactNativeModule = require("react-native"); - - if (!reactNativeModule) { - return Promise.reject(new Error("React Native module could not be found")); - } - - if (reactNativeModule.NativeModules.RNFusedLocation) { - geolocationModule = (await import("react-native-geolocation-service")).default; - } else if (reactNativeModule.NativeModules.RNCGeolocation) { - geolocationModule = Geolocation; - } else { - return Promise.reject(new Error("Geolocation module could not be found")); - } - } else if (navigator && navigator.geolocation) { - geolocationModule = navigator.geolocation; - } else { - return Promise.reject(new Error("Geolocation module could not be found")); - } - - return new Promise((resolve, reject) => { - const options = getOptions(); - geolocationModule?.getCurrentPosition(onSuccess, onError, options); - - function onSuccess(position: GeolocationResponse | GeoPosition): void { - mx.data.create({ - entity: "NanoflowCommons.Geolocation", - callback: mxObject => { - const geolocation = mapPositionToMxObject(mxObject, position); - resolve(geolocation); - }, - error: () => - reject(new Error("Could not create 'NanoflowCommons.Geolocation' object to store location")) - }); - } - - function onError(error: GeolocationError | GeoError): void { - return reject(new Error(error.message)); - } - - function getOptions(): GeolocationOptions | GeoOptions { - let timeoutNumber = timeout && Number(timeout.toString()); - const maximumAgeNumber = maximumAge && Number(maximumAge.toString()); - - // If the timeout is 0 or undefined (empty), it causes a crash on iOS. - // If the timeout is undefined (empty); we set timeout to 30 sec (default timeout) - // If the timeout is 0; we set timeout to 1 hour (no timeout) - if (reactNativeModule?.Platform.OS === "ios") { - if (timeoutNumber === undefined) { - timeoutNumber = 30000; - } else if (timeoutNumber === 0) { - timeoutNumber = 3600000; - } - } - - return { - timeout: timeoutNumber, - maximumAge: maximumAgeNumber, - enableHighAccuracy: highAccuracy - }; - } - - function mapPositionToMxObject( - mxObject: mendix.lib.MxObject, - position: GeolocationResponse | GeoPosition - ): mendix.lib.MxObject { - mxObject.set("Timestamp", new Date(position.timestamp)); - mxObject.set("Latitude", new Big(position.coords.latitude.toFixed(8))); - mxObject.set("Longitude", new Big(position.coords.longitude.toFixed(8))); - mxObject.set("Accuracy", new Big(position.coords.accuracy.toFixed(8))); - if (position.coords.altitude != null) { - mxObject.set("Altitude", new Big(position.coords.altitude.toFixed(8))); - } - if (position.coords.altitudeAccuracy != null && position.coords.altitudeAccuracy !== -1) { - mxObject.set("AltitudeAccuracy", new Big(position.coords.altitudeAccuracy.toFixed(8))); - } - if (position.coords.heading != null && position.coords.heading !== -1) { - mxObject.set("Heading", new Big(position.coords.heading.toFixed(8))); - } - if (position.coords.speed != null && position.coords.speed !== -1) { - mxObject.set("Speed", new Big(position.coords.speed.toFixed(8))); - } - return mxObject; - } - }); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/geolocation/GetCurrentLocationMinimumAccuracy.ts b/packages/jsActions/nanoflow-actions-native/src/geolocation/GetCurrentLocationMinimumAccuracy.ts deleted file mode 100644 index 3a1fa25c9..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/geolocation/GetCurrentLocationMinimumAccuracy.ts +++ /dev/null @@ -1,179 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Big } from "big.js"; -import Geolocation, { - GeolocationError, - GeolocationOptions, - GeolocationResponse, - GeolocationStatic -} from "@react-native-community/geolocation"; - -import type { Platform, NativeModules } from "react-native"; -import type { GeoError, GeoPosition, GeoOptions } from "../../typings/Geolocation"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * This action retrieves the current geographical position of a user/device with a minimum accuracy as parameter. If a position is not acquired with minimum accuracy within a specific timeout it will retrieve the last most precise location. - * - * Since this can compromise privacy, the position is not available unless the user approves it. The web browser will request the permission at the first time the location is requested. When denied by the user it will not prompt a second time. - * - * On hybrid and native platforms the permission should be requested with the `RequestLocationPermission` action. - * - * For good user experience, disable the nanoflow during action using property `Disabled during action` if you’re using `Call a nanoflow button` to run JS Action `Get current location with minimum accuracy`. - * - * Best practices: - * https://developers.google.com/web/fundamentals/native-hardware/user-location/ - * @param {Big} timeout - The maximum length of time (in milliseconds) the device is allowed to take in order to return a location. If empty, there is no timeout. - * @param {Big} maximumAge - The maximum age (in milliseconds) of a possible cached position that is acceptable to return. If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. By default the device will always return a cached position regardless of its age. - * @param {boolean} highAccuracy - Use a higher accuracy method to determine the current location. Setting this to false saves battery life. - * @param {Big} minimumAccuracy - The minimum accuracy to be received in meters. Less amount of meters, more precise is the location. - * @returns {Promise.} - */ -export async function GetCurrentLocationMinimumAccuracy( - timeout?: Big, - maximumAge?: Big, - highAccuracy?: boolean, - minimumAccuracy?: number -): Promise { - // BEGIN USER CODE - - let reactNativeModule: { NativeModules: typeof NativeModules; Platform: typeof Platform } | undefined; - let geolocationModule: - | Geolocation - | GeolocationStatic - | typeof import("react-native-geolocation-service") - | undefined; - - if (navigator && navigator.product === "ReactNative") { - reactNativeModule = require("react-native"); - - if (!reactNativeModule) { - return Promise.reject(new Error("React Native module could not be found")); - } - - if (reactNativeModule.NativeModules.RNFusedLocation) { - geolocationModule = (await import("react-native-geolocation-service")).default; - } else if (reactNativeModule.NativeModules.RNCGeolocation) { - geolocationModule = Geolocation; - } else { - return Promise.reject(new Error("Geolocation module could not be found")); - } - } else if (navigator && navigator.geolocation) { - geolocationModule = navigator.geolocation; - } else { - return Promise.reject(new Error("Geolocation module could not be found")); - } - - return new Promise((resolve, reject) => { - if (!geolocationModule) { - return reject(new Error("Geolocation module could not be found")); - } - - const options = getOptions(); - - // This action is only required while running in PWA or hybrid. - if (navigator && (!navigator.product || navigator.product !== "ReactNative")) { - // This ensures the browser will not ignore the maximumAge https://stackoverflow.com/questions/3397585/navigator-geolocation-getcurrentposition-sometimes-works-sometimes-doesnt/31916631#31916631 - geolocationModule.getCurrentPosition( - // eslint-disable-next-line @typescript-eslint/no-empty-function - () => {}, - // eslint-disable-next-line @typescript-eslint/no-empty-function - () => {}, - {} - ); - } - - const timeoutId = setTimeout(onTimeout, Number(timeout)); - const watchId: number = geolocationModule.watchPosition(onSuccess, onError, options); - let lastAccruedPosition: GeolocationResponse | GeoPosition; - - function createGeolocationObject(position: GeolocationResponse | GeoPosition): void { - mx.data.create({ - entity: "NanoflowCommons.Geolocation", - callback: mxObject => resolve(mapPositionToMxObject(mxObject, position)), - error: () => - reject(new Error("Could not create 'NanoflowCommons.Geolocation' object to store location")) - }); - } - - function onTimeout(): void { - geolocationModule?.clearWatch(watchId); - - if (lastAccruedPosition) { - createGeolocationObject(lastAccruedPosition); - } else { - reject(new Error("Timeout expired")); - } - } - - function onSuccess(position: GeolocationResponse | GeoPosition): void { - if (!minimumAccuracy || Number(minimumAccuracy) >= position.coords.accuracy) { - clearTimeout(timeoutId); - geolocationModule?.clearWatch(watchId); - createGeolocationObject(position); - } else { - if (!lastAccruedPosition || position.coords.accuracy < lastAccruedPosition.coords.accuracy) { - lastAccruedPosition = position; - } - } - } - - function onError(error: GeolocationError | GeoError): void { - return reject(new Error(error.message)); - } - - function getOptions(): GeolocationOptions | GeoOptions { - let timeoutNumber = timeout && Number(timeout.toString()); - const maximumAgeNumber = maximumAge && Number(maximumAge.toString()); - - // If the timeout is 0 or undefined (empty), it causes a crash on iOS. - // If the timeout is undefined (empty); we set timeout to 30 sec (default timeout) - // If the timeout is 0; we set timeout to 1 hour (no timeout) - if (reactNativeModule?.Platform.OS === "ios") { - if (timeoutNumber === undefined) { - timeoutNumber = 30000; - } else if (timeoutNumber === 0) { - timeoutNumber = 3600000; - } - } - - return { - timeout: timeoutNumber, - maximumAge: maximumAgeNumber, - enableHighAccuracy: highAccuracy - }; - } - - function mapPositionToMxObject( - mxObject: mendix.lib.MxObject, - position: GeolocationResponse | GeoPosition - ): mendix.lib.MxObject { - mxObject.set("Timestamp", new Date(position.timestamp)); - mxObject.set("Latitude", new Big(position.coords.latitude.toFixed(8))); - mxObject.set("Longitude", new Big(position.coords.longitude.toFixed(8))); - mxObject.set("Accuracy", new Big(position.coords.accuracy.toFixed(8))); - if (position.coords.altitude != null) { - mxObject.set("Altitude", new Big(position.coords.altitude.toFixed(8))); - } - if (position.coords.altitudeAccuracy != null && position.coords.altitudeAccuracy !== -1) { - mxObject.set("AltitudeAccuracy", new Big(position.coords.altitudeAccuracy.toFixed(8))); - } - if (position.coords.heading != null && position.coords.heading !== -1) { - mxObject.set("Heading", new Big(position.coords.heading.toFixed(8))); - } - if (position.coords.speed != null && position.coords.speed !== -1) { - mxObject.set("Speed", new Big(position.coords.speed.toFixed(8))); - } - return mxObject; - } - }); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/geolocation/GetStraightLineDistance.ts b/packages/jsActions/nanoflow-actions-native/src/geolocation/GetStraightLineDistance.ts deleted file mode 100644 index a013cb54f..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/geolocation/GetStraightLineDistance.ts +++ /dev/null @@ -1,74 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Big } from "big.js"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -type DistanceUnit = "KILOMETER" | "STATUTE_MILE" | "NAUTICAL_MILE"; - -// BEGIN EXTRA CODE - -function deg2rad(deg: Big): Big { - return deg.times(Math.PI / 180); -} - -function kmToStatueMile(km: Big): Big { - return km.div(1.609344); -} - -function kmToNauticalMile(km: Big): Big { - return km.div(1.852); -} - -// END EXTRA CODE - -/** - * latitudePoint1, longitudePoint1, latitudePoint2, longitudePoint2 - * @param {Big} latitudePoint1 - * @param {Big} longitudePoint1 - * @param {Big} latitudePoint2 - * @param {Big} longitudePoint2 - * @param {"KILOMETER"|"STATUTE_MILE"|"NAUTICAL_MILE"} [unit="KILOMETER"] - unit of measure - * @returns {Promise.} - */ -export async function GetStraightLineDistance( - latitudePoint1: Big, - longitudePoint1: Big, - latitudePoint2: Big, - longitudePoint2: Big, - unit = "KILOMETER" as DistanceUnit -): Promise { - // BEGIN USER CODE - const R = 6371; // Radius of the earth in km - const dLat: number = deg2rad(latitudePoint2.minus(latitudePoint1)).toNumber(); - const dLon: number = deg2rad(longitudePoint2.minus(longitudePoint1)).toNumber(); - const a: number = - Math.sin(dLat / 2) * Math.sin(dLat / 2) + - Math.cos(deg2rad(latitudePoint1).toNumber()) * - Math.cos(deg2rad(latitudePoint2).toNumber()) * - Math.sin(dLon / 2) * - Math.sin(dLon / 2); - const c: number = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - const d: Big = new Big(R * c); // Distance in km - - switch (unit) { - case "KILOMETER": { - return d; - } - case "STATUTE_MILE": { - return kmToStatueMile(d); - } - case "NAUTICAL_MILE": { - return kmToNauticalMile(d); - } - default: - throw new Error(`Unknown unit: ${unit}`); - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/geolocation/RequestLocationPermission.ts b/packages/jsActions/nanoflow-actions-native/src/geolocation/RequestLocationPermission.ts deleted file mode 100644 index 4eb3ddf4c..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/geolocation/RequestLocationPermission.ts +++ /dev/null @@ -1,160 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import Geolocation, { GeolocationStatic } from "@react-native-community/geolocation"; - -import type { GeolocationServiceStatic, AuthorizationResult } from "../../typings/Geolocation"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * On the native platform a request for permission should be made before the `GetCurrentLocation` action would work. - * @returns {Promise.} - */ -export async function RequestLocationPermission(): Promise { - // BEGIN USER CODE - - let reactNativeModule: typeof import("react-native") | undefined; - let geolocationModule: - | Geolocation - | GeolocationStatic - | typeof import("react-native-geolocation-service") - | undefined; - - const hasPermissionIOS = async (): Promise => { - const openSetting = (): void => { - reactNativeModule?.Linking.openSettings().catch(() => { - reactNativeModule?.Alert.alert("Unable to open settings."); - }); - }; - - return (geolocationModule as GeolocationServiceStatic) - .requestAuthorization("whenInUse") - .then((status: AuthorizationResult) => { - if (status === "granted") { - return true; - } - - if (status === "denied") { - reactNativeModule?.Alert.alert("Location permission denied."); - } - - if (status === "disabled") { - reactNativeModule?.Alert.alert( - "Location Services must be enabled to determine your location.", - "", - [ - { text: "Go to Settings", onPress: openSetting }, - { - text: "Don't Use Location" - } - ] - ); - } - - return false; - }); - }; - - const hasPermissionAndroid = async (): Promise => { - if (typeof reactNativeModule?.Platform?.Version === "number" && reactNativeModule?.Platform?.Version < 23) { - return true; - } - - const androidLocationPermission = reactNativeModule?.PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION; - - if (!androidLocationPermission) { - return false; - } - - return reactNativeModule?.PermissionsAndroid.check(androidLocationPermission).then(hasPermission => - hasPermission - ? true - : reactNativeModule?.PermissionsAndroid?.request(androidLocationPermission).then(status => { - if (status === reactNativeModule?.PermissionsAndroid.RESULTS.GRANTED) { - return true; - } - - if (status === reactNativeModule?.PermissionsAndroid.RESULTS.DENIED) { - reactNativeModule.ToastAndroid.show( - "Location permission denied by user.", - reactNativeModule.ToastAndroid.LONG - ); - } else if (status === reactNativeModule?.PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN) { - reactNativeModule.ToastAndroid.show( - "Location permission revoked by user.", - reactNativeModule.ToastAndroid.LONG - ); - } - - return false; - }) - ); - }; - - const hasLocationPermission = async (): Promise => { - if (reactNativeModule?.Platform.OS === "ios") { - const hasPermission = await hasPermissionIOS(); - return hasPermission; - } - - if (reactNativeModule?.Platform.OS === "android") { - const hasPermission = await hasPermissionAndroid(); - return hasPermission ?? false; - } - - return Promise.reject(new Error("Unsupported platform")); - }; - - const hasLocationPermissionForOldLibrary = async (): Promise => { - if (reactNativeModule?.Platform.OS === "android") { - const locationPermission = reactNativeModule.PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION; - - return reactNativeModule.PermissionsAndroid.check(locationPermission).then(hasPermission => - hasPermission - ? true - : reactNativeModule?.PermissionsAndroid.request(locationPermission).then( - status => status === reactNativeModule?.PermissionsAndroid.RESULTS.GRANTED - ) - ); - } else if (geolocationModule && (geolocationModule as GeolocationStatic).requestAuthorization) { - try { - (geolocationModule as GeolocationStatic).requestAuthorization(); - return Promise.resolve(true); - } catch (error) { - return Promise.reject(error); - } - } - - return false; - }; - - if (navigator && navigator.product === "ReactNative") { - reactNativeModule = require("react-native"); - - if (!reactNativeModule) { - return Promise.reject(new Error("React Native module could not be found")); - } - - if (reactNativeModule.NativeModules.RNFusedLocation) { - geolocationModule = (await import("react-native-geolocation-service")).default; - return hasLocationPermission(); - } else if (reactNativeModule.NativeModules.RNCGeolocation) { - geolocationModule = Geolocation; - return (await hasLocationPermissionForOldLibrary()) ?? false; - } else { - return Promise.reject(new Error("Geolocation module could not be found")); - } - } else if (navigator && navigator.geolocation) { - return Promise.reject(new Error("No permission request for location is required for web/hybrid platform")); - } else { - return Promise.reject(new Error("Geolocation module could not be found")); - } - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/geolocation/ReverseGeocode.ts b/packages/jsActions/nanoflow-actions-native/src/geolocation/ReverseGeocode.ts deleted file mode 100644 index 1b6a25d9f..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/geolocation/ReverseGeocode.ts +++ /dev/null @@ -1,131 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import Geodecoder from "react-native-geocoder"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -type ReverseGeocodingProvider = "Google" | "Geocodio" | "LocationIQ" | "MapQuest"; - -/** - * Reverse geocoding is the process of converting geographic coordinates (latitude and longitude) into a human-readable address. - * @param {string} latitude - This field is required. - * @param {string} longitude - This field is required. - * @param {"NanoflowCommons.GeocodingProvider.Google"|"NanoflowCommons.GeocodingProvider.Geocodio"|"NanoflowCommons.GeocodingProvider.LocationIQ"|"NanoflowCommons.GeocodingProvider.MapQuest"} geocodingProvider - This field is required for use on web. - * @param {string} providerApiKey - This field is required for use on web. Note that the keys are accessible by the end users and should be protected in other ways; for example restricted domain name. - * @returns {Promise.} - */ -export async function ReverseGeocode( - latitude?: string, - longitude?: string, - geocodingProvider?: ReverseGeocodingProvider, - providerApiKey?: string -): Promise { - // BEGIN USER CODE - /** - * Documentation: - * - Native: https://github.com/devfd/react-native-geocoder - * - Google: https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding - * - Geocodio: https://www.geocod.io/docs/#reverse-geocoding - * - LocationIQ: https://locationiq.com/docs-html/index.html#reverse-geocoding - * - MapQuest: https://developer.mapquest.com/documentation/open/geocoding-api/address/get/ - */ - - if (!latitude) { - return Promise.reject(new Error("Input parameter 'Latitude' is required")); - } - - if (!longitude) { - return Promise.reject(new Error("Input parameter 'Longitude' is required")); - } - - if (navigator && navigator.product === "ReactNative") { - const position = { lat: Number(latitude), lng: Number(longitude) }; - - return Geodecoder.geocodePosition(position).then(results => { - if (results.length === 0) { - return Promise.reject(new Error("No results found")); - } - return results[0].formattedAddress; - }); - } - - if (!geocodingProvider) { - return Promise.reject(new Error("Input parameter 'Geocoding provider' is required for use on web")); - } - - if (!providerApiKey) { - return Promise.reject(new Error("Input parameter 'Provider api key' is required for use on web")); - } - - latitude = encodeURIComponent(latitude); - longitude = encodeURIComponent(longitude); - providerApiKey = encodeURIComponent(providerApiKey); - - const url = getApiUrl(geocodingProvider, latitude, longitude, providerApiKey); - - return fetch(url) - .then(response => - response.json().catch(() => - response.text().then(text => { - return Promise.reject(new Error(text)); - }) - ) - ) - .then(response => getAddress(geocodingProvider, response)) - .catch(error => Promise.reject(error)); - - function getApiUrl(provider: ReverseGeocodingProvider, lat: string, long: string, key: string): string { - switch (provider) { - case "Google": - return `https://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${long}&key=${key}`; - case "Geocodio": - return `https://api.geocod.io/v1.3/reverse?q=${lat},${long}&api_key=${key}`; - case "LocationIQ": - return `https://eu1.locationiq.com/v1/reverse.php?format=json&lat=${lat}&lon=${long}&key=${key}`; - case "MapQuest": - return `https://www.mapquestapi.com/geocoding/v1/reverse?location=${lat},${long}&key=${key}`; - } - } - - function getAddress(provider: ReverseGeocodingProvider, response: any): string { - switch (provider) { - case "Google": - if (response.status !== "OK") { - throw new Error(response.error_message); - } - return response.results[0].formatted_address; - case "Geocodio": - if (response.error) { - throw new Error(response.error); - } - if (response.results.length === 0) { - throw new Error("No results found"); - } - return response.results[0].formatted_address; - case "LocationIQ": - if (response.error) { - throw new Error(response.error); - } - return response.display_name; - case "MapQuest": - if (response.info.statuscode !== 0) { - throw new Error(response.info.messages.join(", ")); - } - if (response.results.length === 0) { - throw new Error("No results found"); - } - const location = response.results[0].locations[0]; - const city = location.adminArea5; - const country = location.adminArea1; - return `${location.street}, ${location.postalCode} ${city}, ${country}`; - } - } - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/local-storage/ClearCachedSessionData.ts b/packages/jsActions/nanoflow-actions-native/src/local-storage/ClearCachedSessionData.ts deleted file mode 100644 index 01d92750a..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/local-storage/ClearCachedSessionData.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @returns {Promise.} - */ -export async function ClearCachedSessionData(): Promise { - // BEGIN USER CODE - if (mx.session && mx.session.clearCachedSessionData === undefined) { - return Promise.reject( - new Error("JS action 'Clear cached session data' is not supported prior to Mendix client v9.14") - ); - } - - await mx.session.clearCachedSessionData(); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/local-storage/ClearLocalStorage.ts b/packages/jsActions/nanoflow-actions-native/src/local-storage/ClearLocalStorage.ts deleted file mode 100644 index 96ccc9d75..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/local-storage/ClearLocalStorage.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @returns {Promise.} - */ -export async function ClearLocalStorage(): Promise { - // BEGIN USER CODE - try { - localStorage.clear(); - return true; - } catch (e) { - console.error(e); - return false; - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemObject.ts b/packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemObject.ts deleted file mode 100644 index 55ade942d..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemObject.ts +++ /dev/null @@ -1,117 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import AsyncStorage from "@react-native-community/async-storage"; -import { StorageValue } from "../../typings/StorageValue"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Retrieve a local stored Mendix object identified by a unique key. When object is the client state it will be returned, if not it will be re-created. Note: when re-creating the local mendix object the Mendix Object ID will never be the same. - * @param {string} key - This field is required. - * @param {string} entity - This field is required. - * @returns {Promise.} - */ -export async function GetStorageItemObject(key?: string, entity?: string): Promise { - // BEGIN USER CODE - - if (!key) { - return Promise.reject(new Error("Input parameter 'Key' is required")); - } - - if (!entity) { - return Promise.reject(new Error("Input parameter 'Entity' is required")); - } - - return getItem(key).then(result => { - if (result === null) { - return Promise.reject(new Error(`Storage item '${key}' does not exist`)); - } - const value: StorageValue = JSON.parse(result); - - return getOrCreateMxObject(entity, value).then(newObject => { - const newValue = serializeMxObject(newObject); - return setItem(key, JSON.stringify(newValue)).then(() => newObject); - }); - }); - - function getItem(key: string): Promise { - if (navigator && navigator.product === "ReactNative") { - return AsyncStorage.getItem(key); - } - - if (window) { - const value = window.localStorage.getItem(key); - return Promise.resolve(value); - } - - return Promise.reject(new Error("No storage API available")); - } - - function setItem(key: string, value: string): Promise { - if (navigator && navigator.product === "ReactNative") { - return AsyncStorage.setItem(key, value); - } - - if (window) { - window.localStorage.setItem(key, value); - return Promise.resolve(); - } - - return Promise.reject(new Error("No storage API available")); - } - - function getOrCreateMxObject(entity: string, value: StorageValue): Promise { - return getMxObject(value.guid).then(existingObject => { - if (existingObject) { - return existingObject; - } else { - return createMxObject(entity, value); - } - }); - } - - function getMxObject(guid: string): Promise { - return new Promise((resolve, reject) => { - mx.data.get({ - guid, - callback: mxObject => resolve(mxObject), - error: error => reject(error) - }); - }); - } - - function createMxObject(entity: string, value: StorageValue): Promise { - return new Promise((resolve, reject) => { - mx.data.create({ - entity, - callback: mxObject => { - Object.keys(value) - .filter(attribute => attribute !== "guid") - .forEach(attributeName => { - const attributeValue = value[attributeName]; - mxObject.set(attributeName, attributeValue); - }); - resolve(mxObject); - }, - error: () => reject(new Error(`Could not create '${entity}' object`)) - }); - }); - } - - function serializeMxObject(object: mendix.lib.MxObject): StorageValue { - return object.getAttributes().reduce( - (accumulator, attributeName) => { - accumulator[attributeName] = object.get(attributeName); - return accumulator; - }, - { guid: object.getGuid() } - ); - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemObjectList.ts b/packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemObjectList.ts deleted file mode 100644 index 5701fb2d9..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemObjectList.ts +++ /dev/null @@ -1,115 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import AsyncStorage from "@react-native-community/async-storage"; -import { StorageValue } from "../../typings/StorageValue"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Retrieve a local stored list of Mendix objects identified by a unique key. When objects are the client state it will be returned, if not they will be re-created. Note: when re-creating the local Mendix object the Mendix Object ID will never be the same. - * @returns {Promise.} - */ -export async function GetStorageItemObjectList(key?: string, entity?: string): Promise { - // BEGIN USER CODE - - if (!key) { - return Promise.reject(new Error("Input parameter 'Key' is required")); - } - - if (!entity) { - return Promise.reject(new Error("Input parameter 'Entity' is required")); - } - - return getItem(key).then(result => { - if (result === null) { - return Promise.reject(new Error(`Storage item '${key}' does not exist`)); - } - const values: StorageValue[] = JSON.parse(result); - - return Promise.all(values.map(value => getOrCreateMxObject(entity, value))).then(newObjects => { - const newValues = newObjects.map(newObject => serializeMxObject(newObject)); - return setItem(key, JSON.stringify(newValues)).then(() => newObjects); - }); - }); - - function getItem(key: string): Promise { - if (navigator && navigator.product === "ReactNative") { - return AsyncStorage.getItem(key); - } - - if (window) { - const value = window.localStorage.getItem(key); - return Promise.resolve(value); - } - - return Promise.reject(new Error("No storage API available")); - } - - function setItem(key: string, value: string): Promise { - if (navigator && navigator.product === "ReactNative") { - return AsyncStorage.setItem(key, value); - } - - if (window) { - window.localStorage.setItem(key, value); - return Promise.resolve(); - } - - return Promise.reject(new Error("No storage API available")); - } - - function getOrCreateMxObject(entity: string, value: StorageValue): Promise { - return getMxObject(value.guid).then(existingObject => { - if (existingObject) { - return existingObject; - } else { - return createMxObject(entity, value); - } - }); - } - - function getMxObject(guid: string): Promise { - return new Promise((resolve, reject) => { - mx.data.get({ - guid, - callback: mxObject => resolve(mxObject), - error: error => reject(error) - }); - }); - } - - function createMxObject(entity: string, value: StorageValue): Promise { - return new Promise((resolve, reject) => { - mx.data.create({ - entity, - callback: mxObject => { - Object.keys(value) - .filter(attribute => attribute !== "guid") - .forEach(attributeName => { - const attributeValue = value[attributeName]; - mxObject.set(attributeName, attributeValue); - }); - resolve(mxObject); - }, - error: () => reject(new Error(`Could not create '${entity}' object`)) - }); - }); - } - - function serializeMxObject(object: mendix.lib.MxObject): StorageValue { - return object.getAttributes().reduce( - (accumulator, attributeName) => { - accumulator[attributeName] = object.get(attributeName); - return accumulator; - }, - { guid: object.getGuid() } - ); - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemString.ts b/packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemString.ts deleted file mode 100644 index 230906431..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/local-storage/GetStorageItemString.ts +++ /dev/null @@ -1,46 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import AsyncStorage from "@react-native-community/async-storage"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Retrieve a local stored string value identified by a unique key. This could be set via the SetStorageItemString JavaScript action. - * @param {string} key - This field is required. - * @returns {Promise.} - */ -export async function GetStorageItemString(key?: string): Promise { - // BEGIN USER CODE - - if (!key) { - return Promise.reject(new Error("Input parameter 'Key' is required")); - } - - return getItem(key).then(result => { - if (result === null) { - return Promise.reject(new Error(`Storage item '${key}' does not exist`)); - } - return result; - }); - - async function getItem(key: string): Promise { - if (navigator && navigator.product === "ReactNative") { - return AsyncStorage.getItem(key); - } - - if (window) { - const value = window.localStorage.getItem(key); - return Promise.resolve(value); - } - - return Promise.reject(new Error("No storage API available")); - } - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/local-storage/RemoveStorageItem.ts b/packages/jsActions/nanoflow-actions-native/src/local-storage/RemoveStorageItem.ts deleted file mode 100644 index 56c44b81d..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/local-storage/RemoveStorageItem.ts +++ /dev/null @@ -1,39 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import AsyncStorage from "@react-native-community/async-storage"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Remove a content identified by a unique key. This could be set via any of the Set Storage Item JavaScript actions. - * @returns {Promise.} - */ -export async function RemoveStorageItem(key?: string): Promise { - // BEGIN USER CODE - - if (!key) { - return Promise.reject(new Error("Input parameter 'Key' is required")); - } - - return removeItem(key).then(() => true); - - function removeItem(key: string): Promise { - if (navigator && navigator.product === "ReactNative") { - return AsyncStorage.removeItem(key); - } - - if (window) { - window.localStorage.removeItem(key); - return Promise.resolve(); - } - - return Promise.reject(new Error("No storage API available")); - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemObject.ts b/packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemObject.ts deleted file mode 100644 index d74ac076c..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemObject.ts +++ /dev/null @@ -1,58 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import AsyncStorage from "@react-native-community/async-storage"; -import { StorageValue } from "../../typings/StorageValue"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Store a Mendix object in device storage, identified by a unique key. Can be accessed by the GetStorageItemObject action. Please note that users can clear the device storage. - * @param {string} key - This field is required. - * @param {MxObject} value - This field is required. - * @returns {Promise.} - */ -export async function SetStorageItemObject(key?: string, value?: mendix.lib.MxObject): Promise { - // BEGIN USER CODE - - if (!key) { - return Promise.reject(new Error("Input parameter 'Key' is required")); - } - - if (!value) { - return Promise.reject(new Error("Input parameter 'Value' is required")); - } - - const serializedObject = serializeMxObject(value); - - return setItem(key, JSON.stringify(serializedObject)); - - function setItem(key: string, value: string): Promise { - if (navigator && navigator.product === "ReactNative") { - return AsyncStorage.setItem(key, value); - } - - if (window) { - window.localStorage.setItem(key, value); - return Promise.resolve(); - } - - return Promise.reject(new Error("No storage API available")); - } - - function serializeMxObject(object: mendix.lib.MxObject): StorageValue { - return object.getAttributes().reduce( - (accumulator, attributeName) => { - accumulator[attributeName] = object.get(attributeName); - return accumulator; - }, - { guid: object.getGuid() } - ); - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemObjectList.ts b/packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemObjectList.ts deleted file mode 100644 index 179865438..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemObjectList.ts +++ /dev/null @@ -1,58 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import AsyncStorage from "@react-native-community/async-storage"; -import { StorageValue } from "../../typings/StorageValue"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Store a list of Mendix objects in device storage, identified by a unique key. Can be accessed by the GetStorageItemObject action. Please note that users can clear the device storage. - * @param {string} key - This field is required. - * @param {MxObject[]} value - This field is required. - * @returns {Promise.} - */ -export async function SetStorageItemObjectList(key?: string, value?: mendix.lib.MxObject[]): Promise { - // BEGIN USER CODE - - if (!key) { - return Promise.reject(new Error("Input parameter 'Key' is required")); - } - - if (!value) { - return Promise.reject(new Error("Input parameter 'Value' is required")); - } - - const serializedObjects = value.map(serializeMxObject); - - return setItem(key, JSON.stringify(serializedObjects)); - - function setItem(key: string, value: string): Promise { - if (navigator && navigator.product === "ReactNative") { - return AsyncStorage.setItem(key, value); - } - - if (window) { - window.localStorage.setItem(key, value); - return Promise.resolve(); - } - - return Promise.reject(new Error("No storage API available")); - } - - function serializeMxObject(object: mendix.lib.MxObject): StorageValue { - return object.getAttributes().reduce( - (accumulator, attributeName) => { - accumulator[attributeName] = object.get(attributeName); - return accumulator; - }, - { guid: object.getGuid() } - ); - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemString.ts b/packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemString.ts deleted file mode 100644 index a9669ab53..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/local-storage/SetStorageItemString.ts +++ /dev/null @@ -1,45 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import AsyncStorage from "@react-native-community/async-storage"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Store a string value in the device storage, identified by a unique key. Can be accessed by the GetStorageItemObject action. Please note that users can clear the device storage. - * @param {string} key - This field is required. - * @param {string} value - This field is required. - * @returns {Promise.} - */ -export async function SetStorageItemString(key?: string, value?: string): Promise { - // BEGIN USER CODE - - if (!key) { - return Promise.reject(new Error("Input parameter 'Key' is required")); - } - - if (!value) { - return Promise.reject(new Error("Input parameter 'Value' is required")); - } - - return setItem(key, value); - - function setItem(key: string, value: string): Promise { - if (navigator && navigator.product === "ReactNative") { - return AsyncStorage.setItem(key, value); - } - - if (window) { - window.localStorage.setItem(key, value); - return Promise.resolve(); - } - - return Promise.reject(new Error("No storage API available")); - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/local-storage/StorageItemExists.ts b/packages/jsActions/nanoflow-actions-native/src/local-storage/StorageItemExists.ts deleted file mode 100644 index d7468790e..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/local-storage/StorageItemExists.ts +++ /dev/null @@ -1,40 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import AsyncStorage from "@react-native-community/async-storage"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Check if an item exists in a device storage, identified by a unique key. The value could be set by a Set Storage Item action. - * @param {string} key - This field is required. - * @returns {Promise.} - */ -export async function StorageItemExists(key?: string): Promise { - // BEGIN USER CODE - - if (!key) { - return Promise.reject(new Error("Input parameter 'Key' is required")); - } - - return getItem(key).then(result => result !== null); - - function getItem(key: string): Promise { - if (navigator && navigator.product === "ReactNative") { - return AsyncStorage.getItem(key); - } - - if (window) { - const value = window.localStorage.getItem(key); - return Promise.resolve(value); - } - - return Promise.reject(new Error("No storage API available")); - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/other/Base64Decode.ts b/packages/jsActions/nanoflow-actions-native/src/other/Base64Decode.ts deleted file mode 100644 index 4012998bb..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/other/Base64Decode.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Base64 } from "js-base64"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @param {string} base64 - * @returns {Promise.} - */ -export async function Base64Decode(base64: string): Promise { - // BEGIN USER CODE - return Base64.decode(base64); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/other/Base64DecodeToImage.ts b/packages/jsActions/nanoflow-actions-native/src/other/Base64DecodeToImage.ts deleted file mode 100644 index f7243f73d..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/other/Base64DecodeToImage.ts +++ /dev/null @@ -1,36 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Base64 } from "js-base64"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * This JS Action takes a base64 String and a System.Image, decodes the base64 String and stores the resulting image in the System.Image object - * @param {string} base64 - * @param {MxObject} image - * @returns {Promise.} - */ -export function Base64DecodeToImage(base64: string, image: mendix.lib.MxObject): Promise { - // BEGIN USER CODE - - if (!base64) { - throw new Error("base64 String should not be empty"); - } - if (!image) { - throw new Error("image should not be null"); - } - - const blob = new Blob([Base64.toUint8Array(base64)], { type: "image/png" }); - - return new Promise((resolve, reject) => { - mx.data.saveDocument(image.getGuid(), "camera image", {}, blob, () => resolve(true), reject); - }); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/other/Base64Encode.ts b/packages/jsActions/nanoflow-actions-native/src/other/Base64Encode.ts deleted file mode 100644 index aa86184df..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/other/Base64Encode.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Base64 } from "js-base64"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @param {string} string - * @returns {Promise.} - */ -export async function Base64Encode(string: string): Promise { - // BEGIN USER CODE - return Base64.encode(string); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/other/FindObjectWithGUID.ts b/packages/jsActions/nanoflow-actions-native/src/other/FindObjectWithGUID.ts deleted file mode 100644 index 8c97c3172..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/other/FindObjectWithGUID.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * @param {MxObject[]} list - * @param {string} objectGUID - * @returns {Promise.} - */ -export async function FindObjectWithGUID( - list: mendix.lib.MxObject[], - objectGUID: string -): Promise { - // BEGIN USER CODE - - return list.find(element => element.getGuid() === objectGUID); - - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/other/GenerateUniqueID.ts b/packages/jsActions/nanoflow-actions-native/src/other/GenerateUniqueID.ts deleted file mode 100644 index 20d46fa7b..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/other/GenerateUniqueID.ts +++ /dev/null @@ -1,73 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -const COUNTER_STORE = "idCounter"; -let locked = false; -let currentCounter: number; - -function sleep(time: number): Promise { - return new Promise(resolve => setTimeout(resolve, time)); -} - -async function initializeCounter(): Promise { - currentCounter = JSON.parse((await getItem(COUNTER_STORE)) || "-1"); -} - -async function getItem(key: string): Promise { - if (navigator && navigator.product === "ReactNative") { - const AsyncStorage = (await import("@react-native-community/async-storage")).default; - return AsyncStorage.getItem(key); - } - if (window) { - return window.localStorage.getItem(key); - } - - throw new Error("No storage API available"); -} -async function setItem(key: string, value: string): Promise { - if (navigator && navigator.product === "ReactNative") { - const AsyncStorage = (await import("@react-native-community/async-storage")).default; - return AsyncStorage.setItem(key, value); - } - if (window) { - return window.localStorage.setItem(key, value); - } - - throw new Error("No storage API available"); -} -// END EXTRA CODE - -/** - * Generates a unique ID based on the current session. - * @returns {Promise.} - */ -export async function GenerateUniqueID(): Promise { - // BEGIN USER CODE - - const sessionId = mx.session.getConfig("sessionObjectId"); - const rnd = Math.round(Math.random() * 10000); - - // eslint-disable-next-line no-unmodified-loop-condition - while (locked) { - await sleep(10); - } - - locked = true; - - if (typeof currentCounter === "undefined") { - await initializeCounter(); - } - - await setItem(COUNTER_STORE, JSON.stringify(++currentCounter)); - - locked = false; - - return `${sessionId}:${currentCounter}:${rnd}`; - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/other/GetGuid.ts b/packages/jsActions/nanoflow-actions-native/src/other/GetGuid.ts deleted file mode 100644 index b445104a8..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/other/GetGuid.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Get the Mendix Object GUID. - * @param {MxObject} entityObject - This field is required. - * @returns {Promise.} - */ -export async function GetGuid(entityObject: mendix.lib.MxObject): Promise { - // BEGIN USER CODE - if (!entityObject) { - return Promise.reject(new Error("Input parameter 'Entity object' is required.")); - } - - return Promise.resolve(entityObject.getGuid()); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/other/GetObjectByGuid.ts b/packages/jsActions/nanoflow-actions-native/src/other/GetObjectByGuid.ts deleted file mode 100644 index e83cf6115..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/other/GetObjectByGuid.ts +++ /dev/null @@ -1,41 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Get a Mendix object by its GUID. - * @param {string} entity - This field is required. - * @param {string} objectGuid - This field is required. - * @returns {Promise.} - */ -export async function GetObjectByGuid(entity: string, objectGuid: string): Promise { - // BEGIN USER CODE - if (!entity) { - return Promise.reject(new Error("Input parameter 'Entity' is required.")); - } - - if (!objectGuid) { - return Promise.reject(new Error("Input parameter 'Object guid' is required.")); - } - - return new Promise((resolve, reject) => { - mx.data.get({ - guid: objectGuid, - callback: object => { - if (object) { - resolve(object); - } else { - reject(new Error("'Object guid' not found")); - } - } - }); - }); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/other/GetPlatform.ts b/packages/jsActions/nanoflow-actions-native/src/other/GetPlatform.ts deleted file mode 100644 index 13a736f06..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/other/GetPlatform.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. - -// BEGIN EXTRA CODE -// END EXTRA CODE - -type Platform = "Web" | "Native_mobile" | "Hybrid_mobile"; - -/** - * Get the client platform (NanoflowCommons.Platform) where the action is running. - * @returns {Promise.<"NanoflowCommons.Platform.Web"|"NanoflowCommons.Platform.Native_mobile"|"NanoflowCommons.Platform.Hybrid_mobile">} - */ -export async function GetPlatform(): Promise { - // BEGIN USER CODE - if (window && window.cordova) { - return Promise.resolve("Hybrid_mobile"); - } else if (navigator && navigator.product === "ReactNative") { - return Promise.resolve("Native_mobile"); - } else { - return Promise.resolve("Web"); - } - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/src/other/Wait.ts b/packages/jsActions/nanoflow-actions-native/src/other/Wait.ts deleted file mode 100644 index df3e67290..000000000 --- a/packages/jsActions/nanoflow-actions-native/src/other/Wait.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was generated by Mendix Studio Pro. -// -// WARNING: Only the following code will be retained when actions are regenerated: -// - the import list -// - the code between BEGIN USER CODE and END USER CODE -// - the code between BEGIN EXTRA CODE and END EXTRA CODE -// Other code you write will be lost the next time you deploy the project. -import { Big } from "big.js"; - -// BEGIN EXTRA CODE -// END EXTRA CODE - -/** - * Wait for number of milliseconds before continuing nanoflow execution. - * @param {Big} delay - The number of milliseconds to wait. This field is required. - * @returns {Promise.} - */ -export async function Wait(delay?: Big): Promise { - // BEGIN USER CODE - if (delay == null) { - return Promise.reject(new Error("Input parameter 'delay' is required.")); - } - - return new Promise(resolve => { - setTimeout(() => resolve(), Number(delay)); - }); - // END USER CODE -} diff --git a/packages/jsActions/nanoflow-actions-native/tsconfig.json b/packages/jsActions/nanoflow-actions-native/tsconfig.json deleted file mode 100644 index 8e8fb45f2..000000000 --- a/packages/jsActions/nanoflow-actions-native/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": "@mendix/pluggable-widgets-tools/configs/tsconfig.base", - "compilerOptions": { - "outDir": "dist/tsc", - "target": "es2017", - "lib": ["es2017", "DOM"], - "types": ["mendix-client", "big.js", "react-native"], - "moduleResolution": "node", - "sourceMap": false, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "removeComments": false, - "newLine": "CRLF" - }, - "baseUrl": "./src", - "include": ["./"], - "exclude": [] -} diff --git a/packages/jsActions/nanoflow-actions-native/typings/Geolocation.d.ts b/packages/jsActions/nanoflow-actions-native/typings/Geolocation.d.ts deleted file mode 100644 index c02df8d4a..000000000 --- a/packages/jsActions/nanoflow-actions-native/typings/Geolocation.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { - AuthorizationLevel, - AuthorizationResult, - GeoError, - GeoPosition, - GeoOptions, - getCurrentPosition, - requestAuthorization, - watchPosition, - clearWatch, - stopObserving -} from "react-native-geolocation-service"; - -type GeolocationServiceStatic = { - getCurrentPosition: typeof getCurrentPosition; - requestAuthorization: typeof requestAuthorization; - watchPosition: typeof watchPosition; - clearWatch: typeof clearWatch; - stopObserving: typeof stopObserving; -}; - -export type { GeolocationServiceStatic, AuthorizationLevel, AuthorizationResult, GeoError, GeoPosition, GeoOptions }; diff --git a/packages/jsActions/nanoflow-actions-native/typings/StorageValue.d.ts b/packages/jsActions/nanoflow-actions-native/typings/StorageValue.d.ts deleted file mode 100644 index 242072942..000000000 --- a/packages/jsActions/nanoflow-actions-native/typings/StorageValue.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface StorageValue { - [key: string]: number | boolean | string; - guid: string; -} diff --git a/packages/jsActions/nanoflow-actions-native/typings/mx.d.ts b/packages/jsActions/nanoflow-actions-native/typings/mx.d.ts deleted file mode 100644 index f44d425f5..000000000 --- a/packages/jsActions/nanoflow-actions-native/typings/mx.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -declare namespace mx { - interface ui { - toggleSidebar: () => void; - } - interface data { - update: (param: { guid?: string | undefined; entity?: string | undefined; callback?: () => void }) => void; - } - interface session { - clearCachedSessionData: () => Promise; - } - interface MxInterface { - reload: () => void; - } -} diff --git a/packages/jsActions/nanoflow-actions-native/typings/navigator.d.ts b/packages/jsActions/nanoflow-actions-native/typings/navigator.d.ts deleted file mode 100644 index 02907ac61..000000000 --- a/packages/jsActions/nanoflow-actions-native/typings/navigator.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -interface Navigator { - readonly product?: "ReactNative"; - share?: (data: { url?: string; text?: string; title?: string }) => Promise; -} - -interface Geolocation { - requestAuthorization?: () => void; -} diff --git a/packages/jsActions/nanoflow-actions-native/typings/react-native-geocoder.d.ts b/packages/jsActions/nanoflow-actions-native/typings/react-native-geocoder.d.ts deleted file mode 100644 index f5c94564a..000000000 --- a/packages/jsActions/nanoflow-actions-native/typings/react-native-geocoder.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -declare module "react-native-geocoder" { - export interface Position { - lat: number; - lng: number; - } - - export interface GeocodingObject { - position: Position; - formattedAddress: string; - feature: string | null; - streetNumber: string | null; - streetName: string | null; - postalCode: string | null; - locality: string | null; - country: string; - countryCode: string; - adminArea: string | null; - subAdminArea: string | null; - subLocality: string | null; - } - - export const apiKey: null | string; - - export function fallbackToGoogle(key: string): void; - - export function geocodePosition(position: Position): Promise; - - export function geocodeAddress(address: string): Promise; - - export = { - apiKey, - fallbackToGoogle, - geocodePosition, - geocodeAddress - }; -} diff --git a/packages/jsActions/nanoflow-actions-native/typings/window.d.ts b/packages/jsActions/nanoflow-actions-native/typings/window.d.ts deleted file mode 100644 index 48eb7136f..000000000 --- a/packages/jsActions/nanoflow-actions-native/typings/window.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -interface Window { - readonly cordova?: object; - readonly plugins?: { - readonly socialsharing?: CordovaSharing; - }; -} - -interface CordovaSharing { - shareWithOptions( - options: CordovaSharingOptions, - success: (result: { completed: boolean; app: string }) => void, - error: (error: string) => void - ): void; -} - -interface CordovaSharingOptions { - message?: string; - subject?: string; - url?: string; -} diff --git a/scripts/release/README.md b/scripts/release/README.md index cf9cc33e2..b833be740 100644 --- a/scripts/release/README.md +++ b/scripts/release/README.md @@ -23,16 +23,16 @@ #### Native Modules -- Native _modules_ published to Marketplace include Native Mobile Resources (named `mobile-resources-native` in code) and Nanoflow Commons (named `nanoflow-actions-native` in code). `nanoflow-actions-hybrid` is deprecated since MX9. +- Native _modules_ published to Marketplace include Native Mobile Resources (named `mobile-resources-native` in code). `nanoflow-actions-hybrid` is deprecated since MX9. `nanoflow-actions-native` is migrate to [this](https://github.com/mendix/nanoflow-commons) repo. - All Native pluggable widgets and some JavaScript actions are released to the Marketplace with Native Mobile Resources module. The module contains all widget `.mpk`s. - JS actions in `nanoflow-actions-native` are included in and released with Nanoflow Commons. 1. Make sure each changed widget has an appropriate change to it's `package.json` & `package.xml` (version bump) and changelog update before releasing. -1. In `CHANGELOG.md`, try to avoid using special characters like backtick[`] around the text while updating the changelog because it won't be able to parse the text; instead you can use square brackets[]. -1. Each widget (e.g. `bar-chart-native`) or module's (e.g. `mobile-resources-native`) `minimumMXVersion` in `package.json` should match the `NativeComponentsTestProject` Mendix project Studio Pro version. You can pull the [repo](https://github.com/mendix/Native-Mobile-Resources) into Windows and double-click the `.mpr` in the root. You should have at least one Studio Pro installation for this to work. -1. On `master`, once all to-be-released changes are merged, add a tag to the commit you want to create a release from. The tag should +2. In `CHANGELOG.md`, try to avoid using special characters like backtick[`] around the text while updating the changelog because it won't be able to parse the text; instead you can use square brackets[]. +3. Each widget (e.g. `bar-chart-native`) or module's (e.g. `mobile-resources-native`) `minimumMXVersion` in `package.json` should match the `NativeComponentsTestProject` Mendix project Studio Pro version. You can pull the [repo](https://github.com/mendix/Native-Mobile-Resources) into Windows and double-click the `.mpr` in the root. You should have at least one Studio Pro installation for this to work. +4. On `master`, once all to-be-released changes are merged, add a tag to the commit you want to create a release from. The tag should be formatted like ${PackageName}-v${Major}.${Minor}.${Patch}. e.g. `mobile-resources-native-v3.0.0`. The automation script uses the version part to bump the module's `package.json` version. Push this tag to GitHub, this will trigger a GitHub action. diff --git a/scripts/release/createNativeModules.js b/scripts/release/createNativeModules.js index 1c464bfe1..ba6cb01fe 100644 --- a/scripts/release/createNativeModules.js +++ b/scripts/release/createNativeModules.js @@ -25,7 +25,7 @@ main().catch(e => { }); async function main() { - const modules = ["mobile-resources-native", "nanoflow-actions-native", "atlas-content-native"]; + const modules = ["mobile-resources-native", "atlas-content-native"]; if (!modules.includes(moduleFolderNameInRepo) || !version) { return; } @@ -34,9 +34,6 @@ async function main() { case "mobile-resources-native": await createNativeMobileResourcesModule(); break; - case "nanoflow-actions-native": - await createNanoflowCommonsModule(); - break; case "atlas-content-native": await createAtlasNativeContentModule(); break; @@ -75,33 +72,6 @@ async function createNativeMobileResourcesModule() { console.log("Done."); } -async function createNanoflowCommonsModule() { - console.log("Creating the Nanoflow Commons module."); - const moduleFolder = join(repoRootPath, "packages/jsActions", moduleFolderNameInRepo); - const tmpFolder = join(repoRootPath, "tmp", moduleFolderNameInRepo); - let moduleInfo = { - ...(await getPackageInfo(moduleFolder)), - moduleNameInModeler: "NanoflowCommons", - moduleFolderNameInModeler: "nanoflowcommons" - }; - moduleInfo = await bumpVersionInPackageJson(moduleFolder, moduleInfo); - - await githubAuthentication(moduleInfo); - const moduleChangelogs = await updateModuleChangelogs(moduleInfo); - await commitAndCreatePullRequest(moduleInfo); - await updateNativeComponentsTestProject(moduleInfo, tmpFolder); - const mpkOutput = await createMPK(tmpFolder, moduleInfo, regex.excludeFiles); - await createGithubRelease(moduleInfo, moduleChangelogs, mpkOutput); - if (process.env.CI !== "true") { - try { - await execShellCommand(`rm -rf ${tmpFolder}`); - } catch (e) { - console.error("Failed to remove the temporary folder"); - } - } - console.log("Done."); -} - async function createAtlasNativeContentModule() { console.log("Creating the Atlas Native Content module."); const moduleFolder = join(repoRootPath, `packages/modules/${moduleFolderNameInRepo}`); diff --git a/scripts/test/e2e-native.js b/scripts/test/e2e-native.js index 281aa08b3..0b67e91da 100644 --- a/scripts/test/e2e-native.js +++ b/scripts/test/e2e-native.js @@ -39,7 +39,7 @@ async function main() { execSync("yarn workspaces foreach run release --since origin/master"); packages.forEach(({ name, location }) => { - if (["mobile-resources-native", "nanoflow-actions-native"].includes(name)) { + if (["mobile-resources-native"].includes(name)) { // for js actions const path = name === "mobile-resources-native" ? "nativemobileresources" : "nanoflowcommons"; const jsActionsPath = `${projectDir}/javascriptsource/${path}/actions`; diff --git a/yarn.lock b/yarn.lock index b03157043..bb7fea80b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3118,16 +3118,6 @@ __metadata: languageName: node linkType: hard -"@react-native-community/geolocation@npm:2.0.2": - version: 2.0.2 - resolution: "@react-native-community/geolocation@npm:2.0.2" - peerDependencies: - react: "*" - react-native: "*" - checksum: b072e740d0a3bd05f6166d66a5ab268d248092ab812b215539667ce0d4b01a078faed9a1bb45ac654e6aae976115f5b8c68dcab9de02e1a811b30cc5bb2e7d36 - languageName: node - linkType: hard - "@react-native-community/netinfo@npm:5.9.7": version: 5.9.7 resolution: "@react-native-community/netinfo@npm:5.9.7" @@ -10916,13 +10906,6 @@ __metadata: languageName: node linkType: hard -"js-base64@npm:~3.7.2": - version: 3.7.2 - resolution: "js-base64@npm:3.7.2" - checksum: 573f28e9a27c3df60096d4d3f551bcb4fcb6d49161cf83396e9bad9b76f94736a70bb70b8808fe834dff2a388f76604ba09d6e153bbf181646e407720139fa5b - languageName: node - linkType: hard - "js-priority-queue@npm:^0.1.5": version: 0.1.5 resolution: "js-priority-queue@npm:0.1.5" @@ -12829,22 +12812,6 @@ __metadata: languageName: node linkType: hard -"nanoflow-actions-native@workspace:packages/jsActions/nanoflow-actions-native": - version: 0.0.0-use.local - resolution: "nanoflow-actions-native@workspace:packages/jsActions/nanoflow-actions-native" - dependencies: - "@mendix/pluggable-widgets-tools": ^9.0.0 - "@react-native-community/async-storage": 1.12.1 - "@react-native-community/geolocation": 2.0.2 - eslint: ^7.20.0 - invariant: ^2.2.4 - js-base64: ~3.7.2 - react-native-geocoder: 0.5.0 - react-native-geolocation-service: 5.2.0 - rollup: ^2.68.0 - languageName: unknown - linkType: soft - "nanoid@npm:^3.3.4": version: 3.3.4 resolution: "nanoid@npm:3.3.4" @@ -14880,13 +14847,6 @@ __metadata: languageName: node linkType: hard -"react-native-geolocation-service@npm:5.2.0": - version: 5.2.0 - resolution: "react-native-geolocation-service@npm:5.2.0" - checksum: 80bdeb521023114f253290d28dfa0ae6acf7db7b37360672e78be7669e2a326ffdfbd8a476d931b3a23fec6b453f3aa8b39a885aa2bb020a11e20170493c00a9 - languageName: node - linkType: hard - "react-native-gesture-handler@npm:1.10.3": version: 1.10.3 resolution: "react-native-gesture-handler@npm:1.10.3"