npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aitmed/prynote-sdk

v1.0.122

Published

> This is the application layer sdk for AiTmed Prynote

Downloads

142

Readme

AiTmed's Prynote SDK

Usage

const sdk = new SDK({ apiVersion: 'v1beta1', env: 'development' })

const doSomething = async () => {
  const phone_number = '+1 1234567890'
  const password = '1234567890'
  // Request Verification Code
  const verification_code = await sdk.account.requestVerificationCode(phone_number)
  // Create User
  await sdk.account.create(
    phone_number,
    password,
    parseInt(verification_code),
  )
  // Login
  await sdk.account.login(
    phone_number,
    password,
    verification_code,
  )
}

API

Store

type ApiVersion = 'v1beta1' | 'v1beta2'
type ENV = 'development' | 'production'

interface ResponseCatcher {
  (response: Response): Response
}

interface ErrorCatcher {
  (error: Level2Error): void
}

class Store {
  constructor({
    apiVersion: ApiVersion
    env: ENV
  })

  public readonly level2SDK
  public env: ENV
  public apiVersion: ApiVersion

  public responseCatcher: ResponseCatcher
  public errorCatcher: ErrorCatcher

  public setResponseCatcher(catcher?: ResponseCatcher)
  public setErrorCatcher(catcher?: ErrorCatcher)
}

SDK

class SDK {
  constructor({
    apiVersion: ApiVersion
    env: ENV
  })

  public readonly account: Account
  public readonly notebook: Notebook
  public readonly note: Note

  public apiVersion: ApiVersion

  public setResponseCatcher(catcher?: ResponseCatcher)
  public setErrorCatcher(catcher?: ErrorCatcher)
}

AiTmedError

AiTmedError {
  readonly code: number
  readonly name: string
  readonly message: string

  constructor({
    code?: number,
    name?: string,
    message?: string
  })
}

| AiTmedError | Name | Default Message | | ---------------------------------------------------- | -------------------------- | ----------------------------- | | -1 | UNKNOW_ERROR | error occurred | | 1 | PERMISSION_DENIED | permission denied | | 2 | UNREGISTERED | account is not registered | | 3 | REGISTERED | account is already registered | | /_ Accoutn / | | | | 1000 | PHONE_NUMBER_INVALID | phone number is invalid | | 1001 | PASSWORD_INVALID | password is invalid | | 1002 | VERIFICATION_CODE_INVALID | verification code is invalid | | 1003 | REQUIRED_VERIFICATION_CODE | verification code is required | | 1004 | REQUIRED_PASSWORD | password is required | | 1005 | USER_NOT_FOUND | user is not found | | / Notebook / | | | | 2000 | NOTEBOOK_NOT_EXIST | notebook is not exist | | 2001 | NOTEBOOK_PERMISSION_DENIED | notebook permission denied | | / Note _/ | | | | 3000 | NOTE_NOT_EXIST | note is not exist | | 3001 | NOTE_PERMISSION_DENIED | note permission denied | | 3002 | NOTE_CONTENT_INVALID | note content is invalid |

Account

interface User {
  id: Uint8Array | string
  phone_number: string

  roles: number

  first_name?: string
  middle_name?: string
  last_name?: string

  profile_photo?: string

  gender?: 'MALE' | 'FEMALE' | 'PNS'
  birthday?: number
  languages?: string[]
}

account.requestVerificationCode

requestVerificationCode(
  phone_number: string
): Promise<string>

account.create

create(
  phone_number: string,
  password: string,
  verification_code: number
): Promise<void>

account.login

login(
  phone_number: string,
  password: string,
  verification_code: number
): Promise<void>

account.loginByPassword

login(
  password: string
): Promise<void>

This method is only able to be used after login new device (loginByVerificationCode)

account.loginByVerificationCode

login(
  phone_number: string,
  verification_code: number
): Promise<void>

account.logout

logout(): Status

account.update

interface UpdateParams {
  first_name?: string
  middle_name?: string
  last_name?: string

  profile_photo?: string

  gender?: 'MALE' | 'FEMALE' | 'PNS'
  birthday?: number
  languages?: string[]
}
update(
  id: Uint8Array | string,
  params: UpdateParams
): Promise<User>

account.updatePhoneNumber NOT IMPLEMENT

updatePhoneNumber(params: {
  phone_number: string,
  new_phone_number: string,
  verification_code: string,
}): Promise<User>

account.updatePassword NOT IMPLEMENT

interface UdpatePasswordParams {
  phone_number: string
  new_password: string
  verification_code?: string
  password?: string
}
updatePassword(params: UdpatePasswordParams): Promise<void>

account.retrieve

updatePassword(id: Uint8Array | string): Promise<User>

Notebook

interface Notebook {
  id: Uint8Array | string
  owner_id: Uint8Array | string

  info: {
    title: string
    edit_mode: number
  }
}

account.getStatus

getStatus(): Status

notebook.create

create(title: string): Promise<NotebookType>

notebook.remove

remove(id: string | Uint8Array): Promise<NotebookType>

notebook.update

update(id: string | Uint8Array, fields: {
  title?: string
}): Promise<NotebookType>

notebook.retrieve

retrieve(id: string | Uint8Array): Promise<NotebookType>

notebook.list

list(params: {
  shared?: Boolean
  count?: number
  edit_mode?: number
  sort_by?: 0 | 1 | 2
}): Promise<{
  ids: Set<string | Uint8Array>
  mapper: Map<string | Uint8Array, NotebookType>
}>

notebook.share NOT IMPLEMENT

share(
  id: string | Uint8Array,
  invite_phone_number: string,
  edit_mode: number
): Promise<void>

notebook.unshare NOT IMPLEMENT

unshare(
  id: string | Uint8Array,
  invited_phone_number: string
): Promise<void>

Note

interface NoteBase {
  id: string
  owner_id: string
  notebook_id: string
  edit_mode: number

  title: string

  tags: string[]

  created_at: number
  modified_at: number
  modified_by: string
}
type NoteTypes =
  | 0 // text
  | 1 // form

interface Note extends NoteBase {
  type: NoteTypes
  content: string
}

type NoteFileTypes =
  | 2 // image
  | 3 // pdf
  | 4 // vedio

interface NoteFile extends NoteBase {
  // title will be the file name
  type: NoteFileTypes
  file: Blob
  file_size: number
}

note.create

create(params: {
    notebook_id: string
    title: string
    content: string | Blob
    type: NoteTypes | NoteFileTypes
}): {
  code: Code
  data: {
    note: Note | NoteFile | null
  }
}

| Return Code | | | -------------------------- | --- | | SUCCESS | | PERMISSION_DENIED | | NOTEBOOK_NOT_EXIST | | NOTEBOOK_PERMISSION_DENIED |

note.remove

remove(id: string): {
  code: Code
  data: {
    note: Note | NoteFile | null
  }
}

| Return Code | | | -------------------------- | --- | | SUCCESS | | PERMISSION_DENIED | | NOTEBOOK_NOT_EXIST | | NOTEBOOK_PERMISSION_DENIED |

note.update

update(id: string, fields: {
  notebook_id?: string
  title?: string
  content?: string | Blob
}): {
  code: Code
  data: {
    note: Note | NoteFile | null
  }
}

| Return Code | | | -------------------------- | --- | | SUCCESS | | PERMISSION_DENIED | | NOTEBOOK_NOT_EXIST | | NOTEBOOK_PERMISSION_DENIED | | NOTE_NOT_EXIST | | NOTE_PERMISSION_DENIED | | NOTE_CONTENT_INVALID |

note.retrieve

retrieve(id: string): {
  code: Code
  data: {
    note: Note | NoteFile | null
  }
}

| Return Code | | | ---------------------- | --- | | SUCCESS | | PERMISSION_DENIED | | NOTE_NOT_EXIST | | NOTE_PERMISSION_DENIED |

note.list

list(notebook_id: string, options: {
  shared?: Boolean

  types?: (NoteTypes | NoteFileTypes)[]
  tags?: string[]

  count?: number
  edit_mode?: number
  sort_by?: 0 | 1 | 2
}): {
  code: Code
  data: {
    ids: string[]
    mapper: {
      [id: string]: Note | NoteFile
    }
  }
}

| Return Code | | | ---------------------- | --- | | SUCCESS | | PERMISSION_DENIED | | NOTE_NOT_EXIST | | NOTE_PERMISSION_DENIED |

note.share

share(id: string, invite_phone_number: string, edit_mode: number): {
  code: Code
}

| Return Code | | | ---------------------- | --- | | SUCCESS | | PERMISSION_DENIED | | PHONE_NUMBER_INVALID | | NOTE_NOT_EXIST | | NOTE_PERMISSION_DENIED |

note.unshare

unshare(id: string, invited_phone_number: string): {
  code: Code
}

| Return Code | | | ---------------------- | --- | | SUCCESS | | PERMISSION_DENIED | | PHONE_NUMBER_INVALID | | NOTE_NOT_EXIST | | NOTE_PERMISSION_DENIED |