@final-commerce/common 2.11.1-online.2 → 2.11.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/README.md +20 -0
- package/bin/gate-done.mjs +92 -44
- package/bin/lib/budget.mjs +71 -0
- package/dist/index.d.mts +1 -215
- package/dist/index.d.ts +1 -215
- package/dist/index.js +0 -233
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -219
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +12 -37
- package/dist/pos-types/index.d.ts +12 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,6 +219,26 @@ node -p "const c = require('@final-commerce/common'); c.formatCurrency(2500, 'EU
|
|
|
219
219
|
# → €25.00
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
+
## Quality gates
|
|
223
|
+
|
|
224
|
+
### `gate-done` time budgets
|
|
225
|
+
|
|
226
|
+
`gate-done` (the pre-push hook) runs four sweeps: npm audit, gitleaks, Vitest with coverage, and a bundle-size or build check. It gives them two separate time budgets, both set in milliseconds through environment variables:
|
|
227
|
+
|
|
228
|
+
| Variable | Default | Covers |
|
|
229
|
+
| -------------------------- | -------- | ---------------------------------------- |
|
|
230
|
+
| `GATE_DONE_BUDGET_MS` | `90000` | npm audit, gitleaks and the bundle sweep |
|
|
231
|
+
| `GATE_DONE_TEST_BUDGET_MS` | `300000` | the Vitest sweep on its own |
|
|
232
|
+
|
|
233
|
+
A budget only counts time spent in its own sweeps, so a slow test suite never takes time from the other sweeps, and the other sweeps never take time from the tests. Husky's pre-push hook inherits your shell environment, so you can raise a budget for one push or for good:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
GATE_DONE_TEST_BUDGET_MS=600000 git push # one push
|
|
237
|
+
export GATE_DONE_TEST_BUDGET_MS=600000 # in ~/.zshrc, for every push
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
If a sweep runs past its budget, `gate-done` kills it and blocks the push with a timeout message (`Vitest killed after 300.0s by the test budget … not a test failure`), not as a test or audit failure. Values that are not positive integers are ignored with a warning, and the default applies.
|
|
241
|
+
|
|
222
242
|
## License
|
|
223
243
|
|
|
224
244
|
Private — Final Commerce internal use only.
|
package/bin/gate-done.mjs
CHANGED
|
@@ -2,58 +2,80 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* gate-done — pre-push hook.
|
|
4
4
|
*
|
|
5
|
-
* Runs
|
|
5
|
+
* Runs four sweeps under two time budgets:
|
|
6
6
|
*
|
|
7
|
-
* 1.
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
7
|
+
* 1. npm audit — known CVE check against the installed dependency tree (warn only)
|
|
8
|
+
* 2. gitleaks — credential / secret scanning (git log + staged)
|
|
9
|
+
* 3. vitest — full test suite with coverage threshold enforcement
|
|
10
|
+
* 4. bundle — size-limit or custom bundle-size script (if configured)
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* Budgets (milliseconds, read from the environment — Husky's pre-push inherits the shell):
|
|
13
|
+
*
|
|
14
|
+
* GATE_DONE_BUDGET_MS default 90000 shared by sweeps 1, 2 and 4
|
|
15
|
+
* GATE_DONE_TEST_BUDGET_MS default 300000 sweep 3 (Vitest) on its own
|
|
16
|
+
*
|
|
17
|
+
* A budget only drains while its own sweeps run, so a slow test suite cannot
|
|
18
|
+
* starve the bundle sweep and vice versa.
|
|
19
|
+
*
|
|
20
|
+
* Any sweep failure except npm audit exits 1, blocking the push.
|
|
21
|
+
* A sweep killed by its budget also exits 1, but is reported as a timeout,
|
|
22
|
+
* not as a failure of the thing it was checking.
|
|
13
23
|
*
|
|
14
24
|
* Install as Husky pre-push hook:
|
|
15
25
|
* echo "npx gate-done" > .husky/pre-push
|
|
16
26
|
*/
|
|
17
27
|
|
|
18
|
-
import { spawnSync } from 'node:child_process';
|
|
19
28
|
import { readFileSync } from 'node:fs';
|
|
20
29
|
import { resolve } from 'node:path';
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
import {
|
|
32
|
+
DEFAULT_BUDGET_MS,
|
|
33
|
+
DEFAULT_TEST_BUDGET_MS,
|
|
34
|
+
budgetKillMessage,
|
|
35
|
+
createBudget,
|
|
36
|
+
readBudgetMs,
|
|
37
|
+
runInBudget,
|
|
38
|
+
} from './lib/budget.mjs';
|
|
39
|
+
|
|
23
40
|
const t0 = Date.now();
|
|
24
41
|
|
|
25
42
|
// ── helpers ──────────────────────────────────────────────────────────────────
|
|
26
43
|
|
|
27
|
-
function remaining() {
|
|
28
|
-
return Math.max(0, BUDGET_MS - (Date.now() - t0));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
44
|
function elapsed() {
|
|
32
45
|
return ((Date.now() - t0) / 1000).toFixed(1);
|
|
33
46
|
}
|
|
34
47
|
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
48
|
+
function makeBudget(name, envVar, fallback) {
|
|
49
|
+
const { ms, invalid } = readBudgetMs(process.env, envVar, fallback);
|
|
50
|
+
if (invalid !== undefined) {
|
|
51
|
+
warn(`${envVar}="${invalid}" is not a positive integer of milliseconds — using ${fallback}.`);
|
|
52
|
+
}
|
|
53
|
+
return createBudget(name, envVar, ms);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function checkBudget(budget, label) {
|
|
57
|
+
if (budget.exhausted()) {
|
|
58
|
+
fail(
|
|
59
|
+
`${budget.name} budget (${budget.envVar}=${budget.ms}) exhausted before "${label}" could start. ` +
|
|
60
|
+
`Push blocked — not a ${label} failure.`,
|
|
61
|
+
);
|
|
38
62
|
}
|
|
39
63
|
}
|
|
40
64
|
|
|
41
65
|
/**
|
|
42
|
-
* Run a command, streaming output
|
|
43
|
-
*
|
|
44
|
-
*
|
|
66
|
+
* Run a command, streaming output, charged to `budget`. The budget's remaining
|
|
67
|
+
* time is the child's timeout, so a runaway child cannot overrun it. A child
|
|
68
|
+
* killed by that timeout blocks the push with a timeout message instead of
|
|
69
|
+
* being reported as a failure of the sweep.
|
|
45
70
|
*/
|
|
46
|
-
function run(cmd) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
stdio: 'inherit',
|
|
51
|
-
timeout: remaining(),
|
|
52
|
-
});
|
|
71
|
+
function run(budget, label, cmd) {
|
|
72
|
+
const result = runInBudget(budget, cmd, { stdio: 'inherit' });
|
|
73
|
+
if (result.timedOut) fail(budgetKillMessage(label, budget, result.durationMs) + ' Push blocked.');
|
|
74
|
+
return result;
|
|
53
75
|
}
|
|
54
76
|
|
|
55
|
-
function capture(cmd) {
|
|
56
|
-
return
|
|
77
|
+
function capture(budget, cmd) {
|
|
78
|
+
return runInBudget(budget, cmd);
|
|
57
79
|
}
|
|
58
80
|
|
|
59
81
|
function fail(msg) {
|
|
@@ -73,12 +95,34 @@ function ok(msg) {
|
|
|
73
95
|
process.stdout.write(`\x1b[32m✔ [${elapsed()}s] ${msg}\x1b[0m\n`);
|
|
74
96
|
}
|
|
75
97
|
|
|
76
|
-
// ──
|
|
98
|
+
// ── budgets ──────────────────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
const sweepBudget = makeBudget('sweep', 'GATE_DONE_BUDGET_MS', DEFAULT_BUDGET_MS);
|
|
101
|
+
const testBudget = makeBudget('test', 'GATE_DONE_TEST_BUDGET_MS', DEFAULT_TEST_BUDGET_MS);
|
|
102
|
+
|
|
103
|
+
info(
|
|
104
|
+
`Budgets: sweeps ${sweepBudget.ms / 1000}s (GATE_DONE_BUDGET_MS), ` +
|
|
105
|
+
`tests ${testBudget.ms / 1000}s (GATE_DONE_TEST_BUDGET_MS).`,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// ── 1. npm audit ─────────────────────────────────────────────────────────────
|
|
109
|
+
|
|
110
|
+
info('Sweep 1/4 — npm audit (known CVEs)…');
|
|
111
|
+
checkBudget(sweepBudget, 'npm audit');
|
|
112
|
+
|
|
113
|
+
const auditResult = run(sweepBudget, 'npm audit', 'npm audit --audit-level=high');
|
|
114
|
+
if (auditResult.status !== 0) {
|
|
115
|
+
warn('npm audit found high or critical vulnerabilities. Run `npm audit` for details.');
|
|
116
|
+
} else {
|
|
117
|
+
ok('npm audit: no high/critical vulnerabilities.');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ── 2. gitleaks ───────────────────────────────────────────────────────────────
|
|
77
121
|
|
|
78
|
-
info('Sweep
|
|
79
|
-
checkBudget('gitleaks');
|
|
122
|
+
info('Sweep 2/4 — gitleaks secrets scan…');
|
|
123
|
+
checkBudget(sweepBudget, 'gitleaks');
|
|
80
124
|
|
|
81
|
-
const hasGitleaks = capture('command -v gitleaks 2>/dev/null').status === 0;
|
|
125
|
+
const hasGitleaks = capture(sweepBudget, 'command -v gitleaks 2>/dev/null').status === 0;
|
|
82
126
|
|
|
83
127
|
if (!hasGitleaks) {
|
|
84
128
|
warn(
|
|
@@ -88,19 +132,19 @@ if (!hasGitleaks) {
|
|
|
88
132
|
} else {
|
|
89
133
|
// Scan the full git history visible from HEAD — correct mode for a pre-push hook.
|
|
90
134
|
// --no-git-serial scans refs in parallel for speed within the budget.
|
|
91
|
-
const glResult = run('gitleaks git --exit-code 1 .');
|
|
135
|
+
const glResult = run(sweepBudget, 'gitleaks', 'gitleaks git --exit-code 1 .');
|
|
92
136
|
if (glResult.status !== 0) {
|
|
93
137
|
fail('gitleaks detected a potential secret. Remove it and retry the push.');
|
|
94
138
|
}
|
|
95
139
|
ok('gitleaks: no secrets detected.');
|
|
96
140
|
}
|
|
97
141
|
|
|
98
|
-
// ──
|
|
142
|
+
// ── 3. vitest coverage ────────────────────────────────────────────────────────
|
|
99
143
|
|
|
100
|
-
info('Sweep
|
|
101
|
-
checkBudget('
|
|
144
|
+
info('Sweep 3/4 — Vitest test suite + coverage thresholds…');
|
|
145
|
+
checkBudget(testBudget, 'Vitest');
|
|
102
146
|
|
|
103
|
-
const vitestResult = run('npx vitest run --coverage');
|
|
147
|
+
const vitestResult = run(testBudget, 'Vitest', 'npx vitest run --coverage');
|
|
104
148
|
|
|
105
149
|
if (vitestResult.status !== 0) {
|
|
106
150
|
fail('Vitest coverage gate failed — fix failing tests or low-coverage areas before pushing.');
|
|
@@ -108,10 +152,10 @@ if (vitestResult.status !== 0) {
|
|
|
108
152
|
|
|
109
153
|
ok('Vitest: all tests passed, coverage thresholds met.');
|
|
110
154
|
|
|
111
|
-
// ──
|
|
155
|
+
// ── 4. bundle size ────────────────────────────────────────────────────────────
|
|
112
156
|
|
|
113
|
-
info('Sweep
|
|
114
|
-
checkBudget('bundle audit');
|
|
157
|
+
info('Sweep 4/4 — bundle size audit…');
|
|
158
|
+
checkBudget(sweepBudget, 'bundle audit');
|
|
115
159
|
|
|
116
160
|
const pkgPath = resolve(process.cwd(), 'package.json');
|
|
117
161
|
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
@@ -122,21 +166,21 @@ const hasBundlesize = Boolean(pkg.devDependencies?.['bundlesize']) || Boolean(pk
|
|
|
122
166
|
const hasBuildScript = Boolean(pkg.scripts?.build);
|
|
123
167
|
|
|
124
168
|
if (hasBundleSizeScript) {
|
|
125
|
-
const result = run('npm run bundle-size');
|
|
169
|
+
const result = run(sweepBudget, 'bundle-size', 'npm run bundle-size');
|
|
126
170
|
if (result.status !== 0) fail('bundle-size script reported a violation. Push blocked.');
|
|
127
171
|
ok('Bundle size: within limits.');
|
|
128
172
|
} else if (hasSizeLimit) {
|
|
129
|
-
const result = run('npx size-limit');
|
|
173
|
+
const result = run(sweepBudget, 'size-limit', 'npx size-limit');
|
|
130
174
|
if (result.status !== 0) fail('size-limit reported a violation. Push blocked.');
|
|
131
175
|
ok('Bundle size: size-limit passed.');
|
|
132
176
|
} else if (hasBundlesize) {
|
|
133
|
-
const result = run('npx bundlesize');
|
|
177
|
+
const result = run(sweepBudget, 'bundlesize', 'npx bundlesize');
|
|
134
178
|
if (result.status !== 0) fail('bundlesize reported a violation. Push blocked.');
|
|
135
179
|
ok('Bundle size: bundlesize passed.');
|
|
136
180
|
} else if (hasBuildScript) {
|
|
137
181
|
// No size tool configured — at minimum verify the build succeeds cleanly.
|
|
138
182
|
info('No size-limit/bundlesize configured — running build as a smoke-check.');
|
|
139
|
-
const result = run('npm run build');
|
|
183
|
+
const result = run(sweepBudget, 'build', 'npm run build');
|
|
140
184
|
if (result.status !== 0) fail('Build failed during gate-done. Push blocked.');
|
|
141
185
|
ok('Build: succeeded (no size budget configured).');
|
|
142
186
|
} else {
|
|
@@ -145,5 +189,9 @@ if (hasBundleSizeScript) {
|
|
|
145
189
|
|
|
146
190
|
// ── done ─────────────────────────────────────────────────────────────────────
|
|
147
191
|
|
|
148
|
-
ok(
|
|
192
|
+
ok(
|
|
193
|
+
`gate-done completed in ${elapsed()}s ` +
|
|
194
|
+
`(sweeps ${(sweepBudget.spent() / 1000).toFixed(1)}/${sweepBudget.ms / 1000}s, ` +
|
|
195
|
+
`tests ${(testBudget.spent() / 1000).toFixed(1)}/${testBudget.ms / 1000}s). Push proceeding.`,
|
|
196
|
+
);
|
|
149
197
|
process.exit(0);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time budgets for the gate-* hooks.
|
|
3
|
+
*
|
|
4
|
+
* A budget is a pool of milliseconds that only drains while one of its own
|
|
5
|
+
* sweeps is running, so gate-done can give the Vitest sweep its own allowance
|
|
6
|
+
* without the fast sweeps (audit, gitleaks, bundle) eating into it.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { spawnSync } from 'node:child_process';
|
|
10
|
+
|
|
11
|
+
export const DEFAULT_BUDGET_MS = 90_000;
|
|
12
|
+
export const DEFAULT_TEST_BUDGET_MS = 300_000;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Read a budget in milliseconds from `env[name]`.
|
|
16
|
+
* Unset or empty falls back to the default; anything that is not a positive
|
|
17
|
+
* integer also falls back, and `invalid` carries the rejected raw value so the
|
|
18
|
+
* caller can warn about it.
|
|
19
|
+
*/
|
|
20
|
+
export function readBudgetMs(env, name, fallback) {
|
|
21
|
+
const raw = env[name];
|
|
22
|
+
if (raw === undefined || raw.trim() === '') return { ms: fallback, source: 'default' };
|
|
23
|
+
const ms = Number(raw.trim());
|
|
24
|
+
if (!Number.isInteger(ms) || ms <= 0) return { ms: fallback, source: 'default', invalid: raw };
|
|
25
|
+
return { ms, source: 'env' };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createBudget(name, envVar, ms, now = Date.now) {
|
|
29
|
+
let spentMs = 0;
|
|
30
|
+
return {
|
|
31
|
+
name,
|
|
32
|
+
envVar,
|
|
33
|
+
ms,
|
|
34
|
+
spent: () => spentMs,
|
|
35
|
+
remaining: () => Math.max(0, ms - spentMs),
|
|
36
|
+
exhausted: () => spentMs >= ms,
|
|
37
|
+
/** Charge the time `fn` takes to this budget and return its result. */
|
|
38
|
+
track(fn) {
|
|
39
|
+
const start = now();
|
|
40
|
+
try {
|
|
41
|
+
return fn();
|
|
42
|
+
} finally {
|
|
43
|
+
spentMs += now() - start;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Run a shell command with the budget's remaining time as the child timeout.
|
|
51
|
+
* `timedOut` is true when the child was killed because the budget ran out,
|
|
52
|
+
* as opposed to exiting non-zero on its own.
|
|
53
|
+
*/
|
|
54
|
+
export function runInBudget(budget, cmd, options = {}) {
|
|
55
|
+
const before = budget.spent();
|
|
56
|
+
const result = budget.track(() =>
|
|
57
|
+
spawnSync(cmd, { shell: true, encoding: 'utf8', ...options, timeout: budget.remaining() }),
|
|
58
|
+
);
|
|
59
|
+
const durationMs = budget.spent() - before;
|
|
60
|
+
return { ...result, durationMs, timedOut: result.error?.code === 'ETIMEDOUT' };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Human-readable reason a sweep was killed by its budget; not a test failure. */
|
|
64
|
+
export function budgetKillMessage(label, budget, durationMs) {
|
|
65
|
+
const secs = (durationMs / 1000).toFixed(1);
|
|
66
|
+
return (
|
|
67
|
+
`${label} killed after ${secs}s by the ${budget.name} budget ` +
|
|
68
|
+
`(${budget.envVar}=${budget.ms}) — not a test failure. ` +
|
|
69
|
+
`Raise ${budget.envVar} (milliseconds) if the run is legitimately slow.`
|
|
70
|
+
);
|
|
71
|
+
}
|
package/dist/index.d.mts
CHANGED
|
@@ -490,25 +490,6 @@ declare enum ShippingZoneError {
|
|
|
490
490
|
MISSING_NAME = "MISSING_NAME"
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
declare enum TaxRegistrationKind {
|
|
494
|
-
GST_HST = "GST_HST",
|
|
495
|
-
PST = "PST",
|
|
496
|
-
QST = "QST"
|
|
497
|
-
}
|
|
498
|
-
declare enum TaxSource {
|
|
499
|
-
MERCHANT = "merchant",
|
|
500
|
-
AUTOMATIC = "automatic"
|
|
501
|
-
}
|
|
502
|
-
declare enum OutOfProvinceTaxes {
|
|
503
|
-
AUTOMATIC = "automatic",
|
|
504
|
-
HOME = "home"
|
|
505
|
-
}
|
|
506
|
-
declare enum TaxWarningCode {
|
|
507
|
-
NOT_REGISTERED = "NOT_REGISTERED",
|
|
508
|
-
NO_RULES_FOR_PLACE = "NO_RULES_FOR_PLACE",
|
|
509
|
-
NO_TABLE = "NO_TABLE"
|
|
510
|
-
}
|
|
511
|
-
|
|
512
493
|
declare enum SalesLineAction {
|
|
513
494
|
SALE = "sale",
|
|
514
495
|
REFUND = "refund"
|
|
@@ -1917,201 +1898,6 @@ interface ShippingZoneProblem {
|
|
|
1917
1898
|
}
|
|
1918
1899
|
declare function validateShippingZone(zone: ShippingZoneRule): ShippingZoneProblem[];
|
|
1919
1900
|
|
|
1920
|
-
interface TaxRegistration {
|
|
1921
|
-
kind: TaxRegistrationKind | `${TaxRegistrationKind}`;
|
|
1922
|
-
place: string;
|
|
1923
|
-
number?: string | null;
|
|
1924
|
-
from?: string | null;
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
declare const STANDARD_TAX_TYPE = "standard";
|
|
1928
|
-
type AutomaticTaxRowStatus = 'confirmed' | 'to_confirm';
|
|
1929
|
-
interface AutomaticTaxTypeRow {
|
|
1930
|
-
key: string;
|
|
1931
|
-
name: string;
|
|
1932
|
-
description?: string | null;
|
|
1933
|
-
sortOrder: number;
|
|
1934
|
-
active: boolean;
|
|
1935
|
-
}
|
|
1936
|
-
interface AutomaticTaxPart {
|
|
1937
|
-
code: string;
|
|
1938
|
-
name: string;
|
|
1939
|
-
rate: string;
|
|
1940
|
-
level: 'federal' | 'provincial';
|
|
1941
|
-
}
|
|
1942
|
-
interface AutomaticTaxRateRow {
|
|
1943
|
-
code: string;
|
|
1944
|
-
name: string;
|
|
1945
|
-
kind: TaxRegistrationKind | `${TaxRegistrationKind}`;
|
|
1946
|
-
places: string[];
|
|
1947
|
-
rate: string;
|
|
1948
|
-
from?: string | null;
|
|
1949
|
-
to?: string | null;
|
|
1950
|
-
order: number;
|
|
1951
|
-
compound: boolean;
|
|
1952
|
-
registrationPlace: string;
|
|
1953
|
-
harmonized: boolean;
|
|
1954
|
-
parts?: AutomaticTaxPart[] | null;
|
|
1955
|
-
sourceUrl?: string | null;
|
|
1956
|
-
status: AutomaticTaxRowStatus;
|
|
1957
|
-
}
|
|
1958
|
-
interface AutomaticTaxRuleRow {
|
|
1959
|
-
taxType: string;
|
|
1960
|
-
codes: string[];
|
|
1961
|
-
rate: string;
|
|
1962
|
-
from?: string | null;
|
|
1963
|
-
to?: string | null;
|
|
1964
|
-
sourceUrl?: string | null;
|
|
1965
|
-
status: AutomaticTaxRowStatus;
|
|
1966
|
-
note?: string | null;
|
|
1967
|
-
}
|
|
1968
|
-
interface AutomaticTaxTable {
|
|
1969
|
-
version: string;
|
|
1970
|
-
types: AutomaticTaxTypeRow[];
|
|
1971
|
-
rates: AutomaticTaxRateRow[];
|
|
1972
|
-
rules: AutomaticTaxRuleRow[];
|
|
1973
|
-
}
|
|
1974
|
-
declare function automaticTaxTableVersion(table: Omit<AutomaticTaxTable, 'version'>): string;
|
|
1975
|
-
declare function buildAutomaticTaxTable(rows: {
|
|
1976
|
-
types: readonly AutomaticTaxTypeRow[];
|
|
1977
|
-
rates: readonly AutomaticTaxRateRow[];
|
|
1978
|
-
rules: readonly AutomaticTaxRuleRow[];
|
|
1979
|
-
}): AutomaticTaxTable;
|
|
1980
|
-
declare function registrationPlacesByKind(rates: readonly AutomaticTaxRateRow[]): ReadonlyMap<string, readonly string[]>;
|
|
1981
|
-
|
|
1982
|
-
declare function sha1Hex(text: string): string;
|
|
1983
|
-
|
|
1984
|
-
interface CartAddress {
|
|
1985
|
-
firstName?: string;
|
|
1986
|
-
lastName?: string;
|
|
1987
|
-
address1?: string;
|
|
1988
|
-
address2?: string;
|
|
1989
|
-
city?: string;
|
|
1990
|
-
state?: string;
|
|
1991
|
-
postCode?: string;
|
|
1992
|
-
country?: string;
|
|
1993
|
-
fromCustomer?: boolean;
|
|
1994
|
-
}
|
|
1995
|
-
|
|
1996
|
-
type ShopperScope = {
|
|
1997
|
-
kind: 'all';
|
|
1998
|
-
} | {
|
|
1999
|
-
kind: 'store';
|
|
2000
|
-
companyId: string;
|
|
2001
|
-
};
|
|
2002
|
-
interface ShopperIdentity {
|
|
2003
|
-
id: string;
|
|
2004
|
-
emails: string[];
|
|
2005
|
-
scope: ShopperScope;
|
|
2006
|
-
}
|
|
2007
|
-
type ShopperOrderStatus = 'paid' | 'partially_refunded' | 'refunded' | 'cancelled';
|
|
2008
|
-
interface ShopperStoreRef {
|
|
2009
|
-
companyId: string;
|
|
2010
|
-
name: string;
|
|
2011
|
-
logo: string | null;
|
|
2012
|
-
}
|
|
2013
|
-
interface ShopperOrderRow {
|
|
2014
|
-
orderId: string;
|
|
2015
|
-
receiptId: string;
|
|
2016
|
-
placedAt: string;
|
|
2017
|
-
store: ShopperStoreRef;
|
|
2018
|
-
status: ShopperOrderStatus;
|
|
2019
|
-
total: number;
|
|
2020
|
-
currency: CurrencyCode | null;
|
|
2021
|
-
itemCount: number;
|
|
2022
|
-
}
|
|
2023
|
-
interface ShopperOrderItem {
|
|
2024
|
-
lineId: string;
|
|
2025
|
-
name: string;
|
|
2026
|
-
variant: string | null;
|
|
2027
|
-
quantity: number;
|
|
2028
|
-
total: number;
|
|
2029
|
-
}
|
|
2030
|
-
interface ShopperOrderTotals {
|
|
2031
|
-
subtotal: number;
|
|
2032
|
-
discount: number;
|
|
2033
|
-
tax: number;
|
|
2034
|
-
shipping: number;
|
|
2035
|
-
refunded: number;
|
|
2036
|
-
}
|
|
2037
|
-
interface ShopperCard {
|
|
2038
|
-
brand: string;
|
|
2039
|
-
lastFour: string;
|
|
2040
|
-
}
|
|
2041
|
-
interface ShopperOrderDetail extends ShopperOrderRow {
|
|
2042
|
-
items: ShopperOrderItem[];
|
|
2043
|
-
totals: ShopperOrderTotals;
|
|
2044
|
-
card: ShopperCard | null;
|
|
2045
|
-
delivery: {
|
|
2046
|
-
type: 'pickup' | 'shipping';
|
|
2047
|
-
place: string | null;
|
|
2048
|
-
} | null;
|
|
2049
|
-
returnRequestedAt: string | null;
|
|
2050
|
-
}
|
|
2051
|
-
interface ShopperPaymentMethod {
|
|
2052
|
-
id: string;
|
|
2053
|
-
brand: string;
|
|
2054
|
-
lastFour: string;
|
|
2055
|
-
expiryMonth: string;
|
|
2056
|
-
expiryYear: string;
|
|
2057
|
-
holderName: string | null;
|
|
2058
|
-
isDefault: boolean;
|
|
2059
|
-
}
|
|
2060
|
-
interface ShopperStore extends ShopperStoreRef {
|
|
2061
|
-
city: string | null;
|
|
2062
|
-
email: string | null;
|
|
2063
|
-
phone: string | null;
|
|
2064
|
-
website: string | null;
|
|
2065
|
-
returnPolicy: string | null;
|
|
2066
|
-
news: boolean;
|
|
2067
|
-
orderCount: number;
|
|
2068
|
-
}
|
|
2069
|
-
declare const SHOPPER_CONSENT_SOURCES: readonly ["checkout", "my-account", "store-account"];
|
|
2070
|
-
type ShopperConsentSource = (typeof SHOPPER_CONSENT_SOURCES)[number];
|
|
2071
|
-
interface ShopperSavedAddress extends Omit<CartAddress, 'fromCustomer'> {
|
|
2072
|
-
id: string;
|
|
2073
|
-
label: string | null;
|
|
2074
|
-
isDefault: boolean;
|
|
2075
|
-
}
|
|
2076
|
-
type ShopperAddressInput = Omit<ShopperSavedAddress, 'id' | 'isDefault'>;
|
|
2077
|
-
interface ShopperNotificationChoices {
|
|
2078
|
-
sms: boolean;
|
|
2079
|
-
push: boolean;
|
|
2080
|
-
}
|
|
2081
|
-
interface ShopperProfile {
|
|
2082
|
-
phone: string | null;
|
|
2083
|
-
addresses: ShopperSavedAddress[];
|
|
2084
|
-
defaultCardId: string | null;
|
|
2085
|
-
notifications: ShopperNotificationChoices;
|
|
2086
|
-
}
|
|
2087
|
-
declare const SHOPPER_RETURN_METHODS: readonly ["mail", "in-store"];
|
|
2088
|
-
type ShopperReturnMethod = (typeof SHOPPER_RETURN_METHODS)[number];
|
|
2089
|
-
interface ShopperReturnRequestInput {
|
|
2090
|
-
items: {
|
|
2091
|
-
lineId: string;
|
|
2092
|
-
quantity: number;
|
|
2093
|
-
}[];
|
|
2094
|
-
method: ShopperReturnMethod;
|
|
2095
|
-
note?: string;
|
|
2096
|
-
}
|
|
2097
|
-
declare const SHOPPER_ERROR_CODES: {
|
|
2098
|
-
readonly ORDER_NOT_FOUND: "ORDER_NOT_FOUND";
|
|
2099
|
-
readonly RETURN_ALREADY_REQUESTED: "RETURN_ALREADY_REQUESTED";
|
|
2100
|
-
readonly RETURN_NOT_ALLOWED: "RETURN_NOT_ALLOWED";
|
|
2101
|
-
readonly STORE_HAS_NO_SUPPORT_EMAIL: "STORE_HAS_NO_SUPPORT_EMAIL";
|
|
2102
|
-
readonly TOO_MANY_ADDRESSES: "TOO_MANY_ADDRESSES";
|
|
2103
|
-
readonly STORE_NOT_LINKED: "STORE_NOT_LINKED";
|
|
2104
|
-
readonly STORED_METHOD_NOT_FOUND: "STORED_METHOD_NOT_FOUND";
|
|
2105
|
-
};
|
|
2106
|
-
type ShopperErrorCode = (typeof SHOPPER_ERROR_CODES)[keyof typeof SHOPPER_ERROR_CODES];
|
|
2107
|
-
|
|
2108
|
-
declare function normalizeShopperEmail(email: unknown): string | null;
|
|
2109
|
-
|
|
2110
|
-
declare function cardFromProcessorData(processorData: unknown): {
|
|
2111
|
-
cardBrand?: string;
|
|
2112
|
-
cardLastFour?: string;
|
|
2113
|
-
};
|
|
2114
|
-
|
|
2115
1901
|
interface CurrencyRate {
|
|
2116
1902
|
rate: number;
|
|
2117
1903
|
country: string;
|
|
@@ -2180,4 +1966,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
|
|
|
2180
1966
|
}];
|
|
2181
1967
|
type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
|
|
2182
1968
|
|
|
2183
|
-
export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, type AssignUserChange, AttributeType, type
|
|
1969
|
+
export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, type AssignUserChange, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, HttpMethod, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForAssignedUsers, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductSalesChartStep, ProductSalesReportCompare, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, SHIPPING_COUNTRIES, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, SalesLineAction, SalesLineSourceArray, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, type ShippingTuple, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, applyAssignment, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, currentAssignees, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, listShippingCountries, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, orderAssignments, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shipsToCountry, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
|