@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,60 +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 statuses = (0, _1.default)({ call: mockCall });
|
|
10
|
-
const ID = '77';
|
|
11
|
-
describe('Statuses', () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
mockCall.mockClear();
|
|
14
|
-
mockList.mockClear();
|
|
15
|
-
});
|
|
16
|
-
it('should expose API methods', () => {
|
|
17
|
-
expect(statuses).toMatchSnapshot();
|
|
18
|
-
});
|
|
19
|
-
describe('`create`', () => {
|
|
20
|
-
it('should invoke `call`', async () => {
|
|
21
|
-
await statuses.create({
|
|
22
|
-
NAME: 'Test name'
|
|
23
|
-
});
|
|
24
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe('`get`', () => {
|
|
28
|
-
it('should invoke `call`', async () => {
|
|
29
|
-
await statuses.get(ID);
|
|
30
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
describe('`list`', () => {
|
|
34
|
-
it('should invoke `call`', async () => {
|
|
35
|
-
await statuses.list({
|
|
36
|
-
order: { NAME: 'ASC' },
|
|
37
|
-
filter: { ENTITY_ID: 'STATUS' }
|
|
38
|
-
});
|
|
39
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
40
|
-
});
|
|
41
|
-
it('should work without optional params', async () => {
|
|
42
|
-
await statuses.list();
|
|
43
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
describe('`update`', () => {
|
|
47
|
-
it('should invoke `call`', async () => {
|
|
48
|
-
await statuses.update(ID, {
|
|
49
|
-
NAME: 'Test name'
|
|
50
|
-
});
|
|
51
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
52
|
-
});
|
|
53
|
-
it('should work without optional params', async () => {
|
|
54
|
-
await statuses.update(ID, {
|
|
55
|
-
NAME: 'Test name'
|
|
56
|
-
});
|
|
57
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Method } from '../../methods';
|
|
2
|
-
import { GetPayload, ListPayload } from '../../payloads';
|
|
3
|
-
import { Fields } from '../common';
|
|
4
|
-
import { Status } from './entities';
|
|
5
|
-
export declare type StatusesMethods = {
|
|
6
|
-
readonly [Method.CRM_STATUS_FIELDS]: {
|
|
7
|
-
readonly type: Status;
|
|
8
|
-
readonly payload: GetPayload<Fields>;
|
|
9
|
-
readonly params?: Record<string, unknown>;
|
|
10
|
-
};
|
|
11
|
-
readonly [Method.CRM_STATUS_ADD]: {
|
|
12
|
-
readonly type: Status;
|
|
13
|
-
readonly payload: GetPayload<number>;
|
|
14
|
-
readonly params: {
|
|
15
|
-
readonly fields: Partial<Status>;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
readonly [Method.CRM_STATUS_DELETE]: {
|
|
19
|
-
readonly type: Status;
|
|
20
|
-
readonly payload: GetPayload<boolean>;
|
|
21
|
-
readonly params: {
|
|
22
|
-
readonly id: string | number;
|
|
23
|
-
readonly params?: {
|
|
24
|
-
readonly FORCED?: 'Y' | 'N';
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
readonly [Method.CRM_STATUS_GET]: {
|
|
29
|
-
readonly type: Status;
|
|
30
|
-
readonly payload: GetPayload<Status>;
|
|
31
|
-
readonly params: {
|
|
32
|
-
readonly id: string | number;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
readonly [Method.CRM_STATUS_LIST]: {
|
|
36
|
-
readonly type: Status;
|
|
37
|
-
readonly payload: ListPayload<Status>;
|
|
38
|
-
readonly params: {
|
|
39
|
-
readonly order?: Record<string, unknown>;
|
|
40
|
-
readonly filter?: Record<string, unknown>;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
readonly [Method.CRM_STATUS_UPDATE]: {
|
|
44
|
-
readonly type: Status;
|
|
45
|
-
readonly payload: GetPayload<boolean>;
|
|
46
|
-
readonly params: {
|
|
47
|
-
readonly id: string | number;
|
|
48
|
-
readonly fields: Record<string, unknown>;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { GenderString, ISODate, NumberString } from '../common';
|
|
2
|
-
export declare type User = {
|
|
3
|
-
readonly [key: string]: string | boolean | null | readonly number[];
|
|
4
|
-
readonly ID: NumberString;
|
|
5
|
-
readonly ACTIVE: boolean;
|
|
6
|
-
readonly EMAIL: string | null;
|
|
7
|
-
readonly NAME: string | null;
|
|
8
|
-
readonly LAST_NAME: string | null;
|
|
9
|
-
readonly SECOND_NAME: string | null;
|
|
10
|
-
readonly PERSONAL_GENDER: GenderString;
|
|
11
|
-
readonly PERSONAL_PROFESSION: string | null;
|
|
12
|
-
readonly PERSONAL_WWW: string | null;
|
|
13
|
-
readonly PERSONAL_BIRTHDAY: ISODate;
|
|
14
|
-
readonly PERSONAL_PHOTO: string | null;
|
|
15
|
-
readonly PERSONAL_ICQ: string | null;
|
|
16
|
-
readonly PERSONAL_PHONE: string | null;
|
|
17
|
-
readonly PERSONAL_FAX: string | null;
|
|
18
|
-
readonly PERSONAL_MOBILE: string | null;
|
|
19
|
-
readonly PERSONAL_PAGER: string | null;
|
|
20
|
-
readonly PERSONAL_STREET: string | null;
|
|
21
|
-
readonly PERSONAL_CITY: string | null;
|
|
22
|
-
readonly PERSONAL_STATE: string | null;
|
|
23
|
-
readonly PERSONAL_ZIP: string | null;
|
|
24
|
-
readonly PERSONAL_COUNTRY: string | null;
|
|
25
|
-
readonly WORK_COMPANY: string | null;
|
|
26
|
-
readonly WORK_POSITION: string | null;
|
|
27
|
-
readonly WORK_PHONE: string | null;
|
|
28
|
-
readonly UF_DEPARTMENT: readonly number[];
|
|
29
|
-
readonly UF_INTERESTS: string | null;
|
|
30
|
-
readonly UF_SKILLS: string | null;
|
|
31
|
-
readonly UF_WEB_SITES: string | null;
|
|
32
|
-
readonly UF_XING: string | null;
|
|
33
|
-
readonly UF_LINKEDIN: string | null;
|
|
34
|
-
readonly UF_FACEBOOK: string | null;
|
|
35
|
-
readonly UF_TWITTER: string | null;
|
|
36
|
-
readonly UF_SKYPE: string | null;
|
|
37
|
-
readonly UF_DISTRICT: string | null;
|
|
38
|
-
readonly UF_PHONE_INNER: NumberString | null;
|
|
39
|
-
readonly USER_TYPE: 'employee';
|
|
40
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Call } from '../../client/methods/call';
|
|
2
|
-
declare type Dependencies = {
|
|
3
|
-
readonly call: Call;
|
|
4
|
-
};
|
|
5
|
-
declare const _default: ({ call }: Dependencies) => {
|
|
6
|
-
fields: () => Promise<import("../../payloads").GetPayload<import("./entities").User>>;
|
|
7
|
-
get: (id?: string) => Promise<import("../../payloads").GetPayload<readonly import("./entities").User[]>>;
|
|
8
|
-
};
|
|
9
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,33 +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 { users } = (0, bitrix_1.default)(WEBHOOK_URL);
|
|
12
|
-
describe('Users', () => {
|
|
13
|
-
describe('fields', () => {
|
|
14
|
-
it('should get all fields', async () => {
|
|
15
|
-
const { result } = await users.fields();
|
|
16
|
-
expect(result).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
describe('get', () => {
|
|
20
|
-
it('should get all users', async () => {
|
|
21
|
-
const { result } = await users.get();
|
|
22
|
-
expect(result).toMatchSnapshot();
|
|
23
|
-
});
|
|
24
|
-
it('should get entry with ID = 1', async () => {
|
|
25
|
-
const { result } = await users.get('1');
|
|
26
|
-
expect(result).toMatchSnapshot();
|
|
27
|
-
});
|
|
28
|
-
it('should return an error in case non existent ID is requested', async () => {
|
|
29
|
-
const { result } = await users.get('1001');
|
|
30
|
-
expect(result).toEqual([]);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,7 +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.USER_FIELDS, {}),
|
|
6
|
-
get: (id) => call(methods_1.Method.USER_GET, { id })
|
|
7
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +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 users = (0, _1.default)({ call: mockCall });
|
|
10
|
-
const ID = '77';
|
|
11
|
-
describe('Users', () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
mockCall.mockClear();
|
|
14
|
-
mockList.mockClear();
|
|
15
|
-
});
|
|
16
|
-
it('should expose API methods', () => {
|
|
17
|
-
expect(users).toMatchSnapshot();
|
|
18
|
-
});
|
|
19
|
-
describe('`get`', () => {
|
|
20
|
-
it('should invoke `call`', async () => {
|
|
21
|
-
await users.get(ID);
|
|
22
|
-
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Method } from '../../methods';
|
|
2
|
-
import { GetPayload } from '../../payloads';
|
|
3
|
-
import { User } from './entities';
|
|
4
|
-
export declare type UsersMethods = {
|
|
5
|
-
readonly [Method.USER_FIELDS]: {
|
|
6
|
-
readonly type: User;
|
|
7
|
-
readonly payload: GetPayload<User>;
|
|
8
|
-
readonly params?: Record<string, unknown>;
|
|
9
|
-
};
|
|
10
|
-
readonly [Method.USER_GET]: {
|
|
11
|
-
readonly type: User;
|
|
12
|
-
readonly payload: GetPayload<readonly User[]>;
|
|
13
|
-
readonly params: {
|
|
14
|
-
readonly id?: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare type Diff<T, U> = T extends U ? never : T;
|
package/build/main/utils/Diff.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract value from the `MAP` following the `KEY`
|
|
3
|
-
* It works with `enum` as a `KEY` when matched against dict as `enum` values as a keys,
|
|
4
|
-
* which justifies whole existence of that helper.
|
|
5
|
-
*/
|
|
6
|
-
export declare type ExtractValue<MAP extends Record<string, unknown>, KEY extends string | number | symbol, MAPKEY extends keyof MAP = KEY extends keyof MAP ? KEY : never> = MAP[MAPKEY];
|
package/build/module/bitrix.d.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { ExtendOptions } from 'got';
|
|
2
|
-
/**
|
|
3
|
-
* Construct a Bitrix client with generic methods
|
|
4
|
-
* @param restURI REST endpoint, like a `https://hello.bitrix24.ua/rest` or an inbound webhook endpoint,
|
|
5
|
-
* like a `https://hello.bitrix24.ua/rest/1/WEBHOOK_TOKEN`.
|
|
6
|
-
* @param accessToken Bitrix application Access Token. Do not specify in case inbound webhook endpoint used.
|
|
7
|
-
* @param clientOptions an object that will overwrite underlying configuration for HTTP client,
|
|
8
|
-
* see `https://github.com/sindresorhus/got/blob/main/documentation/2-options.md`.
|
|
9
|
-
*/
|
|
10
|
-
export declare const Bitrix: (restURI: string, accessToken?: string, clientOptions?: ExtendOptions) => {
|
|
11
|
-
call: import("./client/methods/call").Call;
|
|
12
|
-
batch: import("./client/methods/batch").Batch;
|
|
13
|
-
list: import("./client/methods/list").List;
|
|
14
|
-
companies: {
|
|
15
|
-
fields: () => Promise<import("./payloads").GetPayload<import("./services/common").Fields>>;
|
|
16
|
-
create: <D extends {
|
|
17
|
-
readonly fields: Partial<import("./services/companies/entities").Company>;
|
|
18
|
-
readonly params?: {
|
|
19
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
20
|
-
} | undefined;
|
|
21
|
-
}>(fields: D["fields"], params?: D["params"] | undefined) => Promise<import("./payloads").GetPayload<number>>;
|
|
22
|
-
get: (id: string) => Promise<import("./payloads").GetPayload<import("./services/companies/entities").Company>>;
|
|
23
|
-
list: (params?: import("./methods").ListParams) => Promise<import("./payloads").ListPayload<import("./services/companies/entities").Company>>;
|
|
24
|
-
update: <D_1 extends {
|
|
25
|
-
readonly id: string;
|
|
26
|
-
readonly fields: Record<string, unknown>;
|
|
27
|
-
readonly params?: {
|
|
28
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
29
|
-
} | undefined;
|
|
30
|
-
}>(id: string, fields: D_1["fields"], params?: D_1["params"] | undefined) => Promise<import("./payloads").GetPayload<boolean>>;
|
|
31
|
-
};
|
|
32
|
-
contacts: {
|
|
33
|
-
fields: () => Promise<import("./payloads").GetPayload<import("./services/common").Fields>>;
|
|
34
|
-
create: <D_2 extends {
|
|
35
|
-
readonly fields: Partial<import("./services/contacts/entities").Contact>;
|
|
36
|
-
readonly params?: {
|
|
37
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
38
|
-
} | undefined;
|
|
39
|
-
}>(fields: D_2["fields"], params?: D_2["params"] | undefined) => Promise<import("./payloads").GetPayload<number>>;
|
|
40
|
-
get: (id: string) => Promise<import("./payloads").GetPayload<import("./services/contacts/entities").Contact>>;
|
|
41
|
-
list: (params?: import("./methods").ListParams) => Promise<import("./payloads").ListPayload<import("./services/contacts/entities").Contact>>;
|
|
42
|
-
update: <D_3 extends {
|
|
43
|
-
readonly id: string;
|
|
44
|
-
readonly fields: Record<string, unknown>;
|
|
45
|
-
readonly params?: {
|
|
46
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
47
|
-
} | undefined;
|
|
48
|
-
}>(id: string, fields: D_3["fields"], params?: D_3["params"] | undefined) => Promise<import("./payloads").GetPayload<boolean>>;
|
|
49
|
-
};
|
|
50
|
-
deals: {
|
|
51
|
-
fields: () => Promise<import("./payloads").GetPayload<import("./services/common").Fields>>;
|
|
52
|
-
create: <D_4 extends {
|
|
53
|
-
readonly fields: Partial<import("./services/deals/entities").Deal>;
|
|
54
|
-
readonly params?: {
|
|
55
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
56
|
-
} | undefined;
|
|
57
|
-
}>(fields: D_4["fields"], params?: D_4["params"] | undefined) => Promise<import("./payloads").GetPayload<number>>;
|
|
58
|
-
get: (id: string) => Promise<import("./payloads").GetPayload<import("./services/deals/entities").Deal>>;
|
|
59
|
-
list: (params?: import("./methods").ListParams) => Promise<import("./payloads").ListPayload<import("./services/deals/entities").Deal>>;
|
|
60
|
-
update: <D_5 extends {
|
|
61
|
-
readonly id: string;
|
|
62
|
-
readonly fields: Record<string, unknown>;
|
|
63
|
-
readonly params?: {
|
|
64
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
65
|
-
} | undefined;
|
|
66
|
-
}>(id: string, fields: D_5["fields"], params?: D_5["params"] | undefined) => Promise<import("./payloads").GetPayload<boolean>>;
|
|
67
|
-
};
|
|
68
|
-
leads: {
|
|
69
|
-
fields: () => Promise<import("./payloads").GetPayload<import("./services/common").Fields>>;
|
|
70
|
-
create: <D_6 extends {
|
|
71
|
-
readonly fields: Partial<import("./services/leads/entities").Lead>;
|
|
72
|
-
readonly params?: {
|
|
73
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
74
|
-
} | undefined;
|
|
75
|
-
}>(fields: D_6["fields"], params?: D_6["params"] | undefined) => Promise<import("./payloads").GetPayload<number>>;
|
|
76
|
-
get: (id: string) => Promise<import("./payloads").GetPayload<import("./services/leads/entities").Lead>>;
|
|
77
|
-
list: (params?: import("./methods").ListParams) => Promise<import("./payloads").ListPayload<import("./services/leads/entities").Lead>>;
|
|
78
|
-
update: <D_7 extends {
|
|
79
|
-
readonly id: string;
|
|
80
|
-
readonly fields: Record<string, unknown>;
|
|
81
|
-
readonly params?: {
|
|
82
|
-
readonly REGISTER_SONET_EVENT: "Y" | "N";
|
|
83
|
-
} | undefined;
|
|
84
|
-
}>(id: string, fields: D_7["fields"], params?: D_7["params"] | undefined) => Promise<import("./payloads").GetPayload<boolean>>;
|
|
85
|
-
};
|
|
86
|
-
statuses: {
|
|
87
|
-
fields: () => Promise<import("./payloads").GetPayload<import("./services/common").Fields>>;
|
|
88
|
-
create: (fields: Partial<import("./services/statuses/entities").Status>) => Promise<import("./payloads").GetPayload<number>>;
|
|
89
|
-
delete: (id: string | number, params?: {
|
|
90
|
-
readonly FORCED?: "Y" | "N" | undefined;
|
|
91
|
-
} | undefined) => Promise<import("./payloads").GetPayload<boolean>>;
|
|
92
|
-
get: (id: string | number) => Promise<import("./payloads").GetPayload<import("./services/statuses/entities").Status>>;
|
|
93
|
-
list: (params?: {
|
|
94
|
-
readonly order?: Record<string, unknown> | undefined;
|
|
95
|
-
readonly filter?: Record<string, unknown> | undefined;
|
|
96
|
-
}) => Promise<import("./payloads").ListPayload<import("./services/statuses/entities").Status>>;
|
|
97
|
-
update: (id: string | number, fields: Record<string, unknown>) => Promise<import("./payloads").GetPayload<boolean>>;
|
|
98
|
-
};
|
|
99
|
-
users: {
|
|
100
|
-
fields: () => Promise<import("./payloads").GetPayload<import("./services/users/entities").User>>;
|
|
101
|
-
get: (id?: string | undefined) => Promise<import("./payloads").GetPayload<readonly import("./services/users/entities").User[]>>;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
export default Bitrix;
|
|
105
|
-
export * from './methods';
|
|
106
|
-
export * from './commands';
|
|
107
|
-
export * from './services/common';
|
|
108
|
-
export * from './services/companies/entities';
|
|
109
|
-
export * from './services/contacts/entities';
|
|
110
|
-
export * from './services/currencies/entities';
|
|
111
|
-
export * from './services/deals/entities';
|
|
112
|
-
export * from './services/leads/entities';
|
|
113
|
-
export * from './services/statuses/entities';
|
|
114
|
-
export * from './services/users/entities';
|
|
File without changes
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
describe('Bitrix API', () => {
|
|
3
|
-
describe('`get` method', () => {
|
|
4
|
-
it.todo('should get result');
|
|
5
|
-
it.todo('should reject on error');
|
|
6
|
-
});
|
|
7
|
-
describe('`batch` method', () => {
|
|
8
|
-
it.todo('should execute the batch');
|
|
9
|
-
it.todo('should reject on errors');
|
|
10
|
-
});
|
|
11
|
-
describe('`deals`', () => {
|
|
12
|
-
describe('`get` method', () => {
|
|
13
|
-
it.todo('should get entry');
|
|
14
|
-
it.todo('should reject on error');
|
|
15
|
-
});
|
|
16
|
-
describe('`list` method', () => {
|
|
17
|
-
it.todo('should all entries');
|
|
18
|
-
it.todo('should reject on error');
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe('`leads`', () => {
|
|
22
|
-
describe('`get` method', () => {
|
|
23
|
-
it.todo('should get entry');
|
|
24
|
-
it.todo('should reject on error');
|
|
25
|
-
});
|
|
26
|
-
describe('`list` method', () => {
|
|
27
|
-
it.todo('should get all entries');
|
|
28
|
-
it.todo('should reject on error');
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
});
|
package/build/module/bitrix.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import Client from './client';
|
|
2
|
-
import CompaniesService from './services/companies';
|
|
3
|
-
import ContactsService from './services/contacts';
|
|
4
|
-
import DealsService from './services/deals';
|
|
5
|
-
import LeadsService from './services/leads';
|
|
6
|
-
import StatusesService from './services/statuses';
|
|
7
|
-
import UsersService from './services/users';
|
|
8
|
-
/**
|
|
9
|
-
* Construct a Bitrix client with generic methods
|
|
10
|
-
* @param restURI REST endpoint, like a `https://hello.bitrix24.ua/rest` or an inbound webhook endpoint,
|
|
11
|
-
* like a `https://hello.bitrix24.ua/rest/1/WEBHOOK_TOKEN`.
|
|
12
|
-
* @param accessToken Bitrix application Access Token. Do not specify in case inbound webhook endpoint used.
|
|
13
|
-
* @param clientOptions an object that will overwrite underlying configuration for HTTP client,
|
|
14
|
-
* see `https://github.com/sindresorhus/got/blob/main/documentation/2-options.md`.
|
|
15
|
-
*/
|
|
16
|
-
export const Bitrix = (restURI, accessToken, clientOptions) => {
|
|
17
|
-
const { call, batch, list } = Client(restURI, accessToken, clientOptions);
|
|
18
|
-
return {
|
|
19
|
-
call,
|
|
20
|
-
batch,
|
|
21
|
-
list,
|
|
22
|
-
companies: CompaniesService({ call, list }),
|
|
23
|
-
contacts: ContactsService({ call, list }),
|
|
24
|
-
deals: DealsService({ call, list }),
|
|
25
|
-
leads: LeadsService({ call, list }),
|
|
26
|
-
statuses: StatusesService({ call }),
|
|
27
|
-
users: UsersService({ call })
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export default Bitrix;
|
|
31
|
-
export * from './methods';
|
|
32
|
-
export * from './commands';
|
|
33
|
-
export * from './services/common';
|
|
34
|
-
export * from './services/companies/entities';
|
|
35
|
-
export * from './services/contacts/entities';
|
|
36
|
-
export * from './services/currencies/entities';
|
|
37
|
-
export * from './services/deals/entities';
|
|
38
|
-
export * from './services/leads/entities';
|
|
39
|
-
export * from './services/statuses/entities';
|
|
40
|
-
export * from './services/users/entities';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Bitrix from './bitrix';
|
|
2
|
-
import * as client from './client';
|
|
3
|
-
describe('Bitrix', () => {
|
|
4
|
-
it('should init', () => {
|
|
5
|
-
expect(() => Bitrix('https://test.com', 'test_token')).not.toThrow();
|
|
6
|
-
});
|
|
7
|
-
it('should pass endpoint and access token to the client', () => {
|
|
8
|
-
const SpiedClient = jest.spyOn(client, 'default');
|
|
9
|
-
Bitrix('https://test.com', 'test_token');
|
|
10
|
-
expect(SpiedClient.mock.calls).toMatchSnapshot();
|
|
11
|
-
});
|
|
12
|
-
it('should expose API methods', () => {
|
|
13
|
-
const bitrix = Bitrix('https://test.com', 'test_token');
|
|
14
|
-
expect(bitrix).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import got from 'got';
|
|
2
|
-
import nock from 'nock';
|
|
3
|
-
import Queue from 'p-queue';
|
|
4
|
-
import { Method } from '../methods';
|
|
5
|
-
import Client from './index';
|
|
6
|
-
const TEST_URI = 'https://test.com/rest';
|
|
7
|
-
const TEST_ACCESS_TOKEN = 'test_access_token';
|
|
8
|
-
const RESPONSE_200 = 200;
|
|
9
|
-
const spiedQueueAdd = jest.spyOn(Queue.prototype, 'add');
|
|
10
|
-
const client = Client(TEST_URI, TEST_ACCESS_TOKEN);
|
|
11
|
-
describe('Client', () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
spiedQueueAdd.mockClear();
|
|
14
|
-
});
|
|
15
|
-
it('should init', () => {
|
|
16
|
-
expect(() => Client(TEST_URI, TEST_ACCESS_TOKEN)).not.toThrow();
|
|
17
|
-
});
|
|
18
|
-
it('should extend `Got` instance with a specified parameters', () => {
|
|
19
|
-
const spiedGotExtend = jest.spyOn(got, 'extend');
|
|
20
|
-
Client('https://test.com', 'test_token', { https: { rejectUnauthorized: false } });
|
|
21
|
-
expect(spiedGotExtend.mock.calls).toMatchSnapshot();
|
|
22
|
-
});
|
|
23
|
-
it('should expose API methods', () => {
|
|
24
|
-
expect(client).toMatchSnapshot();
|
|
25
|
-
});
|
|
26
|
-
describe('`call`', () => {
|
|
27
|
-
// @todo restore test when issue is resolved (https://github.com/nock/nock/issues/1832)
|
|
28
|
-
it.skip('should add to queue', async () => {
|
|
29
|
-
const payload = {};
|
|
30
|
-
const method = Method.CRM_DEAL_LIST;
|
|
31
|
-
nock(TEST_URI)
|
|
32
|
-
.get(`/${method}?access_token=${TEST_ACCESS_TOKEN}`)
|
|
33
|
-
.twice()
|
|
34
|
-
.reply(RESPONSE_200, payload);
|
|
35
|
-
await client.call(method, {});
|
|
36
|
-
await client.call(method, {});
|
|
37
|
-
expect(spiedQueueAdd.mock.calls).toMatchSnapshot();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('`batch`', () => {
|
|
41
|
-
// @todo restore test when issue is resolved (https://github.com/nock/nock/issues/1832)
|
|
42
|
-
it.skip('should add to queue', async () => {
|
|
43
|
-
const payload = {
|
|
44
|
-
result: {
|
|
45
|
-
result: ['done'],
|
|
46
|
-
result_error: []
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const commands = [
|
|
50
|
-
{ method: Method.CRM_DEAL_GET },
|
|
51
|
-
{ method: Method.CRM_DEAL_LIST }
|
|
52
|
-
];
|
|
53
|
-
nock(TEST_URI)
|
|
54
|
-
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
55
|
-
// fails to match request when it contains `cmd[someName]`. The issue definitely connected
|
|
56
|
-
// to the `[]`, since it does not appear when only one bracket present
|
|
57
|
-
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[0].method}&access_token=${TEST_ACCESS_TOKEN}`)
|
|
58
|
-
.reply(RESPONSE_200, payload)
|
|
59
|
-
.get(`/${Method.BATCH}?cmd%5B0%5D=${commands[1].method}&access_token=${TEST_ACCESS_TOKEN}`)
|
|
60
|
-
.reply(RESPONSE_200, payload);
|
|
61
|
-
await client.batch(commands, 1);
|
|
62
|
-
expect(spiedQueueAdd.mock.calls).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Got can't merge `query` option with other queries if they are string. But that hook can.
|
|
3
|
-
*/
|
|
4
|
-
export default (accessToken) => (options) => {
|
|
5
|
-
if (!accessToken)
|
|
6
|
-
return;
|
|
7
|
-
if (!options.path)
|
|
8
|
-
return;
|
|
9
|
-
const hasQuery = options.path.includes('?');
|
|
10
|
-
options.path = `${options.path}${hasQuery ? '&' : '?'}access_token=${accessToken}`;
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import got from 'got';
|
|
2
|
-
import addAccessToken from './addAccessToken';
|
|
3
|
-
const token = 'mock_token';
|
|
4
|
-
const merge = got.mergeOptions;
|
|
5
|
-
describe('Client `addAccessToken` hook', () => {
|
|
6
|
-
it('should add access token to URL without a query', () => {
|
|
7
|
-
const options = merge({ path: 'test', responseType: 'json' });
|
|
8
|
-
addAccessToken(token)(options);
|
|
9
|
-
expect(options.path).toBe(`test?access_token=${token}`);
|
|
10
|
-
});
|
|
11
|
-
it('should add access token to URL with a query', () => {
|
|
12
|
-
const options = merge({ path: 'test?value=1', responseType: 'json' });
|
|
13
|
-
addAccessToken(token)(options);
|
|
14
|
-
expect(options.path).toBe(`test?value=1&access_token=${token}`);
|
|
15
|
-
});
|
|
16
|
-
it('should not add access token when it is undefined', () => {
|
|
17
|
-
const options = merge({ path: 'test', responseType: 'json' });
|
|
18
|
-
addAccessToken()(options);
|
|
19
|
-
expect(options.path).toBe('test');
|
|
20
|
-
});
|
|
21
|
-
it('should not add access token when URL is undefined', () => {
|
|
22
|
-
const options = merge({ path: undefined, responseType: 'json' });
|
|
23
|
-
addAccessToken(token)(options);
|
|
24
|
-
expect(options.path).toBe(undefined);
|
|
25
|
-
});
|
|
26
|
-
});
|