@huloglobal/vendure-plugin-quotations 0.8.5 → 0.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/CHANGELOG.md +110 -0
- package/README.md +107 -10
- package/dist/approvals.d.ts +46 -0
- package/dist/approvals.d.ts.map +1 -0
- package/dist/approvals.js +136 -0
- package/dist/approvals.js.map +1 -0
- package/dist/crons.d.ts +5 -3
- package/dist/crons.d.ts.map +1 -1
- package/dist/crons.js +16 -10
- package/dist/crons.js.map +1 -1
- package/dist/csv.d.ts +7 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/csv.js +32 -0
- package/dist/csv.js.map +1 -0
- package/dist/deposits.d.ts +25 -0
- package/dist/deposits.d.ts.map +1 -0
- package/dist/deposits.js +59 -0
- package/dist/deposits.js.map +1 -0
- package/dist/events.d.ts +55 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +58 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/pay-links.d.ts +37 -0
- package/dist/pay-links.d.ts.map +1 -0
- package/dist/pay-links.js +61 -0
- package/dist/pay-links.js.map +1 -0
- package/dist/payment.service.d.ts +117 -0
- package/dist/payment.service.d.ts.map +1 -0
- package/dist/payment.service.js +476 -0
- package/dist/payment.service.js.map +1 -0
- package/dist/pdf.d.ts +15 -0
- package/dist/pdf.d.ts.map +1 -0
- package/dist/pdf.js +356 -0
- package/dist/pdf.js.map +1 -0
- package/dist/plugin.d.ts +5 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +18 -6
- package/dist/plugin.js.map +1 -1
- package/dist/pro-settings.d.ts +72 -0
- package/dist/pro-settings.d.ts.map +1 -0
- package/dist/pro-settings.js +202 -0
- package/dist/pro-settings.js.map +1 -0
- package/dist/pro.service.d.ts +130 -0
- package/dist/pro.service.d.ts.map +1 -0
- package/dist/pro.service.js +732 -0
- package/dist/pro.service.js.map +1 -0
- package/dist/quotation.controller.d.ts +50 -6
- package/dist/quotation.controller.d.ts.map +1 -1
- package/dist/quotation.controller.js +618 -24
- package/dist/quotation.controller.js.map +1 -1
- package/dist/quotation.service.d.ts +188 -11
- package/dist/quotation.service.d.ts.map +1 -1
- package/dist/quotation.service.js +636 -99
- package/dist/quotation.service.js.map +1 -1
- package/dist/quote-total.d.ts +49 -0
- package/dist/quote-total.d.ts.map +1 -0
- package/dist/quote-total.js +81 -0
- package/dist/quote-total.js.map +1 -0
- package/dist/templates.d.ts +13 -1
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +17 -6
- package/dist/templates.js.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/webhooks.d.ts +61 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +308 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +4 -3
- package/ui/components/quotations.component.ts +328 -19
|
@@ -18,32 +18,63 @@ const core_1 = require("@vendure/core");
|
|
|
18
18
|
const vendure_licence_sdk_1 = require("@huloglobal/vendure-licence-sdk");
|
|
19
19
|
const no_store_1 = require("./no-store");
|
|
20
20
|
const quotation_service_1 = require("./quotation.service");
|
|
21
|
+
const pro_service_1 = require("./pro.service");
|
|
22
|
+
const payment_service_1 = require("./payment.service");
|
|
23
|
+
const pro_settings_1 = require("./pro-settings");
|
|
24
|
+
const approvals_1 = require("./approvals");
|
|
21
25
|
const plugin_1 = require("./plugin");
|
|
22
26
|
const templates_1 = require("./templates");
|
|
23
27
|
const PLUGIN_ID = 'vendure-plugin-quotations';
|
|
24
28
|
const BUY_URL = `https://elite.charity/licence/buy/${PLUGIN_ID}`;
|
|
25
29
|
function denyUnlessAdmin(ctx, res, write) {
|
|
26
30
|
const needed = write ? [core_1.Permission.UpdateSettings] : [core_1.Permission.ReadSettings];
|
|
27
|
-
if (!ctx.userHasPermissions(needed)) {
|
|
31
|
+
if (!(0, vendure_licence_sdk_1.isAdminApiSession)(ctx) || !ctx.userHasPermissions(needed)) {
|
|
28
32
|
res.status(403).json({ error: 'forbidden' });
|
|
29
33
|
return true;
|
|
30
34
|
}
|
|
31
35
|
return false;
|
|
32
36
|
}
|
|
33
37
|
/** Premium = licensed OR inside the 14-day evaluation. */
|
|
34
|
-
function denyUnlessPremium(res) {
|
|
38
|
+
function denyUnlessPremium(res, feature = 'This feature') {
|
|
35
39
|
if (plugin_1.QuotationsPlugin.hasPremiumAccess())
|
|
36
40
|
return false;
|
|
37
41
|
res.status(402).json({
|
|
38
42
|
error: 'licence-required',
|
|
39
|
-
message:
|
|
43
|
+
message: `${feature} needs a licence (or the 14-day evaluation). Quoting, sending, reminders and pay links stay free.`,
|
|
40
44
|
buyUrl: BUY_URL,
|
|
41
45
|
});
|
|
42
46
|
return true;
|
|
43
47
|
}
|
|
48
|
+
/** Map a thrown error to a response: a premium refusal is a 402, everything else a 400. */
|
|
49
|
+
function fail(res, e) {
|
|
50
|
+
if (e instanceof pro_service_1.PremiumRequired) {
|
|
51
|
+
return res.status(402).json({ error: 'licence-required', message: e.message, buyUrl: BUY_URL });
|
|
52
|
+
}
|
|
53
|
+
return res.status(400).json({ error: (e === null || e === void 0 ? void 0 : e.message) || 'failed', message: (e === null || e === void 0 ? void 0 : e.message) || 'failed' });
|
|
54
|
+
}
|
|
55
|
+
/** Public PDF downloads: per client, sliding minute. */
|
|
56
|
+
const PDF_PER_MINUTE = 20;
|
|
44
57
|
let QuotationController = class QuotationController {
|
|
45
|
-
constructor(service) {
|
|
58
|
+
constructor(service, pro, payments) {
|
|
46
59
|
this.service = service;
|
|
60
|
+
this.pro = pro;
|
|
61
|
+
this.payments = payments;
|
|
62
|
+
this.pdfHits = new Map();
|
|
63
|
+
}
|
|
64
|
+
pdfAllowed(key) {
|
|
65
|
+
const now = Date.now();
|
|
66
|
+
const hits = (this.pdfHits.get(key) || []).filter(t => now - t < 60000);
|
|
67
|
+
if (hits.length >= PDF_PER_MINUTE) {
|
|
68
|
+
this.pdfHits.set(key, hits);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
hits.push(now);
|
|
72
|
+
this.pdfHits.set(key, hits);
|
|
73
|
+
if (this.pdfHits.size > 5000)
|
|
74
|
+
for (const [k, v] of this.pdfHits)
|
|
75
|
+
if (!v.length || now - v[v.length - 1] > 60000)
|
|
76
|
+
this.pdfHits.delete(k);
|
|
77
|
+
return true;
|
|
47
78
|
}
|
|
48
79
|
// ── Public: the customer quote page ────────────────────────────────
|
|
49
80
|
async publicQuote(token, res) {
|
|
@@ -52,7 +83,35 @@ let QuotationController = class QuotationController {
|
|
|
52
83
|
if (!q || q.status === 'draft' || q.status === 'requested')
|
|
53
84
|
return res.status(404).type('html').send(this.notFoundHtml());
|
|
54
85
|
const cfg = await this.service.getConfig(q.channelId);
|
|
55
|
-
return res.type('html').send((0, templates_1.renderQuotePage)(q, cfg));
|
|
86
|
+
return res.type('html').send((0, templates_1.renderQuotePage)(q, cfg, { extra: await this.service.pageExtras(q) }));
|
|
87
|
+
}
|
|
88
|
+
/** The quote as a PDF, from the customer link. Does not count as opening the quote. */
|
|
89
|
+
async publicPdf(req, token, res) {
|
|
90
|
+
(0, no_store_1.noStore)(res);
|
|
91
|
+
if (!this.pdfAllowed(req.ip || 'unknown'))
|
|
92
|
+
return res.status(429).type('text').send('Too many downloads — try again in a minute.');
|
|
93
|
+
const q = await this.service.getQuoteByToken(String(token || ''));
|
|
94
|
+
if (!q || q.status === 'draft' || q.status === 'requested')
|
|
95
|
+
return res.status(404).type('html').send(this.notFoundHtml());
|
|
96
|
+
const out = await this.service.quotePdf(Number(q.id));
|
|
97
|
+
if (!out)
|
|
98
|
+
return res.status(404).type('html').send(this.notFoundHtml());
|
|
99
|
+
res.setHeader('Content-Disposition', `inline; filename="${out.filename}"`);
|
|
100
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
101
|
+
return res.type('application/pdf').send(out.pdf);
|
|
102
|
+
}
|
|
103
|
+
// ── Storefront: "My quotes" for the signed-in customer ──────────────
|
|
104
|
+
/**
|
|
105
|
+
* The signed-in customer's quotes on this channel (shop session cookie or
|
|
106
|
+
* bearer token, channel from the `vendure-token` header). Each row has the
|
|
107
|
+
* quote link, the PDF link and, when one is due, the pay link.
|
|
108
|
+
*/
|
|
109
|
+
async myQuotes(ctx, res) {
|
|
110
|
+
(0, no_store_1.noStore)(res);
|
|
111
|
+
const customerId = await this.service.customerIdForUser(ctx.activeUserId);
|
|
112
|
+
if (!customerId)
|
|
113
|
+
return res.status(401).json({ error: 'not-signed-in', message: 'Sign in to see your quotes.' });
|
|
114
|
+
return res.json({ items: await this.service.quotesForCustomer(customerId, Number(ctx.channelId) || null) });
|
|
56
115
|
}
|
|
57
116
|
async publicRespond(token, body, res) {
|
|
58
117
|
(0, no_store_1.noStore)(res);
|
|
@@ -64,22 +123,27 @@ let QuotationController = class QuotationController {
|
|
|
64
123
|
const cfg = await this.service.getConfig(q.channelId);
|
|
65
124
|
return res.type('html').send((0, templates_1.renderQuotePage)(q, cfg, {
|
|
66
125
|
message: result.ok
|
|
67
|
-
? (action === 'accept'
|
|
126
|
+
? (action === 'accept'
|
|
127
|
+
? (cfg.payLinkOnAccept && this.payments.available() ? 'Thank you — your acceptance has been recorded. Your payment link is on its way by e-mail.' : 'Thank you — your acceptance has been recorded.')
|
|
128
|
+
: 'Thanks for letting us know.')
|
|
68
129
|
: result.reason,
|
|
69
130
|
done: result.ok,
|
|
131
|
+
extra: await this.service.pageExtras(q),
|
|
70
132
|
}));
|
|
71
133
|
}
|
|
72
134
|
// ── Public: customer-initiated quote requests ───────────────────────
|
|
73
135
|
/** Storefronts POST here (JSON). Channel from the `vendure-token` header
|
|
74
136
|
* or `channelToken` in the body; falls back to the default channel. */
|
|
75
|
-
async publicRequest(req, body, res) {
|
|
137
|
+
async publicRequest(ctx, req, body, res) {
|
|
76
138
|
var _a;
|
|
77
139
|
const token = String(req.headers['vendure-token'] || (body === null || body === void 0 ? void 0 : body.channelToken) || '');
|
|
78
140
|
const channelId = await this.service.channelIdForToken(token);
|
|
79
141
|
// req.ip is already the client address (the host trusts its proxy); a header any client can set is not.
|
|
80
142
|
const clientKey = req.ip || String((body === null || body === void 0 ? void 0 : body.email) || '');
|
|
81
143
|
try {
|
|
82
|
-
|
|
144
|
+
// A signed-in storefront customer's request is linked to their account ("My quotes").
|
|
145
|
+
const customerId = await this.service.customerIdForUser(ctx === null || ctx === void 0 ? void 0 : ctx.activeUserId).catch(() => null);
|
|
146
|
+
const result = await this.service.createRequest(channelId, body || {}, clientKey, customerId);
|
|
83
147
|
if (!result.ok)
|
|
84
148
|
return res.status(((_a = result.reason) === null || _a === void 0 ? void 0 : _a.startsWith('Too many')) ? 429 : 400).json({ ok: false, message: result.reason });
|
|
85
149
|
return res.status(200).json({ ok: true, reference: result.reference, message: result.reference ? `Thanks — your request ${result.reference} is with our team.` : 'Thanks — your request is with our team.' });
|
|
@@ -123,15 +187,20 @@ let QuotationController = class QuotationController {
|
|
|
123
187
|
return plugin_1.QuotationsPlugin.isLicensed() ? 'paid' : (((_a = plugin_1.QuotationsPlugin.getEvalState()) === null || _a === void 0 ? void 0 : _a.active) ? 'trial' : 'free');
|
|
124
188
|
}
|
|
125
189
|
// ── Admin: set-up checklist, weekly report, dashboard widget ───────
|
|
190
|
+
/** The set-up checklist is premium: without premium it reports nothing to do (and the card stays hidden). */
|
|
126
191
|
async setup(ctx, res) {
|
|
127
192
|
if (denyUnlessAdmin(ctx, res, false))
|
|
128
193
|
return;
|
|
194
|
+
if (!plugin_1.QuotationsPlugin.hasPremiumAccess())
|
|
195
|
+
return res.json({ items: [], complete: true, locked: true });
|
|
129
196
|
return res.json(await this.service.setupChecklist());
|
|
130
197
|
}
|
|
131
198
|
/** Dismiss an optional checklist item (only the ones marked dismissible). */
|
|
132
199
|
async setupDismiss(ctx, res, body) {
|
|
133
200
|
if (denyUnlessAdmin(ctx, res, true))
|
|
134
201
|
return;
|
|
202
|
+
if (denyUnlessPremium(res, 'The set-up checklist'))
|
|
203
|
+
return;
|
|
135
204
|
const ok = await this.service.dismissSetupItem(String((body === null || body === void 0 ? void 0 : body.key) || ''));
|
|
136
205
|
if (!ok)
|
|
137
206
|
return res.status(400).json({ ok: false, message: 'That item cannot be dismissed' });
|
|
@@ -143,7 +212,7 @@ let QuotationController = class QuotationController {
|
|
|
143
212
|
const d = this.service.digest();
|
|
144
213
|
if (!d)
|
|
145
214
|
return res.status(503).json({ message: 'Weekly report not initialised' });
|
|
146
|
-
return res.json(await d.settings());
|
|
215
|
+
return res.json({ ...(await d.settings()), premium: plugin_1.QuotationsPlugin.hasPremiumAccess() });
|
|
147
216
|
}
|
|
148
217
|
async digestUpdate(ctx, res, body) {
|
|
149
218
|
var _a;
|
|
@@ -158,7 +227,7 @@ let QuotationController = class QuotationController {
|
|
|
158
227
|
if (body && 'recipient' in body)
|
|
159
228
|
patch.recipient = body.recipient === null ? null : String((_a = body.recipient) !== null && _a !== void 0 ? _a : '');
|
|
160
229
|
try {
|
|
161
|
-
return res.json(await d.updateSettings(patch));
|
|
230
|
+
return res.json({ ...(await d.updateSettings(patch)), premium: plugin_1.QuotationsPlugin.hasPremiumAccess() });
|
|
162
231
|
}
|
|
163
232
|
catch (e) {
|
|
164
233
|
return res.status(400).json({ message: (e === null || e === void 0 ? void 0 : e.message) || 'Invalid settings' });
|
|
@@ -168,6 +237,8 @@ let QuotationController = class QuotationController {
|
|
|
168
237
|
async digestSendTest(ctx, res, body) {
|
|
169
238
|
if (denyUnlessAdmin(ctx, res, true))
|
|
170
239
|
return;
|
|
240
|
+
if (denyUnlessPremium(res, 'The weekly report'))
|
|
241
|
+
return;
|
|
171
242
|
const d = this.service.digest();
|
|
172
243
|
if (!d)
|
|
173
244
|
return res.status(503).json({ sent: false, to: null, reason: 'Weekly report not initialised' });
|
|
@@ -179,6 +250,8 @@ let QuotationController = class QuotationController {
|
|
|
179
250
|
(0, no_store_1.noStore)(res);
|
|
180
251
|
if (denyUnlessAdmin(ctx, res, false))
|
|
181
252
|
return;
|
|
253
|
+
if (denyUnlessPremium(res, 'The weekly report'))
|
|
254
|
+
return;
|
|
182
255
|
const mail = await this.service.digestPreview();
|
|
183
256
|
return res.type('html').send(mail.html);
|
|
184
257
|
}
|
|
@@ -400,20 +473,25 @@ let QuotationController = class QuotationController {
|
|
|
400
473
|
return res.status(400).json({ error: e.message });
|
|
401
474
|
}
|
|
402
475
|
}
|
|
403
|
-
/** Send (or re-send) the quote email.
|
|
476
|
+
/** Send (or re-send) the quote email. Free. */
|
|
404
477
|
async send(ctx, res, id) {
|
|
405
478
|
if (denyUnlessAdmin(ctx, res, true))
|
|
406
479
|
return;
|
|
407
|
-
|
|
480
|
+
const result = await this.service.sendQuote(Number(id), await this.actorLabel(ctx));
|
|
481
|
+
return res.status(result.ok ? 200 : 400).json(result);
|
|
482
|
+
}
|
|
483
|
+
/** The store shared the quote itself: open it for the customer without e-mailing. Free. */
|
|
484
|
+
async markSent(ctx, res, id) {
|
|
485
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
408
486
|
return;
|
|
409
|
-
const result = await this.service.
|
|
487
|
+
const result = await this.service.markSent(Number(id), await this.actorLabel(ctx));
|
|
410
488
|
return res.status(result.ok ? 200 : 400).json(result);
|
|
411
489
|
}
|
|
412
|
-
/** Convert an accepted quote to a draft order. Premium-gated. */
|
|
490
|
+
/** Convert an accepted quote to a draft order from the admin. Premium-gated (the pay link converts on its own, free). */
|
|
413
491
|
async convert(ctx, res, id) {
|
|
414
492
|
if (denyUnlessAdmin(ctx, res, true))
|
|
415
493
|
return;
|
|
416
|
-
if (denyUnlessPremium(res))
|
|
494
|
+
if (denyUnlessPremium(res, 'Converting quotes to draft orders from the admin'))
|
|
417
495
|
return;
|
|
418
496
|
const result = await this.service.convertToDraftOrder(ctx, Number(id), this.actor(ctx));
|
|
419
497
|
return res.status(result.ok ? 200 : 400).json(result);
|
|
@@ -440,13 +518,10 @@ let QuotationController = class QuotationController {
|
|
|
440
518
|
return;
|
|
441
519
|
return res.json(await this.service.searchCustomers(String(q || '')));
|
|
442
520
|
}
|
|
443
|
-
/** Send the quote email to a staff address for checking.
|
|
444
|
-
* like real sending (it exercises the same SMTP path). */
|
|
521
|
+
/** Send the quote email to a staff address for checking. Free. */
|
|
445
522
|
async testSend(ctx, res, id, body) {
|
|
446
523
|
if (denyUnlessAdmin(ctx, res, true))
|
|
447
524
|
return;
|
|
448
|
-
if (denyUnlessPremium(res))
|
|
449
|
-
return;
|
|
450
525
|
const to = String((body === null || body === void 0 ? void 0 : body.to) || '').trim();
|
|
451
526
|
if (!/.+@.+\..+/.test(to))
|
|
452
527
|
return res.status(400).json({ ok: false, reason: 'A valid email address is required' });
|
|
@@ -488,9 +563,272 @@ let QuotationController = class QuotationController {
|
|
|
488
563
|
return;
|
|
489
564
|
return res.json(await this.service.searchVariants(Number(channelId) || 1, String(q || '')));
|
|
490
565
|
}
|
|
566
|
+
// ── Admin: staff preview, PDF, 12-month report (free) ───────────────
|
|
567
|
+
/** The customer page as the customer sees it; not an opening, the accept form switched off. */
|
|
568
|
+
async staffPreview(ctx, res, id) {
|
|
569
|
+
(0, no_store_1.noStore)(res);
|
|
570
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
571
|
+
return;
|
|
572
|
+
const html = await this.service.staffPreviewHtml(Number(id));
|
|
573
|
+
if (!html)
|
|
574
|
+
return res.status(404).json({ error: 'not-found' });
|
|
575
|
+
return res.type('html').send(html);
|
|
576
|
+
}
|
|
577
|
+
async adminPdf(ctx, res, id) {
|
|
578
|
+
(0, no_store_1.noStore)(res);
|
|
579
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
580
|
+
return;
|
|
581
|
+
const out = await this.service.quotePdf(Number(id));
|
|
582
|
+
if (!out)
|
|
583
|
+
return res.status(404).json({ error: 'not-found' });
|
|
584
|
+
res.setHeader('Content-Disposition', `inline; filename="${out.filename}"`);
|
|
585
|
+
return res.type('application/pdf').send(out.pdf);
|
|
586
|
+
}
|
|
587
|
+
async monthly(ctx, res, channelId) {
|
|
588
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
589
|
+
return;
|
|
590
|
+
return res.json(await this.service.monthlyReport(channelId ? Number(channelId) : null));
|
|
591
|
+
}
|
|
592
|
+
// ── Admin: sales reports (premium) ──────────────────────────────────
|
|
593
|
+
async sales(ctx, res, from, to) {
|
|
594
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
595
|
+
return;
|
|
596
|
+
try {
|
|
597
|
+
const r = pro_service_1.QuotationProService.range(from, to);
|
|
598
|
+
return res.json({
|
|
599
|
+
from: r.fromDay, to: r.toDay,
|
|
600
|
+
byStaff: await this.pro.reportByStaff(r.from, r.to),
|
|
601
|
+
bySource: await this.pro.reportBySource(r.from, r.to),
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
catch (e) {
|
|
605
|
+
return fail(res, e);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
async salesCsv(ctx, res, from, to) {
|
|
609
|
+
(0, no_store_1.noStore)(res);
|
|
610
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
611
|
+
return;
|
|
612
|
+
try {
|
|
613
|
+
const r = pro_service_1.QuotationProService.range(from, to);
|
|
614
|
+
const csv = await this.pro.reportCsv(r.from, r.to);
|
|
615
|
+
res.setHeader('Content-Disposition', `attachment; filename="quotes-${r.fromDay}-to-${r.toDay}.csv"`);
|
|
616
|
+
return res.type('text/csv; charset=utf-8').send(csv);
|
|
617
|
+
}
|
|
618
|
+
catch (e) {
|
|
619
|
+
return fail(res, e);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
// ── Admin: premium settings (approvals, deposits, follow-ups, webhooks) ──
|
|
623
|
+
async proSettings(ctx, res) {
|
|
624
|
+
var _a;
|
|
625
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
626
|
+
return;
|
|
627
|
+
const settings = await this.pro.settings();
|
|
628
|
+
const canWrite = ctx.userHasPermissions([core_1.Permission.UpdateSettings]);
|
|
629
|
+
return res.json({
|
|
630
|
+
settings, premium: plugin_1.QuotationsPlugin.hasPremiumAccess(), webhookEvents: pro_settings_1.WEBHOOK_EVENTS,
|
|
631
|
+
// The signing secret is shown to administrators who can change settings only.
|
|
632
|
+
webhookSecret: canWrite && settings.webhooks.length ? await this.pro.webhookSecret() : null,
|
|
633
|
+
payLinks: { available: this.payments.available(), source: ((_a = this.payments.payLinkProvider()) === null || _a === void 0 ? void 0 : _a.source) || null },
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
async saveProSettings(ctx, res, body) {
|
|
637
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
638
|
+
return;
|
|
639
|
+
try {
|
|
640
|
+
const r = await this.pro.saveSettings(body || {});
|
|
641
|
+
return res.json({ ok: r.errors.length === 0, settings: r.settings, errors: r.errors });
|
|
642
|
+
}
|
|
643
|
+
catch (e) {
|
|
644
|
+
return fail(res, e);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
// ── Admin: templates (premium) ──────────────────────────────────────
|
|
648
|
+
async templates(ctx, res) {
|
|
649
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
650
|
+
return;
|
|
651
|
+
return res.json({ items: await this.pro.listTemplates(), premium: plugin_1.QuotationsPlugin.hasPremiumAccess() });
|
|
652
|
+
}
|
|
653
|
+
async saveTemplate(ctx, res, id, body) {
|
|
654
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
655
|
+
return;
|
|
656
|
+
try {
|
|
657
|
+
return res.json(await this.pro.saveTemplateFromQuote(Number(id), String((body === null || body === void 0 ? void 0 : body.name) || ''), await this.actorLabel(ctx)));
|
|
658
|
+
}
|
|
659
|
+
catch (e) {
|
|
660
|
+
return fail(res, e);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
async quoteFromTemplate(ctx, res, id, body) {
|
|
664
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
665
|
+
return;
|
|
666
|
+
try {
|
|
667
|
+
const me = ctx.activeUserId ? await this.service.staffForUser(Number(ctx.activeUserId)) : null;
|
|
668
|
+
return res.json(await this.pro.quoteFromTemplate(Number(id), Number(body === null || body === void 0 ? void 0 : body.channelId) || 1, await this.actorLabel(ctx), me || {}));
|
|
669
|
+
}
|
|
670
|
+
catch (e) {
|
|
671
|
+
return fail(res, e);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
async renameTemplate(ctx, res, id, body) {
|
|
675
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
676
|
+
return;
|
|
677
|
+
try {
|
|
678
|
+
await this.pro.renameTemplate(Number(id), String((body === null || body === void 0 ? void 0 : body.name) || ''));
|
|
679
|
+
return res.json({ ok: true });
|
|
680
|
+
}
|
|
681
|
+
catch (e) {
|
|
682
|
+
return fail(res, e);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
async deleteTemplate(ctx, res, id) {
|
|
686
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
687
|
+
return;
|
|
688
|
+
try {
|
|
689
|
+
await this.pro.deleteTemplate(Number(id));
|
|
690
|
+
return res.json({ ok: true });
|
|
691
|
+
}
|
|
692
|
+
catch (e) {
|
|
693
|
+
return fail(res, e);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
// ── Admin: discount approval (premium) ──────────────────────────────
|
|
697
|
+
async approval(ctx, res, id) {
|
|
698
|
+
var _a;
|
|
699
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
700
|
+
return;
|
|
701
|
+
try {
|
|
702
|
+
const info = await this.pro.approvalInfo(Number(id));
|
|
703
|
+
const me = ctx.activeUserId ? await this.service.staffForUser(Number(ctx.activeUserId)) : null;
|
|
704
|
+
const q = await this.service.getQuote(Number(id));
|
|
705
|
+
const decide = (0, approvals_1.canDecide)({
|
|
706
|
+
approverEmail: (me === null || me === void 0 ? void 0 : me.email) || '', isSuperAdmin: ctx.userHasPermissions([core_1.Permission.SuperAdmin]),
|
|
707
|
+
settings: await this.pro.settings(), preparerEmail: (q === null || q === void 0 ? void 0 : q.preparedByEmail) || ((_a = info.row) === null || _a === void 0 ? void 0 : _a.requestedBy) || '',
|
|
708
|
+
});
|
|
709
|
+
return res.json({ ...info, canDecide: decide.ok, cannotDecideReason: decide.ok ? null : decide.reason });
|
|
710
|
+
}
|
|
711
|
+
catch (e) {
|
|
712
|
+
return fail(res, e);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
async requestApproval(ctx, res, id) {
|
|
716
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
717
|
+
return;
|
|
718
|
+
try {
|
|
719
|
+
await this.pro.requestApproval(Number(id), await this.actorLabel(ctx));
|
|
720
|
+
return res.json({ ok: true });
|
|
721
|
+
}
|
|
722
|
+
catch (e) {
|
|
723
|
+
return fail(res, e);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
async decideApproval(ctx, res, id, body) {
|
|
727
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
728
|
+
return;
|
|
729
|
+
try {
|
|
730
|
+
const me = ctx.activeUserId ? await this.service.staffForUser(Number(ctx.activeUserId)) : null;
|
|
731
|
+
if (!(me === null || me === void 0 ? void 0 : me.email))
|
|
732
|
+
return res.status(403).json({ error: 'You are not an approver for discount approval.' });
|
|
733
|
+
await this.pro.decideApproval(Number(id), (body === null || body === void 0 ? void 0 : body.decision) === 'approve', String((body === null || body === void 0 ? void 0 : body.comment) || ''), { email: me.email, name: me.name, isSuperAdmin: ctx.userHasPermissions([core_1.Permission.SuperAdmin]) });
|
|
734
|
+
return res.json({ ok: true });
|
|
735
|
+
}
|
|
736
|
+
catch (e) {
|
|
737
|
+
return fail(res, e);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
async pendingApprovals(ctx, res) {
|
|
741
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
742
|
+
return;
|
|
743
|
+
return res.json({ items: await this.pro.pendingApprovals() });
|
|
744
|
+
}
|
|
745
|
+
// ── Admin: webhooks (premium) ───────────────────────────────────────
|
|
746
|
+
async webhookLog(ctx, res) {
|
|
747
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
748
|
+
return;
|
|
749
|
+
return res.json({ items: await this.pro.webhookLog(100) });
|
|
750
|
+
}
|
|
751
|
+
async webhookTest(ctx, res, hookId) {
|
|
752
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
753
|
+
return;
|
|
754
|
+
try {
|
|
755
|
+
const row = await this.pro.testWebhook(String(hookId));
|
|
756
|
+
if (!row)
|
|
757
|
+
return res.status(404).json({ error: 'Webhook not found' });
|
|
758
|
+
return res.json(row);
|
|
759
|
+
}
|
|
760
|
+
catch (e) {
|
|
761
|
+
return fail(res, e);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
async webhookRetry(ctx, res, id) {
|
|
765
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
766
|
+
return;
|
|
767
|
+
try {
|
|
768
|
+
return res.json({ ok: await this.pro.retryWebhook(Number(id)) });
|
|
769
|
+
}
|
|
770
|
+
catch (e) {
|
|
771
|
+
return fail(res, e);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
async webhookSecret(ctx, res) {
|
|
775
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
776
|
+
return;
|
|
777
|
+
try {
|
|
778
|
+
return res.json({ secret: await this.pro.regenerateWebhookSecret() });
|
|
779
|
+
}
|
|
780
|
+
catch (e) {
|
|
781
|
+
return fail(res, e);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
// ── Admin: pay links (free) and deposits (premium) ──────────────────
|
|
785
|
+
async payment(ctx, res, id) {
|
|
786
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
787
|
+
return;
|
|
788
|
+
try {
|
|
789
|
+
return res.json(await this.payments.adminInfo(Number(id)));
|
|
790
|
+
}
|
|
791
|
+
catch (e) {
|
|
792
|
+
return fail(res, e);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
async payLink(ctx, res, id, body) {
|
|
796
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
797
|
+
return;
|
|
798
|
+
const r = await this.payments.createPayLink(Number(id), await this.actorLabel(ctx), { email: !!(body === null || body === void 0 ? void 0 : body.email) });
|
|
799
|
+
return res.status(r.ok ? 200 : 400).json(r);
|
|
800
|
+
}
|
|
801
|
+
async payLinkEmail(ctx, res, id) {
|
|
802
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
803
|
+
return;
|
|
804
|
+
const r = await this.payments.emailPayLink(Number(id), await this.actorLabel(ctx));
|
|
805
|
+
return res.status(r.ok ? 200 : 400).json(r);
|
|
806
|
+
}
|
|
807
|
+
async deposit(ctx, res, id, body) {
|
|
808
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
809
|
+
return;
|
|
810
|
+
try {
|
|
811
|
+
await this.payments.setDepositOverride(Number(id), String((body === null || body === void 0 ? void 0 : body.mode) || ''), body === null || body === void 0 ? void 0 : body.pct);
|
|
812
|
+
return res.json(await this.payments.adminInfo(Number(id)));
|
|
813
|
+
}
|
|
814
|
+
catch (e) {
|
|
815
|
+
return fail(res, e);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
async balance(ctx, res, id, body) {
|
|
819
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
820
|
+
return;
|
|
821
|
+
const r = await this.payments.createBalance(Number(id), await this.actorLabel(ctx), { email: !!(body === null || body === void 0 ? void 0 : body.email) });
|
|
822
|
+
return res.status(r.ok ? 200 : 400).json(r);
|
|
823
|
+
}
|
|
491
824
|
actor(ctx) {
|
|
492
825
|
return String(ctx.activeUserId || 'admin');
|
|
493
826
|
}
|
|
827
|
+
/** The administrator's e-mail address for the trail (falls back to the user id). */
|
|
828
|
+
async actorLabel(ctx) {
|
|
829
|
+
const me = ctx.activeUserId ? await this.service.staffForUser(Number(ctx.activeUserId)).catch(() => null) : null;
|
|
830
|
+
return (me === null || me === void 0 ? void 0 : me.email) || this.actor(ctx);
|
|
831
|
+
}
|
|
494
832
|
};
|
|
495
833
|
exports.QuotationController = QuotationController;
|
|
496
834
|
__decorate([
|
|
@@ -501,6 +839,23 @@ __decorate([
|
|
|
501
839
|
__metadata("design:paramtypes", [String, Object]),
|
|
502
840
|
__metadata("design:returntype", Promise)
|
|
503
841
|
], QuotationController.prototype, "publicQuote", null);
|
|
842
|
+
__decorate([
|
|
843
|
+
(0, common_1.Get)('quote/:token/pdf'),
|
|
844
|
+
__param(0, (0, common_1.Req)()),
|
|
845
|
+
__param(1, (0, common_1.Param)('token')),
|
|
846
|
+
__param(2, (0, common_1.Res)()),
|
|
847
|
+
__metadata("design:type", Function),
|
|
848
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
849
|
+
__metadata("design:returntype", Promise)
|
|
850
|
+
], QuotationController.prototype, "publicPdf", null);
|
|
851
|
+
__decorate([
|
|
852
|
+
(0, common_1.Get)('my'),
|
|
853
|
+
__param(0, (0, core_1.Ctx)()),
|
|
854
|
+
__param(1, (0, common_1.Res)()),
|
|
855
|
+
__metadata("design:type", Function),
|
|
856
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
857
|
+
__metadata("design:returntype", Promise)
|
|
858
|
+
], QuotationController.prototype, "myQuotes", null);
|
|
504
859
|
__decorate([
|
|
505
860
|
(0, common_1.Post)('quote/:token'),
|
|
506
861
|
__param(0, (0, common_1.Param)('token')),
|
|
@@ -512,11 +867,12 @@ __decorate([
|
|
|
512
867
|
], QuotationController.prototype, "publicRespond", null);
|
|
513
868
|
__decorate([
|
|
514
869
|
(0, common_1.Post)('request'),
|
|
515
|
-
__param(0, (0,
|
|
516
|
-
__param(1, (0, common_1.
|
|
517
|
-
__param(2, (0, common_1.
|
|
870
|
+
__param(0, (0, core_1.Ctx)()),
|
|
871
|
+
__param(1, (0, common_1.Req)()),
|
|
872
|
+
__param(2, (0, common_1.Body)()),
|
|
873
|
+
__param(3, (0, common_1.Res)()),
|
|
518
874
|
__metadata("design:type", Function),
|
|
519
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
875
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, Object, Object]),
|
|
520
876
|
__metadata("design:returntype", Promise)
|
|
521
877
|
], QuotationController.prototype, "publicRequest", null);
|
|
522
878
|
__decorate([
|
|
@@ -746,6 +1102,15 @@ __decorate([
|
|
|
746
1102
|
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
747
1103
|
__metadata("design:returntype", Promise)
|
|
748
1104
|
], QuotationController.prototype, "send", null);
|
|
1105
|
+
__decorate([
|
|
1106
|
+
(0, common_1.Post)('quotes/:id/mark-sent'),
|
|
1107
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1108
|
+
__param(1, (0, common_1.Res)()),
|
|
1109
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1110
|
+
__metadata("design:type", Function),
|
|
1111
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1112
|
+
__metadata("design:returntype", Promise)
|
|
1113
|
+
], QuotationController.prototype, "markSent", null);
|
|
749
1114
|
__decorate([
|
|
750
1115
|
(0, common_1.Post)('quotes/:id/convert'),
|
|
751
1116
|
__param(0, (0, core_1.Ctx)()),
|
|
@@ -839,8 +1204,237 @@ __decorate([
|
|
|
839
1204
|
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, String]),
|
|
840
1205
|
__metadata("design:returntype", Promise)
|
|
841
1206
|
], QuotationController.prototype, "variants", null);
|
|
1207
|
+
__decorate([
|
|
1208
|
+
(0, common_1.Get)('quotes/:id/page'),
|
|
1209
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1210
|
+
__param(1, (0, common_1.Res)()),
|
|
1211
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1212
|
+
__metadata("design:type", Function),
|
|
1213
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1214
|
+
__metadata("design:returntype", Promise)
|
|
1215
|
+
], QuotationController.prototype, "staffPreview", null);
|
|
1216
|
+
__decorate([
|
|
1217
|
+
(0, common_1.Get)('quotes/:id/pdf'),
|
|
1218
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1219
|
+
__param(1, (0, common_1.Res)()),
|
|
1220
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1221
|
+
__metadata("design:type", Function),
|
|
1222
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1223
|
+
__metadata("design:returntype", Promise)
|
|
1224
|
+
], QuotationController.prototype, "adminPdf", null);
|
|
1225
|
+
__decorate([
|
|
1226
|
+
(0, common_1.Get)('reports/monthly'),
|
|
1227
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1228
|
+
__param(1, (0, common_1.Res)()),
|
|
1229
|
+
__param(2, (0, common_1.Query)('channelId')),
|
|
1230
|
+
__metadata("design:type", Function),
|
|
1231
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1232
|
+
__metadata("design:returntype", Promise)
|
|
1233
|
+
], QuotationController.prototype, "monthly", null);
|
|
1234
|
+
__decorate([
|
|
1235
|
+
(0, common_1.Get)('reports/sales'),
|
|
1236
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1237
|
+
__param(1, (0, common_1.Res)()),
|
|
1238
|
+
__param(2, (0, common_1.Query)('from')),
|
|
1239
|
+
__param(3, (0, common_1.Query)('to')),
|
|
1240
|
+
__metadata("design:type", Function),
|
|
1241
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, String]),
|
|
1242
|
+
__metadata("design:returntype", Promise)
|
|
1243
|
+
], QuotationController.prototype, "sales", null);
|
|
1244
|
+
__decorate([
|
|
1245
|
+
(0, common_1.Get)('reports/sales-csv'),
|
|
1246
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1247
|
+
__param(1, (0, common_1.Res)()),
|
|
1248
|
+
__param(2, (0, common_1.Query)('from')),
|
|
1249
|
+
__param(3, (0, common_1.Query)('to')),
|
|
1250
|
+
__metadata("design:type", Function),
|
|
1251
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, String]),
|
|
1252
|
+
__metadata("design:returntype", Promise)
|
|
1253
|
+
], QuotationController.prototype, "salesCsv", null);
|
|
1254
|
+
__decorate([
|
|
1255
|
+
(0, common_1.Get)('pro/settings'),
|
|
1256
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1257
|
+
__param(1, (0, common_1.Res)()),
|
|
1258
|
+
__metadata("design:type", Function),
|
|
1259
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
1260
|
+
__metadata("design:returntype", Promise)
|
|
1261
|
+
], QuotationController.prototype, "proSettings", null);
|
|
1262
|
+
__decorate([
|
|
1263
|
+
(0, common_1.Post)('pro/settings'),
|
|
1264
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1265
|
+
__param(1, (0, common_1.Res)()),
|
|
1266
|
+
__param(2, (0, common_1.Body)()),
|
|
1267
|
+
__metadata("design:type", Function),
|
|
1268
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, Object]),
|
|
1269
|
+
__metadata("design:returntype", Promise)
|
|
1270
|
+
], QuotationController.prototype, "saveProSettings", null);
|
|
1271
|
+
__decorate([
|
|
1272
|
+
(0, common_1.Get)('templates'),
|
|
1273
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1274
|
+
__param(1, (0, common_1.Res)()),
|
|
1275
|
+
__metadata("design:type", Function),
|
|
1276
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
1277
|
+
__metadata("design:returntype", Promise)
|
|
1278
|
+
], QuotationController.prototype, "templates", null);
|
|
1279
|
+
__decorate([
|
|
1280
|
+
(0, common_1.Post)('quotes/:id/save-template'),
|
|
1281
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1282
|
+
__param(1, (0, common_1.Res)()),
|
|
1283
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1284
|
+
__param(3, (0, common_1.Body)()),
|
|
1285
|
+
__metadata("design:type", Function),
|
|
1286
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, Object]),
|
|
1287
|
+
__metadata("design:returntype", Promise)
|
|
1288
|
+
], QuotationController.prototype, "saveTemplate", null);
|
|
1289
|
+
__decorate([
|
|
1290
|
+
(0, common_1.Post)('templates/:id/new-quote'),
|
|
1291
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1292
|
+
__param(1, (0, common_1.Res)()),
|
|
1293
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1294
|
+
__param(3, (0, common_1.Body)()),
|
|
1295
|
+
__metadata("design:type", Function),
|
|
1296
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, Object]),
|
|
1297
|
+
__metadata("design:returntype", Promise)
|
|
1298
|
+
], QuotationController.prototype, "quoteFromTemplate", null);
|
|
1299
|
+
__decorate([
|
|
1300
|
+
(0, common_1.Put)('templates/:id'),
|
|
1301
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1302
|
+
__param(1, (0, common_1.Res)()),
|
|
1303
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1304
|
+
__param(3, (0, common_1.Body)()),
|
|
1305
|
+
__metadata("design:type", Function),
|
|
1306
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, Object]),
|
|
1307
|
+
__metadata("design:returntype", Promise)
|
|
1308
|
+
], QuotationController.prototype, "renameTemplate", null);
|
|
1309
|
+
__decorate([
|
|
1310
|
+
(0, common_1.Delete)('templates/:id'),
|
|
1311
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1312
|
+
__param(1, (0, common_1.Res)()),
|
|
1313
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1314
|
+
__metadata("design:type", Function),
|
|
1315
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1316
|
+
__metadata("design:returntype", Promise)
|
|
1317
|
+
], QuotationController.prototype, "deleteTemplate", null);
|
|
1318
|
+
__decorate([
|
|
1319
|
+
(0, common_1.Get)('quotes/:id/approval'),
|
|
1320
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1321
|
+
__param(1, (0, common_1.Res)()),
|
|
1322
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1323
|
+
__metadata("design:type", Function),
|
|
1324
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1325
|
+
__metadata("design:returntype", Promise)
|
|
1326
|
+
], QuotationController.prototype, "approval", null);
|
|
1327
|
+
__decorate([
|
|
1328
|
+
(0, common_1.Post)('quotes/:id/approval/request'),
|
|
1329
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1330
|
+
__param(1, (0, common_1.Res)()),
|
|
1331
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1332
|
+
__metadata("design:type", Function),
|
|
1333
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1334
|
+
__metadata("design:returntype", Promise)
|
|
1335
|
+
], QuotationController.prototype, "requestApproval", null);
|
|
1336
|
+
__decorate([
|
|
1337
|
+
(0, common_1.Post)('quotes/:id/approval/decide'),
|
|
1338
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1339
|
+
__param(1, (0, common_1.Res)()),
|
|
1340
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1341
|
+
__param(3, (0, common_1.Body)()),
|
|
1342
|
+
__metadata("design:type", Function),
|
|
1343
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, Object]),
|
|
1344
|
+
__metadata("design:returntype", Promise)
|
|
1345
|
+
], QuotationController.prototype, "decideApproval", null);
|
|
1346
|
+
__decorate([
|
|
1347
|
+
(0, common_1.Get)('approvals/pending'),
|
|
1348
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1349
|
+
__param(1, (0, common_1.Res)()),
|
|
1350
|
+
__metadata("design:type", Function),
|
|
1351
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
1352
|
+
__metadata("design:returntype", Promise)
|
|
1353
|
+
], QuotationController.prototype, "pendingApprovals", null);
|
|
1354
|
+
__decorate([
|
|
1355
|
+
(0, common_1.Get)('webhooks/log'),
|
|
1356
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1357
|
+
__param(1, (0, common_1.Res)()),
|
|
1358
|
+
__metadata("design:type", Function),
|
|
1359
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
1360
|
+
__metadata("design:returntype", Promise)
|
|
1361
|
+
], QuotationController.prototype, "webhookLog", null);
|
|
1362
|
+
__decorate([
|
|
1363
|
+
(0, common_1.Post)('webhooks/:hookId/test'),
|
|
1364
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1365
|
+
__param(1, (0, common_1.Res)()),
|
|
1366
|
+
__param(2, (0, common_1.Param)('hookId')),
|
|
1367
|
+
__metadata("design:type", Function),
|
|
1368
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1369
|
+
__metadata("design:returntype", Promise)
|
|
1370
|
+
], QuotationController.prototype, "webhookTest", null);
|
|
1371
|
+
__decorate([
|
|
1372
|
+
(0, common_1.Post)('webhooks/log/:id/retry'),
|
|
1373
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1374
|
+
__param(1, (0, common_1.Res)()),
|
|
1375
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1376
|
+
__metadata("design:type", Function),
|
|
1377
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1378
|
+
__metadata("design:returntype", Promise)
|
|
1379
|
+
], QuotationController.prototype, "webhookRetry", null);
|
|
1380
|
+
__decorate([
|
|
1381
|
+
(0, common_1.Post)('webhooks/secret/regenerate'),
|
|
1382
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1383
|
+
__param(1, (0, common_1.Res)()),
|
|
1384
|
+
__metadata("design:type", Function),
|
|
1385
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
1386
|
+
__metadata("design:returntype", Promise)
|
|
1387
|
+
], QuotationController.prototype, "webhookSecret", null);
|
|
1388
|
+
__decorate([
|
|
1389
|
+
(0, common_1.Get)('quotes/:id/payment'),
|
|
1390
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1391
|
+
__param(1, (0, common_1.Res)()),
|
|
1392
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1393
|
+
__metadata("design:type", Function),
|
|
1394
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1395
|
+
__metadata("design:returntype", Promise)
|
|
1396
|
+
], QuotationController.prototype, "payment", null);
|
|
1397
|
+
__decorate([
|
|
1398
|
+
(0, common_1.Post)('quotes/:id/pay-link'),
|
|
1399
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1400
|
+
__param(1, (0, common_1.Res)()),
|
|
1401
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1402
|
+
__param(3, (0, common_1.Body)()),
|
|
1403
|
+
__metadata("design:type", Function),
|
|
1404
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, Object]),
|
|
1405
|
+
__metadata("design:returntype", Promise)
|
|
1406
|
+
], QuotationController.prototype, "payLink", null);
|
|
1407
|
+
__decorate([
|
|
1408
|
+
(0, common_1.Post)('quotes/:id/pay-link/email'),
|
|
1409
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1410
|
+
__param(1, (0, common_1.Res)()),
|
|
1411
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1412
|
+
__metadata("design:type", Function),
|
|
1413
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String]),
|
|
1414
|
+
__metadata("design:returntype", Promise)
|
|
1415
|
+
], QuotationController.prototype, "payLinkEmail", null);
|
|
1416
|
+
__decorate([
|
|
1417
|
+
(0, common_1.Post)('quotes/:id/deposit'),
|
|
1418
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1419
|
+
__param(1, (0, common_1.Res)()),
|
|
1420
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1421
|
+
__param(3, (0, common_1.Body)()),
|
|
1422
|
+
__metadata("design:type", Function),
|
|
1423
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, Object]),
|
|
1424
|
+
__metadata("design:returntype", Promise)
|
|
1425
|
+
], QuotationController.prototype, "deposit", null);
|
|
1426
|
+
__decorate([
|
|
1427
|
+
(0, common_1.Post)('quotes/:id/balance'),
|
|
1428
|
+
__param(0, (0, core_1.Ctx)()),
|
|
1429
|
+
__param(1, (0, common_1.Res)()),
|
|
1430
|
+
__param(2, (0, common_1.Param)('id')),
|
|
1431
|
+
__param(3, (0, common_1.Body)()),
|
|
1432
|
+
__metadata("design:type", Function),
|
|
1433
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, Object]),
|
|
1434
|
+
__metadata("design:returntype", Promise)
|
|
1435
|
+
], QuotationController.prototype, "balance", null);
|
|
842
1436
|
exports.QuotationController = QuotationController = __decorate([
|
|
843
1437
|
(0, common_1.Controller)('quotations'),
|
|
844
|
-
__metadata("design:paramtypes", [quotation_service_1.QuotationService])
|
|
1438
|
+
__metadata("design:paramtypes", [quotation_service_1.QuotationService, pro_service_1.QuotationProService, payment_service_1.QuotationPaymentService])
|
|
845
1439
|
], QuotationController);
|
|
846
1440
|
//# sourceMappingURL=quotation.controller.js.map
|