npm package: @lokavaluto/lokapi-backend-cyclos
Description: Cyclos backend for Lokavaluto API
Author: Valentin LAB
Latest version: 0.1.1-alpha.202511131512



This is a backend for managing any cyclos currency through LokAPI.
The latter aims at providing a simple framework for building client
app to manage currency payments. You can refer to `@lokavaluto/lokapi`'s doc to
get more knowledge of how to use it.

# Adding `@lokavaluto/lokapi-backend-cyclos` to your project

From the root of your project:

```sh
npm install --save @lokavaluto/lokapi-backend-cyclos
```

Or better, as `@lokavaluto/lokapi-backend-cyclos` is still in early release,

```sh
npm install --save Lokavaluto/lokapi-backend-cyclos#master
```

To be sure to get the latest version, relaunch this last command
whenever you want to update.

# Usage

You can provide this backend when subclassing LokAPI:

For instance:

```typescript
import LokAPIBrowserAbstract from "@lokavaluto/lokapi-browser"

import cyclos from '@lokavaluto/lokapi-backend-cyclos'

class LokAPI extends LokAPIBrowserAbstract {

  BackendFactories = {
    cyclos,
  }

  requestLocalPassword = async function (state: string) {
    // ... your UI code to request password from user
  }

  requestLogin() {
    // ... your UI code to request password from user
  }

}

if (!process.env.VUE_APP_LOKAPI_HOST) {
  throw new Error("Please specify VUE_APP_LOKAPI_HOST in '.env'")
}

if (!process.env.VUE_APP_LOKAPI_DB) {
  throw new Error("Please specify VUE_APP_LOKAPI_DB in '.env'")
}

export var lokAPI = new LokAPI(
  process.env.VUE_APP_LOKAPI_HOST,
  process.env.VUE_APP_LOKAPI_DB,
)
```


For usage of `@lokavaluto/lokapi`, please refer to `@lokavaluto/lokapi`'s documentation.

# Developers

To get started developing and tinkering with this code, you can:

## Install dependencies

```sh
npm install
```

## Build the project

```sh
npx tsc -w
```
Changelog
=========


(unreleased)
------------

New
~~~
- Add ``Backend.getCurrencyName()`` [Valentin Lab]
- Add ``Backend.getUserAccountsFromWalletIdent()`` [Valentin Lab]
- Repair ``Recipient.internalId`` [Valentin Lab]
- Add ``Backend.isUnconfigured()`` [Seddik]
- Support of ``Recipient.userAccountInternalId`` property. [Valentin
  Lab]
- Upgrade API to support the ``.prepareTransfer()`` new process.
  [Valentin Lab]
- Add
  ``{UserAccount,Account,Recipient}.isBusinessForFinanceBackend(..)``
  [Valentin Lab]
- ``transaction.isReconversion`` property now return string state.
  [Valentin Lab]

  If false, it is not a reconversion, if true it is a reconversion but wasn't
  yet acknowledged by the administrative backend. If it is a string, then it
  is the state as defined by the administrative backend.
- Add ``transaction.isTopUp`` and ``transaction.isReconversion``
  properties. [Valentin Lab]
- Do not cache failure of ``Backend.getAccounts(..)`` [Valentin Lab]
- Add implementation of split memo interface. [Valentin Lab]

  Note that there are no split memo support yet on cyclos backends, but
  we still need to advertise this and support the new prototypes.
- Provide implementation of ``CreditRequest`` [Valentin Lab]

  All backends now require to provide an implementation of
  ``CreditRequest`` as they could be displayed before actual payment and
  canceled.

Changes
~~~~~~~
- Make ``Recipient.transfer()`` return a full ``Transaction`` object.
  [Valentin Lab]

Fix
~~~
- Prevent requesting an amount that exceeds internal javascript float
  representation. [Valentin Lab]
- Get the correct currency symbol for all transactions. [Seddik]
- Return cyclos symbol identifier as ``Transaction.currency`` instead of
  cyclos currency name. [Valentin Lab]


0.1.0 (2023-05-08)
------------------

New
~~~
- New: enforce ``@0k.io/types-request`` version ``0.0.4`` or higher for
  timeout support. [Valentin Lab]
- Add date filter to ``getTransactions(..)`` [Valentin Lab]
- Resolve transaction's related name using odoo's new ``cyclos/contact``
  API endpoint. [Valentin Lab]
- Add ``Recipient.getSymbol()`` method implementation. [Valentin Lab]
- Add ``Recipient.fromUserAccount`` property. [Valentin Lab]
- Add ``UserAccount.getSymbol()`` implementation. [Valentin Lab]
- Make ``UserAccount.getAccounts()`` debounced and cached. [Valentin
  Lab]
- Provide ``UserAccount.requiresUnlock()`` to advertise if an unlock is
  required on current ``userAccount`` [Valentin Lab]
- Single out insufficient balance error to throw common exception.
  [Seddik Kadi]
- Make accounts answer to ``creditable`` boolean property. [Valentin
  Lab]
- Inactive user account don't have any money account accessible.
  [Valentin Lab]
- ``Backend.internalId`` property is now implemented on super class.
  [Valentin Lab]

Changes
~~~~~~~
- Chg: use new package ``@0k.io/types-request`` [Valentin Lab]

  This new package refactored out from lokapi some
  exceptions and types.

Fix
~~~
- Prevent exception upon listing transaction data with deleted user
  account. [Valentin Lab]
- New: api v12 changed structure of backend data ``bank_accounts`` ->
  ``accounts`` [Valentin Lab]
- Use new location of lokapi exceptions. [Valentin Lab]

  Re-introduce the ``instanceof`` check as it was tested as working
  on different builds (dev, production), and minified.


0.0.1 (2021-11-17)
------------------
- First import. [Valentin Lab]