@hobenakicoffee/libraries 1.23.0 → 1.25.0
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/package.json +1 -1
- package/src/types/supabase.ts +13 -5
- package/src/utils/format-count.test.ts +21 -0
- package/src/utils/format-count.ts +11 -0
- package/src/utils/index.ts +1 -0
package/package.json
CHANGED
package/src/types/supabase.ts
CHANGED
|
@@ -610,7 +610,6 @@ export type Database = {
|
|
|
610
610
|
};
|
|
611
611
|
newsletter_post_versions: {
|
|
612
612
|
Row: {
|
|
613
|
-
ai_summary: string | null;
|
|
614
613
|
content: string | null;
|
|
615
614
|
created_at: string;
|
|
616
615
|
id: string;
|
|
@@ -620,7 +619,6 @@ export type Database = {
|
|
|
620
619
|
version_number: number;
|
|
621
620
|
};
|
|
622
621
|
Insert: {
|
|
623
|
-
ai_summary?: string | null;
|
|
624
622
|
content?: string | null;
|
|
625
623
|
created_at?: string;
|
|
626
624
|
id?: string;
|
|
@@ -630,7 +628,6 @@ export type Database = {
|
|
|
630
628
|
version_number: number;
|
|
631
629
|
};
|
|
632
630
|
Update: {
|
|
633
|
-
ai_summary?: string | null;
|
|
634
631
|
content?: string | null;
|
|
635
632
|
created_at?: string;
|
|
636
633
|
id?: string;
|
|
@@ -1497,6 +1494,7 @@ export type Database = {
|
|
|
1497
1494
|
has_access: boolean;
|
|
1498
1495
|
}[];
|
|
1499
1496
|
};
|
|
1497
|
+
cleanup_orphaned_post_images: { Args: never; Returns: undefined };
|
|
1500
1498
|
create_manager: {
|
|
1501
1499
|
Args: {
|
|
1502
1500
|
manager_department?: string;
|
|
@@ -1506,6 +1504,14 @@ export type Database = {
|
|
|
1506
1504
|
};
|
|
1507
1505
|
Returns: string;
|
|
1508
1506
|
};
|
|
1507
|
+
create_newsletter_draft: {
|
|
1508
|
+
Args: { p_profile_id: string };
|
|
1509
|
+
Returns: {
|
|
1510
|
+
id: string;
|
|
1511
|
+
slug: string;
|
|
1512
|
+
title: string;
|
|
1513
|
+
}[];
|
|
1514
|
+
};
|
|
1509
1515
|
create_next_month_partition: { Args: never; Returns: undefined };
|
|
1510
1516
|
custom_access_token_hook: { Args: { event: Json }; Returns: Json };
|
|
1511
1517
|
drop_old_partitions: { Args: never; Returns: undefined };
|
|
@@ -1597,6 +1603,7 @@ export type Database = {
|
|
|
1597
1603
|
p_from?: string;
|
|
1598
1604
|
p_limit?: number;
|
|
1599
1605
|
p_profile_id: string;
|
|
1606
|
+
p_search?: string;
|
|
1600
1607
|
p_status: Database["public"]["Enums"]["post_status_enum"];
|
|
1601
1608
|
p_to?: string;
|
|
1602
1609
|
};
|
|
@@ -1615,6 +1622,7 @@ export type Database = {
|
|
|
1615
1622
|
purchase_count: number;
|
|
1616
1623
|
revenue_total: number;
|
|
1617
1624
|
slug: string;
|
|
1625
|
+
subtitle: string;
|
|
1618
1626
|
tags: string[];
|
|
1619
1627
|
title: string;
|
|
1620
1628
|
updated_at: string;
|
|
@@ -1804,7 +1812,7 @@ export type Database = {
|
|
|
1804
1812
|
| "refunded"
|
|
1805
1813
|
| "reviewing";
|
|
1806
1814
|
payout_provider: "bkash" | "nagad" | "rocket" | "bank";
|
|
1807
|
-
post_status_enum: "draft" | "published" | "archived";
|
|
1815
|
+
post_status_enum: "draft" | "published" | "archived" | "review";
|
|
1808
1816
|
post_version_source_enum:
|
|
1809
1817
|
| "autosave"
|
|
1810
1818
|
| "ai_polish"
|
|
@@ -2054,7 +2062,7 @@ export const Constants = {
|
|
|
2054
2062
|
"reviewing",
|
|
2055
2063
|
],
|
|
2056
2064
|
payout_provider: ["bkash", "nagad", "rocket", "bank"],
|
|
2057
|
-
post_status_enum: ["draft", "published", "archived"],
|
|
2065
|
+
post_status_enum: ["draft", "published", "archived", "review"],
|
|
2058
2066
|
post_version_source_enum: [
|
|
2059
2067
|
"autosave",
|
|
2060
2068
|
"ai_polish",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { formatCount } from "./format-count";
|
|
3
|
+
|
|
4
|
+
describe("formatCount", () => {
|
|
5
|
+
test("formats numbers less than 1000 using formatNumber", () => {
|
|
6
|
+
expect(formatCount(0)).toBe("0");
|
|
7
|
+
expect(formatCount(999)).toBe("999");
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test("formats numbers >= 1000 with k suffix", () => {
|
|
11
|
+
expect(formatCount(1000)).toBe("1k");
|
|
12
|
+
expect(formatCount(2000)).toBe("2k");
|
|
13
|
+
expect(formatCount(10_000)).toBe("10k");
|
|
14
|
+
expect(formatCount(1_000_000)).toBe("1000k");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("shows decimal for non-round thousands", () => {
|
|
18
|
+
expect(formatCount(1500)).toBe("1.5k");
|
|
19
|
+
expect(formatCount(10_500)).toBe("10.5k");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { formatNumber } from "./format-number";
|
|
2
|
+
|
|
3
|
+
export function formatCount(n: number) {
|
|
4
|
+
if (n >= 1000) {
|
|
5
|
+
const formatted = n / 1000;
|
|
6
|
+
return Number.isInteger(formatted)
|
|
7
|
+
? `${formatted}k`
|
|
8
|
+
: `${formatted.toFixed(1)}k`;
|
|
9
|
+
}
|
|
10
|
+
return formatNumber(n);
|
|
11
|
+
}
|