@owlmeans/payment 0.1.18-rc.47 → 0.1.18-rc.49
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/README.md +21 -21
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/entitlements/SKILL.md +7 -6
- package/agent-meta/skills/payment/SKILL.md +130 -118
- package/build/checkout/index.d.ts +1 -0
- package/build/checkout/index.d.ts.map +1 -1
- package/build/checkout/index.js.map +1 -1
- package/build/checkout/narrow/types.d.ts +25 -0
- package/build/checkout/narrow/types.d.ts.map +1 -0
- package/build/checkout/narrow/types.js +2 -0
- package/build/checkout/narrow/types.js.map +1 -0
- package/build/checkout/narrow.d.ts +4 -18
- package/build/checkout/narrow.d.ts.map +1 -1
- package/build/checkout/narrow.js +43 -54
- package/build/checkout/narrow.js.map +1 -1
- package/build/checkout/types.d.ts +2 -2
- package/build/checkout/types.d.ts.map +1 -1
- package/build/consts.d.ts +2 -0
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +2 -0
- package/build/consts.js.map +1 -1
- package/build/consumer/consts.local.d.ts +3 -0
- package/build/consumer/consts.local.d.ts.map +1 -1
- package/build/consumer/consts.local.js +9 -0
- package/build/consumer/consts.local.js.map +1 -1
- package/build/consumer/copy/types.d.ts +56 -0
- package/build/consumer/copy/types.d.ts.map +1 -0
- package/build/consumer/copy/types.js +2 -0
- package/build/consumer/copy/types.js.map +1 -0
- package/build/consumer/copy.d.ts +8 -40
- package/build/consumer/copy.d.ts.map +1 -1
- package/build/consumer/copy.js +75 -100
- package/build/consumer/copy.js.map +1 -1
- package/build/consumer/deadline/types.d.ts +30 -0
- package/build/consumer/deadline/types.d.ts.map +1 -0
- package/build/consumer/deadline/types.js +2 -0
- package/build/consumer/deadline/types.js.map +1 -0
- package/build/consumer/deadline.d.ts +6 -21
- package/build/consumer/deadline.d.ts.map +1 -1
- package/build/consumer/deadline.js +40 -51
- package/build/consumer/deadline.js.map +1 -1
- package/build/consumer/fifo/types.d.ts +17 -0
- package/build/consumer/fifo/types.d.ts.map +1 -0
- package/build/consumer/fifo/types.js +2 -0
- package/build/consumer/fifo/types.js.map +1 -0
- package/build/consumer/fifo.d.ts +3 -13
- package/build/consumer/fifo.d.ts.map +1 -1
- package/build/consumer/fifo.js +30 -30
- package/build/consumer/fifo.js.map +1 -1
- package/build/consumer/index.d.ts +6 -0
- package/build/consumer/index.d.ts.map +1 -1
- package/build/consumer/index.js.map +1 -1
- package/build/consumer/policy/types.d.ts +20 -0
- package/build/consumer/policy/types.d.ts.map +1 -0
- package/build/consumer/policy/types.js +2 -0
- package/build/consumer/policy/types.js.map +1 -0
- package/build/consumer/policy.d.ts +6 -12
- package/build/consumer/policy.d.ts.map +1 -1
- package/build/consumer/policy.js +63 -65
- package/build/consumer/policy.js.map +1 -1
- package/build/consumer/refund/types.d.ts +27 -0
- package/build/consumer/refund/types.d.ts.map +1 -0
- package/build/consumer/refund/types.js +2 -0
- package/build/consumer/refund/types.js.map +1 -0
- package/build/consumer/refund.d.ts +5 -20
- package/build/consumer/refund.d.ts.map +1 -1
- package/build/consumer/refund.js +85 -96
- package/build/consumer/refund.js.map +1 -1
- package/build/consumer/refusal.d.ts.map +1 -1
- package/build/consumer/refusal.js +2 -7
- package/build/consumer/refusal.js.map +1 -1
- package/build/consumer/revive/types.d.ts +19 -0
- package/build/consumer/revive/types.d.ts.map +1 -0
- package/build/consumer/revive/types.js +2 -0
- package/build/consumer/revive/types.js.map +1 -0
- package/build/consumer/revive.d.ts +8 -8
- package/build/consumer/revive.d.ts.map +1 -1
- package/build/consumer/revive.js +37 -23
- package/build/consumer/revive.js.map +1 -1
- package/build/consumer/types.d.ts +6 -6
- package/build/consumer/types.d.ts.map +1 -1
- package/build/consumer/types.local.d.ts +2 -1
- package/build/consumer/types.local.d.ts.map +1 -1
- package/build/countries.d.ts +0 -1
- package/build/countries.d.ts.map +1 -1
- package/build/countries.js +0 -1
- package/build/countries.js.map +1 -1
- package/build/entitled.d.ts +14 -0
- package/build/entitled.d.ts.map +1 -0
- package/build/entitled.js +17 -0
- package/build/entitled.js.map +1 -0
- package/build/entitlement/types.d.ts +29 -0
- package/build/entitlement/types.d.ts.map +1 -0
- package/build/entitlement/types.js +2 -0
- package/build/entitlement/types.js.map +1 -0
- package/build/entitlement.d.ts +6 -33
- package/build/entitlement.d.ts.map +1 -1
- package/build/entitlement.js +55 -79
- package/build/entitlement.js.map +1 -1
- package/build/estimate/types.d.ts +34 -0
- package/build/estimate/types.d.ts.map +1 -0
- package/build/estimate/types.js +2 -0
- package/build/estimate/types.js.map +1 -0
- package/build/estimate.d.ts +6 -26
- package/build/estimate.d.ts.map +1 -1
- package/build/estimate.js +61 -77
- package/build/estimate.js.map +1 -1
- package/build/i18n.js +25 -25
- package/build/i18n.js.map +1 -1
- package/build/index.d.ts +8 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/limit/types.d.ts +44 -0
- package/build/limit/types.d.ts.map +1 -0
- package/build/limit/types.js +2 -0
- package/build/limit/types.js.map +1 -0
- package/build/limit.d.ts +10 -28
- package/build/limit.d.ts.map +1 -1
- package/build/limit.js +79 -89
- package/build/limit.js.map +1 -1
- package/build/pricing/types.d.ts +13 -0
- package/build/pricing/types.d.ts.map +1 -0
- package/build/pricing/types.js +2 -0
- package/build/pricing/types.js.map +1 -0
- package/build/pricing.d.ts +7 -1
- package/build/pricing.d.ts.map +1 -1
- package/build/pricing.js +70 -59
- package/build/pricing.js.map +1 -1
- package/build/promo/types.d.ts +14 -0
- package/build/promo/types.d.ts.map +1 -0
- package/build/promo/types.js +2 -0
- package/build/promo/types.js.map +1 -0
- package/build/promo.d.ts +5 -9
- package/build/promo.d.ts.map +1 -1
- package/build/promo.js +17 -18
- package/build/promo.js.map +1 -1
- package/build/regions/types.d.ts +32 -0
- package/build/regions/types.d.ts.map +1 -0
- package/build/regions/types.js +2 -0
- package/build/regions/types.js.map +1 -0
- package/build/regions.d.ts +7 -21
- package/build/regions.d.ts.map +1 -1
- package/build/regions.js +39 -46
- package/build/regions.js.map +1 -1
- package/build/service.d.ts.map +1 -1
- package/build/service.js +9 -9
- package/build/service.js.map +1 -1
- package/build/view/types.d.ts +33 -0
- package/build/view/types.d.ts.map +1 -0
- package/build/view/types.js +2 -0
- package/build/view/types.js.map +1 -0
- package/build/view.d.ts +7 -24
- package/build/view.d.ts.map +1 -1
- package/build/view.js +69 -81
- package/build/view.js.map +1 -1
- package/package.json +11 -11
- package/src/checkout/index.ts +1 -0
- package/src/checkout/narrow/types.ts +27 -0
- package/src/checkout/narrow.ts +53 -58
- package/src/checkout/types.ts +1 -1
- package/src/consts.ts +3 -0
- package/src/consumer/consts.local.ts +11 -0
- package/src/consumer/copy/types.ts +54 -0
- package/src/consumer/copy.ts +93 -106
- package/src/consumer/deadline/types.ts +30 -0
- package/src/consumer/deadline.ts +45 -48
- package/src/consumer/fifo/types.ts +17 -0
- package/src/consumer/fifo.ts +33 -37
- package/src/consumer/index.ts +6 -0
- package/src/consumer/policy/types.ts +20 -0
- package/src/consumer/policy.ts +57 -51
- package/src/consumer/refund/types.ts +27 -0
- package/src/consumer/refund.ts +97 -101
- package/src/consumer/refusal.ts +2 -8
- package/src/consumer/revive/types.ts +23 -0
- package/src/consumer/revive.ts +56 -32
- package/src/consumer/types.local.ts +1 -1
- package/src/consumer/types.ts +4 -3
- package/src/countries.ts +0 -3
- package/src/entitled.ts +20 -0
- package/src/entitlement/types.ts +29 -0
- package/src/entitlement.ts +66 -85
- package/src/estimate/types.ts +34 -0
- package/src/estimate.ts +69 -77
- package/src/i18n.ts +26 -25
- package/src/index.ts +8 -1
- package/src/limit/types.ts +41 -0
- package/src/limit.ts +102 -96
- package/src/pricing/types.ts +13 -0
- package/src/pricing.ts +94 -71
- package/src/promo/types.ts +18 -0
- package/src/promo.ts +31 -26
- package/src/regions/types.ts +42 -0
- package/src/regions.ts +59 -48
- package/src/service.ts +9 -11
- package/src/view/types.ts +39 -0
- package/src/view.ts +98 -97
- package/tests/checkout-narrow.spec.ts +19 -19
- package/tests/consumer-copy.spec.ts +90 -90
- package/tests/consumer-deadline.spec.ts +21 -22
- package/tests/consumer-fifo.spec.ts +12 -12
- package/tests/consumer-refund.spec.ts +27 -29
- package/tests/consumer-regions.spec.ts +39 -39
- package/tests/consumer-wire.spec.ts +12 -11
- package/tests/contract.spec.ts +3 -3
- package/tests/entitlement.spec.ts +25 -25
- package/tests/estimate.spec.ts +26 -26
- package/tests/limit.spec.ts +33 -36
- package/tests/pricing.spec.ts +10 -13
- package/tests/view.spec.ts +24 -24
package/build/consumer/copy.js
CHANGED
|
@@ -2,111 +2,86 @@ import { LIB_NAMESPACE, resolveI18nResource } from '@owlmeans/i18n';
|
|
|
2
2
|
import '../i18n.js';
|
|
3
3
|
import { ConsentKind, CONSUMER_RIGHTS_RESOURCE } from '../consts.js';
|
|
4
4
|
import { ConsumerRightsError } from '../errors.js';
|
|
5
|
-
import {
|
|
5
|
+
import { consumerRightsPolicyHelper } from './policy.js';
|
|
6
6
|
const isTree = (value) => value != null && typeof value === 'object' && !Array.isArray(value);
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
export const createConsumerCopyHelper = () => {
|
|
8
|
+
const merge = (base, over) => {
|
|
9
|
+
const result = { ...base };
|
|
10
|
+
for (const [key, value] of Object.entries(over)) {
|
|
11
|
+
const current = result[key];
|
|
12
|
+
if (isTree(value)) {
|
|
13
|
+
result[key] = merge(isTree(current) ? current : {}, value);
|
|
14
|
+
}
|
|
15
|
+
else if (typeof value === 'string') {
|
|
16
|
+
result[key] = value;
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
const resolve = (lng) => resolveI18nResource(lng, CONSUMER_RIGHTS_RESOURCE, LIB_NAMESPACE);
|
|
22
|
+
const consumerRightsCopy = (lng) => {
|
|
23
|
+
const base = consumerRightsPolicyHelper.baseLanguageOf(lng);
|
|
24
|
+
let copy = merge({}, resolve('en') ?? {});
|
|
25
|
+
if (base !== '' && base !== 'en') {
|
|
26
|
+
copy = merge(copy, resolve(base) ?? {});
|
|
16
27
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
const resolve = (lng) => resolveI18nResource(lng, CONSUMER_RIGHTS_RESOURCE, LIB_NAMESPACE);
|
|
21
|
-
/**
|
|
22
|
-
* The consumer-rights copy of one language — the `payment-consumer-rights` bundles as registered
|
|
23
|
-
* (the package's own, merged under any application override made with
|
|
24
|
-
* `addI18nApp(lng, 'payment-consumer-rights', data, { ns: LIB_NAMESPACE })`), key by key over the
|
|
25
|
-
* English ones so a missing key still reads. Any language, independent of the active i18next
|
|
26
|
-
* language and without draining a bundle: this is what a server renders e-mails and paygate
|
|
27
|
-
* texts from, and what a dialog shows in the billing country's language.
|
|
28
|
-
*/
|
|
29
|
-
export const consumerRightsCopy = (lng) => {
|
|
30
|
-
const base = baseLanguageOf(lng);
|
|
31
|
-
let copy = merge({}, resolve('en') ?? {});
|
|
32
|
-
if (base !== '' && base !== 'en') {
|
|
33
|
-
copy = merge(copy, resolve(base) ?? {});
|
|
34
|
-
}
|
|
35
|
-
if (lng !== base && lng.trim() !== '') {
|
|
36
|
-
copy = merge(copy, resolve(lng) ?? {});
|
|
37
|
-
}
|
|
38
|
-
return copy;
|
|
39
|
-
};
|
|
40
|
-
const textAt = (copy, path) => {
|
|
41
|
-
const value = path.split('.').reduce((node, key) => isTree(node) ? node[key] : undefined, copy);
|
|
42
|
-
return typeof value === 'string' ? value : undefined;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* One text of the copy at a dot path (`withdrawal.function`), its `{{name}}` placeholders filled.
|
|
46
|
-
* Values are inserted as given — escape them for the medium (HTML) before passing them in.
|
|
47
|
-
*
|
|
48
|
-
* With a `context`, the variant `<path>_<context>` is read first and the base `path` only where the
|
|
49
|
-
* copy has no such variant — the i18next context suffix (`performance-consent.request_included`).
|
|
50
|
-
*
|
|
51
|
-
* @throws ConsumerRightsError `copy:<path>` when the path is not a text, `copy:<path>:<name>` when a
|
|
52
|
-
* placeholder has no value — a legal text is never sent with a hole in it.
|
|
53
|
-
*/
|
|
54
|
-
export const consumerText = (lng, path, vars = {}, context) => {
|
|
55
|
-
const copy = consumerRightsCopy(lng);
|
|
56
|
-
const variant = context != null && context !== '' ? `${path}_${context}` : null;
|
|
57
|
-
const key = variant != null && textAt(copy, variant) != null ? variant : path;
|
|
58
|
-
const value = textAt(copy, key);
|
|
59
|
-
if (value == null) {
|
|
60
|
-
throw new ConsumerRightsError(`copy:${path}`);
|
|
61
|
-
}
|
|
62
|
-
return value.replace(/\{\{\s*([\w-]+)\s*\}\}/g, (_, name) => {
|
|
63
|
-
const filled = vars[name];
|
|
64
|
-
if (filled == null) {
|
|
65
|
-
throw new ConsumerRightsError(`copy:${key}:${name}`);
|
|
28
|
+
if (lng !== base && lng.trim() !== '') {
|
|
29
|
+
copy = merge(copy, resolve(lng) ?? {});
|
|
66
30
|
}
|
|
67
|
-
return
|
|
31
|
+
return copy;
|
|
32
|
+
};
|
|
33
|
+
const textAt = (copy, path) => {
|
|
34
|
+
const value = path.split('.').reduce((node, key) => isTree(node) ? node[key] : undefined, copy);
|
|
35
|
+
return typeof value === 'string' ? value : undefined;
|
|
36
|
+
};
|
|
37
|
+
const consumerText = (lng, path, vars = {}, context) => {
|
|
38
|
+
const copy = consumerRightsCopy(lng);
|
|
39
|
+
const variant = context != null && context !== '' ? `${path}_${context}` : null;
|
|
40
|
+
const key = variant != null && textAt(copy, variant) != null ? variant : path;
|
|
41
|
+
const value = textAt(copy, key);
|
|
42
|
+
if (value == null) {
|
|
43
|
+
throw new ConsumerRightsError(`copy:${path}`);
|
|
44
|
+
}
|
|
45
|
+
return value.replace(/\{\{\s*([\w-]+)\s*\}\}/g, (_, name) => {
|
|
46
|
+
const filled = vars[name];
|
|
47
|
+
if (filled == null) {
|
|
48
|
+
throw new ConsumerRightsError(`copy:${key}:${name}`);
|
|
49
|
+
}
|
|
50
|
+
return String(filled);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const placeholdersOf = (text) => [...new Set([...text.matchAll(/\{\{\s*([\w-]+)\s*\}\}/g)].map(match => match[1]))];
|
|
54
|
+
const legalLabelsOf = (lng) => ({
|
|
55
|
+
withdrawal: {
|
|
56
|
+
function: consumerText(lng, 'withdrawal.function'),
|
|
57
|
+
confirm: consumerText(lng, 'withdrawal.confirm'),
|
|
58
|
+
},
|
|
59
|
+
cancellation: {
|
|
60
|
+
function: consumerText(lng, 'cancellation.function'),
|
|
61
|
+
confirm: consumerText(lng, 'cancellation.confirm'),
|
|
62
|
+
},
|
|
68
63
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
withdrawal: {
|
|
79
|
-
function: consumerText(lng, 'withdrawal.function'),
|
|
80
|
-
confirm: consumerText(lng, 'withdrawal.confirm'),
|
|
81
|
-
},
|
|
82
|
-
cancellation: {
|
|
83
|
-
function: consumerText(lng, 'cancellation.function'),
|
|
84
|
-
confirm: consumerText(lng, 'cancellation.confirm'),
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
/**
|
|
88
|
-
* The copy variant of a plan's subscription start statement — the one place it is decided.
|
|
89
|
-
*
|
|
90
|
-
* `'units'` exactly when the plan's `withdrawal.components` declare a `units` part: the statement
|
|
91
|
-
* then names the split (the services pro rata by time, the right of withdrawal expiring for the
|
|
92
|
-
* included units used) — the `_units` texts. Otherwise (no components, or `time` parts only: the
|
|
93
|
-
* whole price pro rata by the days elapsed) `undefined`, the base texts.
|
|
94
|
-
*/
|
|
95
|
-
export const startContextOf = (plan) => plan?.withdrawal?.components?.some(component => component.basis === 'units') === true ? 'units' : undefined;
|
|
96
|
-
/**
|
|
97
|
-
* The express request of one consent kind in one language, rendered — what the dialog shows, the
|
|
98
|
-
* server records and the confirmation e-mail repeats verbatim. `trader` names the business;
|
|
99
|
-
* `plan` (the plan's title) is required for a subscription start; `context` picks the
|
|
100
|
-
* `_<context>` variant of each text that has one — the policy's `consentContext` for the
|
|
101
|
-
* performance consent, `startContextOf(plan)` for a subscription start.
|
|
102
|
-
*/
|
|
103
|
-
export const consentStatementOf = (lng, kind, vars) => {
|
|
104
|
-
const branch = kind === ConsentKind.SubscriptionStart ? 'subscription-start' : 'performance-consent';
|
|
105
|
-
const values = { trader: vars.trader, ...(vars.plan != null ? { plan: vars.plan } : {}) };
|
|
106
|
-
return {
|
|
107
|
-
request: consumerText(lng, `${branch}.request`, values, vars.context),
|
|
108
|
-
acknowledgement: consumerText(lng, `${branch}.acknowledgement`, values, vars.context),
|
|
109
|
-
checkbox: consumerText(lng, `${branch}.checkbox`, values, vars.context),
|
|
64
|
+
const startContextOf = (plan) => plan?.withdrawal?.components?.some(component => component.basis === 'units') === true ? 'units' : undefined;
|
|
65
|
+
const consentStatementOf = (lng, kind, vars) => {
|
|
66
|
+
const branch = kind === ConsentKind.SubscriptionStart ? 'subscription-start' : 'performance-consent';
|
|
67
|
+
const values = { trader: vars.trader, ...(vars.plan != null ? { plan: vars.plan } : {}) };
|
|
68
|
+
return {
|
|
69
|
+
request: consumerText(lng, `${branch}.request`, values, vars.context),
|
|
70
|
+
acknowledgement: consumerText(lng, `${branch}.acknowledgement`, values, vars.context),
|
|
71
|
+
checkbox: consumerText(lng, `${branch}.checkbox`, values, vars.context),
|
|
72
|
+
};
|
|
110
73
|
};
|
|
74
|
+
return { consumerRightsCopy, consumerText, placeholdersOf, legalLabelsOf, startContextOf, consentStatementOf };
|
|
111
75
|
};
|
|
76
|
+
export const consumerCopyHelper = createConsumerCopyHelper();
|
|
77
|
+
/** @deprecated compat:factory-refactor — use `consumerCopyHelper.consumerRightsCopy(…)` */
|
|
78
|
+
export const consumerRightsCopy = (lng) => consumerCopyHelper.consumerRightsCopy(lng);
|
|
79
|
+
/** @deprecated compat:factory-refactor — use `consumerCopyHelper.consumerText(…)` */
|
|
80
|
+
export const consumerText = (lng, path, vars, context) => consumerCopyHelper.consumerText(lng, path, vars, context);
|
|
81
|
+
/** @deprecated compat:factory-refactor — use `consumerCopyHelper.legalLabelsOf(…)` */
|
|
82
|
+
export const legalLabelsOf = (lng) => consumerCopyHelper.legalLabelsOf(lng);
|
|
83
|
+
/** @deprecated compat:factory-refactor — use `consumerCopyHelper.startContextOf(…)` */
|
|
84
|
+
export const startContextOf = (plan) => consumerCopyHelper.startContextOf(plan);
|
|
85
|
+
/** @deprecated compat:factory-refactor — use `consumerCopyHelper.consentStatementOf(…)` */
|
|
86
|
+
export const consentStatementOf = (lng, kind, vars) => consumerCopyHelper.consentStatementOf(lng, kind, vars);
|
|
112
87
|
//# sourceMappingURL=copy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy.js","sourceRoot":"","sources":["../../src/consumer/copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"copy.js","sourceRoot":"","sources":["../../src/consumer/copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AA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AE,IAAiB,EAAE,OAAgB,EAAU,EAAE,CACrG,kBAAkB,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AAE3D,sFAAsF;AACtF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAe,EAAE,CAAC,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;AAEhG,uFAAuF;AACvF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAwD,EAAuB,EAAE,CAC9G,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;AAEzC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,GAAW,EAAE,IAAiB,EAAE,IAAyD,EACvE,EAAE,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DeadlinePolicy } from '../types.local.js';
|
|
2
|
+
import type { WithdrawalDeadlineRule, WithdrawalWindow } from '../types.js';
|
|
3
|
+
/** The withdrawal period: its exclusive end, its last day for display, and whether it is open. */
|
|
4
|
+
export interface WithdrawalDeadlineHelper {
|
|
5
|
+
/**
|
|
6
|
+
* The EXCLUSIVE end of a withdrawal period — the first instant at which it is over.
|
|
7
|
+
*
|
|
8
|
+
* The period starts the day after the purchase (the purchase day is not counted) and lasts `days`
|
|
9
|
+
* UTC calendar days; a last day on a Saturday or Sunday moves to the Monday after; `marginDays`
|
|
10
|
+
* are then added for public holidays and time zones; the result is the start of the next UTC day.
|
|
11
|
+
* Wed 2026-09-23 → 2026-10-13T00:00Z, Sat 2026-09-26 → 2026-10-18T00:00Z, Sun 2026-12-20 →
|
|
12
|
+
* 2027-01-10T00:00Z (14 days, margin 5). Shown to a person as its last included day
|
|
13
|
+
* (`lastWithdrawalDayOf`), never as the exclusive instant.
|
|
14
|
+
*
|
|
15
|
+
* @throws ConsumerRightsError (`deadline`) for an invalid date or rule.
|
|
16
|
+
*/
|
|
17
|
+
withdrawalDeadlineOf: (purchasedAt: Date, rule?: WithdrawalDeadlineRule | DeadlinePolicy) => Date;
|
|
18
|
+
/**
|
|
19
|
+
* The last day a withdrawal is still in time, for display: the UTC calendar day of `deadline − 1 ms`
|
|
20
|
+
* (a deadline is the EXCLUSIVE first instant after the period). 2026-10-13T00:00Z → 2026-10-12;
|
|
21
|
+
* show it as a UTC date, "until the end of 12 October 2026".
|
|
22
|
+
*/
|
|
23
|
+
lastWithdrawalDayOf: (deadline: Date) => Date;
|
|
24
|
+
/**
|
|
25
|
+
* Whether a withdrawal window is open at `at`: a deadline exists, `at` is before it, and the
|
|
26
|
+
* purchase was neither withdrawn from nor refunded. A bare deadline is accepted as well.
|
|
27
|
+
*/
|
|
28
|
+
withdrawalOpen: (window: WithdrawalWindow | Date | null | undefined, at?: Date) => boolean;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/consumer/deadline/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE3E,kGAAkG;AAClG,MAAM,WAAW,wBAAwB;IACvC;;;;;;;;;;;OAWG;IACH,oBAAoB,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,sBAAsB,GAAG,cAAc,KAAK,IAAI,CAAA;IACjG;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,QAAQ,EAAE,IAAI,KAAK,IAAI,CAAA;IAC7C;;;OAGG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,EAAE,EAAE,CAAC,EAAE,IAAI,KAAK,OAAO,CAAA;CAC3F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/consumer/deadline/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
import type { DeadlinePolicy } from './types.local.js';
|
|
2
2
|
import type { WithdrawalDeadlineRule, WithdrawalWindow } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* UTC calendar days; a last day on a Saturday or Sunday moves to the Monday after; `marginDays`
|
|
8
|
-
* are then added for public holidays and time zones; the result is the start of the next UTC day.
|
|
9
|
-
* Wed 2026-09-23 → 2026-10-13T00:00Z, Sat 2026-09-26 → 2026-10-18T00:00Z, Sun 2026-12-20 →
|
|
10
|
-
* 2027-01-10T00:00Z (14 days, margin 5). Shown to a person as its last included day
|
|
11
|
-
* (`lastWithdrawalDayOf`), never as the exclusive instant.
|
|
12
|
-
*
|
|
13
|
-
* @throws ConsumerRightsError (`deadline`) for an invalid date or rule.
|
|
14
|
-
*/
|
|
3
|
+
import type { WithdrawalDeadlineHelper } from './deadline/types.js';
|
|
4
|
+
export declare const createWithdrawalDeadlineHelper: () => WithdrawalDeadlineHelper;
|
|
5
|
+
export declare const withdrawalDeadlineHelper: WithdrawalDeadlineHelper;
|
|
6
|
+
/** @deprecated compat:factory-refactor — use `withdrawalDeadlineHelper.withdrawalDeadlineOf(…)` */
|
|
15
7
|
export declare const withdrawalDeadlineOf: (purchasedAt: Date, rule?: WithdrawalDeadlineRule | DeadlinePolicy) => Date;
|
|
16
|
-
/**
|
|
17
|
-
* The last day a withdrawal is still in time, for display: the UTC calendar day of `deadline − 1 ms`
|
|
18
|
-
* (a deadline is the EXCLUSIVE first instant after the period). 2026-10-13T00:00Z → 2026-10-12;
|
|
19
|
-
* show it as a UTC date, "until the end of 12 October 2026".
|
|
20
|
-
*/
|
|
8
|
+
/** @deprecated compat:factory-refactor — use `withdrawalDeadlineHelper.lastWithdrawalDayOf(…)` */
|
|
21
9
|
export declare const lastWithdrawalDayOf: (deadline: Date) => Date;
|
|
22
|
-
/**
|
|
23
|
-
* Whether a withdrawal window is open at `at`: a deadline exists, `at` is before it, and the
|
|
24
|
-
* purchase was neither withdrawn from nor refunded. A bare deadline is accepted as well.
|
|
25
|
-
*/
|
|
10
|
+
/** @deprecated compat:factory-refactor — use `withdrawalDeadlineHelper.withdrawalOpen(…)` */
|
|
26
11
|
export declare const withdrawalOpen: (window: WithdrawalWindow | Date | null | undefined, at?: Date) => boolean;
|
|
27
12
|
//# sourceMappingURL=deadline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deadline.d.ts","sourceRoot":"","sources":["../../src/consumer/deadline.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"deadline.d.ts","sourceRoot":"","sources":["../../src/consumer/deadline.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC1E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAEnE,eAAO,MAAM,8BAA8B,QAAO,wBAyCjD,CAAA;AAED,eAAO,MAAM,wBAAwB,0BAAmC,CAAA;AAExE,mGAAmG;AACnG,eAAO,MAAM,oBAAoB,gBAAiB,IAAI,SAAS,sBAAsB,GAAG,cAAc,KAAG,IACvC,CAAA;AAElE,kGAAkG;AAClG,eAAO,MAAM,mBAAmB,aAAc,IAAI,KAAG,IAA8D,CAAA;AAEnH,6FAA6F;AAC7F,eAAO,MAAM,cAAc,WAAY,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,OAAO,IAAI,KAAG,OAC1C,CAAA"}
|
|
@@ -1,55 +1,44 @@
|
|
|
1
1
|
import { ConsumerRightsError } from '../errors.js';
|
|
2
2
|
import { DAY_MS } from './consts.js';
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
* The last day a withdrawal is still in time, for display: the UTC calendar day of `deadline − 1 ms`
|
|
37
|
-
* (a deadline is the EXCLUSIVE first instant after the period). 2026-10-13T00:00Z → 2026-10-12;
|
|
38
|
-
* show it as a UTC date, "until the end of 12 October 2026".
|
|
39
|
-
*/
|
|
40
|
-
export const lastWithdrawalDayOf = (deadline) => {
|
|
41
|
-
const last = new Date(deadline.getTime() - 1);
|
|
42
|
-
return new Date(Date.UTC(last.getUTCFullYear(), last.getUTCMonth(), last.getUTCDate()));
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Whether a withdrawal window is open at `at`: a deadline exists, `at` is before it, and the
|
|
46
|
-
* purchase was neither withdrawn from nor refunded. A bare deadline is accepted as well.
|
|
47
|
-
*/
|
|
48
|
-
export const withdrawalOpen = (window, at = new Date()) => {
|
|
49
|
-
if (window == null) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
const { deadline, withdrawnAt, refundedAt } = window instanceof Date ? { deadline: window } : window;
|
|
53
|
-
return deadline != null && withdrawnAt == null && refundedAt == null && at.getTime() < deadline.getTime();
|
|
3
|
+
export const createWithdrawalDeadlineHelper = () => {
|
|
4
|
+
const ruleOf = (rule) => {
|
|
5
|
+
if (rule != null && 'withdrawalDays' in rule) {
|
|
6
|
+
return { days: rule.withdrawalDays, weekendRollover: rule.deadline.weekendRollover, marginDays: rule.deadline.marginDays };
|
|
7
|
+
}
|
|
8
|
+
return { days: rule?.days ?? 14, weekendRollover: rule?.weekendRollover ?? true, marginDays: rule?.marginDays ?? 5 };
|
|
9
|
+
};
|
|
10
|
+
const withdrawalDeadlineOf = (purchasedAt, rule) => {
|
|
11
|
+
const { days, weekendRollover, marginDays } = ruleOf(rule);
|
|
12
|
+
if (Number.isNaN(purchasedAt.getTime()) || !Number.isSafeInteger(days) || days < 0
|
|
13
|
+
|| !Number.isSafeInteger(marginDays) || marginDays < 0) {
|
|
14
|
+
throw new ConsumerRightsError('deadline');
|
|
15
|
+
}
|
|
16
|
+
const purchaseDay = Date.UTC(purchasedAt.getUTCFullYear(), purchasedAt.getUTCMonth(), purchasedAt.getUTCDate());
|
|
17
|
+
let lastDay = purchaseDay + days * DAY_MS;
|
|
18
|
+
if (weekendRollover) {
|
|
19
|
+
const weekday = new Date(lastDay).getUTCDay();
|
|
20
|
+
lastDay += weekday === 6 ? 2 * DAY_MS : weekday === 0 ? DAY_MS : 0;
|
|
21
|
+
}
|
|
22
|
+
return new Date(lastDay + (marginDays + 1) * DAY_MS);
|
|
23
|
+
};
|
|
24
|
+
const lastWithdrawalDayOf = (deadline) => {
|
|
25
|
+
const last = new Date(deadline.getTime() - 1);
|
|
26
|
+
return new Date(Date.UTC(last.getUTCFullYear(), last.getUTCMonth(), last.getUTCDate()));
|
|
27
|
+
};
|
|
28
|
+
const withdrawalOpen = (window, at = new Date()) => {
|
|
29
|
+
if (window == null) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const { deadline, withdrawnAt, refundedAt } = window instanceof Date ? { deadline: window } : window;
|
|
33
|
+
return deadline != null && withdrawnAt == null && refundedAt == null && at.getTime() < deadline.getTime();
|
|
34
|
+
};
|
|
35
|
+
return { withdrawalDeadlineOf, lastWithdrawalDayOf, withdrawalOpen };
|
|
54
36
|
};
|
|
37
|
+
export const withdrawalDeadlineHelper = createWithdrawalDeadlineHelper();
|
|
38
|
+
/** @deprecated compat:factory-refactor — use `withdrawalDeadlineHelper.withdrawalDeadlineOf(…)` */
|
|
39
|
+
export const withdrawalDeadlineOf = (purchasedAt, rule) => withdrawalDeadlineHelper.withdrawalDeadlineOf(purchasedAt, rule);
|
|
40
|
+
/** @deprecated compat:factory-refactor — use `withdrawalDeadlineHelper.lastWithdrawalDayOf(…)` */
|
|
41
|
+
export const lastWithdrawalDayOf = (deadline) => withdrawalDeadlineHelper.lastWithdrawalDayOf(deadline);
|
|
42
|
+
/** @deprecated compat:factory-refactor — use `withdrawalDeadlineHelper.withdrawalOpen(…)` */
|
|
43
|
+
export const withdrawalOpen = (window, at) => withdrawalDeadlineHelper.withdrawalOpen(window, at);
|
|
55
44
|
//# sourceMappingURL=deadline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deadline.js","sourceRoot":"","sources":["../../src/consumer/deadline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"deadline.js","sourceRoot":"","sources":["../../src/consumer/deadline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKpC,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAA6B,EAAE;IAC3E,MAAM,MAAM,GAAG,CAAC,IAA8C,EAAoC,EAAE;QAClG,IAAI,IAAI,IAAI,IAAI,IAAI,gBAAgB,IAAI,IAAI,EAAE,CAAC;YAC7C,OAAO,EAAE,IAAI,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IAAI,CAAC,CAAA;AAElE,kGAAkG;AAClG,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,QAAc,EAAQ,EAAE,CAAC,wBAAwB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAA;AAEnH,6FAA6F;AAC7F,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAkD,EAAE,EAAS,EAAW,EAAE,CACvG,wBAAwB,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FifoAllocation, FifoLot, FifoLotUsage, FifoSpend } from '../types.js';
|
|
2
|
+
/** First-in-first-out allocation of spends over granted lots. */
|
|
3
|
+
export interface FifoHelper {
|
|
4
|
+
/**
|
|
5
|
+
* First in, first out: every spend, in time order, takes from the oldest lot granted AT OR BEFORE
|
|
6
|
+
* it that still has units, then the next one; what no such lot covers is `unallocated` (a lot
|
|
7
|
+
* granted later never pays for an earlier spend). Lots come back in grant order. Pure — the input
|
|
8
|
+
* arrays are not reordered.
|
|
9
|
+
*/
|
|
10
|
+
allocateFifo: (lots: FifoLot[], spends: FifoSpend[]) => FifoAllocation;
|
|
11
|
+
/**
|
|
12
|
+
* The units of a lot used strictly AFTER an instant — its consent. Without one (`null`), nothing
|
|
13
|
+
* is deductible: before consent the consumer bears no cost.
|
|
14
|
+
*/
|
|
15
|
+
unitsUsedAfter: (lot: Pick<FifoLotUsage, 'slices'>, after: Date | null | undefined) => number;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/consumer/fifo/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEnF,iEAAiE;AACjE,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,cAAc,CAAA;IACtE;;;OAGG;IACH,cAAc,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,KAAK,MAAM,CAAA;CAC9F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/consumer/fifo/types.ts"],"names":[],"mappings":""}
|
package/build/consumer/fifo.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* granted later never pays for an earlier spend). Lots come back in grant order. Pure — the input
|
|
5
|
-
* arrays are not reordered.
|
|
6
|
-
*/
|
|
7
|
-
import type { FifoAllocation, FifoLot, FifoLotUsage, FifoSpend } from './types.js';
|
|
8
|
-
export declare const allocateFifo: (lots: FifoLot[], spends: FifoSpend[]) => FifoAllocation;
|
|
9
|
-
/**
|
|
10
|
-
* The units of a lot used strictly AFTER an instant — its consent. Without one (`null`), nothing
|
|
11
|
-
* is deductible: before consent the consumer bears no cost.
|
|
12
|
-
*/
|
|
13
|
-
export declare const unitsUsedAfter: (lot: Pick<FifoLotUsage, 'slices'>, after: Date | null | undefined) => number;
|
|
1
|
+
import type { FifoHelper } from './fifo/types.js';
|
|
2
|
+
export declare const createFifoHelper: () => FifoHelper;
|
|
3
|
+
export declare const fifoHelper: FifoHelper;
|
|
14
4
|
//# sourceMappingURL=fifo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fifo.d.ts","sourceRoot":"","sources":["../../src/consumer/fifo.ts"],"names":[],"mappings":"AACA
|
|
1
|
+
{"version":3,"file":"fifo.d.ts","sourceRoot":"","sources":["../../src/consumer/fifo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,eAAO,MAAM,gBAAgB,QAAO,UAoCnC,CAAA;AAED,eAAO,MAAM,UAAU,YAAqB,CAAA"}
|
package/build/consumer/fifo.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
export const
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
export const createFifoHelper = () => {
|
|
2
|
+
const allocateFifo = (lots, spends) => {
|
|
3
|
+
const usage = [...lots]
|
|
4
|
+
.map((lot, index) => ({ lot, index }))
|
|
5
|
+
.sort((a, b) => a.lot.at.getTime() - b.lot.at.getTime() || a.index - b.index)
|
|
6
|
+
.map(({ lot }) => ({ id: lot.id, at: lot.at, granted: Math.max(0, lot.units), used: 0, slices: [] }));
|
|
7
|
+
const ordered = [...spends]
|
|
8
|
+
.map((spend, index) => ({ spend, index }))
|
|
9
|
+
.sort((a, b) => a.spend.at.getTime() - b.spend.at.getTime() || a.index - b.index);
|
|
10
|
+
let unallocated = 0;
|
|
11
|
+
for (const { spend } of ordered) {
|
|
12
|
+
let left = Math.max(0, spend.units);
|
|
13
|
+
for (const lot of usage) {
|
|
14
|
+
if (left <= 0 || lot.at.getTime() > spend.at.getTime()) {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
const take = Math.min(left, lot.granted - lot.used);
|
|
18
|
+
if (take > 0) {
|
|
19
|
+
lot.used += take;
|
|
20
|
+
lot.slices.push({ at: spend.at, units: take });
|
|
21
|
+
left -= take;
|
|
22
|
+
}
|
|
21
23
|
}
|
|
24
|
+
unallocated += left;
|
|
22
25
|
}
|
|
23
|
-
unallocated
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
+
return { lots: usage, unallocated };
|
|
27
|
+
};
|
|
28
|
+
const unitsUsedAfter = (lot, after) => after == null ? 0 : lot.slices
|
|
29
|
+
.filter(slice => slice.at.getTime() > after.getTime())
|
|
30
|
+
.reduce((sum, slice) => sum + slice.units, 0);
|
|
31
|
+
return { allocateFifo, unitsUsedAfter };
|
|
26
32
|
};
|
|
27
|
-
|
|
28
|
-
* The units of a lot used strictly AFTER an instant — its consent. Without one (`null`), nothing
|
|
29
|
-
* is deductible: before consent the consumer bears no cost.
|
|
30
|
-
*/
|
|
31
|
-
export const unitsUsedAfter = (lot, after) => after == null ? 0 : lot.slices
|
|
32
|
-
.filter(slice => slice.at.getTime() > after.getTime())
|
|
33
|
-
.reduce((sum, slice) => sum + slice.units, 0);
|
|
33
|
+
export const fifoHelper = createFifoHelper();
|
|
34
34
|
//# sourceMappingURL=fifo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fifo.js","sourceRoot":"","sources":["../../src/consumer/fifo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fifo.js","sourceRoot":"","sources":["../../src/consumer/fifo.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAe,EAAE;IAC/C,MAAM,YAAY,GAAG,CAAC,IAAe,EAAE,MAAmB,EAAkB,EAAE;QAC5E,MAAM,KAAK,GAAmB,CAAC,GAAG,IAAI,CAAC;aACpC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;aACrC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;aAC5E,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IAAI,IAAI,CAAA;oBAChB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;oBAC9C,IAAI,IAAI,IAAI,CAAA;gBACd,CAAC;YACH,CAAC;YACD,WAAW,IAAI,IAAI,CAAA;QACrB,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;IACrC,CAAC,CAAA;IAED,MAAM,cAAc,GAAG,CAAC,GAAiC,EAAE,KAA8B,EAAU,EAAE,CACnG,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM;SAC3B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;SACrD,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IAEjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAA;AACzC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAA"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export * from './policy.js';
|
|
2
2
|
export * from './consts.js';
|
|
3
3
|
export type * from './types.js';
|
|
4
|
+
export type * from './copy/types.js';
|
|
5
|
+
export type * from './deadline/types.js';
|
|
6
|
+
export type * from './fifo/types.js';
|
|
7
|
+
export type * from './policy/types.js';
|
|
8
|
+
export type * from './refund/types.js';
|
|
9
|
+
export type * from './revive/types.js';
|
|
4
10
|
export * from './deadline.js';
|
|
5
11
|
export * from './refund.js';
|
|
6
12
|
export * from './fifo.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumer/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumer/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,iBAAiB,CAAA;AACpC,mBAAmB,qBAAqB,CAAA;AACxC,mBAAmB,iBAAiB,CAAA;AACpC,mBAAmB,mBAAmB,CAAA;AACtC,mBAAmB,mBAAmB,CAAA;AACtC,mBAAmB,mBAAmB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/consumer/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/consumer/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAQ3B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ConsumerRightsLinks, ConsumerRightsPolicy } from '../../types.js';
|
|
2
|
+
/** The consumer-rights policy's invariants, its languages and its links. */
|
|
3
|
+
export interface ConsumerRightsPolicyHelper {
|
|
4
|
+
/**
|
|
5
|
+
* @throws ConsumerRightsError (`policy:<field>`) when the text version is empty, a country or a
|
|
6
|
+
* currency is malformed, the period is shorter than 14 days, the margin is outside 0..7 days, the
|
|
7
|
+
* consent context is not a lowercase key, the default language has no links, a link is not an
|
|
8
|
+
* absolute https URL, or the withdrawal information is missing while the withdrawal function or the
|
|
9
|
+
* performance consent is on.
|
|
10
|
+
*/
|
|
11
|
+
assertConsumerRightsPolicy: (policy: ConsumerRightsPolicy) => ConsumerRightsPolicy;
|
|
12
|
+
/** `de-DE` → `de`. */
|
|
13
|
+
baseLanguageOf: (lng: string | null | undefined) => string;
|
|
14
|
+
/**
|
|
15
|
+
* The links of one language, field by field over the default language's — a language that only
|
|
16
|
+
* translates the Billing Terms still points at the default withdrawal information.
|
|
17
|
+
*/
|
|
18
|
+
linksOf: (policy: Pick<ConsumerRightsPolicy, 'links' | 'defaultLanguage'>, lng?: string | null) => ConsumerRightsLinks;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/consumer/policy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAE/E,4EAA4E;AAC5E,MAAM,WAAW,0BAA0B;IACzC;;;;;;OAMG;IACH,0BAA0B,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,oBAAoB,CAAA;IAClF,sBAAsB;IACtB,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,KAAK,MAAM,CAAA;IAC1D;;;OAGG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,iBAAiB,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,mBAAmB,CAAA;CACvH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/consumer/policy/types.ts"],"names":[],"mappings":""}
|