@nauticana/sail 1.1.12 → 1.1.14
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 +83 -8
- package/package.json +1 -1
- package/src/component/agency/agency_accept.html +33 -0
- package/src/component/agency/agency_accept.ts +94 -0
- package/src/component/agency/agency_clients.html +97 -0
- package/src/component/agency/agency_clients.ts +182 -0
- package/src/component/agency/agency_earnings_summary.html +24 -0
- package/src/component/agency/agency_earnings_summary.ts +15 -0
- package/src/component/agency/agency_payout_history.html +19 -0
- package/src/component/agency/agency_payout_history.ts +18 -0
- package/src/component/agency/agency_payout_profile.html +49 -0
- package/src/component/agency/agency_payout_profile.ts +101 -0
- package/src/component/agency/agency_status_banner.html +9 -0
- package/src/component/agency/agency_status_banner.ts +24 -0
- package/src/component/agency/commission_ledger.html +19 -0
- package/src/component/agency/commission_ledger.ts +18 -0
- package/src/component/login/login_component.html +8 -2
- package/src/component/payout/bank_info_form.ts +9 -3
- package/src/component/payout/provider_onboarding.ts +17 -5
- package/src/config.ts +2 -2
- package/src/index.ts +9 -0
- package/src/model/agency.ts +109 -0
- package/src/model/appdata.ts +10 -6
- package/src/service/agency.service.ts +76 -0
- package/src/service/payout.service.ts +27 -1
- package/src/service/rest_service.ts +1 -0
- package/src/service/rest_url.ts +16 -0
- package/src/util/errors.ts +25 -8
- package/src/util/money.ts +15 -0
package/src/util/errors.ts
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type ProblemShape = { title?: unknown; detail?: unknown; message?: unknown; code?: unknown };
|
|
2
|
+
|
|
3
|
+
// Structural extraction, not instanceof: bundling can produce two class
|
|
4
|
+
// identities for HttpErrorResponse (see api-response.interceptor.ts), so match
|
|
5
|
+
// by shape — SailApiError carries `problem`, an HTTP error a numeric `status`
|
|
6
|
+
// plus an `error` body.
|
|
7
|
+
function problemOf(err: unknown): ProblemShape | undefined {
|
|
8
|
+
if (!err || typeof err !== 'object') return undefined;
|
|
9
|
+
const e = err as { problem?: unknown; status?: unknown; error?: unknown };
|
|
10
|
+
const body = e.problem ?? (typeof e.status === 'number' && 'error' in e ? e.error : undefined);
|
|
11
|
+
return body && typeof body === 'object' ? (body as ProblemShape) : undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function asString(value: unknown): string | undefined {
|
|
15
|
+
return typeof value === 'string' && value ? value : undefined;
|
|
16
|
+
}
|
|
3
17
|
|
|
4
18
|
/**
|
|
5
19
|
* Human-readable message from any sail error shape — SailApiError (BackendService),
|
|
6
20
|
* raw HttpErrorResponse (direct HttpClient calls), or plain Error.
|
|
7
21
|
*/
|
|
8
22
|
export function errorDetail(err: unknown, fallback: string): string {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const body = err.error as { detail?: string; message?: string } | null;
|
|
14
|
-
return body?.detail ?? body?.message ?? fallback;
|
|
23
|
+
const problem = problemOf(err);
|
|
24
|
+
if (problem) {
|
|
25
|
+
const message = asString(problem.detail) ?? asString(problem.title) ?? asString(problem.message);
|
|
26
|
+
if (message) return message;
|
|
15
27
|
}
|
|
16
28
|
if (err instanceof Error && err.message) {
|
|
17
29
|
return err.message;
|
|
18
30
|
}
|
|
19
31
|
return fallback;
|
|
20
32
|
}
|
|
33
|
+
|
|
34
|
+
/** Stable machine-readable discriminator from a keel RFC 7807 response. */
|
|
35
|
+
export function errorCode(err: unknown): string | undefined {
|
|
36
|
+
return asString(problemOf(err)?.code);
|
|
37
|
+
}
|
package/src/util/money.ts
CHANGED
|
@@ -13,6 +13,21 @@ export function formatCurrency(amount: number, currency: string): string {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Format an integer minor-unit amount using the currency's exponent reported
|
|
18
|
+
* by Intl (JPY 0, USD 2, BHD 3, ...). No hardcoded /100 assumption.
|
|
19
|
+
*/
|
|
20
|
+
export function formatMinorCurrency(minor: number, currency: string): string {
|
|
21
|
+
const code = currency.trim().toUpperCase();
|
|
22
|
+
try {
|
|
23
|
+
const formatter = new Intl.NumberFormat(undefined, { style: 'currency', currency: code });
|
|
24
|
+
const exponent = formatter.resolvedOptions().maximumFractionDigits ?? 2;
|
|
25
|
+
return formatter.format(minor / 10 ** exponent);
|
|
26
|
+
} catch {
|
|
27
|
+
return `${minor} ${code}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
16
31
|
/** PERIOD_TYPE code vocabulary — the single source for cycle labels/durations. */
|
|
17
32
|
export const PERIOD_TYPE_INFO: Record<string, { label: string; noun: string; suffix: string; months: number }> = {
|
|
18
33
|
D: { label: 'Daily', noun: 'day', suffix: '/day', months: 1 / 30 },
|