@saasicat/nest 0.25.0 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_entries.cjs +25 -5
- package/dist/billing/index.js +2 -2
- package/dist/{chunk-VQQWF7MW.js → chunk-37HEKVDH.js} +25 -5
- package/dist/{chunk-4O6R6ARQ.js → chunk-B6IWLV7R.js} +1 -1
- package/dist/{chunk-RPZKPFWI.js → chunk-TCBYOFAC.js} +2 -2
- package/dist/{chunk-A7FHAN2I.js → chunk-YWDLYOFN.js} +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/platform/index.js +4 -4
- package/dist/promo/index.d.cts +48 -2
- package/dist/promo/index.d.ts +48 -2
- package/dist/promo/index.js +2 -2
- package/dist/testing/index.js +4 -4
- package/package.json +4 -4
package/dist/_entries.cjs
CHANGED
|
@@ -4820,12 +4820,32 @@ function addCycles(date, cycle, n) {
|
|
|
4820
4820
|
return r;
|
|
4821
4821
|
}
|
|
4822
4822
|
__name(addCycles, "addCycles");
|
|
4823
|
-
|
|
4823
|
+
var LEGACY_LABEL_LOCALE = "de-DE";
|
|
4824
|
+
var LEGACY_LABEL_CURRENCY = "EUR";
|
|
4825
|
+
var ICU_NON_BREAKING_SPACES = /[\u00A0\u202F]/g;
|
|
4826
|
+
function requireSupportedLocale(locale) {
|
|
4827
|
+
if (Intl.NumberFormat.supportedLocalesOf([
|
|
4828
|
+
locale
|
|
4829
|
+
]).length === 0) {
|
|
4830
|
+
throw new RangeError(`buildLabel: locale "${locale}" names a language this runtime cannot serve. It would be formatted as "${new Intl.NumberFormat(locale).resolvedOptions().locale}" instead \u2014 a language nobody chose. Pass a tag the runtime serves.`);
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4833
|
+
__name(requireSupportedLocale, "requireSupportedLocale");
|
|
4834
|
+
function formatPromoValue(value, valueType, { locale = LEGACY_LABEL_LOCALE, currency = LEGACY_LABEL_CURRENCY }) {
|
|
4835
|
+
requireSupportedLocale(locale);
|
|
4836
|
+
const numberFormat = valueType === "PERCENT" ? {
|
|
4837
|
+
style: "unit",
|
|
4838
|
+
unit: "percent"
|
|
4839
|
+
} : {
|
|
4840
|
+
style: "currency",
|
|
4841
|
+
currency
|
|
4842
|
+
};
|
|
4843
|
+
return new Intl.NumberFormat(locale, numberFormat).format(value).replace(ICU_NON_BREAKING_SPACES, " ");
|
|
4844
|
+
}
|
|
4845
|
+
__name(formatPromoValue, "formatPromoValue");
|
|
4846
|
+
function buildLabel(code, cycle, options = {}) {
|
|
4824
4847
|
const value = Number(code.value);
|
|
4825
|
-
const valueStr = code.valueType
|
|
4826
|
-
minimumFractionDigits: 2,
|
|
4827
|
-
maximumFractionDigits: 2
|
|
4828
|
-
})} \u20AC`;
|
|
4848
|
+
const valueStr = formatPromoValue(value, code.valueType, options);
|
|
4829
4849
|
if (code.durationType === "ONCE") {
|
|
4830
4850
|
return `${valueStr} once`;
|
|
4831
4851
|
}
|
package/dist/billing/index.js
CHANGED
|
@@ -60,8 +60,8 @@ import {
|
|
|
60
60
|
periodEndWithMinLead,
|
|
61
61
|
resolveBundleCancelEffectiveAt,
|
|
62
62
|
resolveBundlePriceNet
|
|
63
|
-
} from "../chunk-
|
|
64
|
-
import "../chunk-
|
|
63
|
+
} from "../chunk-YWDLYOFN.js";
|
|
64
|
+
import "../chunk-37HEKVDH.js";
|
|
65
65
|
import "../chunk-B7NRY2LV.js";
|
|
66
66
|
import {
|
|
67
67
|
AUDIT_CONTEXT_RESOLVER_TOKEN,
|
|
@@ -43,12 +43,32 @@ function addCycles(date, cycle, n) {
|
|
|
43
43
|
return r;
|
|
44
44
|
}
|
|
45
45
|
__name(addCycles, "addCycles");
|
|
46
|
-
|
|
46
|
+
var LEGACY_LABEL_LOCALE = "de-DE";
|
|
47
|
+
var LEGACY_LABEL_CURRENCY = "EUR";
|
|
48
|
+
var ICU_NON_BREAKING_SPACES = /[\u00A0\u202F]/g;
|
|
49
|
+
function requireSupportedLocale(locale) {
|
|
50
|
+
if (Intl.NumberFormat.supportedLocalesOf([
|
|
51
|
+
locale
|
|
52
|
+
]).length === 0) {
|
|
53
|
+
throw new RangeError(`buildLabel: locale "${locale}" names a language this runtime cannot serve. It would be formatted as "${new Intl.NumberFormat(locale).resolvedOptions().locale}" instead \u2014 a language nobody chose. Pass a tag the runtime serves.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
__name(requireSupportedLocale, "requireSupportedLocale");
|
|
57
|
+
function formatPromoValue(value, valueType, { locale = LEGACY_LABEL_LOCALE, currency = LEGACY_LABEL_CURRENCY }) {
|
|
58
|
+
requireSupportedLocale(locale);
|
|
59
|
+
const numberFormat = valueType === "PERCENT" ? {
|
|
60
|
+
style: "unit",
|
|
61
|
+
unit: "percent"
|
|
62
|
+
} : {
|
|
63
|
+
style: "currency",
|
|
64
|
+
currency
|
|
65
|
+
};
|
|
66
|
+
return new Intl.NumberFormat(locale, numberFormat).format(value).replace(ICU_NON_BREAKING_SPACES, " ");
|
|
67
|
+
}
|
|
68
|
+
__name(formatPromoValue, "formatPromoValue");
|
|
69
|
+
function buildLabel(code, cycle, options = {}) {
|
|
47
70
|
const value = Number(code.value);
|
|
48
|
-
const valueStr = code.valueType
|
|
49
|
-
minimumFractionDigits: 2,
|
|
50
|
-
maximumFractionDigits: 2
|
|
51
|
-
})} \u20AC`;
|
|
71
|
+
const valueStr = formatPromoValue(value, code.valueType, options);
|
|
52
72
|
if (code.durationType === "ONCE") {
|
|
53
73
|
return `${valueStr} once`;
|
|
54
74
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PromoCodesModule
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-B6IWLV7R.js";
|
|
4
4
|
import {
|
|
5
5
|
AdminManifestModule,
|
|
6
6
|
AdminManifestService,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
SubscriptionBundleModule,
|
|
18
18
|
TenantBillingModule,
|
|
19
19
|
isPlatformFeatureGuard
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-YWDLYOFN.js";
|
|
21
21
|
import {
|
|
22
22
|
SubscriptionContractModule
|
|
23
23
|
} from "./chunk-B7NRY2LV.js";
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { P as ProviderSpec, a as asProvider } from './di-CcNeq9v-.cjs';
|
|
2
2
|
import { S as SetupService } from './define-saasicat-D30I-WET.cjs';
|
|
3
3
|
export { a as SAASICAT_PUBLIC_ROUTE_KEY, b as SETUP_CONFIG_TOKEN, c as SETUP_PROVISIONING_PORT_TOKEN, d as SaaSiCatPublicRoute, e as SetupConfig, f as defineSaaSiCat, i as isSaaSiCatPublicRoute } from './define-saasicat-D30I-WET.cjs';
|
|
4
|
-
export { CreatePromoCodeDto, PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, PROMO_CODE_REPOSITORY_TOKEN, PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, PROMO_SERVICE_CONFIG_TOKEN, PROMO_SUBSCRIPTION_LOOKUP_TOKEN, PROMO_TRANSACTION_RUNNER_TOKEN, PreviewPromoCodeDto, PromoCodeExpirer, PromoCodeForCalc, PromoCodePublicController, UpdatePromoCodeDto, addCycles, buildLabel, buildPromoCodeAdminController, computeDiscountGross, computeDiscountedGross, computeIncludedVat, computeRegularStartsAt, grossFromNet, round2 } from './promo/index.cjs';
|
|
4
|
+
export { CreatePromoCodeDto, PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, PROMO_CODE_REPOSITORY_TOKEN, PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, PROMO_SERVICE_CONFIG_TOKEN, PROMO_SUBSCRIPTION_LOOKUP_TOKEN, PROMO_TRANSACTION_RUNNER_TOKEN, PreviewPromoCodeDto, PromoCodeExpirer, PromoCodeForCalc, PromoCodePublicController, PromoLabelOptions, UpdatePromoCodeDto, addCycles, buildLabel, buildPromoCodeAdminController, computeDiscountGross, computeDiscountedGross, computeIncludedVat, computeRegularStartsAt, grossFromNet, round2 } from './promo/index.cjs';
|
|
5
5
|
export { a as PreviewInput, b as PreviewInvalid, c as PreviewReason, d as PreviewResult, e as PreviewValid, f as PromoCodeStats, g as PromoCodesService, P as PromoServiceConfig, R as RedeemInput } from './service-D48clObR.cjs';
|
|
6
6
|
export { P as PromoCodeRateLimitGuard, h as hashIp, i as ipFingerprint } from './rate-limit.guard-dntqAlfZ.cjs';
|
|
7
7
|
export { P as PromoCodesModule, a as PromoCodesModuleOptions } from './module-CHMIyWlf.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { P as ProviderSpec, a as asProvider } from './di-CcNeq9v-.js';
|
|
2
2
|
import { S as SetupService } from './define-saasicat-BK6RRWWG.js';
|
|
3
3
|
export { a as SAASICAT_PUBLIC_ROUTE_KEY, b as SETUP_CONFIG_TOKEN, c as SETUP_PROVISIONING_PORT_TOKEN, d as SaaSiCatPublicRoute, e as SetupConfig, f as defineSaaSiCat, i as isSaaSiCatPublicRoute } from './define-saasicat-BK6RRWWG.js';
|
|
4
|
-
export { CreatePromoCodeDto, PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, PROMO_CODE_REPOSITORY_TOKEN, PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, PROMO_SERVICE_CONFIG_TOKEN, PROMO_SUBSCRIPTION_LOOKUP_TOKEN, PROMO_TRANSACTION_RUNNER_TOKEN, PreviewPromoCodeDto, PromoCodeExpirer, PromoCodeForCalc, PromoCodePublicController, UpdatePromoCodeDto, addCycles, buildLabel, buildPromoCodeAdminController, computeDiscountGross, computeDiscountedGross, computeIncludedVat, computeRegularStartsAt, grossFromNet, round2 } from './promo/index.js';
|
|
4
|
+
export { CreatePromoCodeDto, PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, PROMO_CODE_REPOSITORY_TOKEN, PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, PROMO_SERVICE_CONFIG_TOKEN, PROMO_SUBSCRIPTION_LOOKUP_TOKEN, PROMO_TRANSACTION_RUNNER_TOKEN, PreviewPromoCodeDto, PromoCodeExpirer, PromoCodeForCalc, PromoCodePublicController, PromoLabelOptions, UpdatePromoCodeDto, addCycles, buildLabel, buildPromoCodeAdminController, computeDiscountGross, computeDiscountedGross, computeIncludedVat, computeRegularStartsAt, grossFromNet, round2 } from './promo/index.js';
|
|
5
5
|
export { a as PreviewInput, b as PreviewInvalid, c as PreviewReason, d as PreviewResult, e as PreviewValid, f as PromoCodeStats, g as PromoCodesService, P as PromoServiceConfig, R as RedeemInput } from './service-D48clObR.js';
|
|
6
6
|
export { P as PromoCodeRateLimitGuard, h as hashIp, i as ipFingerprint } from './rate-limit.guard-dntqAlfZ.js';
|
|
7
7
|
export { P as PromoCodesModule, a as PromoCodesModuleOptions } from './module-BE17XFLg.js';
|
package/dist/index.js
CHANGED
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
SetupController,
|
|
71
71
|
SetupModule,
|
|
72
72
|
SetupService
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-TCBYOFAC.js";
|
|
74
74
|
import {
|
|
75
75
|
CreatePromoCodeDto,
|
|
76
76
|
PreviewPromoCodeDto,
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
buildPromoCodeAdminController,
|
|
83
83
|
hashIp,
|
|
84
84
|
ipFingerprint
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-B6IWLV7R.js";
|
|
86
86
|
import {
|
|
87
87
|
ADMIN_MANIFEST_CONFIG,
|
|
88
88
|
ADMIN_RESOURCES_PORT_TOKEN,
|
|
@@ -172,7 +172,7 @@ import {
|
|
|
172
172
|
periodEndWithMinLead,
|
|
173
173
|
resolveBundleCancelEffectiveAt,
|
|
174
174
|
resolveBundlePriceNet
|
|
175
|
-
} from "./chunk-
|
|
175
|
+
} from "./chunk-YWDLYOFN.js";
|
|
176
176
|
import {
|
|
177
177
|
PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN,
|
|
178
178
|
PROMO_CODE_REPOSITORY_TOKEN,
|
|
@@ -188,7 +188,7 @@ import {
|
|
|
188
188
|
computeDiscountGross,
|
|
189
189
|
computeDiscountedGross,
|
|
190
190
|
computeRegularStartsAt
|
|
191
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-37HEKVDH.js";
|
|
192
192
|
import {
|
|
193
193
|
SubscriptionContractModule,
|
|
194
194
|
SubscriptionContractService,
|
package/dist/platform/index.js
CHANGED
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
SubscriptionPlanResolver,
|
|
18
18
|
TenantManifestService,
|
|
19
19
|
buildTenantManifestController
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-TCBYOFAC.js";
|
|
21
21
|
import {
|
|
22
22
|
PromoCodeRateLimitGuard
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-B6IWLV7R.js";
|
|
24
24
|
import {
|
|
25
25
|
AdminBypassRlsInterceptor,
|
|
26
26
|
AdminManifestModule,
|
|
@@ -41,10 +41,10 @@ import {
|
|
|
41
41
|
SubscriptionBundlesService,
|
|
42
42
|
TenantAdminGuard,
|
|
43
43
|
TenantBillingController
|
|
44
|
-
} from "../chunk-
|
|
44
|
+
} from "../chunk-YWDLYOFN.js";
|
|
45
45
|
import {
|
|
46
46
|
PromoCodesService
|
|
47
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-37HEKVDH.js";
|
|
48
48
|
import {
|
|
49
49
|
SubscriptionContractModule,
|
|
50
50
|
SubscriptionContractService
|
package/dist/promo/index.d.cts
CHANGED
|
@@ -31,7 +31,53 @@ declare function computeDiscountedGross(planGross: number, discountGross: number
|
|
|
31
31
|
*/
|
|
32
32
|
declare function computeRegularStartsAt(startsAt: Date, cycle: BillingCycle, durationType: PromoCodeDurationType, durationValue: number | null): Date;
|
|
33
33
|
declare function addCycles(date: Date, cycle: BillingCycle, n: number): Date;
|
|
34
|
-
|
|
34
|
+
/** Number locale and currency for {@link buildLabel}. */
|
|
35
|
+
interface PromoLabelOptions {
|
|
36
|
+
/**
|
|
37
|
+
* BCP-47 tag deciding grouping, decimal separator, and where the currency
|
|
38
|
+
* symbol sits: `'de-DE'` produces `1.234,56 €`, `'en-US'` produces
|
|
39
|
+
* `€1,234.56`.
|
|
40
|
+
*
|
|
41
|
+
* A tag whose LANGUAGE the runtime cannot serve is a configuration error
|
|
42
|
+
* and throws. `Intl` alone does not give that: it rejects a malformed tag,
|
|
43
|
+
* but a well-formed one it does not know — `'zz-ZZ'` — silently resolves to
|
|
44
|
+
* the runtime default, which on this one is `en-US`. An amount then reaches
|
|
45
|
+
* the customer formatted in a language nobody chose.
|
|
46
|
+
*
|
|
47
|
+
* The check reaches exactly that far, and it is worth knowing where it
|
|
48
|
+
* stops: `supportedLocalesOf` accepts an unknown REGION on a known language,
|
|
49
|
+
* so `'de-ED'` passes and formats as `de`. Measured, not assumed. That
|
|
50
|
+
* fallback stays inside the language the caller asked for, which is the
|
|
51
|
+
* difference between a typo costing a separator and costing a language.
|
|
52
|
+
*/
|
|
53
|
+
locale?: string;
|
|
54
|
+
/**
|
|
55
|
+
* ISO-4217 code for `ABSOLUTE` values, e.g. `'EUR'`, `'CHF'`, `'JPY'`.
|
|
56
|
+
* The code also decides the number of decimals — two for EUR, none for
|
|
57
|
+
* JPY — because the minor-unit count is a property of the currency, not a
|
|
58
|
+
* formatting preference. Percentages ignore this.
|
|
59
|
+
*
|
|
60
|
+
* Not checked against a list, unlike the locale. `Intl` rejects a code that
|
|
61
|
+
* is not three letters and renders a three-letter one it does not know as
|
|
62
|
+
* itself — `1.234,56 XBT` is wrong but visible, where a wrong locale is
|
|
63
|
+
* silent. And no enumeration available here separates a made-up code from a
|
|
64
|
+
* real one it omits: `Intl.supportedValuesOf('currency')` leaves out `XAU`,
|
|
65
|
+
* `XAG` and `XPT`, which are assigned. See `requireSupportedLocale`.
|
|
66
|
+
*/
|
|
67
|
+
currency?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Human-readable summary of a promo code, e.g. `25 % once` or
|
|
71
|
+
* `1.234,56 € for the first month`.
|
|
72
|
+
*
|
|
73
|
+
* The words are English and cannot be swapped here — translating them needs
|
|
74
|
+
* the parts (`valueType`, `value`, `durationType`, `durationValue`), which the
|
|
75
|
+
* promo preview response already carries next to this string. Composing the
|
|
76
|
+
* sentence in the consumer's own i18n layer is the better answer and the one
|
|
77
|
+
* planned for the next breaking release; until then `options` at least stops
|
|
78
|
+
* the function from deciding number locale and currency for everyone.
|
|
79
|
+
*/
|
|
80
|
+
declare function buildLabel(code: Pick<PromoCodeForCalc, 'valueType' | 'value' | 'durationType' | 'durationValue'>, cycle: BillingCycle, options?: PromoLabelOptions): string;
|
|
35
81
|
|
|
36
82
|
declare function round2(n: number): number;
|
|
37
83
|
/** Gross = net * (1 + vatRate/100). */
|
|
@@ -120,4 +166,4 @@ declare class UpdatePromoCodeDto {
|
|
|
120
166
|
revenueDeductionAccount?: string | null;
|
|
121
167
|
}
|
|
122
168
|
|
|
123
|
-
export { CreatePromoCodeDto, PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, PROMO_CODE_REPOSITORY_TOKEN, PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, PROMO_SERVICE_CONFIG_TOKEN, PROMO_SUBSCRIPTION_LOOKUP_TOKEN, PROMO_TRANSACTION_RUNNER_TOKEN, PreviewPromoCodeDto, PreviewResult, PromoCodeExpirer, type PromoCodeForCalc, PromoCodePublicController, PromoCodesService, UpdatePromoCodeDto, addCycles, buildLabel, buildPromoCodeAdminController, computeDiscountGross, computeDiscountedGross, computeIncludedVat, computeRegularStartsAt, grossFromNet, round2 };
|
|
169
|
+
export { CreatePromoCodeDto, PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, PROMO_CODE_REPOSITORY_TOKEN, PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, PROMO_SERVICE_CONFIG_TOKEN, PROMO_SUBSCRIPTION_LOOKUP_TOKEN, PROMO_TRANSACTION_RUNNER_TOKEN, PreviewPromoCodeDto, PreviewResult, PromoCodeExpirer, type PromoCodeForCalc, PromoCodePublicController, PromoCodesService, type PromoLabelOptions, UpdatePromoCodeDto, addCycles, buildLabel, buildPromoCodeAdminController, computeDiscountGross, computeDiscountedGross, computeIncludedVat, computeRegularStartsAt, grossFromNet, round2 };
|
package/dist/promo/index.d.ts
CHANGED
|
@@ -31,7 +31,53 @@ declare function computeDiscountedGross(planGross: number, discountGross: number
|
|
|
31
31
|
*/
|
|
32
32
|
declare function computeRegularStartsAt(startsAt: Date, cycle: BillingCycle, durationType: PromoCodeDurationType, durationValue: number | null): Date;
|
|
33
33
|
declare function addCycles(date: Date, cycle: BillingCycle, n: number): Date;
|
|
34
|
-
|
|
34
|
+
/** Number locale and currency for {@link buildLabel}. */
|
|
35
|
+
interface PromoLabelOptions {
|
|
36
|
+
/**
|
|
37
|
+
* BCP-47 tag deciding grouping, decimal separator, and where the currency
|
|
38
|
+
* symbol sits: `'de-DE'` produces `1.234,56 €`, `'en-US'` produces
|
|
39
|
+
* `€1,234.56`.
|
|
40
|
+
*
|
|
41
|
+
* A tag whose LANGUAGE the runtime cannot serve is a configuration error
|
|
42
|
+
* and throws. `Intl` alone does not give that: it rejects a malformed tag,
|
|
43
|
+
* but a well-formed one it does not know — `'zz-ZZ'` — silently resolves to
|
|
44
|
+
* the runtime default, which on this one is `en-US`. An amount then reaches
|
|
45
|
+
* the customer formatted in a language nobody chose.
|
|
46
|
+
*
|
|
47
|
+
* The check reaches exactly that far, and it is worth knowing where it
|
|
48
|
+
* stops: `supportedLocalesOf` accepts an unknown REGION on a known language,
|
|
49
|
+
* so `'de-ED'` passes and formats as `de`. Measured, not assumed. That
|
|
50
|
+
* fallback stays inside the language the caller asked for, which is the
|
|
51
|
+
* difference between a typo costing a separator and costing a language.
|
|
52
|
+
*/
|
|
53
|
+
locale?: string;
|
|
54
|
+
/**
|
|
55
|
+
* ISO-4217 code for `ABSOLUTE` values, e.g. `'EUR'`, `'CHF'`, `'JPY'`.
|
|
56
|
+
* The code also decides the number of decimals — two for EUR, none for
|
|
57
|
+
* JPY — because the minor-unit count is a property of the currency, not a
|
|
58
|
+
* formatting preference. Percentages ignore this.
|
|
59
|
+
*
|
|
60
|
+
* Not checked against a list, unlike the locale. `Intl` rejects a code that
|
|
61
|
+
* is not three letters and renders a three-letter one it does not know as
|
|
62
|
+
* itself — `1.234,56 XBT` is wrong but visible, where a wrong locale is
|
|
63
|
+
* silent. And no enumeration available here separates a made-up code from a
|
|
64
|
+
* real one it omits: `Intl.supportedValuesOf('currency')` leaves out `XAU`,
|
|
65
|
+
* `XAG` and `XPT`, which are assigned. See `requireSupportedLocale`.
|
|
66
|
+
*/
|
|
67
|
+
currency?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Human-readable summary of a promo code, e.g. `25 % once` or
|
|
71
|
+
* `1.234,56 € for the first month`.
|
|
72
|
+
*
|
|
73
|
+
* The words are English and cannot be swapped here — translating them needs
|
|
74
|
+
* the parts (`valueType`, `value`, `durationType`, `durationValue`), which the
|
|
75
|
+
* promo preview response already carries next to this string. Composing the
|
|
76
|
+
* sentence in the consumer's own i18n layer is the better answer and the one
|
|
77
|
+
* planned for the next breaking release; until then `options` at least stops
|
|
78
|
+
* the function from deciding number locale and currency for everyone.
|
|
79
|
+
*/
|
|
80
|
+
declare function buildLabel(code: Pick<PromoCodeForCalc, 'valueType' | 'value' | 'durationType' | 'durationValue'>, cycle: BillingCycle, options?: PromoLabelOptions): string;
|
|
35
81
|
|
|
36
82
|
declare function round2(n: number): number;
|
|
37
83
|
/** Gross = net * (1 + vatRate/100). */
|
|
@@ -120,4 +166,4 @@ declare class UpdatePromoCodeDto {
|
|
|
120
166
|
revenueDeductionAccount?: string | null;
|
|
121
167
|
}
|
|
122
168
|
|
|
123
|
-
export { CreatePromoCodeDto, PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, PROMO_CODE_REPOSITORY_TOKEN, PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, PROMO_SERVICE_CONFIG_TOKEN, PROMO_SUBSCRIPTION_LOOKUP_TOKEN, PROMO_TRANSACTION_RUNNER_TOKEN, PreviewPromoCodeDto, PreviewResult, PromoCodeExpirer, type PromoCodeForCalc, PromoCodePublicController, PromoCodesService, UpdatePromoCodeDto, addCycles, buildLabel, buildPromoCodeAdminController, computeDiscountGross, computeDiscountedGross, computeIncludedVat, computeRegularStartsAt, grossFromNet, round2 };
|
|
169
|
+
export { CreatePromoCodeDto, PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, PROMO_CODE_REPOSITORY_TOKEN, PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, PROMO_SERVICE_CONFIG_TOKEN, PROMO_SUBSCRIPTION_LOOKUP_TOKEN, PROMO_TRANSACTION_RUNNER_TOKEN, PreviewPromoCodeDto, PreviewResult, PromoCodeExpirer, type PromoCodeForCalc, PromoCodePublicController, PromoCodesService, type PromoLabelOptions, UpdatePromoCodeDto, addCycles, buildLabel, buildPromoCodeAdminController, computeDiscountGross, computeDiscountedGross, computeIncludedVat, computeRegularStartsAt, grossFromNet, round2 };
|
package/dist/promo/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
buildPromoCodeAdminController,
|
|
11
11
|
hashIp,
|
|
12
12
|
ipFingerprint
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-B6IWLV7R.js";
|
|
14
14
|
import {
|
|
15
15
|
PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN,
|
|
16
16
|
PROMO_CODE_REPOSITORY_TOKEN,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
computeDiscountGross,
|
|
27
27
|
computeDiscountedGross,
|
|
28
28
|
computeRegularStartsAt
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-37HEKVDH.js";
|
|
30
30
|
import "../chunk-E56W4U2P.js";
|
|
31
31
|
import "../chunk-YSC46BGM.js";
|
|
32
32
|
import {
|
package/dist/testing/index.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
StaticEntitlementService,
|
|
6
6
|
StaticFeatureGuard,
|
|
7
7
|
StaticPlanResolver
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-TCBYOFAC.js";
|
|
9
|
+
import "../chunk-B6IWLV7R.js";
|
|
10
10
|
import "../chunk-SN5UOC43.js";
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-YWDLYOFN.js";
|
|
12
|
+
import "../chunk-37HEKVDH.js";
|
|
13
13
|
import "../chunk-B7NRY2LV.js";
|
|
14
14
|
import "../chunk-7X5MSAIL.js";
|
|
15
15
|
import "../chunk-WPUVJRIN.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saasicat/nest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"description": "NestJS implementation of SaaSiCat: capability discovery, catalog packaging, contracts, entitlement enforcement, billing and admin APIs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -137,8 +137,8 @@
|
|
|
137
137
|
"js-yaml": "^4.3.1",
|
|
138
138
|
"otplib": "^13.4.1",
|
|
139
139
|
"qrcode": "^1.5.4",
|
|
140
|
-
"@saasicat/spec": "^0.
|
|
141
|
-
"@saasicat/types": "^0.
|
|
140
|
+
"@saasicat/spec": "^0.26.1",
|
|
141
|
+
"@saasicat/types": "^0.26.1"
|
|
142
142
|
},
|
|
143
143
|
"peerDependencies": {
|
|
144
144
|
"@nestjs/common": "^11.0.0",
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
"access": "public"
|
|
181
181
|
},
|
|
182
182
|
"scripts": {
|
|
183
|
-
"build": "tsup && tsup --config tsup.cjs.config.ts && node scripts/build-cjs-stubs.mjs",
|
|
183
|
+
"build": "node ../../scripts/build-and-prune.mjs \"tsup && tsup --config tsup.cjs.config.ts && node scripts/build-cjs-stubs.mjs\"",
|
|
184
184
|
"pretest": "pnpm run build",
|
|
185
185
|
"test": "node --test tests/**/*.test.js"
|
|
186
186
|
}
|