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

appc-registry-sdk

v0.0.6

Published

Appcelerator Registry SDK

Downloads

5

Readme

Appcelerator Registry SDK for Node.js

This is a node module which provides a JavaScript API for accessing the Appcelerator Registry.

Build Status

Installation

You can install via npm or directly include the library in your node application.

Once installed, you can use the module by requiring it.

NOTE: You must set the baseurl to the correct URL location of the server endpoint.

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';

Security

To enable, you must first login using the API login. After a successful login, you must call API.session = result.session where result is the return value from the login API call.

Example code:

var api = new API("login");
API.baseurl = "http://localhost:8080";
api.body({"username":"[email protected]","password":"arrowrocks"});
api.send(function(err,resp,body){
	if (err) { throw err; }
	API.session = body.session;
	api = new API("whoami");
	api.send(function(err,resp,body){
		if (err) { throw err; }
		console.log(body);
	});
});

APIs

login

API for login

POST /api/login

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- username | username | body | yes password | password | body | yes org_id | organization id | body | yes ipaddress | the machine ip address | body | yes fingerprint | the machine unique id | body | yes fingerprint_description | the machine description | body | yes

API Result session

Name | Description | Type :----| :---------- | :--- username | username | string password | password | string org_id | organization id | number org_name | organization name | string session | encrypted session token | string ipaddress | the machine ip address | string fingerprint | the machine unique id | string fingerprint_description | the machine description | string expiry | expiration timestamp in milliseconds | number firstname | first name of the user | string lastname | last name of the user | string sid | session sid | string dashboard | dashboard url used for session | string

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('login');
api.body({
	"username": "",
	"password": "",
	"org_id": "",
	"ipaddress": "",
	"fingerprint": "",
	"fingerprint_description": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

listOrganizations

API for determing the logged in user organizations

GET /api/orgs

API Result org

Name | Description | Type :----| :---------- | :--- org_id | the organization guid | number name | the name of the organization | string active | the active flag for the organization | boolean

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('listOrganizations');
api.send(function(err,resp,json){
	console.log(json);
});

switchLoggedInOrg

API for switching a logged in user org

PUT /api/org

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- org_id | the organization id | body | no

API Result org

Name | Description | Type :----| :---------- | :--- org_id | the organization guid | number name | the name of the organization | string active | the active flag for the organization | boolean

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('switchLoggedInOrg');
api.body({
	"org_id": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

whoami

API for determing the logged in user

GET /api/whoami

API Result session

Name | Description | Type :----| :---------- | :--- username | username | string password | password | string org_id | organization id | number org_name | organization name | string session | encrypted session token | string ipaddress | the machine ip address | string fingerprint | the machine unique id | string fingerprint_description | the machine description | string expiry | expiration timestamp in milliseconds | number firstname | first name of the user | string lastname | last name of the user | string sid | session sid | string dashboard | dashboard url used for session | string

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('whoami');
api.send(function(err,resp,json){
	console.log(json);
});

listComponents

API for fetching all the components

GET /api/component

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- limit | max number of components to return | query | yes

API Result component

Name | Description | Type :----| :---------- | :--- created_date | date the component was published | date file_id | foreign key to the file object | string filesize | the component file size | number parts_count | the component count in the case of split files | number parts_index | the component index in the case of split files | number parts_total | the component total size in the case of split files | number parts_shasum | the component sha of the part in the case of split files | number shasum | the component sha1 | string name | the name of the component | string component | the full component name | string description | the description of the component | string version | the version of the component | string version_sortable | the field that is used for sorting by version | number type | the metadata type of the component | string subtype | the component plugin subtype | string owners | the owners of the component | array orgs | the orgs of the component | array users | the users of the component | array access | the access type such as private, public, etc | string author | the component author name | string author_id | the component author user guid | string author_username | the component author username | string unpublished | return true if the component has been unpublished | boolean package_json | the contents of the package.json | string

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('listComponents');
api.json({
	"limit": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getComponent

API for fetching all the components

GET /api/component/:type/:nameversion

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | type of the component to get the details | path | no nameversion | name and version of the component to get the details | path | no

API Result component

Name | Description | Type :----| :---------- | :--- created_date | date the component was published | date file_id | foreign key to the file object | string filesize | the component file size | number parts_count | the component count in the case of split files | number parts_index | the component index in the case of split files | number parts_total | the component total size in the case of split files | number parts_shasum | the component sha of the part in the case of split files | number shasum | the component sha1 | string name | the name of the component | string component | the full component name | string description | the description of the component | string version | the version of the component | string version_sortable | the field that is used for sorting by version | number type | the metadata type of the component | string subtype | the component plugin subtype | string owners | the owners of the component | array orgs | the orgs of the component | array users | the users of the component | array access | the access type such as private, public, etc | string author | the component author name | string author_id | the component author user guid | string author_username | the component author username | string unpublished | return true if the component has been unpublished | boolean package_json | the contents of the package.json | string

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getComponent');
api.params({
	"type": "",
	"nameversion": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

plugins

API for listing plugins

GET /api/plugin/:type/:subtype

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of component | path | no subtype | the subtype of the plugin | path | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('plugins');
api.params({
	"type": "",
	"subtype": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

publish

API for publishing a component

POST /api/publish

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- file | file to publish | body | no package.json | contents of the package.json | body | no parts_count | the component count in the case of split files | body | yes parts_index | the component index in the case of split files | body | yes parts_total | the component total in the case of split files | body | yes parts_shasum | the component sha of the part in the case of split files | body | yes shasum | the component sha1 | body | no force | overwrite if already published with the same version | body | yes subtype | the subtype of the component | body | yes

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('publish');
api.body({
	"file": "",
	"package.json": "",
	"parts_count": "",
	"parts_index": "",
	"parts_total": "",
	"parts_shasum": "",
	"shasum": "",
	"force": "",
	"subtype": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

search

API for searching for components

GET /api/search/:term/:filter?

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- term | the search term | path | no filter | the search term filter | path | yes

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('search');
api.params({
	"term": "",
	"filter": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

unpublish

API for unpublishing a published component

GET /api/unpublish/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | type of the component | path | no name | name of the component | path | no version | version of the component | path | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('unpublish');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getAccess

API for getting component access level

GET /api/access/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getAccess');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

setAccess

API for setting component access level

PUT /api/access/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no access | the access of the component | body | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('setAccess');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"access": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getAppc

API for listing the AppC packages

GET /api/appc/install/:version?

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- version | the version of the package | path | yes

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getAppc');
api.params({
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

listAppc

API for listing the AppC packages

GET /api/appc/list

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('listAppc');
api.send(function(err,resp,json){
	console.log(json);
});

installs

API for getting a list of components locations to install

GET /api/install

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- components | components to install | body | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('installs');
api.body({
	"components": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

install

API for installing a specific component

GET /api/install/:token

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- token | the one-time install token | path | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('install');
api.params({
	"token": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

addOrg

API for adding an org for a component

POST /api/org/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no org_id | the org_id to add | body | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('addOrg');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"org_id": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

deleteOrg

API for removing an org from a component

DELETE /api/org/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no org_id | the org_id to remove | body | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('deleteOrg');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"org_id": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getOrg

API for getting the orgs for a component

GET /api/org/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getOrg');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

addOwner

API for adding an owner to a component

POST /api/owner/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no user | the user to add | body | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('addOwner');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"user": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

deleteOwner

API for removing an owner of a component

DELETE /api/owner/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no user | the user to remove | body | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('deleteOwner');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"user": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getOwner

API for getting the owners of a component

GET /api/owner/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getOwner');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

addUser

API for adding a user to a component

POST /api/user/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no user | the user to add | body | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('addUser');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"user": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

deleteUser

API for removing a user from a component

DELETE /api/user/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no user | the user to remove | body | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('deleteUser');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"user": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getUser

API for getting users of a component

GET /api/user/:type/:name/:version

API Parameters

Name | Description | Type | Optional :----| :---------- | :--- | :------- type | the type of the component | path | no name | the name of the component | path | no version | the version of the component | path | no

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getUser');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

Other SDK APIs

The following additional APIs are available:

API.baseurl

Set the base url for the Arrow server.

Usage Example

API.baseurl = 'http://localhost:8080';

api.json

Set the JSON body.

Usage Example

api.json({
	foo: true
});

api.body

Set the body. The body can include one or more files (provide a valid file path as the value) to automatically send multipart/form-data. To specify a file for uploading, pass an instance of a stream.Readable.

Usage Example

api.body({
	file: fs.createReadStream('/path/to/myfile.json'),
	name: 'this is a name'
});

api.query

Set query parameters for the URL. These will automatically be appended correctly to the request URL.

Usage Example

api.query({
	pretty_json: true
});

api.params

Set URL parameters in the request URL.

Usage Example

api.params({
	username: 'test'
});

api.header

Add an HTTP request headers.

Usage Example

api.header('X-Foo','Bar');

You can add multiple headers by chaining the methods:

api.header('X-Foo','Bar')
	.header('X-Bar','Foo');

API.debug

Turn on/off debug logging.

Usage Example

API.debug = false;

You can set either by passing debug in API constructor as part of the config object (first parameter) or by setting the environment variable DEBUG to arrow:sdk.

Usage Example

var api = new API({debug:true},'/api/login');
DEBUG=arrow:sdk node app

Events

The following events can also be listened to:

  • error: fired when an error occurs during an API request
  • response: fired when an API response is received
  • timeout: fired when an API request times out

Usage Example

var api = new API('myapi')
	.on('error',function(err){
		console.error("An error occurred.",err);
	})
	.on('timeout',function(err){
		console.error("A timeout occurred.",err);
	})
	.on('response',function(resp,json){
		console.log(json);
	})
	.send({
		username: 'foo',
		password: 'bar'
	});

Dependencies

To use this library, you must add an appropriate npm dependency for the request library. It can be any of the following compatible modules:

Add the appropriate request module to your package.json dependencies.

Notes

This SDK was generated using the Appcelerator Arrow SDK generator. Generated on Fri Feb 13 2015 08:41:07 GMT-0800 (PST) by [email protected].