@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
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as BitrixError, t as createClient } from "./client-Bk76ySik.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2bad/bitrix",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Bitrix24 REST API client that doesn't suck",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -19,85 +19,58 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/2BAD/bitrix.git"
|
|
22
|
+
"url": "git+https://github.com/2BAD/bitrix.git"
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"author": "2BAD (https://github.com/2BAD)",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": {
|
|
30
|
+
"types": "./build/index.d.ts",
|
|
31
|
+
"default": "./build/index.js"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"bin": {
|
|
36
|
+
"bitrix-types": "./build/bin.js"
|
|
37
|
+
},
|
|
29
38
|
"files": [
|
|
30
39
|
"build"
|
|
31
40
|
],
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"build:module": "tsc --project tsconfig.json",
|
|
36
|
-
"clean": "rimraf build",
|
|
37
|
-
"lint": "eslint . --ext .ts",
|
|
38
|
-
"lint:fix": "run-s \"lint -- --fix\"",
|
|
39
|
-
"prepublishOnly": "run-s clean build",
|
|
40
|
-
"test": "jest --coverage",
|
|
41
|
-
"test:integration": "jest integration --coverage",
|
|
42
|
-
"test:unit": "jest unit --coverage",
|
|
43
|
-
"preversion": "run-s clean lint test:unit build"
|
|
44
|
-
},
|
|
45
|
-
"prettier": {
|
|
46
|
-
"printWidth": 100,
|
|
47
|
-
"semi": false,
|
|
48
|
-
"singleQuote": true,
|
|
49
|
-
"trailingComma": "none"
|
|
50
|
-
},
|
|
51
|
-
"jest": {
|
|
52
|
-
"collectCoverageFrom": [
|
|
53
|
-
"source/**/*.ts"
|
|
54
|
-
],
|
|
55
|
-
"coverageDirectory": "coverage",
|
|
56
|
-
"modulePathIgnorePatterns": [
|
|
57
|
-
"<rootDir>/build/"
|
|
58
|
-
],
|
|
59
|
-
"preset": "ts-jest",
|
|
60
|
-
"setupFiles": [
|
|
61
|
-
"dotenv/config"
|
|
62
|
-
],
|
|
63
|
-
"testEnvironment": "node",
|
|
64
|
-
"testMatch": [
|
|
65
|
-
"**/?(*.)+(spec|test).[jt]s?(x)"
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
"dependencies": {
|
|
69
|
-
"@types/lodash.chunk": "4.2.7",
|
|
70
|
-
"@types/lodash.frompairs": "4.0.7",
|
|
71
|
-
"@types/lodash.range": "3.2.7",
|
|
72
|
-
"@types/qs": "6.9.7",
|
|
73
|
-
"got": "11.8.2",
|
|
74
|
-
"lodash.chunk": "4.2.0",
|
|
75
|
-
"lodash.frompairs": "4.0.1",
|
|
76
|
-
"lodash.range": "3.2.0",
|
|
77
|
-
"p-queue": "6.6.2",
|
|
78
|
-
"qs": "6.11.0"
|
|
41
|
+
"volta": {
|
|
42
|
+
"node": "26.13.0",
|
|
43
|
+
"pnpm": "12.16.1"
|
|
79
44
|
},
|
|
80
45
|
"devDependencies": {
|
|
81
|
-
"@2bad/
|
|
82
|
-
"@
|
|
83
|
-
"@
|
|
84
|
-
"@
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"jest": "26.6.3",
|
|
94
|
-
"nock": "13.2.9",
|
|
95
|
-
"npm-run-all": "4.1.5",
|
|
96
|
-
"rimraf": "3.0.2",
|
|
97
|
-
"ts-jest": "26.5.5",
|
|
98
|
-
"typescript": "4.8.4"
|
|
46
|
+
"@2bad/axiom": "2.1.0",
|
|
47
|
+
"@2bad/tsconfig": "4.0.0",
|
|
48
|
+
"@arethetypeswrong/cli": "0.18.5",
|
|
49
|
+
"@types/node": "26.6.6",
|
|
50
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
51
|
+
"npm-run-all2": "9.0.4",
|
|
52
|
+
"oxfmt": "0.75.0",
|
|
53
|
+
"oxlint": "1.90.0",
|
|
54
|
+
"publint": "0.3.25",
|
|
55
|
+
"tsdown": "0.23.4",
|
|
56
|
+
"typescript": "7.0.2",
|
|
57
|
+
"vitest": "5.0.5"
|
|
99
58
|
},
|
|
100
|
-
"
|
|
101
|
-
"node": "
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=26"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsdown",
|
|
64
|
+
"check": "run-p check:**",
|
|
65
|
+
"check:code": "oxlint ./source",
|
|
66
|
+
"check:format": "oxfmt --check ./source",
|
|
67
|
+
"check:types": "tsc --noEmit",
|
|
68
|
+
"fix": "run-p fix:**",
|
|
69
|
+
"fix:code": "oxlint --fix ./source",
|
|
70
|
+
"fix:format": "oxfmt ./source",
|
|
71
|
+
"preversion": "run-s check test:unit build",
|
|
72
|
+
"test": "vitest run",
|
|
73
|
+
"test:integration": "vitest run integration --coverage",
|
|
74
|
+
"test:unit": "vitest run unit --coverage"
|
|
102
75
|
}
|
|
103
|
-
}
|
|
76
|
+
}
|
package/build/main/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/main/bitrix.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.Bitrix = void 0;
|
|
21
|
-
const client_1 = __importDefault(require("./client"));
|
|
22
|
-
const companies_1 = __importDefault(require("./services/companies"));
|
|
23
|
-
const contacts_1 = __importDefault(require("./services/contacts"));
|
|
24
|
-
const deals_1 = __importDefault(require("./services/deals"));
|
|
25
|
-
const leads_1 = __importDefault(require("./services/leads"));
|
|
26
|
-
const statuses_1 = __importDefault(require("./services/statuses"));
|
|
27
|
-
const users_1 = __importDefault(require("./services/users"));
|
|
28
|
-
/**
|
|
29
|
-
* Construct a Bitrix client with generic methods
|
|
30
|
-
* @param restURI REST endpoint, like a `https://hello.bitrix24.ua/rest` or an inbound webhook endpoint,
|
|
31
|
-
* like a `https://hello.bitrix24.ua/rest/1/WEBHOOK_TOKEN`.
|
|
32
|
-
* @param accessToken Bitrix application Access Token. Do not specify in case inbound webhook endpoint used.
|
|
33
|
-
* @param clientOptions an object that will overwrite underlying configuration for HTTP client,
|
|
34
|
-
* see `https://github.com/sindresorhus/got/blob/main/documentation/2-options.md`.
|
|
35
|
-
*/
|
|
36
|
-
const Bitrix = (restURI, accessToken, clientOptions) => {
|
|
37
|
-
const { call, batch, list } = (0, client_1.default)(restURI, accessToken, clientOptions);
|
|
38
|
-
return {
|
|
39
|
-
call,
|
|
40
|
-
batch,
|
|
41
|
-
list,
|
|
42
|
-
companies: (0, companies_1.default)({ call, list }),
|
|
43
|
-
contacts: (0, contacts_1.default)({ call, list }),
|
|
44
|
-
deals: (0, deals_1.default)({ call, list }),
|
|
45
|
-
leads: (0, leads_1.default)({ call, list }),
|
|
46
|
-
statuses: (0, statuses_1.default)({ call }),
|
|
47
|
-
users: (0, users_1.default)({ call })
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
exports.Bitrix = Bitrix;
|
|
51
|
-
exports.default = exports.Bitrix;
|
|
52
|
-
__exportStar(require("./methods"), exports);
|
|
53
|
-
__exportStar(require("./commands"), exports);
|
|
54
|
-
__exportStar(require("./services/common"), exports);
|
|
55
|
-
__exportStar(require("./services/companies/entities"), exports);
|
|
56
|
-
__exportStar(require("./services/contacts/entities"), exports);
|
|
57
|
-
__exportStar(require("./services/currencies/entities"), exports);
|
|
58
|
-
__exportStar(require("./services/deals/entities"), exports);
|
|
59
|
-
__exportStar(require("./services/leads/entities"), exports);
|
|
60
|
-
__exportStar(require("./services/statuses/entities"), exports);
|
|
61
|
-
__exportStar(require("./services/users/entities"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const bitrix_1 = __importDefault(require("./bitrix"));
|
|
30
|
-
const client = __importStar(require("./client"));
|
|
31
|
-
describe('Bitrix', () => {
|
|
32
|
-
it('should init', () => {
|
|
33
|
-
expect(() => (0, bitrix_1.default)('https://test.com', 'test_token')).not.toThrow();
|
|
34
|
-
});
|
|
35
|
-
it('should pass endpoint and access token to the client', () => {
|
|
36
|
-
const SpiedClient = jest.spyOn(client, 'default');
|
|
37
|
-
(0, bitrix_1.default)('https://test.com', 'test_token');
|
|
38
|
-
expect(SpiedClient.mock.calls).toMatchSnapshot();
|
|
39
|
-
});
|
|
40
|
-
it('should expose API methods', () => {
|
|
41
|
-
const bitrix = (0, bitrix_1.default)('https://test.com', 'test_token');
|
|
42
|
-
expect(bitrix).toMatchSnapshot();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,70 +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 got_1 = __importDefault(require("got"));
|
|
7
|
-
const nock_1 = __importDefault(require("nock"));
|
|
8
|
-
const p_queue_1 = __importDefault(require("p-queue"));
|
|
9
|
-
const methods_1 = require("../methods");
|
|
10
|
-
const index_1 = __importDefault(require("./index"));
|
|
11
|
-
const TEST_URI = 'https://test.com/rest';
|
|
12
|
-
const TEST_ACCESS_TOKEN = 'test_access_token';
|
|
13
|
-
const RESPONSE_200 = 200;
|
|
14
|
-
const spiedQueueAdd = jest.spyOn(p_queue_1.default.prototype, 'add');
|
|
15
|
-
const client = (0, index_1.default)(TEST_URI, TEST_ACCESS_TOKEN);
|
|
16
|
-
describe('Client', () => {
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
spiedQueueAdd.mockClear();
|
|
19
|
-
});
|
|
20
|
-
it('should init', () => {
|
|
21
|
-
expect(() => (0, index_1.default)(TEST_URI, TEST_ACCESS_TOKEN)).not.toThrow();
|
|
22
|
-
});
|
|
23
|
-
it('should extend `Got` instance with a specified parameters', () => {
|
|
24
|
-
const spiedGotExtend = jest.spyOn(got_1.default, 'extend');
|
|
25
|
-
(0, index_1.default)('https://test.com', 'test_token', { https: { rejectUnauthorized: false } });
|
|
26
|
-
expect(spiedGotExtend.mock.calls).toMatchSnapshot();
|
|
27
|
-
});
|
|
28
|
-
it('should expose API methods', () => {
|
|
29
|
-
expect(client).toMatchSnapshot();
|
|
30
|
-
});
|
|
31
|
-
describe('`call`', () => {
|
|
32
|
-
// @todo restore test when issue is resolved (https://github.com/nock/nock/issues/1832)
|
|
33
|
-
it.skip('should add to queue', async () => {
|
|
34
|
-
const payload = {};
|
|
35
|
-
const method = methods_1.Method.CRM_DEAL_LIST;
|
|
36
|
-
(0, nock_1.default)(TEST_URI)
|
|
37
|
-
.get(`/${method}?access_token=${TEST_ACCESS_TOKEN}`)
|
|
38
|
-
.twice()
|
|
39
|
-
.reply(RESPONSE_200, payload);
|
|
40
|
-
await client.call(method, {});
|
|
41
|
-
await client.call(method, {});
|
|
42
|
-
expect(spiedQueueAdd.mock.calls).toMatchSnapshot();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe('`batch`', () => {
|
|
46
|
-
// @todo restore test when issue is resolved (https://github.com/nock/nock/issues/1832)
|
|
47
|
-
it.skip('should add to queue', async () => {
|
|
48
|
-
const payload = {
|
|
49
|
-
result: {
|
|
50
|
-
result: ['done'],
|
|
51
|
-
result_error: []
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const commands = [
|
|
55
|
-
{ method: methods_1.Method.CRM_DEAL_GET },
|
|
56
|
-
{ method: methods_1.Method.CRM_DEAL_LIST }
|
|
57
|
-
];
|
|
58
|
-
(0, nock_1.default)(TEST_URI)
|
|
59
|
-
// @todo We'd want to use `query` object here as it is much more readable, but nock for some reason
|
|
60
|
-
// fails to match request when it contains `cmd[someName]`. The issue definitely connected
|
|
61
|
-
// to the `[]`, since it does not appear when only one bracket present
|
|
62
|
-
.get(`/${methods_1.Method.BATCH}?cmd%5B0%5D=${commands[0].method}&access_token=${TEST_ACCESS_TOKEN}`)
|
|
63
|
-
.reply(RESPONSE_200, payload)
|
|
64
|
-
.get(`/${methods_1.Method.BATCH}?cmd%5B0%5D=${commands[1].method}&access_token=${TEST_ACCESS_TOKEN}`)
|
|
65
|
-
.reply(RESPONSE_200, payload);
|
|
66
|
-
await client.batch(commands, 1);
|
|
67
|
-
expect(spiedQueueAdd.mock.calls).toMatchSnapshot();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Got can't merge `query` option with other queries if they are string. But that hook can.
|
|
5
|
-
*/
|
|
6
|
-
exports.default = (accessToken) => (options) => {
|
|
7
|
-
if (!accessToken)
|
|
8
|
-
return;
|
|
9
|
-
if (!options.path)
|
|
10
|
-
return;
|
|
11
|
-
const hasQuery = options.path.includes('?');
|
|
12
|
-
options.path = `${options.path}${hasQuery ? '&' : '?'}access_token=${accessToken}`;
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,31 +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 got_1 = __importDefault(require("got"));
|
|
7
|
-
const addAccessToken_1 = __importDefault(require("./addAccessToken"));
|
|
8
|
-
const token = 'mock_token';
|
|
9
|
-
const merge = got_1.default.mergeOptions;
|
|
10
|
-
describe('Client `addAccessToken` hook', () => {
|
|
11
|
-
it('should add access token to URL without a query', () => {
|
|
12
|
-
const options = merge({ path: 'test', responseType: 'json' });
|
|
13
|
-
(0, addAccessToken_1.default)(token)(options);
|
|
14
|
-
expect(options.path).toBe(`test?access_token=${token}`);
|
|
15
|
-
});
|
|
16
|
-
it('should add access token to URL with a query', () => {
|
|
17
|
-
const options = merge({ path: 'test?value=1', responseType: 'json' });
|
|
18
|
-
(0, addAccessToken_1.default)(token)(options);
|
|
19
|
-
expect(options.path).toBe(`test?value=1&access_token=${token}`);
|
|
20
|
-
});
|
|
21
|
-
it('should not add access token when it is undefined', () => {
|
|
22
|
-
const options = merge({ path: 'test', responseType: 'json' });
|
|
23
|
-
(0, addAccessToken_1.default)()(options);
|
|
24
|
-
expect(options.path).toBe('test');
|
|
25
|
-
});
|
|
26
|
-
it('should not add access token when URL is undefined', () => {
|
|
27
|
-
const options = merge({ path: undefined, responseType: 'json' });
|
|
28
|
-
(0, addAccessToken_1.default)(token)(options);
|
|
29
|
-
expect(options.path).toBe(undefined);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,15 +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.ru/rest` or an inbound webhook endpoint,
|
|
5
|
-
* like a `https://hello.bitrix24.ru/rest/1/WEBHOOK_TOKEN`.
|
|
6
|
-
* @param accessToken Bitrix application Access Token. Do not specify in case inbound webhook endpoint used.
|
|
7
|
-
* @param options 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
|
-
declare const _default: (restURI: string, accessToken?: string, options?: ExtendOptions) => {
|
|
11
|
-
call: import("./methods/call").Call;
|
|
12
|
-
batch: import("./methods/batch").Batch;
|
|
13
|
-
list: import("./methods/list").List;
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|
|
@@ -1,53 +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 got_1 = __importDefault(require("got"));
|
|
7
|
-
const p_queue_1 = __importDefault(require("p-queue"));
|
|
8
|
-
const addAccessToken_1 = __importDefault(require("./hooks/addAccessToken"));
|
|
9
|
-
const batch_1 = __importDefault(require("./methods/batch"));
|
|
10
|
-
const call_1 = __importDefault(require("./methods/call"));
|
|
11
|
-
const list_1 = __importDefault(require("./methods/list"));
|
|
12
|
-
const BITRIX_API_RATE_LIMIT = 2;
|
|
13
|
-
const BITRIX_API_RATE_INTERVAL = 1000; // 1 second
|
|
14
|
-
/**
|
|
15
|
-
* Construct a Bitrix client with generic methods
|
|
16
|
-
* @param restURI REST endpoint, like a `https://hello.bitrix24.ru/rest` or an inbound webhook endpoint,
|
|
17
|
-
* like a `https://hello.bitrix24.ru/rest/1/WEBHOOK_TOKEN`.
|
|
18
|
-
* @param accessToken Bitrix application Access Token. Do not specify in case inbound webhook endpoint used.
|
|
19
|
-
* @param options an object that will overwrite underlying configuration for HTTP client,
|
|
20
|
-
* see `https://github.com/sindresorhus/got/blob/main/documentation/2-options.md`.
|
|
21
|
-
*/
|
|
22
|
-
exports.default = (restURI, accessToken, options) => {
|
|
23
|
-
const client = got_1.default.extend({
|
|
24
|
-
prefixUrl: restURI,
|
|
25
|
-
headers: {
|
|
26
|
-
'user-agent': '@2bad/bitrix'
|
|
27
|
-
},
|
|
28
|
-
responseType: 'json',
|
|
29
|
-
hooks: {
|
|
30
|
-
beforeRequest: [
|
|
31
|
-
(0, addAccessToken_1.default)(accessToken)
|
|
32
|
-
]
|
|
33
|
-
},
|
|
34
|
-
...options !== null && options !== void 0 ? options : {}
|
|
35
|
-
});
|
|
36
|
-
const queue = new p_queue_1.default({
|
|
37
|
-
intervalCap: BITRIX_API_RATE_LIMIT,
|
|
38
|
-
interval: BITRIX_API_RATE_INTERVAL
|
|
39
|
-
});
|
|
40
|
-
const queuedGet = (...args) => queue.add(() => client.get(...args));
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
|
-
// @ts-expect-error @todo remove after issue is resolved (https://github.com/sindresorhus/got/issues/954)
|
|
43
|
-
const call = (0, call_1.default)({ get: queuedGet });
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
45
|
-
// @ts-expect-error @todo remove after issue is resolved (https://github.com/sindresorhus/got/issues/954)
|
|
46
|
-
const batch = (0, batch_1.default)({ get: queuedGet });
|
|
47
|
-
const list = (0, list_1.default)({ call, batch });
|
|
48
|
-
return {
|
|
49
|
-
call,
|
|
50
|
-
batch,
|
|
51
|
-
list
|
|
52
|
-
};
|
|
53
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import got from 'got';
|
|
2
|
-
import { Commands } from '../../commands';
|
|
3
|
-
import { Method, MethodPayloadType } from '../../methods';
|
|
4
|
-
import { BatchPayload } from '../../payloads';
|
|
5
|
-
export declare const MAX_COMMANDS_PER_BATCH = 50;
|
|
6
|
-
/**
|
|
7
|
-
* Split any number of commands into the chunks with max commands per batch in each chunk
|
|
8
|
-
*/
|
|
9
|
-
export declare const chunkCommands: <C extends Commands>(commands: C, size?: number) => readonly C[];
|
|
10
|
-
/**
|
|
11
|
-
* Prepares list of commands to be used in requests to the Bitrix
|
|
12
|
-
* @note We could avoid that function... if only Bitrix API would support posting of the batch commands as
|
|
13
|
-
* plain objects, like it does with other methods. Instead, it should be a dict or array of string queries
|
|
14
|
-
*/
|
|
15
|
-
export declare const prepareCommandsQueries: <C extends Commands, R = { [K in keyof C]: string; }>(commands: C) => R;
|
|
16
|
-
/**
|
|
17
|
-
* Merges list of batch responses into a single batch
|
|
18
|
-
* @todo Generics inference is complicated here and might be not super accurate
|
|
19
|
-
*/
|
|
20
|
-
export declare const mergeBatchPayloads: <B extends BatchPayload<unknown>, P = B extends BatchPayload<infer U> ? U : never>(payloads: readonly B[]) => BatchPayload<P>;
|
|
21
|
-
export declare type CommandsPayloads<C extends Commands, CM = {
|
|
22
|
-
[K in keyof C]: C[K] extends {
|
|
23
|
-
readonly method: infer M;
|
|
24
|
-
} ? M : never;
|
|
25
|
-
}> = {
|
|
26
|
-
[K in keyof CM]: MethodPayloadType<CM[K] extends Method ? CM[K] : never>;
|
|
27
|
-
};
|
|
28
|
-
export declare type Batch = <C extends Commands, P = CommandsPayloads<C>>(commands: C, commandsPerRequest?: number) => Promise<BatchPayload<P>>;
|
|
29
|
-
declare type Dependencies = {
|
|
30
|
-
readonly get: typeof got.get;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Dispatches a batch request with specified commands. Will fill figure out payload type based on the Methods.
|
|
34
|
-
* Supports unlimited number of commands. If they do exceed max amount of commands per batch, will dispatch
|
|
35
|
-
* multiple request and merge result into single batch payload
|
|
36
|
-
* @todo For now due to issues with types it won't check `params` of command, so any Method can be used
|
|
37
|
-
* with any (even wrong) params
|
|
38
|
-
*/
|
|
39
|
-
declare const _default: ({ get }: Dependencies) => Batch;
|
|
40
|
-
export default _default;
|