@pliancy/salesforce-cpq-sdk 3.26.0 → 4.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.
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Connection } from 'jsforce';
|
|
2
|
-
import { AmendmentQuote, Contract, ContractEntity, ContractQuery } from './contract.types';
|
|
1
|
+
import { Connection, QueryCondition, Schema } from 'jsforce';
|
|
2
|
+
import { AmendmentQuote, Contract, ContractEntity, ContractQuery, ContractStatus } from './contract.types';
|
|
3
3
|
import { Base } from '../base/base';
|
|
4
4
|
export declare class Contracts extends Base<ContractEntity> {
|
|
5
5
|
private readonly connection;
|
|
6
6
|
private readonly client;
|
|
7
7
|
constructor(connection: Connection);
|
|
8
8
|
getById(id: string): Promise<Contract | null>;
|
|
9
|
-
|
|
9
|
+
getLatestByStatusForAccount(accountId: string, status: ContractStatus, options?: ContractQuery): Promise<Contract | undefined>;
|
|
10
10
|
getDraftsByBillingPeriod(accountId: string, start: string, end: string): Promise<Contract[]>;
|
|
11
|
+
update(id: string, update: Partial<Omit<Contract, 'Id'>>, options?: QueryCondition<Schema, ContractEntity>): Promise<import("jsforce").SaveResult>;
|
|
11
12
|
/**
|
|
12
13
|
* Creates an amendment quote based on the provided contract ID.
|
|
13
14
|
*
|
|
@@ -13,17 +13,18 @@ class Contracts extends base_1.Base {
|
|
|
13
13
|
async getById(id) {
|
|
14
14
|
return this.client.findOne({ Id: id });
|
|
15
15
|
}
|
|
16
|
-
async
|
|
17
|
-
|
|
16
|
+
async getLatestByStatusForAccount(accountId, status, options) {
|
|
17
|
+
var _a;
|
|
18
|
+
const query = this.buildQuery({ AccountId: accountId, Status: status }, options);
|
|
18
19
|
const contracts = (await this.client.find(query));
|
|
19
20
|
if (!(contracts && contracts.length))
|
|
20
21
|
return undefined;
|
|
21
22
|
// If there's only one contract, return it
|
|
22
|
-
if (contracts.length === 1)
|
|
23
|
+
if (contracts.length === 1 && ((_a = contracts[0]) === null || _a === void 0 ? void 0 : _a.Status) === status)
|
|
23
24
|
return contracts.shift();
|
|
24
25
|
contracts.sort((a, b) => {
|
|
25
|
-
const aTime = new Date(a.
|
|
26
|
-
const bTime = new Date(b.
|
|
26
|
+
const aTime = new Date(a.CreatedDate).getTime();
|
|
27
|
+
const bTime = new Date(b.CreatedDate).getTime();
|
|
27
28
|
return bTime - aTime;
|
|
28
29
|
});
|
|
29
30
|
// Return the first in the array
|
|
@@ -37,6 +38,10 @@ class Contracts extends base_1.Base {
|
|
|
37
38
|
EndDate: { $lte: new jsforce_1.SfDate(end) },
|
|
38
39
|
});
|
|
39
40
|
}
|
|
41
|
+
async update(id, update, options) {
|
|
42
|
+
const query = this.buildQuery({ Id: id, ...update }, options);
|
|
43
|
+
return this.client.update(query);
|
|
44
|
+
}
|
|
40
45
|
/**
|
|
41
46
|
* Creates an amendment quote based on the provided contract ID.
|
|
42
47
|
*
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pliancy/salesforce-cpq-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Salesforce CPQ SDK for Node.js",
|
|
7
7
|
"private": false,
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"jsforce": "3.
|
|
9
|
+
"jsforce": "3.10.7",
|
|
10
10
|
"tslib": "2.8.1"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"@digitalroute/cz-conventional-changelog-for-jira": "8.0.1",
|
|
21
21
|
"@pliancy/eslint-config-ts": "1.1.1",
|
|
22
22
|
"@pliancy/semantic-release-config-npm": "2.2.0",
|
|
23
|
-
"@types/jest": "
|
|
24
|
-
"@types/node": "22.
|
|
23
|
+
"@types/jest": "30.0.0",
|
|
24
|
+
"@types/node": "22.18.1",
|
|
25
25
|
"commitizen": "4.3.1",
|
|
26
26
|
"cz-conventional-changelog": "3.3.0",
|
|
27
27
|
"husky": "9.1.7",
|
|
28
|
-
"jest": "
|
|
29
|
-
"npm-run-all2": "
|
|
28
|
+
"jest": "30.1.3",
|
|
29
|
+
"npm-run-all2": "8.0.4",
|
|
30
30
|
"pinst": "3.0.0",
|
|
31
31
|
"rimraf": "6.0.1",
|
|
32
|
-
"ts-jest": "29.
|
|
33
|
-
"typescript": "5.
|
|
32
|
+
"ts-jest": "29.4.1",
|
|
33
|
+
"typescript": "5.9.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "run-s -l clean test tsc",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"email": "justin.mcmahon@pliancy.com"
|
|
54
54
|
},
|
|
55
55
|
"volta": {
|
|
56
|
-
"node": "22.
|
|
56
|
+
"node": "22.19.0",
|
|
57
57
|
"yarn": "1.22.22"
|
|
58
58
|
},
|
|
59
59
|
"config": {
|