@composable-os/client 0.1.0-beta.17 → 0.1.0-beta.19
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/account.d.ts +1 -6
- package/dist/account.js +11 -36
- package/dist/agreements.d.ts +1 -1
- package/dist/agreements.js +4 -10
- package/dist/display.d.ts +1 -0
- package/dist/display.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/owner.js +3 -14
- package/package.json +5 -2
package/dist/account.d.ts
CHANGED
|
@@ -589,14 +589,9 @@ export declare function accountSections(packs?: readonly AccountSection[], hide?
|
|
|
589
589
|
export declare function portalSections(portal: AccountPortal | undefined, packs?: readonly AccountSection[], base?: readonly string[]): AccountSection[];
|
|
590
590
|
/** The base sections a shell hides for this customer, from what the host answered. */
|
|
591
591
|
export declare function hiddenSections(subscriptions: readonly AccountSubscription[] | undefined): string[];
|
|
592
|
-
/**
|
|
593
|
-
* An amount the host gave in the currency's minor unit, in that currency: `$29.00`. Display only:
|
|
594
|
-
* the minor unit's digits are the currency's own.
|
|
595
|
-
*/
|
|
596
|
-
export declare function formatMinor(minor: number, currency: string, locale?: string): string;
|
|
597
592
|
/** A date as a reader sees it (`3 Dec 2026`), from the host's ISO timestamp. Display only. */
|
|
598
593
|
export declare function accountDay(iso: string | null | undefined, locale?: string): string;
|
|
599
|
-
/** A moment as a reader sees it (`3 Dec 2026,
|
|
594
|
+
/** A moment as a reader sees it (`3 Dec 2026, 9:30 am`). Display only. */
|
|
600
595
|
export declare function accountTime(iso: string | null | undefined, locale?: string): string;
|
|
601
596
|
/** A session in words: what it is, and when it began and was last used. */
|
|
602
597
|
export declare function sessionWords(session: AccountSession): {
|
package/dist/account.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatDay, formatDayTime, formatMinor, monthName } from "./display.js";
|
|
1
2
|
import { packHooks } from "./hooks.js";
|
|
2
3
|
/**
|
|
3
4
|
* What can need a customer's attention (`me.attention`, ADR 0711): a fixed vocabulary in core.
|
|
@@ -104,40 +105,13 @@ export function hiddenSections(subscriptions) {
|
|
|
104
105
|
return showsPayment(subscriptions) ? [] : ["payment"];
|
|
105
106
|
}
|
|
106
107
|
// --- Words (display only) ----------------------------------------------------------------------------
|
|
107
|
-
/**
|
|
108
|
-
* An amount the host gave in the currency's minor unit, in that currency: `$29.00`. Display only:
|
|
109
|
-
* the minor unit's digits are the currency's own.
|
|
110
|
-
*/
|
|
111
|
-
export function formatMinor(minor, currency, locale) {
|
|
112
|
-
try {
|
|
113
|
-
const format = new Intl.NumberFormat(locale, { style: "currency", currency });
|
|
114
|
-
const digits = format.resolvedOptions().maximumFractionDigits ?? 2;
|
|
115
|
-
return format.format(minor / 10 ** digits);
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
return `${minor} ${currency}`;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
/** The host's ISO timestamp as a reader sees it, or "" for none or one that does not parse. */
|
|
122
|
-
function localWhen(iso, locale, format) {
|
|
123
|
-
if (!iso)
|
|
124
|
-
return "";
|
|
125
|
-
const at = new Date(iso);
|
|
126
|
-
return Number.isNaN(at.getTime()) ? "" : at.toLocaleString(locale, format);
|
|
127
|
-
}
|
|
128
108
|
/** A date as a reader sees it (`3 Dec 2026`), from the host's ISO timestamp. Display only. */
|
|
129
109
|
export function accountDay(iso, locale) {
|
|
130
|
-
return
|
|
110
|
+
return formatDay(iso, { locale });
|
|
131
111
|
}
|
|
132
|
-
/** A moment as a reader sees it (`3 Dec 2026,
|
|
112
|
+
/** A moment as a reader sees it (`3 Dec 2026, 9:30 am`). Display only. */
|
|
133
113
|
export function accountTime(iso, locale) {
|
|
134
|
-
return
|
|
135
|
-
day: "numeric",
|
|
136
|
-
month: "short",
|
|
137
|
-
year: "numeric",
|
|
138
|
-
hour: "2-digit",
|
|
139
|
-
minute: "2-digit",
|
|
140
|
-
});
|
|
114
|
+
return formatDayTime(iso, { locale });
|
|
141
115
|
}
|
|
142
116
|
/** A session in words: what it is, and when it began and was last used. */
|
|
143
117
|
export function sessionWords(session) {
|
|
@@ -181,7 +155,7 @@ export function orderStateWords(order) {
|
|
|
181
155
|
* order does not have (no deposit, nothing refunded) is left out.
|
|
182
156
|
*/
|
|
183
157
|
export function orderMoney(order, locale) {
|
|
184
|
-
const money = (minor) => formatMinor(minor, order.currency, locale);
|
|
158
|
+
const money = (minor) => formatMinor(minor, order.currency, { locale });
|
|
185
159
|
const out = [{ key: "total", label: "Total", value: money(order.total) }];
|
|
186
160
|
if (order.taxAmount > 0)
|
|
187
161
|
out.push({ key: "tax", label: "Tax included", value: money(order.taxAmount) });
|
|
@@ -295,7 +269,7 @@ export function subscriptionStatus(sub, locale) {
|
|
|
295
269
|
}
|
|
296
270
|
/** One period's price in words (`$29.00 a month`), as the host gave it. */
|
|
297
271
|
export function subscriptionPrice(sub, locale) {
|
|
298
|
-
return `${formatMinor(sub.amount, sub.currency, locale)} a ${sub.interval}`;
|
|
272
|
+
return `${formatMinor(sub.amount, sub.currency, { locale })} a ${sub.interval}`;
|
|
299
273
|
}
|
|
300
274
|
/** What a native shell says where money is managed on the website (ADR 0714). */
|
|
301
275
|
export const MANAGE_ON_WEBSITE_WORDS = "Manage on the website";
|
|
@@ -355,10 +329,9 @@ export function birthdayDays(month) {
|
|
|
355
329
|
}
|
|
356
330
|
/** The twelve months' names in `locale`, January first, with their numbers. */
|
|
357
331
|
export function birthdayMonths(locale) {
|
|
358
|
-
const format = new Intl.DateTimeFormat(locale, { month: "long", timeZone: "UTC" });
|
|
359
332
|
return DAYS_IN_MONTH.map((_, i) => ({
|
|
360
333
|
value: String(i + 1),
|
|
361
|
-
label:
|
|
334
|
+
label: monthName(i + 1, { locale }),
|
|
362
335
|
}));
|
|
363
336
|
}
|
|
364
337
|
export function birthdayForm(birthday) {
|
|
@@ -578,7 +551,7 @@ export function isPreviewChanged(error) {
|
|
|
578
551
|
}
|
|
579
552
|
/** The preview in words, every part of it, as the host answered it. Display only. */
|
|
580
553
|
export function deletePreviewWords(preview, locale) {
|
|
581
|
-
const money = (minor, currency) => formatMinor(minor, currency, locale);
|
|
554
|
+
const money = (minor, currency) => formatMinor(minor, currency, { locale });
|
|
582
555
|
const ends = preview.subscriptions.map((sub) => {
|
|
583
556
|
const what = `${sub.title} (${money(sub.amount, sub.currency)} a ${sub.interval})`;
|
|
584
557
|
const when = sub.endsAt ? ` on ${accountDay(sub.endsAt, locale)}` : "";
|
|
@@ -627,7 +600,9 @@ export function deletedWords(done, locale) {
|
|
|
627
600
|
/** An attention item in words: what it is, the detail, and what the button says. Display only. */
|
|
628
601
|
export function attentionWords(item, locale) {
|
|
629
602
|
const day = accountDay(item.at, locale);
|
|
630
|
-
const money = item.amount !== null && item.currency
|
|
603
|
+
const money = item.amount !== null && item.currency
|
|
604
|
+
? formatMinor(item.amount, item.currency, { locale })
|
|
605
|
+
: "";
|
|
631
606
|
const left = item.usesLeft === null ? "" : item.usesLeft === 1 ? "1 left" : `${item.usesLeft} left`;
|
|
632
607
|
const title = item.record.title;
|
|
633
608
|
const whose = item.person.self ? null : `For ${item.person.name}`;
|
package/dist/agreements.d.ts
CHANGED
|
@@ -235,7 +235,7 @@ export declare function copyWords(accepted: Pick<Accepted, "copyTo">): string;
|
|
|
235
235
|
* gave (the host's messages name a rule only).
|
|
236
236
|
*/
|
|
237
237
|
export declare function agreeErrorWords(error: unknown): string;
|
|
238
|
-
/** A moment in the person's own zone, for display ("24 Nov 2026,
|
|
238
|
+
/** A moment in the person's own zone, for display ("24 Nov 2026, 9:30 am"). */
|
|
239
239
|
export declare function agreementTime(iso: string, locale?: string): string;
|
|
240
240
|
/** Where a person's own signed PDF downloads from on the app's site (the host's route, ADR 0645). */
|
|
241
241
|
export declare function agreementPdfPath(acceptanceId: string): string;
|
package/dist/agreements.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// What a person types, draws and answers is personal data, and health answers are health
|
|
13
13
|
// information: nothing here logs, stores or sends them anywhere but the one call that agrees.
|
|
14
14
|
// They live in a block's memory until that call, and the block forgets them after it.
|
|
15
|
+
import { formatDayTime } from "./display.js";
|
|
15
16
|
import { packHooks } from "./hooks.js";
|
|
16
17
|
export const MINOR_PAYER_WORDS = "A parent or guardian needs to buy this for you.";
|
|
17
18
|
const CHANGED_WORDS = "What must be agreed to changed just now. Please read it again.";
|
|
@@ -223,16 +224,9 @@ export function agreeErrorWords(error) {
|
|
|
223
224
|
return e.message;
|
|
224
225
|
return "That did not go through. Please try again.";
|
|
225
226
|
}
|
|
226
|
-
/** A moment in the person's own zone, for display ("24 Nov 2026,
|
|
227
|
-
export function agreementTime(iso, locale
|
|
228
|
-
return
|
|
229
|
-
day: "numeric",
|
|
230
|
-
month: "short",
|
|
231
|
-
year: "numeric",
|
|
232
|
-
hour: "2-digit",
|
|
233
|
-
minute: "2-digit",
|
|
234
|
-
hourCycle: "h23",
|
|
235
|
-
}).format(new Date(iso));
|
|
227
|
+
/** A moment in the person's own zone, for display ("24 Nov 2026, 9:30 am"). */
|
|
228
|
+
export function agreementTime(iso, locale) {
|
|
229
|
+
return formatDayTime(iso, { locale });
|
|
236
230
|
}
|
|
237
231
|
/** Where a person's own signed PDF downloads from on the app's site (the host's route, ADR 0645). */
|
|
238
232
|
export function agreementPdfPath(acceptanceId) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@composable-os/sdk/display";
|
package/dist/display.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// How money, clock times, dates and durations read (issue #577) are defined once, in the SDK's
|
|
2
|
+
// dependency-free `display` entry, so the host, routine mail and extension code say them as every
|
|
3
|
+
// screen does. The client re-exports them for the app, the blocks and client apps.
|
|
4
|
+
export * from "@composable-os/sdk/display";
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/owner.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// What is on screen only: money, the drill-in rows (they name members) and an approval's detail
|
|
13
13
|
// are read with `gcTime: 0`, and `forgetToday` drops them when the app goes to the background
|
|
14
14
|
// (ADR 0629's pattern).
|
|
15
|
+
import { formatDay, formatMinor } from "./display.js";
|
|
15
16
|
import { ApiError, NetworkError } from "./errors.js";
|
|
16
17
|
import { packHooks } from "./hooks.js";
|
|
17
18
|
// --- Words -----------------------------------------------------------------------------------------
|
|
@@ -21,15 +22,9 @@ export function todayValueWords(item, locale) {
|
|
|
21
22
|
return new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 0 }).format(item.value / 100);
|
|
22
23
|
}
|
|
23
24
|
if (item.format === "money" && item.currency)
|
|
24
|
-
return
|
|
25
|
+
return formatMinor(item.value, item.currency, { locale });
|
|
25
26
|
return new Intl.NumberFormat(locale).format(item.value);
|
|
26
27
|
}
|
|
27
|
-
/** An amount in a currency's minor unit, in words: `$1,234.50`. */
|
|
28
|
-
function moneyWords(minor, currency, locale) {
|
|
29
|
-
const format = new Intl.NumberFormat(locale, { style: "currency", currency });
|
|
30
|
-
const digits = format.resolvedOptions().maximumFractionDigits ?? 2;
|
|
31
|
-
return format.format(minor / 10 ** digits);
|
|
32
|
-
}
|
|
33
28
|
/** The comparison under a value: `5 yesterday`, `$90.00 last week`, or null when there is none. */
|
|
34
29
|
export function todayCompareWords(item, locale) {
|
|
35
30
|
if (!item.compare)
|
|
@@ -39,13 +34,7 @@ export function todayCompareWords(item, locale) {
|
|
|
39
34
|
}
|
|
40
35
|
/** The day at the top of the screen, in the business's zone: `Tuesday 24 November`. */
|
|
41
36
|
export function todayDayWords(answer, locale) {
|
|
42
|
-
|
|
43
|
-
return new Intl.DateTimeFormat(locale, {
|
|
44
|
-
weekday: "long",
|
|
45
|
-
day: "numeric",
|
|
46
|
-
month: "long",
|
|
47
|
-
timeZone: "UTC",
|
|
48
|
-
}).format(new Date(`${answer.day}T12:00:00Z`));
|
|
37
|
+
return formatDay(answer.day, { weekday: "long", month: "long", year: false, locale });
|
|
49
38
|
}
|
|
50
39
|
/** What a setup change says on a phone: the host refuses it there (decision 8). */
|
|
51
40
|
export const REVIEW_ON_COMPUTER_WORDS = "Review on a computer";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composable-os/client",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.19",
|
|
4
4
|
"license": "FSL-1.1-ALv2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -21,5 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist"
|
|
24
|
-
]
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@composable-os/sdk": "0.1.0-beta.19"
|
|
27
|
+
}
|
|
25
28
|
}
|