0.8.0 • Published 2 years ago

@vista.io/vista-api-client v0.8.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Vista API for NodeJS

NodeJS client for the Vista API.

Reference

Prerequisites

You'll need to create a Vista API key from the Vista Dashboard.

Usage

Install the package:

npm install @vista.io/vista-api-client;

Then in your Node application:

import VistaClient from '@vista.io/vista-api-client';

const VISTA_API_KEY = 'create-in-vista-dashboard';
const client = new VistaClient(VISTA_API_KEY, 'branch_name');
const roles = client.roles.list()

After that you are good to go!

Please see the Vista API Documentation for the API documentation.

All Operator

You can use VistaClient.ALL in place where resource_id or resource_type is accepted to indicate all.

Changing Branches for Operation

Although branch is required as a part of the constructor, one may use client.withBranch(branch: string) to use supply a different branch using the same client.

Usage

The following describes methods namespaced by Vista resources.

Admin

client.admin

methoddescription
createBranch(branch: string)Creates a set of read-only tokens meant to be used by Vista React components
cloneBranch(branch: string, newBranch: string)Clones templates in branch to newBranch
createReadTokens()Creates a set of read-only tokens meant to be used by Vista React components
getCompany()Gets Company ID

Resource Types

client.resourceTypes

methoddescription
list()Lists all Resource Types
upsert(name: string, actions: string[], attributes: {id: string, target_resource_type: string, attribute_type: 'RELATIONSHIP' \| 'SCALAR'}[])Upserts a Resource Type
addRelationship(fromId: string, fromResourceType: string, attribute: string, toId: string, toResourceType: string)Adds an attribute relationship between 2 resourceIds

Roles

client.roles

methoddescription
client.roles.list(orgId?: string)Lists all Roles
client.roles.upsert(roleId: string, permissions: { resourceType: string, attribute: string, action: string, ownerId: string }[] owners: { key: { query: string, dbId: string } }, arentRoles: string[], orgId: string)Upserts a Role

Users

client.users

methoddescription
create(userId: string, orgId: string)Creates new User
list(orgId?: string)Lists Users in orgId
listOrgs()Lists all orgs for set branch
assignToUserset(userId: string, usersetId: string)Adds User to a Userset
removeFromUserset(userId: string, usersetId: string)Removes User from Userset
check(userId: string, action: string, resourceType: string, resourceId: string, attribute?: string)Checks User access
expand(userId: string)Returns all permissions for users (action, resource_type, resource_id)
grantAction(userId: string, action: string, resourceType: string, resourceId: string, attribute?: string?)Allows User to perform action on (resourceId, resourceType)
revokeAction(userId: string, action: string, resourceType: string, resourceId: string, attribute?: string?)Revokes action on (resourceId, resourceType) for User
grantRole(userId: string, roleId: string, resourceType: string, resourceId: string)Grants Role to User
revokeRole(userId: string, roleId: string, resourceType: string, resourceId: string)Revokes Role from User

Usersets

client.usersets

methoddescription
create(userId: string, orgId: string)Creates Userset
inherit(childRoleId: string, parentRoleId: string)Adds Userset as child of parent Userset
grantAction(userId: string, action: string, resourceType: string, resourceId: string, attribute?: string)Allows User to perform action on (resourceId, resourceType)
revokeAction(userId: string, action: string, resourceType: string, resourceId: string, attribute?: string)Revokes action on (resourceId, resourceType) for Userset
grantRole(userId: string, roleId: string, resourceType: string, resourceId: string)Grants Role to Userset
revokeRole(userId: string, roleId: string, resourceType: string, resourceId: string)Revokes Role from Userset

Grants

client.grants

methoddescription
list(userId: string \| null, action: string \| null, resourceId: string \| null, resourceType: string \| null, attribute: string \| null, orgId: string \| null, startTime: string \| null, endTime: string \| null)List & filter grants by arguments, startTime is inclusive (>=) and endTime is exclusive (<)
listUnflattened(usersetId: string \| None, relation: string \| None, relationType: string \| None, resourceId: string \| None, resourceType: string \| None, attribute: string \| None, orgId: string \| None)Filters User or Userset grants

Blueprint

client.blueprint

methoddescription
upsert(fpath: string)Upserts branches, resource types, and roles defined in blueprint file (yaml or json). fpath is the relative path to the vista config file.
0.8.0

2 years ago

0.7.6

2 years ago

0.7.5

2 years ago

0.7.7

2 years ago

0.7.2

2 years ago

0.7.1

2 years ago

0.7.4

2 years ago

0.7.3

2 years ago

0.7.0

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.4.10

2 years ago

0.4.13

2 years ago

0.4.14

2 years ago

0.4.11

2 years ago

0.4.12

2 years ago

0.4.5

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.4.4

2 years ago

0.4.1

2 years ago

0.3.2

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.3.3

2 years ago

0.1.23

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.20

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.16

3 years ago

0.1.8

3 years ago

0.1.17

3 years ago

0.1.7

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago