@pliancy/salesforce-cpq-sdk 1.13.0 → 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.
@@ -100,6 +100,17 @@ export type QuoteWithLineItems = Quote & {
100
100
  };
101
101
  export type UpdateQuoteLine = Pick<QuoteLine, 'Id' | 'SBQQ__Quantity__c'>;
102
102
  export type UpdateQuoteLinesRequest = UpdateQuoteLine[];
103
- export type ApprovalStatus = 'Approved' | 'Rejected' | 'Pending' | 'Approval Not Required' | 'Required : Not Sent for Approval';
103
+ export declare enum ApprovalStatus {
104
+ APPROVED = "Approved",
105
+ REJECTED = "Rejected",
106
+ PENDING = "Pending",
107
+ REQUIRED = "Required : Not Sent for Approval",
108
+ NOT_REQUIRED = "Approval Not Required"
109
+ }
104
110
  export type QuoteQuery = QueryCondition<Schema, 'SBQQ__Quote__c'>;
105
111
  export type UpdateQuoteQuery = SObjectUpdateRecord<Schema, 'SBQQ__Quote__c'>;
112
+ export interface ApprovalProcessRequest {
113
+ success: boolean;
114
+ errors?: string[];
115
+ newWorkItemIds?: string[];
116
+ }
@@ -1,2 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApprovalStatus = void 0;
4
+ var ApprovalStatus;
5
+ (function (ApprovalStatus) {
6
+ ApprovalStatus["APPROVED"] = "Approved";
7
+ ApprovalStatus["REJECTED"] = "Rejected";
8
+ ApprovalStatus["PENDING"] = "Pending";
9
+ ApprovalStatus["REQUIRED"] = "Required : Not Sent for Approval";
10
+ ApprovalStatus["NOT_REQUIRED"] = "Approval Not Required";
11
+ })(ApprovalStatus || (exports.ApprovalStatus = ApprovalStatus = {}));
@@ -12,6 +12,21 @@ export declare class Quotes {
12
12
  update(quoteId: string, query: Partial<Omit<Quote, 'Id'>>): Promise<SaveResult>;
13
13
  updateLineItemQuantities(lineItems: UpdateQuoteLine[]): Promise<SaveResult[]>;
14
14
  order(quoteId: string, options?: UpdateQuoteQuery): Promise<SaveResult>;
15
- approve(quoteId: string): Promise<SaveResult>;
15
+ submitAndApprove(quoteId: string, comments?: string): Promise<{
16
+ success: boolean;
17
+ workItemId: string;
18
+ errors?: undefined;
19
+ error?: undefined;
20
+ } | {
21
+ success: boolean;
22
+ errors: string[] | undefined;
23
+ workItemId?: undefined;
24
+ error?: undefined;
25
+ } | {
26
+ success: boolean;
27
+ error: any;
28
+ workItemId?: undefined;
29
+ errors?: undefined;
30
+ }>;
16
31
  private buildQuery;
17
32
  }
@@ -66,9 +66,27 @@ class Quotes {
66
66
  const query = this.buildQuery({ Id: quoteId, SBQQ__Ordered__c: true }, options);
67
67
  return this.client.update(query);
68
68
  }
69
- async approve(quoteId) {
70
- await this.connection.process.approval.submit(quoteId);
71
- return this.client.update({ Id: quoteId, ApprovalStatus__c: 'Approved' });
69
+ async submitAndApprove(quoteId, comments = '') {
70
+ try {
71
+ const { ApprovalProcess } = require('jsforce/lib/process');
72
+ const approvalProcess = new ApprovalProcess(this.connection);
73
+ const submission = (await approvalProcess.submit(quoteId, comments, {
74
+ skipEntryCriteria: true,
75
+ }));
76
+ if ((submission === null || submission === void 0 ? void 0 : submission.newWorkItemIds) && (submission === null || submission === void 0 ? void 0 : submission.newWorkItemIds.length)) {
77
+ const workItemId = submission.newWorkItemIds[0];
78
+ if (!workItemId)
79
+ return { success: false, errors: ['No workItemId returned'] };
80
+ await approvalProcess.approve(workItemId);
81
+ return { success: true, workItemId };
82
+ }
83
+ else {
84
+ return { success: false, errors: submission.errors };
85
+ }
86
+ }
87
+ catch (error) {
88
+ return { success: false, error: error.message };
89
+ }
72
90
  }
73
91
  buildQuery(base, options) {
74
92
  const query = { ...base };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@pliancy/salesforce-cpq-sdk",
3
- "version": "1.13.0",
3
+ "version": "3.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.4.1",
9
+ "jsforce": "3.6.3",
10
10
  "tslib": "2.6.2"
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": "29.5.13",
24
- "@types/node": "22.5.5",
25
- "commitizen": "4.3.0",
23
+ "@types/jest": "29.5.14",
24
+ "@types/node": "22.10.2",
25
+ "commitizen": "4.3.1",
26
26
  "cz-conventional-changelog": "3.3.0",
27
- "husky": "9.1.6",
27
+ "husky": "9.1.7",
28
28
  "jest": "29.7.0",
29
- "npm-run-all2": "5.0.2",
29
+ "npm-run-all2": "7.0.2",
30
30
  "pinst": "3.0.0",
31
31
  "rimraf": "6.0.1",
32
32
  "ts-jest": "29.2.5",
33
- "typescript": "5.6.2"
33
+ "typescript": "5.7.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.9.0",
56
+ "node": "22.12.0",
57
57
  "yarn": "1.22.21"
58
58
  },
59
59
  "config": {