@huloglobal/vendure-plugin-quotations 0.8.6 → 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 +83 -0
- package/README.md +103 -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/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 +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 +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 +617 -23
- package/dist/quotation.controller.js.map +1 -1
- package/dist/quotation.service.d.ts +178 -11
- package/dist/quotation.service.d.ts.map +1 -1
- package/dist/quotation.service.js +577 -88
- package/dist/quotation.service.js.map +1 -1
- 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 +3 -2
- package/ui/components/quotations.component.ts +328 -19
package/dist/deposits.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.currencyStep = currencyStep;
|
|
4
|
+
exports.splitDeposit = splitDeposit;
|
|
5
|
+
exports.depositPctFor = depositPctFor;
|
|
6
|
+
const pro_settings_1 = require("./pro-settings");
|
|
7
|
+
/**
|
|
8
|
+
* Deposits (premium): an accepted quote is paid in two parts, a deposit and
|
|
9
|
+
* then the balance. Deposit + balance = the quoted total exactly, in the
|
|
10
|
+
* quote's minor units. Vendure keeps two decimals for every currency, so for
|
|
11
|
+
* zero-decimal currencies (JPY, KRW …) the deposit is rounded to whole units
|
|
12
|
+
* (a multiple of 100 minor units) and the balance is the rest.
|
|
13
|
+
*/
|
|
14
|
+
const ZERO_DECIMAL = new Set(['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']);
|
|
15
|
+
/** The smallest amount a payment provider can charge in this currency, in Vendure minor units. */
|
|
16
|
+
function currencyStep(currency) {
|
|
17
|
+
return ZERO_DECIMAL.has(String(currency || '').toUpperCase()) ? 100 : 1;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Split `total` into [deposit, balance]: the deposit is `pct` percent of the
|
|
21
|
+
* total rounded half-up to whole steps of the currency, in integer arithmetic
|
|
22
|
+
* (percent to two decimals, so no floating-point drift); the balance is the
|
|
23
|
+
* rest. [0, total] when no deposit fits (pct out of range, or the rounded
|
|
24
|
+
* deposit is 0 or the whole total).
|
|
25
|
+
*/
|
|
26
|
+
function splitDeposit(total, pct, currency) {
|
|
27
|
+
const t = Math.floor(Number(total) || 0);
|
|
28
|
+
const bp = Math.round((Number(pct) || 0) * 100); // basis points of a percent: 12.5% → 1250
|
|
29
|
+
if (bp <= 0 || bp >= 10000 || t <= 0)
|
|
30
|
+
return [0, t];
|
|
31
|
+
const step = currencyStep(currency);
|
|
32
|
+
const num = t * bp; // exact: total < 2^31, bp < 10^4
|
|
33
|
+
const den = 10000 * step;
|
|
34
|
+
const steps = Math.floor((2 * num + den) / (2 * den)); // round half up
|
|
35
|
+
const deposit = steps * step;
|
|
36
|
+
if (deposit <= 0 || deposit >= t)
|
|
37
|
+
return [0, t];
|
|
38
|
+
return [deposit, t - deposit];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The deposit percentage for a quote: its own override ("none" or a
|
|
42
|
+
* percentage), else the setting when the quote's total is above the
|
|
43
|
+
* threshold for its currency (or no threshold is set). 0 = no deposit.
|
|
44
|
+
*/
|
|
45
|
+
function depositPctFor(q, s, o) {
|
|
46
|
+
if ((o === null || o === void 0 ? void 0 : o.overrideMode) === 'none')
|
|
47
|
+
return 0;
|
|
48
|
+
if ((o === null || o === void 0 ? void 0 : o.overrideMode) === 'pct')
|
|
49
|
+
return Number(o.overridePct) || 0;
|
|
50
|
+
if (!(s.depositPct > 0))
|
|
51
|
+
return 0;
|
|
52
|
+
if (s.depositAbove.trim()) {
|
|
53
|
+
const limit = (0, pro_settings_1.limitFor)(s.depositAbove, String(q.currency || ''));
|
|
54
|
+
if (limit === null || Number(q.totalPence) <= limit)
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
return s.depositPct;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=deposits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deposits.js","sourceRoot":"","sources":["../src/deposits.ts"],"names":[],"mappings":";;AAaA,oCAEC;AASD,oCAWC;AASD,sCASC;AArDD,iDAAuD;AAEvD;;;;;;GAMG;AAEH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAE/I,kGAAkG;AAClG,SAAgB,YAAY,CAAC,QAAgB;IACzC,OAAO,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,KAAa,EAAE,GAAW,EAAE,QAAgB;IACrE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACzC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,0CAA0C;IAC3F,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,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,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK;YAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,CAAC,CAAC,UAAU,CAAC;AACxB,CAAC"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { RequestContext, VendureEvent } from '@vendure/core';
|
|
2
|
+
/**
|
|
3
|
+
* What happened to a quote. Every entry on a quote's activity trail that
|
|
4
|
+
* changes what the customer or the store can do is published on Vendure's
|
|
5
|
+
* EventBus as a {@link QuotationEvent} with one of these types.
|
|
6
|
+
*/
|
|
7
|
+
export type QuotationEventType = 'created' | 'requested' | 'updated' | 'sent' | 'viewed' | 'accepted' | 'declined' | 'expired' | 'cancelled' | 'converted' | 'paid' | 'payment' | 'approval' | 'followup' | 'deleted';
|
|
8
|
+
/** The trail entry types that become EventBus events (comments, acknowledgements and the like stay on the trail only). */
|
|
9
|
+
export declare const PUBLISHED_EVENT_TYPES: ReadonlySet<string>;
|
|
10
|
+
/** A small, stable picture of the quote at the time of the event (no token, no internal notes). */
|
|
11
|
+
export interface QuotationEventQuote {
|
|
12
|
+
id: number;
|
|
13
|
+
channelId: number;
|
|
14
|
+
reference: string;
|
|
15
|
+
status: string;
|
|
16
|
+
customerId: number | null;
|
|
17
|
+
customerName: string;
|
|
18
|
+
customerEmail: string;
|
|
19
|
+
customerCompany: string;
|
|
20
|
+
currency: string;
|
|
21
|
+
subTotalPence: number;
|
|
22
|
+
discountPence: number;
|
|
23
|
+
vatPence: number;
|
|
24
|
+
totalPence: number;
|
|
25
|
+
validUntil: string | null;
|
|
26
|
+
sentAt: string | null;
|
|
27
|
+
paidAt: string | null;
|
|
28
|
+
convertedOrderId: number | null;
|
|
29
|
+
preparedByName: string;
|
|
30
|
+
preparedByEmail: string;
|
|
31
|
+
requestSource: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function eventQuote(q: any): QuotationEventQuote;
|
|
34
|
+
/**
|
|
35
|
+
* Published on Vendure's EventBus whenever a quote moves: created, requested
|
|
36
|
+
* from the storefront, sent (or marked as sent), opened, accepted, declined,
|
|
37
|
+
* expired, cancelled, converted, paid, and the approval / payment / follow-up
|
|
38
|
+
* steps. Subscribe with
|
|
39
|
+
* `eventBus.ofType(QuotationEvent).pipe(filter(e => e.type === 'accepted'))`.
|
|
40
|
+
*/
|
|
41
|
+
export declare class QuotationEvent extends VendureEvent {
|
|
42
|
+
ctx: RequestContext;
|
|
43
|
+
type: QuotationEventType;
|
|
44
|
+
quote: QuotationEventQuote;
|
|
45
|
+
/** The trail text, e.g. `Accepted by "Jane Buyer"`. */
|
|
46
|
+
detail: string;
|
|
47
|
+
/** Who did it: an administrator id, the customer's e-mail address, or '' for the system. */
|
|
48
|
+
actor: string;
|
|
49
|
+
constructor(ctx: RequestContext, type: QuotationEventType, quote: QuotationEventQuote,
|
|
50
|
+
/** The trail text, e.g. `Accepted by "Jane Buyer"`. */
|
|
51
|
+
detail: string,
|
|
52
|
+
/** Who did it: an administrator id, the customer's e-mail address, or '' for the system. */
|
|
53
|
+
actor: string);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GACxB,SAAS,GACT,WAAW,GACX,SAAS,GACT,MAAM,GACN,QAAQ,GACR,UAAU,GACV,UAAU,GACV,SAAS,GACT,WAAW,GACX,WAAW,GACX,MAAM,GACN,SAAS,GACT,UAAU,GACV,UAAU,GACV,SAAS,CAAC;AAEhB,0HAA0H;AAC1H,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,MAAM,CAGpD,CAAC;AAEH,mGAAmG;AACnG,MAAM,WAAW,mBAAmB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,GAAG,mBAAmB,CAwBtD;AAED;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,YAAY;IAEjC,GAAG,EAAE,cAAc;IACnB,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,mBAAmB;IACjC,uDAAuD;IAChD,MAAM,EAAE,MAAM;IACrB,4FAA4F;IACrF,KAAK,EAAE,MAAM;gBANb,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,mBAAmB;IACjC,uDAAuD;IAChD,MAAM,EAAE,MAAM;IACrB,4FAA4F;IACrF,KAAK,EAAE,MAAM;CAI3B"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuotationEvent = exports.PUBLISHED_EVENT_TYPES = void 0;
|
|
4
|
+
exports.eventQuote = eventQuote;
|
|
5
|
+
const core_1 = require("@vendure/core");
|
|
6
|
+
/** The trail entry types that become EventBus events (comments, acknowledgements and the like stay on the trail only). */
|
|
7
|
+
exports.PUBLISHED_EVENT_TYPES = new Set([
|
|
8
|
+
'created', 'requested', 'updated', 'sent', 'viewed', 'accepted', 'declined', 'expired', 'cancelled',
|
|
9
|
+
'converted', 'paid', 'payment', 'approval', 'followup', 'deleted',
|
|
10
|
+
]);
|
|
11
|
+
function eventQuote(q) {
|
|
12
|
+
const iso = (v) => (v ? new Date(v).toISOString() : null);
|
|
13
|
+
return {
|
|
14
|
+
id: Number(q.id),
|
|
15
|
+
channelId: Number(q.channelId),
|
|
16
|
+
reference: String(q.reference || ''),
|
|
17
|
+
status: String(q.status || ''),
|
|
18
|
+
customerId: q.customerId ? Number(q.customerId) : null,
|
|
19
|
+
customerName: String(q.customerName || ''),
|
|
20
|
+
customerEmail: String(q.customerEmail || ''),
|
|
21
|
+
customerCompany: String(q.customerCompany || ''),
|
|
22
|
+
currency: String(q.currency || ''),
|
|
23
|
+
subTotalPence: Number(q.subTotalPence || 0),
|
|
24
|
+
discountPence: Number(q.discountPence || 0),
|
|
25
|
+
vatPence: Number(q.vatPence || 0),
|
|
26
|
+
totalPence: Number(q.totalPence || 0),
|
|
27
|
+
validUntil: iso(q.validUntil),
|
|
28
|
+
sentAt: iso(q.sentAt),
|
|
29
|
+
paidAt: iso(q.paidAt),
|
|
30
|
+
convertedOrderId: q.convertedOrderId ? Number(q.convertedOrderId) : null,
|
|
31
|
+
preparedByName: String(q.preparedByName || ''),
|
|
32
|
+
preparedByEmail: String(q.preparedByEmail || ''),
|
|
33
|
+
requestSource: String(q.requestSource || ''),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Published on Vendure's EventBus whenever a quote moves: created, requested
|
|
38
|
+
* from the storefront, sent (or marked as sent), opened, accepted, declined,
|
|
39
|
+
* expired, cancelled, converted, paid, and the approval / payment / follow-up
|
|
40
|
+
* steps. Subscribe with
|
|
41
|
+
* `eventBus.ofType(QuotationEvent).pipe(filter(e => e.type === 'accepted'))`.
|
|
42
|
+
*/
|
|
43
|
+
class QuotationEvent extends core_1.VendureEvent {
|
|
44
|
+
constructor(ctx, type, quote,
|
|
45
|
+
/** The trail text, e.g. `Accepted by "Jane Buyer"`. */
|
|
46
|
+
detail,
|
|
47
|
+
/** Who did it: an administrator id, the customer's e-mail address, or '' for the system. */
|
|
48
|
+
actor) {
|
|
49
|
+
super();
|
|
50
|
+
this.ctx = ctx;
|
|
51
|
+
this.type = type;
|
|
52
|
+
this.quote = quote;
|
|
53
|
+
this.detail = detail;
|
|
54
|
+
this.actor = actor;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.QuotationEvent = QuotationEvent;
|
|
58
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAsDA,gCAwBC;AA9ED,wCAA6D;AAwB7D,0HAA0H;AAC7G,QAAA,qBAAqB,GAAwB,IAAI,GAAG,CAAqB;IAClF,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW;IACnG,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS;CACpE,CAAC,CAAC;AA0BH,SAAgB,UAAU,CAAC,CAAM;IAC7B,MAAM,GAAG,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/D,OAAO;QACH,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAChB,SAAS,E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AI,EAAE,CAAC;QAChD,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC;KAC/C,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAa,cAAe,SAAQ,mBAAY;IAC5C,YACW,GAAmB,EACnB,IAAwB,EACxB,KAA0B;IACjC,uDAAuD;IAChD,MAAc;IACrB,4FAA4F;IACrF,KAAa;QAEpB,KAAK,EAAE,CAAC;QARD,QAAG,GAAH,GAAG,CAAgB;QACnB,SAAI,GAAJ,IAAI,CAAoB;QACxB,UAAK,GAAL,KAAK,CAAqB;QAE1B,WAAM,GAAN,MAAM,CAAQ;QAEd,UAAK,GAAL,KAAK,CAAQ;IAGxB,CAAC;CACJ;AAZD,wCAYC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { QuotationsPlugin, getOptions } from './plugin';
|
|
2
2
|
export type { QuotationsInitOptions } from './plugin';
|
|
3
3
|
export { QuotationService } from './quotation.service';
|
|
4
|
+
export { QuotationProService } from './pro.service';
|
|
5
|
+
export { QuotationPaymentService } from './payment.service';
|
|
6
|
+
export { QuotationEvent, QuotationEventType, QuotationEventQuote } from './events';
|
|
7
|
+
export type { QuotePayLinkProvider, QuotePayLinkInput, QuotePayLink } from './pay-links';
|
|
4
8
|
export * from './types';
|
|
5
9
|
export { quoteTotals, lineTotal, formatMoney } from './pricing';
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,YAAY,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,YAAY,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACnF,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzF,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,12 +14,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.formatMoney = exports.lineTotal = exports.quoteTotals = exports.QuotationService = exports.getOptions = exports.QuotationsPlugin = void 0;
|
|
17
|
+
exports.formatMoney = exports.lineTotal = exports.quoteTotals = exports.QuotationEvent = exports.QuotationPaymentService = exports.QuotationProService = exports.QuotationService = exports.getOptions = exports.QuotationsPlugin = void 0;
|
|
18
18
|
var plugin_1 = require("./plugin");
|
|
19
19
|
Object.defineProperty(exports, "QuotationsPlugin", { enumerable: true, get: function () { return plugin_1.QuotationsPlugin; } });
|
|
20
20
|
Object.defineProperty(exports, "getOptions", { enumerable: true, get: function () { return plugin_1.getOptions; } });
|
|
21
21
|
var quotation_service_1 = require("./quotation.service");
|
|
22
22
|
Object.defineProperty(exports, "QuotationService", { enumerable: true, get: function () { return quotation_service_1.QuotationService; } });
|
|
23
|
+
var pro_service_1 = require("./pro.service");
|
|
24
|
+
Object.defineProperty(exports, "QuotationProService", { enumerable: true, get: function () { return pro_service_1.QuotationProService; } });
|
|
25
|
+
var payment_service_1 = require("./payment.service");
|
|
26
|
+
Object.defineProperty(exports, "QuotationPaymentService", { enumerable: true, get: function () { return payment_service_1.QuotationPaymentService; } });
|
|
27
|
+
var events_1 = require("./events");
|
|
28
|
+
Object.defineProperty(exports, "QuotationEvent", { enumerable: true, get: function () { return events_1.QuotationEvent; } });
|
|
23
29
|
__exportStar(require("./types"), exports);
|
|
24
30
|
var pricing_1 = require("./pricing");
|
|
25
31
|
Object.defineProperty(exports, "quoteTotals", { enumerable: true, get: function () { return pricing_1.quoteTotals; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAwD;AAA/C,0GAAA,gBAAgB,OAAA;AAAE,oGAAA,UAAU,OAAA;AAErC,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,0CAAwB;AACxB,qCAAgE;AAAvD,sGAAA,WAAW,OAAA;AAAE,oGAAA,SAAS,OAAA;AAAE,sGAAA,WAAW,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAwD;AAA/C,0GAAA,gBAAgB,OAAA;AAAE,oGAAA,UAAU,OAAA;AAErC,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,6CAAoD;AAA3C,kHAAA,mBAAmB,OAAA;AAC5B,qDAA4D;AAAnD,0HAAA,uBAAuB,OAAA;AAChC,mCAAmF;AAA1E,wGAAA,cAAc,OAAA;AAEvB,0CAAwB;AACxB,qCAAgE;AAAvD,sGAAA,WAAW,OAAA;AAAE,oGAAA,SAAS,OAAA;AAAE,sGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ModuleRef } from '@nestjs/core';
|
|
2
|
+
import { RequestContext } from '@vendure/core';
|
|
3
|
+
/** What Quotations asks a pay-link provider for. Amounts are Vendure minor units of the order's currency. */
|
|
4
|
+
export interface QuotePayLinkInput {
|
|
5
|
+
orderCode: string;
|
|
6
|
+
/** Only part of the order total (a deposit or the balance); omitted = what is left to pay on the order. */
|
|
7
|
+
amount?: number;
|
|
8
|
+
currency: string;
|
|
9
|
+
description: string;
|
|
10
|
+
customerEmail?: string;
|
|
11
|
+
returnUrl?: string;
|
|
12
|
+
expiresInHours?: number;
|
|
13
|
+
/** Stable reference for the link, e.g. "Q-2026-0012-D". */
|
|
14
|
+
reference?: string;
|
|
15
|
+
metadata?: Record<string, string | number>;
|
|
16
|
+
}
|
|
17
|
+
export interface QuotePayLink {
|
|
18
|
+
url: string;
|
|
19
|
+
ref: string;
|
|
20
|
+
expiresAt?: string;
|
|
21
|
+
provider?: string;
|
|
22
|
+
}
|
|
23
|
+
/** A host can plug in any pay-link source with `QuotationsPlugin.init({ payLinks: { create } })`. */
|
|
24
|
+
export interface QuotePayLinkProvider {
|
|
25
|
+
create(ctx: RequestContext, input: QuotePayLinkInput): Promise<QuotePayLink>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Finds a pay-link provider at runtime without depending on HULO Payments:
|
|
29
|
+
* the host's own `payLinks` option first, else the HULO Payments for Vendure
|
|
30
|
+
* package when it is installed and its plugin is loaded (its public service
|
|
31
|
+
* `createPayLink(ctx, { orderCode, amount?, … })`). Returns null when neither
|
|
32
|
+
* is there, and Quotations then works exactly as without pay links.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolvePayLinkProvider(moduleRef: ModuleRef | null, hostOption?: QuotePayLinkProvider | null): (QuotePayLinkProvider & {
|
|
35
|
+
source: string;
|
|
36
|
+
}) | null;
|
|
37
|
+
//# sourceMappingURL=pay-links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay-links.d.ts","sourceRoot":"","sources":["../src/pay-links.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAU,cAAc,EAAE,MAAM,eAAe,CAAC;AAIvD,6GAA6G;AAC7G,MAAM,WAAW,iBAAiB;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,2GAA2G;IAC3G,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,YAAY;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;AAEjG,qGAAqG;AACrG,MAAM,WAAW,oBAAoB;IACjC,MAAM,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAChF;AAOD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,oBAAoB,GAAG,IAAI,GAAG,CAAC,oBAAoB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,CA8BhK"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolvePayLinkProvider = resolvePayLinkProvider;
|
|
4
|
+
const core_1 = require("@vendure/core");
|
|
5
|
+
const loggerCtx = 'Quotations';
|
|
6
|
+
const PAYMENTS_PACKAGE = '@huloglobal/vendure-plugin-payments';
|
|
7
|
+
/** Service classes the HULO Payments package exports that may carry the pay-link API, in order of preference. */
|
|
8
|
+
const SERVICE_EXPORTS = ['PayLinkService', 'PaymentsService', 'HuloPaymentsService'];
|
|
9
|
+
const METHOD_NAMES = ['createPayLink', 'createPayLinkForOrder'];
|
|
10
|
+
/**
|
|
11
|
+
* Finds a pay-link provider at runtime without depending on HULO Payments:
|
|
12
|
+
* the host's own `payLinks` option first, else the HULO Payments for Vendure
|
|
13
|
+
* package when it is installed and its plugin is loaded (its public service
|
|
14
|
+
* `createPayLink(ctx, { orderCode, amount?, … })`). Returns null when neither
|
|
15
|
+
* is there, and Quotations then works exactly as without pay links.
|
|
16
|
+
*/
|
|
17
|
+
function resolvePayLinkProvider(moduleRef, hostOption) {
|
|
18
|
+
if (hostOption && typeof hostOption.create === 'function')
|
|
19
|
+
return { create: (c, i) => hostOption.create(c, i), source: 'host' };
|
|
20
|
+
if (!moduleRef)
|
|
21
|
+
return null;
|
|
22
|
+
let mod;
|
|
23
|
+
try {
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
25
|
+
mod = require(PAYMENTS_PACKAGE);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
for (const name of SERVICE_EXPORTS) {
|
|
31
|
+
const cls = mod === null || mod === void 0 ? void 0 : mod[name];
|
|
32
|
+
if (typeof cls !== 'function')
|
|
33
|
+
continue;
|
|
34
|
+
const method = METHOD_NAMES.find(m => { var _a; return typeof ((_a = cls.prototype) === null || _a === void 0 ? void 0 : _a[m]) === 'function'; });
|
|
35
|
+
if (!method)
|
|
36
|
+
continue;
|
|
37
|
+
let svc;
|
|
38
|
+
try {
|
|
39
|
+
svc = moduleRef.get(cls, { strict: false });
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
svc = null;
|
|
43
|
+
}
|
|
44
|
+
if (!svc)
|
|
45
|
+
continue;
|
|
46
|
+
return {
|
|
47
|
+
source: `${PAYMENTS_PACKAGE}:${name}.${method}`,
|
|
48
|
+
async create(ctx, input) {
|
|
49
|
+
const r = await svc[method](ctx, input);
|
|
50
|
+
if ((r === null || r === void 0 ? void 0 : r.errorCode) || (r === null || r === void 0 ? void 0 : r.error))
|
|
51
|
+
throw new Error(String(r.message || r.error || r.errorCode));
|
|
52
|
+
if (!(r === null || r === void 0 ? void 0 : r.url))
|
|
53
|
+
throw new Error('HULO Payments did not return a pay link');
|
|
54
|
+
return { url: String(r.url), ref: String(r.ref || r.reference || r.id || ''), expiresAt: r.expiresAt, provider: r.provider };
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
core_1.Logger.verbose(`${PAYMENTS_PACKAGE} is installed but exposes no pay-link service; quote pay links are off`, loggerCtx);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=pay-links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay-links.js","sourceRoot":"","sources":["../src/pay-links.ts"],"names":[],"mappings":";;AAuCA,wDA8BC;AApED,wCAAuD;AAEvD,MAAM,SAAS,GAAG,YAAY,CAAC;AAwB/B,MAAM,gBAAgB,GAAG,qCAAqC,CAAC;AAC/D,iHAAiH;AACjH,MAAM,eAAe,GAAG,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;AACrF,MAAM,YAAY,GAAG,CAAC,eAAe,EAAE,uBAAuB,CAAC,C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AC,MAAM,CAAC,GAAG,EAAE,KAAK;gBACnB,MAAM,CAAC,GAAQ,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBAC7C,IAAI,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,SAAS,MAAI,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,KAAK,CAAA;oBAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC3F,IAAI,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,GAAG,CAAA;oBAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;gBACxE,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;YACjI,CAAC;SACJ,CAAC;IACN,CAAC;IACD,aAAM,CAAC,OAAO,CAAC,GAAG,gBAAgB,wEAAwE,EAAE,SAAS,CAAC,CAAC;IACvH,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { ModuleRef } from '@nestjs/core';
|
|
3
|
+
import { EventBus, OrderService, RequestContext, TransactionalConnection } from '@vendure/core';
|
|
4
|
+
import { QuotationProService } from './pro.service';
|
|
5
|
+
import { QuotePayLinkProvider } from './pay-links';
|
|
6
|
+
import { QuotationService } from './quotation.service';
|
|
7
|
+
/**
|
|
8
|
+
* Taking payment for an accepted quote.
|
|
9
|
+
*
|
|
10
|
+
* Pay link (free): the accepted quote becomes a Vendure draft order at the
|
|
11
|
+
* quoted total (the usual conversion), the order moves to ArrangingPayment,
|
|
12
|
+
* and a pay link for it comes from HULO Payments for Vendure (detected at
|
|
13
|
+
* runtime; no dependency) or from the host's own `payLinks` provider. With
|
|
14
|
+
* "Pay link on acceptance" on, this happens when the customer accepts and the
|
|
15
|
+
* link is e-mailed to them; staff can also create and e-mail it by hand.
|
|
16
|
+
*
|
|
17
|
+
* Deposits (premium): an accepted quote is paid in two parts on the same
|
|
18
|
+
* order, a deposit link and then a balance link. Deposit + balance = the
|
|
19
|
+
* quoted total exactly, in minor units. Each link is claimed before it is
|
|
20
|
+
* created (a double click cannot make two), and the quote is marked paid
|
|
21
|
+
* only when the order's settled payments cover the whole total.
|
|
22
|
+
*
|
|
23
|
+
* Payment state is read from Vendure itself (payment and order state events),
|
|
24
|
+
* so it works with any payment method that lands on the order.
|
|
25
|
+
*/
|
|
26
|
+
export declare class QuotationPaymentService implements OnModuleInit, OnApplicationBootstrap {
|
|
27
|
+
private core;
|
|
28
|
+
private pro;
|
|
29
|
+
private connection;
|
|
30
|
+
private orderService;
|
|
31
|
+
private eventBus;
|
|
32
|
+
private moduleRef;
|
|
33
|
+
private provider;
|
|
34
|
+
constructor(core: QuotationService, pro: QuotationProService, connection: TransactionalConnection, orderService: OrderService, eventBus: EventBus, moduleRef: ModuleRef);
|
|
35
|
+
private get db();
|
|
36
|
+
onModuleInit(): Promise<void>;
|
|
37
|
+
onApplicationBootstrap(): void;
|
|
38
|
+
/** The pay-link provider, found once (host option, else HULO Payments for Vendure). */
|
|
39
|
+
payLinkProvider(): (QuotePayLinkProvider & {
|
|
40
|
+
source: string;
|
|
41
|
+
}) | null;
|
|
42
|
+
available(): boolean;
|
|
43
|
+
depositRow(quoteId: number): Promise<any | null>;
|
|
44
|
+
private ensureDepositRow;
|
|
45
|
+
/** The deposit this quote would take now: [pct, deposit, balance]; deposit 0 = none. Needs premium. */
|
|
46
|
+
depositPlan(q: any): Promise<{
|
|
47
|
+
pct: number;
|
|
48
|
+
deposit: number;
|
|
49
|
+
balance: number;
|
|
50
|
+
}>;
|
|
51
|
+
/** Per-quote deposit: '' = the default rule, 'none', or 'pct' with a percentage. Premium. */
|
|
52
|
+
setDepositOverride(quoteId: number, mode: string, pctIn: unknown): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Turn an accepted quote into something the customer can pay: the draft
|
|
55
|
+
* order (converted here when it is not yet), moved to ArrangingPayment, and
|
|
56
|
+
* a pay link for the whole total, or for the deposit when one applies.
|
|
57
|
+
* The quote is claimed first (payRef '' → 'creating'), so a double click
|
|
58
|
+
* or a retried request cannot make two links; a failure releases it.
|
|
59
|
+
*/
|
|
60
|
+
createPayLink(quoteId: number, actor: string, opts?: {
|
|
61
|
+
email?: boolean;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
ok: boolean;
|
|
64
|
+
reason?: string;
|
|
65
|
+
url?: string;
|
|
66
|
+
part?: 'full' | 'deposit';
|
|
67
|
+
}>;
|
|
68
|
+
/** The request context on the quote's channel and currency. */
|
|
69
|
+
private orderCtx;
|
|
70
|
+
/**
|
|
71
|
+
* Move the quote's draft order to ArrangingPayment (where payments can land).
|
|
72
|
+
* A draft needs a customer (set at conversion) and, by default, a shipping
|
|
73
|
+
* method: a free one is picked when the channel has one (a quote's price
|
|
74
|
+
* never includes shipping). Otherwise the admin is told what is missing.
|
|
75
|
+
*/
|
|
76
|
+
private readyForPayment;
|
|
77
|
+
/** What the customer pays now: the deposit, then the balance, or the whole total. */
|
|
78
|
+
paymentState(q: any): Promise<{
|
|
79
|
+
url: string;
|
|
80
|
+
label: string;
|
|
81
|
+
amount: number;
|
|
82
|
+
paid: boolean;
|
|
83
|
+
due: 'deposit' | 'balance' | 'full' | '';
|
|
84
|
+
deposit: any | null;
|
|
85
|
+
}>;
|
|
86
|
+
/** For the customer page, the PDF and "My quotes". */
|
|
87
|
+
private pageExtras;
|
|
88
|
+
/** E-mail the link that is due now (deposit, balance or the whole total). */
|
|
89
|
+
emailPayLink(quoteId: number, actor: string): Promise<{
|
|
90
|
+
ok: boolean;
|
|
91
|
+
reason?: string;
|
|
92
|
+
}>;
|
|
93
|
+
/** The customer accepted: with "Pay link on acceptance" on, create the link and e-mail it. */
|
|
94
|
+
private onAccepted;
|
|
95
|
+
/**
|
|
96
|
+
* The balance pay link, once the deposit is paid. Claimed first ('' →
|
|
97
|
+
* 'creating'), so a double click cannot make two; a failure releases it.
|
|
98
|
+
* Works whatever the licence state, so a deposit taken is always completed.
|
|
99
|
+
*/
|
|
100
|
+
createBalance(quoteId: number, actor: string, opts?: {
|
|
101
|
+
email?: boolean;
|
|
102
|
+
}): Promise<{
|
|
103
|
+
ok: boolean;
|
|
104
|
+
reason?: string;
|
|
105
|
+
url?: string;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* Payments landed on an order: if it belongs to a quote, record the
|
|
109
|
+
* deposit as paid once the settled payments cover it, and the quote as
|
|
110
|
+
* paid once they cover the whole quoted total (or the order is paid).
|
|
111
|
+
* Every write is conditional, so repeated events record nothing twice.
|
|
112
|
+
*/
|
|
113
|
+
syncOrder(ctx: RequestContext, orderId: number): Promise<void>;
|
|
114
|
+
/** For the admin quote screen. */
|
|
115
|
+
adminInfo(quoteId: number): Promise<any>;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=payment.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.service.d.ts","sourceRoot":"","sources":["../src/payment.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,sBAAsB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACH,QAAQ,EAAiB,YAAY,EACrC,cAAc,EAAE,uBAAuB,EAC1C,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAmB,mBAAmB,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