Skip to content

Commit

Permalink
Release version 0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiostalla committed Dec 27, 2023
1 parent 0a95dcb commit 53d83d6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 21 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Changelog
All notable changes to this project since its first released version (0.9.0) are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [1.0.0] – Not yet released

### Added
- Form API for HTML5: set up forms from CRUD action metadata

## [0.9.2] – 2023-12-27

### Fixed
- Connection to URLs ending with slash
- RxJS integration

## [0.9.1] – 2023-07-28

### Added
- Installation instructions

### Changed
- Clearer error messages

### Fixed
- Authentication loop
- Readme file contents

### Removed
- The Angular UI is no longer part of Portofino. It is now a separate project.
- Given the lack of built-in UI, several new helper projects have been started to help build Portofino-based
applications, including a command-line tool and libraries to integrate Portofino into web applications. Please
refer to [the website](https://manydesigns.github.io/Portofino/).
47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
[![npm version](https://badge.fury.io/js/portofino-commander.svg)](https://badge.fury.io/js/portofino-commander)

# portofino-commander
# Portofino-commander

A JavaScript library to query, inspect and modify a [Portofino](https://github.com/ManyDesigns/Portofino) application.
A JavaScript library to query, inspect and modify a [Portofino](https://github.com/ManyDesigns/Portofino) service. We can use this to build an application
on top of a Portofino backend.

It has few dependencies:
- The standard `fetch` API
- RxJS
- jwt-decode
- i18next
Portofino-commander has few dependencies:
- The standard `fetch` API, for HTTP requests;
- RxJS, for reactive APIs;
- jwt-decode, to handle authentication;
- i18next, for internationalization.

These all work both on the browser and in Node, therefore Portofino-commander runs in both environments.
These all work on the browser as well as in Node, therefore Portofino-commander runs in both environments.

## Installation

portofino-commander is available from the NPM Registry so we can use tools like NPM or Yarn to install it:
Portofino-commander is available from the NPM Registry, so we can use tools like NPM or Yarn to install it:

```
npm install --save portofino-commander
Expand All @@ -30,7 +31,7 @@ For convenience, we also provide a minified bundle of Portofino-commander and it
so you can include it like so:

```html
<script src="./static/bundle/portofino-commander-0.9.1-bundle.js" charset="UTF-8" defer></script>
<script src="./static/bundle/portofino-commander-0.9.2-bundle.js" charset="UTF-8" defer></script>
```

You can find the bundle in the [Releases page](https://github.com/alessiostalla/portofino-commander/releases).
Expand All @@ -54,7 +55,12 @@ const portofino = Portofino.connect(
```

The above applies to Portofino 5 and 6 services (based on Spring Boot).
Of course, a service could have a non-standard configuration, and its address could be different.

**Note** that, in a production or staging application, the service is going to be exposed with a public or internal
URL, most probably behind a reverse proxy. So, the actual URL will vary accordingly to the server's configuration.

#### Non-standard Service URL
Even on a development machine, a service could have a non-standard configuration, and its address could be different.

If unsure, check the log messages emitted while the service starts up and look for lines like the following:

Expand Down Expand Up @@ -82,16 +88,19 @@ if the application is deployed at the root (e.g., on Tomcat, if the .war file is

`/api` is the REST API root, because if we access `http://localhost:8080/demo-tt` we'll receive the HTML of the
application's home page. This path can be customized in the application's `web.xml` file, but `/api` is the
default and it rarely gets changed.
default, and it rarely gets changed.

Again, this only applies to local usage in a development environment. A deployed .war application will have a different
URL, that depends on the configuration of the server.

### Making Requests

Once we've got a connection, we can make requests to the server. We do this conceptually in two steps:
- First, we obtain a _resource_ (e.g. a CRUD `ResourceAction`) – this is a _class_ of the application;
- First, we obtain a _resource_ (e.g. a CRUD `ResourceAction`) – this is a _class_ in the application;
- Then, we invoke an _operation_ on the resource (e.g. "save" on an CRUD) – this is a _method_ of the resource.

Portofino-commander implements access to a resource and invocation of an operation with an RxJS Observable.
These are proxied so that we don't have to use the RxJS APIs (such as `pipe` or `subscribe`) to chain them.
Portofino-commander implements both access to a resource and invocation of an operation with an RxJS Observable.
Observables are proxied so that we don't have to use the RxJS APIs (such as `pipe` or `subscribe`) to chain them.
Some examples follow.

Let's first define an _observer_ that will just print the result of an operation to the console:
Expand Down Expand Up @@ -149,7 +158,7 @@ portofino.upstairs.get("database/tables")
.subscribe(observer);
```

**Note:** on Portofino 5, we have to replace `.load()` with `.op_get()` (see below).
**Note:** when connecting to a Portofino 5 service or application, we have to replace `.load()` with `.op_get()` (see below).

When we're done, we should terminate the session:

Expand All @@ -158,7 +167,7 @@ portofino.logout().subscribe();
```

Note how calls to `subscribe` are needed to actually perform the HTTP requests to the backend. This is because RxJS is
"lazy" and doesn't run any code until someone looks at the results.
"lazy" and doesn't run any code until someone looks at the results (i.e. subscribes to the observable).

Portofino-commander automatically discovers operations such as _load()_ above for CRUD, or _getTablesInSchema(db, schema)_,
by querying the Portofino service. That's why `resource.get(subresource)` returns an _Observable_. The resource is only
Expand Down Expand Up @@ -223,7 +232,7 @@ invoking operations on the server (such as _load_ in the previous example) is an

## Compatibility

portofino-commander is developed and tested against Portofino 6.
Portofino-commander is developed and tested against Portofino 6.

While portofino-commander's general approach works perfectly well with Portofino 5, some REST APIs in P5 weren't
designed with such a client in mind, and require some extra handling to invoke them.
Expand Down Expand Up @@ -261,7 +270,7 @@ Portofino-commander is licensed under the GNU AGPL. In layman terms, if you buil
it, you need to release its source code.
If you'd like to use portofino-commander as a component in a tool or service and require a more business-friendly license,
please open an issue or contact me directly. I'm open to licensing this to specific organizations so that they can use it,
but I prefer to have a say in that.
even free of charge, but I prefer to have a say in that.

## Donations

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "portofino-commander",
"author": "Alessio Stalla",
"version": "1.0.0",
"version": "0.9.2",
"license": "AGPL-3.0-or-later",
"repository": {
"url": "https://github.com/alessiostalla/portofino-commander/"
Expand Down
2 changes: 1 addition & 1 deletion src/portofino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class ResourceAction {

get<T extends ResourceAction>(
segment: string,
type: new (...args) => T = ResourceAction as any,
type: new (...args: any[]) => T = ResourceAction as any,
setup: (o: Observable<T>) => Observable<T> = o => o) {
if (segment.startsWith("/")) {
return this.root.get(segment);
Expand Down

0 comments on commit 53d83d6

Please sign in to comment.