# magma-sdk

Latest version **1.1.2** (published 2022-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install magma-sdk
pnpm add magma-sdk
yarn add magma-sdk
bun add magma-sdk
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2022-08-01 |
| First published | 2022-07-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 693.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | rush |

## Links

- npm: https://www.npmjs.com/package/magma-sdk
- npm.io page: https://npm.io/package/magma-sdk

## Recent versions

- 1.1.2 (latest) — 2022-08-01
- 1.1.1 — 2022-08-01
- 1.1.0 — 2022-08-01
- 1.0.1 — 2022-07-31

## README

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [magma-sdk](#magma-sdk)
  - [Requirements](#requirements)
  - [Installation instructions](#installation-instructions)
  - [Example application](#example-application)
  - [License](#license)
- [Classes](#classes)
  - [Class: ApiClient](#class-apiclient)
    - [Constructors](#constructors)
    - [Properties](#properties)
    - [Methods](#methods)
- [Interfaces](#interfaces)
  - [Interface: ApiClientOptions](#interface-apiclientoptions)
    - [Properties](#properties-1)
  - [Interface: CreateOptions](#interface-createoptions)
    - [Properties](#properties-2)
  - [Interface: EntityData](#interface-entitydata)
    - [Properties](#properties-3)
  - [Interface: ListOptions](#interface-listoptions)
    - [Properties](#properties-4)
  - [Interface: MoveOptions](#interface-moveoptions)
    - [Properties](#properties-5)
  - [Interface: TeamTreeItem](#interface-teamtreeitem)
    - [Properties](#properties-6)
  - [Interface: UploadOptions](#interface-uploadoptions)
    - [Properties](#properties-7)
  - [Interface: UserData](#interface-userdata)
    - [Properties](#properties-8)
  - [Interface: WalkContext](#interface-walkcontext)
    - [Properties](#properties-9)
  - [Interface: WalkLocation](#interface-walklocation)
    - [Properties](#properties-10)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->


<a name="readmemd"></a>

# magma-sdk

Hi there, this is the Node.JS SDK for Magma.

Use cases:
- Programmatic access to magma data
- Automate your magma workflow
- Anything you can imagine

## Requirements
- Paid team account on public, private or self-hosted Magma instance
- Working installation of Node.JS version 18 or higher

## Installation instructions

```
npm install magma-sdk
```

or

```
yarn add magma-sdk
```

## Example application

```ts
const serverUrl = 'https://your-custom-deployment'; // leave undefined for default cloud server

// get token from /my/account/api
const apiToken = 'b4610f40-9a19-5421-b05e-6beb73bee04d';
const apiClient = new ApiClient({ serverUrl, apiToken });

const out = await apiClient.profile();
// out contains your profile information
```

## License
All examples and public code are available under the MIT license.

Copyright (c) Magma

# Classes


<a name="classesapiclientmd"></a>

## Class: ApiClient

### Constructors

#### constructor

• **new ApiClient**(`options`)

##### Parameters

| Name | Type |
| :------ | :------ |
| `options` | [`ApiClientOptions`](#interfacesapiclientoptionsmd) |

### Properties

#### serverUrl

• **serverUrl**: `string`

### Methods

#### create

▸ **create**(`data`): `Promise`<`unknown`\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `data` | [`CreateOptions`](#interfacescreateoptionsmd) |

##### Returns

`Promise`<`unknown`\>

___

#### delete

▸ **delete**(`id`): `Promise`<`unknown`\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `id` | `string` |

##### Returns

`Promise`<`unknown`\>

___

#### download

▸ **download**(`id`, `type?`): `Promise`<{ `entity`: [`EntityData`](#interfacesentitydatamd) ; `stream`: `ReadableStream` = response.body }\>

##### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `id` | `string` | `undefined` |
| `type` | `string` | `'png'` |

##### Returns

`Promise`<{ `entity`: [`EntityData`](#interfacesentitydatamd) ; `stream`: `ReadableStream` = response.body }\>

___

#### get

▸ **get**(`id`): `Promise`<[`EntityData`](#interfacesentitydatamd)\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `id` | `string` |

##### Returns

`Promise`<[`EntityData`](#interfacesentitydatamd)\>

___

#### hierarchy

▸ **hierarchy**(`id`): `Promise`<[`EntityData`](#interfacesentitydatamd)\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `id` | `string` |

##### Returns

`Promise`<[`EntityData`](#interfacesentitydatamd)\>

___

#### list

▸ **list**(`__namedParameters`): `Promise`<[`EntityData`](#interfacesentitydatamd)[]\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `__namedParameters` | [`ListOptions`](#interfaceslistoptionsmd) |

##### Returns

`Promise`<[`EntityData`](#interfacesentitydatamd)[]\>

___

#### move

▸ **move**(`__namedParameters`): `Promise`<{ `failure`: `string`[] ; `sucess`: `string`[]  }\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `__namedParameters` | [`MoveOptions`](#interfacesmoveoptionsmd) |

##### Returns

`Promise`<{ `failure`: `string`[] ; `sucess`: `string`[]  }\>

___

#### profile

▸ **profile**(): `Promise`<[`UserData`](#interfacesuserdatamd)\>

##### Returns

`Promise`<[`UserData`](#interfacesuserdatamd)\>

___

#### teams

▸ **teams**(): `Promise`<[`TeamTreeItem`](#interfacesteamtreeitemmd)[]\>

##### Returns

`Promise`<[`TeamTreeItem`](#interfacesteamtreeitemmd)[]\>

___

#### update

▸ **update**(`id`, `data`): `Promise`<`unknown`\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `id` | `string` |
| `data` | `any` |

##### Returns

`Promise`<`unknown`\>

___

#### upload

▸ **upload**(`__namedParameters`, `stream`): `Promise`<[`EntityData`](#interfacesentitydatamd)\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `__namedParameters` | [`UploadOptions`](#interfacesuploadoptionsmd) |
| `stream` | `ArrayBuffer` \| `Buffer` \| `ReadableStream` |

##### Returns

`Promise`<[`EntityData`](#interfacesentitydatamd)\>

___

#### walkRecursively

▸ **walkRecursively**(`__namedParameters`, `callback`): `Promise`<`void`\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `__namedParameters` | [`ListOptions`](#interfaceslistoptionsmd) |
| `callback` | (`context`: [`WalkContext`](#interfaceswalkcontextmd)) => `Promise`<`void`\> |

##### Returns

`Promise`<`void`\>

# Interfaces


<a name="interfacesapiclientoptionsmd"></a>

## Interface: ApiClientOptions

### Properties

#### apiToken

• **apiToken**: `string`

___

#### serverUrl

• `Optional` **serverUrl**: `string`


<a name="interfacescreateoptionsmd"></a>

## Interface: CreateOptions

### Properties

#### folder

• `Optional` **folder**: `string`

___

#### name

• `Optional` **name**: `string`

___

#### project

• `Optional` **project**: `string`

___

#### type

• **type**: `string`


<a name="interfacesentitydatamd"></a>

## Interface: EntityData

### Properties

#### \_id

• **\_id**: `string`

___

#### archived

• `Optional` **archived**: `boolean`

___

#### author

• `Optional` **author**: `string` \| `EntityAuthor`

___

#### cacheId

• `Optional` **cacheId**: `string`

___

#### children

• `Optional` **children**: `number`

___

#### collaborators

• `Optional` **collaborators**: `Collaborator`[]

___

#### createdAt

• `Optional` **createdAt**: `string` \| `Date`

___

#### depth

• `Optional` **depth**: `number`

___

#### folder

• `Optional` **folder**: `string`

___

#### folderHierarchy

• `Optional` **folderHierarchy**: [`EntityData`](#interfacesentitydatamd)[]

___

#### hasPassword

• `Optional` **hasPassword**: `boolean`

___

#### isHidden

• `Optional` **isHidden**: `boolean`

___

#### modifiedAt

• `Optional` **modifiedAt**: `string` \| `Date`

___

#### name

• **name**: `string`

___

#### openedAt

• `Optional` **openedAt**: `string` \| `Date`

___

#### participants

• `Optional` **participants**: `Participant`[]

___

#### password

• `Optional` **password**: `string`

___

#### privateId

• `Optional` **privateId**: ``null`` \| `string` \| ``false``

___

#### project

• `Optional` **project**: `string` \| `ProjectLinkMetadata`

___

#### shareType

• `Optional` **shareType**: `EntityShareTypes`

___

#### shortId

• **shortId**: `string`

___

#### status

• `Optional` **status**: `EntityStatus`

___

#### team

• `Optional` **team**: `string`

___

#### threads

• `Optional` **threads**: `Object`

##### Type declaration

| Name | Type |
| :------ | :------ |
| `unread` | `number` |
| `unresolved` | `number` |

___

#### type

• **type**: `EntityType`

___

#### updatedAt

• `Optional` **updatedAt**: `string` \| `Date`

___

#### userRole

• `Optional` **userRole**: `UserRole`


<a name="interfaceslistoptionsmd"></a>

## Interface: ListOptions

### Properties

#### folder

• `Optional` **folder**: `string`

___

#### project

• `Optional` **project**: `string`


<a name="interfacesmoveoptionsmd"></a>

## Interface: MoveOptions

### Properties

#### entities

• **entities**: `string`[]

___

#### folder

• `Optional` **folder**: `string`

___

#### project

• `Optional` **project**: `string`


<a name="interfacesteamtreeitemmd"></a>

## Interface: TeamTreeItem

### Properties

#### \_id

• **\_id**: `string`

___

#### avatar

• **avatar**: `string`

___

#### name

• **name**: `string`

___

#### projects

• **projects**: `ProjectTreeItem`[]

___

#### slug

• **slug**: `string`


<a name="interfacesuploadoptionsmd"></a>

## Interface: UploadOptions

### Properties

#### filename

• **filename**: `string`

___

#### folder

• `Optional` **folder**: `string`

___

#### project

• `Optional` **project**: `string`

___

#### team

• `Optional` **team**: `string`

___

#### type

• **type**: `string`


<a name="interfacesuserdatamd"></a>

## Interface: UserData

### Properties

#### \_id

• **\_id**: `string`

___

#### avatar

• `Optional` **avatar**: `string`

___

#### color

• `Optional` **color**: `string`

___

#### createdAt

• `Optional` **createdAt**: `string`

___

#### email

• `Optional` **email**: `string`

___

#### hideNewFeatureNotifications

• `Optional` **hideNewFeatureNotifications**: `boolean`

___

#### intercomHash

• `Optional` **intercomHash**: `string`

___

#### intercomPayload

• `Optional` **intercomPayload**: `string`

___

#### isImpersonating

• `Optional` **isImpersonating**: `boolean`

___

#### isSuperAdmin

• `Optional` **isSuperAdmin**: `boolean`

___

#### lastActive

• `Optional` **lastActive**: `Date`

___

#### lastNewFeature

• `Optional` **lastNewFeature**: `string`

___

#### lastTeam

• `Optional` **lastTeam**: `string`

___

#### muteAppNotifications

• `Optional` **muteAppNotifications**: `boolean`

___

#### name

• **name**: `string`

___

#### newFeature

• `Optional` **newFeature**: `string`

___

#### newsletter

• `Optional` **newsletter**: `boolean`

___

#### oauth

• `Optional` **oauth**: `string`

___

#### plan

• `Optional` **plan**: `string`

___

#### pro

• `Optional` **pro**: `boolean`

___

#### settings

• `Optional` **settings**: `string`

___

#### tawkHash

• `Optional` **tawkHash**: `string`

___

#### unverifiedEmail

• `Optional` **unverifiedEmail**: `string`

___

#### userType

• **userType**: `string`

___

#### workRole

• `Optional` **workRole**: `string`

___

#### workTags

• `Optional` **workTags**: `string`[]


<a name="interfaceswalkcontextmd"></a>

## Interface: WalkContext

### Properties

#### entity

• **entity**: [`EntityData`](#interfacesentitydatamd)

___

#### tree

• **tree**: [`WalkLocation`](#interfaceswalklocationmd)[]


<a name="interfaceswalklocationmd"></a>

## Interface: WalkLocation

### Properties

#### entity

• **entity**: [`EntityData`](#interfacesentitydatamd)

---
_Source: https://npm.io/package/magma-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
