@rontrol/babel-plugin-access-control-autocomplete
TypeScript icon, indicating that this package has built-in type declarations

0.0.22 • Public • Published

@rontrol/babel-plugin-access-control-autocomplete

Autocomplete AccessControl React HoC.

When added access control for each Component, we may added some component as below:

import { mustAllOfPermissions } from "@rontrol/access";
import { AcComponent2 } from "other";
import { useRequest, useTempDataForRequest } from "@rontrol/request";
import { listApp, putApp } from "some-clients";

export const AcComponent = mustAllOfPermissions(
  AcComponent2,
  listApp,
  putApp,
)(() => {
  const [] = useRequest(putApp, {});
  const [] = useTempDataForRequest(listApp, {});

  return <AcComponent2 />;
});

but it will be boring and easy to make mistake.

with this plugin we could use special named component (Ac(Every)Component and AcSomeComponet) to autocomplete the AccessControlComponent.

the key of access control should be from request method, we could collect them by use(\w+)?Request or useAc(\w+) hooks or create(\w+)?Request HoC. and AccessControlComponent will be composed too.

export const AcComponent = () => {
  const [] = useRequest(putApp, {});
  const [] = useTempDataForRequest(listApp, {});

  return <AcComponent2 />;
};

will be transform to

export const AcComponent = mustAllOfPermissions(
  AcComponent2,
  listApp,
  putApp,
)(() => {
  const [] = useRequest(putApp, {});
  const [] = useTempDataForRequest(listApp, {});

  return <AcComponent2 />;
});

Readme

Keywords

none

Package Sidebar

Install

npm i @rontrol/babel-plugin-access-control-autocomplete

Weekly Downloads

1

Version

0.0.22

License

none

Unpacked Size

22.4 kB

Total Files

6

Last publish

Collaborators

  • rx-78-2