@pliancy/salesforce-cpq-sdk 3.15.0 → 3.17.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
@@ -6,6 +6,8 @@ export * from './lib/contracts/contracts';
6
6
  export * from './lib/contracts/contract.types';
7
7
  export * from './lib/products/products';
8
8
  export * from './lib/products/product.types';
9
+ export * from './lib/products/product-options/product-options';
10
+ export * from './lib/products/product-options/product-option.types';
9
11
  export * from './lib/subscriptions/subscriptions';
10
12
  export * from './lib/subscriptions/subscription.types';
11
13
  export * from './lib/quotes/quotes';
@@ -16,5 +18,9 @@ export * from './lib/orders/orders';
16
18
  export * from './lib/orders/order.types';
17
19
  export * from './lib/orders/order-items/order-items';
18
20
  export * from './lib/orders/order-items/order-item.types';
21
+ export * from './lib/price-books/price-books';
22
+ export * from './lib/price-books/price-book.types';
23
+ export * from './lib/price-books/entries/price-book-entries';
24
+ export * from './lib/price-books/entries/price-book-entries.types';
19
25
  export * from './lib/custom/custom';
20
26
  export { SaveResult, SaveError };
package/dist/index.js CHANGED
@@ -23,6 +23,8 @@ __exportStar(require("./lib/contracts/contracts"), exports);
23
23
  __exportStar(require("./lib/contracts/contract.types"), exports);
24
24
  __exportStar(require("./lib/products/products"), exports);
25
25
  __exportStar(require("./lib/products/product.types"), exports);
26
+ __exportStar(require("./lib/products/product-options/product-options"), exports);
27
+ __exportStar(require("./lib/products/product-options/product-option.types"), exports);
26
28
  __exportStar(require("./lib/subscriptions/subscriptions"), exports);
27
29
  __exportStar(require("./lib/subscriptions/subscription.types"), exports);
28
30
  __exportStar(require("./lib/quotes/quotes"), exports);
@@ -33,4 +35,8 @@ __exportStar(require("./lib/orders/orders"), exports);
33
35
  __exportStar(require("./lib/orders/order.types"), exports);
34
36
  __exportStar(require("./lib/orders/order-items/order-items"), exports);
35
37
  __exportStar(require("./lib/orders/order-items/order-item.types"), exports);
38
+ __exportStar(require("./lib/price-books/price-books"), exports);
39
+ __exportStar(require("./lib/price-books/price-book.types"), exports);
40
+ __exportStar(require("./lib/price-books/entries/price-book-entries"), exports);
41
+ __exportStar(require("./lib/price-books/entries/price-book-entries.types"), exports);
36
42
  __exportStar(require("./lib/custom/custom"), exports);
@@ -1,8 +1,5 @@
1
1
  import { Address, QueryCondition, Schema } from 'jsforce';
2
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';
6
3
  export interface Contract {
7
4
  [index: string]: any;
8
5
  Id: string;
@@ -88,61 +85,33 @@ export interface Contract {
88
85
  SBQQ__ActiveContract__c: number;
89
86
  SBQQ__OpportunityPricebookId__c: string;
90
87
  }
91
- export interface NestedContractAmendmentResponseObject {
88
+ export interface Attributes {
92
89
  attributes: {
93
90
  type: 'Account' | 'User' | 'Pricebook2' | 'Opportunity';
94
91
  url: string;
95
92
  };
96
93
  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
- };
94
+ Name: string;
107
95
  }
108
96
  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
- })[];
97
+ record: AmendmentQuote;
145
98
  }
99
+ export type AmendmentQuote = Attributes & Quote & {
100
+ SBQQ__Account__r: Attributes & {
101
+ SBQQ__RenewalModel__c: string;
102
+ SBQQ__RenewalPricingMethod__c: string;
103
+ };
104
+ SBQQ__MasterEvergreenContract__r: Attributes & {
105
+ ContractNumber: string;
106
+ };
107
+ SBQQ__SalesRep__r: Attributes;
108
+ SBQQ__PriceBook__r: Attributes;
109
+ SBQQ__Opportunity2__r: Attributes & {
110
+ SBQQ__PrimaryQuote__c: string;
111
+ Pricebook2Id: string;
112
+ AccountId: string;
113
+ };
114
+ };
146
115
  export type ContractStatus = 'Draft' | 'Activated' | 'In Approval Process';
147
116
  export declare const ContractsCollection = "Contract";
148
117
  export type ContractEntity = typeof ContractsCollection;
@@ -1,5 +1,5 @@
1
1
  import { Connection } from 'jsforce';
2
- import { Contract, ContractQuery, ContractEntity, AmendmentQuote } from './contract.types';
2
+ import { AmendmentQuote, Contract, ContractEntity, ContractQuery } 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,7 +8,16 @@ 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
+ /**
12
+ * Creates an amendment quote based on the provided contract ID.
13
+ *
14
+ * This Apex call actually returns an absurdly complex object with deeply nested objects. All we
15
+ * need out of this is the quote ID, frankly, so all I'm returning is the Quote and its
16
+ * minimally nested objects. If someone needs more out of this feel free to tackle it and submit
17
+ * a PR. JM - 03/2025
18
+ *
19
+ * @param {string} contractId - The unique identifier of the contract to be amended.
20
+ * @return {Promise<{ success: boolean; message?: string }>} A promise that resolves to an object indicating the success status of the operation and an optional message in case of failure.
21
+ */
22
+ createAmendmentQuote(contractId: string): Promise<AmendmentQuote>;
14
23
  }
@@ -37,20 +37,21 @@ 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
- };
40
+ /**
41
+ * Creates an amendment quote based on the provided contract ID.
42
+ *
43
+ * This Apex call actually returns an absurdly complex object with deeply nested objects. All we
44
+ * need out of this is the quote ID, frankly, so all I'm returning is the Quote and its
45
+ * minimally nested objects. If someone needs more out of this feel free to tackle it and submit
46
+ * a PR. JM - 03/2025
47
+ *
48
+ * @param {string} contractId - The unique identifier of the contract to be amended.
49
+ * @return {Promise<{ success: boolean; message?: string }>} A promise that resolves to an object indicating the success status of the operation and an optional message in case of failure.
50
+ */
51
+ async createAmendmentQuote(contractId) {
52
+ const str = await this.connection.apex.patch(`/SBQQ/ServiceRouter?loader=SBQQ.ContractManipulationAPI.ContractAmender&uid=${contractId}`, {}, { headers: { Accept: 'application/json' } });
53
+ const json = JSON.parse(str);
54
+ return json.record;
54
55
  }
55
56
  }
56
57
  exports.Contracts = Contracts;
@@ -0,0 +1,50 @@
1
+ export interface ProductOption {
2
+ [index: string]: any;
3
+ Id: string;
4
+ OwnerId: string;
5
+ IsDeleted: boolean;
6
+ Name: string;
7
+ CreatedDate: string;
8
+ CreatedById: string;
9
+ LastModifiedDate: string;
10
+ LastModifiedById: string;
11
+ SystemModstamp: string;
12
+ SBQQ__AppliedImmediatelyContext__c?: unknown;
13
+ SBQQ__AppliedImmediately__c: boolean;
14
+ SBQQ__Bundled__c: boolean;
15
+ SBQQ__ComponentCodePosition__c?: unknown;
16
+ SBQQ__ComponentCode__c?: unknown;
17
+ SBQQ__ComponentDescriptionPosition__c?: unknown;
18
+ SBQQ__ComponentDescription__c?: unknown;
19
+ SBQQ__ConfiguredSKU__c: string;
20
+ SBQQ__DefaultPricingTable__c?: unknown;
21
+ SBQQ__DiscountAmount__c?: unknown;
22
+ SBQQ__DiscountSchedule__c?: unknown;
23
+ SBQQ__Discount__c?: unknown;
24
+ SBQQ__DiscountedByPackage__c: boolean;
25
+ SBQQ__ExistingQuantity__c?: unknown;
26
+ SBQQ__Feature__c?: unknown;
27
+ SBQQ__MaxQuantity__c?: unknown;
28
+ SBQQ__MinQuantity__c?: unknown;
29
+ SBQQ__Number__c: number;
30
+ SBQQ__OptionalSKU__c: string;
31
+ SBQQ__QuantityEditable__c: boolean;
32
+ SBQQ__Quantity__c: number;
33
+ SBQQ__QuoteLineVisibility__c?: unknown;
34
+ SBQQ__RenewalProductOption__c?: unknown;
35
+ SBQQ__Required__c: boolean;
36
+ SBQQ__Selected__c: boolean;
37
+ SBQQ__SubscriptionScope__c?: unknown;
38
+ SBQQ__System__c: boolean;
39
+ SBQQ__Type__c: string;
40
+ SBQQ__UnitPrice__c?: unknown;
41
+ SBQQ__UpliftedByPackage__c: boolean;
42
+ SBQQ__PriceEditable__c: string;
43
+ SBQQ__ProductCode__c: string;
44
+ SBQQ__ProductConfigurationType__c?: unknown;
45
+ SBQQ__ProductDescription__c?: unknown;
46
+ SBQQ__ProductFamily__c: string;
47
+ SBQQ__ProductName__c: string;
48
+ SBQQ__ProductQuantityScale__c?: unknown;
49
+ SBQQ__ProductSubscriptionPricing__c: string;
50
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import { Connection } from 'jsforce';
2
+ import { ProductOption } from './product-option.types';
3
+ export declare class ProductOptions {
4
+ private readonly connection;
5
+ private readonly client;
6
+ constructor(connection: Connection);
7
+ getByProductCode(code: string): Promise<ProductOption[]>;
8
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductOptions = void 0;
4
+ class ProductOptions {
5
+ constructor(connection) {
6
+ this.connection = connection;
7
+ this.client = this.connection.sobject('SBQQ__ProductOption__c');
8
+ }
9
+ async getByProductCode(code) {
10
+ return this.client.find({ SBQQ__ProductCode__c: code });
11
+ }
12
+ }
13
+ exports.ProductOptions = ProductOptions;
@@ -3,7 +3,9 @@ import { Product } from './product.types';
3
3
  export declare class Products {
4
4
  private readonly connection;
5
5
  private readonly client;
6
+ private readonly options;
6
7
  constructor(connection: Connection);
7
8
  get(query: QueryCondition<Schema, 'Product2'>): Promise<Product[]>;
8
9
  getById(id: string): Promise<Product | null>;
10
+ getOptionsByProductCode(code: string): Promise<import("./product-options/product-option.types").ProductOption[]>;
9
11
  }
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Products = void 0;
4
+ const product_options_1 = require("./product-options/product-options");
4
5
  class Products {
5
6
  constructor(connection) {
6
7
  this.connection = connection;
7
8
  this.client = this.connection.sobject('Product2');
9
+ this.options = new product_options_1.ProductOptions(this.connection);
8
10
  }
9
11
  async get(query) {
10
12
  return this.client.find(query);
@@ -12,5 +14,8 @@ class Products {
12
14
  async getById(id) {
13
15
  return this.client.findOne({ Id: id });
14
16
  }
17
+ getOptionsByProductCode(code) {
18
+ return this.options.getByProductCode(code);
19
+ }
15
20
  }
16
21
  exports.Products = Products;
@@ -106,10 +106,10 @@ export interface QuoteLine {
106
106
  SBQQ__SubscriptionBase__c?: string;
107
107
  SBQQ__SubscriptionCategory__c: string;
108
108
  SBQQ__SubscriptionPercent__c?: string;
109
- SBQQ__SubscriptionPricing__c: string;
109
+ SBQQ__SubscriptionPricing__c: SubscriptionPricing;
110
110
  SBQQ__SubscriptionScope__c: string;
111
111
  SBQQ__SubscriptionTargetPrice__c?: string;
112
- SBQQ__SubscriptionTerm__c?: string;
112
+ SBQQ__SubscriptionTerm__c?: number;
113
113
  SBQQ__TaxCode__c?: string;
114
114
  SBQQ__Taxable__c: boolean;
115
115
  SBQQ__TermDiscountSchedule__c?: string;
@@ -129,7 +129,7 @@ export interface QuoteLine {
129
129
  SBQQ__EffectiveEndDate__c?: string;
130
130
  SBQQ__EffectiveQuantity__c: number;
131
131
  SBQQ__EffectiveStartDate__c: string;
132
- SBQQ__EffectiveSubscriptionTerm__c?: string;
132
+ SBQQ__EffectiveSubscriptionTerm__c?: number;
133
133
  SBQQ__ListTotal__c: number;
134
134
  SBQQ__Markup__c: number;
135
135
  SBQQ__NetTotal__c: number;
@@ -141,7 +141,17 @@ export interface QuoteLine {
141
141
  SBQQ__ProductFamily__c: string;
142
142
  SBQQ__ProductName__c: string;
143
143
  SBQQ__RegularTotal__c: number;
144
- SBQQ__SubscriptionType__c: string;
144
+ SBQQ__SubscriptionType__c: SubscriptionType;
145
145
  SBQQ__TotalDiscountAmount__c: number;
146
146
  SBQQ__TotalDiscountRate__c: number;
147
147
  }
148
+ export declare enum SubscriptionType {
149
+ RENEWABLE = "Renewable",
150
+ ONE_TIME = "One-time",
151
+ RENEWAL_EVERGREEN = "Renewable/Evergreen",
152
+ EVERGREEN = "Evergreen"
153
+ }
154
+ export declare enum SubscriptionPricing {
155
+ FIXED_PRICE = "Fixed Price",
156
+ PERCENT_OF_TOTAL = "Percent Of Total"
157
+ }
@@ -1,2 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubscriptionPricing = exports.SubscriptionType = void 0;
4
+ var SubscriptionType;
5
+ (function (SubscriptionType) {
6
+ SubscriptionType["RENEWABLE"] = "Renewable";
7
+ SubscriptionType["ONE_TIME"] = "One-time";
8
+ SubscriptionType["RENEWAL_EVERGREEN"] = "Renewable/Evergreen";
9
+ SubscriptionType["EVERGREEN"] = "Evergreen";
10
+ })(SubscriptionType || (exports.SubscriptionType = SubscriptionType = {}));
11
+ var SubscriptionPricing;
12
+ (function (SubscriptionPricing) {
13
+ SubscriptionPricing["FIXED_PRICE"] = "Fixed Price";
14
+ SubscriptionPricing["PERCENT_OF_TOTAL"] = "Percent Of Total";
15
+ })(SubscriptionPricing || (exports.SubscriptionPricing = SubscriptionPricing = {}));
@@ -75,7 +75,7 @@ export interface Quote {
75
75
  SBQQ__ShippingStreet__c: string;
76
76
  SBQQ__Source__c?: string;
77
77
  SBQQ__StartDate__c: string;
78
- SBQQ__Status__c: string;
78
+ SBQQ__Status__c: QuoteStatus;
79
79
  SBQQ__SubscriptionTerm__c?: string;
80
80
  SBQQ__TargetCustomerAmount__c?: string;
81
81
  SBQQ__Type__c: QuoteType;
@@ -100,6 +100,15 @@ export declare enum QuoteType {
100
100
  AMENDMENT = "Amendment",
101
101
  REQUOTE = "Re-Quote"
102
102
  }
103
+ export declare enum QuoteStatus {
104
+ DRAFT = "Draft",
105
+ IN_REVIEW = "In Review",
106
+ APPROVED = "Approved",
107
+ DENIED = "Denied",
108
+ PRESENTED = "Presented",
109
+ ACCEPTED = "Accepted",
110
+ REJECTED = "Rejected"
111
+ }
103
112
  export type QuoteWithLineItems = Quote & {
104
113
  lineItems: QuoteLine[];
105
114
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuotesCollection = exports.ApprovalStatus = exports.QuoteType = void 0;
3
+ exports.QuotesCollection = exports.ApprovalStatus = exports.QuoteStatus = exports.QuoteType = void 0;
4
4
  var QuoteType;
5
5
  (function (QuoteType) {
6
6
  QuoteType["QUOTE"] = "Quote";
@@ -8,6 +8,16 @@ var QuoteType;
8
8
  QuoteType["AMENDMENT"] = "Amendment";
9
9
  QuoteType["REQUOTE"] = "Re-Quote";
10
10
  })(QuoteType || (exports.QuoteType = QuoteType = {}));
11
+ var QuoteStatus;
12
+ (function (QuoteStatus) {
13
+ QuoteStatus["DRAFT"] = "Draft";
14
+ QuoteStatus["IN_REVIEW"] = "In Review";
15
+ QuoteStatus["APPROVED"] = "Approved";
16
+ QuoteStatus["DENIED"] = "Denied";
17
+ QuoteStatus["PRESENTED"] = "Presented";
18
+ QuoteStatus["ACCEPTED"] = "Accepted";
19
+ QuoteStatus["REJECTED"] = "Rejected";
20
+ })(QuoteStatus || (exports.QuoteStatus = QuoteStatus = {}));
11
21
  var ApprovalStatus;
12
22
  (function (ApprovalStatus) {
13
23
  ApprovalStatus["APPROVED"] = "Approved";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pliancy/salesforce-cpq-sdk",
3
- "version": "3.15.0",
3
+ "version": "3.17.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "description": "Salesforce CPQ SDK for Node.js",