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

@smartcloud/compliance

v2.5.61

Published

Common Compliance code and type definitions

Downloads

953

Readme

SmartCloud Compliance SDK

Installation

It is recommended to use the latest version of this SDK. To install:

npm install @smartcloud/compliance@latest

Getting started

To intialise the client, either apiSecret or a tokenGetter function must be supplied in order to be authenticated.

const client = new ComplianceClient(config);

Configuration:

interface ComplianceBaseConfig {
    basePath: string; // SmartCloud API base path
    apiKey: string; // Your SmartCloud API key
    // Optional override for getting user
    user?: {
        id: string; // Your SmartCloud user ID
        email?: string;
        name?: string;
        alias?: string; // Your name alias
    }
    // At least one of either
    apiSecret: string;  // Your SmartCloud API secret
    tokenGetter: () => Promise<string>; // Getter function to get your Firebase Token periodically
}

Features

Cases

To access cases from an organization.

const cases = client.cases(orgId);

Cases returned by the SDK are wrapped in a Case class with unique features depending on the type of case

Get cases by modification date

Cases returned are ordered where the most recently updated case is returned first.

const caseStream = cases.getCasesByModification({ latest: Date.now(), oldest: 0, fullCase: false });
caseStream.on('data', (caseList) => {
    // Do something with case list
});
caseStream.on('end', () => {
    // Finished
});

Get cases by creation date

Cases returned are ordered where the most recent case is returned first.

const caseStream = cases.getCasesByCreation({ latest: Date.now(), oldest: 0, fullCase: false });
caseStream.on('data', (caseList) => {
    // Do something with case list
});
caseStream.on('end', () => {
    // Finished
});

Get cases by URI

Get up to 40 cases by URI

const caseList = await cases.getCasesByURI(['uri1', 'uri2', 'uri3'], fullCase: false);

Case

The case class can be used to directly modify a case and/or it's events. Currently the only supported case type is Parking, though a generic class can be used to manage custom cases. Supported cases may have unique methods or handle specific use cases differently

Event getters

Getter methods for specific known event types are available

  • Metadata getMetadataEvent
  • Case ID getCaseIdEvent
  • Cancel getCancelledEvent
  • Close getClosedEvent
  • Breach getBreachEvent
  • Breach Appeal getBreachAppealEvents
  • Breach Reminder getBreachReminder

Additionally, you may get a specific event through these methods:

  • Get event by type:
const event = await case.getEventByType(type);
  • Get event by ID:
const event = await case.getEventById(eventId);

Case Updaters

Updater methods can be used to update case metadata information. Methods: assignOfficer updateGroups updateSiteLocation updateLocation addNotes editNotes deleteNotes updatePriority

Case Actions

Actions can be taken upon a case that may result in changing it's state or events. Methods: issueBreach closeCase openCase cancelCase

🚘 Parking Case

Methods: getParkingSessionEvent

Parking Session Event

Methods: getOffenses getParkingSessionVersion

Events

Each case may have multiple events which hold specific data relating to that event type Methods: updateEvent Event.createUnpublished

To publish a new event to a case:

const event = await case.postNewEvent(newEvent);

Similarly, an event can also be deleted from a case:

await case.deleteEvents(eventIds);

Example Code

const cases = client.cases('org1');
const myCase = await cases.createCase<ParkingCase>('Parking', [{
    type: 'Metadata',
    data: {
        groups: ['org1#org1', 'org1#region1', 'region1#site1'],
        metadata: {
            location: {
                latitude: 0,
                longitude: 0,
                openLocationCode: 'xxxxx',
            }
            priority: 1,
        }
    }
  }
]);
await myCase.addNotes({ text: 'My first note' });

const metadataEvent = myCase.getMetadataEvent();
await metadataEvent.updateEvent({
    ...metadataEvent.data,
    metadata: {
        ...metadataEvent.metadata,
        custom: {
            foo: 'bar',
        }
    }
  }
);

await myCase.closeCase('special-circumstance');

Compliance Configuration

To access compliance configuration for an organization:

const configuration = await client.configuration(orgId);

Methods: getConfig addConfig updateConfig deleteConfig addCatalog deleteCatalog toJSON Configurations hold an array of grouped configurations. Each grouped configuration also contains an array of sub group configurations. Currently the only supported configuration is Parking. However, generic configurations can also be managed.

const parkingConfig = configuration.getConfig({ type: 'Parking' });
// full config JSON object including absent property values
const object = parkingConfig.toJSON();

Group Config

Currently only the Parking and Animal configuration types are supported. However, generic configurations can also be managed.

🚘 Parking Configuration

Methods: getTicketTemplate getTicketTemplateData Getter methods are supplied for known catalog types

  • Policies (Time based overstay, no payment, payment overstay)
  • Vehicle Makes
  • Vehicle Types
  • Vehicle States
  • Vehicle Colours
  • Bay Types
  • Substates
  • Substate Triggers
  • Trigger Actions
  • Common Notes
  • Cancel Reasons
  • Close Reasons