@2bad/bitrix 2.5.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -188
- package/build/bin.d.ts +1 -0
- package/build/bin.js +160 -0
- package/build/client-Bk76ySik.js +769 -0
- package/build/index.d.ts +2881 -0
- package/build/index.js +1 -0
- package/package.json +46 -73
- package/build/main/bitrix.d.ts +0 -114
- package/build/main/bitrix.integration.test.d.ts +0 -0
- package/build/main/bitrix.integration.test.js +0 -31
- package/build/main/bitrix.js +0 -61
- package/build/main/bitrix.unit.test.d.ts +0 -1
- package/build/main/bitrix.unit.test.js +0 -44
- package/build/main/client/client.unit.test.d.ts +0 -1
- package/build/main/client/client.unit.test.js +0 -70
- package/build/main/client/hooks/addAccessToken.d.ts +0 -6
- package/build/main/client/hooks/addAccessToken.js +0 -13
- package/build/main/client/hooks/addAccessToken.unit.test.d.ts +0 -1
- package/build/main/client/hooks/addAccessToken.unit.test.js +0 -31
- package/build/main/client/index.d.ts +0 -15
- package/build/main/client/index.js +0 -53
- package/build/main/client/methods/batch.d.ts +0 -40
- package/build/main/client/methods/batch.js +0 -85
- package/build/main/client/methods/batch.unit.test.d.ts +0 -1
- package/build/main/client/methods/batch.unit.test.js +0 -494
- package/build/main/client/methods/call.d.ts +0 -17
- package/build/main/client/methods/call.js +0 -36
- package/build/main/client/methods/call.unit.test.d.ts +0 -1
- package/build/main/client/methods/call.unit.test.js +0 -183
- package/build/main/client/methods/list.d.ts +0 -30
- package/build/main/client/methods/list.js +0 -66
- package/build/main/client/methods/list.unit.test.d.ts +0 -1
- package/build/main/client/methods/list.unit.test.js +0 -277
- package/build/main/commands.d.ts +0 -10
- package/build/main/commands.js +0 -2
- package/build/main/methods.d.ts +0 -92
- package/build/main/methods.js +0 -41
- package/build/main/payloads.d.ts +0 -40
- package/build/main/payloads.js +0 -2
- package/build/main/services/common.d.ts +0 -22
- package/build/main/services/common.js +0 -2
- package/build/main/services/companies/entities.d.ts +0 -54
- package/build/main/services/companies/entities.js +0 -2
- package/build/main/services/companies/index.d.ts +0 -26
- package/build/main/services/companies/index.integration.test.d.ts +0 -1
- package/build/main/services/companies/index.integration.test.js +0 -19
- package/build/main/services/companies/index.js +0 -10
- package/build/main/services/companies/index.unit.test.d.ts +0 -1
- package/build/main/services/companies/index.unit.test.js +0 -72
- package/build/main/services/companies/methods.d.ts +0 -44
- package/build/main/services/companies/methods.js +0 -3
- package/build/main/services/contacts/entities.d.ts +0 -45
- package/build/main/services/contacts/entities.js +0 -2
- package/build/main/services/contacts/index.d.ts +0 -26
- package/build/main/services/contacts/index.integration.test.d.ts +0 -1
- package/build/main/services/contacts/index.integration.test.js +0 -19
- package/build/main/services/contacts/index.js +0 -10
- package/build/main/services/contacts/index.unit.test.d.ts +0 -1
- package/build/main/services/contacts/index.unit.test.js +0 -72
- package/build/main/services/contacts/methods.d.ts +0 -44
- package/build/main/services/contacts/methods.js +0 -3
- package/build/main/services/currencies/entities.d.ts +0 -15
- package/build/main/services/currencies/entities.js +0 -2
- package/build/main/services/deals/entities.d.ts +0 -43
- package/build/main/services/deals/entities.js +0 -2
- package/build/main/services/deals/index.d.ts +0 -26
- package/build/main/services/deals/index.integration.test.d.ts +0 -1
- package/build/main/services/deals/index.integration.test.js +0 -19
- package/build/main/services/deals/index.js +0 -10
- package/build/main/services/deals/index.unit.test.d.ts +0 -1
- package/build/main/services/deals/index.unit.test.js +0 -72
- package/build/main/services/deals/methods.d.ts +0 -44
- package/build/main/services/deals/methods.js +0 -3
- package/build/main/services/leads/entities.d.ts +0 -49
- package/build/main/services/leads/entities.js +0 -2
- package/build/main/services/leads/index.d.ts +0 -26
- package/build/main/services/leads/index.integration.test.d.ts +0 -1
- package/build/main/services/leads/index.integration.test.js +0 -19
- package/build/main/services/leads/index.js +0 -10
- package/build/main/services/leads/index.unit.test.d.ts +0 -1
- package/build/main/services/leads/index.unit.test.js +0 -72
- package/build/main/services/leads/methods.d.ts +0 -44
- package/build/main/services/leads/methods.js +0 -3
- package/build/main/services/statuses/entities.d.ts +0 -16
- package/build/main/services/statuses/entities.js +0 -2
- package/build/main/services/statuses/index.d.ts +0 -14
- package/build/main/services/statuses/index.integration.test.d.ts +0 -1
- package/build/main/services/statuses/index.integration.test.js +0 -90
- package/build/main/services/statuses/index.js +0 -11
- package/build/main/services/statuses/index.unit.test.d.ts +0 -1
- package/build/main/services/statuses/index.unit.test.js +0 -60
- package/build/main/services/statuses/methods.d.ts +0 -51
- package/build/main/services/statuses/methods.js +0 -3
- package/build/main/services/users/entities.d.ts +0 -40
- package/build/main/services/users/entities.js +0 -2
- package/build/main/services/users/index.d.ts +0 -9
- package/build/main/services/users/index.integration.test.d.ts +0 -1
- package/build/main/services/users/index.integration.test.js +0 -33
- package/build/main/services/users/index.js +0 -7
- package/build/main/services/users/index.unit.test.d.ts +0 -1
- package/build/main/services/users/index.unit.test.js +0 -25
- package/build/main/services/users/methods.d.ts +0 -17
- package/build/main/services/users/methods.js +0 -3
- package/build/main/utils/Diff.d.ts +0 -1
- package/build/main/utils/Diff.js +0 -2
- package/build/main/utils/ExtractValue.d.ts +0 -6
- package/build/main/utils/ExtractValue.js +0 -2
- package/build/main/utils/isArray.d.ts +0 -2
- package/build/main/utils/isArray.js +0 -4
- package/build/module/bitrix.d.ts +0 -114
- package/build/module/bitrix.integration.test.d.ts +0 -0
- package/build/module/bitrix.integration.test.js +0 -31
- package/build/module/bitrix.js +0 -40
- package/build/module/bitrix.unit.test.d.ts +0 -1
- package/build/module/bitrix.unit.test.js +0 -16
- package/build/module/client/client.unit.test.d.ts +0 -1
- package/build/module/client/client.unit.test.js +0 -65
- package/build/module/client/hooks/addAccessToken.d.ts +0 -6
- package/build/module/client/hooks/addAccessToken.js +0 -11
- package/build/module/client/hooks/addAccessToken.unit.test.d.ts +0 -1
- package/build/module/client/hooks/addAccessToken.unit.test.js +0 -26
- package/build/module/client/index.d.ts +0 -15
- package/build/module/client/index.js +0 -48
- package/build/module/client/methods/batch.d.ts +0 -40
- package/build/module/client/methods/batch.js +0 -76
- package/build/module/client/methods/batch.unit.test.d.ts +0 -1
- package/build/module/client/methods/batch.unit.test.js +0 -466
- package/build/module/client/methods/call.d.ts +0 -17
- package/build/module/client/methods/call.js +0 -28
- package/build/module/client/methods/call.unit.test.d.ts +0 -1
- package/build/module/client/methods/call.unit.test.js +0 -155
- package/build/module/client/methods/list.d.ts +0 -30
- package/build/module/client/methods/list.js +0 -55
- package/build/module/client/methods/list.unit.test.d.ts +0 -1
- package/build/module/client/methods/list.unit.test.js +0 -252
- package/build/module/commands.d.ts +0 -10
- package/build/module/commands.js +0 -1
- package/build/module/methods.d.ts +0 -92
- package/build/module/methods.js +0 -38
- package/build/module/payloads.d.ts +0 -40
- package/build/module/payloads.js +0 -1
- package/build/module/services/common.d.ts +0 -22
- package/build/module/services/common.js +0 -1
- package/build/module/services/companies/entities.d.ts +0 -54
- package/build/module/services/companies/entities.js +0 -1
- package/build/module/services/companies/index.d.ts +0 -26
- package/build/module/services/companies/index.integration.test.d.ts +0 -1
- package/build/module/services/companies/index.integration.test.js +0 -14
- package/build/module/services/companies/index.js +0 -8
- package/build/module/services/companies/index.unit.test.d.ts +0 -1
- package/build/module/services/companies/index.unit.test.js +0 -67
- package/build/module/services/companies/methods.d.ts +0 -44
- package/build/module/services/companies/methods.js +0 -1
- package/build/module/services/contacts/entities.d.ts +0 -45
- package/build/module/services/contacts/entities.js +0 -1
- package/build/module/services/contacts/index.d.ts +0 -26
- package/build/module/services/contacts/index.integration.test.d.ts +0 -1
- package/build/module/services/contacts/index.integration.test.js +0 -14
- package/build/module/services/contacts/index.js +0 -8
- package/build/module/services/contacts/index.unit.test.d.ts +0 -1
- package/build/module/services/contacts/index.unit.test.js +0 -67
- package/build/module/services/contacts/methods.d.ts +0 -44
- package/build/module/services/contacts/methods.js +0 -1
- package/build/module/services/currencies/entities.d.ts +0 -15
- package/build/module/services/currencies/entities.js +0 -1
- package/build/module/services/deals/entities.d.ts +0 -43
- package/build/module/services/deals/entities.js +0 -1
- package/build/module/services/deals/index.d.ts +0 -26
- package/build/module/services/deals/index.integration.test.d.ts +0 -1
- package/build/module/services/deals/index.integration.test.js +0 -14
- package/build/module/services/deals/index.js +0 -8
- package/build/module/services/deals/index.unit.test.d.ts +0 -1
- package/build/module/services/deals/index.unit.test.js +0 -67
- package/build/module/services/deals/methods.d.ts +0 -44
- package/build/module/services/deals/methods.js +0 -1
- package/build/module/services/leads/entities.d.ts +0 -49
- package/build/module/services/leads/entities.js +0 -1
- package/build/module/services/leads/index.d.ts +0 -26
- package/build/module/services/leads/index.integration.test.d.ts +0 -1
- package/build/module/services/leads/index.integration.test.js +0 -14
- package/build/module/services/leads/index.js +0 -8
- package/build/module/services/leads/index.unit.test.d.ts +0 -1
- package/build/module/services/leads/index.unit.test.js +0 -67
- package/build/module/services/leads/methods.d.ts +0 -44
- package/build/module/services/leads/methods.js +0 -1
- package/build/module/services/statuses/entities.d.ts +0 -16
- package/build/module/services/statuses/entities.js +0 -1
- package/build/module/services/statuses/index.d.ts +0 -14
- package/build/module/services/statuses/index.integration.test.d.ts +0 -1
- package/build/module/services/statuses/index.integration.test.js +0 -85
- package/build/module/services/statuses/index.js +0 -9
- package/build/module/services/statuses/index.unit.test.d.ts +0 -1
- package/build/module/services/statuses/index.unit.test.js +0 -55
- package/build/module/services/statuses/methods.d.ts +0 -51
- package/build/module/services/statuses/methods.js +0 -1
- package/build/module/services/users/entities.d.ts +0 -40
- package/build/module/services/users/entities.js +0 -1
- package/build/module/services/users/index.d.ts +0 -9
- package/build/module/services/users/index.integration.test.d.ts +0 -1
- package/build/module/services/users/index.integration.test.js +0 -28
- package/build/module/services/users/index.js +0 -5
- package/build/module/services/users/index.unit.test.d.ts +0 -1
- package/build/module/services/users/index.unit.test.js +0 -20
- package/build/module/services/users/methods.d.ts +0 -17
- package/build/module/services/users/methods.js +0 -1
- package/build/module/utils/Diff.d.ts +0 -1
- package/build/module/utils/Diff.js +0 -1
- package/build/module/utils/ExtractValue.d.ts +0 -6
- package/build/module/utils/ExtractValue.js +0 -1
- package/build/module/utils/isArray.d.ts +0 -2
- package/build/module/utils/isArray.js +0 -2
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { BoolString, ISODate, NumberString } from '../common';
|
|
2
|
-
export declare type Deal = {
|
|
3
|
-
readonly [key: string]: string | null;
|
|
4
|
-
readonly ID: NumberString;
|
|
5
|
-
readonly TITLE: string;
|
|
6
|
-
readonly TYPE_ID: string;
|
|
7
|
-
readonly STAGE_ID: string;
|
|
8
|
-
readonly PROBABILITY: NumberString | null;
|
|
9
|
-
readonly CURRENCY_ID: string;
|
|
10
|
-
readonly OPPORTUNITY: NumberString;
|
|
11
|
-
readonly TAX_VALUE: NumberString;
|
|
12
|
-
readonly LEAD_ID: NumberString;
|
|
13
|
-
readonly COMPANY_ID: NumberString;
|
|
14
|
-
readonly CONTACT_ID: NumberString | null;
|
|
15
|
-
readonly QUOTE_ID: NumberString | null;
|
|
16
|
-
readonly BEGINDATE: ISODate;
|
|
17
|
-
readonly CLOSEDATE: ISODate;
|
|
18
|
-
readonly ASSIGNED_BY_ID: NumberString;
|
|
19
|
-
readonly CREATED_BY_ID: NumberString;
|
|
20
|
-
readonly MODIFY_BY_ID: NumberString;
|
|
21
|
-
readonly DATE_CREATE: ISODate;
|
|
22
|
-
readonly DATE_MODIFY: ISODate;
|
|
23
|
-
readonly OPENED: BoolString;
|
|
24
|
-
readonly CLOSED: BoolString;
|
|
25
|
-
readonly COMMENTS: string;
|
|
26
|
-
readonly ADDITIONAL_INFO: NumberString | null;
|
|
27
|
-
readonly LOCATION_ID: NumberString | null;
|
|
28
|
-
readonly CATEGORY_ID: NumberString;
|
|
29
|
-
readonly STAGE_SEMANTIC_ID: NumberString;
|
|
30
|
-
readonly IS_NEW: BoolString;
|
|
31
|
-
readonly IS_RECURRING: BoolString;
|
|
32
|
-
readonly IS_RETURN_CUSTOMER: BoolString;
|
|
33
|
-
readonly IS_REPEATED_APPROACH: BoolString;
|
|
34
|
-
readonly SOURCE_ID: NumberString | null;
|
|
35
|
-
readonly SOURCE_DESCRIPTION: string | null;
|
|
36
|
-
readonly ORIGINATOR_ID: string;
|
|
37
|
-
readonly ORIGIN_ID: NumberString;
|
|
38
|
-
readonly UTM_SOURCE: string | null;
|
|
39
|
-
readonly UTM_MEDIUM: string | null;
|
|
40
|
-
readonly UTM_CAMPAIGN: string | null;
|
|
41
|
-
readonly UTM_CONTENT: string | null;
|
|
42
|
-
readonly UTM_TERM: string | null;
|
|
43
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Call } from '../../client/methods/call';
|
|
2
|
-
import { List } from '../../client/methods/list';
|
|
3
|
-
import { Method, MethodParams } from '../../methods';
|
|
4
|
-
declare type Dependencies = {
|
|
5
|
-
readonly call: Call;
|
|
6
|
-
readonly list: List;
|
|
7
|
-
};
|
|
8
|
-
declare const _default: ({ call, list }: Dependencies) => {
|
|
9
|
-
fields: () => Promise<import("../../payloads").GetPayload<import("../common").Fields>>;
|
|
10
|
-
create: <D extends {
|
|
11
|
-
readonly fields: Partial<import("./entities").Deal>;
|
|
12
|
-
readonly params?: {
|
|
13
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
14
|
-
} | undefined;
|
|
15
|
-
}>(fields: D["fields"], params?: D["params"] | undefined) => Promise<import("../../payloads").GetPayload<number>>;
|
|
16
|
-
get: (id: string) => Promise<import("../../payloads").GetPayload<import("./entities").Deal>>;
|
|
17
|
-
list: (params?: MethodParams<Method.CRM_DEAL_LIST>) => Promise<import("../../payloads").ListPayload<import("./entities").Deal>>;
|
|
18
|
-
update: <D_1 extends {
|
|
19
|
-
readonly id: string;
|
|
20
|
-
readonly fields: Record<string, unknown>;
|
|
21
|
-
readonly params?: {
|
|
22
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
23
|
-
} | undefined;
|
|
24
|
-
}>(id: string, fields: D_1["fields"], params?: D_1["params"] | undefined) => Promise<import("../../payloads").GetPayload<boolean>>;
|
|
25
|
-
};
|
|
26
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const bitrix_1 = __importDefault(require("./../../bitrix"));
|
|
7
|
-
const WEBHOOK_URL = process.env['WEBHOOK_URL'];
|
|
8
|
-
if (!WEBHOOK_URL) {
|
|
9
|
-
throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
|
|
10
|
-
}
|
|
11
|
-
const { deals } = (0, bitrix_1.default)(WEBHOOK_URL);
|
|
12
|
-
describe('Deals', () => {
|
|
13
|
-
describe('fields', () => {
|
|
14
|
-
it('should get all fields', async () => {
|
|
15
|
-
const { result } = await deals.fields();
|
|
16
|
-
expect(result).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const methods_1 = require("../../methods");
|
|
4
|
-
exports.default = ({ call, list }) => ({
|
|
5
|
-
fields: () => call(methods_1.Method.CRM_DEAL_FIELDS, {}),
|
|
6
|
-
create: (fields, params) => call(methods_1.Method.CRM_DEAL_ADD, { fields, params }),
|
|
7
|
-
get: (id) => call(methods_1.Method.CRM_DEAL_GET, { id }),
|
|
8
|
-
list: (params = {}) => list(methods_1.Method.CRM_DEAL_LIST, params),
|
|
9
|
-
update: (id, fields, params) => call(methods_1.Method.CRM_DEAL_UPDATE, { id, fields, params })
|
|
10
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const _1 = __importDefault(require("."));
|
|
7
|
-
const mockCall = jest.fn(() => Promise.resolve());
|
|
8
|
-
const mockList = jest.fn(() => Promise.resolve());
|
|
9
|
-
const deals = (0, _1.default)({ call: mockCall, list: mockList });
|
|
10
|
-
const ID = '77';
|
|
11
|
-
describe('Deals', () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
mockCall.mockClear();
|
|
14
|
-
mockList.mockClear();
|
|
15
|
-
});
|
|
16
|
-
it('should expose API methods', () => {
|
|
17
|
-
expect(deals).toMatchSnapshot();
|
|
18
|
-
});
|
|
19
|
-
describe('`create`', () => {
|
|
20
|
-
it('should invoke `call`', async () => {
|
|
21
|
-
await deals.create({
|
|
22
|
-
COMMENTS: 'Some comment'
|
|
23
|
-
}, {
|
|
24
|
-
REGISTER_SONET_EVENT: 'Y'
|
|
25
|
-
});
|
|
26
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
27
|
-
});
|
|
28
|
-
it('should work without optional params', async () => {
|
|
29
|
-
await deals.create({
|
|
30
|
-
COMMENTS: 'Some comment'
|
|
31
|
-
});
|
|
32
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe('`get`', () => {
|
|
36
|
-
it('should invoke `call`', async () => {
|
|
37
|
-
await deals.get(ID);
|
|
38
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe('`list`', () => {
|
|
42
|
-
it('should invoke `list`', async () => {
|
|
43
|
-
await deals.list({
|
|
44
|
-
start: 0,
|
|
45
|
-
order: { COMMENTS: 'ASC' },
|
|
46
|
-
filter: { '>PROBABILITY': 50 },
|
|
47
|
-
select: ['*', 'UF_*']
|
|
48
|
-
});
|
|
49
|
-
expect(mockList.mock.calls).toMatchSnapshot();
|
|
50
|
-
});
|
|
51
|
-
it('should work without optional params', async () => {
|
|
52
|
-
await deals.list();
|
|
53
|
-
expect(mockList.mock.calls).toMatchSnapshot();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('`update`', () => {
|
|
57
|
-
it('should invoke `call`', async () => {
|
|
58
|
-
await deals.update(ID, {
|
|
59
|
-
COMMENTS: 'Some comment'
|
|
60
|
-
}, {
|
|
61
|
-
REGISTER_SONET_EVENT: 'Y'
|
|
62
|
-
});
|
|
63
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
64
|
-
});
|
|
65
|
-
it('should work without optional params', async () => {
|
|
66
|
-
await deals.update(ID, {
|
|
67
|
-
COMMENTS: 'Some comment'
|
|
68
|
-
});
|
|
69
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ListParams, Method } from '../../methods';
|
|
2
|
-
import { GetPayload, ListPayload } from '../../payloads';
|
|
3
|
-
import { Fields } from '../common';
|
|
4
|
-
import { Deal } from './entities';
|
|
5
|
-
export declare type DealsMethods = {
|
|
6
|
-
readonly [Method.CRM_DEAL_FIELDS]: {
|
|
7
|
-
readonly type: Deal;
|
|
8
|
-
readonly payload: GetPayload<Fields>;
|
|
9
|
-
readonly params?: Record<string, unknown>;
|
|
10
|
-
};
|
|
11
|
-
readonly [Method.CRM_DEAL_ADD]: {
|
|
12
|
-
readonly type: Deal;
|
|
13
|
-
readonly payload: GetPayload<number>;
|
|
14
|
-
readonly params: {
|
|
15
|
-
readonly fields: Partial<Deal>;
|
|
16
|
-
readonly params?: {
|
|
17
|
-
readonly REGISTER_SONET_EVENT: 'Y' | 'N';
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
readonly [Method.CRM_DEAL_GET]: {
|
|
22
|
-
readonly type: Deal;
|
|
23
|
-
readonly payload: GetPayload<Deal>;
|
|
24
|
-
readonly params: {
|
|
25
|
-
readonly id: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
readonly [Method.CRM_DEAL_LIST]: {
|
|
29
|
-
readonly type: Deal;
|
|
30
|
-
readonly payload: ListPayload<Deal>;
|
|
31
|
-
readonly params: ListParams;
|
|
32
|
-
};
|
|
33
|
-
readonly [Method.CRM_DEAL_UPDATE]: {
|
|
34
|
-
readonly type: Deal;
|
|
35
|
-
readonly payload: GetPayload<boolean>;
|
|
36
|
-
readonly params: {
|
|
37
|
-
readonly id: string;
|
|
38
|
-
readonly fields: Record<string, unknown>;
|
|
39
|
-
readonly params?: {
|
|
40
|
-
readonly REGISTER_SONET_EVENT: 'Y' | 'N';
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { BoolString, ISODate, NumberString } from '../common';
|
|
2
|
-
export declare type Lead = {
|
|
3
|
-
readonly [key: string]: string | null;
|
|
4
|
-
readonly ID: NumberString;
|
|
5
|
-
readonly TITLE: string;
|
|
6
|
-
readonly HONORIFIC: string | null;
|
|
7
|
-
readonly NAME: string | null;
|
|
8
|
-
readonly SECOND_NAME: string | null;
|
|
9
|
-
readonly LAST_NAME: string | null;
|
|
10
|
-
readonly COMPANY_TITLE: string | null;
|
|
11
|
-
readonly COMPANY_ID: NumberString | null;
|
|
12
|
-
readonly CONTACT_ID: NumberString | null;
|
|
13
|
-
readonly IS_RETURN_CUSTOMER: BoolString;
|
|
14
|
-
readonly BIRTHDATE: ISODate;
|
|
15
|
-
readonly SOURCE_ID: NumberString;
|
|
16
|
-
readonly SOURCE_DESCRIPTION: string | null;
|
|
17
|
-
readonly STATUS_ID: string;
|
|
18
|
-
readonly STATUS_DESCRIPTION: string | null;
|
|
19
|
-
readonly POST: string | null;
|
|
20
|
-
readonly COMMENTS: string | null;
|
|
21
|
-
readonly CURRENCY_ID: string;
|
|
22
|
-
readonly OPPORTUNITY: NumberString;
|
|
23
|
-
readonly HAS_PHONE: BoolString;
|
|
24
|
-
readonly HAS_EMAIL: BoolString;
|
|
25
|
-
readonly HAS_IMOL: BoolString;
|
|
26
|
-
readonly ASSIGNED_BY_ID: NumberString;
|
|
27
|
-
readonly CREATED_BY_ID: NumberString;
|
|
28
|
-
readonly MODIFY_BY_ID: NumberString;
|
|
29
|
-
readonly DATE_CREATE: ISODate;
|
|
30
|
-
readonly DATE_MODIFY: ISODate;
|
|
31
|
-
readonly DATE_CLOSED: ISODate;
|
|
32
|
-
readonly STATUS_SEMANTIC_ID: string;
|
|
33
|
-
readonly OPENED: BoolString;
|
|
34
|
-
readonly ORIGINATOR_ID: string | null;
|
|
35
|
-
readonly ORIGIN_ID: NumberString | null;
|
|
36
|
-
readonly ADDRESS: string | null;
|
|
37
|
-
readonly ADDRESS_2: string | null;
|
|
38
|
-
readonly ADDRESS_CITY: string | null;
|
|
39
|
-
readonly ADDRESS_POSTAL_CODE: string | null;
|
|
40
|
-
readonly ADDRESS_REGION: string | null;
|
|
41
|
-
readonly ADDRESS_PROVINCE: string | null;
|
|
42
|
-
readonly ADDRESS_COUNTRY: string | null;
|
|
43
|
-
readonly ADDRESS_COUNTRY_CODE: string | null;
|
|
44
|
-
readonly UTM_SOURCE: string | null;
|
|
45
|
-
readonly UTM_MEDIUM: string | null;
|
|
46
|
-
readonly UTM_CAMPAIGN: string | null;
|
|
47
|
-
readonly UTM_CONTENT: string | null;
|
|
48
|
-
readonly UTM_TERM: string | null;
|
|
49
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Call } from '../../client/methods/call';
|
|
2
|
-
import { List } from '../../client/methods/list';
|
|
3
|
-
import { Method, MethodParams } from '../../methods';
|
|
4
|
-
declare type Dependencies = {
|
|
5
|
-
readonly call: Call;
|
|
6
|
-
readonly list: List;
|
|
7
|
-
};
|
|
8
|
-
declare const _default: ({ call, list }: Dependencies) => {
|
|
9
|
-
fields: () => Promise<import("../../payloads").GetPayload<import("../common").Fields>>;
|
|
10
|
-
create: <D extends {
|
|
11
|
-
readonly fields: Partial<import("./entities").Lead>;
|
|
12
|
-
readonly params?: {
|
|
13
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
14
|
-
} | undefined;
|
|
15
|
-
}>(fields: D["fields"], params?: D["params"] | undefined) => Promise<import("../../payloads").GetPayload<number>>;
|
|
16
|
-
get: (id: string) => Promise<import("../../payloads").GetPayload<import("./entities").Lead>>;
|
|
17
|
-
list: (params?: MethodParams<Method.CRM_LEAD_LIST>) => Promise<import("../../payloads").ListPayload<import("./entities").Lead>>;
|
|
18
|
-
update: <D_1 extends {
|
|
19
|
-
readonly id: string;
|
|
20
|
-
readonly fields: Record<string, unknown>;
|
|
21
|
-
readonly params?: {
|
|
22
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
23
|
-
} | undefined;
|
|
24
|
-
}>(id: string, fields: D_1["fields"], params?: D_1["params"] | undefined) => Promise<import("../../payloads").GetPayload<boolean>>;
|
|
25
|
-
};
|
|
26
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const bitrix_1 = __importDefault(require("./../../bitrix"));
|
|
7
|
-
const WEBHOOK_URL = process.env['WEBHOOK_URL'];
|
|
8
|
-
if (!WEBHOOK_URL) {
|
|
9
|
-
throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
|
|
10
|
-
}
|
|
11
|
-
const { leads } = (0, bitrix_1.default)(WEBHOOK_URL);
|
|
12
|
-
describe('Leads', () => {
|
|
13
|
-
describe('fields', () => {
|
|
14
|
-
it('should get all fields', async () => {
|
|
15
|
-
const { result } = await leads.fields();
|
|
16
|
-
expect(result).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const methods_1 = require("../../methods");
|
|
4
|
-
exports.default = ({ call, list }) => ({
|
|
5
|
-
fields: () => call(methods_1.Method.CRM_LEAD_FIELDS, {}),
|
|
6
|
-
create: (fields, params) => call(methods_1.Method.CRM_LEAD_ADD, { fields, params }),
|
|
7
|
-
get: (id) => call(methods_1.Method.CRM_LEAD_GET, { id }),
|
|
8
|
-
list: (params = {}) => list(methods_1.Method.CRM_LEAD_LIST, params),
|
|
9
|
-
update: (id, fields, params) => call(methods_1.Method.CRM_LEAD_UPDATE, { id, fields, params })
|
|
10
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const _1 = __importDefault(require("."));
|
|
7
|
-
const mockCall = jest.fn(() => Promise.resolve());
|
|
8
|
-
const mockList = jest.fn(() => Promise.resolve());
|
|
9
|
-
const leads = (0, _1.default)({ call: mockCall, list: mockList });
|
|
10
|
-
const ID = '77';
|
|
11
|
-
describe('Leads', () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
mockCall.mockClear();
|
|
14
|
-
mockList.mockClear();
|
|
15
|
-
});
|
|
16
|
-
it('should expose API methods', () => {
|
|
17
|
-
expect(leads).toMatchSnapshot();
|
|
18
|
-
});
|
|
19
|
-
describe('`create`', () => {
|
|
20
|
-
it('should invoke `call`', async () => {
|
|
21
|
-
await leads.create({
|
|
22
|
-
COMMENTS: 'Some comment'
|
|
23
|
-
}, {
|
|
24
|
-
REGISTER_SONET_EVENT: 'Y'
|
|
25
|
-
});
|
|
26
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
27
|
-
});
|
|
28
|
-
it('should work without optional params', async () => {
|
|
29
|
-
await leads.create({
|
|
30
|
-
COMMENTS: 'Some comment'
|
|
31
|
-
});
|
|
32
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe('`get`', () => {
|
|
36
|
-
it('should invoke `call`', async () => {
|
|
37
|
-
await leads.get(ID);
|
|
38
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe('`list`', () => {
|
|
42
|
-
it('should invoke `list`', async () => {
|
|
43
|
-
await leads.list({
|
|
44
|
-
start: 0,
|
|
45
|
-
order: { COMMENTS: 'ASC' },
|
|
46
|
-
filter: { '>PROBABILITY': 50 },
|
|
47
|
-
select: ['*', 'UF_*']
|
|
48
|
-
});
|
|
49
|
-
expect(mockList.mock.calls).toMatchSnapshot();
|
|
50
|
-
});
|
|
51
|
-
it('should work without optional params', async () => {
|
|
52
|
-
await leads.list();
|
|
53
|
-
expect(mockList.mock.calls).toMatchSnapshot();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('`update`', () => {
|
|
57
|
-
it('should invoke `call`', async () => {
|
|
58
|
-
await leads.update(ID, {
|
|
59
|
-
COMMENTS: 'Some comment'
|
|
60
|
-
}, {
|
|
61
|
-
REGISTER_SONET_EVENT: 'Y'
|
|
62
|
-
});
|
|
63
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
64
|
-
});
|
|
65
|
-
it('should work without optional params', async () => {
|
|
66
|
-
await leads.update(ID, {
|
|
67
|
-
COMMENTS: 'Some comment'
|
|
68
|
-
});
|
|
69
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ListParams, Method } from '../../methods';
|
|
2
|
-
import { GetPayload, ListPayload } from '../../payloads';
|
|
3
|
-
import { Fields } from '../common';
|
|
4
|
-
import { Lead } from './entities';
|
|
5
|
-
export declare type LeadsMethods = {
|
|
6
|
-
readonly [Method.CRM_LEAD_FIELDS]: {
|
|
7
|
-
readonly type: Lead;
|
|
8
|
-
readonly payload: GetPayload<Fields>;
|
|
9
|
-
readonly params?: Record<string, unknown>;
|
|
10
|
-
};
|
|
11
|
-
readonly [Method.CRM_LEAD_ADD]: {
|
|
12
|
-
readonly type: Lead;
|
|
13
|
-
readonly payload: GetPayload<number>;
|
|
14
|
-
readonly params: {
|
|
15
|
-
readonly fields: Partial<Lead>;
|
|
16
|
-
readonly params?: {
|
|
17
|
-
readonly REGISTER_SONET_EVENT: 'Y' | 'N';
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
readonly [Method.CRM_LEAD_GET]: {
|
|
22
|
-
readonly type: Lead;
|
|
23
|
-
readonly payload: GetPayload<Lead>;
|
|
24
|
-
readonly params: {
|
|
25
|
-
readonly id: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
readonly [Method.CRM_LEAD_LIST]: {
|
|
29
|
-
readonly type: Lead;
|
|
30
|
-
readonly payload: ListPayload<Lead>;
|
|
31
|
-
readonly params: ListParams;
|
|
32
|
-
};
|
|
33
|
-
readonly [Method.CRM_LEAD_UPDATE]: {
|
|
34
|
-
readonly type: Lead;
|
|
35
|
-
readonly payload: GetPayload<boolean>;
|
|
36
|
-
readonly params: {
|
|
37
|
-
readonly id: string;
|
|
38
|
-
readonly fields: Record<string, unknown>;
|
|
39
|
-
readonly params?: {
|
|
40
|
-
readonly REGISTER_SONET_EVENT: 'Y' | 'N';
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BoolString, NumberString } from '../common';
|
|
2
|
-
export declare type Extra = {
|
|
3
|
-
readonly SEMANTICS: string;
|
|
4
|
-
readonly COLOR: string;
|
|
5
|
-
};
|
|
6
|
-
export declare type Status = {
|
|
7
|
-
readonly [key: string]: string | Extra | undefined;
|
|
8
|
-
readonly ID: NumberString;
|
|
9
|
-
readonly ENTITY_ID: string;
|
|
10
|
-
readonly STATUS_ID: NumberString;
|
|
11
|
-
readonly NAME: string;
|
|
12
|
-
readonly NAME_INIT: string;
|
|
13
|
-
readonly SORT: NumberString;
|
|
14
|
-
readonly SYSTEM: BoolString;
|
|
15
|
-
readonly EXTRA: Extra | undefined;
|
|
16
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Call } from '../../client/methods/call';
|
|
2
|
-
import { Method, MethodParams } from '../../methods';
|
|
3
|
-
declare type Dependencies = {
|
|
4
|
-
readonly call: Call;
|
|
5
|
-
};
|
|
6
|
-
declare const _default: ({ call }: Dependencies) => {
|
|
7
|
-
fields: () => Promise<import("../../payloads").GetPayload<import("../common").Fields>>;
|
|
8
|
-
create: (fields: MethodParams<Method.CRM_STATUS_ADD>['fields']) => Promise<import("../../payloads").GetPayload<number>>;
|
|
9
|
-
delete: (id: string | number, params?: MethodParams<Method.CRM_STATUS_DELETE>['params']) => Promise<import("../../payloads").GetPayload<boolean>>;
|
|
10
|
-
get: (id: string | number) => Promise<import("../../payloads").GetPayload<import("./entities").Status>>;
|
|
11
|
-
list: (params?: MethodParams<Method.CRM_STATUS_LIST>) => Promise<import("../../payloads").ListPayload<import("./entities").Status>>;
|
|
12
|
-
update: (id: string | number, fields: MethodParams<Method.CRM_STATUS_UPDATE>['fields']) => Promise<import("../../payloads").GetPayload<boolean>>;
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const bitrix_1 = __importDefault(require("../../bitrix"));
|
|
7
|
-
// @ts-ignore this should be improved in a future but it works for now
|
|
8
|
-
const isSortedAsc = (arr) => arr.slice(1).every((v, i) => arr[i] <= v);
|
|
9
|
-
// @ts-ignore this should be improved in a future but it works for now
|
|
10
|
-
const isSortedDesc = (arr) => arr.slice(1).every((v, i) => arr[i] >= v);
|
|
11
|
-
const WEBHOOK_URL = process.env['WEBHOOK_URL'];
|
|
12
|
-
if (!WEBHOOK_URL) {
|
|
13
|
-
throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
|
|
14
|
-
}
|
|
15
|
-
const { statuses } = (0, bitrix_1.default)(WEBHOOK_URL);
|
|
16
|
-
describe('Statuses', () => {
|
|
17
|
-
describe('fields', () => {
|
|
18
|
-
it('should get all fields', async () => {
|
|
19
|
-
const { result } = await statuses.fields();
|
|
20
|
-
expect(result).toMatchSnapshot();
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
describe('list', () => {
|
|
24
|
-
it('should get all entries without optional parameters', async () => {
|
|
25
|
-
const { result } = await statuses.list();
|
|
26
|
-
expect(result).toMatchSnapshot();
|
|
27
|
-
});
|
|
28
|
-
it('should return only entries with ENTITY_ID = STATUS sorted in ascending order', async () => {
|
|
29
|
-
const { result } = await statuses.list({
|
|
30
|
-
order: { SORT: 'ASC' },
|
|
31
|
-
filter: { ENTITY_ID: 'STATUS' }
|
|
32
|
-
});
|
|
33
|
-
expect(result.every((s) => s.ENTITY_ID === 'STATUS')).toBeTruthy();
|
|
34
|
-
expect(isSortedAsc(result.map((s) => s.SORT))).toBeTruthy();
|
|
35
|
-
expect(result).toMatchSnapshot();
|
|
36
|
-
});
|
|
37
|
-
it('should return only entries with ENTITY_ID = STATUS sorted in descending order', async () => {
|
|
38
|
-
const { result } = await statuses.list({
|
|
39
|
-
order: { SORT: 'DESC' },
|
|
40
|
-
filter: { ENTITY_ID: 'STATUS' }
|
|
41
|
-
});
|
|
42
|
-
expect(result.every((s) => s.ENTITY_ID === 'STATUS')).toBeTruthy();
|
|
43
|
-
expect(isSortedDesc(result.map((s) => s.SORT))).toBeTruthy();
|
|
44
|
-
expect(result).toMatchSnapshot();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
describe('get', () => {
|
|
48
|
-
it('should get entry with ID = 1', async () => {
|
|
49
|
-
const { result } = await statuses.get('1');
|
|
50
|
-
expect(result).toMatchSnapshot();
|
|
51
|
-
});
|
|
52
|
-
it('should return an error in case non existent ID is requested', async () => {
|
|
53
|
-
const get = statuses.get('1001');
|
|
54
|
-
await expect(get).rejects.toThrow(Error);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe('create', () => {
|
|
58
|
-
it('should create an entry', async () => {
|
|
59
|
-
const entry = {
|
|
60
|
-
ENTITY_ID: 'STATUS',
|
|
61
|
-
STATUS_ID: 'TEST',
|
|
62
|
-
NAME: 'TEST'
|
|
63
|
-
};
|
|
64
|
-
const { result: id } = await statuses.create(entry);
|
|
65
|
-
expect(id).toBeGreaterThan(0);
|
|
66
|
-
const { result: status } = await statuses.get(id);
|
|
67
|
-
expect(status).toMatchSnapshot({
|
|
68
|
-
ID: expect.any(String)
|
|
69
|
-
});
|
|
70
|
-
const { result: deleteResult } = await statuses.delete(id);
|
|
71
|
-
expect(deleteResult).toBeTruthy();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe('update', () => {
|
|
75
|
-
it('should update an entry', async () => {
|
|
76
|
-
const STATUS_ID = 101;
|
|
77
|
-
const { result: status } = await statuses.get(STATUS_ID);
|
|
78
|
-
expect(status).toMatchSnapshot();
|
|
79
|
-
const { result: updateResult } = await statuses.update(STATUS_ID, {
|
|
80
|
-
...status,
|
|
81
|
-
NAME: 'CHANGED'
|
|
82
|
-
});
|
|
83
|
-
expect(updateResult).toBeTruthy();
|
|
84
|
-
const { result: updatedStatus } = await statuses.get(STATUS_ID);
|
|
85
|
-
expect(updatedStatus).toMatchSnapshot();
|
|
86
|
-
const { result: rollbackResult } = await statuses.update(STATUS_ID, status);
|
|
87
|
-
expect(rollbackResult).toBeTruthy();
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const methods_1 = require("../../methods");
|
|
4
|
-
exports.default = ({ call }) => ({
|
|
5
|
-
fields: () => call(methods_1.Method.CRM_STATUS_FIELDS, {}),
|
|
6
|
-
create: (fields) => call(methods_1.Method.CRM_STATUS_ADD, { fields }),
|
|
7
|
-
delete: (id, params = {}) => call(methods_1.Method.CRM_STATUS_DELETE, { id, params }),
|
|
8
|
-
get: (id) => call(methods_1.Method.CRM_STATUS_GET, { id }),
|
|
9
|
-
list: (params = {}) => call(methods_1.Method.CRM_STATUS_LIST, params),
|
|
10
|
-
update: (id, fields) => call(methods_1.Method.CRM_STATUS_UPDATE, { id, fields })
|
|
11
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|