Huge News!Announcing our $40M Series B led by Abstract Ventures.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.4.2 to 3.6.0

dist/api/activeRecords/common/EntityCriteriaBuilder.d.ts

28

dist/api/activeRecords/common/EmbeddedEntityList.d.ts

@@ -1,5 +0,7 @@

import { IEmbedded, IEmbeddedEntity, IResourceEntity, IResourceEntityWithEmbedded, IResourceFactory } from "../../../interfaces/api";
import { IEmbedded, IEmbeddedEntity, IResourceEntity, IResourceFactory } from "../../../interfaces/api";
import { ObjectKey } from "../../../interfaces/common";
import { ICriteriaItem } from "./CriteriaBuilder";
export interface IEmbeddedEntityList<E extends IEmbeddedEntity> extends ICriteriaItem {
import { IEntityCriteriaItem } from "./EntityCriteriaBuilder";
import { IHasEmbeddedEntity } from "../mixins/hasEmbedded";
export interface IEmbeddedEntityList<E extends IEmbeddedEntity> extends IEntityCriteriaItem {
readonly embeddedType: ObjectKey<IEmbedded<E>>;
length: number;

@@ -11,2 +13,3 @@ add(criteria: E[]): void;

}
export declare type IHasTypedEmbeddedEntity<T extends IResourceFactory<IResourceEntity<T>>, E> = IHasEmbeddedEntity<T, IEmbedded<E>>;
export interface IQueryAttributes<E extends IEmbeddedEntity> {

@@ -18,9 +21,9 @@ save?: ObjectKey<E>[];

export interface IEmbeddedEntityListOptions<T extends IResourceFactory<IResourceEntity<T>>, E extends IEmbeddedEntity> {
entity: IResourceEntityWithEmbedded<T, E>;
entity: IHasTypedEmbeddedEntity<T, E>;
embeddedType: ObjectKey<IEmbedded<E>>;
attributes?: IQueryAttributes<E>;
}
export declare class EmbeddedEntityList<T extends IResourceFactory<IResourceEntityWithEmbedded<T, E>>, E extends IEmbeddedEntity> implements IEmbeddedEntityList<E> {
protected entity: IResourceEntityWithEmbedded<T, E>;
protected embeddedType: ObjectKey<IEmbedded<E>>;
export declare class EmbeddedEntityList<T extends IResourceFactory<IHasTypedEmbeddedEntity<T, E>>, E extends IEmbeddedEntity> implements IEmbeddedEntityList<E> {
readonly embeddedType: ObjectKey<IEmbedded<E>>;
protected entity: IHasTypedEmbeddedEntity<T, E>;
protected attributes?: IQueryAttributes<E>;

@@ -37,19 +40,20 @@ constructor(options: IEmbeddedEntityListOptions<T, E>);

_embedded: {
[x: string]: E[];
[x: string]: { [P in keyof E]?: E[P] | undefined; }[];
};
};
getCreateCriteria(): {
protected pickItemAttributes(item: E, attributes?: ObjectKey<E>[]): { [P in keyof E]?: E[P] | undefined; };
get createCriteria(): {
_embedded?: undefined;
} | {
_embedded: {
[x: string]: E[];
[x: string]: { [P in keyof E]?: E[P] | undefined; }[];
};
};
getUpdateCriteria(): {
get updateCriteria(): {
_embedded?: undefined;
} | {
_embedded: {
[x: string]: E[];
[x: string]: { [P in keyof E]?: E[P] | undefined; }[];
};
};
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmbeddedEntityList = void 0;
const lodash_1 = require("lodash");
class EmbeddedEntityList {

@@ -17,4 +16,6 @@ constructor(options) {

set(value) {
const embedded = this.entity.getEmbedded();
this.entity.setEmbedded(Object.assign(Object.assign({}, embedded), { [this.embeddedType]: value }));
const patch = {
[this.embeddedType]: value
};
this.entity.setEmbedded(patch);
}

@@ -49,3 +50,3 @@ get length() {

}
const value = this.get().map(item => attributes ? (0, lodash_1.pick)(item, attributes) : item);
const value = this.get().map(item => this.pickItemAttributes(item, attributes));
return {

@@ -57,3 +58,15 @@ _embedded: {

}
getCreateCriteria() {
pickItemAttributes(item, attributes) {
if (!attributes) {
return item;
}
const target = {};
return attributes.reduce((target, key) => {
if (key in item) {
target[key] = item[key];
}
return target;
}, target);
}
get createCriteria() {
var _a, _b;

@@ -63,3 +76,3 @@ const attributes = ((_a = this.attributes) === null || _a === void 0 ? void 0 : _a.create) || ((_b = this.attributes) === null || _b === void 0 ? void 0 : _b.save);

}
getUpdateCriteria() {
get updateCriteria() {
var _a, _b;

@@ -66,0 +79,0 @@ const attributes = ((_a = this.attributes) === null || _a === void 0 ? void 0 : _a.update) || ((_b = this.attributes) === null || _b === void 0 ? void 0 : _b.save);

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

import { IEntityAttributes, IResourceEntity } from "../../interfaces/api";
import { hasSave, IHasSaveEntity } from "./mixins/hasSave";
import { hasFetch, IHasFetchEntity } from "./mixins/hasFetch";
import { IHasCreateEntity } from "./mixins/hasCreate";
import { IHasUpdateEntity } from "./mixins/hasUpdate";
import { hasSave, IHasSave } from "./mixins/hasSave";
import { hasFetch, IHasFetch } from "./mixins/hasFetch";
import { IHasEmbeddedTagsEntity } from "./mixins/embedded/hasEmbeddedTags";

@@ -17,2 +15,4 @@ import { IHasEmbeddedCustomersEntity } from "./mixins/embedded/hasEmbeddedCustomers";

import { IHasEmbeddedContactsEntity } from "./mixins/embedded/hasEmbeddedContacts";
import { IHasEmbedded } from "./mixins/hasEmbedded";
import { hasTasks, IHasTasks } from "./mixins/hasTasks";
export interface CompanyAttributes extends IEntityAttributes {

@@ -31,3 +31,3 @@ id?: number;

account_id?: number;
_embedded?: ICompanyHasEmbedded;
_embedded?: ICompanyEmbedded;
}

@@ -40,4 +40,4 @@ export interface 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;
export declare type ICompanyEmbedded = IHasEmbeddedTagsEntity<ICompanyFactory> & IHasEmbeddedContactsEntity<ICompanyFactory> & IHasEmbeddedCustomersEntity<ICompanyFactory> & IHasEmbeddedCatalogElementsEntity<ICompanyFactory>;
export declare type ICompany = IResourceEntity<ICompanyFactory> & CompanyAttributes & IHasEmbedded<ICompanyEmbedded> & IHasSave<ICompanyFactory> & IHasFetch<ICompanyFactory> & ICompanyEmbedded & IHasTasks<ICompanyFactory>;
/**

@@ -65,8 +65,8 @@ * Сделка

is_price_modified_by_robot?: boolean;
_embedded?: ICompanyHasEmbedded;
_embedded?: ICompanyEmbedded;
getAttributes(): CompanyAttributes;
setAttributes(attributes?: CompanyAttributes): void;
}
export declare const mixins: (typeof hasSave | typeof hasFetch)[];
export declare const mixins: (typeof hasSave | typeof hasFetch | typeof hasTasks)[];
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>;

@@ -18,2 +18,4 @@ "use strict";

const hasEmbeddedContacts_1 = require("./mixins/embedded/hasEmbeddedContacts");
const hasEmbedded_1 = require("./mixins/hasEmbedded");
const hasTasks_1 = require("./mixins/hasTasks");
/**

@@ -58,2 +60,4 @@ * Сделка

hasFetch_1.hasFetch,
hasEmbedded_1.hasEmbedded,
hasTasks_1.hasTasks
];

@@ -60,0 +64,0 @@ exports.embeddedMixins = [

@@ -8,4 +8,4 @@ /**

import { IEmbeddedEntity, IEntityAttributes, IResourceEntity } from "../../interfaces/api";
import { hasSave, IHasSaveEntity } from "./mixins/hasSave";
import { hasFetch, IHasFetchEntity } from "./mixins/hasFetch";
import { hasSave, IHasSave } from "./mixins/hasSave";
import { hasFetch, IHasFetch } from "./mixins/hasFetch";
import { IHasEmbeddedTags } from "./Tag";

@@ -19,2 +19,4 @@ import { IHasEmbeddedCompanies } from "./Company";

import { IHasEmbeddedCustomersEntity } from "./mixins/embedded/hasEmbeddedCustomers";
import { IHasEmbedded } from "./mixins/hasEmbedded";
import { hasTasks, IHasTasks } from "./mixins/hasTasks";
export interface ContactAttributes extends IEntityAttributes {

@@ -46,3 +48,3 @@ id?: number;

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 type IContact = IResourceEntity<IContactFactory> & ContactAttributes & IHasEmbedded<IContactEmbedded> & IHasSave<IContactFactory> & IHasFetch<IContactFactory> & IHasTasks<IContactFactory> & IContactHasEmbedded;
export declare class BaseContact extends ResourceEntity<IContactFactory> {

@@ -66,4 +68,4 @@ name?: string;

}
export declare const mixins: (typeof hasSave | typeof hasFetch)[];
export declare const mixins: (typeof hasSave | typeof hasFetch | typeof hasTasks)[];
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>;

@@ -18,2 +18,4 @@ "use strict";

const hasEmbeddedCustomers_1 = require("./mixins/embedded/hasEmbeddedCustomers");
const hasEmbedded_1 = require("./mixins/hasEmbedded");
const hasTasks_1 = require("./mixins/hasTasks");
class BaseContact extends ResourceEntity_1.default {

@@ -59,2 +61,4 @@ getAttributes() {

hasFetch_1.hasFetch,
hasEmbedded_1.hasEmbedded,
hasTasks_1.hasTasks,
];

@@ -61,0 +65,0 @@ exports.embeddedMixins = [

import { IEmbeddedEntity, IEntityAttributes, IResourceEntity } from "../../interfaces/api";
import { ICustomerFactory } from "../factories/CustomerFactory";
import { JSONObject, TConstructor } from "../../types";
import { IRequestOptions } from "../../interfaces/common";
import { IHasGetByIdCriteria } from "../factories/mixins/hasGetById";
import ResourceEntity from "../ResourceEntity";
import { IHasSave } from "./mixins/hasSave";
import { IHasFetch } from "./mixins/hasFetch";
import { IHasEmbeddedTags } from "./Tag";
import { IHasTasks } from "./mixins/hasTasks";
import { IHasEmbedded } from "./mixins/hasEmbedded";
export interface CustomerAttributes extends IEntityAttributes {

@@ -28,8 +30,3 @@ name?: string;

}
export interface ICustomer extends IResourceEntity<ICustomerFactory>, CustomerAttributes {
create(options?: IRequestOptions): Promise<ICustomer>;
update(options?: IRequestOptions): Promise<ICustomer>;
save(options?: IRequestOptions): Promise<ICustomer>;
fetch(criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<ICustomer>;
}
export declare type ICustomer = IResourceEntity<ICustomerFactory> & CustomerAttributes & IHasEmbedded<ICustomerEmbedded> & IHasSave<ICustomerFactory> & IHasFetch<ICustomerFactory> & IHasTasks<ICustomerFactory>;
export declare class BaseCustomer extends ResourceEntity<ICustomerFactory> {

@@ -36,0 +33,0 @@ name?: string;

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

const hasFetch_1 = require("./mixins/hasFetch");
const hasTasks_1 = require("./mixins/hasTasks");
class BaseCustomer extends ResourceEntity_1.default {

@@ -46,4 +47,5 @@ getAttributes() {

hasSave_1.hasSave,
hasFetch_1.hasFetch
hasFetch_1.hasFetch,
hasTasks_1.hasTasks
]);
//# sourceMappingURL=Customer.js.map

@@ -8,4 +8,4 @@ /**

import { IEntityAttributes, IResourceEntity } from "../../interfaces/api";
import { hasSave, IHasSaveEntity } from "./mixins/hasSave";
import { hasFetch, IHasFetchEntity } from "./mixins/hasFetch";
import { hasSave, IHasSave } from "./mixins/hasSave";
import { hasFetch, IHasFetch } from "./mixins/hasFetch";
import { IHasEmbeddedTags } from "./Tag";

@@ -21,2 +21,4 @@ import { IHasEmbeddedContacts } from "./Contact";

import { IHasEmbeddedSource } from "./Source";
import { IHasEmbedded } from "./mixins/hasEmbedded";
import { hasTasks, IHasTasks } from "./mixins/hasTasks";
export interface LeadAttributes extends IEntityAttributes {

@@ -42,2 +44,3 @@ id?: number;

account_id?: number;
labor_cost?: number;
is_price_modified_by_robot?: boolean;

@@ -47,3 +50,3 @@ _embedded?: ILeadEmbedded;

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 ILead = IResourceEntity<ILeadFactory> & LeadAttributes & IHasEmbedded<ILeadEmbedded> & IHasSave<ILeadFactory> & IHasFetch<ILeadFactory> & ILeadHasEmbedded & IHasTasks<ILeadFactory>;
export declare type ILeadEmbedded = IHasEmbeddedTags & IHasEmbeddedContacts & IHasEmbeddedCompanies & IHasEmbeddedCatalogElements & IHasEmbeddedLossReasons & IHasEmbeddedSource;

@@ -71,2 +74,3 @@ /**

account_id?: number;
labor_cost?: number;
is_price_modified_by_robot?: boolean;

@@ -77,4 +81,4 @@ _embedded?: ILeadEmbedded;

}
export declare const mixins: (typeof hasSave | typeof hasFetch)[];
export declare const mixins: (typeof hasSave | typeof hasFetch | typeof hasTasks)[];
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>;

@@ -19,2 +19,4 @@ "use strict";

const hasEmbeddedSource_1 = require("./mixins/embedded/hasEmbeddedSource");
const hasEmbedded_1 = require("./mixins/hasEmbedded");
const hasTasks_1 = require("./mixins/hasTasks");
/**

@@ -42,2 +44,3 @@ * Сделка

account_id: this.account_id,
labor_cost: this.labor_cost,
is_price_modified_by_robot: this.is_price_modified_by_robot,

@@ -59,2 +62,5 @@ _embedded: this._embedded

this.updated_by = attributes.updated_by;
this.closed_at = attributes.closed_at;
this.created_at = attributes.created_at;
this.updated_at = attributes.updated_at;
this.closed_task_at = attributes.closed_task_at;

@@ -65,2 +71,3 @@ this.is_deleted = attributes.is_deleted;

this.account_id = attributes.account_id;
this.labor_cost = attributes.labor_cost;
this.is_price_modified_by_robot = attributes.is_price_modified_by_robot;

@@ -76,2 +83,4 @@ this._embedded = attributes._embedded;

hasFetch_1.hasFetch,
hasEmbedded_1.hasEmbedded,
hasTasks_1.hasTasks,
];

@@ -78,0 +87,0 @@ exports.embeddedMixins = [

@@ -1,6 +0,7 @@

import { IResourceEntity, IResourceEntityWithEmbedded, IResourceFactory } from "../../../../interfaces/api";
import { IEmbedded, IResourceEntity, IResourceFactory } from "../../../../interfaces/api";
import { TConstructor } from "../../../../types";
import { IEmbeddedCatalogElement } from "../../CatalogElement";
import { IHasSaveEntity } from "../hasSave";
import { IHasCreateAndUpdateEntity, IHasSave } from "../hasSave";
import { IEmbeddedEntityList, IQueryAttributes } from "../../common/EmbeddedEntityList";
import { IHasEmbedded } from "../hasEmbedded";
export interface IHasEmbeddedCatalogElementsEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IResourceEntity<T> {

@@ -12,3 +13,3 @@ embeddedCatalogElements: IEmbeddedEntityList<IEmbeddedCatalogElement>;

}
export declare type IRequiredEntity<T extends IResourceFactory<IResourceEntity<T>>> = IHasSaveEntity<T> & IResourceEntityWithEmbedded<T, IEmbeddedCatalogElement>;
export declare type IRequiredEntity<T extends IResourceFactory<IHasCreateAndUpdateEntity<T>>> = IResourceEntity<T> & IHasSave<T> & IHasEmbedded<IEmbedded<IEmbeddedCatalogElement>>;
export declare function hasEmbeddedCatalogElements(options?: IHasEmbeddedCatalogElementsOptions): <T extends IResourceFactory<IRequiredEntity<T>>>(Base: TConstructor<IRequiredEntity<T>>) => TConstructor<IResourceEntity<T>>;

@@ -1,6 +0,7 @@

import { IResourceEntity, IResourceEntityWithEmbedded, IResourceFactory } from "../../../../interfaces/api";
import { IEmbedded, IResourceEntity, IResourceFactory } from "../../../../interfaces/api";
import { TConstructor } from "../../../../types";
import { IEmbeddedCompany } from "../../Company";
import { IHasSaveEntity } from "../hasSave";
import { IHasCreateAndUpdateEntity, IHasSave } from "../hasSave";
import { IEmbeddedEntityList, IQueryAttributes } from "../../common/EmbeddedEntityList";
import { IHasEmbedded } from "../hasEmbedded";
export interface IHasEmbeddedCompaniesEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IResourceEntity<T> {

@@ -12,3 +13,3 @@ embeddedCompanies: IEmbeddedEntityList<IEmbeddedCompany>;

}
export declare type IRequiredEntity<T extends IResourceFactory<IResourceEntity<T>>> = IHasSaveEntity<T> & IResourceEntityWithEmbedded<T, IEmbeddedCompany>;
export declare type IRequiredEntity<T extends IResourceFactory<IHasCreateAndUpdateEntity<T>>> = IResourceEntity<T> & IHasSave<T> & IHasEmbedded<IEmbedded<IEmbeddedCompany>>;
export declare function hasEmbeddedCompanies(options?: IHasEmbeddedTagsCompaniesOptions): <T extends IResourceFactory<IRequiredEntity<T>>>(Base: TConstructor<IRequiredEntity<T>>) => TConstructor<IResourceEntity<T>>;

@@ -1,6 +0,7 @@

import { IResourceEntity, IResourceEntityWithEmbedded, IResourceFactory } from "../../../../interfaces/api";
import { IEmbedded, IResourceEntity, IResourceFactory } from "../../../../interfaces/api";
import { TConstructor } from "../../../../types";
import { IEmbeddedContact } from "../../Contact";
import { IHasSaveEntity } from "../hasSave";
import { IHasCreateAndUpdateEntity, IHasSaveEntity } from "../hasSave";
import { IEmbeddedEntityList, IQueryAttributes } from "../../common/EmbeddedEntityList";
import { IHasEmbedded } from "../hasEmbedded";
export interface IHasEmbeddedContactsEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IResourceEntity<T> {

@@ -12,3 +13,3 @@ embeddedContacts: IEmbeddedEntityList<IEmbeddedContact>;

}
export declare type IRequiredEntity<T extends IResourceFactory<IResourceEntity<T>>> = IHasSaveEntity<T> & IResourceEntityWithEmbedded<T, IEmbeddedContact>;
export declare type IRequiredEntity<T extends IResourceFactory<IHasCreateAndUpdateEntity<T>>> = IHasSaveEntity<T> & IHasEmbedded<IEmbedded<IEmbeddedContact>>;
export declare function hasEmbeddedContacts(options?: IHasEmbeddedContactsOptions): <T extends IResourceFactory<IRequiredEntity<T>>>(Base: TConstructor<IRequiredEntity<T>>) => TConstructor<IResourceEntity<T>>;

@@ -1,6 +0,7 @@

import { IResourceEntity, IResourceEntityWithEmbedded, IResourceFactory } from "../../../../interfaces/api";
import { IEmbedded, IResourceEntity, IResourceFactory } from "../../../../interfaces/api";
import { TConstructor } from "../../../../types";
import { IEmbeddedCustomer } from "../../Customer";
import { IHasSaveEntity } from "../hasSave";
import { IHasCreateAndUpdateEntity, IHasSave } from "../hasSave";
import { IEmbeddedEntityList, IQueryAttributes } from "../../common/EmbeddedEntityList";
import { IHasEmbedded } from "../hasEmbedded";
export interface IHasEmbeddedCustomersEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IResourceEntity<T> {

@@ -12,3 +13,3 @@ customerList: IEmbeddedEntityList<IEmbeddedCustomer>;

}
export declare type IRequiredEntity<T extends IResourceFactory<IResourceEntity<T>>> = IHasSaveEntity<T> & IResourceEntityWithEmbedded<T, IEmbeddedCustomer>;
export declare type IRequiredEntity<T extends IResourceFactory<IHasCreateAndUpdateEntity<T>>> = IResourceEntity<T> & IHasSave<T> & IHasEmbedded<IEmbedded<IEmbeddedCustomer>>;
export declare function hasEmbeddedCustomers(options?: IHasEmbeddedCustomersOptions): <T extends IResourceFactory<IRequiredEntity<T>>>(Base: TConstructor<IRequiredEntity<T>>) => TConstructor<IResourceEntity<T>>;

@@ -1,6 +0,7 @@

import { IResourceEntity, IResourceEntityWithEmbedded, IResourceFactory } from "../../../../interfaces/api";
import { IEmbedded, IResourceEntity, IResourceFactory } from "../../../../interfaces/api";
import { TConstructor } from "../../../../types";
import { IHasSaveEntity } from "../hasSave";
import { IHasCreateAndUpdateEntity, IHasSave } from "../hasSave";
import { IEmbeddedEntityList, IQueryAttributes } from "../../common/EmbeddedEntityList";
import { IEmbeddedLossReason } from "../../LossReason";
import { IHasEmbedded } from "../hasEmbedded";
export interface IHasEmbeddedLossReasonsEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IResourceEntity<T> {

@@ -12,3 +13,3 @@ lossReasons: IEmbeddedEntityList<IEmbeddedLossReason>;

}
export declare type IRequiredEntity<T extends IResourceFactory<IResourceEntity<T>>> = IHasSaveEntity<T> & IResourceEntityWithEmbedded<T, IEmbeddedLossReason>;
export declare type IRequiredEntity<T extends IResourceFactory<IHasCreateAndUpdateEntity<T>>> = IResourceEntity<T> & IHasSave<T> & IHasEmbedded<IEmbedded<IEmbeddedLossReason>>;
export declare function hasEmbeddedLossReasons(options?: IHasEmbeddedLossReasonsOptions): <T extends IResourceFactory<IRequiredEntity<T>>>(Base: TConstructor<IRequiredEntity<T>>) => TConstructor<IResourceEntity<T>>;

@@ -1,13 +0,14 @@

import { IResourceEntity, IResourceEntityWithEmbedded, IResourceFactory } from "../../../../interfaces/api";
import { IEmbedded, IResourceEntity, IResourceFactory } from "../../../../interfaces/api";
import { TConstructor } from "../../../../types";
import { IEmbeddedTag } from "../../Tag";
import { IHasSaveEntity } from "../hasSave";
import { ICriteriaItem } from "../../common/CriteriaBuilder";
export declare type IRequiredEntity<T extends IResourceFactory<IResourceEntity<T>>> = IHasSaveEntity<T> & IResourceEntityWithEmbedded<T, IEmbeddedTag>;
import { IHasCreateAndUpdateEntity, IHasSave } from "../hasSave";
import { IEntityCriteriaItem } from "../../common/EntityCriteriaBuilder";
import { IHasEmbedded } from "../hasEmbedded";
export declare type IRequiredEntity<T extends IResourceFactory<IHasCreateAndUpdateEntity<T>>> = IResourceEntity<T> & IHasSave<T> & IHasEmbedded<IEmbedded<IEmbeddedTag>>;
export declare function hasEmbeddedSource<T extends IResourceFactory<IRequiredEntity<T>>>(Base: TConstructor<IRequiredEntity<T>>): TConstructor<IResourceEntity<T>>;
export declare class EmbeddedSourceCriteriaItem<T extends IResourceFactory<IRequiredEntity<T>>> implements ICriteriaItem {
export declare class EmbeddedSourceCriteriaItem<T extends IResourceFactory<IRequiredEntity<T>>> implements IEntityCriteriaItem {
protected entity: IRequiredEntity<T>;
constructor(entity: IRequiredEntity<T>);
getCreateCriteria(): object;
getUpdateCriteria(): object;
get createCriteria(): object;
get updateCriteria(): object;
}

@@ -18,6 +18,6 @@ "use strict";

}
getCreateCriteria() {
get createCriteria() {
return {};
}
getUpdateCriteria() {
get updateCriteria() {
return {

@@ -24,0 +24,0 @@ _embedded: {

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

import { IResourceEntity, IResourceEntityWithEmbedded, IResourceFactory } from "../../../../interfaces/api";
import { IEmbedded, IResourceEntity, IResourceFactory } from "../../../../interfaces/api";
import { TConstructor } from "../../../../types";

@@ -6,2 +6,3 @@ import { IEmbeddedTag } from "../../Tag";

import { IEmbeddedEntityList, IQueryAttributes } from "../../common/EmbeddedEntityList";
import { IHasEmbedded } from "../hasEmbedded";
export interface IHasEmbeddedTagsEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IResourceEntity<T> {

@@ -13,3 +14,3 @@ embeddedTags: IEmbeddedEntityList<IEmbeddedTag>;

}
export declare type IRequiredEntity<T extends IResourceFactory<IResourceEntity<T>>> = IHasSaveEntity<T> & IResourceEntityWithEmbedded<T, IEmbeddedTag>;
export declare type IRequiredEntity<T extends IResourceFactory<IHasSaveEntity<T>>> = IHasSaveEntity<T> & IHasEmbedded<IEmbedded<IEmbeddedTag>>;
export declare function hasEmbeddedTags(options?: IHasEmbeddedTagsOptions): <T extends IResourceFactory<IRequiredEntity<T>>>(Base: TConstructor<IRequiredEntity<T>>) => TConstructor<IResourceEntity<T>>;

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

import { IHasCreateFactory } from "../../factories/mixins/hasCreate";
export interface IHasCreateEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IResourceEntity<T> {
create(options?: IRequestOptions): Promise<IHasCreateEntity<T>>;
export interface IHasCreate<T extends IResourceFactory<IResourceEntity<T>>> {
create(options?: IRequestOptions): Promise<IResourceEntity<T>>;
}
export declare type IHasCreateEntity<T extends IResourceFactory<IResourceEntity<T>>> = IResourceEntity<T> & IHasCreate<T>;
export declare function hasCreate<T extends IHasCreateFactory<IResourceEntity<T>>>(Base: TEntityConstructor<T>): TConstructor<IResourceEntity<T>>;

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

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const criteria = this.criteriaBuilder.getCreateCriteria();
const criteria = this.criteriaBuilder.createCriteria;
const factory = this.getFactory();

@@ -12,0 +12,0 @@ const [first] = yield factory.create([criteria], options);

@@ -5,5 +5,5 @@ import { IResourceEntity } from "../../../interfaces/api";

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 interface IHasFetch<T extends IHasGetByIdFactory<IResourceEntity<T>>> {
fetch(criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<IResourceEntity<T> | null>;
}
export declare function hasFetch<T extends IHasGetByIdFactory<IResourceEntity<T>>>(Base: TEntityConstructor<T>): TConstructor<IResourceEntity<T>>;

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

const tslib_1 = require("tslib");
// export type IHasFetchEntity<T extends IHasGetByIdFactory<IResourceEntity<T>>> = IResourceEntity<T> & IHasFetch<T>;
function hasFetch(Base) {
// return class HasFetch extends Base implements IHasFetch<T> {
return class HasFetch extends Base {

@@ -11,9 +13,9 @@ fetch(criteria, options) {

if (this.isNew()) {
return false;
return null;
}
const id = this.id;
const factory = this.getFactory();
const lead = yield factory.getById(id, criteria, options);
const instance = yield factory.getById(id, criteria, options);
this.emit('fetch');
return lead;
return instance;
});

@@ -20,0 +22,0 @@ }

@@ -6,9 +6,10 @@ import { IResourceEntity, IResourceFactory } from "../../../interfaces/api";

import { IHasUpdateFactory } from "../../factories/mixins/hasUpdate";
import { IHasCreateEntity } from "./hasCreate";
import { IHasUpdateEntity } from "./hasUpdate";
import { IHasCreate, IHasCreateEntity } from "./hasCreate";
import { IHasUpdate, IHasUpdateEntity } from "./hasUpdate";
export declare type IHasCreateAndUpdateFactory<T extends IResourceEntity<IResourceFactory<T>>> = IHasCreateFactory<T> & IHasUpdateFactory<T>;
export declare type IHasCreateAndUpdateEntity<T extends IResourceFactory<IResourceEntity<T>>> = IHasCreateEntity<T> & IHasUpdateEntity<T>;
export interface IHasSaveEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IResourceEntity<T>, IHasCreateAndUpdateEntity<T> {
save(options?: IRequestOptions): Promise<IHasSaveEntity<T>>;
export interface IHasSave<T extends IResourceFactory<IHasCreateAndUpdateEntity<T>>> extends IHasCreate<T>, IHasUpdate<T> {
save(options?: IRequestOptions): Promise<IResourceEntity<T>>;
}
export declare type IHasSaveEntity<T extends IResourceFactory<IHasCreateAndUpdateEntity<T>>> = IResourceEntity<T> & IHasCreate<T> & IHasUpdate<T> & IHasSave<T>;
export declare function hasSave<T extends IHasCreateAndUpdateFactory<IHasCreateAndUpdateEntity<T>>>(Base: TConstructor<IHasCreateAndUpdateEntity<T>>): TConstructor<IResourceEntity<T>>;

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

import { IHasUpdateFactory } from "../../factories/mixins/hasUpdate";
export interface IHasUpdateEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IResourceEntity<T> {
update(options?: IRequestOptions): Promise<T>;
export interface IHasUpdate<T extends IResourceFactory<IResourceEntity<T>>> {
update(options?: IRequestOptions): Promise<IResourceEntity<T>>;
}
export declare type IHasUpdateEntity<T extends IResourceFactory<IResourceEntity<T>>> = IResourceEntity<T> & IHasUpdate<T>;
export declare function hasUpdate<T extends IHasUpdateFactory<IResourceEntity<T>>>(Base: TEntityConstructor<T>): TConstructor<IResourceEntity<T>>;

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

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

@@ -12,0 +12,0 @@ this.updated_at = first.updated_at;

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

import { ICompany } from "../activeRecords/Company";
import { ObjectKey } from "../../interfaces/common";
import { JSONObject } from "../../types";

@@ -14,2 +15,4 @@ import { IResourceFactory } from "../../interfaces/api";

import { IHasTagsFactory } from "./mixins/hasTags";
import { IHasTasksFactory } from "./mixins/hasTasks";
import { IFactoryConstructors } from "./index";
export interface CompaniesGetCriteria extends IGetCriteria {

@@ -35,3 +38,3 @@ filter?: string;

}
export declare type ICompanyFactory = IHasGetFactory<ICompany> & IHasGetByIdFactory<ICompany> & IHasCreateFactory<ICompany> & IHasUpdateFactory<ICompany> & IResourceFactory<ICompany> & IHasTagsFactory<ICompany>;
export declare type ICompanyFactory = IHasGetFactory<ICompany> & IHasGetByIdFactory<ICompany> & IHasCreateFactory<ICompany> & IHasUpdateFactory<ICompany> & IResourceFactory<ICompany> & IHasTagsFactory<ICompany> & IHasTasksFactory<ICompany>;
/**

@@ -43,4 +46,4 @@ * Фабрика управления компаниями

getBaseUrl(): string;
getEmbeddedKey(): string;
getEmbeddedKey(): ObjectKey<IFactoryConstructors>;
}
export declare const CompanyFactory: any;

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

const hasTags_1 = require("./mixins/hasTags");
const hasTasks_1 = require("./mixins/hasTasks");
/**

@@ -38,4 +39,5 @@ * Фабрика управления компаниями

hasUpdate_1.hasUpdate,
hasTags_1.hasTags
hasTags_1.hasTags,
hasTasks_1.hasTasks
]);
//# sourceMappingURL=CompanyFactory.js.map
import ResourceFactory from "../ResourceFactory";
import { IContact } from "../activeRecords/Contact";
import { ObjectKey } from "../../interfaces/common";
import { IResourceFactory } from "../../interfaces/api";

@@ -10,4 +11,6 @@ import { JSONObject } from "../../types";

import { IHasTagsFactory } from "./mixins/hasTags";
import { IHasTasksFactory } from "./mixins/hasTasks";
import { IFactoryConstructors } from "./index";
export interface ContactsGetCriteria extends IGetCriteria {
filter?: string;
filter?: object;
}

@@ -39,3 +42,3 @@ export interface ContactsCreateCriteria {

}
export declare type IContactFactory = IHasGetFactory<IContact> & IHasGetByIdFactory<IContact> & IHasCreateFactory<IContact> & IHasUpdateFactory<IContact> & IResourceFactory<IContact> & IHasTagsFactory<IContact>;
export declare type IContactFactory = IHasGetFactory<IContact> & IHasGetByIdFactory<IContact> & IHasCreateFactory<IContact> & IHasUpdateFactory<IContact> & IResourceFactory<IContact> & IHasTagsFactory<IContact> & IHasTasksFactory<IContact>;
/**

@@ -47,4 +50,4 @@ * Фабрика управления контактами

getBaseUrl(): string;
getEmbeddedKey(): string;
getEmbeddedKey(): ObjectKey<IFactoryConstructors>;
}
export declare const ContactFactory: any;

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

const hasUpdate_1 = require("./mixins/hasUpdate");
const hasTasks_1 = require("./mixins/hasTasks");
/**

@@ -33,4 +34,5 @@ * Фабрика управления контактами

hasCreate_1.hasCreate,
hasUpdate_1.hasUpdate
hasUpdate_1.hasUpdate,
hasTasks_1.hasTasks
]);
//# sourceMappingURL=ContactFactory.js.map

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

import { IGetCriteria } from "./mixins/hasGetByCriteria";
import { IGetCriteria, IHasGetFactory } from "./mixins/hasGetByCriteria";
import { IHasGetByIdFactory } from "./mixins/hasGetById";
import { IHasCreateFactory } from "./mixins/hasCreate";
import { IHasUpdateFactory } from "./mixins/hasUpdate";
import { ICustomer } from "../activeRecords/Customer";

@@ -6,2 +9,5 @@ import ResourceFactory from "../ResourceFactory";

import { JSONObject } from "../../types";
import { IHasTasksFactory } from "./mixins/hasTasks";
import { ObjectKey } from "../../interfaces/common";
import { IFactoryConstructors } from "./index";
export interface CustomersGetCriteria extends IGetCriteria {

@@ -35,9 +41,9 @@ filter?: string;

}
export declare type ICustomerFactory = IResourceFactory<ICustomer>;
export declare type ICustomerFactory = IHasGetFactory<ICustomer> & IHasGetByIdFactory<ICustomer> & IHasCreateFactory<ICustomer> & IHasUpdateFactory<ICustomer> & IResourceFactory<ICustomer> & IHasTasksFactory<ICustomer>;
export declare class BaseCustomerFactory extends ResourceFactory<ICustomer> {
getEntityClass(): import("../../types").TConstructor<ICustomer>;
getBaseUrl(): string;
getEmbeddedKey(): string;
getEmbeddedKey(): ObjectKey<IFactoryConstructors>;
setMode(): void;
}
export declare const CustomerFactory: any;

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

const ResourceFactory_1 = tslib_1.__importDefault(require("../ResourceFactory"));
const hasTasks_1 = require("./mixins/hasTasks");
class BaseCustomerFactory extends ResourceFactory_1.default {

@@ -32,4 +33,5 @@ getEntityClass() {

hasCreate_1.hasCreate,
hasUpdate_1.hasUpdate
hasUpdate_1.hasUpdate,
hasTasks_1.hasTasks
]);
//# sourceMappingURL=CustomerFactory.js.map

@@ -7,2 +7,3 @@ import { ILeadFactory } from "./LeadFactory";

import { TConstructor } from "../../types";
import { ITaskFactory } from "./TaskFactory";
export interface IFactoryConstructors {

@@ -14,4 +15,5 @@ leads: TConstructor<ILeadFactory>;

customers: TConstructor<ICustomerFactory>;
tasks: TConstructor<ITaskFactory>;
}
declare const factories: IFactoryConstructors;
export default factories;

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

const CustomerFactory_1 = require("./CustomerFactory");
const TaskFactory_1 = require("./TaskFactory");
const factories = {

@@ -15,4 +16,5 @@ leads: LeadFactory_1.LeadFactory,

customers: CustomerFactory_1.CustomerFactory,
tasks: TaskFactory_1.TaskFactory
};
exports.default = factories;
//# sourceMappingURL=index.js.map

@@ -6,5 +6,6 @@ /**

import { ILead } from "../activeRecords/Lead";
import { ObjectKey } from "../../interfaces/common";
import { JSONObject } from "../../types";
import { IResourceFactory } from "../../interfaces/api";
import { IGetCriteria, IHasGetFactory } from "./mixins/hasGetByCriteria";
import { hasGetByCriteria, IGetCriteria, IHasGetFactory } from "./mixins/hasGetByCriteria";
import { IHasGetByIdFactory } from "./mixins/hasGetById";

@@ -14,4 +15,6 @@ import { IHasCreateFactory } from "./mixins/hasCreate";

import { IHasTagsFactory } from "./mixins/hasTags";
import { IHasTasksFactory } from "./mixins/hasTasks";
import { IFactoryConstructors } from "./index";
export interface LeadsGetCriteria extends IGetCriteria {
filter?: string;
filter?: object;
}

@@ -35,3 +38,3 @@ export interface LeadsCreateCriteria {

}
export declare type ILeadFactory = IHasGetFactory<ILead> & IHasGetByIdFactory<ILead> & IHasCreateFactory<ILead> & IHasUpdateFactory<ILead> & IResourceFactory<ILead> & IHasTagsFactory<ILead>;
export declare type ILeadFactory = IResourceFactory<ILead> & IHasGetFactory<ILead> & IHasGetByIdFactory<ILead> & IHasCreateFactory<ILead> & IHasUpdateFactory<ILead> & IHasTagsFactory<ILead> & IHasTasksFactory<ILead>;
/**

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

getBaseUrl(): string;
getEmbeddedKey(): string;
getEmbeddedKey(): ObjectKey<IFactoryConstructors>;
/**

@@ -50,2 +53,3 @@ * @todo https://www.amocrm.ru/developers/content/crm_platform/leads-api#leads-complex-add

}
export declare const mixins: (typeof hasGetByCriteria)[];
export declare const LeadFactory: any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LeadFactory = exports.BaseLeadFactory = void 0;
exports.LeadFactory = exports.mixins = exports.BaseLeadFactory = void 0;
const tslib_1 = require("tslib");

@@ -16,2 +16,3 @@ /**

const hasTags_1 = require("./mixins/hasTags");
const hasTasks_1 = require("./mixins/hasTasks");
/**

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

exports.BaseLeadFactory = BaseLeadFactory;
exports.LeadFactory = (0, util_1.applyMixins)(BaseLeadFactory, [
exports.mixins = [
hasGetByCriteria_1.hasGetByCriteria,

@@ -46,4 +47,6 @@ hasGetById_1.hasGetById,

hasUpdate_1.hasUpdate,
hasTags_1.hasTags
]);
hasTags_1.hasTags,
hasTasks_1.hasTasks
];
exports.LeadFactory = (0, util_1.applyMixins)(BaseLeadFactory, exports.mixins);
//# sourceMappingURL=LeadFactory.js.map

@@ -8,5 +8,6 @@ import { TFactoryConstructor } from "../../../types";

}
export interface IHasCreateFactory<T extends IResourceEntity<IResourceFactory<T>>> extends IResourceFactory<T> {
export interface IHasCreate<T extends IResourceEntity<IResourceFactory<T>>> {
create<A extends IEntityAttributes>(criteria: (object | A)[], options?: IRequestOptions): Promise<T[]>;
}
export declare type IHasCreateFactory<T extends IResourceEntity<IResourceFactory<T>>> = IResourceFactory<T> & IHasCreate<T>;
export declare function hasCreate<T extends IResourceEntity<IResourceFactory<T>>>(Base: TFactoryConstructor<T>): TFactoryConstructor<T>;

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

const tslib_1 = require("tslib");
const FactoryCriteriaBuilder_1 = require("../common/FactoryCriteriaBuilder");
function hasCreate(Base) {

@@ -11,3 +12,4 @@ return class CanCreate extends Base {

const url = this.getUrl();
const requestCriteria = this.getEntityCriteria(criteria);
const entityCriteria = this.getEntityCriteria(criteria);
const requestCriteria = this.criteriaBuilder.getCriteria(FactoryCriteriaBuilder_1.CriteriaBuilderType.CREATE, entityCriteria);
const request = this.getRequest();

@@ -14,0 +16,0 @@ const { data } = yield request.post(url, requestCriteria, options);

@@ -12,5 +12,6 @@ import { IRequestOptions } from "../../../interfaces/common";

}
export interface IHasGetFactory<T> {
export interface IHasGetByCriteria<T extends IResourceEntity<IResourceFactory<T>>> {
get(criteria?: IGetCriteria, options?: IRequestOptions): Promise<IResourcePagination<T>>;
}
export declare type IHasGetFactory<T extends IResourceEntity<IResourceFactory<T>>> = IResourceFactory<T> & IHasGetByCriteria<T>;
export declare function hasGetByCriteria<T extends IResourceEntity<IResourceFactory<T>>>(Base: TFactoryConstructor<T>): TFactoryConstructor<T>;

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

const ResourcePagination_1 = tslib_1.__importDefault(require("../../ResourcePagination"));
const FactoryCriteriaBuilder_1 = require("../common/FactoryCriteriaBuilder");
function hasGetByCriteria(Base) {
return class HasGetWithCriteria extends Base {
get(criteria, options) {
get(criteria = {}, options) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const url = this.getUrl();
const requestCriteria = this.criteriaBuilder.getCriteria(FactoryCriteriaBuilder_1.CriteriaBuilderType.GET, criteria);
const params = {
url,
criteria,
criteria: requestCriteria,
options,

@@ -16,0 +18,0 @@ factory: this,

import { TFactoryConstructor } from "../../../types";
import { IResourceEntity, IResourceFactory } from "../../../interfaces/api";
import { IRequestOptions } from "../../../interfaces/common";
import { IFactoryCriteriaItem } from "../common/FactoryCriteriaBuilder";
export declare enum GetWith {

@@ -13,8 +14,16 @@ CONTACTS = "contacts",

}
export interface IHasGetByIdFactory<T extends IResourceEntity<IResourceFactory<T>>> extends IResourceFactory<T> {
export interface IHasGetById<T extends IResourceEntity<IResourceFactory<T>>> {
getById(identity: number, criteria?: IHasGetByIdCriteria, options?: IRequestOptions): Promise<T | null>;
}
export declare const getRequestCriteria: (criteria?: IHasGetByIdCriteria | undefined) => {
export declare type IHasGetByIdFactory<T extends IResourceEntity<IResourceFactory<T>>> = IResourceFactory<T> & IHasGetById<T>;
export declare const getRequestCriteria: (criteria?: IHasGetByIdCriteria) => {
with: string;
} | undefined;
export declare class GetByIdFactoryCriteriaItem implements IFactoryCriteriaItem {
fetchCriteria(criteria?: IHasGetByIdCriteria): {
with?: undefined;
} | {
with: string;
};
}
export declare function hasGetById<T extends IResourceEntity<IResourceFactory<T>>>(Base: TFactoryConstructor<T>): TFactoryConstructor<T>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasGetById = exports.getRequestCriteria = exports.GetWith = void 0;
exports.hasGetById = exports.GetByIdFactoryCriteriaItem = exports.getRequestCriteria = exports.GetWith = void 0;
const tslib_1 = require("tslib");
const FactoryCriteriaBuilder_1 = require("../common/FactoryCriteriaBuilder");
var GetWith;

@@ -24,4 +25,19 @@ (function (GetWith) {

exports.getRequestCriteria = getRequestCriteria;
class GetByIdFactoryCriteriaItem {
fetchCriteria(criteria = {}) {
if (!criteria.with) {
return {};
}
return {
with: criteria.with.join(',')
};
}
}
exports.GetByIdFactoryCriteriaItem = GetByIdFactoryCriteriaItem;
function hasGetById(Base) {
return class HasGetById extends Base {
constructor(client) {
super(client);
this.criteriaBuilder.add(new GetByIdFactoryCriteriaItem());
}
getById(identity, criteria, options) {

@@ -31,3 +47,3 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () {

const request = this.getRequest();
const requestCriteria = (0, exports.getRequestCriteria)(criteria);
const requestCriteria = this.criteriaBuilder.getCriteria(FactoryCriteriaBuilder_1.CriteriaBuilderType.GET, criteria);
const { data } = yield request.get(url, requestCriteria, options);

@@ -34,0 +50,0 @@ if (!data) {

import { IResourceEntity, IResourceFactory } from "../../../interfaces/api";
import { TFactoryConstructor } from "../../../types";
import { IRequestOptions } from "../../../interfaces/common";
import { TagCreateCriteria } from "../TagFactory";
import { ITagFactory } from "../TagFactory";
import { IGetCriteria } from "./hasGetByCriteria";
import { ITag } from "../../activeRecords/Tag";
import { IResourcePagination } from "../../ResourcePagination";
export interface IGetTagsCriteria extends IGetCriteria {

@@ -14,17 +11,6 @@ filter?: {

}
export interface IFactoryTagList {
/**
* {@link https://www.amocrm.ru/developers/content/crm_platform/tags-api#%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA-%D1%82%D0%B5%D0%B3%D0%BE%D0%B2-%D0%B4%D0%BB%D1%8F-%D1%81%D1%83%D1%89%D0%BD%D0%BE%D1%81%D1%82%D0%B8 | API}
*/
get(criteria?: IGetTagsCriteria, options?: IRequestOptions): Promise<IResourcePagination<ITag>>;
/**
* {@link https://www.amocrm.ru/developers/content/crm_platform/tags-api#%D0%94%D0%BE%D0%B1%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D1%82%D0%B5%D0%B3%D0%BE%D0%B2-%D0%B4%D0%BB%D1%8F-%D0%BA%D0%BE%D0%BD%D0%BA%D1%80%D0%B5%D1%82%D0%BD%D0%BE%D0%B3%D0%BE-%D1%82%D0%B8%D0%BF%D0%B0-%D1%81%D1%83%D1%89%D0%BD%D0%BE%D1%81%D1%82%D0%B8 | API}
*/
create(criteria: (TagCreateCriteria | ITag)[], options?: IRequestOptions): Promise<ITag[]>;
export interface IHasTags<T extends IResourceEntity<IResourceFactory<T>>> {
tags: ITagFactory;
}
export interface IHasTagsFactory<T extends IResourceEntity<IResourceFactory<T>>> extends IResourceFactory<T> {
get tagList(): IFactoryTagList;
getTags(criteria?: IGetTagsCriteria, options?: IRequestOptions): Promise<IResourcePagination<ITag>>;
createTags(criteria: (TagCreateCriteria | ITag)[], options?: IRequestOptions): Promise<ITag[]>;
}
export declare type IHasTagsFactory<T extends IResourceEntity<IResourceFactory<T>>> = IResourceFactory<T> & IHasTags<T>;
export declare function hasTags<T extends IResourceEntity<IResourceFactory<T>>>(Base: TFactoryConstructor<T>): TFactoryConstructor<T>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasTags = void 0;
const getEntityFactory_1 = require("../common/getEntityFactory");
function hasTags(Base) {
return class HasTags extends Base {
get tagList() {
if (this._tags) {
return this._tags;
}
this._tags = {
get: this.getTags.bind(this),
create: this.createTags.bind(this),
};
return this._tags;
constructor(client) {
super(client);
this.tags = (0, getEntityFactory_1.getEntityFactory)({
factory: this,
type: 'tags'
});
}
getTagsFactory() {
if (this._tagsFactory !== undefined) {
return this._tagsFactory;
}
const entityType = this.getEmbeddedKey();
const client = this.getClient();
const constructors = client.getFactoryConstructors();
const factory = new constructors.tags(client, entityType);
this._tagsFactory = factory;
return factory;
}
getTags(criteria, options) {
const factory = this.getTagsFactory();
return factory.get(criteria, options);
}
createTags(criteria, options) {
const factory = this.getTagsFactory();
return factory.create(criteria, options);
}
};

@@ -36,0 +15,0 @@ }

@@ -12,5 +12,6 @@ import { TFactoryConstructor } from "../../../types";

}
export interface IHasUpdateFactory<T extends IResourceEntity<IResourceFactory<T>>> extends IResourceFactory<T> {
export interface IHasUpdate<T extends IResourceEntity<IResourceFactory<T>>> {
update(criteria: (object | T)[], options?: IRequestOptions): Promise<T[]>;
}
export declare type IHasUpdateFactory<T extends IResourceEntity<IResourceFactory<T>>> = IResourceFactory<T> & IHasUpdate<T>;
export declare function hasUpdate<T extends IResourceEntity<IResourceFactory<T>>>(Base: TFactoryConstructor<T>): TFactoryConstructor<T>;

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

const tslib_1 = require("tslib");
const FactoryCriteriaBuilder_1 = require("../common/FactoryCriteriaBuilder");
function hasUpdate(Base) {

@@ -11,3 +12,4 @@ return class HasUpdate extends Base {

const url = this.getUrl();
const requestCriteria = this.getEntityCriteria(criteria);
const entityCriteria = this.getEntityCriteria(criteria);
const requestCriteria = this.criteriaBuilder.getCriteria(FactoryCriteriaBuilder_1.CriteriaBuilderType.UPDATE, entityCriteria);
const request = this.getRequest();

@@ -18,3 +20,2 @@ const { data } = yield request.patch(url, requestCriteria, options);

return response.map(attributes => this.from(attributes));
;
});

@@ -21,0 +22,0 @@ }

@@ -6,3 +6,3 @@ /**

import ResourcePagination from "../ResourcePagination";
import { IRequestOptions } from "../../interfaces/common";
import { IRequestOptions, ObjectKey } from "../../interfaces/common";
import { IResourceFactory } from "../../interfaces/api";

@@ -12,2 +12,3 @@ import { ITag } from "../activeRecords/Tag";

import { IClient } from "../../Client";
import { IFactoryConstructors } from "./index";
export interface TagCreateCriteria {

@@ -57,4 +58,4 @@ name: string;

getBaseUrl(): string;
getEmbeddedKey(): string;
getEmbeddedKey(): ObjectKey<IFactoryConstructors>;
}
export declare const TagFactory: any;
import { IEntityAttributes, IResourceEntity, IResourceFactory } from "../interfaces/api";
import { EventEmitter } from "../common/EventEmitter";
import { ICriteriaBuilder } from "./activeRecords/common/CriteriaBuilder";
import { IEntityCriteriaBuilder } from "./activeRecords/common/EntityCriteriaBuilder";
/**

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

_embedded?: object;
readonly criteriaBuilder: ICriteriaBuilder;
readonly criteriaBuilder: IEntityCriteriaBuilder;
protected readonly factory: T;

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

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

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

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

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

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

@@ -25,11 +25,4 @@ getFactory() {

}
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

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

import { IClient } from "../Client";
import { IFactoryCriteriaBuilder } from "./factories/common/FactoryCriteriaBuilder";
import { ObjectKey } from "../interfaces/common";
import { IFactoryConstructors } from "./factories";
/**

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

protected readonly client: IClient;
readonly criteriaBuilder: IFactoryCriteriaBuilder;
constructor(client: IClient);
abstract getBaseUrl(): string;
abstract getEmbeddedKey(): string;
abstract getEmbeddedKey(): ObjectKey<IFactoryConstructors>;
getClient(): IClient;

@@ -19,0 +23,0 @@ getEmbedded<A extends IEntityAttributes>(data: ICollectionResponse<A>): A[];

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

const EventEmitter_1 = require("../common/EventEmitter");
const FactoryCriteriaBuilder_1 = require("./factories/common/FactoryCriteriaBuilder");
/**

@@ -16,2 +17,3 @@ * Основной класс фабрики сущностей. Класс-фабрика служит для создания

this.request = client.getRequest();
this.criteriaBuilder = new FactoryCriteriaBuilder_1.FactoryCriteriaBuilder(this);
}

@@ -18,0 +20,0 @@ getClient() {

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

return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (this.page === 1) {
return this.data;
}
if (!this.hasFirst()) {

@@ -87,0 +90,0 @@ return false;

@@ -18,2 +18,4 @@ import { IClientOptions } from "./interfaces/common";

import { IEntityConstructors } from "./api/activeRecords";
import { ITask } from "./api/activeRecords/Task";
import { ITaskFactory } from "./api/factories/TaskFactory";
export declare type IClientEntity<T> = {

@@ -36,5 +38,7 @@ new (attributes?: JSONObject): T;

Company: IClientEntity<ICompany>;
Task: IClientEntity<ITask>;
leads: ILeadFactory;
contacts: IContactFactory;
companies: ICompanyFactory;
tasks: ITaskFactory;
}

@@ -53,5 +57,7 @@ /**

readonly Company: IClientEntity<ICompany>;
readonly Task: IClientEntity<ITask>;
readonly leads: ILeadFactory;
readonly contacts: IContactFactory;
readonly companies: ICompanyFactory;
readonly tasks: ITaskFactory;
constructor(options: IClientOptions);

@@ -58,0 +64,0 @@ get constructors(): {

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

this.companies = new factories.companies(this);
this.tasks = new factories.tasks(this);
this.Lead = this.assignEntity(this.leads);
this.Contact = this.assignEntity(this.contacts);
this.Company = this.assignEntity(this.companies);
this.Task = this.assignEntity(this.tasks);
}

@@ -35,0 +37,0 @@ get constructors() {

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

protected waitForUserAction(): Promise<boolean>;
protected getToken(): string | undefined;
/**

@@ -46,0 +47,0 @@ * Формирует запрос к порталу. Предварительно проверяет наличие соединения

@@ -57,5 +57,10 @@ "use strict";

const code = this.environment.get('auth.code');
const bearer = this.environment.get('auth.bearer');
const hasCode = Boolean(code);
const hasBearer = Boolean(bearer);
const hasAuthServer = this.environment.exists('auth.server');
const tokenExists = this.token.exists();
if (hasBearer) {
return true;
}
if (!hasCode && hasAuthServer) {

@@ -80,7 +85,6 @@ yield this.waitForUserAction();

this.emit('connected');
this.connected = true;
return true;
}
catch (e) {
this.emit('connectionError', e);
this.emit('error', e);
throw e;

@@ -121,2 +125,10 @@ }

}
getToken() {
const bearer = this.environment.get('auth.bearer');
if (bearer) {
return bearer;
}
const token = this.token.getValue();
return token === null || token === void 0 ? void 0 : token.access_token;
}
/**

@@ -129,3 +141,3 @@ * Формирует запрос к порталу. Предварительно проверяет наличие соединения

yield this.update();
const token = this.token.getValue();
const token = this.getToken();
const domain = this.environment.get('domain');

@@ -132,0 +144,0 @@ const config = {

@@ -31,3 +31,3 @@ "use strict";

if (token) {
clientHeaders['Authorization'] = 'Bearer ' + token.access_token;
clientHeaders['Authorization'] = 'Bearer ' + token;
}

@@ -34,0 +34,0 @@ if (this.isFormData()) {

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

set(path, value) {
if (!this.options) {
throw new Error('NO_ENVIRONMENT_OPTIONS');
}
let handler = this.options;

@@ -46,0 +43,0 @@ const parts = path.split('.');

import { IClientRequest } from "../common/ClientRequest";
import { TConstructor } from "../types";
import { IRequestOptions } from "./common";
import { IRequestOptions, ObjectKey } from "./common";
import { IEventEmitter } from "../common/EventEmitter";

@@ -8,3 +8,4 @@ import { IClient } from "../Client";

import { IFactoryConstructors } from "../api/factories";
import { ICriteriaBuilder } from "../api/activeRecords/common/CriteriaBuilder";
import { IEntityCriteriaBuilder } from "../api/activeRecords/common/EntityCriteriaBuilder";
import { IFactoryCriteriaBuilder } from "../api/factories/common/FactoryCriteriaBuilder";
export interface IClientConstructors {

@@ -15,2 +16,3 @@ entities: IEntityConstructors;

export interface IResourceFactory<T extends IResourceEntity<IResourceFactory<T>>> extends IEventEmitter {
criteriaBuilder: IFactoryCriteriaBuilder;
getClient(): IClient;

@@ -21,3 +23,3 @@ getEntityClass(): TConstructor<T>;

getRequest(): IClientRequest;
getEmbeddedKey(): string;
getEmbeddedKey(): ObjectKey<IFactoryConstructors>;
getEmbedded<A extends IEntityAttributes>(data: ICollectionResponse<A>): A[];

@@ -28,6 +30,7 @@ getUrl(path?: string): string;

}
export declare type EntityAttributes<T extends IResourceEntity<IResourceFactory<T>>> = ReturnType<T['getAttributes']>;
export interface IResourceEntity<T extends IResourceFactory<IResourceEntity<T>>> extends IEventEmitter {
id?: number;
updated_at?: number;
criteriaBuilder: ICriteriaBuilder;
criteriaBuilder: IEntityCriteriaBuilder;
isNew(): boolean;

@@ -38,6 +41,2 @@ getFactory(): 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 {

@@ -71,2 +70,6 @@ id: number;

}
export interface ITimestampRangeCriteria {
from?: number;
to?: number;
}
export interface ILinkResponse {

@@ -73,0 +76,0 @@ href: string;

@@ -8,2 +8,3 @@ /// <reference types="node" />

redirect_uri: string;
bearer?: string;
code?: string;

@@ -40,3 +41,3 @@ }

options?: IRequestOptions;
token?: ITokenData;
token?: string;
}

@@ -67,1 +68,2 @@ export interface IAPIResponse<T> {

export declare type ObjectKey<T> = keyof T;
export declare type ObjectValues<T> = T[keyof T];

@@ -19,7 +19,7 @@ import { IResourceEntity } from "../../interfaces/api";

readonly tagList: IEntityHasUpdatableTagList<T>;
updateTags(criteria: (TagAttributes | ITag)[] | null, options?: IRequestOptions | undefined): Promise<IResourceEntity<T>[]>;
clearTags(options?: IRequestOptions | undefined): Promise<IResourceEntity<T>[]>;
updateTags(criteria: (TagAttributes | ITag)[] | null, options?: IRequestOptions): Promise<IResourceEntity<T>[]>;
clearTags(options?: IRequestOptions): Promise<IResourceEntity<T>[]>;
id?: number | undefined;
updated_at?: number | undefined;
criteriaBuilder: import("../../api/activeRecords/common/CriteriaBuilder").ICriteriaBuilder;
criteriaBuilder: import("../../api/activeRecords/common/EntityCriteriaBuilder").IEntityCriteriaBuilder;
isNew(): boolean;

@@ -26,0 +26,0 @@ getFactory(): T;

import { IEntityAttributes, IResourceEntity, IResourceFactory, ISelfResponse } from "../../interfaces/api";
import { TConstructor } from "../../types";
import { IHasTagsFactory, IFactoryTagList } from "../../api/factories/mixins/hasTags";
import { IHasTagsFactory } from "../../api/factories/mixins/hasTags";
import { IHasUpdateFactory } from "../../api/factories/mixins/hasUpdate";

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

export declare type THasUpdateAndTagsFactory<T extends IResourceEntity<IHasTagsFactory<T>>> = IHasTagsFactory<T> & IHasUpdateFactory<T>;
export interface IFactoryHasUpdatableTagList<T extends IResourceEntity<IHasTagsFactory<T>>> extends IFactoryTagList {
export interface IFactoryHasUpdatableTagList<T extends IResourceEntity<IHasTagsFactory<T>>> {
setFor(criteria: (object | T)[], tagsCriteria: (TagAttributes | ITag)[] | null, options?: IRequestOptions): Promise<T[]>;

@@ -29,7 +29,6 @@ clearFor(criteria: (object | T)[], options?: IRequestOptions): Promise<T[]>;

readonly tagList: IFactoryHasUpdatableTagList<T>;
setTagsFor(criteria: (object | T)[], tagsCriteria: (TagAttributes | ITag)[] | null, options?: IRequestOptions | undefined): Promise<T[]>;
clearTagsFor(criteria: (object | T)[], options?: IRequestOptions | undefined): Promise<T[]>;
setTags(criteria: (TagAttributes | ITag)[] | null, options?: IRequestOptions | undefined): Promise<ISelfResponse>;
getTags(criteria?: import("../../api/factories/mixins/hasTags").IGetTagsCriteria | undefined, options?: IRequestOptions | undefined): Promise<import("../../api/ResourcePagination").IResourcePagination<ITag>>;
createTags(criteria: (ITag | import("../../api/factories/TagFactory").TagCreateCriteria)[], options?: IRequestOptions | undefined): Promise<ITag[]>;
setTagsFor(criteria: (object | T)[], tagsCriteria: (TagAttributes | ITag)[] | null, options?: IRequestOptions): Promise<T[]>;
clearTagsFor(criteria: (object | T)[], options?: IRequestOptions): Promise<T[]>;
setTags(criteria: (TagAttributes | ITag)[] | null, options?: IRequestOptions): Promise<ISelfResponse>;
criteriaBuilder: import("../../api/factories/common/FactoryCriteriaBuilder").IFactoryCriteriaBuilder;
getClient(): import("../../Client").IClient;

@@ -39,3 +38,3 @@ createEntity(): T;

getRequest(): import("../../common/ClientRequest").IClientRequest;
getEmbeddedKey(): string;
getEmbeddedKey(): keyof import("../../api/factories").IFactoryConstructors;
getEmbedded<A extends IEntityAttributes>(data: import("../../interfaces/api").ICollectionResponse<A>): A[];

@@ -63,4 +62,5 @@ getUrl(path?: string | undefined): string;

eventNames(): (string | symbol)[];
tags: import("../../api/factories/TagFactory").ITagFactory;
update(criteria: (object | T)[], options?: IRequestOptions | undefined): Promise<T[]>;
};
};

@@ -16,3 +16,3 @@ "use strict";

}
const tagList = Object.assign(Object.assign({}, super.tagList), { setFor: this.setTagsFor.bind(this), clearFor: this.clearTagsFor.bind(this), set: this.setTags.bind(this) });
const tagList = Object.assign(Object.assign({}, super.tags), { setFor: this.setTagsFor.bind(this), clearFor: this.clearTagsFor.bind(this), set: this.setTags.bind(this) });
this._updatableTagList = tagList;

@@ -19,0 +19,0 @@ return tagList;

@@ -41,4 +41,6 @@ import { IHasUpdatableTagsFactory } from "./factories/hasUpdatableTags";

Company: import("../Client").IClientEntity<import("../api/activeRecords/Company").ICompany>;
Task: import("../Client").IClientEntity<import("../api/activeRecords/Task").ITask>;
companies: import("../api/factories/CompanyFactory").ICompanyFactory;
tasks: import("../api/factories/TaskFactory").ITaskFactory;
};
};

@@ -19,4 +19,7 @@ declare const _default: {

};
tasks: {
path: string;
};
};
};
export default _default;

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

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

@@ -22,0 +25,0 @@ }

export declare const delay: (ms: number) => Promise<unknown>;
export declare const overwriteMerge: <T>(_: T[], data: T[]) => T[];
export declare function applyMixins(baseClass: any, mixins: any[]): any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyMixins = exports.delay = void 0;
exports.applyMixins = exports.overwriteMerge = exports.delay = void 0;
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
exports.delay = delay;
const overwriteMerge = (_, data) => data;
exports.overwriteMerge = overwriteMerge;
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -7,0 +9,0 @@ function applyMixins(baseClass, mixins) {

{
"name": "amocrm-js",
"version": "3.4.2",
"version": "3.6.0",
"description": "JS Library for AmoCRM",

@@ -13,4 +13,5 @@ "main": "./dist/Client.js",

"scripts": {
"test:setup": "npx ts-node tests/setup.ts",
"test:get-token": "npx ts-node tests/getToken.ts",
"test": "jest --no-cache --verbose false --silent false",
"test:api": "npm test ./tests/api",
"build": "tsc",

@@ -42,5 +43,7 @@ "docs": "typedoc --entryPointStrategy expand ./src",

"@microsoft/tsdoc": "^0.14.1",
"@types/deepmerge": "^2.2.0",
"@types/events": "^3.0.0",
"@types/jest": "^27.5.1",
"@types/lodash": "^4.14.191",
"@types/moment": "^2.13.0",
"@types/node": "^17.0.34",

@@ -57,2 +60,3 @@ "@types/qs": "^6.9.7",

"jest": "^28.1.0",
"moment": "^2.29.4",
"ngrok": "^4.3.1",

@@ -64,3 +68,3 @@ "ts-jest": "^28.0.2",

"dependencies": {
"lodash": "^4.17.21",
"deepmerge": "^4.3.1",
"qs": "^6.10.3",

@@ -67,0 +71,0 @@ "tslib": "^2.4.0",

@@ -18,3 +18,3 @@

По вопросам сотрудничества [пишите мне в Telegram](https://t.me/neizerth).
По вопросам, в том числе сотрудничества [пишите мне в Telegram](https://t.me/neizerth).

@@ -25,4 +25,3 @@ ## Сообщество и вопросы

По всем вопросам работы библиотеки заходите в [чат проекта в Telegram](https://t.me/+QKoG6INanhIyYTAy).
Сделаем вместе пространство уютным :)
Сделаем вместе пространство уютным :) <3

@@ -81,3 +80,4 @@ ## Изменения в 3.x.x по сравнению с 2.x.x

1. По заранее известному коду авторизации
1. Через [долгосрочный токен](https://www.amocrm.ru/developers/content/oauth/step-by-step#%D0%94%D0%BE%D0%BB%D0%B3%D0%BE%D1%81%D1%80%D0%BE%D1%87%D0%BD%D1%8B%D0%B5-%D1%82%D0%BE%D0%BA%D0%B5%D0%BD%D1%8B)
2. По заранее известному коду авторизации
(например, с помощью [упрощённой авторизации](https://www.amocrm.ru/developers/content/oauth/easy-auth))

@@ -89,2 +89,8 @@ 2. С помощью встроенного OAuth-сервера (см. пример ниже)

### Получение кода авторизацию
1. С помощью [упрощённой авторизации](https://www.amocrm.ru/developers/content/oauth/easy-auth)
2. С помощью встроенного сервера авторизации данной библиотеки
3. Вручную
### Процесс OAuth авторизации

@@ -96,7 +102,20 @@

### Получение кода авторизацию
### Подключение по долгосрочному токену
1. С помощью [упрощённой авторизации](https://www.amocrm.ru/developers/content/oauth/easy-auth)
2. С помощью встроенного сервера авторизации данной библиотеки
3. Вручную
```js
const client = new Client({
// логин пользователя в портале, где адрес портала domain.amocrm.ru
domain: 'domain', // может быть указан полный домен вида domain.amocrm.ru, domain.amocrm.com
/*
Информация об интеграции (подробности подключения
описаны на https://www.amocrm.ru/developers/content/oauth/step-by-step)
*/
auth: {
client_id: 'clientId', // ID интеграции
client_secret: 'clientSecret', // Секретный ключ
redirect_uri: 'redirectUri', // Ссылка для перенаправления
bearer: 'ltsToken', // долгосрочный токен
},
});
```

@@ -237,2 +256,3 @@ ### Подключение по коду авторизации (упрощенная авторизация)

- Теги [[примеры работы]](./examples/javascript/04-tags)
- Задачи [[примеры работы]](./examples/javascript/05-tasks)

@@ -451,9 +471,7 @@ <a id="requests"></a>

- NO_JSON_RESPONSE. Пустой ответ
- INVALID_JSON_RESPONSE. Некорректный JSON вет
- INVALID_JSON_RESPONSE. Некорректный JSON ответ
- API_RESPONSE_ERROR. Ошибка в ответе по API
- NO_TOKEN_AND_CODE. В настройках отсуствует код и не установлен токен
- CONNECTION_ERROR. Неудачное соединение
- NO_ENVIRONMENT_OPTIONS. Отсутствуют настройки
- PATH_IS_EMPTY. Попытка установить client.environment.set без переданного первого пути
- INVALID_PATH. Неверный
- PATH_IS_EMPTY. Попытка вызвать client.environment.set без переданного пути
- INVALID_PATH. Неверный путь при вызове client.environment.set
- NO_AUTH_OPTIONS. Отсутствуют настройки config.auth

@@ -521,7 +539,9 @@ - JSON_PARSE_ERROR. Ответ AmoCRM сформирован в неверном JSON формате

- Компании [[примеры работы]](./examples/javascript/03-companies)
- Теги [[примеры работы]](./examples/javascript/04-tags)
- Задачи [[примеры работы]](./examples/javascript/05-tasks)
## Доска почёта
Спасибо @amorev, @maxism, @shuraman69, @korovenko-tatyana, @lotgyero, @capfsb за вклад в разработку этого проекта
Спасибо @amorev, @maxism, @shuraman69, @korovenko-tatyana, @lotgyero, @capfsb, @templar820 за вклад в разработку этого проекта
Отдельная благодарность @dmitrytemlead за возможность протестировать библиотеку в стороннем проекте

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

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