New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

amocrm-js

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amocrm-js - npm Package Compare versions

Comparing version 3.3.5 to 3.4.0

dist/api/activeRecords/CatalogElement.d.ts

70

dist/api/activeRecords/Company.d.ts

@@ -6,6 +6,12 @@ /**

import { JSONObject, TConstructor } from "../../types";
import { IRequestOptions } from "../../interfaces/common";
import { ICompanyFactory } from "../factories/CompanyFactory";
import { IEntityAttributes, IResourceEntity } from "../../interfaces/api";
import { IHasGetByIdCriteria } from "../factories/mixins/hasGetById";
import { hasSave, IHasSaveEntity } from "./mixins/hasSave";
import { hasFetch, IHasFetchEntity } from "./mixins/hasFetch";
import { IHasCreateEntity } from "./mixins/hasCreate";
import { IHasUpdateEntity } from "./mixins/hasUpdate";
import { IHasEmbeddedTagsEntity } from "./mixins/embedded/hasEmbeddedTags";
import { IHasEmbeddedCustomersEntity } from "./mixins/embedded/hasEmbeddedCustomers";
import { IHasEmbeddedCatalogElementsEntity } from "./mixins/embedded/hasEmbeddedCatalogElements";
import { IHasEmbeddedContactsEntity } from "./mixins/embedded/hasEmbeddedContacts";
export interface CompanyAttributes extends IEntityAttributes {

@@ -24,52 +30,12 @@ id?: number;

account_id?: number;
_embedded?: JSONObject;
_embedded?: ICompanyHasEmbedded;
}
export interface ICompany extends IResourceEntity<ICompanyFactory>, CompanyAttributes {
/**
* Добавляет сущность на портал AmoCRM
* @example
* ```ts
* const company = new client.Company({
* name: "Walter White"
* });
* await company.create();
* ```
* @example
* ```ts
* const company = new client.Company;
* company.name = "Walter White";
* await company.create();
* ```
* @returns ссылка на созданную сущность
* */
create(options?: IRequestOptions): Promise<ICompany>;
/**
* Обновляет сущность на портале AmoCRM.
* @param options настройки запроса и обработки результата
* @example
* ```ts
* const company = await client.companies.getById(123);
* company.name = "Walter White";
* await company.update();
* ```
* @returns ссылка на обновлённую сущность
* */
update(options?: IRequestOptions): Promise<ICompany>;
/**
* Создаёт или сохраняет сущность, в зависимости от результата {@link isNew()}
* @param options настройки запроса и обработки результата
* */
save(options?: IRequestOptions): Promise<ICompany>;
/**
* Получает содержимое сущности на портале
* @param criteria фильтр для уточнения результатов запроса
* @param options настройки запроса и обработки результата
* @example
* ```ts
* const company = new client.Company({ id: 123 });
* await company.fetch();
* ```
* */
fetch(criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<ICompany>;
export interface IEmbeddedCompany {
id?: number;
}
export interface IHasEmbeddedCompanies {
companies?: IEmbeddedCompany[];
}
export declare type ICompanyHasEmbedded = IHasEmbeddedTagsEntity<ICompanyFactory> & IHasEmbeddedContactsEntity<ICompanyFactory> & IHasEmbeddedCustomersEntity<ICompanyFactory> & IHasEmbeddedCatalogElementsEntity<ICompanyFactory>;
export declare type ICompany = IResourceEntity<ICompanyFactory> & CompanyAttributes & IHasCreateEntity<ICompanyFactory> & IHasUpdateEntity<ICompanyFactory> & IHasSaveEntity<ICompanyFactory> & IHasFetchEntity<ICompanyFactory> & ICompanyHasEmbedded;
/**

@@ -97,6 +63,8 @@ * Сделка

is_price_modified_by_robot?: boolean;
_embedded?: JSONObject;
_embedded?: ICompanyHasEmbedded;
getAttributes(): CompanyAttributes;
setAttributes(attributes?: CompanyAttributes): void;
}
export declare const mixins: (typeof hasSave | typeof hasFetch)[];
export declare const embeddedMixins: ((<T extends import("../../interfaces/api").IResourceFactory<import("./mixins/embedded/hasEmbeddedTags").IRequiredEntity<T>>>(Base: TConstructor<import("./mixins/embedded/hasEmbeddedTags").IRequiredEntity<T>>) => TConstructor<IResourceEntity<T>>) | (<T_1 extends import("../../interfaces/api").IResourceFactory<import("./mixins/embedded/hasEmbeddedCatalogElements").IRequiredEntity<T_1>>>(Base: TConstructor<import("./mixins/embedded/hasEmbeddedCatalogElements").IRequiredEntity<T_1>>) => TConstructor<IResourceEntity<T_1>>) | (<T_2 extends import("../../interfaces/api").IResourceFactory<import("./mixins/embedded/hasEmbeddedContacts").IRequiredEntity<T_2>>>(Base: TConstructor<import("./mixins/embedded/hasEmbeddedContacts").IRequiredEntity<T_2>>) => TConstructor<IResourceEntity<T_2>>))[];
export declare const Company: TConstructor<ICompany>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Company = exports.BaseCompany = void 0;
exports.Company = exports.embeddedMixins = exports.mixins = exports.BaseCompany = void 0;
const tslib_1 = require("tslib");

@@ -14,2 +14,6 @@ /**

const hasUpdate_1 = require("./mixins/hasUpdate");
const hasEmbeddedTags_1 = require("./mixins/embedded/hasEmbeddedTags");
const hasEmbeddedCustomers_1 = require("./mixins/embedded/hasEmbeddedCustomers");
const hasEmbeddedCatalogElements_1 = require("./mixins/embedded/hasEmbeddedCatalogElements");
const hasEmbeddedContacts_1 = require("./mixins/embedded/hasEmbeddedContacts");
/**

@@ -49,8 +53,22 @@ * Сделка

exports.BaseCompany = BaseCompany;
exports.Company = (0, util_1.applyMixins)(BaseCompany, [
exports.mixins = [
hasCreate_1.hasCreate,
hasUpdate_1.hasUpdate,
hasSave_1.hasSave,
hasFetch_1.hasFetch
hasFetch_1.hasFetch,
];
exports.embeddedMixins = [
(0, hasEmbeddedTags_1.hasEmbeddedTags)({
attributes: {
save: ['id', 'name']
}
}),
(0, hasEmbeddedCustomers_1.hasEmbeddedCustomers)(),
(0, hasEmbeddedContacts_1.hasEmbeddedContacts)(),
(0, hasEmbeddedCatalogElements_1.hasEmbeddedCatalogElements)()
];
exports.Company = (0, util_1.applyMixins)(BaseCompany, [
...exports.mixins,
...exports.embeddedMixins
]);
//# sourceMappingURL=Company.js.map

@@ -7,5 +7,13 @@ /**

import { JSONObject, TConstructor } from "../../types";
import { IEntityAttributes, IResourceEntity } from "../../interfaces/api";
import { IRequestOptions } from "../../interfaces/common";
import { IHasGetByIdCriteria } from "../factories/mixins/hasGetById";
import { IEmbeddedEntity, IEntityAttributes, IResourceEntity } from "../../interfaces/api";
import { hasSave, IHasSaveEntity } from "./mixins/hasSave";
import { hasFetch, IHasFetchEntity } from "./mixins/hasFetch";
import { IHasEmbeddedTags } from "./Tag";
import { IHasEmbeddedCompanies } from "./Company";
import { IHasEmbeddedCatalogElements } from "./CatalogElement";
import { IHasEmbeddedCustomers } from "./Customer";
import { IHasEmbeddedTagsEntity } from "./mixins/embedded/hasEmbeddedTags";
import { IHasEmbeddedCompaniesEntity } from "./mixins/embedded/hasEmbeddedCompanies";
import { IHasEmbeddedCatalogElementsEntity } from "./mixins/embedded/hasEmbeddedCatalogElements";
import { IHasEmbeddedCustomersEntity } from "./mixins/embedded/hasEmbeddedCustomers";
export interface ContactAttributes extends IEntityAttributes {

@@ -26,52 +34,14 @@ id?: number;

account_id?: number;
_embedded?: JSONObject;
_embedded?: IContactEmbedded;
}
export interface IContact extends IResourceEntity<IContactFactory>, ContactAttributes {
/**
* Добавляет сущность на портал AmoCRM
* @example
* ```ts
* const contact = new client.Contact({
* name: "Walter White"
* });
* await contact.create();
* ```
* @example
* ```ts
* const contact = new client.Contact;
* contact.name = "Walter White";
* await contact.create();
* ```
* @returns ссылка на созданную сущность
* */
create(options?: IRequestOptions): Promise<IContact>;
/**
* Обновляет сущность на портале AmoCRM.
* @param options настройки запроса и обработки результата
* @example
* ```ts
* const contact = await client.contacts.getById(123);
* contact.name = "Walter White";
* await contact.update();
* ```
* @returns ссылка на обновлённую сущность
* */
update(options?: IRequestOptions): Promise<IContact>;
/**
* Создаёт или сохраняет сущность, в зависимости от результата {@link isNew()}
* @param options настройки запроса и обработки результата
* */
save(options?: IRequestOptions): Promise<IContact>;
/**
* Получает содержимое сущности на портале
* @param criteria фильтр для уточнения результатов запроса
* @param options настройки запроса и обработки результата
* @example
* ```ts
* const contact = new client.Contact({ id: 123 });
* await contact.fetch();
* ```
* */
fetch(criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<IContact>;
export interface IEmbeddedContact extends IEmbeddedEntity {
id?: number;
is_main?: boolean;
}
export declare type IContactEmbedded = IHasEmbeddedTags & IHasEmbeddedCompanies & IHasEmbeddedCustomers & IHasEmbeddedCatalogElements;
export interface IHasEmbeddedContacts {
contacts?: IEmbeddedContact[];
}
export declare type IContactHasEmbedded = IHasEmbeddedTagsEntity<IContactFactory> & IHasEmbeddedCompaniesEntity<IContactFactory> & IHasEmbeddedCustomersEntity<IContactFactory> & IHasEmbeddedCatalogElementsEntity<IContactFactory>;
export declare type IContact = IResourceEntity<IContactFactory> & ContactAttributes & IHasSaveEntity<IContactFactory> & IHasFetchEntity<IContactFactory> & IContactHasEmbedded;
export declare class BaseContact extends ResourceEntity<IContactFactory> {

@@ -91,6 +61,8 @@ name?: string;

account_id?: number;
_embedded?: JSONObject;
_embedded?: IContactEmbedded;
getAttributes(): ContactAttributes;
setAttributes(attributes?: ContactAttributes): void;
}
export declare const mixins: (typeof hasSave | typeof hasFetch)[];
export declare const embeddedMixins: ((<T extends import("../../interfaces/api").IResourceFactory<import("./mixins/embedded/hasEmbeddedTags").IRequiredEntity<T>>>(Base: TConstructor<import("./mixins/embedded/hasEmbeddedTags").IRequiredEntity<T>>) => TConstructor<IResourceEntity<T>>) | (<T_1 extends import("../../interfaces/api").IResourceFactory<import("./mixins/embedded/hasEmbeddedCatalogElements").IRequiredEntity<T_1>>>(Base: TConstructor<import("./mixins/embedded/hasEmbeddedCatalogElements").IRequiredEntity<T_1>>) => TConstructor<IResourceEntity<T_1>>))[];
export declare const Contact: TConstructor<IContact>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Contact = exports.BaseContact = void 0;
exports.Contact = exports.embeddedMixins = exports.mixins = exports.BaseContact = void 0;
const tslib_1 = require("tslib");

@@ -14,2 +14,6 @@ /**

const hasFetch_1 = require("./mixins/hasFetch");
const hasEmbeddedTags_1 = require("./mixins/embedded/hasEmbeddedTags");
const hasEmbeddedCompanies_1 = require("./mixins/embedded/hasEmbeddedCompanies");
const hasEmbeddedCatalogElements_1 = require("./mixins/embedded/hasEmbeddedCatalogElements");
const hasEmbeddedCustomers_1 = require("./mixins/embedded/hasEmbeddedCustomers");
class BaseContact extends ResourceEntity_1.default {

@@ -50,8 +54,22 @@ getAttributes() {

exports.BaseContact = BaseContact;
exports.Contact = (0, util_1.applyMixins)(BaseContact, [
exports.mixins = [
hasCreate_1.hasCreate,
hasUpdate_1.hasUpdate,
hasSave_1.hasSave,
hasFetch_1.hasFetch
hasFetch_1.hasFetch,
];
exports.embeddedMixins = [
(0, hasEmbeddedTags_1.hasEmbeddedTags)({
attributes: {
save: ['id', 'name']
}
}),
(0, hasEmbeddedCustomers_1.hasEmbeddedCustomers)(),
(0, hasEmbeddedCompanies_1.hasEmbeddedCompanies)(),
(0, hasEmbeddedCatalogElements_1.hasEmbeddedCatalogElements)()
];
exports.Contact = (0, util_1.applyMixins)(BaseContact, [
...exports.mixins,
...exports.embeddedMixins
]);
//# sourceMappingURL=Contact.js.map

@@ -6,6 +6,16 @@ /**

import { JSONObject, TConstructor } from "../../types";
import { IRequestOptions } from "../../interfaces/common";
import { ILeadFactory } from "../factories/LeadFactory";
import { IEntityAttributes, IResourceEntity } from "../../interfaces/api";
import { IHasGetByIdCriteria } from "../factories/mixins/hasGetById";
import { hasSave, IHasSaveEntity } from "./mixins/hasSave";
import { hasFetch, IHasFetchEntity } from "./mixins/hasFetch";
import { IHasEmbeddedTags } from "./Tag";
import { IHasEmbeddedContacts } from "./Contact";
import { IHasEmbeddedCompanies } from "./Company";
import { IHasEmbeddedCatalogElements } from "./CatalogElement";
import { IHasEmbeddedTagsEntity } from "./mixins/embedded/hasEmbeddedTags";
import { IHasEmbeddedContactsEntity } from "./mixins/embedded/hasEmbeddedContacts";
import { IHasEmbeddedCompaniesEntity } from "./mixins/embedded/hasEmbeddedCompanies";
import { IHasEmbeddedCatalogElementsEntity } from "./mixins/embedded/hasEmbeddedCatalogElements";
import { IHasEmbeddedLossReasons } from "./LossReason";
import { IHasEmbeddedSource } from "./Source";
export interface LeadAttributes extends IEntityAttributes {

@@ -32,52 +42,7 @@ id?: number;

is_price_modified_by_robot?: boolean;
_embedded?: JSONObject;
_embedded?: ILeadEmbedded;
}
export interface ILead extends IResourceEntity<ILeadFactory>, LeadAttributes {
/**
* Добавляет сущность на портал AmoCRM
* @example
* ```ts
* const lead = new client.Lead({
* name: "Walter White"
* });
* await lead.create();
* ```
* @example
* ```ts
* const lead = new client.Lead;
* lead.name = "Walter White";
* await lead.create();
* ```
* @returns ссылка на созданную сущность
* */
create(options?: IRequestOptions): Promise<ILead>;
/**
* Обновляет сущность на портале AmoCRM.
* @param options настройки запроса и обработки результата
* @example
* ```ts
* const lead = await client.leads.getById(123);
* lead.name = "Walter White";
* await lead.update();
* ```
* @returns ссылка на обновлённую сущность
* */
update(options?: IRequestOptions): Promise<ILead>;
/**
* Создаёт или сохраняет сущность, в зависимости от результата {@link isNew()}
* @param options настройки запроса и обработки результата
* */
save(options?: IRequestOptions): Promise<ILead>;
/**
* Получает содержимое сущности на портале
* @param criteria фильтр для уточнения результатов запроса
* @param options настройки запроса и обработки результата
* @example
* ```ts
* const lead = new client.Lead({ id: 123 });
* await lead.fetch();
* ```
* */
fetch(criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<ILead>;
}
export declare type ILeadHasEmbedded = IHasEmbeddedTagsEntity<ILeadFactory> & IHasEmbeddedContactsEntity<ILeadFactory> & IHasEmbeddedCompaniesEntity<ILeadFactory> & IHasEmbeddedCatalogElementsEntity<ILeadFactory>;
export declare type ILead = IResourceEntity<ILeadFactory> & LeadAttributes & IHasSaveEntity<ILeadFactory> & IHasFetchEntity<ILeadFactory> & ILeadHasEmbedded;
export declare type ILeadEmbedded = IHasEmbeddedTags & IHasEmbeddedContacts & IHasEmbeddedCompanies & IHasEmbeddedCatalogElements & IHasEmbeddedLossReasons & IHasEmbeddedSource;
/**

@@ -105,6 +70,8 @@ * Сделка

is_price_modified_by_robot?: boolean;
_embedded?: JSONObject;
_embedded?: ILeadEmbedded;
getAttributes(): LeadAttributes;
setAttributes(attributes: LeadAttributes): void;
}
export declare const mixins: (typeof hasSave | typeof hasFetch)[];
export declare const embeddedMixins: ((<T extends import("../../interfaces/api").IResourceFactory<import("./mixins/embedded/hasEmbeddedTags").IRequiredEntity<T>>>(Base: TConstructor<import("./mixins/embedded/hasEmbeddedTags").IRequiredEntity<T>>) => TConstructor<IResourceEntity<T>>) | (<T_1 extends import("../../interfaces/api").IResourceFactory<import("./mixins/embedded/hasEmbeddedCatalogElements").IRequiredEntity<T_1>>>(Base: TConstructor<import("./mixins/embedded/hasEmbeddedCatalogElements").IRequiredEntity<T_1>>) => TConstructor<IResourceEntity<T_1>>) | (<T_2 extends import("../../interfaces/api").IResourceFactory<import("./mixins/embedded/hasEmbeddedContacts").IRequiredEntity<T_2>>>(Base: TConstructor<import("./mixins/embedded/hasEmbeddedContacts").IRequiredEntity<T_2>>) => TConstructor<IResourceEntity<T_2>>))[];
export declare const Lead: TConstructor<ILead>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Lead = exports.BaseLead = void 0;
exports.Lead = exports.embeddedMixins = exports.mixins = exports.BaseLead = void 0;
const tslib_1 = require("tslib");

@@ -14,2 +14,7 @@ /**

const hasUpdate_1 = require("./mixins/hasUpdate");
const hasEmbeddedTags_1 = require("./mixins/embedded/hasEmbeddedTags");
const hasEmbeddedContacts_1 = require("./mixins/embedded/hasEmbeddedContacts");
const hasEmbeddedCompanies_1 = require("./mixins/embedded/hasEmbeddedCompanies");
const hasEmbeddedCatalogElements_1 = require("./mixins/embedded/hasEmbeddedCatalogElements");
const hasEmbeddedSource_1 = require("./mixins/embedded/hasEmbeddedSource");
/**

@@ -63,8 +68,31 @@ * Сделка

exports.BaseLead = BaseLead;
exports.Lead = (0, util_1.applyMixins)(BaseLead, [
exports.mixins = [
hasCreate_1.hasCreate,
hasUpdate_1.hasUpdate,
hasSave_1.hasSave,
hasFetch_1.hasFetch
hasFetch_1.hasFetch,
];
exports.embeddedMixins = [
(0, hasEmbeddedTags_1.hasEmbeddedTags)({
attributes: {
save: ['id', 'name']
}
}),
(0, hasEmbeddedContacts_1.hasEmbeddedContacts)({
attributes: {
save: ['id', "is_main"]
}
}),
(0, hasEmbeddedCompanies_1.hasEmbeddedCompanies)({
attributes: {
save: ['id']
}
}),
(0, hasEmbeddedCatalogElements_1.hasEmbeddedCatalogElements)(),
hasEmbeddedSource_1.hasEmbeddedSource
];
exports.Lead = (0, util_1.applyMixins)(BaseLead, [
...exports.mixins,
...exports.embeddedMixins
]);
//# sourceMappingURL=Lead.js.map

@@ -9,5 +9,6 @@ "use strict";

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const criteria = [this];
const criteria = this.criteriaBuilder.getCreateCriteria();
const factory = this.getFactory();
const [first] = yield factory.create(criteria, options);
const [first] = yield factory.create([criteria], options);
this.id = first.id;
this.emit('create');

@@ -14,0 +15,0 @@ return first;

import { IResourceEntity } from "../../../interfaces/api";
import { TConstructor, TEntityConstructor } from "../../../types";
import { IRequestOptions } from "../../../interfaces/common";
import { ICanGetByIdFactory, IHasGetByIdCriteria } from "../../factories/mixins/hasGetById";
export interface IHasFetchEntity<T extends ICanGetByIdFactory<IResourceEntity<T>>> {
import { IHasGetByIdFactory, IHasGetByIdCriteria } from "../../factories/mixins/hasGetById";
export interface IHasFetchEntity<T extends IHasGetByIdFactory<IResourceEntity<T>>> {
fetch(criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<IHasFetchEntity<T> | false | null>;
}
export declare function hasFetch<T extends ICanGetByIdFactory<IResourceEntity<T>>>(Base: TEntityConstructor<T>): TConstructor<IResourceEntity<T>>;
export declare function hasFetch<T extends IHasGetByIdFactory<IResourceEntity<T>>>(Base: TEntityConstructor<T>): TConstructor<IResourceEntity<T>>;

@@ -11,4 +11,4 @@ import { IResourceEntity, IResourceFactory } from "../../../interfaces/api";

export interface IHasSaveEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IResourceEntity<T>, IHasCreateAndUpdateEntity<T> {
save(options?: IRequestOptions): Promise<T | false>;
save(options?: IRequestOptions): Promise<IHasSaveEntity<T>>;
}
export declare function hasSave<T extends IHasCreateAndUpdateFactory<IHasCreateAndUpdateEntity<T>>>(Base: TConstructor<IHasCreateAndUpdateEntity<T>>): TConstructor<IResourceEntity<T>>;

@@ -9,6 +9,7 @@ "use strict";

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const criteria = [this];
const [lead] = yield this.getFactory().update(criteria, options);
const criteria = this.criteriaBuilder.getUpdateCriteria();
const [first] = yield this.getFactory().update([criteria], options);
this.updated_at = first.updated_at;
this.emit('update');
return lead;
return first;
});

@@ -15,0 +16,0 @@ }

@@ -6,8 +6,12 @@ /**

import { ICompany } from "../activeRecords/Company";
import ResourcePagination from "../ResourcePagination";
import { IRequestOptions } from "../../interfaces/common";
import { JSONObject } from "../../types";
import { IResourceFactory } from "../../interfaces/api";
import { IGetCriteria } from "./mixins/hasGetByCriteria";
import { IHasGetByIdCriteria } from "./mixins/hasGetById";
import { IGetCriteria, IHasGetFactory } from "./mixins/hasGetByCriteria";
import { IHasGetByIdFactory } from "./mixins/hasGetById";
import { IHasCreateFactory } from "./mixins/hasCreate";
import { IHasUpdateFactory } from "./mixins/hasUpdate";
import { IHasTagsFactory } from "./mixins/hasTags";
export interface CompaniesGetCriteria extends IGetCriteria {
filter?: string;
}
export interface CompaniesCreateCriteria {

@@ -30,111 +34,5 @@ name?: string;

}
export interface ICompanyFactory extends IResourceFactory<ICompany> {
/**
* @param criteria фильтр сделок (https://www.amocrm.ru/developers/content/crm_platform/companies-api#companies-list)
* @example
* ```ts
* const pagination = await client.companies.get({
* order: 'created_at',
* page: 2,
* query: 'Иванов'
* })
* ```
* @param options настройки запроса и обработки результата
* @returns постраничную навигацию, экземпляр {@link ResourcePagination}
*
* @example
* ```ts
* const pagination = await client.companies.get()
* const data = pagination.getData(); // [company, company]
* const page = pagination.getPage();
*
* await pagination.next();
*
* const nextData = pagination.data();
* ```
*
* Метод {@link ResourcePagination.getData | getData()} навигации вернёт массив объектов {@link Company}
*
* */
get(criteria?: IGetCriteria, options?: IRequestOptions): Promise<ResourcePagination<ICompany>>;
/**
* Находит сделку по её id
* @param identity id сделки
* @param criteria параметры получения сделки (https://www.amocrm.ru/developers/content/crm_platform/companies-api#company-detail)
* @example
* ```ts
* const company = client.companies.getById(123, {
* with: 'catalog_elements'
* })
* ```
* @param options настройки запроса и обработки результата
* @returns экземпляр найденной сделки или null, если сделка не найдена.
* */
getById(identity: number, criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<ICompany | null>;
/**
* Создаёт новые сделки
* @param criteria параметры создания сделок (https://www.amocrm.ru/developers/content/crm_platform/companies-api#companies-add)
* и/или массив объектов {@link Company}
* @example
* ```ts
* const companies = await client.companies.create([
* {
* name: "Company 1"
* },
* {
* name: "Company 2"
* }
* ])
* ```
*
* @example
* ```ts
* const company1 = new client.Company;
* company1.name = 'Company 1';
* const company2 = new client.Company;
* company2.name = 'Company 2';
*
* await client.companies.create([company1, company2])
* ```
*
* @example
* ```ts
* const companies = await client.companies.create([
* new client.Company({
* name: "Company 1"
* }),
* {
* name: "Company 2"
* }
* ]);
* ```
*
* @param options настройки запроса и обработки результата
* @returns массив объектов {@link Company}. Если в параметр criteria передавались экземпляры {@link Company}, после
* создания сделок в AmoCRM, у них обновится поле id
*
* @example
* ```ts
* const company1 = new client.Company;
* company1.name = 'Company 1';
* company1.id; // undefined;
*
* await client.companies.create([company1])
*
* company1.id; // 123
* ```
* */
create(criteria: (CompaniesCreateCriteria | ICompany)[], options?: IRequestOptions): Promise<ICompany[]>;
/**
* Обновляет существующие сделки. Принцип работы метода аналогичен {@link create}
* @param criteria параметры обновления сделок (https://www.amocrm.ru/developers/content/crm_platform/companies-api#companies-edit)
* и/или массив объектов {@link Company}
* @param options настройки запроса и обработки результата
* @returns массив объектов {@link Company}. Если в параметр criteria передавались экземпляры {@link Company}, после
* создания сделок в AmoCRM, у них обновится поле id
* */
update(criteria: (CompaniesUpdateCriteria | ICompany)[], options?: IRequestOptions): Promise<ICompany[]>;
}
export declare type ICompanyFactory = IHasGetFactory<ICompany> & IHasGetByIdFactory<ICompany> & IHasCreateFactory<ICompany> & IHasUpdateFactory<ICompany> & IResourceFactory<ICompany> & IHasTagsFactory<ICompany>;
/**
* Фабрика управления сделками
* Фабрика управления компаниями
* */

@@ -146,3 +44,2 @@ export declare class BaseCompanyFactory extends ResourceFactory<ICompany> {

}
declare const CompanyFactory: any;
export default CompanyFactory;
export declare const CompanyFactory: any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseCompanyFactory = void 0;
exports.CompanyFactory = exports.BaseCompanyFactory = void 0;
const tslib_1 = require("tslib");

@@ -16,4 +16,5 @@ /**

const util_1 = require("../../util");
const hasTags_1 = require("./mixins/hasTags");
/**
* Фабрика управления сделками
* Фабрика управления компаниями
* */

@@ -32,9 +33,9 @@ class BaseCompanyFactory extends ResourceFactory_1.default {

exports.BaseCompanyFactory = BaseCompanyFactory;
const CompanyFactory = (0, util_1.applyMixins)(BaseCompanyFactory, [
exports.CompanyFactory = (0, util_1.applyMixins)(BaseCompanyFactory, [
hasGetByCriteria_1.hasGetByCriteria,
hasGetById_1.hasGetById,
hasCreate_1.hasCreate,
hasUpdate_1.hasUpdate
hasUpdate_1.hasUpdate,
hasTags_1.hasTags
]);
exports.default = CompanyFactory;
//# sourceMappingURL=CompanyFactory.js.map
import ResourceFactory from "../ResourceFactory";
import { IContact } from "../activeRecords/Contact";
import { IRequestOptions } from "../../interfaces/common";
import ResourcePagination from "../ResourcePagination";
import { IResourceFactory } from "../../interfaces/api";
import { JSONObject } from "../../types";
import { IGetCriteria } from "./mixins/hasGetByCriteria";
import { IHasGetByIdCriteria } from "./mixins/hasGetById";
import { IGetCriteria, IHasGetFactory } from "./mixins/hasGetByCriteria";
import { IHasGetByIdFactory } from "./mixins/hasGetById";
import { IHasCreateFactory } from "./mixins/hasCreate";
import { IHasUpdateFactory } from "./mixins/hasUpdate";
import { IHasTagsFactory } from "./mixins/hasTags";
export interface ContactsGetCriteria extends IGetCriteria {
filter?: string;
}
export interface ContactsCreateCriteria {

@@ -34,108 +38,3 @@ name?: string;

}
export interface IContactFactory extends IResourceFactory<IContact> {
/**
* @param criteria фильтр контактов (https://www.amocrm.ru/developers/content/crm_platform/contacts-api#contacts-list)
* @example
* ```ts
* const pagination = await client.contacts.get({
* order: 'created_at',
* page: 2,
* query: 'Иванов'
* })
* ```
* @param options настройки запроса и обработки результата
* @returns постраничную навигацию, экземпляр {@link ResourcePagination}
*
* @example
* ```ts
* const pagination = await client.contacts.get()
* const data = pagination.getData(); // [contact, contact]
* const page = pagination.getPage();
*
* await pagination.next();
*
* const nextData = pagination.data();
* ```
*
* Метод {@link ResourcePagination.getData | getData()} навигации вернёт массив объектов {@link Contact}
* */
get(criteria?: IGetCriteria, options?: IRequestOptions): Promise<ResourcePagination<IContact>>;
/**
* Находит контакт по её id
* @param identity id контакта
* @param criteria параметры получения контакта (https://www.amocrm.ru/developers/content/crm_platform/contacts-api#ontact-detail)
* @example
* ```ts
* const contact = client.contacts.getById(123, {
* with: 'catalog_elements'
* })
* ```
* @param options настройки запроса и обработки результата
* @returns экземпляр найденного контакта или null, если контакт не найден.
* */
getById(identity: number, criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<IContact | null>;
/**
* Создаёт новые контакты
* @param criteria параметры создания контактов (https://www.amocrm.ru/developers/content/crm_platform/contacts-api#contacts-add)
* и/или массив объектов {@link Contact}
* @example
* ```ts
* const contacts = await client.contacts.create([
* {
* name: "Contact 1"
* },
* {
* name: "Contact 2"
* }
* ])
* ```
*
* @example
* ```ts
* const contact1 = new client.Contact;
* contact1.name = 'Contact 1';
* const contact2 = new client.Contact;
* contact2.name = 'Contact 2';
*
* await client.contacts.create([contact1, contact2])
* ```
*
* @example
* ```ts
* const contacts = await client.contacts.create([
* new client.Contact({
* name: "Contact 1"
* }),
* {
* name: "Contact 2"
* }
* ]);
* ```
*
* @param options настройки запроса и обработки результата
* @returns массив объектов {@link Contact}. Если в параметр criteria передавались экземпляры {@link Contact}, после
* создания уонтакта в AmoCRM, у них обновится поле id
*
* @example
* ```ts
* const contact1 = new client.Contact;
* contact1.name = 'Contact 1';
* contact1.id; // undefined;
*
* await client.contacts.create([contact1])
*
* contact1.id; // 123
* ```
* */
create(criteria: (ContactsCreateCriteria | IContact)[], options?: IRequestOptions): Promise<IContact[]>;
/**
* Обновляет существующие сделки. Принцип работы метода аналогичен {@link create}
* @param criteria параметры обновления сделок (https://www.amocrm.ru/developers/content/crm_platform/contacts-api#contacts-edit)
* и/или массив объектов {@link Contact}
* @param options настройки запроса и обработки результата
* @returns массив объектов {@link Contact}. Если в параметр criteria передавались экземпляры {@link Contact}, после
* создания сделок в AmoCRM, у них обновится поле id
* */
update(criteria: (ContactsUpdateCriteria | IContact)[], options?: IRequestOptions): Promise<IContact[]>;
}
export declare type IContactFactory = IHasGetFactory<IContact> & IHasGetByIdFactory<IContact> & IHasCreateFactory<IContact> & IHasUpdateFactory<IContact> & IResourceFactory<IContact> & IHasTagsFactory<IContact>;
/**

@@ -142,0 +41,0 @@ * Фабрика управления контактами

@@ -6,8 +6,12 @@ /**

import { ILead } from "../activeRecords/Lead";
import ResourcePagination from "../ResourcePagination";
import { IRequestOptions } from "../../interfaces/common";
import { JSONObject } from "../../types";
import { IResourceFactory } from "../../interfaces/api";
import { IGetCriteria } from "./mixins/hasGetByCriteria";
import { IHasGetByIdCriteria } from "./mixins/hasGetById";
import { IGetCriteria, IHasGetFactory } from "./mixins/hasGetByCriteria";
import { IHasGetByIdFactory } from "./mixins/hasGetById";
import { IHasCreateFactory } from "./mixins/hasCreate";
import { IHasUpdateFactory } from "./mixins/hasUpdate";
import { IHasTagsFactory } from "./mixins/hasTags";
export interface LeadsGetCriteria extends IGetCriteria {
filter?: string;
}
export interface LeadsCreateCriteria {

@@ -30,109 +34,3 @@ name?: string;

}
export interface ILeadFactory extends IResourceFactory<ILead> {
/**
* @param criteria фильтр сделок (https://www.amocrm.ru/developers/content/crm_platform/leads-api#leads-list)
* @example
* ```ts
* const pagination = await client.leads.get({
* order: 'created_at',
* page: 2,
* query: 'Иванов'
* })
* ```
* @param options настройки запроса и обработки результата
* @returns постраничную навигацию, экземпляр {@link ResourcePagination}
*
* @example
* ```ts
* const pagination = await client.leads.get()
* const data = pagination.getData(); // [lead, lead]
* const page = pagination.getPage();
*
* await pagination.next();
*
* const nextData = pagination.data();
* ```
*
* Метод {@link ResourcePagination.getData | getData()} навигации вернёт массив объектов {@link Lead}
*
* */
get(criteria?: IGetCriteria, options?: IRequestOptions): Promise<ResourcePagination<ILead>>;
/**
* Находит сделку по её id
* @param identity id сделки
* @param criteria параметры получения сделки (https://www.amocrm.ru/developers/content/crm_platform/leads-api#lead-detail)
* @example
* ```ts
* const lead = client.leads.getById(123, {
* with: 'catalog_elements'
* })
* ```
* @param options настройки запроса и обработки результата
* @returns экземпляр найденной сделки или null, если сделка не найдена.
* */
getById(identity: number, criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<ILead | null>;
/**
* Создаёт новые сделки
* @param criteria параметры создания сделок (https://www.amocrm.ru/developers/content/crm_platform/leads-api#leads-add)
* и/или массив объектов {@link Lead}
* @example
* ```ts
* const leads = await client.leads.create([
* {
* name: "Lead 1"
* },
* {
* name: "Lead 2"
* }
* ])
* ```
*
* @example
* ```ts
* const lead1 = new client.Lead;
* lead1.name = 'Lead 1';
* const lead2 = new client.Lead;
* lead2.name = 'Lead 2';
*
* await client.leads.create([lead1, lead2])
* ```
*
* @example
* ```ts
* const leads = await client.leads.create([
* new client.Lead({
* name: "Lead 1"
* }),
* {
* name: "Lead 2"
* }
* ]);
* ```
*
* @param options настройки запроса и обработки результата
* @returns массив объектов {@link Lead}. Если в параметр criteria передавались экземпляры {@link Lead}, после
* создания сделок в AmoCRM, у них обновится поле id
*
* @example
* ```ts
* const lead1 = new client.Lead;
* lead1.name = 'Lead 1';
* lead1.id; // undefined;
*
* await client.leads.create([lead1])
*
* lead1.id; // 123
* ```
* */
create(criteria: (LeadsCreateCriteria | ILead)[], options?: IRequestOptions): Promise<ILead[]>;
/**
* Обновляет существующие сделки. Принцип работы метода аналогичен {@link create}
* @param criteria параметры обновления сделок (https://www.amocrm.ru/developers/content/crm_platform/leads-api#leads-edit)
* и/или массив объектов {@link Lead}
* @param options настройки запроса и обработки результата
* @returns массив объектов {@link Lead}. Если в параметр criteria передавались экземпляры {@link Lead}, после
* создания сделок в AmoCRM, у них обновится поле id
* */
update(criteria: (LeadsUpdateCriteria | ILead)[], options?: IRequestOptions): Promise<ILead[]>;
}
export declare type ILeadFactory = IHasGetFactory<ILead> & IHasGetByIdFactory<ILead> & IHasCreateFactory<ILead> & IHasUpdateFactory<ILead> & IResourceFactory<ILead> & IHasTagsFactory<ILead>;
/**

@@ -139,0 +37,0 @@ * Фабрика управления сделками

@@ -9,3 +9,2 @@ "use strict";

const ResourceFactory_1 = tslib_1.__importDefault(require("../ResourceFactory"));
const Lead_1 = require("../activeRecords/Lead");
const v4_1 = tslib_1.__importDefault(require("../../schema/v4"));

@@ -17,2 +16,3 @@ const hasGetByCriteria_1 = require("./mixins/hasGetByCriteria");

const util_1 = require("../../util");
const hasTags_1 = require("./mixins/hasTags");
/**

@@ -23,3 +23,3 @@ * Фабрика управления сделками

getEntityClass() {
return Lead_1.Lead;
return this.getClient().getEntityConstructors().Lead;
}

@@ -46,4 +46,5 @@ getBaseUrl() {

hasCreate_1.hasCreate,
hasUpdate_1.hasUpdate
hasUpdate_1.hasUpdate,
hasTags_1.hasTags
]);
//# sourceMappingURL=LeadFactory.js.map

@@ -14,12 +14,4 @@ "use strict";

const response = this.getEmbedded(data);
const result = response.map((attributes, index) => {
const entityCriteria = criteria[index];
const instance = entityCriteria instanceof this.getEntityClass() ?
entityCriteria :
this.from(entityCriteria);
instance.id = attributes.id;
return instance;
});
this.emit('create');
return result;
return response.map(attributes => this.from(attributes));
});

@@ -26,0 +18,0 @@ }

import { IRequestOptions } from "../../../interfaces/common";
import { IResourceEntity, IResourceFactory, IResourcePagination } from "../../../interfaces/api";
import { IResourceEntity, IResourceFactory } from "../../../interfaces/api";
import { IResourcePagination } from "../../ResourcePagination";
import { TFactoryConstructor } from "../../../types";

@@ -9,8 +10,7 @@ export interface IGetCriteria {

query?: string | number;
filter?: string;
order?: string;
}
export interface IHasGetWithCriteria<T> {
export interface IHasGetFactory<T> {
get(criteria?: IGetCriteria, options?: IRequestOptions): Promise<IResourcePagination<T>>;
}
export declare function hasGetByCriteria<T extends IResourceEntity<IResourceFactory<T>>>(Base: TFactoryConstructor<T>): TFactoryConstructor<T>;
import { TFactoryConstructor } from "../../../types";
import { IResourceEntity, IResourceFactory } from "../../../interfaces/api";
import { IRequestOptions } from "../../../interfaces/common";
export declare enum GetWith {
CONTACTS = "contacts",
COMPANIES = "companies",
CATALOG_ELEMENTS = "catalog_elements",
LOSS_REASON = "loss_reason"
}
export interface IHasGetByIdCriteria {
with?: string;
with?: string[];
}
export interface ICanGetByIdFactory<T extends IResourceEntity<IResourceFactory<T>>> extends IResourceFactory<T> {
export interface IHasGetByIdFactory<T extends IResourceEntity<IResourceFactory<T>>> extends IResourceFactory<T> {
getById(identity: number, criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<T | null>;
}
export declare const getRequestCriteria: (criteria?: IHasGetByIdCriteria | undefined) => {
with: string;
} | undefined;
export declare function hasGetById<T extends IResourceEntity<IResourceFactory<T>>>(Base: TFactoryConstructor<T>): TFactoryConstructor<T>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasGetById = void 0;
exports.hasGetById = exports.getRequestCriteria = exports.GetWith = void 0;
const tslib_1 = require("tslib");
var GetWith;
(function (GetWith) {
GetWith["CONTACTS"] = "contacts";
GetWith["COMPANIES"] = "companies";
GetWith["CATALOG_ELEMENTS"] = "catalog_elements";
GetWith["LOSS_REASON"] = "loss_reason";
})(GetWith = exports.GetWith || (exports.GetWith = {}));
const getRequestCriteria = (criteria) => {
if (!criteria) {
return;
}
if (!criteria.with) {
return;
}
return {
with: criteria.with.join(',')
};
};
exports.getRequestCriteria = getRequestCriteria;
function hasGetById(Base) {

@@ -11,3 +30,4 @@ return class HasGetById extends Base {

const request = this.getRequest();
const { data } = yield request.get(url, criteria, options);
const requestCriteria = (0, exports.getRequestCriteria)(criteria);
const { data } = yield request.get(url, requestCriteria, options);
if (!data) {

@@ -14,0 +34,0 @@ return null;

@@ -14,13 +14,5 @@ "use strict";

const response = this.getEmbedded(data);
const result = response.map((attributes, index) => {
const entityCriteria = criteria[index];
const instance = entityCriteria instanceof this.getEntityClass() ?
entityCriteria :
this.from(entityCriteria);
instance.id = attributes.id;
instance.updated_at = attributes.updated_at;
return instance;
});
this.emit('update');
return result;
return response.map(attributes => this.from(attributes));
;
});

@@ -27,0 +19,0 @@ }

import { IEntityAttributes, IResourceEntity, IResourceFactory } from "../interfaces/api";
import { EventEmitter } from "../common/EventEmitter";
import { ICriteriaBuilder } from "./activeRecords/common/CriteriaBuilder";
/**

@@ -9,2 +10,4 @@ * Основной класс сущностей

updated_at?: number;
_embedded?: object;
readonly criteriaBuilder: ICriteriaBuilder;
protected readonly factory: T;

@@ -18,2 +21,4 @@ required: string[];

isNew(): boolean;
getEmbedded(): object;
setEmbedded(patch: object): void;
/**

@@ -20,0 +25,0 @@ * Возвращает все атрибуты сущности, которые должны синхронизироваться с порталом AmoCRM

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const EventEmitter_1 = require("../common/EventEmitter");
const CriteriaBuilder_1 = require("./activeRecords/common/CriteriaBuilder");
/**

@@ -12,2 +13,3 @@ * Основной класс сущностей

this.factory = factory;
this.criteriaBuilder = new CriteriaBuilder_1.CriteriaBuilder(this);
}

@@ -21,6 +23,13 @@ getFactory() {

isNew() {
return this.id !== undefined;
return this.id === undefined;
}
getEmbedded() {
return this._embedded || {};
}
setEmbedded(patch) {
const embedded = this.getEmbedded();
this._embedded = Object.assign(Object.assign({}, embedded), patch);
}
}
exports.default = ResourceEntity;
//# sourceMappingURL=ResourceEntity.js.map

@@ -5,2 +5,3 @@ import { ICollectionResponse, IEntityAttributes, IResourceEntity, IResourceFactory } from "../interfaces/api";

import { TConstructor } from "../types";
import { IClient } from "../Client";
/**

@@ -12,5 +13,7 @@ * Основной класс фабрики сущностей. Класс-фабрика служит для создания

protected readonly request: IClientRequest;
constructor(request: IClientRequest);
protected readonly client: IClient;
constructor(client: IClient);
abstract getBaseUrl(): string;
abstract getEmbeddedKey(): string;
getClient(): IClient;
getEmbedded<A extends IEntityAttributes>(data: ICollectionResponse<A>): A[];

@@ -17,0 +20,0 @@ /**

@@ -11,6 +11,10 @@ "use strict";

class ResourceFactory extends EventEmitter_1.EventEmitter {
constructor(request) {
constructor(client) {
super();
this.request = request;
this.client = client;
this.request = client.getRequest();
}
getClient() {
return this.client;
}
getEmbedded(data) {

@@ -17,0 +21,0 @@ const key = this.getEmbeddedKey();

import { IClientRequest } from "../common/ClientRequest";
import { IPaginatedResponse, IPaginationLinks, IResourceEntity, IResourceFactory, IResourcePagination, IResourcePaginationParams } from "../interfaces/api";
import { IPaginatedResponse, IPaginationLinks, IResourceEntity, IResourceFactory, IResourcePaginationParams } from "../interfaces/api";
export interface IResourcePagination<T> {
fetch(): void;
getData(): T[];
getPage(): number;
hasPrev(): boolean;
hasNext(): boolean;
hasFirst(): boolean;
next(): Promise<boolean | T[]>;
prev(): Promise<boolean | T[]>;
[Symbol.iterator](): Iterator<T>;
}
/**

@@ -13,2 +24,3 @@ * Постраничная навигация вывода сущностей

constructor(request: IClientRequest, params: IResourcePaginationParams<T>);
[Symbol.iterator](): IterableIterator<T>;
/**

@@ -15,0 +27,0 @@ * Загружает данные первой страницы

@@ -15,2 +15,5 @@ "use strict";

}
[Symbol.iterator]() {
return this.data[Symbol.iterator]();
}
/**

@@ -17,0 +20,0 @@ * Загружает данные первой страницы

@@ -1,2 +0,1 @@

import "reflect-metadata";
import { IClientOptions } from "./interfaces/common";

@@ -12,3 +11,3 @@ import { EventEmitter } from "./common/EventEmitter";

import { JSONObject } from "./types";
import { IResourceEntity, IResourceFactory } from "./interfaces/api";
import { IClientConstructors, IResourceEntity, IResourceFactory } from "./interfaces/api";
import { IContact } from "./api/activeRecords/Contact";

@@ -18,7 +17,29 @@ import { IContactFactory } from "./api/factories/ContactFactory";

import { ICompany } from "./api/activeRecords/Company";
export declare type IClientEntity<T> = (attributes?: JSONObject) => T;
import { IFactoryConstructors } from "./api/factories";
import { IEntityConstructors } from "./api/activeRecords";
export declare type IClientEntity<T> = {
new (attributes?: JSONObject): T;
};
export interface IClient {
constructors: IClientConstructors;
getRequest(): IClientRequest;
getFactoryConstructors(): IFactoryConstructors;
getEntityConstructors(): IEntityConstructors;
assignEntity<T extends IResourceEntity<IResourceFactory<T>>>(factory: IResourceFactory<T>): IClientEntity<T>;
readonly token: IToken;
readonly environment: IEnvironment;
readonly request: IClientRequest;
readonly connection: IConnection;
readonly auth: IAuth;
Lead: IClientEntity<ILead>;
Contact: IClientEntity<IContact>;
Company: IClientEntity<ICompany>;
leads: ILeadFactory;
contacts: IContactFactory;
companies: ICompanyFactory;
}
/**
* Основной класс библиотеки
* */
export declare class Client extends EventEmitter {
export declare class Client extends EventEmitter implements IClient {
readonly token: IToken;

@@ -36,2 +57,19 @@ readonly environment: IEnvironment;

constructor(options: IClientOptions);
get constructors(): {
factories: IFactoryConstructors;
entities: {
Lead: import("./types").TConstructor<ILead>;
Contact: import("./types").TConstructor<IContact>;
Company: import("./types").TConstructor<ICompany>;
Tag: import("./types").TConstructor<import("./api/activeRecords/Tag").ITag>;
};
};
getRequest(): IClientRequest;
getFactoryConstructors(): IFactoryConstructors;
getEntityConstructors(): {
Lead: import("./types").TConstructor<ILead>;
Contact: import("./types").TConstructor<IContact>;
Company: import("./types").TConstructor<ICompany>;
Tag: import("./types").TConstructor<import("./api/activeRecords/Tag").ITag>;
};
/**

@@ -42,3 +80,3 @@ * Привязывает конструктор сущностей

* */
protected assignEntity<T extends IResourceEntity<IResourceFactory<T>>>(factory: IResourceFactory<T>): IClientEntity<T>;
assignEntity<T extends IResourceEntity<IResourceFactory<T>>>(factory: IResourceFactory<T>): IClientEntity<T>;
}

@@ -5,3 +5,2 @@ "use strict";

const tslib_1 = require("tslib");
require("reflect-metadata");
const EventEmitter_1 = require("./common/EventEmitter");

@@ -13,5 +12,3 @@ const Connection_1 = require("./common/Connection");

const Token_1 = require("./common/Token");
const LeadFactory_1 = require("./api/factories/LeadFactory");
const ContactFactory_1 = require("./api/factories/ContactFactory");
const CompanyFactory_1 = tslib_1.__importDefault(require("./api/factories/CompanyFactory"));
const constructors_1 = tslib_1.__importDefault(require("./common/constructors"));
/**

@@ -31,9 +28,22 @@ * Основной класс библиотеки

this.request = new ClientRequest_1.ClientRequest(this.connection);
this.leads = new LeadFactory_1.LeadFactory(this.request);
const { factories } = this.constructors;
this.leads = new factories.leads(this);
this.contacts = new factories.contacts(this);
this.companies = new factories.companies(this);
this.Lead = this.assignEntity(this.leads);
this.contacts = new ContactFactory_1.ContactFactory(this.request);
this.Contact = this.assignEntity(this.contacts);
this.companies = new CompanyFactory_1.default(this.request);
this.Company = this.assignEntity(this.companies);
}
get constructors() {
return constructors_1.default;
}
getRequest() {
return this.request;
}
getFactoryConstructors() {
return this.constructors.factories;
}
getEntityConstructors() {
return this.constructors.entities;
}
/**

@@ -40,0 +50,0 @@ * Привязывает конструктор сущностей

@@ -9,2 +9,3 @@ import { IAPIResponse, IRequestOptions } from "../interfaces/common";

patch<T>(url: string, data?: object, options?: IRequestOptions): Promise<IAPIResponse<T>>;
delete<T>(url: string, data?: object, options?: IRequestOptions): Promise<IAPIResponse<T>>;
}

@@ -22,2 +23,3 @@ /**

patch<T>(url: string, data?: object, options?: IRequestOptions): Promise<IAPIResponse<T>>;
delete<T>(url: string, data?: object, options?: IRequestOptions): Promise<IAPIResponse<T>>;
}

@@ -26,4 +26,7 @@ "use strict";

}
delete(url, data, options) {
return this.connection.makeRequest('DELETE', url, data, options);
}
}
exports.ClientRequest = ClientRequest;
//# sourceMappingURL=ClientRequest.js.map

@@ -1,2 +0,2 @@

import { EventEmitter } from "./EventEmitter";
import { EventEmitter, IEventEmitter } from "./EventEmitter";
import { IAPIResponse, IRequestOptions } from "../interfaces/common";

@@ -7,3 +7,3 @@ import { IToken } from "./Token";

import { IAuth } from "./Auth";
export interface IConnection {
export interface IConnection extends IEventEmitter {
update(): Promise<boolean>;

@@ -10,0 +10,0 @@ isTokenExpired(): boolean;

@@ -9,2 +9,3 @@ import { EventEmitter } from "./EventEmitter";

checkErrors<T>(data: T, apiResponse: IAPIResponse<string>): void;
handleError<T>(data: T, apiResponse: IAPIResponse<string>): void;
}

@@ -40,8 +40,11 @@ "use strict";

if ('status' in data) {
console.error(data);
throw new APIResponseError_1.default('API_RESPONSE_ERROR', data, apiResponse);
this.handleError(data, apiResponse);
}
}
handleError(data, apiResponse) {
console.error(JSON.stringify(data, null, 2));
throw new APIResponseError_1.default('API_RESPONSE_ERROR', data, apiResponse);
}
}
exports.default = JSONResponseParser;
//# sourceMappingURL=JSONResponseParser.js.map
import { IClientRequest } from "../common/ClientRequest";
import { JSONObject, TConstructor } from "../types";
import { TConstructor } from "../types";
import { IRequestOptions } from "./common";
import { IEventEmitter } from "../common/EventEmitter";
import { IClient } from "../Client";
import { IEntityConstructors } from "../api/activeRecords";
import { IFactoryConstructors } from "../api/factories";
import { ICriteriaBuilder } from "../api/activeRecords/common/CriteriaBuilder";
export interface IClientConstructors {
entities: IEntityConstructors;
factories: IFactoryConstructors;
}
export interface IResourceFactory<T extends IResourceEntity<IResourceFactory<T>>> extends IEventEmitter {
getClient(): IClient;
getEntityClass(): TConstructor<T>;

@@ -14,2 +23,3 @@ createEntity(): T;

getEntityCriteria(criteriaData: (object)[]): IEntityAttributes[];
getEntityCriteria<R>(criteriaData: (object)[]): R[];
}

@@ -19,2 +29,3 @@ export interface IResourceEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IEventEmitter {

updated_at?: number;
criteriaBuilder: ICriteriaBuilder;
isNew(): boolean;

@@ -25,5 +36,13 @@ getFactory(): T;

}
export interface IResourceEntityConstructor<T> {
from(request: IClientRequest, attributes?: JSONObject): T;
export interface IResourceEntityWithEmbedded<T extends IResourceFactory<IResourceEntity<T>>, E extends IEmbeddedEntity> extends IResourceEntity<T> {
getEmbedded(): IEmbedded<E>;
setEmbedded(patch: object): void;
}
export interface ISelfResponse {
id: number;
updated_at: number;
_links: {
href: string;
};
}
export interface ICollectionResponse<T> {

@@ -37,6 +56,2 @@ _links: {

}
export interface IResourcePagination<T> {
fetch(): void;
getData(): T[];
}
export interface IPaginationLinks {

@@ -72,2 +87,9 @@ current?: string;

id?: number;
_embedded?: object;
}
export interface IEmbeddedEntity {
id?: number;
}
export interface IEmbedded<T extends IEmbeddedEntity> {
[index: string]: T[];
}
/// <reference types="node" />
import * as http from 'http';
import { TStringValueObject } from "../types";
import { TClientPlugin, TStringValueObject } from "../types";
export interface ITokenOptions {

@@ -17,5 +17,5 @@ client_id: string;

export interface IClientOptions {
[index: string]: string | object;
domain: string;
auth: IAuthOptions;
plugins?: TClientPlugin[];
}

@@ -65,1 +65,2 @@ export interface ITokenData {

}
export declare type ObjectKey<T> = keyof T;
declare const _default: {
apiUrl: string;
auth: {

@@ -15,4 +16,7 @@ token: string;

};
customers: {
path: string;
};
};
};
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
apiUrl: '/api/v4',
auth: {

@@ -16,2 +17,5 @@ token: '/oauth2/access_token'

path: '/api/v4/companies'
},
customers: {
path: '/api/v4/customers'
}

@@ -18,0 +22,0 @@ }

@@ -1,2 +0,2 @@

import { IResourceEntity, IResourceFactory } from "./interfaces/api";
import { IClientConstructors, IResourceEntity, IResourceFactory } from "./interfaces/api";
export declare type TStringValueObject = {

@@ -11,4 +11,5 @@ [index: string]: string;

}
export declare type TClientPlugin = (constructors: IClientConstructors) => IClientConstructors;
export declare type TConstructor<T> = new (...args: any[]) => T;
export declare type TFactoryConstructor<T extends IResourceEntity<IResourceFactory<T>>> = TConstructor<IResourceFactory<T>>;
export declare type TEntityConstructor<T extends IResourceFactory<IResourceEntity<T>>> = TConstructor<IResourceEntity<T>>;

@@ -8,7 +8,5 @@ "use strict";

function applyMixins(baseClass, mixins) {
return mixins.reduce((target, mixin) => {
return mixin(target);
}, baseClass);
return mixins.reduce((target, mixin) => mixin(target), baseClass);
}
exports.applyMixins = applyMixins;
//# sourceMappingURL=util.js.map
{
"name": "amocrm-js",
"version": "3.3.5",
"version": "3.4.0",
"description": "JS Library for AmoCRM",

@@ -10,5 +10,6 @@ "main": "./dist/Client.js",

"engines": {
"node": ">=12"
"node": ">=16"
},
"scripts": {
"test:setup": "npx ts-node tests/setup.ts",
"test": "jest --no-cache --verbose false --silent false",

@@ -35,3 +36,3 @@ "build": "tsc",

"devDependencies": {
"@babel/core": "^7.17.10",
"@babel/core": "^7.21.0",
"@babel/plugin-proposal-class-properties": "^7.17.12",

@@ -44,2 +45,3 @@ "@babel/plugin-proposal-decorators": "^7.17.12",

"@types/jest": "^27.5.1",
"@types/lodash": "^4.14.191",
"@types/node": "^17.0.34",

@@ -62,4 +64,4 @@ "@types/qs": "^6.9.7",

"dependencies": {
"lodash": "^4.17.21",
"qs": "^6.10.3",
"reflect-metadata": "^0.1.13",
"tslib": "^2.4.0",

@@ -66,0 +68,0 @@ "typescript": "^4.6.4"

@@ -18,6 +18,8 @@

По вопросам сотрудничества и проектам [пишите в Telegram](https://t.me/neizerth).
По вопросам сотрудничества [пишите мне в Telegram](https://t.me/neizerth).
## Сообщество и вопросы
[YouTube-плейлист по AmoCRM и библиотеке](https://www.youtube.com/playlist?list=PLcMMJHB8iEYmoNo5PnSjv8286zzMw4bdq)
По всем вопросам работы библиотеки заходите в [чат проекта в Telegram](https://t.me/+QKoG6INanhIyYTAy).

@@ -162,3 +164,3 @@ Сделаем вместе пространство уютным :)

(как это сделать, описано ниже), извлекает код авторизации и
с помощью *crm.connection.setCode(code)* автоматически получает токен для работы
с помощью *crm.auth.setCode(code)* автоматически получает токен для работы

@@ -231,2 +233,3 @@ #### Использование в целях разработки

- Компании [[примеры работы]](./examples/javascript/03-companies)
- Теги [[примеры работы]](./examples/javascript/04-tags)

@@ -233,0 +236,0 @@ <a id="requests"></a>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc