@merchi/sdk 1.42.22 → 1.42.24
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/constants/index.d.ts +2 -1
- package/dist/constants/index.js +2 -1
- package/dist/constants/job_followup_types.d.ts +8 -0
- package/dist/constants/job_followup_types.js +8 -0
- package/dist/constants/job_status.d.ts +4 -0
- package/dist/constants/job_status.js +5 -0
- package/dist/constants/notification_types.d.ts +5 -1
- package/dist/constants/notification_types.js +4 -0
- package/dist/entities/domain.d.ts +2 -0
- package/dist/entities/domain.js +4 -0
- package/dist/entities/invoice.d.ts +15 -0
- package/dist/entities/invoice.js +45 -1
- package/dist/entities/invoice.test.js +89 -0
- package/dist/entities/job.d.ts +12 -0
- package/dist/entities/job.js +55 -0
- package/dist/entities/job_followup.d.ts +47 -0
- package/dist/entities/job_followup.js +114 -0
- package/dist/entities/job_followup.test.d.ts +1 -0
- package/dist/entities/job_followup.test.js +138 -0
- package/dist/entities/job_followup_template.d.ts +20 -0
- package/dist/entities/job_followup_template.js +84 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/dist/merchi.d.ts +4 -0
- package/dist/merchi.js +4 -0
- package/package.json +1 -1
- package/src/constants/index.ts +2 -0
- package/src/constants/job_followup_types.ts +9 -0
- package/src/constants/job_status.ts +5 -0
- package/src/constants/notification_types.ts +4 -0
- package/src/entities/domain.ts +4 -0
- package/src/entities/invoice.test.ts +39 -0
- package/src/entities/invoice.ts +42 -0
- package/src/entities/job.ts +61 -0
- package/src/entities/job_followup.test.ts +99 -0
- package/src/entities/job_followup.ts +91 -0
- package/src/entities/job_followup_template.ts +45 -0
- package/src/index.ts +8 -0
- package/src/merchi.ts +8 -0
|
@@ -17,9 +17,10 @@ import * as production_status from './job/production_status.js';
|
|
|
17
17
|
import * as shipment_status from './job/shipment_status.js';
|
|
18
18
|
import * as call_to_actions from './call_to_actions.js';
|
|
19
19
|
import * as domain_types from './domain_types.js';
|
|
20
|
+
import * as job_followup_types from './job_followup_types.js';
|
|
20
21
|
import * as job_status from './job_status.js';
|
|
21
22
|
import * as white_label_accessibilities from './white_label_accessibilities.js';
|
|
22
23
|
import * as robots_meta_directives from './robots_meta_directives.js';
|
|
23
24
|
import * as inventory_statuses from './inventory_statuses.js';
|
|
24
25
|
import * as discount_types from './discount_types.js';
|
|
25
|
-
export { discount_types, field_types, input_types, inventory_statuses, platform, robots_meta_directives, system_roles, user_types, white_label_accessibilities, roles, notification_sections, notification_types, shipment_services, shipment_companies, auto_assign_production_on_actions, product_types, drafting_status, job_types, payment_status, production_status, shipment_status, call_to_actions, domain_types, job_status, };
|
|
26
|
+
export { discount_types, field_types, input_types, inventory_statuses, platform, robots_meta_directives, system_roles, user_types, white_label_accessibilities, roles, notification_sections, notification_types, shipment_services, shipment_companies, auto_assign_production_on_actions, product_types, drafting_status, job_followup_types, job_types, payment_status, production_status, shipment_status, call_to_actions, domain_types, job_status, };
|
package/dist/constants/index.js
CHANGED
|
@@ -17,9 +17,10 @@ import * as production_status from './job/production_status.js';
|
|
|
17
17
|
import * as shipment_status from './job/shipment_status.js';
|
|
18
18
|
import * as call_to_actions from './call_to_actions.js';
|
|
19
19
|
import * as domain_types from './domain_types.js';
|
|
20
|
+
import * as job_followup_types from './job_followup_types.js';
|
|
20
21
|
import * as job_status from './job_status.js';
|
|
21
22
|
import * as white_label_accessibilities from './white_label_accessibilities.js';
|
|
22
23
|
import * as robots_meta_directives from './robots_meta_directives.js';
|
|
23
24
|
import * as inventory_statuses from './inventory_statuses.js';
|
|
24
25
|
import * as discount_types from './discount_types.js';
|
|
25
|
-
export { discount_types, field_types, input_types, inventory_statuses, platform, robots_meta_directives, system_roles, user_types, white_label_accessibilities, roles, notification_sections, notification_types, shipment_services, shipment_companies, auto_assign_production_on_actions, product_types, drafting_status, job_types, payment_status, production_status, shipment_status, call_to_actions, domain_types, job_status, };
|
|
26
|
+
export { discount_types, field_types, input_types, inventory_statuses, platform, robots_meta_directives, system_roles, user_types, white_label_accessibilities, roles, notification_sections, notification_types, shipment_services, shipment_companies, auto_assign_production_on_actions, product_types, drafting_status, job_followup_types, job_types, payment_status, production_status, shipment_status, call_to_actions, domain_types, job_status, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var JobFollowupType;
|
|
2
|
+
(function (JobFollowupType) {
|
|
3
|
+
JobFollowupType[JobFollowupType["COMPLETION"] = 0] = "COMPLETION";
|
|
4
|
+
JobFollowupType[JobFollowupType["REVIEW_REQUEST"] = 1] = "REVIEW_REQUEST";
|
|
5
|
+
JobFollowupType[JobFollowupType["REORDER"] = 2] = "REORDER";
|
|
6
|
+
JobFollowupType[JobFollowupType["FEEDBACK"] = 3] = "FEEDBACK";
|
|
7
|
+
JobFollowupType[JobFollowupType["CUSTOM"] = 4] = "CUSTOM";
|
|
8
|
+
})(JobFollowupType || (JobFollowupType = {}));
|
|
@@ -14,6 +14,11 @@ export var PaymentStatus;
|
|
|
14
14
|
PaymentStatus[PaymentStatus["PARTIAL_PAID"] = 3] = "PARTIAL_PAID";
|
|
15
15
|
PaymentStatus[PaymentStatus["FULLY_PAID"] = 4] = "FULLY_PAID";
|
|
16
16
|
})(PaymentStatus || (PaymentStatus = {}));
|
|
17
|
+
export var InvoiceQuoteStatus;
|
|
18
|
+
(function (InvoiceQuoteStatus) {
|
|
19
|
+
InvoiceQuoteStatus["ISSUED"] = "issued";
|
|
20
|
+
InvoiceQuoteStatus["DECLINED"] = "declined";
|
|
21
|
+
})(InvoiceQuoteStatus || (InvoiceQuoteStatus = {}));
|
|
17
22
|
export var ProductionStatus;
|
|
18
23
|
(function (ProductionStatus) {
|
|
19
24
|
ProductionStatus[ProductionStatus["INIT"] = 0] = "INIT";
|
|
@@ -97,5 +97,9 @@ export declare enum NotificationType {
|
|
|
97
97
|
REFERRER_ASSIGNED = 105,
|
|
98
98
|
REFERRER_JOB_PAID = 106,
|
|
99
99
|
REFERRER_JOB_RECEIVED = 107,
|
|
100
|
-
FULFILLMENT_PARTNER_INVITED = 108
|
|
100
|
+
FULFILLMENT_PARTNER_INVITED = 108,
|
|
101
|
+
JOB_FOLLOWUP = 109,
|
|
102
|
+
SEND_QUOTE = 110,
|
|
103
|
+
QUOTE_INVOICE_APPROVED = 111,
|
|
104
|
+
QUOTE_INVOICE_DECLINED = 112
|
|
101
105
|
}
|
|
@@ -99,4 +99,8 @@ export var NotificationType;
|
|
|
99
99
|
NotificationType[NotificationType["REFERRER_JOB_PAID"] = 106] = "REFERRER_JOB_PAID";
|
|
100
100
|
NotificationType[NotificationType["REFERRER_JOB_RECEIVED"] = 107] = "REFERRER_JOB_RECEIVED";
|
|
101
101
|
NotificationType[NotificationType["FULFILLMENT_PARTNER_INVITED"] = 108] = "FULFILLMENT_PARTNER_INVITED";
|
|
102
|
+
NotificationType[NotificationType["JOB_FOLLOWUP"] = 109] = "JOB_FOLLOWUP";
|
|
103
|
+
NotificationType[NotificationType["SEND_QUOTE"] = 110] = "SEND_QUOTE";
|
|
104
|
+
NotificationType[NotificationType["QUOTE_INVOICE_APPROVED"] = 111] = "QUOTE_INVOICE_APPROVED";
|
|
105
|
+
NotificationType[NotificationType["QUOTE_INVOICE_DECLINED"] = 112] = "QUOTE_INVOICE_DECLINED";
|
|
102
106
|
})(NotificationType || (NotificationType = {}));
|
|
@@ -13,6 +13,7 @@ import { Job } from './job.js';
|
|
|
13
13
|
import { User } from './user.js';
|
|
14
14
|
import { Notification } from './notification.js';
|
|
15
15
|
import { Product } from './product.js';
|
|
16
|
+
import { JobFollowupTemplate } from './job_followup_template.js';
|
|
16
17
|
import { Reminder } from './reminder.js';
|
|
17
18
|
import { Session } from './session.js';
|
|
18
19
|
import { SupplyDomain } from './supply_domain.js';
|
|
@@ -493,6 +494,7 @@ export declare class Domain extends Entity {
|
|
|
493
494
|
categories?: Category[];
|
|
494
495
|
notifications?: Notification[];
|
|
495
496
|
reminders?: Reminder[];
|
|
497
|
+
jobFollowupTemplates?: JobFollowupTemplate[];
|
|
496
498
|
products?: Product[];
|
|
497
499
|
supplyProducts?: SupplyDomain[];
|
|
498
500
|
jobs?: Job[];
|
package/dist/entities/domain.js
CHANGED
|
@@ -530,6 +530,10 @@ var Domain = /** @class */ (function (_super) {
|
|
|
530
530
|
Domain.property({ arrayType: 'Reminder' }),
|
|
531
531
|
__metadata("design:type", Array)
|
|
532
532
|
], Domain.prototype, "reminders", void 0);
|
|
533
|
+
__decorate([
|
|
534
|
+
Domain.property({ arrayType: 'JobFollowupTemplate' }),
|
|
535
|
+
__metadata("design:type", Array)
|
|
536
|
+
], Domain.prototype, "jobFollowupTemplates", void 0);
|
|
533
537
|
__decorate([
|
|
534
538
|
Domain.property({ arrayType: 'Product' }),
|
|
535
539
|
__metadata("design:type", Array)
|
|
@@ -41,6 +41,10 @@ export declare class Invoice extends Entity {
|
|
|
41
41
|
sendWhatsapp?: boolean | null;
|
|
42
42
|
unpaid?: boolean | null;
|
|
43
43
|
isTest?: boolean | null;
|
|
44
|
+
isQuote?: boolean | null;
|
|
45
|
+
quoteApprovedDate?: Date | null;
|
|
46
|
+
quoteDeclinedDate?: Date | null;
|
|
47
|
+
quoteDeclineReason?: string | null;
|
|
44
48
|
currency?: string;
|
|
45
49
|
acceptSquare?: boolean;
|
|
46
50
|
acceptStripe?: boolean;
|
|
@@ -56,6 +60,7 @@ export declare class Invoice extends Entity {
|
|
|
56
60
|
isCompletelyPaid?: boolean;
|
|
57
61
|
responsibleManager?: User | null;
|
|
58
62
|
creator?: User | null;
|
|
63
|
+
quoteApprovedBy?: User | null;
|
|
59
64
|
client?: User;
|
|
60
65
|
clientCompany?: Company | null;
|
|
61
66
|
subscriptionCompanies?: Company[];
|
|
@@ -77,4 +82,14 @@ export declare class Invoice extends Entity {
|
|
|
77
82
|
quotes?: Quote[];
|
|
78
83
|
cart?: Cart;
|
|
79
84
|
payments?: Payment[];
|
|
85
|
+
private respondToQuote;
|
|
86
|
+
/** Approving a quote turns it into a payable invoice. */
|
|
87
|
+
approveQuote: () => Promise<{
|
|
88
|
+
invoice: Invoice;
|
|
89
|
+
paymentUrl: string;
|
|
90
|
+
}>;
|
|
91
|
+
declineQuote: (reason?: string) => Promise<{
|
|
92
|
+
invoice: Invoice;
|
|
93
|
+
paymentUrl: string;
|
|
94
|
+
}>;
|
|
80
95
|
}
|
package/dist/entities/invoice.js
CHANGED
|
@@ -34,7 +34,31 @@ import { User } from './user.js';
|
|
|
34
34
|
var Invoice = /** @class */ (function (_super) {
|
|
35
35
|
__extends(Invoice, _super);
|
|
36
36
|
function Invoice() {
|
|
37
|
-
|
|
37
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
38
|
+
_this.respondToQuote = function (action, reason) {
|
|
39
|
+
if (_this.id === undefined || _this.id === null) {
|
|
40
|
+
throw new Error('id is undefined, did you forget to set it?');
|
|
41
|
+
}
|
|
42
|
+
var resource = "/invoices/".concat(_this.id, "/").concat(action, "_quote/");
|
|
43
|
+
var data = new FormData();
|
|
44
|
+
if (reason) {
|
|
45
|
+
data.append('reason', reason);
|
|
46
|
+
}
|
|
47
|
+
var fetchOptions = { method: 'POST', body: data, query: [] };
|
|
48
|
+
return _this.merchi.authenticatedFetch(resource, fetchOptions).
|
|
49
|
+
then(function (payload) {
|
|
50
|
+
_this.fromJson(payload.invoice);
|
|
51
|
+
return { invoice: _this, paymentUrl: payload.paymentUrl };
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
/** Approving a quote turns it into a payable invoice. */
|
|
55
|
+
_this.approveQuote = function () {
|
|
56
|
+
return _this.respondToQuote('approve');
|
|
57
|
+
};
|
|
58
|
+
_this.declineQuote = function (reason) {
|
|
59
|
+
return _this.respondToQuote('decline', reason);
|
|
60
|
+
};
|
|
61
|
+
return _this;
|
|
38
62
|
}
|
|
39
63
|
Invoice.resourceName = 'invoices';
|
|
40
64
|
Invoice.singularName = 'invoice';
|
|
@@ -123,6 +147,22 @@ var Invoice = /** @class */ (function (_super) {
|
|
|
123
147
|
Invoice.property({ type: Boolean }),
|
|
124
148
|
__metadata("design:type", Object)
|
|
125
149
|
], Invoice.prototype, "isTest", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
Invoice.property({ type: Boolean }),
|
|
152
|
+
__metadata("design:type", Object)
|
|
153
|
+
], Invoice.prototype, "isQuote", void 0);
|
|
154
|
+
__decorate([
|
|
155
|
+
Invoice.property({ type: Date }),
|
|
156
|
+
__metadata("design:type", Object)
|
|
157
|
+
], Invoice.prototype, "quoteApprovedDate", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
Invoice.property({ type: Date }),
|
|
160
|
+
__metadata("design:type", Object)
|
|
161
|
+
], Invoice.prototype, "quoteDeclinedDate", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
Invoice.property({ type: String }),
|
|
164
|
+
__metadata("design:type", Object)
|
|
165
|
+
], Invoice.prototype, "quoteDeclineReason", void 0);
|
|
126
166
|
__decorate([
|
|
127
167
|
Invoice.property(),
|
|
128
168
|
__metadata("design:type", String)
|
|
@@ -183,6 +223,10 @@ var Invoice = /** @class */ (function (_super) {
|
|
|
183
223
|
Invoice.property({ type: User }),
|
|
184
224
|
__metadata("design:type", Object)
|
|
185
225
|
], Invoice.prototype, "creator", void 0);
|
|
226
|
+
__decorate([
|
|
227
|
+
Invoice.property({ type: User }),
|
|
228
|
+
__metadata("design:type", Object)
|
|
229
|
+
], Invoice.prototype, "quoteApprovedBy", void 0);
|
|
186
230
|
__decorate([
|
|
187
231
|
Invoice.property(),
|
|
188
232
|
__metadata("design:type", User)
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
1
37
|
import { setup, mockFetch } from '../test_util.js';
|
|
2
38
|
import { Merchi } from '../merchi.js';
|
|
3
39
|
setup();
|
|
@@ -37,6 +73,59 @@ test('client and invoice tokens supported by merchi', function () {
|
|
|
37
73
|
expect(fetch.mock.calls[0][1]['query']).toEqual(correct);
|
|
38
74
|
return invocation;
|
|
39
75
|
});
|
|
76
|
+
test('reads quote fields', function () {
|
|
77
|
+
var merchi = new Merchi();
|
|
78
|
+
var invoice = new merchi.Invoice();
|
|
79
|
+
invoice.fromJson({
|
|
80
|
+
id: 1,
|
|
81
|
+
isQuote: true,
|
|
82
|
+
quoteDeclinedDate: 1761700000,
|
|
83
|
+
quoteDeclineReason: 'Too expensive',
|
|
84
|
+
});
|
|
85
|
+
expect(invoice.isQuote).toBe(true);
|
|
86
|
+
expect(invoice.quoteDeclinedDate).toBeInstanceOf(Date);
|
|
87
|
+
expect(invoice.quoteDeclineReason).toBe('Too expensive');
|
|
88
|
+
});
|
|
89
|
+
test('approveQuote posts to approve_quote with the invoice token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
+
var merchi, fetch, invoice, result;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
merchi = new Merchi(undefined, undefined, 'i');
|
|
95
|
+
fetch = mockFetch(true, { invoice: { id: 1, isQuote: false }, paymentUrl: 'https://pay' }, 200);
|
|
96
|
+
invoice = new merchi.Invoice();
|
|
97
|
+
invoice.id = 1;
|
|
98
|
+
invoice.isQuote = true;
|
|
99
|
+
return [4 /*yield*/, invoice.approveQuote()];
|
|
100
|
+
case 1:
|
|
101
|
+
result = _a.sent();
|
|
102
|
+
expect(fetch.mock.calls[0][0]).toContain('/invoices/1/approve_quote/');
|
|
103
|
+
expect(fetch.mock.calls[0][1]['method']).toBe('POST');
|
|
104
|
+
expect(fetch.mock.calls[0][1]['query']).toContainEqual(['invoice_token', 'i']);
|
|
105
|
+
expect(result.paymentUrl).toBe('https://pay');
|
|
106
|
+
expect(invoice.isQuote).toBe(false);
|
|
107
|
+
return [2 /*return*/];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); });
|
|
111
|
+
test('declineQuote sends the reason', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var merchi, fetch, invoice;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
merchi = new Merchi();
|
|
117
|
+
fetch = mockFetch(true, { invoice: { id: 1 }, paymentUrl: '' }, 200);
|
|
118
|
+
invoice = new merchi.Invoice();
|
|
119
|
+
invoice.id = 1;
|
|
120
|
+
return [4 /*yield*/, invoice.declineQuote('Too expensive')];
|
|
121
|
+
case 1:
|
|
122
|
+
_a.sent();
|
|
123
|
+
expect(fetch.mock.calls[0][0]).toContain('/invoices/1/decline_quote/');
|
|
124
|
+
expect(fetch.mock.calls[0][1]['body'].get('reason')).toBe('Too expensive');
|
|
125
|
+
return [2 /*return*/];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}); });
|
|
40
129
|
test('preserves server payment engine hint', function () {
|
|
41
130
|
var merchi = new Merchi();
|
|
42
131
|
var entity = new merchi.Invoice();
|
package/dist/entities/job.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { MatchingInventory } from './matching_inventory.js';
|
|
|
13
13
|
import { InternalTag } from './internal_tag.js';
|
|
14
14
|
import { Invoice } from './invoice.js';
|
|
15
15
|
import { JobComment } from './job_comment.js';
|
|
16
|
+
import { JobFollowup, JobFollowupUpdate, ScheduledJobFollowup } from './job_followup.js';
|
|
16
17
|
import { JobNote } from './job_note.js';
|
|
17
18
|
import { JobOperationLog } from './job_operation_log.js';
|
|
18
19
|
import { Notification } from './notification.js';
|
|
@@ -24,6 +25,7 @@ import { User } from './user.js';
|
|
|
24
25
|
import { Variation } from './variation.js';
|
|
25
26
|
import { VariationsGroup } from './variations_group.js';
|
|
26
27
|
import { InventoryStatus } from '../constants/inventory_statuses.js';
|
|
28
|
+
import { InvoiceQuoteStatus } from '../constants/job_status.js';
|
|
27
29
|
import { Item } from './item.js';
|
|
28
30
|
export declare class Job extends Entity {
|
|
29
31
|
protected static resourceName: string;
|
|
@@ -62,6 +64,8 @@ export declare class Job extends Entity {
|
|
|
62
64
|
jobInfoApprovedByClient?: boolean;
|
|
63
65
|
groupBuyStatus?: number | null;
|
|
64
66
|
paymentStatus?: number | null;
|
|
67
|
+
/** Set while the job's invoice is still a quote; paymentStatus stays INIT. */
|
|
68
|
+
invoiceQuoteStatus?: InvoiceQuoteStatus | null;
|
|
65
69
|
deductionDate?: Date | null;
|
|
66
70
|
shippingStatus?: number | null;
|
|
67
71
|
completed?: boolean;
|
|
@@ -143,6 +147,7 @@ export declare class Job extends Entity {
|
|
|
143
147
|
notifications?: Notification[];
|
|
144
148
|
assignments?: Assignment[];
|
|
145
149
|
reminders?: Reminder[];
|
|
150
|
+
jobFollowups?: JobFollowup[];
|
|
146
151
|
supplyAssignment?: Assignment;
|
|
147
152
|
supplyJob?: Job;
|
|
148
153
|
supplyQuoteTotalCost?: number;
|
|
@@ -153,4 +158,11 @@ export declare class Job extends Entity {
|
|
|
153
158
|
getQuote: () => Promise<this>;
|
|
154
159
|
deduct: (matchingInventories: MatchingInventory[]) => Promise<this>;
|
|
155
160
|
bulkDeduct: () => Promise<this>;
|
|
161
|
+
private jobResourceId;
|
|
162
|
+
private readFollowups;
|
|
163
|
+
private readFollowup;
|
|
164
|
+
listFollowups: () => Promise<JobFollowup[]>;
|
|
165
|
+
complete: (followups?: ScheduledJobFollowup[]) => Promise<JobFollowup[]>;
|
|
166
|
+
updateFollowup: (followupId: number, changes: JobFollowupUpdate) => Promise<JobFollowup>;
|
|
167
|
+
cancelFollowup: (followupId: number) => Promise<JobFollowup>;
|
|
156
168
|
}
|
package/dist/entities/job.js
CHANGED
|
@@ -81,6 +81,53 @@ var Job = /** @class */ (function (_super) {
|
|
|
81
81
|
}
|
|
82
82
|
return _this.deduct(_this.matchingInventories);
|
|
83
83
|
};
|
|
84
|
+
_this.jobResourceId = function () {
|
|
85
|
+
if (_this.id === undefined || _this.id === null) {
|
|
86
|
+
throw new Error('id is undefined, did you forget to set it?');
|
|
87
|
+
}
|
|
88
|
+
return _this.id;
|
|
89
|
+
};
|
|
90
|
+
_this.readFollowups = function (data) {
|
|
91
|
+
var _a;
|
|
92
|
+
var rows = (_a = data === null || data === void 0 ? void 0 : data.jobFollowups) !== null && _a !== void 0 ? _a : [];
|
|
93
|
+
return rows.map(function (row) { return new _this.merchi.JobFollowup().fromJson(row); });
|
|
94
|
+
};
|
|
95
|
+
_this.readFollowup = function (data) {
|
|
96
|
+
var _a;
|
|
97
|
+
return new _this.merchi.JobFollowup().fromJson((_a = data === null || data === void 0 ? void 0 : data.jobFollowup) !== null && _a !== void 0 ? _a : data);
|
|
98
|
+
};
|
|
99
|
+
_this.listFollowups = function () {
|
|
100
|
+
var resource = "/jobs/".concat(_this.jobResourceId(), "/followups/");
|
|
101
|
+
var fetchOptions = { method: 'GET', query: [] };
|
|
102
|
+
return _this.merchi.authenticatedFetch(resource, fetchOptions).
|
|
103
|
+
then(function (data) { return _this.readFollowups(data); });
|
|
104
|
+
};
|
|
105
|
+
_this.complete = function (followups) {
|
|
106
|
+
if (followups === void 0) { followups = []; }
|
|
107
|
+
var resource = "/jobs/".concat(_this.jobResourceId(), "/complete/");
|
|
108
|
+
var data = new FormData();
|
|
109
|
+
data.append('followups', JSON.stringify(followups));
|
|
110
|
+
var fetchOptions = { method: 'POST', body: data, query: [] };
|
|
111
|
+
return _this.merchi.authenticatedFetch(resource, fetchOptions).
|
|
112
|
+
then(function (payload) { return _this.readFollowups(payload); });
|
|
113
|
+
};
|
|
114
|
+
_this.updateFollowup = function (followupId, changes) {
|
|
115
|
+
var resource = "/jobs/".concat(_this.jobResourceId(), "/followups/").concat(followupId, "/");
|
|
116
|
+
var fetchOptions = {
|
|
117
|
+
method: 'PATCH',
|
|
118
|
+
headers: { 'Content-Type': 'application/json' },
|
|
119
|
+
body: JSON.stringify(changes),
|
|
120
|
+
query: [],
|
|
121
|
+
};
|
|
122
|
+
return _this.merchi.authenticatedFetch(resource, fetchOptions).
|
|
123
|
+
then(function (data) { return _this.readFollowup(data); });
|
|
124
|
+
};
|
|
125
|
+
_this.cancelFollowup = function (followupId) {
|
|
126
|
+
var resource = "/jobs/".concat(_this.jobResourceId(), "/followups/").concat(followupId, "/cancel/");
|
|
127
|
+
var fetchOptions = { method: 'POST', query: [] };
|
|
128
|
+
return _this.merchi.authenticatedFetch(resource, fetchOptions).
|
|
129
|
+
then(function (data) { return _this.readFollowup(data); });
|
|
130
|
+
};
|
|
84
131
|
return _this;
|
|
85
132
|
}
|
|
86
133
|
Job.resourceName = 'jobs';
|
|
@@ -218,6 +265,10 @@ var Job = /** @class */ (function (_super) {
|
|
|
218
265
|
Job.property({ type: Number }),
|
|
219
266
|
__metadata("design:type", Object)
|
|
220
267
|
], Job.prototype, "paymentStatus", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
Job.property({ type: String }),
|
|
270
|
+
__metadata("design:type", Object)
|
|
271
|
+
], Job.prototype, "invoiceQuoteStatus", void 0);
|
|
221
272
|
__decorate([
|
|
222
273
|
Job.property({ type: Date }),
|
|
223
274
|
__metadata("design:type", Object)
|
|
@@ -542,6 +593,10 @@ var Job = /** @class */ (function (_super) {
|
|
|
542
593
|
Job.property({ arrayType: 'Reminder' }),
|
|
543
594
|
__metadata("design:type", Array)
|
|
544
595
|
], Job.prototype, "reminders", void 0);
|
|
596
|
+
__decorate([
|
|
597
|
+
Job.property({ arrayType: 'JobFollowup' }),
|
|
598
|
+
__metadata("design:type", Array)
|
|
599
|
+
], Job.prototype, "jobFollowups", void 0);
|
|
545
600
|
__decorate([
|
|
546
601
|
Job.property(),
|
|
547
602
|
__metadata("design:type", Assignment)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Domain } from './domain.js';
|
|
2
|
+
import { Entity } from '../entity.js';
|
|
3
|
+
import type { Job } from './job.js';
|
|
4
|
+
import type { JobFollowupTemplate } from './job_followup_template.js';
|
|
5
|
+
import type { JobFollowupStatus } from '../constants/job_followup_types.js';
|
|
6
|
+
import type { User } from './user.js';
|
|
7
|
+
export interface ScheduledJobFollowup {
|
|
8
|
+
templateId: number;
|
|
9
|
+
sendAt: string;
|
|
10
|
+
timezone: string;
|
|
11
|
+
sendEmail: boolean;
|
|
12
|
+
sendSms: boolean;
|
|
13
|
+
subject?: string;
|
|
14
|
+
body?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface JobFollowupUpdate {
|
|
17
|
+
sendAt?: string;
|
|
18
|
+
timezone?: string;
|
|
19
|
+
sendEmail?: boolean;
|
|
20
|
+
sendSms?: boolean;
|
|
21
|
+
subject?: string;
|
|
22
|
+
body?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class JobFollowup extends Entity {
|
|
25
|
+
protected static resourceName: string;
|
|
26
|
+
protected static singularName: string;
|
|
27
|
+
protected static pluralName: string;
|
|
28
|
+
id?: number;
|
|
29
|
+
jobId?: number;
|
|
30
|
+
domainId?: number;
|
|
31
|
+
templateId?: number | null;
|
|
32
|
+
templateName?: string;
|
|
33
|
+
followupType?: number;
|
|
34
|
+
subject?: string;
|
|
35
|
+
body?: string;
|
|
36
|
+
sendAt?: string;
|
|
37
|
+
sendEmail?: boolean;
|
|
38
|
+
sendSms?: boolean;
|
|
39
|
+
status?: JobFollowupStatus;
|
|
40
|
+
sentAt?: string | null;
|
|
41
|
+
lastError?: string | null;
|
|
42
|
+
created?: Date;
|
|
43
|
+
job?: Job;
|
|
44
|
+
domain?: Domain;
|
|
45
|
+
template?: JobFollowupTemplate;
|
|
46
|
+
createdBy?: User;
|
|
47
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
17
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
19
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
20
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
|
+
};
|
|
22
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
23
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
24
|
+
};
|
|
25
|
+
import { Entity } from '../entity.js';
|
|
26
|
+
var JobFollowup = /** @class */ (function (_super) {
|
|
27
|
+
__extends(JobFollowup, _super);
|
|
28
|
+
function JobFollowup() {
|
|
29
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
30
|
+
}
|
|
31
|
+
// Scheduled rows are listed and updated under /jobs/<id>/followups/,
|
|
32
|
+
// not this collection path.
|
|
33
|
+
JobFollowup.resourceName = 'job_followups';
|
|
34
|
+
JobFollowup.singularName = 'jobFollowup';
|
|
35
|
+
JobFollowup.pluralName = 'jobFollowups';
|
|
36
|
+
__decorate([
|
|
37
|
+
JobFollowup.property(),
|
|
38
|
+
__metadata("design:type", Number)
|
|
39
|
+
], JobFollowup.prototype, "id", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
JobFollowup.property(),
|
|
42
|
+
__metadata("design:type", Number)
|
|
43
|
+
], JobFollowup.prototype, "jobId", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
JobFollowup.property(),
|
|
46
|
+
__metadata("design:type", Number)
|
|
47
|
+
], JobFollowup.prototype, "domainId", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
JobFollowup.property({ type: Number }),
|
|
50
|
+
__metadata("design:type", Object)
|
|
51
|
+
], JobFollowup.prototype, "templateId", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
JobFollowup.property(),
|
|
54
|
+
__metadata("design:type", String)
|
|
55
|
+
], JobFollowup.prototype, "templateName", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
JobFollowup.property(),
|
|
58
|
+
__metadata("design:type", Number)
|
|
59
|
+
], JobFollowup.prototype, "followupType", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
JobFollowup.property(),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], JobFollowup.prototype, "subject", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
JobFollowup.property(),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], JobFollowup.prototype, "body", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
JobFollowup.property(),
|
|
70
|
+
__metadata("design:type", String)
|
|
71
|
+
], JobFollowup.prototype, "sendAt", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
JobFollowup.property(),
|
|
74
|
+
__metadata("design:type", Boolean)
|
|
75
|
+
], JobFollowup.prototype, "sendEmail", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
JobFollowup.property(),
|
|
78
|
+
__metadata("design:type", Boolean)
|
|
79
|
+
], JobFollowup.prototype, "sendSms", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
JobFollowup.property({ type: String }),
|
|
82
|
+
__metadata("design:type", String)
|
|
83
|
+
], JobFollowup.prototype, "status", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
JobFollowup.property({ type: String }),
|
|
86
|
+
__metadata("design:type", Object)
|
|
87
|
+
], JobFollowup.prototype, "sentAt", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
JobFollowup.property({ type: String }),
|
|
90
|
+
__metadata("design:type", Object)
|
|
91
|
+
], JobFollowup.prototype, "lastError", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
JobFollowup.property({ type: Date }),
|
|
94
|
+
__metadata("design:type", Date)
|
|
95
|
+
], JobFollowup.prototype, "created", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
JobFollowup.property({ type: 'Job' }),
|
|
98
|
+
__metadata("design:type", Function)
|
|
99
|
+
], JobFollowup.prototype, "job", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
JobFollowup.property({ type: 'Domain' }),
|
|
102
|
+
__metadata("design:type", Function)
|
|
103
|
+
], JobFollowup.prototype, "domain", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
JobFollowup.property({ type: 'JobFollowupTemplate' }),
|
|
106
|
+
__metadata("design:type", Function)
|
|
107
|
+
], JobFollowup.prototype, "template", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
JobFollowup.property({ type: 'User' }),
|
|
110
|
+
__metadata("design:type", Function)
|
|
111
|
+
], JobFollowup.prototype, "createdBy", void 0);
|
|
112
|
+
return JobFollowup;
|
|
113
|
+
}(Entity));
|
|
114
|
+
export { JobFollowup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|