@pliancy/salesforce-cpq-sdk 3.11.0 → 3.12.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.
@@ -0,0 +1,4 @@
1
+ import { QueryCondition, Schema } from 'jsforce';
2
+ export declare class Base<TEntity extends string> {
3
+ buildQuery(base: QueryCondition<Schema, TEntity>, options?: QueryCondition<Schema, TEntity>): QueryCondition<Schema, TEntity>;
4
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Base = void 0;
4
+ class Base {
5
+ buildQuery(base, options) {
6
+ const query = { ...base };
7
+ if (options)
8
+ Object.assign(query, options);
9
+ return query;
10
+ }
11
+ }
12
+ exports.Base = Base;
@@ -85,4 +85,6 @@ export interface Contract {
85
85
  SBQQ__OpportunityPricebookId__c: string;
86
86
  }
87
87
  export type ContractStatus = 'Draft' | 'Activated' | 'In Approval Process';
88
- export type ContractQuery = QueryCondition<Schema, 'SBQQ__Contract__c'>;
88
+ export declare const ContractsCollection = "SBQQ__Contract__c";
89
+ export type ContractEntity = typeof ContractsCollection;
90
+ export type ContractQuery = QueryCondition<Schema, ContractEntity>;
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContractsCollection = void 0;
4
+ exports.ContractsCollection = 'SBQQ__Contract__c';
@@ -1,11 +1,11 @@
1
1
  import { Connection } from 'jsforce';
2
- import { Contract, ContractQuery } from './contract.types';
3
- export declare class Contracts {
2
+ import { Contract, ContractQuery, ContractEntity } from './contract.types';
3
+ import { Base } from '../base/base';
4
+ export declare class Contracts extends Base<ContractEntity> {
4
5
  private readonly connection;
5
6
  private readonly client;
6
7
  constructor(connection: Connection);
7
8
  getById(id: string): Promise<Contract | null>;
8
9
  getLatestActivatedByAccountId(id: string, options?: ContractQuery): Promise<Contract | undefined>;
9
10
  getDraftsByBillingPeriod(accountId: string, start: string, end: string): Promise<Contract[]>;
10
- private buildQuery;
11
11
  }
@@ -2,10 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Contracts = void 0;
4
4
  const jsforce_1 = require("jsforce");
5
- class Contracts {
5
+ const contract_types_1 = require("./contract.types");
6
+ const base_1 = require("../base/base");
7
+ class Contracts extends base_1.Base {
6
8
  constructor(connection) {
9
+ super();
7
10
  this.connection = connection;
8
- this.client = this.connection.sobject('Contract');
11
+ this.client = this.connection.sobject(contract_types_1.ContractsCollection);
9
12
  }
10
13
  async getById(id) {
11
14
  return this.client.findOne({ Id: id });
@@ -34,11 +37,5 @@ class Contracts {
34
37
  EndDate: { $lte: new jsforce_1.SfDate(end) },
35
38
  });
36
39
  }
37
- buildQuery(base, options) {
38
- const query = { ...base };
39
- if (options)
40
- Object.assign(query, options);
41
- return query;
42
- }
43
40
  }
44
41
  exports.Contracts = Contracts;
@@ -1,5 +1,5 @@
1
1
  import { QuoteLine } from './quote-lines/quote-line.types';
2
- import { QueryCondition, Schema, SObjectUpdateRecord } from 'jsforce';
2
+ import { QueryCondition, Schema } from 'jsforce';
3
3
  export interface Quote {
4
4
  [index: string]: any;
5
5
  Id: string;
@@ -116,8 +116,9 @@ export declare enum ApprovalStatus {
116
116
  REQUIRED = "Required : Not Sent for Approval",
117
117
  NOT_REQUIRED = "Approval Not Required"
118
118
  }
119
- export type QuoteQuery = QueryCondition<Schema, 'SBQQ__Quote__c'>;
120
- export type UpdateQuoteQuery = SObjectUpdateRecord<Schema, 'SBQQ__Quote__c'>;
119
+ export declare const QuotesCollection = "SBQQ__Quote__c";
120
+ export type QuoteEntity = typeof QuotesCollection;
121
+ export type QuoteQuery = QueryCondition<Schema, QuoteEntity>;
121
122
  export interface ApprovalProcessRequest {
122
123
  success: boolean;
123
124
  errors?: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApprovalStatus = exports.QuoteType = void 0;
3
+ exports.QuotesCollection = exports.ApprovalStatus = exports.QuoteType = void 0;
4
4
  var QuoteType;
5
5
  (function (QuoteType) {
6
6
  QuoteType["QUOTE"] = "Quote";
@@ -16,3 +16,4 @@ var ApprovalStatus;
16
16
  ApprovalStatus["REQUIRED"] = "Required : Not Sent for Approval";
17
17
  ApprovalStatus["NOT_REQUIRED"] = "Approval Not Required";
18
18
  })(ApprovalStatus || (exports.ApprovalStatus = ApprovalStatus = {}));
19
+ exports.QuotesCollection = 'SBQQ__Quote__c';
@@ -1,7 +1,8 @@
1
1
  import { Connection, SaveResult } from 'jsforce';
2
- import { Quote, QuoteQuery, QuoteWithLineItems, UpdateQuoteLineQuantities, UpdateQuoteLine, UpdateQuoteQuery } from './quote.types';
2
+ import { QuoteEntity, Quote, QuoteQuery, QuoteWithLineItems, UpdateQuoteLine, UpdateQuoteLineQuantities } from './quote.types';
3
3
  import { QuoteLine } from './quote-lines/quote-line.types';
4
- export declare class Quotes {
4
+ import { Base } from '../base/base';
5
+ export declare class Quotes extends Base<QuoteEntity> {
5
6
  private readonly connection;
6
7
  private readonly client;
7
8
  private readonly items;
@@ -15,7 +16,7 @@ export declare class Quotes {
15
16
  updateLineItems(lineItems: UpdateQuoteLine[]): Promise<SaveResult[]>;
16
17
  deleteLineItems(ids: string[]): Promise<SaveResult[]>;
17
18
  addLineItems(lineItems: Partial<Omit<QuoteLine, 'Id'>>[]): Promise<SaveResult[]>;
18
- order(quoteId: string, options?: UpdateQuoteQuery): Promise<SaveResult>;
19
+ order(quoteId: string, options?: QuoteQuery): Promise<SaveResult>;
19
20
  submitAndApprove(quoteId: string, comments?: string): Promise<{
20
21
  success: boolean;
21
22
  workItemId: string;
@@ -32,5 +33,4 @@ export declare class Quotes {
32
33
  workItemId?: undefined;
33
34
  errors?: undefined;
34
35
  }>;
35
- private buildQuery;
36
36
  }
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Quotes = void 0;
4
+ const quote_types_1 = require("./quote.types");
4
5
  const quote_lines_1 = require("./quote-lines/quote-lines");
5
- class Quotes {
6
+ const base_1 = require("../base/base");
7
+ class Quotes extends base_1.Base {
6
8
  constructor(connection) {
9
+ super();
7
10
  this.connection = connection;
8
- this.client = this.connection.sobject('SBQQ__Quote__c');
11
+ this.client = this.connection.sobject(quote_types_1.QuotesCollection);
9
12
  this.items = new quote_lines_1.QuoteLines(this.connection);
10
13
  }
11
14
  async getAll(options) {
@@ -104,11 +107,5 @@ class Quotes {
104
107
  return { success: false, error: error.message };
105
108
  }
106
109
  }
107
- buildQuery(base, options) {
108
- const query = { ...base };
109
- if (options)
110
- Object.assign(query, options);
111
- return query;
112
- }
113
110
  }
114
111
  exports.Quotes = Quotes;
@@ -1,3 +1,4 @@
1
+ import { QueryCondition, Schema } from 'jsforce';
1
2
  export interface Subscription {
2
3
  [index: string]: any;
3
4
  Id: string;
@@ -17,7 +18,7 @@ export interface Subscription {
17
18
  SBQQ__Bundle__c: boolean;
18
19
  SBQQ__BundledQuantity__c?: string;
19
20
  SBQQ__Bundled__c: boolean;
20
- SBQQ__ChargeType__c?: string;
21
+ SBQQ__ChargeType__c?: ChargeType;
21
22
  SBQQ__ComponentDiscountedByPackage__c: boolean;
22
23
  SBQQ__ComponentSubscriptionScope__c?: string;
23
24
  SBQQ__Contract__c: string;
@@ -88,3 +89,7 @@ export interface Subscription {
88
89
  SBQQ__StartDate__c: string;
89
90
  SBQQ__SubscriptionType__c: string;
90
91
  }
92
+ export type ChargeType = 'One-Time' | 'Recurring' | 'Usage';
93
+ export declare const SubscriptionsCollection = "SBQQ__Subscription__c";
94
+ export type SubscriptionEntity = typeof SubscriptionsCollection;
95
+ export type SubscriptionQuery = QueryCondition<Schema, SubscriptionEntity>;
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubscriptionsCollection = void 0;
4
+ exports.SubscriptionsCollection = 'SBQQ__Subscription__c';
@@ -1,9 +1,10 @@
1
1
  import { Connection, SaveResult, Schema, SObject } from 'jsforce';
2
- import { Subscription } from './subscription.types';
3
- export declare class Subscriptions {
2
+ import { SubscriptionEntity, Subscription, SubscriptionQuery } from './subscription.types';
3
+ import { Base } from '../base/base';
4
+ export declare class Subscriptions extends Base<SubscriptionEntity> {
4
5
  private readonly connection;
5
- client: SObject<Schema, 'SBQQ__Subscription__c'>;
6
+ client: SObject<Schema, SubscriptionEntity>;
6
7
  constructor(connection: Connection);
7
- getByContractNumber(contractNumber: string): Promise<Subscription[]>;
8
- update(id: string, update: Partial<Omit<Subscription, 'Id'>>): Promise<SaveResult>;
8
+ getByContractNumber(contractNumber: string, options?: SubscriptionQuery): Promise<Subscription[]>;
9
+ update(id: string, update: Partial<Omit<Subscription, 'Id'>>, options?: SubscriptionQuery): Promise<SaveResult>;
9
10
  }
@@ -1,19 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Subscriptions = void 0;
4
- class Subscriptions {
4
+ const subscription_types_1 = require("./subscription.types");
5
+ const base_1 = require("../base/base");
6
+ class Subscriptions extends base_1.Base {
5
7
  constructor(connection) {
8
+ super();
6
9
  this.connection = connection;
7
- this.client = this.connection.sobject('SBQQ__Subscription__c');
10
+ this.client = this.connection.sobject(subscription_types_1.SubscriptionsCollection);
8
11
  }
9
- async getByContractNumber(contractNumber) {
10
- return this.client.find({ SBQQ__ContractNumber__c: contractNumber });
12
+ async getByContractNumber(contractNumber, options) {
13
+ const base = { SBQQ__ContractNumber__c: contractNumber };
14
+ const query = this.buildQuery(base, options);
15
+ return this.client.find(query);
11
16
  }
12
- async update(id, update) {
13
- return this.client.update({
14
- Id: id,
15
- ...update,
16
- });
17
+ async update(id, update, options) {
18
+ const query = this.buildQuery({ Id: id, ...update }, options);
19
+ return this.client.update(query);
17
20
  }
18
21
  }
19
22
  exports.Subscriptions = Subscriptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pliancy/salesforce-cpq-sdk",
3
- "version": "3.11.0",
3
+ "version": "3.12.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "description": "Salesforce CPQ SDK for Node.js",