moises-node
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

moises-node

Non-official Music AI (Before called Moises AI) API wrapper package with Typescript support

Codacy Badge npm version Node.js Package

Install

yarn add moises-node

or

npm i moises-node

How to use it?

// importing into your project
import { 
    processFile, 
    processFolder, 
    ProcessStatus, 
    ProcessFileOptions,
    JobStatus,
    DownloadResult
} from 'moises-node'

// types exported by the library
export type ProcessStatus =
    | 'PENDING'
    | 'PROCESSING'
    | 'SUCCEEDED'
    | 'FAILED'
    | 'ABORTED'

export type ProcessFolderOptions = {
    apiKey: string
    workflowId: string
    inputFolder: string
    outputFolder: string
    maxConcurrencyNumber?: number
    abortSignal?: AbortSignal
    jobMonitorInterval?: number
    onProgress?: (
        file: string,
        status: JobStatus | ProcessStatus,
        report: any
    ) => Promise<void>
    onLog?(message: string): Promise<void>
    onError?(message: string): Promise<void>
}

export type ProcessFileOptions = {
    apiKey: string
    workflowId: string
    filePath: string
    outputFolder: string
    jobMonitorInterval?: number
    onProgress?: (
        file: string,
        status: JobStatus | ProcessStatus,
        report: any
    ) => Promise<void>
    onLog?(message: string): Promise<void>
    onError?(message: string): Promise<void>
}

export type JobStatus =
    | 'SUCCEEDED'
    | 'FAILED'
    | 'PENDING'
    | 'PROCESSING'
    | 'DELETED'
    | 'QUEUED'
    | 'CANCELLED'
    | 'STARTED'

export type DownloadResult = {
    [key: string]: string
}

// functions exported by the library
async function processFile({
    apiKey,
    workflowId,
    filePath,
    outputFolder,
    jobMonitorInterval,
    onProgress,
    onLog,
    onError,
}: ProcessFileOptions) : Promise<DownloadResult>

async function processFolder({
    apiKey,
    workflowId,
    inputFolder,
    outputFolder,
    maxConcurrencyNumber = 5,
    abortSignal,
    jobMonitorInterval = 1000,
    onProgress,
    onLog,
    onError,
}: ProcessFolderOptions): Promise<DownloadResult[]>

Package Sidebar

Install

npm i moises-node

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

38.1 kB

Total Files

24

Last publish

Collaborators

  • leandrosimoes