Skip to content

Commit

Permalink
Release 0.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 15, 2024
1 parent 7187fa6 commit f460e1a
Show file tree
Hide file tree
Showing 44 changed files with 5,981 additions and 656 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,28 @@ Release notes follow the [keep a changelog](https://keepachangelog.com/en/1.1.0/

## [Unreleased]

## [0.11.2] - 2024-11-15

### Added

- Created a new package `@quatico/magellan-starter` containing templates for different frontend frameworks. The package contains a binary `create-magellan` that guides the user through the process of scaffolding the template in a directory of choice. Currently, the following templates are available:
- `react-typescript-webpack`: a simple React application using Typescript and Webpack

## [0.11.0] - 2024-11-15

### Fixed

- `formdata-fetch`: improved endpoint validation for absolute and relative urls. Invalid URLs now throw an exception.

### Changed

- **Breaking Change**: The functions `addTransport` and `addTransportIfAbsent` have been removed from the public API. Please use `setTransport` instead. `setTransport` will replace the transport handler if it already exists, or add it if it does not.
- **Breaking Change**: The functions `addNamespace` and `addNamespaceIfAbsent` have been removed from the public API. Please use `setNamespace` instead. `setNamespace` will replace the namespace mapping if it already exists, or add it if it does not.
- **Breaking Change**: The function `applyExecutionContext` has been removed from the public API.

## [0.10.0] - 2024-09-20

## Fixed
### Fixed

- Fixes `resolveNamespace` with custom namespace input returning default namespace and transport if custom namespace could not be resolved. The function now throws an error that the configuration for the custom namespace could not be found.

Expand Down
71 changes: 32 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@

# Magellan

[![CI](https://github.com/quatico-solutions/magellan/actions/workflows/protect-stable.yml/badge.svg)](https://github.com/quatico-solutions/magellan/actions/workflows/protect-stable.yml) [![npm version](https://badge.fury.io/js/@quatico%2Fmagellan-cli.svg)](https://www.npmjs.com/search?q=%40quatico)
[![npm version](https://badge.fury.io/js/@quatico%2Fmagellan-cli.svg)](https://www.npmjs.com/search?q=%40quatico)

The Magellan project provides compiler tooling and a runtime API for remote execution of
service functions written in TypeScript.
The Magellan project provides compiler tooling and a runtime API for remote execution of service functions written in TypeScript.

In many applications, backend developers have to create REST APIs, e.g., using swagger.io. Frontend developer implement
client code in their components to present domain logic and data in the browser. During the development developers in
frontend and backend have numerous discussions about this API, followed by changes and extensions on both sides.
Magellan simplifies this process by providing a compiler that generates all involved code for both sides.
In many applications, backend developers have to create REST APIs, e.g., using [swagger.io](https://swagger.io/). Frontend developer implement client code in their components to present domain logic and data in the browser. During the development developers infrontend and backend have numerous discussions about this API, followed by changes and extensions on both sides. Magellan simplifies this process by providing a compiler that generates all involved code for both sides.

Magellan is a TypeScript library that provides a compiler and runtime API for service functions with the following features:

- Transparent support to write services that consume node modules in the frontend
- npm package generation of TypeScript server code for remote execution through node
- (Almost) invisible transport layer between browser and node.
- Effortless configuration of service endpoints
- Automatic serialization of input/output values
- Transparent error messages and exception handling
- Transparent support to write services that consume node modules in the frontend
- npm package generation of TypeScript server code for remote execution through node
- (Almost) invisible transport layer between browser and node.
- Effortless configuration of service endpoints
- Automatic serialization of input/output values
- Transparent error messages and exception handling

## 1 Prerequisites

Expand All @@ -46,7 +42,7 @@ a [React](https://reactjs.org/) component that displays it in the browser. This
## 3 Create a react application

```bash
npx create-react-app magellan-demo --template typescript
npx create-react-app magellan-demo --template typescript
```

and open the project in your favorite IDE for example in Visual Studio Code using
Expand All @@ -63,8 +59,8 @@ Add an example function that returns a greeting `src/services/greet-me.ts`:
```typescript
export const greetMe = async (name: string): Promise<string> => {
// In the browser, accessing process.arch causes an error.
return `Hello ${name}, great to see you I'm Magellan running on "${ typeof window === "undefined" ? `${process.arch}" server`: "browser"}!`;
}
return `Hello ${name}, great to see you I'm Magellan running on "${typeof window === "undefined" ? `${process.arch}" server` : "browser"}!`;
};
```

### 3.2 Use the service in the application
Expand All @@ -89,7 +85,7 @@ function App() {
+ setGreeting("server does not wish to greet us");
+ });
+ }, []);

return (
<div className="App">
<header className="App-header">
Expand Down Expand Up @@ -182,28 +178,25 @@ const { join } = require("path");
const isProduction = process.env.NODE_ENV === "production";

const websmithConfig = {
debug: process.env.NODE_ENV === "debug",
sourceMap: !isProduction,
project: join(__dirname, "tsconfig.json"),
config: join(__dirname, "websmith.config.json"),
targets: "client,server",
debug: process.env.NODE_ENV === "debug",
sourceMap: !isProduction,
project: join(__dirname, "tsconfig.json"),
config: join(__dirname, "websmith.config.json"),
targets: "client,server",
};

module.exports = {
webpack: function override(config, env) {
config.module.rules.push({
test: /\.[jt]sx?$/,
include: [
join(__dirname, "src"),
join(__dirname, "node_modules", "@quatico", "magellan-client"),
],
exclude: [/\.spec\.tsx?$/, /node_modules/],
loader: "@quatico/websmith-webpack",
options: websmithConfig,
});

return config;
},
webpack: function override(config, env) {
config.module.rules.push({
test: /\.[jt]sx?$/,
include: [join(__dirname, "src"), join(__dirname, "node_modules", "@quatico", "magellan-client")],
exclude: [/\.spec\.tsx?$/, /node_modules/],
loader: "@quatico/websmith-webpack",
options: websmithConfig,
});

return config;
},
};
```

Expand All @@ -218,13 +211,13 @@ Create a file `websmith.config.json` in the magellan-demo directory with the fol
"client": {
"writeFile": false,
"addons": ["client-function-transform"],
"config": {"functionsDir": "./src/services"}
"config": { "functionsDir": "./src/services" }
},
"server": {
"writeFile": true,
"addons": ["service-function-generate"],
"config": {"functionsDir": "./src/services" },
"options": {"outDir": "./lib/server","module": 1}
"config": { "functionsDir": "./src/services" },
"options": { "outDir": "./lib/server", "module": 1 }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.10.1"
"version": "0.11.2"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@quatico/magellan",
"description": "",
"version": "0.10.1",
"version": "0.11.2",
"keywords": [
"typescript",
"java",
Expand Down Expand Up @@ -62,7 +62,7 @@
"nx-cloud": "16.0.5",
"prettier": "^2.8.8",
"regenerator-runtime": "0.13.11",
"rimraf": "5.0.0",
"rimraf": "^5.0.0",
"ts-jest": "^29.1.0",
"ts-node": "10.9.x",
"typescript": "5.0.x"
Expand Down
10 changes: 5 additions & 5 deletions packages/addons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@quatico/magellan-addons",
"version": "0.10.1",
"version": "0.11.2",
"description": "A example library for the websmith compiler",
"author": "Quatico Solutions AG",
"license": "SEE LICENSE IN LICENSE",
Expand All @@ -25,7 +25,7 @@
"test": "jest --coverage",
"test:update-snapshots": "yarn test -u",
"test:watch": "jest --watch",
"publish-npm": "npm publish"
"publish-npm": "npm publish --access public"
},
"devDependencies": {
"@swc/core": "^1.3.57",
Expand All @@ -44,12 +44,12 @@
"eslint-plugin-testing-library": "^5.10.3",
"jest": "^29.5.0",
"prettier": "^2.8.8",
"rimraf": "5.0.0",
"rimraf": "^5.0.0",
"ts-jest": "^29.1.0"
},
"dependencies": {
"@quatico/magellan-client": "^0.10.1",
"@quatico/magellan-server": "^0.10.1",
"@quatico/magellan-client": "^0.11.2",
"@quatico/magellan-server": "^0.11.2",
"@quatico/websmith-api": "0.4.0",
"typescript": "5.0.x"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@quatico/magellan-cli",
"description": "CLI for the Magellan project",
"version": "0.10.1",
"version": "0.11.2",
"author": "Quatico Solutions AG",
"license": "SEE LICENSE IN LICENSE",
"main": "lib/index.js",
Expand Down Expand Up @@ -32,11 +32,11 @@
"test": "jest --coverage",
"test:watch": "jest --watch",
"test:update-snapshots": "yarn test -u",
"publish-npm": "npm publish"
"publish-npm": "npm publish --access public"
},
"dependencies": {
"@quatico/magellan-client": "^0.10.1",
"@quatico/magellan-server": "^0.10.1",
"@quatico/magellan-client": "^0.11.2",
"@quatico/magellan-server": "^0.11.2",
"@quatico/websmith-api": "0.4.0",
"@quatico/websmith-compiler": "0.4.0",
"@quatico/websmith-core": "0.4.0",
Expand All @@ -54,7 +54,7 @@
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"cross-env": "^7.0.3",
"esbuild": "^0.15.13",
"esbuild": "^0.24.0",
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-alias": "^1.1.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@quatico/magellan-client",
"description": "Client library for proxies generated with @quatico/websmith-compiler",
"version": "0.10.1",
"version": "0.11.2",
"author": "Quatico Solutions AG",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand All @@ -25,10 +25,10 @@
"test": "jest --coverage",
"test:watch": "jest --watch",
"test:update-snapshots": "yarn test -u",
"publish-npm": "npm publish"
"publish-npm": "npm publish --access public"
},
"dependencies": {
"@quatico/magellan-shared": "^0.10.1"
"@quatico/magellan-shared": "^0.11.2"
},
"devDependencies": {
"@swc/core": "^1.3.57",
Expand Down
26 changes: 2 additions & 24 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,7 @@ import { deserialize, serialize } from "@quatico/magellan-shared";
import { remoteInvoke } from "./remote-invoke";
import { Sdk } from "./sdk";
import type { Configuration, Context } from "./transport";
import {
addNamespace,
addNamespaceIfAbsent,
addTransport,
addTransportIfAbsent,
initProjectConfiguration,
resolveNamespace,
setNamespace,
setTransport
} from "./transport";
import { initProjectConfiguration, resolveNamespace, setNamespace, setTransport } from "./transport";

export {
addNamespace,
addNamespaceIfAbsent,
addTransport,
addTransportIfAbsent,
deserialize,
initProjectConfiguration,
remoteInvoke,
resolveNamespace,
Sdk,
serialize,
setNamespace,
setTransport,
};
export { setNamespace, setTransport, deserialize, initProjectConfiguration, remoteInvoke, resolveNamespace, Sdk, serialize };
export type { Configuration, Context, NamespaceMapping, TransportHandler };
21 changes: 1 addition & 20 deletions packages/client/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,19 @@
*/

import { NamespaceMapping, TransportHandler } from "@quatico/magellan-shared";
import { addNamespace, addNamespaceIfAbsent, addTransport, addTransportIfAbsent, getConfiguration, setNamespace, setTransport } from "./transport";
import { getConfiguration, setNamespace, setTransport } from "./transport";

export class Sdk {
public init() {
// eslint-disable-next-line no-console
console.info(`Initialize Sdk with configuration: `, getConfiguration());
}
public addNamespace(name: string, mapping: NamespaceMapping): this | never {
addNamespace(name, mapping);
return this;
}

public addNamespaceIfAbsent(name: string, mapping: NamespaceMapping): this {
addNamespaceIfAbsent(name, mapping);
return this;
}

public setNamespace(name: string, mapping: NamespaceMapping): this {
setNamespace(name, mapping);
return this;
}

public addTransport(name: string, transport: TransportHandler): this | never {
addTransport(name, transport);
return this;
}

public addTransportIfAbsent(name: string, transport: TransportHandler): this {
addTransportIfAbsent(name, transport);
return this;
}

public setTransport(name: string, transport: TransportHandler): this {
setTransport(name, transport);
return this;
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export type { Configuration } from "./Configuration";
export { getConfiguration, initProjectConfiguration } from "./configuration-repository";
export type { Context } from "./Context";
export { formdataFetch } from "./formdata-fetch";
export { addNamespace, addNamespaceIfAbsent, addTransport, addTransportIfAbsent, resolveNamespace, setNamespace, setTransport } from "./namespace";
export { setNamespace, setTransport, resolveNamespace } from "./namespace";
export type { ResolvedNamespace } from "./ResolvedNamespace";
export { transportRequest } from "./transport-request";
Loading

0 comments on commit f460e1a

Please sign in to comment.