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

gits-assignment-service

v1.1.0

Published

Client library for GITS Assignment Service

Downloads

1

Readme

GITS Assignment Management Service

This is a NodeJS client library for GITS Assignment Management Service.

Structure

An assignment usually look like this :

{
  "_id": string_uuid_v4,
  "title": string,
  "description": string,
  "creation_date": integer_timestamp_in_seconds, // example: 1507000739
  "due_date": integer_timestamp_in_seconds,
  "update_date": integer_timestamp_in_seconds,
  "assignee": {
    "id": some_value, // could be string or interer, up to you
    ... // your custom fields, example: name, department_id, type, email, etc
  },
  "assignor": {
    "id": some_value, // could be string or interer, up to you
    ... // your custom fields, example: name, department_id, type, email, etc
  },
  "created_by": {
    "id": some_value, // could be string or interer, up to you
    ... // your custom fields, example: name, department_id, type, email, etc
  },
  "updated_by": {
    "id": some_value, // could be string or interer, up to you
    ... // your custom fields, example: name, department_id, type, email, etc
  },
  "state": {
    "id" : string, // the state id, for state references, keep scrolling
  },
  "extras": {
    ... // your custom fields, example: name, department_id, type, email, etc
  },
  "logs": [
    {
      "date": 12312,
      "type": "edit",
      "context": {
        ... // your custom fields, example: name, department_id, type, email, etc
      }
    },
    
  ]
}

A "State" looks like this

{
  "_id": "",
  "name": "",
  "nexts": [ "next_state_id_1", "next_state_id_2" ]
}

State Workflow

A state has a nexts field. This field contains array of state ids. Let's say an assignment is in a state called pending. The pending state has nexts which is [ 'active', 'invalid', 'rejected' ]. That means pending state can only move forward to one of those three states.

Installation

npm install --save gits-assigntment-service

Register

  • Before you can use this service, you need to register first. Run this curl command
curl -X POST \
  http://159.203.169.253:3040/application/create \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'postman-token: a7bc2296-9215-6c0f-5010-6d7667bd65b3' \
  -d '{
	"name" : "<app-name>",
	"url": "<app-url>",
	"country": "<a-valid-country-code>",
	"email" : "<an-email-address-for-login>",
	"password": "<md5-string>"
}'
  • Save your app Id (apiKey) and app secret.
  • If you lost them, make a request at /application/login
curl -X POST \
  http://159.203.169.253:3040/application/login \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'postman-token: 37b17eb5-cb83-6178-d230-fdcc323775e7' \
  -d '{
	"email": "<your-email>",
	"password": "<md5-string>"
}'

Usage

const assignmentService = require('gits-assignment-service');

// mandatory
assignmentService.key("your-app-key");
assignmentService.secret("your-app-secret");

// a user is just an object with at least an id field (String)
assignmentService.user({ id: 'qwerty' }); 

// optional
// verbosity
assignmentService.verbose({error: 1, result: 1, info: 1});

Assignment API

Get Assignments

assignmentService.assignment.get( query, sort, limit, callback );

This api will return an array of assignments

  • query is an object. It's structure follows mongodb query structure. ex: {_id: 'qwerty'} will find any assignment with _id equals qwerty
  • sort is an object. It's structure follows mongodb $sort structure of mongodb aggregation. Detail here.
  • limit is a positive integer
  • callback is a standard es6 callback. (err, result) => {}

Get Assignments (Pagination Mode)

assignmentService.assignment.get( query, sort, limit, page, callback );
  • page is an integer

This api will return an object like this :

{
    "list": [ /** list of assignments */ ],
    "page": {
        "total_page": 3,
        "total_data": 7,
        "current_page": 2
    }
}

Create Assignment

assignmentService.assignment.create( {
	"title": "fancy title",
	"description": "order from Vitsa",
	"creation_date": 1507631751,
	"updated_date": 0,
	"due_date": 1507770000,
	"assignee": { "id": "[email protected]", "name": "Rahadian Ahmad" },
	"assignor": { "id": "[email protected]", "name": "Ragil Kamal" },
	"extras": {},
	"stateId": "a-workflow-id"
}, callback )

This api will return the newly created assignment (String).

Edit Assignment

assignmentService.assignment.edit( query, update, callback );

This api will return an integer indicating how many documents was edited.

  • update is an object. It's structure follows mongodb update command. Details here

Delete Assignment

assignmentService.assignment.delete( query, callback );

This api will return an integer indicating how many assignments was deleted

Change State

assignmentService.assignment.changeState(assignmentId, newWorkflowId, callback);

This api will return the updated id.

Workflow API

Workflow is a collection of states. A state has nexts field. nexts field could contain 0 state or a fuckton of states.

Create a State

assignmentService.workflow.create({
	"before": [ /** before ids  */ ], // array of string
	"state": {
		"name": "some-name",
		"type": "some-type",
		"next": [ /** next ids */ ] // array of string
	}
}, callback )

This api will return the newly created id

Delete a State

assignmentService.workflow.delete(stateId, callback);

This api will return the just deleted id.

Get state's next states

assignmentService.workflow.getNexts(stateId, callback);

This api will return an array of states

Get all states

assignmentService.workflow.getAll(callback);

This api will return all your states. (without their nexts field)

Add nexts to a state

assignmentService.workflow.addNexts(stateId, [ 'id-1', 'id-2', ... , 'id-n' ], callback);

This api will return the newly updated id

Remove nexts to a state

assignmentService.workflow.removeNext(stateId, [ 'id-1', 'id-2', ... , 'id-n' ], callback);

This api will return the newly updated id

Contributor / Contact

How to Contribute

  1. Make a pull request / merge request