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

@mbc-cqrs-serverless/ui-setting

v1.2.5

Published

Setting master data

Readme

MBC CQRS serverless framework

@mbc-cqrs-serverless/ui-setting

npm version License: MIT

UI configuration management for the MBC CQRS Serverless framework. Manage user interface settings, themes, preferences, and tenant-specific customizations.

Features

  • Setting Schema Definition: Define settings with codes and attributes
  • Data Setting Management: CRUD operations for setting values
  • Multi-tenant Support: Tenant-isolated UI configurations
  • Validation: Automatic setting code validation
  • CQRS Integration: Full event sourcing for setting changes

Installation

npm install @mbc-cqrs-serverless/ui-setting

Quick Start

1. Register the Module

import { Module } from '@nestjs/common';
import { SettingModule } from '@mbc-cqrs-serverless/ui-setting';

@Module({
  imports: [
    SettingModule.register({
      enableSettingController: true, // Optional: enable setting schema REST endpoints
      enableDataController: true, // Optional: enable data setting REST endpoints
    }),
  ],
})
export class AppModule {}

2. Use the Data Setting Service

import { Injectable } from '@nestjs/common';
import { DataSettingService } from '@mbc-cqrs-serverless/ui-setting';
import { IInvoke } from '@mbc-cqrs-serverless/core';

@Injectable()
export class ThemeService {
  constructor(private readonly dataSettingService: DataSettingService) {}

  async createThemePreset(tenantCode: string, data: any, opts: { invokeContext: IInvoke }) {
    return this.dataSettingService.create(
      tenantCode,
      {
        settingCode: 'THEME',
        code: data.code,
        name: data.name,
        attributes: {
          primaryColor: data.primaryColor,
          mode: data.mode,
          fontSize: data.fontSize,
        },
      },
      opts,
    );
  }
}

API Reference

DataSettingService

Service for managing setting data values.

| Method | Description | |--------|-------------| | create(tenantCode, dto, options) | Create new setting data | | update(key, dto, options) | Update setting data | | delete(key, options) | Soft delete setting data | | get(key) | Get setting data by pk/sk | | list(tenantCode, searchDto) | List settings by tenant | | checkExistCode(tenantCode, settingCode, code) | Check if code exists |

SettingService

Service for managing setting schemas.

| Method | Description | |--------|-------------| | create(tenantCode, dto, options) | Create setting schema | | update(key, dto, options) | Update setting schema | | delete(key, options) | Delete setting schema | | get(key) | Get setting schema | | list(tenantCode, searchDto) | List setting schemas |

CreateDataSettingDto

| Property | Type | Required | Description | |----------|------|----------|-------------| | settingCode | string | Yes | Parent setting schema code | | code | string | Yes | Unique value code | | name | string | No | Display name | | attributes | object | No | Setting values |

Usage Examples

Define Setting Schema

First, create the setting schema:

async createSettingSchema(tenantCode: string, opts: { invokeContext: IInvoke }) {
  return this.settingService.create(
    tenantCode,
    {
      code: 'THEME',
      name: 'Theme Settings',
      attributes: {
        description: 'UI theme configuration',
        schema: {
          primaryColor: { type: 'string', format: 'color' },
          mode: { type: 'string', enum: ['light', 'dark'] },
          fontSize: { type: 'number', min: 12, max: 24 },
        },
      },
    },
    opts,
  );
}

Create Setting Values

Then, create values for the schema:

async createThemePreset(
  tenantCode: string,
  preset: ThemePresetDto,
  opts: { invokeContext: IInvoke },
) {
  return this.dataSettingService.create(
    tenantCode,
    {
      settingCode: 'THEME',
      code: preset.code,
      name: preset.name,
      attributes: {
        primaryColor: preset.primaryColor,
        mode: preset.mode,
        fontSize: preset.fontSize,
      },
    },
    opts,
  );
}

Update Setting

async updateTheme(
  pk: string,
  sk: string,
  updates: UpdateThemeDto,
  opts: { invokeContext: IInvoke },
) {
  return this.dataSettingService.update(
    { pk, sk },
    {
      name: updates.name,
      attributes: updates.attributes,
    },
    opts,
  );
}

Delete Setting

async deleteTheme(pk: string, sk: string, opts: { invokeContext: IInvoke }) {
  return this.dataSettingService.delete({ pk, sk }, opts);
}

List Settings

async getThemePresets(tenantCode: string) {
  return this.dataSettingService.list(tenantCode, {
    settingCode: 'THEME',
  });
}

async searchSettings(tenantCode: string, keyword: string) {
  return this.dataSettingService.list(tenantCode, {
    // Returns all settings for the tenant
  });
}

Check Code Availability

async isCodeAvailable(
  tenantCode: string,
  settingCode: string,
  code: string,
): Promise<boolean> {
  const exists = await this.dataSettingService.checkExistCode(
    tenantCode,
    settingCode,
    code,
  );
  return !exists;
}

Data Model

Setting Schema Key Pattern

pk: SETTING#[tenantCode]
sk: SETTING#[settingCode]

Example:
pk: SETTING#MBC
sk: SETTING#THEME

Setting Data Key Pattern

pk: SETTING#[tenantCode]
sk: [settingCode]#[code]

Example:
pk: SETTING#MBC
sk: THEME#DARK_MODE

Example Setting Data Structure

{
  "pk": "SETTING#MBC",
  "sk": "THEME#DARK_MODE",
  "code": "DARK_MODE",
  "name": "Dark Mode Theme",
  "tenantCode": "MBC",
  "type": "MASTER",
  "isDeleted": false,
  "attributes": {
    "primaryColor": "#1a1a2e",
    "mode": "dark",
    "fontSize": 14
  }
}

Common Use Cases

Theme Configuration

// Create theme presets
await dataSettingService.create(tenantCode, {
  settingCode: 'THEME',
  code: 'CORPORATE',
  name: 'Corporate Theme',
  attributes: { primaryColor: '#003366', mode: 'light', fontSize: 14 },
}, opts);

Layout Preferences

// Store user layout preferences
await dataSettingService.create(tenantCode, {
  settingCode: 'LAYOUT',
  code: 'COMPACT',
  name: 'Compact Layout',
  attributes: { sidebarWidth: 200, contentPadding: 16, density: 'compact' },
}, opts);

Feature Flags

// Store feature flags per tenant
await dataSettingService.create(tenantCode, {
  settingCode: 'FEATURE_FLAGS',
  code: 'BETA_FEATURES',
  name: 'Beta Features',
  attributes: { newDashboard: true, darkMode: true, experimentalApi: false },
}, opts);

Related Packages

| Package | Description | |---------|-------------| | @mbc-cqrs-serverless/core | Core CQRS framework | | @mbc-cqrs-serverless/master | Hierarchical settings | | @mbc-cqrs-serverless/tenant | Multi-tenancy support |

Documentation

Full documentation available at https://mbc-cqrs-serverless.mbc-net.com/

License

Copyright © 2024-2025, Murakami Business Consulting, Inc. https://www.mbc-net.com/

This project is under the MIT License.