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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@decsys/param-types

v1.0.0

Published

The Parameter Types utilities package for DECSYS Components

Downloads

10

Readme

GitHub Build Status npm (scoped with tag)

Param Types

The DECSYS Parameter Types utilities package, used for authoring DECSYS Response Components.

Installation

npm install @decsys/param-types

Use in DECSYS Components

Component Authors should use param-types when writing components to provide their components with a params metadata property which provides a spec for parameters which should be configurable within the DECSYS Survey Platform.

It is possible to configure the params property without assistance from param-types but it's not recommended.

param-types provides helper functions and type constants to make specifying params easy.

It also provides a helper for generating propTypes and defaultProps for the parameter props as well.

  1. Use the type builders string, stringUndefined, number, bool and oneOf to specify individual parameters easily
  2. Use buildPropTypes() to build propTypes and defaultProps objects based on the above, as well as any additional propTypes and defaultProps passed to it.

Example


import ParamTypes, { buildPropTypes } from "@decsys/param-types";

/**
 * A component which has two configurable parameters,
 * and also props for loading previous results
 */
const MyComponent = ({ param1, param2, results }) => {
    //...
}

// Configure Component params using the type builders,
// so the Platform Editor knows how to configure your component
MyComponent.params = {
    param1: paramTypes.string("Friendly Label", "Default Value"),
    param2: paramTypes.oneOf(
        "Friendly Label",
        ["valid", "values", "not", "default"],
        "default")
}

// use `buildPropTypes()` to generate `propTypes` and `defaultProps`
// for the params, as well as those defined manually for other props
const { propTypes, defaultProps } = buildPropTypes(
    MyComponent.params,
    // propTypes
    {
        results: // ...
    },
    // defaultProps
    {
        results: // ...
    });

// Set `propTypes` and `defaultProps` on the Component
MyComponent.propTypes = propTypes;
MyComponent.defaultProps = defaultProps;

Imports

You can import from param-types in a variety of ways.

It's only a small package but it should support tree shaking if you use named imports from specific modules.

// named imports from specific modules
import { string as stringParam, oneOf } from "@decsys/param-types/builders";

// default imports from specific modules
import buildPropTypes from "@decsys/param-types/buildPropTypes";

// default or named imports from the package
import paramTypes, { buildPropTypes } from "@decsys/param-types";

ES Modules only?

param-types is only provided as untranspiled ES Modules.

It only depends on prop-types but that should be fulfilled as a peer dependency by the package using it (ultimately the Survey Platform).

DECSYS Components are expected to be written and exported as ES Modules (though bundled with their dependencies).

Due to the scope of use of param-types, other module formats, or direct browser use support do not seem necessary.

Use in the DECSYS Survey Platform

The DECSYS Survey Platform contains some built-in components which all use param-types to specify their params.

The Platform's Component Editor uses the param-types type constants to avoid magic strings, and it uses the params specs of loaded components in order to provide a good parameter configuration experience in the UI.

Licensing

Overview

This software is primarily licensed under the GNU Affero General Public License v3.0 only (AGPL-3.0-only).

A summary is provided below; the full license text may be found in LICENSE.md.

Other license arrangements may be made as appropriate on request.

Copyright and License Summary

DECSYS Param Types

Copyright (C) 2019 Christian Wagner, LUCID (Lab for Uncertainty in Data and Decision Making)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.