npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

summer-day-permission-system

v0.0.6

Published

A componentized TypeScript permission system for Vue 3

Readme

Permission System

A componentized TypeScript permission system for Vue 3, providing comprehensive permission management capabilities including route permission, menu permission, and button permission.

Features

  • TypeScript Support - Full type safety
  • Vue 3 Composition API - Modern Vue 3 syntax
  • Route Permission - Dynamic route permission management
  • Menu Permission - Dynamic menu generation based on permissions
  • Button Permission - Fine-grained button permission control
  • Configurable - Flexible configuration options
  • No Strong Dependencies - Core functionality doesn't rely on specific UI frameworks

Installation

npm install summer-day-permission-system

Usage

1. Basic Usage

import { PermissionChecker } from "summer-day-permission-system";

// Create permission checker instance
const authNode = new Map([
    ["/admin/projects", ["create", "edit", "delete"]],
    ["/admin/users", ["view", "add"]],
]);

const permission = new PermissionChecker(authNode, {
    pathMapping: {
        "/admin/home": "/admin/projects",
    },
});

// Check permission
const canCreate = permission.auth("create"); // true
const canDelete = permission.auth("delete"); // true
const canViewUsers = permission.auth(["view", "add"]); // true

2. Vue 3 Composition API

Global Configuration

// main.ts
import { createApp } from "vue";
import { providePermission } from "summer-day-permission-system";
import App from "./App.vue";

const app = createApp(App);

// Provide permission instance globally
const authNode = new Map([["/admin/projects", ["create", "edit", "delete"]]]);

providePermission(
    app,
    {
        pathMapping: {
            "/admin/home": "/admin/projects",
        },
    },
    authNode
);

app.mount("#app");

Component Usage

<template>
    <button v-if="canCreate" @click="handleCreate">Create Project</button>
    <button v-if="canEdit" @click="handleEdit">Edit Project</button>
</template>

<script setup lang="ts">
import { usePermission } from "summer-day-permission-system";

const permission = usePermission();

const canCreate = permission.auth("create");
const canEdit = permission.auth("edit");

const handleCreate = () => {
    // Create project logic
};

const handleEdit = () => {
    // Edit project logic
};
</script>

3. Route Processing

import { RouteProcessor } from "summer-day-permission-system";

// Route data
const routes = [
    {
        name: "projects",
        path: "projects",
        title: "Project Management",
        type: "menu",
        menu_type: "tab",
        children: [
            {
                name: "create",
                path: "create",
                title: "Create Project",
                type: "button",
                icon: "el-icon-plus",
            },
            {
                name: "edit",
                path: "edit",
                title: "Edit Project",
                type: "button",
                icon: "el-icon-edit",
            },
        ],
    },
];

// Process routes
const { authNode, buttonInfo, menuRules } = RouteProcessor.processRoutes(
    routes,
    "/admin/"
);

// authNode: Map containing permission nodes
// buttonInfo: Map containing button information
// menuRules: Array containing menu rules

API

PermissionChecker

Constructor

new PermissionChecker(authNode?: Map<string, string[]>, config?: PermissionConfig)

Methods

  • auth(name: string | string[]): boolean - Check if user has permission
  • isHasPathAuth(path: string): boolean - Check if path has permission
  • updateAuthNode(authNode: Map<string, string[]>): void - Update permission nodes
  • getAuthNode(): Map<string, string[]> - Get current permission nodes
  • updateConfig(config: Partial<PermissionConfig>): void - Update configuration

RouteProcessor

Static Methods

  • handleAuthNode(routes: RouteItem[], prefix?: string): AuthNode - Process routes to generate auth nodes
  • handleButtonInfo(routes: RouteItem[]): ButtonInfo - Extract button info from routes
  • handleMenuRule(routes: RouteItem[], pathPrefix?: string): MenuRule[] - Generate menu rules from routes
  • processRoutes(routes: RouteItem[], prefix?: string): RouteProcessResult - Process routes comprehensively

Vue 3 Composables

  • createPermission(config?: PermissionConfig): (authNode?: AuthNode) => PermissionInstance - Create permission instance
  • usePermission(): PermissionInstance - Use permission instance in component
  • **providePermission(app: App, config?: PermissionConfig, authNode?: AuthNode): PermissionInstance ** - Provide permission instance globally

Types

PermissionConfig

interface PermissionConfig {
  isDevelopment?: boolean;
  defaultAuthResult?: boolean;
  pathMapping?: Record<string, string>;
}

RouteItem

interface RouteItem {
  id?: number;
  name: string;
  path: string;
  title: string;
  icon?: string;
  type: 'menu' | 'menu_dir' | 'button';
  menu_type?: 'tab' | 'iframe' | 'link';
  component_path?: string;
  extend?: string;
  keepalive?: number;
  url?: string;
  children?: RouteItem[];
}

Configuration

PermissionConfig

| Option | Type | Default | Description | |--------|------|---------|-------------| | isDevelopment | boolean | false | Whether in development mode | | defaultAuthResult | boolean | true | Default permission result in development mode | | pathMapping | Record<string, string> | {} | Path mapping for permission checking |

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

License

MIT