heartraite 1.0.86 → 1.0.88

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.
@@ -2,7 +2,7 @@ import { AdvancedMatch } from "./am.types";
2
2
  import { MatchCompatibility } from "./matchmaking.types";
3
3
  export type Match = {
4
4
  id: string;
5
- users: Record<string, boolean>;
5
+ users: string[];
6
6
  created: string;
7
7
  initiatedBy: string;
8
8
  conversationId: string;
@@ -16,5 +16,5 @@ export type UserMatch = {
16
16
  created: string;
17
17
  conversationId: string;
18
18
  initiatedBy: string;
19
- users: Record<string, boolean>;
19
+ users: string[];
20
20
  };
@@ -14,16 +14,14 @@ export type Conversation = {
14
14
  lastMessageSeen: string;
15
15
  latestMessageTimestamp?: string;
16
16
  messages: Record<string, Message>;
17
- members: Record<string, boolean>;
17
+ members: string[];
18
18
  };
19
19
  export type DBConversation = {
20
20
  id: string;
21
21
  created: string;
22
22
  latestMessage: string;
23
23
  latestMessageTimestamp?: string;
24
- members: {
25
- [id: string]: boolean;
26
- };
24
+ members: string[];
27
25
  };
28
26
  export type UserConversation = Omit<DBConversation, "latestMessage" | "latestMessageTimestamp"> & {
29
27
  lastMessageSeen: string;
@@ -0,0 +1,3 @@
1
+ type SupportedLocale = "sv-SE" | "en-US" | "sv_SE" | "en_US";
2
+ export declare const formatDate: (isoDate?: string | null, locale?: SupportedLocale) => string;
3
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatDate = void 0;
4
+ const normalizeLocale = (locale) => {
5
+ return locale.replace("_", "-"); // Convert sv_SE → sv-SE
6
+ };
7
+ const formatDate = (isoDate, locale = "en-US") => {
8
+ if (!isoDate)
9
+ return "";
10
+ try {
11
+ const normalizedLocale = normalizeLocale(locale);
12
+ return new Intl.DateTimeFormat(normalizedLocale, {
13
+ year: "numeric",
14
+ month: "long",
15
+ day: "numeric",
16
+ }).format(new Date(isoDate));
17
+ }
18
+ catch (e) {
19
+ console.warn("Invalid locale or date:", e);
20
+ return isoDate;
21
+ }
22
+ };
23
+ exports.formatDate = formatDate;
@@ -1,2 +1,3 @@
1
1
  export * from "./time-label.util";
2
2
  export * from "./age.util";
3
+ export * from "./date-label.util";
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./time-label.util"), exports);
18
18
  __exportStar(require("./age.util"), exports);
19
+ __exportStar(require("./date-label.util"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartraite",
3
- "version": "1.0.86",
3
+ "version": "1.0.88",
4
4
  "description": "Heartraite npm package for common functionality",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -3,7 +3,7 @@ import { MatchCompatibility } from "./matchmaking.types";
3
3
 
4
4
  export type Match = {
5
5
  id: string;
6
- users: Record<string, boolean>;
6
+ users: string[];
7
7
  created: string;
8
8
  initiatedBy: string;
9
9
  conversationId: string;
@@ -18,5 +18,5 @@ export type UserMatch = {
18
18
  created: string;
19
19
  conversationId: string;
20
20
  initiatedBy: string;
21
- users: Record<string, boolean>;
21
+ users: string[];
22
22
  };
@@ -15,7 +15,7 @@ export type Conversation = {
15
15
  lastMessageSeen: string;
16
16
  latestMessageTimestamp?: string;
17
17
  messages: Record<string, Message>;
18
- members: Record<string, boolean>;
18
+ members: string[];
19
19
  };
20
20
 
21
21
  export type DBConversation = {
@@ -23,7 +23,7 @@ export type DBConversation = {
23
23
  created: string;
24
24
  latestMessage: string;
25
25
  latestMessageTimestamp?: string;
26
- members: { [id: string]: boolean };
26
+ members: string[];
27
27
  };
28
28
 
29
29
  export type UserConversation = Omit<
@@ -0,0 +1,24 @@
1
+ type SupportedLocale = "sv-SE" | "en-US" | "sv_SE" | "en_US";
2
+
3
+ const normalizeLocale = (locale: SupportedLocale): string => {
4
+ return locale.replace("_", "-"); // Convert sv_SE → sv-SE
5
+ };
6
+
7
+ export const formatDate = (
8
+ isoDate?: string | null,
9
+ locale: SupportedLocale = "en-US"
10
+ ) => {
11
+ if (!isoDate) return "";
12
+
13
+ try {
14
+ const normalizedLocale = normalizeLocale(locale);
15
+ return new Intl.DateTimeFormat(normalizedLocale, {
16
+ year: "numeric",
17
+ month: "long",
18
+ day: "numeric",
19
+ }).format(new Date(isoDate));
20
+ } catch (e) {
21
+ console.warn("Invalid locale or date:", e);
22
+ return isoDate;
23
+ }
24
+ };
@@ -1,2 +1,3 @@
1
1
  export * from "./time-label.util";
2
2
  export * from "./age.util";
3
+ export * from "./date-label.util";