bundle-registry-adaptor

1.0.1 • Public • Published

Repository for the dynamodb centered bundle registry client. The client can be installed in any nodejs project using npm. The client provides functional api with the following methods:

Registry a new bundle for a front end resource. Returns a bundle object that includes an id (uuid) and created_at with time created

register(bundle)

bundle = {
    resourceName,  //namespace for the resource it will be a version of
    url, //location of the resource
    label //optional label to search bundle in registry
}

Get a bundle by id. Returns a bundle. Throws error if not found.

getBundle(id)

returns {
    id, //unique ID
    resourceName,  //namespace for the resource it will be a version of
    url, //location of the resource
    label, //optional label to search bundle in registry
    created_at //time the bundle was registered
}

Associates a bundle to an environment. An environment has 1 bundle of a resource

  • environment: name space defined by the application.
  • resourceName: resource bundle is a version of.
setEnvironmentResource(environment, resourceName)

Get the bundle of a resource associated with an environment.

environment: name space defined by the application. resourceName: resource bundle is a version of.

setEnvironmentResource(environment, resourceName)

return {
    id, //unique ID
    resourceName,  //namespace for the resource it will be a version of
    url, //location of the resource
    label, //optional label to search bundle in registry
    created_at //time the bundle was registered    
}

Get a list of the bundles (in descending order of creation time) for a specific resource with a specific label.

getLabel(resourceName, label)

returns [
    ...
    {
        items {
            id, //unique ID
            resourceName,  //namespace for the resource it will be a version of
            url, //location of the resource
            label, //optional label to search bundle in registry
            created_at //time the bundle was registered                
        }
    }
    ...
]

Get the bundle history of a resource

getBundleHistory(resourceName, options)

resourceName: name space of the resource
options : the following options are supported
             - limit: max number of bundles to retrieve
             - start: offset to get bundles from, use for pagination.  Assign start to the LastEvaluatedKey field returned from the previous request to getStableBundleHistory

returns [
    {
        items: {
            id, //unique ID
            resourceName,  //namespace for the resource it will be a version of
            url, //location of the resource
            label, //optional label to search bundle in registry
            created_at //time the bundle was registered                            
        },
        LastEvaluatedKey: LastEvaluatedKey
    }
]

Initialize the dynamodb tables if they do not exist.

initTables()

Development

Docker is needed for local development.

  • Run the local dynamodo container by running docker-compose up in the project root.
  • scripts/test-driver.js is a node script that will initialize the tables in local dynamodb, add a number of bundles and associations, and output the values. You can use the script to validate the adaptor methods against a real service.

Test

run npm test to execute the unit tests

Readme

Keywords

none

Package Sidebar

Install

npm i bundle-registry-adaptor

Weekly Downloads

2

Version

1.0.1

License

UNLICENSED

Unpacked Size

117 kB

Total Files

12

Last publish

Collaborators

  • gliffy_admin