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

clouddirectory-client

v0.1.1-3

Published

JavaScript convenience wrapper for the AWS Cloud Directory API.

Downloads

3

Readme

Build Status Codecov GitHub license sponsored by

AWS Cloud Directory Client

JavaScript convenience wrapper for the AWS Cloud Directory API.

Example

const CloudDirectoryClient = require('clouddirectory-client');

let client = new CloudDirectoryClient({
  DirectoryArn: '',
  Schema: 'myschema/1', // schema name / major version
});

let index = await client.createIndex({
  IndexName: 'sensors',
  IndexedAttributes: [{ sensor: 'sensor_id' }],
});

client.createObject({
  Attributes: {
    sensor: { sensor_id: 'abc123123' },
  },
  Parents: [{
    Selector: '/floors/ground_floor/server_room',
    LinkName: 'abc123123',
  }],
  Indexes: ['/sensors'],
  IncomingTypedLinks: [{
    Selector: '/floors/ground_floor',
    Attributes: {
      sensor_floor_association: {
        sensor_type: 'water',
        maintenance_date: '2015-04-03',
      },
    },
  }],
});

let sensors = client.listIncomingTypedLinks('/floors/ground_floor', {
  FloorSensorAssociation: { sensor_type: 'water' }
}).iterate();
for (let sensor of sensors) {
  console.log(await sensor);
}

Constructor

new CloudDirectoryClient(options = {}) : Object

Options Hash (options):

  • DirectoryArn (String, required), the Amazon Resource Name (ARN) that is associated with the Directory where the object resides.
  • AppliedSchemaArn (String, required), the Amazon Resource Name (ARN) that is associated with the schema.
  • Client (String), instance of AWS.CloudDirectory. Defaults to new AWS.CloudDirectory().
  • MaxResults (Number), maximum number of items to be retrieved in a single call. Defaults to 10, max value is 30.
  • ConsistencyLevel (String), represents the manner and timing in which the successful write or update of an object is reflected in a subsequent read operation of that same object. Possible values include: SERIALIZABLE and EVENTUAL (default).

Arguments

selector

The selector argument is ubiquitous and can take the following shape:

  • Path /path/to/my/object
  • Object Identifier $AQFnK8iyN7pMTbkTyChgMF7N8WyQmgMnRLS4yPVJfYRDQA
  • List of Path Segments ['path', 'to', 'object'] (the leading slash is optional)

Methods

attachObject

Resolves to null

client.attachObject(parentSelector, childSelector, linkName);

attachTypedLink

Resolves to null

client.attachTypedLink(sourceSelector, targetSelector, {
  [facetName]: { [attributeName]: attributeValue },
});

createIndex

createObject

deleteIndex

Resolves to null

client.deleteIndex(selector);

deleteIndex will detach an index from all its parents before it is deleted. This method will not attempt to remove all links to any children (which would orphan the children unless they have other parents). If the deletion of the index fails due to attached children, the whole transaction is rolled back.

deleteObject

Resolves to null

client.deleteObject(selector);

deleteObject will detach an object from all its parents and indices before it is deleted. This method will not attempt to remove all links to any children (which would orphan the children unless they have other parents). If the deletion of the object fails due to attached children, the whole transaction is rolled back.

detachAllFromIndex

Resolves to null

client.detachAllFromIndex(indexSelector);

Detaches all objects from the specified index.

detachFromIndex

Resolves to null

client.detachFromIndex(indexSelector, objectSelector);

Detaches the specified object from the specified index.

detachObject

Resolves to null

client.detachObject(parentSelector, linkName);

listAttachedIndices

Returns IterableResultSet

client.listAttachedIndices(selector);

listIncomingTypedLinks

Returns IterableResultSet

client.listIncomingTypedLinks(selector, {
  [facetName]: {
    [attributeName]: 'STRING_VALUE',
  },
});

listIndex

Returns IterableResultSet

client.listIndex(selector, {
  [facetNameA]: {
    [attributeName]: 'STRING_VALUE',
  },
  [facetNameB]: {
    [attributeName]: 'STRING_VALUE',
  },
});

listObjectAttributes

Returns IterableResultSet

client.listIncomingTypedLinks(selector, facetName?);

listObjectChildren

Returns IterableResultSet

listObjectParentPaths

Returns IterableResultSet

listObjectParents

Returns IterableResultSet

listObjectPolicies

Returns IterableResultSet

listOutgoingTypedLinks

Returns IterableResultSet

listPolicyAttachments

Returns IterableResultSet

lookupPolicy

Returns IterableResultSet

IterableResultSet

IterableResultSet is returned by all list* and lookup* methods. It's a convenience wrapper for the paging API provided by AWS Cloud Directory. Instead of having to page through results this class provides a iterable result set.

let users = client.listObjectChildren('/users').iterate();
for(let user of users) {
  console.log(await user);
}

resultset.addTransformation

resultset.all

resultset.iterate

resultset.request

Paging and Scrolling

The list* operations return a generator that allows you to scroll through result sets efficiently. The Cloud Directory API implements paging through the NextToken parameters.

let client = new CloudDirectoryClient({ MaxResults: 15 }); // defaults to 10, max. value is 30
let users = client.listObjectChildren('/users');
for(let user of users) {
  console.log(await user);
}

Let's assume we have 100 objects attached to /users that we want to scroll over. With MaxResults set at 15, there will be a total 7 requests made to retrieve all objects. The Cloud Directory API doesn't support skipping object when listing results.