@pliancy/salesforce-cpq-sdk 3.7.0 → 3.9.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/dist/lib/cpq.d.ts CHANGED
@@ -7,6 +7,7 @@ import { Subscriptions } from './subscriptions/subscriptions';
7
7
  import { Quotes } from './quotes/quotes';
8
8
  import { Orders } from './orders/orders';
9
9
  import { OrderItems } from './orders/order-items/order-items';
10
+ import { PriceBooks } from './price-books/price-books';
10
11
  export declare class Cpq {
11
12
  private readonly config;
12
13
  accounts: Accounts;
@@ -14,6 +15,7 @@ export declare class Cpq {
14
15
  contracts: Contracts;
15
16
  orders: Orders;
16
17
  orderItems: OrderItems;
18
+ priceBooks: PriceBooks;
17
19
  products: Products;
18
20
  quotes: Quotes;
19
21
  subscriptions: Subscriptions;
package/dist/lib/cpq.js CHANGED
@@ -9,6 +9,7 @@ const subscriptions_1 = require("./subscriptions/subscriptions");
9
9
  const quotes_1 = require("./quotes/quotes");
10
10
  const orders_1 = require("./orders/orders");
11
11
  const order_items_1 = require("./orders/order-items/order-items");
12
+ const price_books_1 = require("./price-books/price-books");
12
13
  class Cpq {
13
14
  constructor(config) {
14
15
  this.config = config;
@@ -17,6 +18,7 @@ class Cpq {
17
18
  this.contracts = new contracts_1.Contracts(this.connection);
18
19
  this.orders = new orders_1.Orders(this.connection);
19
20
  this.orderItems = new order_items_1.OrderItems(this.connection);
21
+ this.priceBooks = new price_books_1.PriceBooks(this.connection);
20
22
  this.products = new products_1.Products(this.connection);
21
23
  this.subscriptions = new subscriptions_1.Subscriptions(this.connection);
22
24
  this.quotes = new quotes_1.Quotes(this.connection);
@@ -0,0 +1,8 @@
1
+ import { Connection } from 'jsforce';
2
+ import { PriceBookEntry } from './price-book-entries.types';
3
+ export declare class PriceBookEntries {
4
+ private readonly connection;
5
+ private readonly client;
6
+ constructor(connection: Connection);
7
+ getByPriceBookId(id: string): Promise<PriceBookEntry[]>;
8
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PriceBookEntries = void 0;
4
+ class PriceBookEntries {
5
+ constructor(connection) {
6
+ this.connection = connection;
7
+ this.client = this.connection.sobject('PricebookEntry');
8
+ }
9
+ async getByPriceBookId(id) {
10
+ return this.client.find({ Pricebook2Id: id, IsActive: true });
11
+ }
12
+ }
13
+ exports.PriceBookEntries = PriceBookEntries;
@@ -0,0 +1,18 @@
1
+ export interface PriceBookEntry {
2
+ [index: string]: any;
3
+ Id: string;
4
+ Pricebook2Id: string;
5
+ Name: string;
6
+ Product2Id: string;
7
+ UnitPrice: number;
8
+ IsActive: boolean;
9
+ UseStandardPrice: boolean;
10
+ CreatedDate: string;
11
+ CreatedById: string;
12
+ LastModifiedDate: string;
13
+ LastModifiedById: string;
14
+ SystemModstamp: string;
15
+ ProductCode: string;
16
+ IsDeleted: boolean;
17
+ IsArchived: false;
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,21 @@
1
+ import { PriceBookEntry } from './entries/price-book-entries.types';
2
+ export interface PriceBook {
3
+ [index: string]: any;
4
+ Id: string;
5
+ IsDeleted: boolean;
6
+ Name: string;
7
+ CreatedDate: string;
8
+ CreatedById: string;
9
+ LastModifiedDate: string;
10
+ LastModifiedById: string;
11
+ SystemModstamp: string;
12
+ LastViewedDate: string;
13
+ LastReferencedDate: string;
14
+ IsActive: boolean;
15
+ IsArchived: boolean;
16
+ Description?: string;
17
+ IsStandard: boolean;
18
+ }
19
+ export type FullPriceBook = PriceBook & {
20
+ entries: PriceBookEntry[];
21
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { Connection } from 'jsforce';
2
+ import { FullPriceBook } from './price-book.types';
3
+ export declare class PriceBooks {
4
+ private readonly connection;
5
+ private readonly client;
6
+ private readonly entries;
7
+ constructor(connection: Connection);
8
+ getByName(name: string): Promise<FullPriceBook | null>;
9
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PriceBooks = void 0;
4
+ const price_book_entries_1 = require("./entries/price-book-entries");
5
+ class PriceBooks {
6
+ constructor(connection) {
7
+ this.connection = connection;
8
+ this.client = this.connection.sobject('Pricebook2');
9
+ this.entries = new price_book_entries_1.PriceBookEntries(this.connection);
10
+ }
11
+ async getByName(name) {
12
+ const pb = (await this.client.findOne({ Name: name }));
13
+ if (!pb)
14
+ return null;
15
+ pb.entries = await this.entries.getByPriceBookId(pb.Id);
16
+ return pb;
17
+ }
18
+ }
19
+ exports.PriceBooks = PriceBooks;
@@ -76,14 +76,21 @@ class Quotes {
76
76
  return this.client.update(query);
77
77
  }
78
78
  async submitAndApprove(quoteId, comments = '') {
79
+ var _a;
79
80
  try {
80
81
  const { ApprovalProcess } = require('jsforce/lib/process');
81
82
  const approvalProcess = new ApprovalProcess(this.connection);
82
83
  const sResult = (await approvalProcess.submit(quoteId, comments, {
83
84
  skipEntryCriteria: true,
84
85
  }));
85
- if ((sResult === null || sResult === void 0 ? void 0 : sResult.newWorkItemIds) && (sResult === null || sResult === void 0 ? void 0 : sResult.newWorkItemIds.length)) {
86
- const id = sResult.newWorkItemIds[0];
86
+ // JsForce types say the field is 'newWorkItemIds', but the actual result is 'newWorkitemIds'.
87
+ // Look for the actual API return first, then what the types say it should be, default
88
+ // to empty array.
89
+ const workItemIds = sResult.hasOwnProperty('newWorkitemIds')
90
+ ? sResult['newWorkitemIds']
91
+ : (_a = sResult === null || sResult === void 0 ? void 0 : sResult.newWorkItemIds) !== null && _a !== void 0 ? _a : [];
92
+ if (workItemIds && workItemIds.length) {
93
+ const id = workItemIds[0];
87
94
  if (!id)
88
95
  return { success: false, errors: ['No workItemId returned'] };
89
96
  await approvalProcess.approve(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pliancy/salesforce-cpq-sdk",
3
- "version": "3.7.0",
3
+ "version": "3.9.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "description": "Salesforce CPQ SDK for Node.js",