magma-sdk
v1.1.2
Published
<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
Downloads
7
Readme
- magma-sdk
- Classes
- Interfaces
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
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
Class: ApiClient
Constructors
constructor
• new ApiClient(options
)
Parameters
| Name | Type |
| :------ | :------ |
| options
| ApiClientOptions
|
Properties
serverUrl
• serverUrl: string
Methods
create
▸ create(data
): Promise
<unknown
>
Parameters
| Name | Type |
| :------ | :------ |
| data
| CreateOptions
|
Returns
Promise
<unknown
>
delete
▸ delete(id
): Promise
<unknown
>
Parameters
| Name | Type |
| :------ | :------ |
| id
| string
|
Returns
Promise
<unknown
>
download
▸ download(id
, type?
): Promise
<{ entity
: EntityData
; stream
: ReadableStream
= response.body }>
Parameters
| Name | Type | Default value |
| :------ | :------ | :------ |
| id
| string
| undefined
|
| type
| string
| 'png'
|
Returns
Promise
<{ entity
: EntityData
; stream
: ReadableStream
= response.body }>
get
▸ get(id
): Promise
<EntityData
>
Parameters
| Name | Type |
| :------ | :------ |
| id
| string
|
Returns
Promise
<EntityData
>
hierarchy
▸ hierarchy(id
): Promise
<EntityData
>
Parameters
| Name | Type |
| :------ | :------ |
| id
| string
|
Returns
Promise
<EntityData
>
list
▸ list(__namedParameters
): Promise
<EntityData
[]>
Parameters
| Name | Type |
| :------ | :------ |
| __namedParameters
| ListOptions
|
Returns
Promise
<EntityData
[]>
move
▸ move(__namedParameters
): Promise
<{ failure
: string
[] ; sucess
: string
[] }>
Parameters
| Name | Type |
| :------ | :------ |
| __namedParameters
| MoveOptions
|
Returns
Promise
<{ failure
: string
[] ; sucess
: string
[] }>
profile
▸ profile(): Promise
<UserData
>
Returns
Promise
<UserData
>
teams
▸ teams(): Promise
<TeamTreeItem
[]>
Returns
Promise
<TeamTreeItem
[]>
update
▸ update(id
, data
): Promise
<unknown
>
Parameters
| Name | Type |
| :------ | :------ |
| id
| string
|
| data
| any
|
Returns
Promise
<unknown
>
upload
▸ upload(__namedParameters
, stream
): Promise
<EntityData
>
Parameters
| Name | Type |
| :------ | :------ |
| __namedParameters
| UploadOptions
|
| stream
| ArrayBuffer
| Buffer
| ReadableStream
|
Returns
Promise
<EntityData
>
walkRecursively
▸ walkRecursively(__namedParameters
, callback
): Promise
<void
>
Parameters
| Name | Type |
| :------ | :------ |
| __namedParameters
| ListOptions
|
| callback
| (context
: WalkContext
) => Promise
<void
> |
Returns
Promise
<void
>
Interfaces
Interface: ApiClientOptions
Properties
apiToken
• apiToken: string
serverUrl
• Optional
serverUrl: string
Interface: CreateOptions
Properties
folder
• Optional
folder: string
name
• Optional
name: string
project
• Optional
project: string
type
• type: string
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
[]
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
Interface: ListOptions
Properties
folder
• Optional
folder: string
project
• Optional
project: string
Interface: MoveOptions
Properties
entities
• entities: string
[]
folder
• Optional
folder: string
project
• Optional
project: string
Interface: TeamTreeItem
Properties
_id
• _id: string
avatar
• avatar: string
name
• name: string
projects
• projects: ProjectTreeItem
[]
slug
• slug: string
Interface: UploadOptions
Properties
filename
• filename: string
folder
• Optional
folder: string
project
• Optional
project: string
team
• Optional
team: string
type
• type: string
Interface: UserData
Properties
_id
• _id: string
avatar
• Optional
avatar: string
color
• Optional
color: string
createdAt
• Optional
createdAt: string
• 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
[]
Interface: WalkContext
Properties
entity
• entity: EntityData
tree
• tree: WalkLocation
[]
Interface: WalkLocation
Properties
entity
• entity: EntityData