@huloglobal/vendure-plugin-quotations 0.8.6 → 0.10.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 +115 -0
- package/README.md +123 -9
- 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/email-layout.d.ts +104 -0
- package/dist/email-layout.d.ts.map +1 -0
- package/dist/email-layout.js +250 -0
- package/dist/email-layout.js.map +1 -0
- package/dist/emails.d.ts +57 -0
- package/dist/emails.d.ts.map +1 -0
- package/dist/emails.js +124 -0
- package/dist/emails.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 +479 -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 +9 -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 +749 -0
- package/dist/pro.service.js.map +1 -0
- package/dist/quotation.controller.d.ts +54 -8
- package/dist/quotation.controller.d.ts.map +1 -1
- package/dist/quotation.controller.js +626 -32
- package/dist/quotation.controller.js.map +1 -1
- package/dist/quotation.service.d.ts +192 -12
- package/dist/quotation.service.d.ts.map +1 -1
- package/dist/quotation.service.js +648 -103
- package/dist/quotation.service.js.map +1 -1
- package/dist/rate-limit.d.ts +15 -0
- package/dist/rate-limit.d.ts.map +1 -0
- package/dist/rate-limit.js +35 -0
- package/dist/rate-limit.js.map +1 -0
- package/dist/templates.d.ts +12 -3
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +15 -38
- package/dist/templates.js.map +1 -1
- package/dist/types.d.ts +13 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -4
- 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 +7 -6
- package/ui/components/quotations.component.ts +328 -19
|
@@ -17,7 +17,12 @@ const common_1 = require("@nestjs/common");
|
|
|
17
17
|
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
|
+
const rate_limit_1 = require("./rate-limit");
|
|
20
21
|
const quotation_service_1 = require("./quotation.service");
|
|
22
|
+
const pro_service_1 = require("./pro.service");
|
|
23
|
+
const payment_service_1 = require("./payment.service");
|
|
24
|
+
const pro_settings_1 = require("./pro-settings");
|
|
25
|
+
const approvals_1 = require("./approvals");
|
|
21
26
|
const plugin_1 = require("./plugin");
|
|
22
27
|
const templates_1 = require("./templates");
|
|
23
28
|
const PLUGIN_ID = 'vendure-plugin-quotations';
|
|
@@ -31,31 +36,83 @@ function denyUnlessAdmin(ctx, res, write) {
|
|
|
31
36
|
return false;
|
|
32
37
|
}
|
|
33
38
|
/** Premium = licensed OR inside the 14-day evaluation. */
|
|
34
|
-
function denyUnlessPremium(res) {
|
|
39
|
+
function denyUnlessPremium(res, feature = 'This feature') {
|
|
35
40
|
if (plugin_1.QuotationsPlugin.hasPremiumAccess())
|
|
36
41
|
return false;
|
|
37
42
|
res.status(402).json({
|
|
38
43
|
error: 'licence-required',
|
|
39
|
-
message:
|
|
44
|
+
message: `${feature} needs a licence (or the 14-day evaluation). Quoting, sending, reminders and pay links stay free.`,
|
|
40
45
|
buyUrl: BUY_URL,
|
|
41
46
|
});
|
|
42
47
|
return true;
|
|
43
48
|
}
|
|
49
|
+
/** Map a thrown error to a response: a premium refusal is a 402, everything else a 400. */
|
|
50
|
+
function fail(res, e) {
|
|
51
|
+
if (e instanceof pro_service_1.PremiumRequired) {
|
|
52
|
+
return res.status(402).json({ error: 'licence-required', message: e.message, buyUrl: BUY_URL });
|
|
53
|
+
}
|
|
54
|
+
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' });
|
|
55
|
+
}
|
|
56
|
+
/** Public routes, per client address and sliding minute. */
|
|
57
|
+
const PDF_PER_MINUTE = 20;
|
|
58
|
+
/** Quote page views (a customer re-opening their quote, a printer, a link preview). */
|
|
59
|
+
const PAGE_PER_MINUTE = 120;
|
|
60
|
+
/** Accept / decline posts: a person needs a handful; more is guessing tokens or a loop. */
|
|
61
|
+
const RESPOND_PER_MINUTE = 20;
|
|
44
62
|
let QuotationController = class QuotationController {
|
|
45
|
-
constructor(service) {
|
|
63
|
+
constructor(service, pro, payments) {
|
|
46
64
|
this.service = service;
|
|
65
|
+
this.pro = pro;
|
|
66
|
+
this.payments = payments;
|
|
67
|
+
/** Exposed for tests. */
|
|
68
|
+
this.limiter = new rate_limit_1.HitLimiter();
|
|
69
|
+
}
|
|
70
|
+
pdfAllowed(key) {
|
|
71
|
+
return this.limiter.allow('pdf', key, PDF_PER_MINUTE);
|
|
47
72
|
}
|
|
48
73
|
// ── Public: the customer quote page ────────────────────────────────
|
|
49
|
-
async publicQuote(token, res) {
|
|
74
|
+
async publicQuote(req, token, res) {
|
|
50
75
|
(0, no_store_1.noStore)(res);
|
|
76
|
+
if (!this.limiter.allow('page', req.ip || 'unknown', PAGE_PER_MINUTE))
|
|
77
|
+
return res.status(429).type('text').send('Too many requests — try again in a minute.');
|
|
51
78
|
const q = await this.service.markViewed(String(token || ''));
|
|
52
79
|
if (!q || q.status === 'draft' || q.status === 'requested')
|
|
53
80
|
return res.status(404).type('html').send(this.notFoundHtml());
|
|
54
81
|
const cfg = await this.service.getConfig(q.channelId);
|
|
55
|
-
return res.type('html').send((0, templates_1.renderQuotePage)(q, cfg));
|
|
82
|
+
return res.type('html').send((0, templates_1.renderQuotePage)(q, cfg, { extra: await this.service.pageExtras(q) }));
|
|
83
|
+
}
|
|
84
|
+
/** The quote as a PDF, from the customer link. Does not count as opening the quote. */
|
|
85
|
+
async publicPdf(req, token, res) {
|
|
86
|
+
(0, no_store_1.noStore)(res);
|
|
87
|
+
if (!this.pdfAllowed(req.ip || 'unknown'))
|
|
88
|
+
return res.status(429).type('text').send('Too many downloads — try again in a minute.');
|
|
89
|
+
const q = await this.service.getQuoteByToken(String(token || ''));
|
|
90
|
+
if (!q || q.status === 'draft' || q.status === 'requested')
|
|
91
|
+
return res.status(404).type('html').send(this.notFoundHtml());
|
|
92
|
+
const out = await this.service.quotePdf(Number(q.id));
|
|
93
|
+
if (!out)
|
|
94
|
+
return res.status(404).type('html').send(this.notFoundHtml());
|
|
95
|
+
res.setHeader('Content-Disposition', `inline; filename="${out.filename}"`);
|
|
96
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
97
|
+
return res.type('application/pdf').send(out.pdf);
|
|
98
|
+
}
|
|
99
|
+
// ── Storefront: "My quotes" for the signed-in customer ──────────────
|
|
100
|
+
/**
|
|
101
|
+
* The signed-in customer's quotes on this channel (shop session cookie or
|
|
102
|
+
* bearer token, channel from the `vendure-token` header). Each row has the
|
|
103
|
+
* quote link, the PDF link and, when one is due, the pay link.
|
|
104
|
+
*/
|
|
105
|
+
async myQuotes(ctx, res) {
|
|
106
|
+
(0, no_store_1.noStore)(res);
|
|
107
|
+
const customerId = await this.service.customerIdForUser(ctx.activeUserId);
|
|
108
|
+
if (!customerId)
|
|
109
|
+
return res.status(401).json({ error: 'not-signed-in', message: 'Sign in to see your quotes.' });
|
|
110
|
+
return res.json({ items: await this.service.quotesForCustomer(customerId, Number(ctx.channelId) || null) });
|
|
56
111
|
}
|
|
57
|
-
async publicRespond(token, body, res) {
|
|
112
|
+
async publicRespond(req, token, body, res) {
|
|
58
113
|
(0, no_store_1.noStore)(res);
|
|
114
|
+
if (!this.limiter.allow('respond', req.ip || 'unknown', RESPOND_PER_MINUTE))
|
|
115
|
+
return res.status(429).type('text').send('Too many attempts — try again in a minute.');
|
|
59
116
|
const action = (body === null || body === void 0 ? void 0 : body.action) === 'decline' ? 'decline' : 'accept';
|
|
60
117
|
const result = await this.service.respond(String(token || ''), action, String((body === null || body === void 0 ? void 0 : body.name) || ''), String((body === null || body === void 0 ? void 0 : body.comment) || ''), String((body === null || body === void 0 ? void 0 : body.v) || ''));
|
|
61
118
|
const q = result.quote || (await this.service.getQuoteByToken(String(token || '')));
|
|
@@ -64,22 +121,27 @@ let QuotationController = class QuotationController {
|
|
|
64
121
|
const cfg = await this.service.getConfig(q.channelId);
|
|
65
122
|
return res.type('html').send((0, templates_1.renderQuotePage)(q, cfg, {
|
|
66
123
|
message: result.ok
|
|
67
|
-
? (action === 'accept'
|
|
124
|
+
? (action === 'accept'
|
|
125
|
+
? (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.')
|
|
126
|
+
: 'Thanks for letting us know.')
|
|
68
127
|
: result.reason,
|
|
69
128
|
done: result.ok,
|
|
129
|
+
extra: await this.service.pageExtras(q),
|
|
70
130
|
}));
|
|
71
131
|
}
|
|
72
132
|
// ── Public: customer-initiated quote requests ───────────────────────
|
|
73
133
|
/** Storefronts POST here (JSON). Channel from the `vendure-token` header
|
|
74
134
|
* or `channelToken` in the body; falls back to the default channel. */
|
|
75
|
-
async publicRequest(req, body, res) {
|
|
135
|
+
async publicRequest(ctx, req, body, res) {
|
|
76
136
|
var _a;
|
|
77
137
|
const token = String(req.headers['vendure-token'] || (body === null || body === void 0 ? void 0 : body.channelToken) || '');
|
|
78
138
|
const channelId = await this.service.channelIdForToken(token);
|
|
79
139
|
// req.ip is already the client address (the host trusts its proxy); a header any client can set is not.
|
|
80
140
|
const clientKey = req.ip || String((body === null || body === void 0 ? void 0 : body.email) || '');
|
|
81
141
|
try {
|
|
82
|
-
|
|
142
|
+
// A signed-in storefront customer's request is linked to their account ("My quotes").
|
|
143
|
+
const customerId = await this.service.customerIdForUser(ctx === null || ctx === void 0 ? void 0 : ctx.activeUserId).catch(() => null);
|
|
144
|
+
const result = await this.service.createRequest(channelId, body || {}, clientKey, customerId);
|
|
83
145
|
if (!result.ok)
|
|
84
146
|
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
147
|
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 +185,20 @@ let QuotationController = class QuotationController {
|
|
|
123
185
|
return plugin_1.QuotationsPlugin.isLicensed() ? 'paid' : (((_a = plugin_1.QuotationsPlugin.getEvalState()) === null || _a === void 0 ? void 0 : _a.active) ? 'trial' : 'free');
|
|
124
186
|
}
|
|
125
187
|
// ── Admin: set-up checklist, weekly report, dashboard widget ───────
|
|
188
|
+
/** The set-up checklist is premium: without premium it reports nothing to do (and the card stays hidden). */
|
|
126
189
|
async setup(ctx, res) {
|
|
127
190
|
if (denyUnlessAdmin(ctx, res, false))
|
|
128
191
|
return;
|
|
192
|
+
if (!plugin_1.QuotationsPlugin.hasPremiumAccess())
|
|
193
|
+
return res.json({ items: [], complete: true, locked: true });
|
|
129
194
|
return res.json(await this.service.setupChecklist());
|
|
130
195
|
}
|
|
131
196
|
/** Dismiss an optional checklist item (only the ones marked dismissible). */
|
|
132
197
|
async setupDismiss(ctx, res, body) {
|
|
133
198
|
if (denyUnlessAdmin(ctx, res, true))
|
|
134
199
|
return;
|
|
200
|
+
if (denyUnlessPremium(res, 'The set-up checklist'))
|
|
201
|
+
return;
|
|
135
202
|
const ok = await this.service.dismissSetupItem(String((body === null || body === void 0 ? void 0 : body.key) || ''));
|
|
136
203
|
if (!ok)
|
|
137
204
|
return res.status(400).json({ ok: false, message: 'That item cannot be dismissed' });
|
|
@@ -143,7 +210,7 @@ let QuotationController = class QuotationController {
|
|
|
143
210
|
const d = this.service.digest();
|
|
144
211
|
if (!d)
|
|
145
212
|
return res.status(503).json({ message: 'Weekly report not initialised' });
|
|
146
|
-
return res.json(await d.settings());
|
|
213
|
+
return res.json({ ...(await d.settings()), premium: plugin_1.QuotationsPlugin.hasPremiumAccess() });
|
|
147
214
|
}
|
|
148
215
|
async digestUpdate(ctx, res, body) {
|
|
149
216
|
var _a;
|
|
@@ -158,7 +225,7 @@ let QuotationController = class QuotationController {
|
|
|
158
225
|
if (body && 'recipient' in body)
|
|
159
226
|
patch.recipient = body.recipient === null ? null : String((_a = body.recipient) !== null && _a !== void 0 ? _a : '');
|
|
160
227
|
try {
|
|
161
|
-
return res.json(await d.updateSettings(patch));
|
|
228
|
+
return res.json({ ...(await d.updateSettings(patch)), premium: plugin_1.QuotationsPlugin.hasPremiumAccess() });
|
|
162
229
|
}
|
|
163
230
|
catch (e) {
|
|
164
231
|
return res.status(400).json({ message: (e === null || e === void 0 ? void 0 : e.message) || 'Invalid settings' });
|
|
@@ -168,6 +235,8 @@ let QuotationController = class QuotationController {
|
|
|
168
235
|
async digestSendTest(ctx, res, body) {
|
|
169
236
|
if (denyUnlessAdmin(ctx, res, true))
|
|
170
237
|
return;
|
|
238
|
+
if (denyUnlessPremium(res, 'The weekly report'))
|
|
239
|
+
return;
|
|
171
240
|
const d = this.service.digest();
|
|
172
241
|
if (!d)
|
|
173
242
|
return res.status(503).json({ sent: false, to: null, reason: 'Weekly report not initialised' });
|
|
@@ -179,6 +248,8 @@ let QuotationController = class QuotationController {
|
|
|
179
248
|
(0, no_store_1.noStore)(res);
|
|
180
249
|
if (denyUnlessAdmin(ctx, res, false))
|
|
181
250
|
return;
|
|
251
|
+
if (denyUnlessPremium(res, 'The weekly report'))
|
|
252
|
+
return;
|
|
182
253
|
const mail = await this.service.digestPreview();
|
|
183
254
|
return res.type('html').send(mail.html);
|
|
184
255
|
}
|
|
@@ -400,20 +471,25 @@ let QuotationController = class QuotationController {
|
|
|
400
471
|
return res.status(400).json({ error: e.message });
|
|
401
472
|
}
|
|
402
473
|
}
|
|
403
|
-
/** Send (or re-send) the quote email.
|
|
474
|
+
/** Send (or re-send) the quote email. Free. */
|
|
404
475
|
async send(ctx, res, id) {
|
|
405
476
|
if (denyUnlessAdmin(ctx, res, true))
|
|
406
477
|
return;
|
|
407
|
-
|
|
478
|
+
const result = await this.service.sendQuote(Number(id), await this.actorLabel(ctx));
|
|
479
|
+
return res.status(result.ok ? 200 : 400).json(result);
|
|
480
|
+
}
|
|
481
|
+
/** The store shared the quote itself: open it for the customer without e-mailing. Free. */
|
|
482
|
+
async markSent(ctx, res, id) {
|
|
483
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
408
484
|
return;
|
|
409
|
-
const result = await this.service.
|
|
485
|
+
const result = await this.service.markSent(Number(id), await this.actorLabel(ctx));
|
|
410
486
|
return res.status(result.ok ? 200 : 400).json(result);
|
|
411
487
|
}
|
|
412
|
-
/** Convert an accepted quote to a draft order. Premium-gated. */
|
|
488
|
+
/** Convert an accepted quote to a draft order from the admin. Premium-gated (the pay link converts on its own, free). */
|
|
413
489
|
async convert(ctx, res, id) {
|
|
414
490
|
if (denyUnlessAdmin(ctx, res, true))
|
|
415
491
|
return;
|
|
416
|
-
if (denyUnlessPremium(res))
|
|
492
|
+
if (denyUnlessPremium(res, 'Converting quotes to draft orders from the admin'))
|
|
417
493
|
return;
|
|
418
494
|
const result = await this.service.convertToDraftOrder(ctx, Number(id), this.actor(ctx));
|
|
419
495
|
return res.status(result.ok ? 200 : 400).json(result);
|
|
@@ -440,13 +516,10 @@ let QuotationController = class QuotationController {
|
|
|
440
516
|
return;
|
|
441
517
|
return res.json(await this.service.searchCustomers(String(q || '')));
|
|
442
518
|
}
|
|
443
|
-
/** Send the quote email to a staff address for checking.
|
|
444
|
-
* like real sending (it exercises the same SMTP path). */
|
|
519
|
+
/** Send the quote email to a staff address for checking. Free. */
|
|
445
520
|
async testSend(ctx, res, id, body) {
|
|
446
521
|
if (denyUnlessAdmin(ctx, res, true))
|
|
447
522
|
return;
|
|
448
|
-
if (denyUnlessPremium(res))
|
|
449
|
-
return;
|
|
450
523
|
const to = String((body === null || body === void 0 ? void 0 : body.to) || '').trim();
|
|
451
524
|
if (!/.+@.+\..+/.test(to))
|
|
452
525
|
return res.status(400).json({ ok: false, reason: 'A valid email address is required' });
|
|
@@ -488,35 +561,318 @@ let QuotationController = class QuotationController {
|
|
|
488
561
|
return;
|
|
489
562
|
return res.json(await this.service.searchVariants(Number(channelId) || 1, String(q || '')));
|
|
490
563
|
}
|
|
564
|
+
// ── Admin: staff preview, PDF, 12-month report (free) ───────────────
|
|
565
|
+
/** The customer page as the customer sees it; not an opening, the accept form switched off. */
|
|
566
|
+
async staffPreview(ctx, res, id) {
|
|
567
|
+
(0, no_store_1.noStore)(res);
|
|
568
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
569
|
+
return;
|
|
570
|
+
const html = await this.service.staffPreviewHtml(Number(id));
|
|
571
|
+
if (!html)
|
|
572
|
+
return res.status(404).json({ error: 'not-found' });
|
|
573
|
+
return res.type('html').send(html);
|
|
574
|
+
}
|
|
575
|
+
async adminPdf(ctx, res, id) {
|
|
576
|
+
(0, no_store_1.noStore)(res);
|
|
577
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
578
|
+
return;
|
|
579
|
+
const out = await this.service.quotePdf(Number(id));
|
|
580
|
+
if (!out)
|
|
581
|
+
return res.status(404).json({ error: 'not-found' });
|
|
582
|
+
res.setHeader('Content-Disposition', `inline; filename="${out.filename}"`);
|
|
583
|
+
return res.type('application/pdf').send(out.pdf);
|
|
584
|
+
}
|
|
585
|
+
async monthly(ctx, res, channelId) {
|
|
586
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
587
|
+
return;
|
|
588
|
+
return res.json(await this.service.monthlyReport(channelId ? Number(channelId) : null));
|
|
589
|
+
}
|
|
590
|
+
// ── Admin: sales reports (premium) ──────────────────────────────────
|
|
591
|
+
async sales(ctx, res, from, to) {
|
|
592
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
593
|
+
return;
|
|
594
|
+
try {
|
|
595
|
+
const r = pro_service_1.QuotationProService.range(from, to);
|
|
596
|
+
return res.json({
|
|
597
|
+
from: r.fromDay, to: r.toDay,
|
|
598
|
+
byStaff: await this.pro.reportByStaff(r.from, r.to),
|
|
599
|
+
bySource: await this.pro.reportBySource(r.from, r.to),
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
catch (e) {
|
|
603
|
+
return fail(res, e);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
async salesCsv(ctx, res, from, to) {
|
|
607
|
+
(0, no_store_1.noStore)(res);
|
|
608
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
609
|
+
return;
|
|
610
|
+
try {
|
|
611
|
+
const r = pro_service_1.QuotationProService.range(from, to);
|
|
612
|
+
const csv = await this.pro.reportCsv(r.from, r.to);
|
|
613
|
+
res.setHeader('Content-Disposition', `attachment; filename="quotes-${r.fromDay}-to-${r.toDay}.csv"`);
|
|
614
|
+
return res.type('text/csv; charset=utf-8').send(csv);
|
|
615
|
+
}
|
|
616
|
+
catch (e) {
|
|
617
|
+
return fail(res, e);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
// ── Admin: premium settings (approvals, deposits, follow-ups, webhooks) ──
|
|
621
|
+
async proSettings(ctx, res) {
|
|
622
|
+
var _a;
|
|
623
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
624
|
+
return;
|
|
625
|
+
const settings = await this.pro.settings();
|
|
626
|
+
const canWrite = ctx.userHasPermissions([core_1.Permission.UpdateSettings]);
|
|
627
|
+
return res.json({
|
|
628
|
+
settings, premium: plugin_1.QuotationsPlugin.hasPremiumAccess(), webhookEvents: pro_settings_1.WEBHOOK_EVENTS,
|
|
629
|
+
// The signing secret is shown to administrators who can change settings only.
|
|
630
|
+
webhookSecret: canWrite && settings.webhooks.length ? await this.pro.webhookSecret() : null,
|
|
631
|
+
payLinks: { available: this.payments.available(), source: ((_a = this.payments.payLinkProvider()) === null || _a === void 0 ? void 0 : _a.source) || null },
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
async saveProSettings(ctx, res, body) {
|
|
635
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
636
|
+
return;
|
|
637
|
+
try {
|
|
638
|
+
const r = await this.pro.saveSettings(body || {});
|
|
639
|
+
return res.json({ ok: r.errors.length === 0, settings: r.settings, errors: r.errors });
|
|
640
|
+
}
|
|
641
|
+
catch (e) {
|
|
642
|
+
return fail(res, e);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
// ── Admin: templates (premium) ──────────────────────────────────────
|
|
646
|
+
async templates(ctx, res) {
|
|
647
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
648
|
+
return;
|
|
649
|
+
return res.json({ items: await this.pro.listTemplates(), premium: plugin_1.QuotationsPlugin.hasPremiumAccess() });
|
|
650
|
+
}
|
|
651
|
+
async saveTemplate(ctx, res, id, body) {
|
|
652
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
653
|
+
return;
|
|
654
|
+
try {
|
|
655
|
+
return res.json(await this.pro.saveTemplateFromQuote(Number(id), String((body === null || body === void 0 ? void 0 : body.name) || ''), await this.actorLabel(ctx)));
|
|
656
|
+
}
|
|
657
|
+
catch (e) {
|
|
658
|
+
return fail(res, e);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
async quoteFromTemplate(ctx, res, id, body) {
|
|
662
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
663
|
+
return;
|
|
664
|
+
try {
|
|
665
|
+
const me = ctx.activeUserId ? await this.service.staffForUser(Number(ctx.activeUserId)) : null;
|
|
666
|
+
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 || {}));
|
|
667
|
+
}
|
|
668
|
+
catch (e) {
|
|
669
|
+
return fail(res, e);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
async renameTemplate(ctx, res, id, body) {
|
|
673
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
674
|
+
return;
|
|
675
|
+
try {
|
|
676
|
+
await this.pro.renameTemplate(Number(id), String((body === null || body === void 0 ? void 0 : body.name) || ''));
|
|
677
|
+
return res.json({ ok: true });
|
|
678
|
+
}
|
|
679
|
+
catch (e) {
|
|
680
|
+
return fail(res, e);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
async deleteTemplate(ctx, res, id) {
|
|
684
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
685
|
+
return;
|
|
686
|
+
try {
|
|
687
|
+
await this.pro.deleteTemplate(Number(id));
|
|
688
|
+
return res.json({ ok: true });
|
|
689
|
+
}
|
|
690
|
+
catch (e) {
|
|
691
|
+
return fail(res, e);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
// ── Admin: discount approval (premium) ──────────────────────────────
|
|
695
|
+
async approval(ctx, res, id) {
|
|
696
|
+
var _a;
|
|
697
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
698
|
+
return;
|
|
699
|
+
try {
|
|
700
|
+
const info = await this.pro.approvalInfo(Number(id));
|
|
701
|
+
const me = ctx.activeUserId ? await this.service.staffForUser(Number(ctx.activeUserId)) : null;
|
|
702
|
+
const q = await this.service.getQuote(Number(id));
|
|
703
|
+
const decide = (0, approvals_1.canDecide)({
|
|
704
|
+
approverEmail: (me === null || me === void 0 ? void 0 : me.email) || '', isSuperAdmin: ctx.userHasPermissions([core_1.Permission.SuperAdmin]),
|
|
705
|
+
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) || '',
|
|
706
|
+
});
|
|
707
|
+
return res.json({ ...info, canDecide: decide.ok, cannotDecideReason: decide.ok ? null : decide.reason });
|
|
708
|
+
}
|
|
709
|
+
catch (e) {
|
|
710
|
+
return fail(res, e);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
async requestApproval(ctx, res, id) {
|
|
714
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
715
|
+
return;
|
|
716
|
+
try {
|
|
717
|
+
await this.pro.requestApproval(Number(id), await this.actorLabel(ctx));
|
|
718
|
+
return res.json({ ok: true });
|
|
719
|
+
}
|
|
720
|
+
catch (e) {
|
|
721
|
+
return fail(res, e);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
async decideApproval(ctx, res, id, body) {
|
|
725
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
726
|
+
return;
|
|
727
|
+
try {
|
|
728
|
+
const me = ctx.activeUserId ? await this.service.staffForUser(Number(ctx.activeUserId)) : null;
|
|
729
|
+
if (!(me === null || me === void 0 ? void 0 : me.email))
|
|
730
|
+
return res.status(403).json({ error: 'You are not an approver for discount approval.' });
|
|
731
|
+
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]) });
|
|
732
|
+
return res.json({ ok: true });
|
|
733
|
+
}
|
|
734
|
+
catch (e) {
|
|
735
|
+
return fail(res, e);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
async pendingApprovals(ctx, res) {
|
|
739
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
740
|
+
return;
|
|
741
|
+
return res.json({ items: await this.pro.pendingApprovals() });
|
|
742
|
+
}
|
|
743
|
+
// ── Admin: webhooks (premium) ───────────────────────────────────────
|
|
744
|
+
async webhookLog(ctx, res) {
|
|
745
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
746
|
+
return;
|
|
747
|
+
return res.json({ items: await this.pro.webhookLog(100) });
|
|
748
|
+
}
|
|
749
|
+
async webhookTest(ctx, res, hookId) {
|
|
750
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
751
|
+
return;
|
|
752
|
+
try {
|
|
753
|
+
const row = await this.pro.testWebhook(String(hookId));
|
|
754
|
+
if (!row)
|
|
755
|
+
return res.status(404).json({ error: 'Webhook not found' });
|
|
756
|
+
return res.json(row);
|
|
757
|
+
}
|
|
758
|
+
catch (e) {
|
|
759
|
+
return fail(res, e);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
async webhookRetry(ctx, res, id) {
|
|
763
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
764
|
+
return;
|
|
765
|
+
try {
|
|
766
|
+
return res.json({ ok: await this.pro.retryWebhook(Number(id)) });
|
|
767
|
+
}
|
|
768
|
+
catch (e) {
|
|
769
|
+
return fail(res, e);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
async webhookSecret(ctx, res) {
|
|
773
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
774
|
+
return;
|
|
775
|
+
try {
|
|
776
|
+
return res.json({ secret: await this.pro.regenerateWebhookSecret() });
|
|
777
|
+
}
|
|
778
|
+
catch (e) {
|
|
779
|
+
return fail(res, e);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
// ── Admin: pay links (free) and deposits (premium) ──────────────────
|
|
783
|
+
async payment(ctx, res, id) {
|
|
784
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
785
|
+
return;
|
|
786
|
+
try {
|
|
787
|
+
return res.json(await this.payments.adminInfo(Number(id)));
|
|
788
|
+
}
|
|
789
|
+
catch (e) {
|
|
790
|
+
return fail(res, e);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
async payLink(ctx, res, id, body) {
|
|
794
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
795
|
+
return;
|
|
796
|
+
const r = await this.payments.createPayLink(Number(id), await this.actorLabel(ctx), { email: !!(body === null || body === void 0 ? void 0 : body.email) });
|
|
797
|
+
return res.status(r.ok ? 200 : 400).json(r);
|
|
798
|
+
}
|
|
799
|
+
async payLinkEmail(ctx, res, id) {
|
|
800
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
801
|
+
return;
|
|
802
|
+
const r = await this.payments.emailPayLink(Number(id), await this.actorLabel(ctx));
|
|
803
|
+
return res.status(r.ok ? 200 : 400).json(r);
|
|
804
|
+
}
|
|
805
|
+
async deposit(ctx, res, id, body) {
|
|
806
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
807
|
+
return;
|
|
808
|
+
try {
|
|
809
|
+
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);
|
|
810
|
+
return res.json(await this.payments.adminInfo(Number(id)));
|
|
811
|
+
}
|
|
812
|
+
catch (e) {
|
|
813
|
+
return fail(res, e);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
async balance(ctx, res, id, body) {
|
|
817
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
818
|
+
return;
|
|
819
|
+
const r = await this.payments.createBalance(Number(id), await this.actorLabel(ctx), { email: !!(body === null || body === void 0 ? void 0 : body.email) });
|
|
820
|
+
return res.status(r.ok ? 200 : 400).json(r);
|
|
821
|
+
}
|
|
491
822
|
actor(ctx) {
|
|
492
823
|
return String(ctx.activeUserId || 'admin');
|
|
493
824
|
}
|
|
825
|
+
/** The administrator's e-mail address for the trail (falls back to the user id). */
|
|
826
|
+
async actorLabel(ctx) {
|
|
827
|
+
const me = ctx.activeUserId ? await this.service.staffForUser(Number(ctx.activeUserId)).catch(() => null) : null;
|
|
828
|
+
return (me === null || me === void 0 ? void 0 : me.email) || this.actor(ctx);
|
|
829
|
+
}
|
|
494
830
|
};
|
|
495
831
|
exports.QuotationController = QuotationController;
|
|
496
832
|
__decorate([
|
|
497
833
|
(0, common_1.Get)('quote/:token'),
|
|
498
|
-
__param(0, (0, common_1.
|
|
499
|
-
__param(1, (0, common_1.
|
|
834
|
+
__param(0, (0, common_1.Req)()),
|
|
835
|
+
__param(1, (0, common_1.Param)('token')),
|
|
836
|
+
__param(2, (0, common_1.Res)()),
|
|
500
837
|
__metadata("design:type", Function),
|
|
501
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
838
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
502
839
|
__metadata("design:returntype", Promise)
|
|
503
840
|
], QuotationController.prototype, "publicQuote", null);
|
|
504
841
|
__decorate([
|
|
505
|
-
(0, common_1.
|
|
506
|
-
__param(0, (0, common_1.
|
|
507
|
-
__param(1, (0, common_1.
|
|
842
|
+
(0, common_1.Get)('quote/:token/pdf'),
|
|
843
|
+
__param(0, (0, common_1.Req)()),
|
|
844
|
+
__param(1, (0, common_1.Param)('token')),
|
|
508
845
|
__param(2, (0, common_1.Res)()),
|
|
509
846
|
__metadata("design:type", Function),
|
|
510
|
-
__metadata("design:paramtypes", [
|
|
847
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
848
|
+
__metadata("design:returntype", Promise)
|
|
849
|
+
], QuotationController.prototype, "publicPdf", null);
|
|
850
|
+
__decorate([
|
|
851
|
+
(0, common_1.Get)('my'),
|
|
852
|
+
__param(0, (0, core_1.Ctx)()),
|
|
853
|
+
__param(1, (0, common_1.Res)()),
|
|
854
|
+
__metadata("design:type", Function),
|
|
855
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
856
|
+
__metadata("design:returntype", Promise)
|
|
857
|
+
], QuotationController.prototype, "myQuotes", null);
|
|
858
|
+
__decorate([
|
|
859
|
+
(0, common_1.Post)('quote/:token'),
|
|
860
|
+
__param(0, (0, common_1.Req)()),
|
|
861
|
+
__param(1, (0, common_1.Param)('token')),
|
|
862
|
+
__param(2, (0, common_1.Body)()),
|
|
863
|
+
__param(3, (0, common_1.Res)()),
|
|
864
|
+
__metadata("design:type", Function),
|
|
865
|
+
__metadata("design:paramtypes", [Object, String, Object, Object]),
|
|
511
866
|
__metadata("design:returntype", Promise)
|
|
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
|