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

use-case

v0.0.9

Published

UML Use-case implementation for large Applications

Downloads

8

Readme

Use-case

This library aims to effectively plan the software development by following UML Use-case based from User Stories. Use-case manifests will be detailed later by adding use-case relationships and activity workflows using Apptivity package.

Installation

Use-case is packaged by npm. Source can be found in github repository.

npm install use-case --save

Usage

To better understand how to use this library, we are going to run through a quick start guide.

Quick Start Guide

1. Translate User Stories into Use-case manifest using use-case definition objects.

The following are the User Stories gathered from the My Auth Website app.

  1. As a visitor, I can visit the public area of the system.
  2. As a visitor or guest, I can login and change my role into admin.
  3. As an admin, I can logout and change my role back into visitor.
  4. As an admin, I can update my profile in the users control panel.

Below is the sample translation of User Stories into Use-cases using use-case definition object.

var USECASE = require("use-case");
USECASE.system("My Auth Website").
        as("guest").
            emulating("visitor").
        as("visitor").
            accessing("public area").
                can("visit web pages").
                can("login").
                    soThat("I can change my role into admin.",
                    		"Or, change role depending on what is assigned after server authentication.").
        as("admin").
            accessing("private area").
                can("logout").
                    soThat("I can be a visitor/guest again.").
            accessing("users control")
                can("update my profile").
                    soThat("I can customize my something-whatever.");

2. Further detail the Use-cases and Activities.

Use-cases can be defined further into subjects namespace and specific use-case. When usecases and it's relationships are all defined, their equivalent activities should also be defined to complete the whole Use-case definitions.

var myApp = USECASE.system("My auth website");

// don't worry, system, subject, usecase, and actors are case-insensitive
myApp.subject("Public area").
		usecase("navigate").
        usecase("login").
        	extend("get auth info"),
            include("authenticate");

// here you're going to define activity of the defined usecases
myApp.activity("public area", "navigate").
		input("choosePage").
        action("navigate");

myApp.activity("public area", "login").
		action("validate");

myApp.activity("public area", "get auth info").
		action("showLoginPage").
        input("authData");

myApp.activity("public area", "authenticate").
		action("authenticate").
        	handler(function (input) {
            	console.log("authenticating to backend? ", input);
            	return client.authToBackend(input);
            }).
		action("setAuthToken");

The example above is for demo purposes only. That is why, Activity definitions and implementations were defined in one script file. The best practice in coding Apptivity is to split definitions (like the action("setAuthToken"); line above.) from implementations using Apptivity.task(name:String, runner:Function) method in a separate implementation script file.

3. Run a completely defined Use-case.

Complete Use-cases are use-cases having complete definitions of Actor, Subject, optional Usecase relationships, and Activity within the System. Use-cases cannot run using the code below if it is not completely defined.


USECASE("My auth website://guest@public area/visit web pages").
	on("state-change",
    	function (process, state) {
        	console.log("current state ", state.toJS());
        }).
    on("prompt",
    	function (process, action, initialInput) {
        	console.log("what to do with prompts? ", action, initialInput);
            process.answer({ value: "my answer to this prompt." });
        }).
    run({ page: "/about_us.html" }).
        then(function (result) {
            console.log("showing about us? ", result);
            return result;
        },
        function (error) {
            console.log('yes! an error!', error);
            return Promise.reject(error);
        });

Documentation

Detailed documentation including API can be found here.

License

This Project is fully Open Source MIT licensed.