Skip to content

Node.js client library for Pangea Services

Notifications You must be signed in to change notification settings

mcombspangea/node-pangea

Repository files navigation


Pangea Logo


documentation Slack


Pangea Node SDK

A javascript SDK for using Pangea APIs in a Node application.

This package is provided with support for ESM and CommonJS.

Installation

yarn add node-pangea
# or
npm install node-pangea

Usage

import { PangeaConfig, AuditService } from "node-pangea";

const domain = process.env.PANGEA_DOMAIN;
const token = process.env.PANGEA_TOKEN;
const configId = process.env.AUDIT_CONFIG_ID;
const config = new PangeaConfig({ domain: domain, configId: configId });
const audit = new AuditService(token, config);

// log an audit event
const data = {
  actor: "[email protected]",
  action: "update",
  status: "success",
  message: "delete record",
};
const logResponse = await audit.log(data);

// search an audit log
const searchResponse = await audit.search("message:delete", {
  limit: 10,
  verify: true,
});

searchResponse.result.events.forEach((row) => {
  console.log(
    row.event.received_at,
    row.event.actor,
    row.event.action,
    row.event.status,
    row.event.message,
    row.event.membership_proof,
    row.event.consistency_proof
  );
});

Contributing

Currently, the setup scripts only have support for Mac/ZSH environments. Future support is incoming.

To install our linters, simply run ./dev/setup_repo.sh These linters will run on every git commit operation.

Generate SDK Documentation

Overview

Throughout the SDK, there are jsdoc strings that serve as the source of our SDK docs.

The documentation pipeline here looks like:

  1. Write jsdoc strings throughout your code. Please refer to existing jsdoc strings as an example of what and how to document.
  2. Make your pull request.
  3. After the pull request is merged, go ahead and run yarn run --silent print:docs:json to generate the JSON docs uses for rendering.
  4. Copy the output from yarn run --silent print:docs:json and overwrite the existing js_sdk.json file in the docs repo. File is located in platform/docs/openapi/js_sdk.json in the Pangea monorepo. Save this and make a merge request to update the Python SDK docs in the Pangea monorepo.

Running the autogen sdk doc script

Make sure you have all the dependencies installed. From the root of the node-pangea repo run:

yarn install

Now run the script

yarn run --silent print:docs:json

That will output the script in the terminal. If you're on a mac, you can run the script and copy the output to your clipboard with

yarn run --silent print:docs:json | pbcopy

About

Node.js client library for Pangea Services

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published