@canhnm/mgnl-service

Shared Magnolia SPA services

Usage no npm install needed!

<script type="module">
  import canhnmMgnlService from 'https://cdn.skypack.dev/@canhnm/mgnl-service';
</script>

README

Magnolia Page Hint Library

This library helps to generate comments for Magnolia's cms:page, cms:area, and cms:component. Moreover, it also provide simple httpService wrapping fetch API to call REST endpoints.

Installation

This project is not official yet. It's pushed temporarily to https://www.npmjs.com/package/@canhnm/mgnl-service. You can install it into your project by:

npm install --save @canhnm/mgnl-service

API

Magnolia SPA Service

To use magnoliaSpaService, you need to import it from mgnl-service:

import { magnoliaSpaService } from '@canhnm/mgnl-service';

magnoliaSpaService is supported:

function getPageCommentString(page: object): string;
function getAreaCommentString(area: object): string;
function getComponentCommentString(component: object): string;

Http Service

To use httpService, you need to import it from mgnl-service:

import { httpService } from '@canhnm/mgnl-service';

httpService is supported:

function get(utl: string, params?: object, config?: object): Response;
function post(url: string, params?: object, postData?: object, config?: object): Response;
function service(url: string, config?: object): Response;
function delete(url: string, params?: object, config?: object): Response;

Note: delete is a special keyword, if you use typescript, you will see httpDelete instead of delete. It is exported both delete and httpDelete.

Utils

To use utils, you need to import it from mgnl-service:

import { utils } from '@canhnm/mgnl-service';

utils is supported:

// Returned object will be new object that has all properties from all object in the list
function merge(...objectList: Array<object>): object;

Note: You can pass as many objects as you want to merge function. e.g. const newObj = merge(obj1, obj2, obj3);.