@nauticana/sail 1.1.33 → 1.1.35
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 +36 -23
- package/package.json +1 -1
- package/src/agent/component/approval_inbox.html +110 -0
- package/src/agent/component/approval_inbox.ts +129 -0
- package/src/agent/component/assistant_activity.html +28 -0
- package/src/agent/component/assistant_activity.ts +40 -0
- package/src/agent/component/decision_timeline.html +4 -4
- package/src/agent/component/decision_timeline.ts +2 -0
- package/src/agent/component/prompt_section_editor.html +4 -3
- package/src/agent/component/prompt_section_editor.ts +12 -5
- package/src/agent/component/release_sections.html +1 -1
- package/src/agent/component/release_sections.ts +2 -1
- package/src/agent/component/studio_page.html +303 -0
- package/src/agent/component/studio_page.ts +403 -0
- package/src/agent/component/studio_tab.ts +14 -0
- package/src/agent/component/turn_event_list.html +9 -0
- package/src/agent/component/turn_thread.html +27 -0
- package/src/agent/component/turn_thread.ts +83 -0
- package/src/agent/index.ts +8 -0
- package/src/agent/model/agent_studio.ts +185 -9
- package/src/agent/model/approval.ts +78 -0
- package/src/agent/model/conversation.ts +40 -1
- package/src/agent/model/decision.ts +14 -9
- package/src/agent/model/turn_event.ts +10 -0
- package/src/agent/service/agent_studio.service.ts +65 -1
- package/src/agent/service/approval.service.ts +38 -0
- package/src/agent/service/conversation.service.ts +10 -0
- package/src/agent/util/release_diff.ts +33 -0
- package/src/agent/util/studio_errors.ts +11 -0
- package/src/agent/util/turn_timeline.ts +7 -1
- package/src/component/agency/agency_earnings_summary.html +3 -3
- package/src/component/agency/agency_earnings_summary.ts +2 -2
- package/src/component/agency/agency_payout_history.html +1 -1
- package/src/component/agency/agency_payout_history.ts +2 -3
- package/src/component/agency/commission_ledger.html +1 -1
- package/src/component/agency/commission_ledger.ts +2 -3
- package/src/component/billing/plan_selector.ts +1 -1
- package/src/component/billing/price_selector.ts +5 -5
- package/src/component/login/account_deletion.html +17 -4
- package/src/component/login/account_deletion.ts +35 -28
- package/src/component/login/social_login.ts +6 -5
- package/src/component/payout/bank_info_form.html +15 -6
- package/src/component/payout/bank_info_form.ts +28 -72
- package/src/component/security/api_keys.html +78 -0
- package/src/component/security/api_keys.ts +90 -0
- package/src/component/security/connected_apps.html +25 -0
- package/src/component/security/connected_apps.ts +40 -0
- package/src/index.ts +8 -0
- package/src/model/access.ts +28 -0
- package/src/model/appdata.ts +41 -67
- package/src/model/auth.ts +17 -2
- package/src/model/geo.ts +12 -0
- package/src/service/access.service.ts +57 -0
- package/src/service/auth.service.ts +10 -4
- package/src/service/caption_pipe.ts +32 -0
- package/src/service/currency.service.ts +51 -0
- package/src/service/label.service.ts +5 -4
- package/src/service/money_pipe.ts +27 -0
- package/src/service/rest_service.ts +1 -1
- package/src/service/rest_url.ts +4 -0
- package/src/util/money.ts +18 -34
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DestroyRef, Pipe, PipeTransform, inject } from '@angular/core';
|
|
2
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
3
|
+
import { formatMinor } from '../util/money';
|
|
4
|
+
import { CurrencyService } from './currency.service';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `{{ minor | sailMoney:currency }}` formats integer minor units at the catalog exponent, '' until
|
|
8
|
+
* the catalog loads; `{{ minor | sailMoney:currency:exponent }}` uses the exponent keel sent with
|
|
9
|
+
* the amount and needs no catalog. Impure so it re-renders once the catalog is ready.
|
|
10
|
+
*/
|
|
11
|
+
@Pipe({ name: 'sailMoney', pure: false })
|
|
12
|
+
export class MoneyPipe implements PipeTransform {
|
|
13
|
+
private readonly currencies = inject(CurrencyService);
|
|
14
|
+
private readonly destroyRef = inject(DestroyRef);
|
|
15
|
+
private requested = false;
|
|
16
|
+
|
|
17
|
+
transform(minor: number, currency: string, exponent?: number): string {
|
|
18
|
+
if (exponent !== undefined) return formatMinor(minor, currency, exponent);
|
|
19
|
+
if (this.currencies.ready()) return this.currencies.format(minor, currency);
|
|
20
|
+
if (this.currencies.failed()) throw new Error('sail: failed to load the currency catalog.');
|
|
21
|
+
if (!this.requested) {
|
|
22
|
+
this.requested = true;
|
|
23
|
+
this.currencies.load().pipe(takeUntilDestroyed(this.destroyRef)).subscribe({ error: () => undefined });
|
|
24
|
+
}
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -39,7 +39,7 @@ export class SailApiError extends Error {
|
|
|
39
39
|
|
|
40
40
|
@Injectable({providedIn: 'root'})
|
|
41
41
|
export class BackendService extends BaseRestService {
|
|
42
|
-
|
|
42
|
+
protected readonly auth = inject(BaseAuthService);
|
|
43
43
|
|
|
44
44
|
/** Resolved per call so configureRestUrls() may run any time before the first request. */
|
|
45
45
|
protected get prefix(): string {
|
package/src/service/rest_url.ts
CHANGED
|
@@ -25,6 +25,9 @@ export const RestURL = {
|
|
|
25
25
|
trustedDeviceRevokeURL: '/api/user/trusted-device/revoke',
|
|
26
26
|
sessionListURL: '/api/user/sessions',
|
|
27
27
|
sessionRevokeURL: '/api/user/sessions/revoke',
|
|
28
|
+
// keel GrantHandler (v1.2.112): the signed-in user's OAuth grants.
|
|
29
|
+
oauthGrantsURL: '/api/user/oauth-grants',
|
|
30
|
+
oauthGrantRevokeURL: '/api/user/oauth-grants/revoke',
|
|
28
31
|
checkoutURL: '/api/billing/checkout',
|
|
29
32
|
subscriptionURL: '/api/billing/subscription',
|
|
30
33
|
cancelSubURL: '/api/billing/subscription/cancel',
|
|
@@ -45,6 +48,7 @@ export const RestURL = {
|
|
|
45
48
|
ssoSamlMetadataURL: '/public/sso/saml/metadata',
|
|
46
49
|
logoutEverywhereURL: '/api/user/logout-everywhere',
|
|
47
50
|
deleteAccountURL: '/api/user/account',
|
|
51
|
+
reauthSendURL: '/api/user/reauth/send',
|
|
48
52
|
// Self-service profile (keel ProfileHandler). GET profileURL reads the
|
|
49
53
|
// current profile; POST updates name/locale. Email/phone are verify-before-
|
|
50
54
|
// apply (request → confirm). A consumer whose backend mounts these under a
|
package/src/util/money.ts
CHANGED
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
import { PlanPrice } from '../model/appdata';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Format
|
|
5
|
-
*
|
|
6
|
-
* for an unknown currency code rather than throwing.
|
|
4
|
+
* Format integer minor units at the currency's exponent from keel's `currency` table.
|
|
5
|
+
* `Intl` supplies only the symbol and grouping; it never decides the decimals.
|
|
7
6
|
*/
|
|
8
|
-
export function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return `${amount} ${currency}`;
|
|
7
|
+
export function formatMinor(minor: number, currency: string, exponent: number): string {
|
|
8
|
+
if (!Number.isSafeInteger(minor)) throw new Error(`sail: money must be a safe integer (${minor}).`);
|
|
9
|
+
if (!Number.isInteger(exponent) || exponent < 0 || exponent > 6) {
|
|
10
|
+
throw new Error(`sail: currency "${currency}" has no valid exponent (${exponent}).`);
|
|
13
11
|
}
|
|
14
|
-
}
|
|
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
12
|
const code = currency.trim().toUpperCase();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} catch {
|
|
27
|
-
return `${minor} ${code}`;
|
|
28
|
-
}
|
|
13
|
+
if (!code) throw new Error('sail: currency is required.');
|
|
14
|
+
return new Intl.NumberFormat(undefined, {
|
|
15
|
+
style: 'currency', currency: code, minimumFractionDigits: exponent, maximumFractionDigits: exponent,
|
|
16
|
+
}).format(minor / 10 ** exponent);
|
|
29
17
|
}
|
|
30
18
|
|
|
31
19
|
/** PERIOD_TYPE code vocabulary — the single source for cycle labels/durations. */
|
|
@@ -38,19 +26,15 @@ export const PERIOD_TYPE_INFO: Record<string, { label: string; noun: string; suf
|
|
|
38
26
|
};
|
|
39
27
|
|
|
40
28
|
/**
|
|
41
|
-
* "From" price teaser for a plan card
|
|
42
|
-
*
|
|
43
|
-
* compared within one currency, rendered with its cycle ("from $30.00/mo").
|
|
44
|
-
* Returns '' when the plan has no priced offers (free/trial). The exact offer
|
|
45
|
-
* is chosen later via `<sail-price-selector>`.
|
|
29
|
+
* "From" price teaser for a plan card: the cheapest offer per month within the first
|
|
30
|
+
* offer's currency, rendered with its cycle ("from $30.00/mo"); '' when nothing is priced.
|
|
46
31
|
*/
|
|
47
|
-
export function fromPriceLabel(prices: PlanPrice[] | undefined): string {
|
|
48
|
-
const priced = (prices ?? []).filter((p) => p.
|
|
32
|
+
export function fromPriceLabel(prices: readonly PlanPrice[] | null | undefined): string {
|
|
33
|
+
const priced = (prices ?? []).filter((p) => p.amountMinor > 0);
|
|
49
34
|
if (priced.length === 0) return '';
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const perMonth = (p: PlanPrice) => p.amount / (PERIOD_TYPE_INFO[p.billingCycle]?.months ?? 1);
|
|
35
|
+
const comparable = priced.filter((p) => p.currency === priced[0].currency);
|
|
36
|
+
const perMonth = (p: PlanPrice) => p.amountMinor / (PERIOD_TYPE_INFO[p.billingCycle]?.months ?? 1);
|
|
53
37
|
const lowest = comparable.reduce((a, b) => (perMonth(b) < perMonth(a) ? b : a));
|
|
54
|
-
const formatted =
|
|
55
|
-
return
|
|
38
|
+
const formatted = formatMinor(lowest.amountMinor, lowest.currency, lowest.exponent) + (PERIOD_TYPE_INFO[lowest.billingCycle]?.suffix ?? '');
|
|
39
|
+
return comparable.length > 1 ? `from ${formatted}` : formatted;
|
|
56
40
|
}
|