@pliancy/salesforce-cpq-sdk 3.13.0 → 3.15.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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SaveResult, SaveError } from 'jsforce';
1
2
  export { Cpq } from './lib/cpq';
2
3
  export * from './lib/accounts/accounts';
3
4
  export * from './lib/accounts/account.types';
@@ -15,3 +16,5 @@ export * from './lib/orders/orders';
15
16
  export * from './lib/orders/order.types';
16
17
  export * from './lib/orders/order-items/order-items';
17
18
  export * from './lib/orders/order-items/order-item.types';
19
+ export * from './lib/custom/custom';
20
+ export { SaveResult, SaveError };
package/dist/index.js CHANGED
@@ -33,3 +33,4 @@ __exportStar(require("./lib/orders/orders"), exports);
33
33
  __exportStar(require("./lib/orders/order.types"), exports);
34
34
  __exportStar(require("./lib/orders/order-items/order-items"), exports);
35
35
  __exportStar(require("./lib/orders/order-items/order-item.types"), exports);
36
+ __exportStar(require("./lib/custom/custom"), exports);
@@ -1,4 +1,8 @@
1
1
  import { Address, QueryCondition, Schema } from 'jsforce';
2
+ import { Quote } from '../quotes/quote.types';
3
+ import { Product } from '../products/product.types';
4
+ import { PriceBookEntry } from '../price-books/entries/price-book-entries.types';
5
+ import { QuoteLine } from '../quotes/quote-lines/quote-line.types';
2
6
  export interface Contract {
3
7
  [index: string]: any;
4
8
  Id: string;
@@ -84,6 +88,61 @@ export interface Contract {
84
88
  SBQQ__ActiveContract__c: number;
85
89
  SBQQ__OpportunityPricebookId__c: string;
86
90
  }
91
+ export interface NestedContractAmendmentResponseObject {
92
+ attributes: {
93
+ type: 'Account' | 'User' | 'Pricebook2' | 'Opportunity';
94
+ url: string;
95
+ };
96
+ Id: string;
97
+ }
98
+ export interface AmendmentQuoteLine {
99
+ record: QuoteLine & {
100
+ SBQQ__Product__c: string;
101
+ SBQQ__Product__r: Product & {
102
+ PricebookEntries: {
103
+ records: PriceBookEntry[];
104
+ };
105
+ }[];
106
+ };
107
+ }
108
+ export interface ContractAmendmentResponse {
109
+ record: Quote & {
110
+ SBQQ__Account__r: NestedContractAmendmentResponseObject & {
111
+ Name: string;
112
+ SBQQ__RenewalModel__c: string;
113
+ SBQQ__RenewalPricingMethod__c: string;
114
+ };
115
+ SBQQ__MasterEvergreenContract__r: NestedContractAmendmentResponseObject & {
116
+ ContractNumber: string;
117
+ };
118
+ SBQQ__SalesRep__r: NestedContractAmendmentResponseObject & {
119
+ Name: string;
120
+ };
121
+ SBQQ__PriceBook__r: NestedContractAmendmentResponseObject & {
122
+ Name: string;
123
+ };
124
+ SBQQ__Opportunity2__r: NestedContractAmendmentResponseObject & {
125
+ SBQQ__PrimaryQuote__c: string;
126
+ Pricebook2Id: string;
127
+ AccountId: string;
128
+ };
129
+ };
130
+ lineItems: AmendmentQuoteLine[];
131
+ lineItemGroups: string[];
132
+ isPartial: boolean;
133
+ hasMultiSegmentLines: boolean;
134
+ channelDiscountsOffList: boolean;
135
+ calculationRequired: boolean;
136
+ applyPartnerDiscountFirst: boolean;
137
+ applyAdditionalDiscountLast: boolean;
138
+ }
139
+ export interface AmendmentQuote extends Quote {
140
+ lineItems: (QuoteLine & {
141
+ PricebookEntries: {
142
+ records: PriceBookEntry[];
143
+ };
144
+ })[];
145
+ }
87
146
  export type ContractStatus = 'Draft' | 'Activated' | 'In Approval Process';
88
147
  export declare const ContractsCollection = "Contract";
89
148
  export type ContractEntity = typeof ContractsCollection;
@@ -1,5 +1,5 @@
1
1
  import { Connection } from 'jsforce';
2
- import { Contract, ContractQuery, ContractEntity } from './contract.types';
2
+ import { Contract, ContractQuery, ContractEntity, AmendmentQuote } from './contract.types';
3
3
  import { Base } from '../base/base';
4
4
  export declare class Contracts extends Base<ContractEntity> {
5
5
  private readonly connection;
@@ -8,4 +8,7 @@ export declare class Contracts extends Base<ContractEntity> {
8
8
  getById(id: string): Promise<Contract | null>;
9
9
  getLatestActivatedByAccountId(id: string, options?: ContractQuery): Promise<Contract | undefined>;
10
10
  getDraftsByBillingPeriod(accountId: string, start: string, end: string): Promise<Contract[]>;
11
+ createAmendmentQuote(contractId: string, body?: Object, options?: {
12
+ headers?: any;
13
+ }): Promise<AmendmentQuote>;
11
14
  }
@@ -37,5 +37,20 @@ class Contracts extends base_1.Base {
37
37
  EndDate: { $lte: new jsforce_1.SfDate(end) },
38
38
  });
39
39
  }
40
+ async createAmendmentQuote(contractId, body, options = {}) {
41
+ const res = await this.connection.apex.patch(`/SBQQ/ServiceRouter?loader=SBQQ.ContractManipulationAPI.ContractAmender&uid=${contractId}`, body, options);
42
+ // return normalized AmendmentQuote
43
+ return {
44
+ ...res.record,
45
+ lineItems: res.record.lineItems.map((l) => ({
46
+ ...l.record,
47
+ SBQQ__Product__r: {
48
+ PricebookEntries: l.record.SBQQ__Product__r.PricebookEntries.records.map((r) => ({
49
+ ...r.record,
50
+ })),
51
+ },
52
+ })),
53
+ };
54
+ }
40
55
  }
41
56
  exports.Contracts = Contracts;
package/dist/lib/cpq.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Accounts } from './accounts/accounts';
2
2
  import { CpqConfig } from './cpq.types';
3
- import { Connection } from 'jsforce';
3
+ import { Connection, Record } from 'jsforce';
4
4
  import { Contracts } from './contracts/contracts';
5
5
  import { Products } from './products/products';
6
6
  import { Subscriptions } from './subscriptions/subscriptions';
@@ -8,6 +8,7 @@ import { Quotes } from './quotes/quotes';
8
8
  import { Orders } from './orders/orders';
9
9
  import { OrderItems } from './orders/order-items/order-items';
10
10
  import { PriceBooks } from './price-books/price-books';
11
+ import { CustomCollection } from './custom/custom';
11
12
  export declare class Cpq {
12
13
  private readonly config;
13
14
  accounts: Accounts;
@@ -21,4 +22,5 @@ export declare class Cpq {
21
22
  subscriptions: Subscriptions;
22
23
  constructor(config: CpqConfig);
23
24
  authorize(): Promise<void>;
25
+ createCustomApi<T extends Record = Record>(collection: string): CustomCollection<T>;
24
26
  }
package/dist/lib/cpq.js CHANGED
@@ -10,6 +10,7 @@ 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
12
  const price_books_1 = require("./price-books/price-books");
13
+ const custom_1 = require("./custom/custom");
13
14
  class Cpq {
14
15
  constructor(config) {
15
16
  this.config = config;
@@ -26,5 +27,8 @@ class Cpq {
26
27
  async authorize() {
27
28
  await this.connection.authorize({ grant_type: 'client_credentials' });
28
29
  }
30
+ createCustomApi(collection) {
31
+ return new custom_1.CustomCollection(this.connection, collection);
32
+ }
29
33
  }
30
34
  exports.Cpq = Cpq;
@@ -0,0 +1,10 @@
1
+ import { Connection, QueryCondition, Schema, Record, SObjectUpdateRecord, SaveResult } from 'jsforce';
2
+ export declare class CustomCollection<T extends Record = Record> {
3
+ private readonly connection;
4
+ private readonly collection;
5
+ private readonly client;
6
+ constructor(connection: Connection, collection: string);
7
+ getMany(query: QueryCondition<Schema, typeof this.collection>): Promise<T[]>;
8
+ getOne(query: QueryCondition<Schema, typeof this.collection>): Promise<T>;
9
+ updateOne(query: SObjectUpdateRecord<Schema, typeof this.collection>): Promise<SaveResult>;
10
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomCollection = void 0;
4
+ class CustomCollection {
5
+ constructor(connection, collection) {
6
+ this.connection = connection;
7
+ this.collection = collection;
8
+ this.client = this.connection.sobject(this.collection);
9
+ }
10
+ async getMany(query) {
11
+ return this.client.find(query);
12
+ }
13
+ async getOne(query) {
14
+ return this.client.findOne(query);
15
+ }
16
+ async updateOne(query) {
17
+ return this.client.update(query);
18
+ }
19
+ }
20
+ exports.CustomCollection = CustomCollection;
@@ -5,6 +5,7 @@ export declare class Subscriptions extends Base<SubscriptionEntity> {
5
5
  private readonly connection;
6
6
  client: SObject<Schema, SubscriptionEntity>;
7
7
  constructor(connection: Connection);
8
+ getById(id: string): Promise<Subscription>;
8
9
  getByContractNumber(contractNumber: string, options?: SubscriptionQuery): Promise<Subscription[]>;
9
10
  update(id: string, update: Partial<Omit<Subscription, 'Id'>>, options?: SubscriptionQuery): Promise<SaveResult>;
10
11
  }
@@ -9,6 +9,9 @@ class Subscriptions extends base_1.Base {
9
9
  this.connection = connection;
10
10
  this.client = this.connection.sobject(subscription_types_1.SubscriptionsCollection);
11
11
  }
12
+ async getById(id) {
13
+ return this.client.findOne({ Id: id });
14
+ }
12
15
  async getByContractNumber(contractNumber, options) {
13
16
  const base = { SBQQ__ContractNumber__c: contractNumber };
14
17
  const query = this.buildQuery(base, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pliancy/salesforce-cpq-sdk",
3
- "version": "3.13.0",
3
+ "version": "3.15.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "description": "Salesforce CPQ SDK for Node.js",