@huloglobal/vendure-plugin-quotations 0.7.2 → 0.8.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 +21 -0
- package/README.md +49 -2
- package/dist/crons.d.ts.map +1 -1
- package/dist/crons.js +19 -1
- package/dist/crons.js.map +1 -1
- package/dist/plugin.d.ts +7 -3
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +43 -15
- package/dist/plugin.js.map +1 -1
- package/dist/quotation.controller.d.ts +12 -0
- package/dist/quotation.controller.d.ts.map +1 -1
- package/dist/quotation.controller.js +150 -5
- package/dist/quotation.controller.js.map +1 -1
- package/dist/quotation.service.d.ts +70 -2
- package/dist/quotation.service.d.ts.map +1 -1
- package/dist/quotation.service.js +231 -12
- package/dist/quotation.service.js.map +1 -1
- package/package.json +2 -2
- package/ui/components/quotations-widget.component.ts +55 -0
- package/ui/components/quotations.component.ts +198 -7
- package/ui/quotations-nav.module.ts +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ documented here. The format follows
|
|
|
5
5
|
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project
|
|
6
6
|
adheres to [semantic versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.8.0] — 2026-10-11
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Weekly report**: every Monday at 08:00 server time the plugin emails quotes created, sent and accepted, value won, storefront requests and win rate for the week against the week before, with up to three next steps. Settings → Weekly report: on/off, recipient (defaults to the channel notify or reply-to address, then the licence email, then the trial-reminder address), Send me a test, Preview. Uses the plugin's SMTP settings; worker-only, once per install across workers. Endpoints `GET|POST /quotations/digest/settings`, `POST /quotations/digest/send-test`, `GET /quotations/digest/preview`.
|
|
12
|
+
- **Set-up checklist** at the top of the Quotes tab with real checks (SMTP reachable, reply-to/notify address, business name or logo, storefront requests arriving or dismissed, first quote sent); `GET /quotations/setup`, `POST /quotations/setup/dismiss`.
|
|
13
|
+
- **Dashboard widget** (Dashboard → Add widget → Quotations): quotes sent, accepted and value won for the last 7 days, the licence notice when one applies, and a link to the page; `GET /quotations/widget`.
|
|
14
|
+
- **Help drawer** in the page header: New quote → Send → Convert.
|
|
15
|
+
- **Value won · 30d** KPI next to the win rate (quotes accepted in the last 30 days).
|
|
16
|
+
- Licence banners show the lifecycle notice (trial ending, key expiring, evaluation ended) in an amber strip, the premium feature list on trial and free installs, and the 30-day figures ("So far: …"). `meta` / `licence/status` gain `notice`, `premiumFeatures`, `recentStats` and `buyUrl`.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Usage stats sent with the evaluation reminders and the daily heartbeat now cover the last 30 days under the keys `quotesCreated`, `quotesSent`, `quotesAccepted`, `valueWonPence`, `requestsReceived`, `winRatePct` (counts and totals only). Licensed installs keep reporting via the heartbeat.
|
|
20
|
+
- 402 responses carry the buy URL `https://elite.charity/licence/buy/vendure-plugin-quotations`; the admin UI renders any licence-required error as one sentence pointing at the banner.
|
|
21
|
+
- The address given for the evaluation reminder is remembered (plugin pref `eval.leadEmail`) as the report's last-resort recipient.
|
|
22
|
+
- Requires `@huloglobal/vendure-licence-sdk` ^0.15.0. New shared table `hulo_plugin_prefs` (created on boot; shared by all HULO plugins).
|
|
23
|
+
|
|
24
|
+
## [0.7.3] — 2026-09-28
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
- The hourly cron had no deadline: one stalled pass (seen on ELITE: stuck from noon, every later hour logged "previous run still in progress") blocked expiry and chasers until a restart. A pass now has a 15-minute deadline; on timeout it is logged with the step it was in and the single-flight guard is released. Chaser sends are conditional updates, so a late completion cannot double-send.
|
|
28
|
+
|
|
8
29
|
## [0.7.2] — 2026-09-28
|
|
9
30
|
|
|
10
31
|
### Changed
|
package/README.md
CHANGED
|
@@ -15,8 +15,9 @@ End-to-end quotation engine for [Vendure](https://www.vendure.io/):
|
|
|
15
15
|
a basket, product page or form, and it lands in your inbox pre-priced.
|
|
16
16
|
|
|
17
17
|
Works on MySQL, MariaDB and PostgreSQL. Admin UI included (Quotes,
|
|
18
|
-
editor with catalogue search, Settings
|
|
19
|
-
|
|
18
|
+
editor with catalogue search, Settings, a Help drawer and a set-up
|
|
19
|
+
checklist), a dashboard widget, and a weekly report by email. Licence
|
|
20
|
+
activation in the admin, one-click in-app updates.
|
|
20
21
|
|
|
21
22
|
Catalogue search in the editor reads Vendure's search index once the
|
|
22
23
|
channel has been indexed (the default search plugin's `search_index_item`
|
|
@@ -79,6 +80,52 @@ free-text lines, then **Send to customer**. Turn requests off per channel in
|
|
|
79
80
|
Settings. Requests are throttled (10 an hour per client) and a hidden
|
|
80
81
|
`website` field discards bots.
|
|
81
82
|
|
|
83
|
+
## Admin UI
|
|
84
|
+
|
|
85
|
+
**Sales → Quotations** (requires the `ReadSettings` permission; writes need
|
|
86
|
+
`UpdateSettings`). The page has three tabs — Quotes (inbox, KPIs, detail
|
|
87
|
+
and activity trail), the step-by-step editor, and Settings — plus a
|
|
88
|
+
**Help** button in the header that opens a three-step drawer (New quote →
|
|
89
|
+
Send → Convert).
|
|
90
|
+
|
|
91
|
+
**Dashboard → Add widget → Quotations** adds a card with the last 7 days'
|
|
92
|
+
quotes sent, accepted and value won, the licence notice when one applies,
|
|
93
|
+
and a link into the page.
|
|
94
|
+
|
|
95
|
+
## Weekly report, setup checklist and dashboard widget
|
|
96
|
+
|
|
97
|
+
**Set-up checklist.** The top of the Quotes tab shows what is left to do,
|
|
98
|
+
each item checked against the real state: an email server reachable
|
|
99
|
+
(`SMTP_*` env or the `smtp` option), a reply-to or notify address saved
|
|
100
|
+
for a channel, your business name or logo saved, quote requests arriving
|
|
101
|
+
from the storefront (or dismissed, if you only quote by hand) and the
|
|
102
|
+
first quote sent. **Hide** collapses it; it disappears for good once every
|
|
103
|
+
item is done and comes back if one becomes undone.
|
|
104
|
+
|
|
105
|
+
**Weekly report.** Every **Monday at 08:00** (server-local time) the
|
|
106
|
+
plugin emails one short report for the week just gone: quotes created,
|
|
107
|
+
sent and accepted, value won from accepted quotes, storefront requests
|
|
108
|
+
received and the win rate on quotes sent, each against the previous week,
|
|
109
|
+
plus up to three next steps taken from the checklist. The numbers are the
|
|
110
|
+
same ones the plugin reports anonymously to the licence server (counts
|
|
111
|
+
and totals only, never customer data).
|
|
112
|
+
|
|
113
|
+
- Recipient: **Settings → Weekly report**. Left empty it goes to the first
|
|
114
|
+
channel's notify address, else its reply-to address, else the email on
|
|
115
|
+
your licence, else the address you gave for the trial reminder.
|
|
116
|
+
- Turn it off with the switch on the same card; **Send me a test** sends
|
|
117
|
+
the week-to-date report now, **Preview** opens it in a new tab.
|
|
118
|
+
- It uses the same SMTP settings as quote emails (`SMTP_SERVER`,
|
|
119
|
+
`SMTP_PORT`, `SMTP_USER`, `SMTP_PASSWORD`, `SMTP_FROM` or `smtp` in
|
|
120
|
+
`init()`); without them nothing is sent and the test button says why.
|
|
121
|
+
- Runs on the worker only, once per install however many workers you run;
|
|
122
|
+
`disableCron: true` also disables it.
|
|
123
|
+
|
|
124
|
+
Endpoints (admin session): `GET /quotations/setup`,
|
|
125
|
+
`POST /quotations/setup/dismiss`, `GET|POST /quotations/digest/settings`,
|
|
126
|
+
`POST /quotations/digest/send-test`, `GET /quotations/digest/preview`,
|
|
127
|
+
`GET /quotations/widget`.
|
|
128
|
+
|
|
82
129
|
## Licensing
|
|
83
130
|
|
|
84
131
|
Unlicensed installs run in the free tier; the 14-day free trial (card required) is started from the admin banner. Afterwards the
|
package/dist/crons.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crons.d.ts","sourceRoot":"","sources":["../src/crons.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,cAAc,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"crons.d.ts","sourceRoot":"","sources":["../src/crons.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,cAAc,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAQvD,qBACa,cAAc;IACX,OAAO,CAAC,OAAO;IAAoB,OAAO,CAAC,cAAc;gBAAjD,OAAO,EAAE,gBAAgB,EAAU,cAAc,EAAE,cAAc;IAErF;;6DAEyD;IACzD,OAAO,CAAC,WAAW,CAAS;IAE5B;+EAC2E;IAErE,MAAM;CA+Bf"}
|
package/dist/crons.js
CHANGED
|
@@ -16,6 +16,8 @@ const core_1 = require("@vendure/core");
|
|
|
16
16
|
const quotation_service_1 = require("./quotation.service");
|
|
17
17
|
const plugin_1 = require("./plugin");
|
|
18
18
|
const loggerCtx = 'Quotations';
|
|
19
|
+
/** Upper bound for one hourly pass; a stuck pass is logged and the guard released. */
|
|
20
|
+
const HOURLY_DEADLINE_MS = 15 * 60000;
|
|
19
21
|
let QuotationCrons = class QuotationCrons {
|
|
20
22
|
constructor(service, processContext) {
|
|
21
23
|
this.service = service;
|
|
@@ -37,16 +39,32 @@ let QuotationCrons = class QuotationCrons {
|
|
|
37
39
|
return;
|
|
38
40
|
}
|
|
39
41
|
this.runInFlight = true;
|
|
40
|
-
|
|
42
|
+
// A run that never returns (a stalled SMTP or DB call) must not block
|
|
43
|
+
// every later hour: give it a deadline, log it, and free the guard.
|
|
44
|
+
// The chaser sends are per-quote conditional updates, so a late
|
|
45
|
+
// completion cannot double-send.
|
|
46
|
+
let step = 'expireOverdue';
|
|
47
|
+
const run = (async () => {
|
|
41
48
|
await this.service.expireOverdue();
|
|
42
49
|
if (plugin_1.QuotationsPlugin.hasPremiumAccess()) {
|
|
50
|
+
step = 'runChasers';
|
|
43
51
|
const r = await this.service.runChasers();
|
|
44
52
|
if (r.chasers || r.expiryReminders) {
|
|
45
53
|
core_1.Logger.info(`sent ${r.chasers} chaser(s) + ${r.expiryReminders} expiry reminder(s)`, loggerCtx);
|
|
46
54
|
}
|
|
47
55
|
}
|
|
56
|
+
})();
|
|
57
|
+
let timer;
|
|
58
|
+
const deadline = new Promise((_, reject) => { timer = setTimeout(() => reject(new Error(`hourly run exceeded ${HOURLY_DEADLINE_MS / 60000} min in ${step}`)), HOURLY_DEADLINE_MS); });
|
|
59
|
+
try {
|
|
60
|
+
await Promise.race([run, deadline]);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
core_1.Logger.error(`quotations hourly run failed: ${(e === null || e === void 0 ? void 0 : e.message) || e}`, loggerCtx);
|
|
48
64
|
}
|
|
49
65
|
finally {
|
|
66
|
+
if (timer)
|
|
67
|
+
clearTimeout(timer);
|
|
50
68
|
this.runInFlight = false;
|
|
51
69
|
}
|
|
52
70
|
}
|
package/dist/crons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crons.js","sourceRoot":"","sources":["../src/crons.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAAwD;AACxD,wCAAuD;AACvD,2DAAuD;AACvD,qCAAwD;AAExD,MAAM,SAAS,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"crons.js","sourceRoot":"","sources":["../src/crons.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAAwD;AACxD,wCAAuD;AACvD,2DAAuD;AACvD,qCAAwD;AAExD,MAAM,SAAS,GAAG,YAAY,CAAC;AAE/B,sFAAsF;AACtF,MAAM,kBAAkB,GAAG,EAAE,GAAG,KAAM,CAAC;AAGhC,IAAM,cAAc,GAApB,MAAM,cAAc;IACvB,YAAoB,OAAyB,EAAU,cAA8B;QAAjE,YAAO,GAAP,OAAO,CAAkB;QAAU,mBAAc,GAAd,cAAc,CAAgB;QAErF;;iEAEyD;QACjD,gBAAW,GAAG,KAAK,CAAC;IAL4D,CAAC;IAOzF;+EAC2E;IAErE,AAAN,KAAK,CAAC,MAAM;QACR,IAAI,IAAI,CAAC,cAA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AC;QACxC,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YACd,aAAM,CAAC,KAAK,CAAC,iCAAiC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,KAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAChF,CAAC;gBAAS,CAAC;YACP,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAC7B,CAAC;IACL,CAAC;CACJ,CAAA;AA1CY,wCAAc;AAWjB;IADL,IAAA,eAAI,EAAC,yBAAc,CAAC,UAAU,CAAC;;;;4CA+B/B;yBAzCQ,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAEoB,oCAAgB,EAA0B,qBAAc;GAD5E,cAAc,CA0C1B"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type } from '@vendure/core';
|
|
1
|
+
import { ProcessContext, Type } from '@vendure/core';
|
|
2
2
|
import { LicenceStatus, UpdateChecker, EvaluationState } from '@huloglobal/vendure-licence-sdk';
|
|
3
3
|
import { QuotationService } from './quotation.service';
|
|
4
4
|
import { QuotationsPluginOptions } from './types';
|
|
@@ -21,6 +21,7 @@ export declare function getOptions(): QuotationsInitOptions;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare class QuotationsPlugin {
|
|
23
23
|
private service;
|
|
24
|
+
private processContext;
|
|
24
25
|
private static revocation;
|
|
25
26
|
private static updateChecker;
|
|
26
27
|
private static heartbeat;
|
|
@@ -37,6 +38,8 @@ export declare class QuotationsPlugin {
|
|
|
37
38
|
* evaluation window get the full feature set. */
|
|
38
39
|
static hasPremiumAccess(): boolean;
|
|
39
40
|
private static licenceHost;
|
|
41
|
+
/** The key currently in force (env/init, admin-activated or claim-installed) — what the heartbeat reports. */
|
|
42
|
+
private static activeLicenceKey;
|
|
40
43
|
/** Verify + apply a licence key at runtime (admin-UI activation).
|
|
41
44
|
* Identical checks to boot-time verification: signature, pluginId,
|
|
42
45
|
* domain binding, expiry, revocation list. Only applied when valid. */
|
|
@@ -45,9 +48,10 @@ export declare class QuotationsPlugin {
|
|
|
45
48
|
* (an env/init key, if any, is re-verified by the caller flow) and
|
|
46
49
|
* the evaluation clock resumes from wherever the server says it is. */
|
|
47
50
|
static deactivateRuntimeLicence(): void;
|
|
48
|
-
constructor(service: QuotationService);
|
|
51
|
+
constructor(service: QuotationService, processContext: ProcessContext);
|
|
49
52
|
/** Apply an admin-activated licence key persisted in the DB. Runs
|
|
50
|
-
* after DI is up; an explicitly configured env/init key wins.
|
|
53
|
+
* after DI is up; an explicitly configured env/init key wins. Then
|
|
54
|
+
* starts the weekly report scheduler on the worker. */
|
|
51
55
|
onApplicationBootstrap(): Promise<void>;
|
|
52
56
|
static init(options?: QuotationsInitOptions): Type<QuotationsPlugin>;
|
|
53
57
|
static uiExtensions: {
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,IAAI,EAAiB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AACxF,OAAO,EAC8B,aAAa,EAAqB,aAAa,EACpB,eAAe,EAC9E,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAmBlD,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB;IAClE;;6EAEyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,wBAAgB,UAAU,IAAI,qBAAqB,CAA0B;AAE7E;;;;;;;;;GASG;AACH,qBAMa,gBAAgB;IA2Db,OAAO,CAAC,OAAO;IAAoB,OAAO,CAAC,cAAc;IA1DrE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAkC;IAC3D,OAAO,CAAC,MAAM,CAAC,aAAa,CAA8B;IAC1D,OAAO,CAAC,MAAM,CAAC,SAAS,CAA0B;IAClD,OAAO,CAAC,MAAM,CAAC,aAAa,CAA8B;IAC1D,OAAO,CAAC,MAAM,CAAC,UAAU,CAAiC;IAE1D,MAAM,CAAC,gBAAgB;IACvB,MAAM,CAAC,iBAAiB;IACxB,MAAM,CAAC,cAAc;IACrB,MAAM,CAAC,gBAAgB;IACvB,MAAM,CAAC,UAAU,IAAI,OAAO;IAC5B,MAAM,CAAC,YAAY,IAAI,eAAe,GAAG,IAAI;IAC7C,MAAM,CAAC,iBAAiB,IAAI,MAAM,GAAG,IAAI;IACzC;sDACkD;IAClD,MAAM,CAAC,gBAAgB,IAAI,OAAO;IAMlC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAM;IAChC,8GAA8G;IAC9G,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAuB;IAEtD;;4EAEwE;IACxE,MAAM,CAAC,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa;IAazD;;4EAEwE;IACxE,MAAM,CAAC,wBAAwB,IAAI,IAAI;gBAcnB,OAAO,EAAE,gBAAgB,EAAU,cAAc,EAAE,cAAc;IAkBrF;;4DAEwD;IAClD,sBAAsB;IAe5B,MAAM,CAAC,IAAI,CAAC,OAAO,GAAE,qBAA0B,GAAG,IAAI,CAAC,gBAAgB,CAAC;IAwCxE,MAAM,CAAC,YAAY;;;;;;;;;;;;;MAMjB;CACL"}
|
package/dist/plugin.js
CHANGED
|
@@ -71,6 +71,7 @@ let QuotationsPlugin = QuotationsPlugin_1 = class QuotationsPlugin {
|
|
|
71
71
|
});
|
|
72
72
|
if (status.valid) {
|
|
73
73
|
QuotationsPlugin_1.licenceStatus = status;
|
|
74
|
+
QuotationsPlugin_1.activeLicenceKey = key;
|
|
74
75
|
(_b = QuotationsPlugin_1.evalClient) === null || _b === void 0 ? void 0 : _b.stop();
|
|
75
76
|
}
|
|
76
77
|
return status;
|
|
@@ -83,6 +84,7 @@ let QuotationsPlugin = QuotationsPlugin_1 = class QuotationsPlugin {
|
|
|
83
84
|
valid: false,
|
|
84
85
|
message: 'No licence key configured. The plugin will run in unlicensed (degraded) mode.',
|
|
85
86
|
};
|
|
87
|
+
QuotationsPlugin_1.activeLicenceKey = null;
|
|
86
88
|
if (QuotationsPlugin_1.evalClient) {
|
|
87
89
|
QuotationsPlugin_1.evalClient.start();
|
|
88
90
|
}
|
|
@@ -91,26 +93,45 @@ let QuotationsPlugin = QuotationsPlugin_1 = class QuotationsPlugin {
|
|
|
91
93
|
QuotationsPlugin_1.evalClient.start();
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
|
-
constructor(service) {
|
|
95
|
-
var _a;
|
|
96
|
+
constructor(service, processContext) {
|
|
97
|
+
var _a, _b;
|
|
96
98
|
this.service = service;
|
|
99
|
+
this.processContext = processContext;
|
|
97
100
|
this.service.setOptions(cachedOptions);
|
|
98
|
-
// Anonymous aggregates for the (opt-in) evaluation reminder
|
|
99
|
-
// "you sent N
|
|
100
|
-
// than generic copy
|
|
101
|
+
// Anonymous 30-day aggregates for the (opt-in) evaluation reminder
|
|
102
|
+
// emails and the daily heartbeat — "you sent N quotes" converts far
|
|
103
|
+
// better than generic copy, and licensed installs keep reporting so
|
|
104
|
+
// renewal mail can say what the plugin did. Numbers only, never
|
|
105
|
+
// personal data.
|
|
101
106
|
(_a = QuotationsPlugin_1.evalClient) === null || _a === void 0 ? void 0 : _a.setStatsProvider(() => this.service.evalStats());
|
|
107
|
+
(_b = QuotationsPlugin_1.heartbeat) === null || _b === void 0 ? void 0 : _b.setStatsProvider(() => this.service.evalStats());
|
|
108
|
+
// Weekly "what Quotations did for you" report; tier/licence come from
|
|
109
|
+
// this class so the service never has to import it.
|
|
110
|
+
this.service.initDigest({
|
|
111
|
+
tier: () => { var _a; return QuotationsPlugin_1.isLicensed() ? 'paid' : (((_a = QuotationsPlugin_1.getEvalState()) === null || _a === void 0 ? void 0 : _a.active) ? 'trial' : 'free'); },
|
|
112
|
+
licence: () => QuotationsPlugin_1.getLicenceStatus(),
|
|
113
|
+
evalState: () => QuotationsPlugin_1.getEvalState(),
|
|
114
|
+
});
|
|
102
115
|
}
|
|
103
116
|
/** Apply an admin-activated licence key persisted in the DB. Runs
|
|
104
|
-
* after DI is up; an explicitly configured env/init key wins.
|
|
117
|
+
* after DI is up; an explicitly configured env/init key wins. Then
|
|
118
|
+
* starts the weekly report scheduler on the worker. */
|
|
105
119
|
async onApplicationBootstrap() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
var _a;
|
|
121
|
+
try {
|
|
122
|
+
if (!QuotationsPlugin_1.isLicensed()) {
|
|
123
|
+
const stored = await this.service.loadStoredLicenceKey();
|
|
124
|
+
if (stored) {
|
|
125
|
+
const st = QuotationsPlugin_1.activateRuntimeLicence(stored);
|
|
126
|
+
// eslint-disable-next-line no-console
|
|
127
|
+
if (st.valid)
|
|
128
|
+
console.log(`[${PKG_NAME}] licence restored from admin activation — ${st.message}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
if (this.processContext.isWorker && !cachedOptions.disableCron)
|
|
134
|
+
(_a = this.service.digest()) === null || _a === void 0 ? void 0 : _a.start();
|
|
114
135
|
}
|
|
115
136
|
}
|
|
116
137
|
static init(options = {}) {
|
|
@@ -130,6 +151,7 @@ let QuotationsPlugin = QuotationsPlugin_1 = class QuotationsPlugin {
|
|
|
130
151
|
licenceKey: options.licenceKey, pluginId: PLUGIN_ID, host,
|
|
131
152
|
publicKey: HULO_PUBLIC_KEY, revokedIds: QuotationsPlugin_1.revocation.getRevokedIds(),
|
|
132
153
|
});
|
|
154
|
+
QuotationsPlugin_1.activeLicenceKey = QuotationsPlugin_1.licenceStatus.valid ? (options.licenceKey || null) : null;
|
|
133
155
|
if (!QuotationsPlugin_1.licenceStatus.valid) {
|
|
134
156
|
// Unlicensed: register the install (no premium is granted by this; the 14-day
|
|
135
157
|
// evaluation. All premium paths stay enabled while it runs;
|
|
@@ -146,6 +168,10 @@ let QuotationsPlugin = QuotationsPlugin_1 = class QuotationsPlugin {
|
|
|
146
168
|
QuotationsPlugin_1.heartbeat = new vendure_licence_sdk_1.Heartbeat({
|
|
147
169
|
packageName: PKG_NAME, packageVersion: PKG_VERSION,
|
|
148
170
|
licenceKey: options.licenceKey, publicKeyFingerprint: (0, vendure_licence_sdk_1.fingerprintPublicKey)(HULO_PUBLIC_KEY),
|
|
171
|
+
// Admin-activated and claim-installed keys land after boot; the
|
|
172
|
+
// heartbeat reads the key in force on every ping so usage stats
|
|
173
|
+
// stay attached to the licence instead of "unlicensed".
|
|
174
|
+
licenceKeyProvider: () => QuotationsPlugin_1.activeLicenceKey,
|
|
149
175
|
});
|
|
150
176
|
QuotationsPlugin_1.heartbeat.start();
|
|
151
177
|
}
|
|
@@ -159,6 +185,8 @@ QuotationsPlugin.heartbeat = null;
|
|
|
159
185
|
QuotationsPlugin.licenceStatus = null;
|
|
160
186
|
QuotationsPlugin.evalClient = null;
|
|
161
187
|
QuotationsPlugin.licenceHost = '';
|
|
188
|
+
/** The key currently in force (env/init, admin-activated or claim-installed) — what the heartbeat reports. */
|
|
189
|
+
QuotationsPlugin.activeLicenceKey = null;
|
|
162
190
|
QuotationsPlugin.uiExtensions = {
|
|
163
191
|
extensionPath: __dirname + '/../ui',
|
|
164
192
|
ngModules: [
|
|
@@ -173,6 +201,6 @@ exports.QuotationsPlugin = QuotationsPlugin = QuotationsPlugin_1 = __decorate([
|
|
|
173
201
|
providers: [quotation_service_1.QuotationService, crons_1.QuotationCrons],
|
|
174
202
|
compatibility: '^3.0.0',
|
|
175
203
|
}),
|
|
176
|
-
__metadata("design:paramtypes", [quotation_service_1.QuotationService])
|
|
204
|
+
__metadata("design:paramtypes", [quotation_service_1.QuotationService, core_1.ProcessContext])
|
|
177
205
|
], QuotationsPlugin);
|
|
178
206
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAoCA,gCAA6E;AApC7E,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAoCA,gCAA6E;AApC7E,wCAAwF;AACxF,yEAGyC;AAEzC,2DAAuD;AACvD,iEAA6D;AAC7D,mCAAyC;AAGzC,8DAA8D;AAC9D,MAAM,WAAW,GAAW,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC;AAC/D,MAAM,QAAQ,GAAG,uCAAuC,CAAC;AACzD,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAE9C,MAAM,eAAe,GAAG;;;;;;;;yBAQC,CAAC;AAE1B,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,4CAA4C,CAAC;AAS/G,IAAI,aAAa,GAA0B,EAAE,CAAC;AAC9C,SAAgB,UAAU,KAA4B,OAAO,aAAa,CAAC,CAAC,CAAC;AAE7E;;;;;;;;;GASG;AAOI,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAOzB,MAAM,CAAC,gBAAgB,KAAK,OAAO,kBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC;IACpE,MAAM,CAAC,iBAAiB,KAAK,OAAO,WAAW,CAAC,CAAC,CAAC;IAClD,MAAM,CAAC,cAAc,KAAK,OAAO,QAAQ,CAAC,CAAC,CAAC;IAC5C,MAAM,CAAC,gBAAgB,KAAK,OAAO,kBAAgB,CAAC,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AE,CAAC,yBAAkB,CAAC;QAC7B,WAAW,EAAE,CAAC,0CAAmB,CAAC;QAClC,SAAS,EAAE,CAAC,oCAAgB,EAAE,sBAAc,CAAC;QAC7C,aAAa,EAAE,QAAQ;KAC1B,CAAC;qCA4D+B,oCAAgB,EAA0B,qBAAc;GA3D5E,gBAAgB,CA8I5B"}
|
|
@@ -11,6 +11,18 @@ export declare class QuotationController {
|
|
|
11
11
|
publicRequest(req: Request, body: any, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
12
12
|
private notFoundHtml;
|
|
13
13
|
meta(ctx: RequestContext, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
14
|
+
private tier;
|
|
15
|
+
setup(ctx: RequestContext, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
16
|
+
/** Dismiss an optional checklist item (only the ones marked dismissible). */
|
|
17
|
+
setupDismiss(ctx: RequestContext, res: Response, body: any): Promise<Response<any, Record<string, any>> | undefined>;
|
|
18
|
+
digestSettings(ctx: RequestContext, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
19
|
+
digestUpdate(ctx: RequestContext, res: Response, body: any): Promise<Response<any, Record<string, any>> | undefined>;
|
|
20
|
+
/** Send the week-to-date report now (does not move the weekly clock). */
|
|
21
|
+
digestSendTest(ctx: RequestContext, res: Response, body: any): Promise<Response<any, Record<string, any>> | undefined>;
|
|
22
|
+
/** This week's report as HTML, for the Preview button. */
|
|
23
|
+
digestPreview(ctx: RequestContext, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
24
|
+
/** Light payload for the Admin dashboard widget (last 7 days). */
|
|
25
|
+
widget(ctx: RequestContext, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
14
26
|
licenceStatus(ctx: RequestContext, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
|
|
15
27
|
/** Admin-UI licence activation: verify + persist a key at runtime. */
|
|
16
28
|
licenceActivate(ctx: RequestContext, res: Response, body: any): Promise<Response<any, Record<string, any>> | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quotation.controller.d.ts","sourceRoot":"","sources":["../src/quotation.controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAmB,cAAc,EAAE,MAAM,eAAe,CAAC;AAGhE,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"quotation.controller.d.ts","sourceRoot":"","sources":["../src/quotation.controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAmB,cAAc,EAAE,MAAM,eAAe,CAAC;AAGhE,OAAO,EAAE,gBAAgB,EAAoB,MAAM,qBAAqB,CAAC;AAwBzE,qBACa,mBAAmB;IAChB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,gBAAgB;IAIvC,WAAW,CAAiB,KAAK,EAAE,MAAM,EAAS,GAAG,EAAE,QAAQ;IAQ/D,aAAa,CAAiB,KAAK,EAAE,MAAM,EAAU,IAAI,EAAE,GAAG,EAAS,GAAG,EAAE,QAAQ;IAe1F;4EACwE;IAElE,aAAa,CAAQ,GAAG,EAAE,OAAO,EAAU,IAAI,EAAE,GAAG,EAAS,GAAG,EAAE,QAAQ;IAchF,OAAO,CAAC,YAAY;IASd,IAAI,CAAQ,GAAG,EAAE,cAAc,EAAS,GAAG,EAAE,QAAQ;IAuB3D,OAAO,CAAC,IAAI;IAMN,KAAK,CAAQ,GAAG,EAAE,cAAc,EAAS,GAAG,EAAE,QAAQ;IAK5D,6EAA6E;IAEvE,YAAY,CAAQ,GAAG,EAAE,cAAc,EAAS,GAAG,EAAE,QAAQ,EAAU,IAAI,EAAE,GAAG;IAQhF,cAAc,CAAQ,GAAG,EAAE,cAAc,EAAS,GAAG,EAAE,QAAQ;IAQ/D,YAAY,CAAQ,GAAG,EAAE,cAAc,EAA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EAAc,CAAC,CAAC,EAAE,MAAM;IAKxF;+DAC2D;IAErD,QAAQ,CAAQ,GAAG,EAAE,cAAc,EAAS,GAAG,EAAE,QAAQ,EAAe,EAAE,EAAE,MAAM,EAAU,IAAI,EAAE,GAAG;IAS3G,oDAAoD;IAE9C,OAAO,CAAQ,GAAG,EAAE,cAAc,EAAS,GAAG,EAAE,QAAQ,EAAe,EAAE,EAAE,MAAM;IAQjF,MAAM,CAAQ,GAAG,EAAE,cAAc,EAAS,GAAG,EAAE,QAAQ,EAAe,EAAE,EAAE,MAAM,EAAU,IAAI,EAAE,GAAG;IAOnG,OAAO,CAAQ,GAAG,EAAE,cAAc,EAAS,GAAG,EAAE,QAAQ,EAAe,EAAE,EAAE,MAAM,EAAU,IAAI,EAAE,GAAG;IAOpG,QAAQ,CAAQ,GAAG,EAAE,cAAc,EAAS,GAAG,EAAE,QAAQ,EAAsB,SAAS,CAAC,EAAE,MAAM,EAAc,CAAC,CAAC,EAAE,MAAM;IAK/H,OAAO,CAAC,KAAK;CAGhB"}
|
|
@@ -19,6 +19,8 @@ const vendure_licence_sdk_1 = require("@huloglobal/vendure-licence-sdk");
|
|
|
19
19
|
const quotation_service_1 = require("./quotation.service");
|
|
20
20
|
const plugin_1 = require("./plugin");
|
|
21
21
|
const templates_1 = require("./templates");
|
|
22
|
+
const PLUGIN_ID = 'vendure-plugin-quotations';
|
|
23
|
+
const BUY_URL = `https://elite.charity/licence/buy/${PLUGIN_ID}`;
|
|
22
24
|
function denyUnlessAdmin(ctx, res, write) {
|
|
23
25
|
const needed = write ? [core_1.Permission.UpdateSettings] : [core_1.Permission.ReadSettings];
|
|
24
26
|
if (!ctx.userHasPermissions(needed)) {
|
|
@@ -34,7 +36,7 @@ function denyUnlessPremium(res) {
|
|
|
34
36
|
res.status(402).json({
|
|
35
37
|
error: 'licence-required',
|
|
36
38
|
message: 'Sending, chasers and order conversion need a licence (or the 14-day evaluation). Drafting and previewing stay free.',
|
|
37
|
-
buyUrl:
|
|
39
|
+
buyUrl: BUY_URL,
|
|
38
40
|
});
|
|
39
41
|
return true;
|
|
40
42
|
}
|
|
@@ -91,21 +93,103 @@ let QuotationController = class QuotationController {
|
|
|
91
93
|
}
|
|
92
94
|
// ── Admin: meta / licence / update ─────────────────────────────────
|
|
93
95
|
async meta(ctx, res) {
|
|
94
|
-
var _a;
|
|
95
96
|
if (denyUnlessAdmin(ctx, res, false))
|
|
96
97
|
return;
|
|
97
98
|
const updater = plugin_1.QuotationsPlugin.getUpdateChecker();
|
|
98
99
|
const licence = plugin_1.QuotationsPlugin.getLicenceStatus();
|
|
100
|
+
const evalState = plugin_1.QuotationsPlugin.getEvalState();
|
|
101
|
+
const summary = (0, vendure_licence_sdk_1.describeLicence)(licence);
|
|
99
102
|
return res.json({
|
|
100
103
|
name: plugin_1.QuotationsPlugin.getPackageName(),
|
|
101
104
|
version: plugin_1.QuotationsPlugin.getPackageVersion(),
|
|
102
105
|
update: updater ? updater.getStatus() : null,
|
|
103
106
|
selfUpdate: (0, vendure_licence_sdk_1.selfUpdateEnv)(),
|
|
104
107
|
licensed: !!(licence === null || licence === void 0 ? void 0 : licence.valid),
|
|
105
|
-
licence:
|
|
108
|
+
licence: summary,
|
|
106
109
|
licenceMessage: (licence === null || licence === void 0 ? void 0 : licence.valid) ? '' : ((licence === null || licence === void 0 ? void 0 : licence.message) || 'No licence key configured'),
|
|
107
|
-
tier:
|
|
108
|
-
eval:
|
|
110
|
+
tier: this.tier(),
|
|
111
|
+
eval: evalState,
|
|
112
|
+
notice: (0, vendure_licence_sdk_1.licenceLifecycleNotice)(summary, evalState, PLUGIN_ID),
|
|
113
|
+
premiumFeatures: quotation_service_1.PREMIUM_FEATURES,
|
|
114
|
+
recentStats: await this.service.recentStats(),
|
|
115
|
+
buyUrl: BUY_URL,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
tier() {
|
|
119
|
+
var _a;
|
|
120
|
+
return plugin_1.QuotationsPlugin.isLicensed() ? 'paid' : (((_a = plugin_1.QuotationsPlugin.getEvalState()) === null || _a === void 0 ? void 0 : _a.active) ? 'trial' : 'free');
|
|
121
|
+
}
|
|
122
|
+
// ── Admin: set-up checklist, weekly report, dashboard widget ───────
|
|
123
|
+
async setup(ctx, res) {
|
|
124
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
125
|
+
return;
|
|
126
|
+
return res.json(await this.service.setupChecklist());
|
|
127
|
+
}
|
|
128
|
+
/** Dismiss an optional checklist item (only the ones marked dismissible). */
|
|
129
|
+
async setupDismiss(ctx, res, body) {
|
|
130
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
131
|
+
return;
|
|
132
|
+
const ok = await this.service.dismissSetupItem(String((body === null || body === void 0 ? void 0 : body.key) || ''));
|
|
133
|
+
if (!ok)
|
|
134
|
+
return res.status(400).json({ ok: false, message: 'That item cannot be dismissed' });
|
|
135
|
+
return res.json(await this.service.setupChecklist());
|
|
136
|
+
}
|
|
137
|
+
async digestSettings(ctx, res) {
|
|
138
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
139
|
+
return;
|
|
140
|
+
const d = this.service.digest();
|
|
141
|
+
if (!d)
|
|
142
|
+
return res.status(503).json({ message: 'Weekly report not initialised' });
|
|
143
|
+
return res.json(await d.settings());
|
|
144
|
+
}
|
|
145
|
+
async digestUpdate(ctx, res, body) {
|
|
146
|
+
var _a;
|
|
147
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
148
|
+
return;
|
|
149
|
+
const d = this.service.digest();
|
|
150
|
+
if (!d)
|
|
151
|
+
return res.status(503).json({ message: 'Weekly report not initialised' });
|
|
152
|
+
const patch = {};
|
|
153
|
+
if (typeof (body === null || body === void 0 ? void 0 : body.enabled) === 'boolean')
|
|
154
|
+
patch.enabled = body.enabled;
|
|
155
|
+
if (body && 'recipient' in body)
|
|
156
|
+
patch.recipient = body.recipient === null ? null : String((_a = body.recipient) !== null && _a !== void 0 ? _a : '');
|
|
157
|
+
try {
|
|
158
|
+
return res.json(await d.updateSettings(patch));
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
return res.status(400).json({ message: (e === null || e === void 0 ? void 0 : e.message) || 'Invalid settings' });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** Send the week-to-date report now (does not move the weekly clock). */
|
|
165
|
+
async digestSendTest(ctx, res, body) {
|
|
166
|
+
if (denyUnlessAdmin(ctx, res, true))
|
|
167
|
+
return;
|
|
168
|
+
const d = this.service.digest();
|
|
169
|
+
if (!d)
|
|
170
|
+
return res.status(503).json({ sent: false, to: null, reason: 'Weekly report not initialised' });
|
|
171
|
+
const r = await d.sendNow(String((body === null || body === void 0 ? void 0 : body.to) || '').trim() || null);
|
|
172
|
+
return res.json({ sent: r.sent, to: r.to, reason: r.reason, subject: r.preview.subject });
|
|
173
|
+
}
|
|
174
|
+
/** This week's report as HTML, for the Preview button. */
|
|
175
|
+
async digestPreview(ctx, res) {
|
|
176
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
177
|
+
return;
|
|
178
|
+
const mail = await this.service.digestPreview();
|
|
179
|
+
return res.type('html').send(mail.html);
|
|
180
|
+
}
|
|
181
|
+
/** Light payload for the Admin dashboard widget (last 7 days). */
|
|
182
|
+
async widget(ctx, res) {
|
|
183
|
+
if (denyUnlessAdmin(ctx, res, false))
|
|
184
|
+
return;
|
|
185
|
+
const licence = plugin_1.QuotationsPlugin.getLicenceStatus();
|
|
186
|
+
const evalState = plugin_1.QuotationsPlugin.getEvalState();
|
|
187
|
+
const n = (0, vendure_licence_sdk_1.licenceLifecycleNotice)((0, vendure_licence_sdk_1.describeLicence)(licence), evalState, PLUGIN_ID);
|
|
188
|
+
return res.json({
|
|
189
|
+
tier: this.tier(),
|
|
190
|
+
notice: n ? { kind: n.kind, message: n.message, daysLeft: n.daysLeft } : null,
|
|
191
|
+
stats: await this.service.widgetStats(),
|
|
192
|
+
route: '/extensions/quotations',
|
|
109
193
|
});
|
|
110
194
|
}
|
|
111
195
|
async licenceStatus(ctx, res) {
|
|
@@ -224,6 +308,8 @@ let QuotationController = class QuotationController {
|
|
|
224
308
|
});
|
|
225
309
|
if (!resp.ok)
|
|
226
310
|
return res.status(502).json({ error: 'upstream', status: resp.status });
|
|
311
|
+
// Remembered as the weekly report's last-resort recipient.
|
|
312
|
+
await this.service.prefs.set('eval.leadEmail', email.toLowerCase());
|
|
227
313
|
return res.json({ ok: true });
|
|
228
314
|
}
|
|
229
315
|
catch (e) {
|
|
@@ -436,6 +522,65 @@ __decorate([
|
|
|
436
522
|
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
437
523
|
__metadata("design:returntype", Promise)
|
|
438
524
|
], QuotationController.prototype, "meta", null);
|
|
525
|
+
__decorate([
|
|
526
|
+
(0, common_1.Get)('setup'),
|
|
527
|
+
__param(0, (0, core_1.Ctx)()),
|
|
528
|
+
__param(1, (0, common_1.Res)()),
|
|
529
|
+
__metadata("design:type", Function),
|
|
530
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
531
|
+
__metadata("design:returntype", Promise)
|
|
532
|
+
], QuotationController.prototype, "setup", null);
|
|
533
|
+
__decorate([
|
|
534
|
+
(0, common_1.Post)('setup/dismiss'),
|
|
535
|
+
__param(0, (0, core_1.Ctx)()),
|
|
536
|
+
__param(1, (0, common_1.Res)()),
|
|
537
|
+
__param(2, (0, common_1.Body)()),
|
|
538
|
+
__metadata("design:type", Function),
|
|
539
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, Object]),
|
|
540
|
+
__metadata("design:returntype", Promise)
|
|
541
|
+
], QuotationController.prototype, "setupDismiss", null);
|
|
542
|
+
__decorate([
|
|
543
|
+
(0, common_1.Get)('digest/settings'),
|
|
544
|
+
__param(0, (0, core_1.Ctx)()),
|
|
545
|
+
__param(1, (0, common_1.Res)()),
|
|
546
|
+
__metadata("design:type", Function),
|
|
547
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
548
|
+
__metadata("design:returntype", Promise)
|
|
549
|
+
], QuotationController.prototype, "digestSettings", null);
|
|
550
|
+
__decorate([
|
|
551
|
+
(0, common_1.Post)('digest/settings'),
|
|
552
|
+
__param(0, (0, core_1.Ctx)()),
|
|
553
|
+
__param(1, (0, common_1.Res)()),
|
|
554
|
+
__param(2, (0, common_1.Body)()),
|
|
555
|
+
__metadata("design:type", Function),
|
|
556
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, Object]),
|
|
557
|
+
__metadata("design:returntype", Promise)
|
|
558
|
+
], QuotationController.prototype, "digestUpdate", null);
|
|
559
|
+
__decorate([
|
|
560
|
+
(0, common_1.Post)('digest/send-test'),
|
|
561
|
+
__param(0, (0, core_1.Ctx)()),
|
|
562
|
+
__param(1, (0, common_1.Res)()),
|
|
563
|
+
__param(2, (0, common_1.Body)()),
|
|
564
|
+
__metadata("design:type", Function),
|
|
565
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object, Object]),
|
|
566
|
+
__metadata("design:returntype", Promise)
|
|
567
|
+
], QuotationController.prototype, "digestSendTest", null);
|
|
568
|
+
__decorate([
|
|
569
|
+
(0, common_1.Get)('digest/preview'),
|
|
570
|
+
__param(0, (0, core_1.Ctx)()),
|
|
571
|
+
__param(1, (0, common_1.Res)()),
|
|
572
|
+
__metadata("design:type", Function),
|
|
573
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
574
|
+
__metadata("design:returntype", Promise)
|
|
575
|
+
], QuotationController.prototype, "digestPreview", null);
|
|
576
|
+
__decorate([
|
|
577
|
+
(0, common_1.Get)('widget'),
|
|
578
|
+
__param(0, (0, core_1.Ctx)()),
|
|
579
|
+
__param(1, (0, common_1.Res)()),
|
|
580
|
+
__metadata("design:type", Function),
|
|
581
|
+
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
582
|
+
__metadata("design:returntype", Promise)
|
|
583
|
+
], QuotationController.prototype, "widget", null);
|
|
439
584
|
__decorate([
|
|
440
585
|
(0, common_1.Get)('licence/status'),
|
|
441
586
|
__param(0, (0, core_1.Ctx)()),
|