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 🙏

© 2026 – Pkg Stats / Ryan Hefner

moysklad-sdk

v0.3.132

Published

Moysklad-SDK

Readme

Moysklad-Sdk

Библиотека для упрощения взаимодействия между МоимСкладом и другими приложениями. Поддерживает работу со ~~всеми~~ основными сущностями и предоставляет дополнительные методы.

  • Создание новых документов
  • Редактирование существующих документов
  • Дополнительные методы для манипуляции с документами
  • ~~Rich-query фильтрации на основе реплики в MongoDB~~
  • ~~LiveQuery~~
  • ~~Websocket event listeners~~

TODO

  • [x] Установка библиотеки через npm
  • [x] Разобраться, на чьей стороне (бек или сдк) заниматься преобразованием данных, парсингом и составлением фильтров. Принято решение сделать всю логику на стороне SDK, оставить прокси максимально безмозглым, чтобы не разносить логику по двум местам и иметь возможность всё дебажить прямо на клиенте.
  • [ ] Добавить метод, отдающий структуру документа (fields, types, etc.)
  • [ ] Кроссбраузерность и кроссплатформенность

Установка

Используя npm:

npm install moysklad-sdk

Подключение

import SDK, { initSDK } from 'moysklad-sdk';


// Вызывается один раз для всего проекта
initSDK({
    // Опции подключения
    secret: <SECRET_KEY>
});

// Синглтон экземпляр  библиотеки
console.log('SDK', SDK);

Разработка

Запуск сборщика rollup в режиме watch

npm run dev

Компиляция в прод

npm run build
npm publish

Демо (Должен быть запущен Moysklad-Sync)

npm run demo

Примеры использования

Изменение существующего заказа покупателю.

const customerorder = await SDK.Entity.Customerorder.load({
    name: 'Test order',
});

await customerorder.setStore({
    name: 'Другой склад',
});

await customerorder.save();

Создание нового заказа покупателю.

const customerorder = await SDK.Entity.Customerorder.create({
    name: 'New order',
});

await customerorder.setStore({
    name: 'Другой склад',
});

await customerorder.save();

Поиск документов:

В качестве аргументов поиска может быть указано одно из следующих значений, в порядке приоритета:

  1. ID объекта
  2. Массив для агрегации
  3. Объект для фильтрации

Лимит поиска нужно обязательно указывать в явном виде.

// Поиск по ID
const organization = await SDK.Entity.Organization.load('07bbe005-8b17-11e7-7a34-5acf0019232a');

// Поиск с фильтрацией
const counterparty = await SDK.Entity.Counterparty.load({
    name: 'Розничный покупатель',
});

// Поиск с агрегацией
const counterparty = await SDK.Entity.Counterparty.load([
    {
        $match: {
            name: 'Розничный покупатель',
        },
    },
]);

// Поиск с фильтрацией по ссылке.
const customerorder = await SDK.Entity.Customerorder.loadList(
    {
        agent: counterparty,
    },
    {
        limit: 10,
    },
);

Объект у которого в фильтре передан объект, содержащий ...meta.href будет автоматически сокращён по правилу:

Object.keys(filter).forEach(key => {
    if (filter[key].meta && filter[key].meta.href) {
        filter[`${key}.meta.href`] = filter[key].meta.href.split('?')[0];
        delete filter[key];
    }
});



filter = {
    meta: {
        href: 'https://online.moysklad.ru/api/remap/1.2/entity/store/<STORE_ID>?expand=parent',
        type: 'store',
        ...
    },
    id: '<STORE_ID>',
    name: 'xxxx',
    ...
}

filter = {
    'meta.href': 'https://online.moysklad.ru/api/remap/1.2/entity/store/<STORE_ID>'
}

Таким образом можно передавать для фильтрации другие документы:

const targetStore = await SDK.Entity.Store.load({
    name: 'Со склада',
});

const sourceStore = await SDK.Entity.Store.load({
    name: 'На склад',
});

await SDK.Entity.Move.load({
    targetStore,
    sourceStore,
});
  • [x] Добавил декораторы свойств и reflect-metadata
  • [ ] Глянуть на https://stackblitz.com/edit/typescript-teougc для продвинутых мета