heartraite 1.0.5 → 1.0.8

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.
@@ -0,0 +1,4 @@
1
+ export declare class FirebaseAuthException extends Error {
2
+ code: string;
3
+ constructor(code: string);
4
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FirebaseAuthException = void 0;
4
+ class FirebaseAuthException extends Error {
5
+ constructor(code) {
6
+ super();
7
+ this.code = code;
8
+ this.name = "FirebaseAuthException";
9
+ // Mapping of Firebase error codes to human-readable messages
10
+ const errorMapping = {
11
+ "auth/invalid-email": "The email address is invalid.",
12
+ "auth/email-already-exists": "This email is already in use.",
13
+ "auth/invalid-password": "The password is invalid. Please ensure it meets the requirements.",
14
+ "auth/operation-not-allowed": "Email/password accounts are disabled. Please contact support.",
15
+ "auth/user-not-found": "No user found with the provided credentials.",
16
+ "auth/wrong-password": "The password provided is incorrect.",
17
+ "auth/too-many-requests": "Too many requests have been made. Please try again later.",
18
+ };
19
+ // Set default message for unknown codes
20
+ this.message = errorMapping[code] || "An unexpected error occurred.";
21
+ }
22
+ }
23
+ exports.FirebaseAuthException = FirebaseAuthException;
@@ -0,0 +1 @@
1
+ export * from "./auth.exceptions";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./auth.exceptions"), exports);
@@ -0,0 +1,3 @@
1
+ export type DeepPartial<T> = {
2
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
3
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,6 @@
1
1
  export * from "./assessment.types";
2
2
  export * from "./cloud-function-types";
3
+ export * from "./helper.types";
3
4
  export * from "./like.types";
4
5
  export * from "./match.types";
5
6
  export * from "./message.types";
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./assessment.types"), exports);
18
18
  __exportStar(require("./cloud-function-types"), exports);
19
+ __exportStar(require("./helper.types"), exports);
19
20
  __exportStar(require("./like.types"), exports);
20
21
  __exportStar(require("./match.types"), exports);
21
22
  __exportStar(require("./message.types"), exports);
@@ -1,5 +1,7 @@
1
1
  import { FeedbackAgreement, Gender, LikeType, ReportReason } from "../enum";
2
+ import { DeepPartial } from "./helper.types";
2
3
  import { Answer } from "./submission.types";
4
+ import { DatingPreferences, UserNotifications, UserProfile } from "./user.types";
3
5
  export type RegisterUserRequest = {
4
6
  email: string;
5
7
  password: string;
@@ -105,7 +107,13 @@ export type RegisterOnboardingRequest = {
105
107
  };
106
108
  };
107
109
  export type GetUserRequest = undefined;
108
- export type UpdateUserRequest = Partial<any>;
110
+ export type UpdateUserRequest = {
111
+ profile?: DeepPartial<UserProfile>;
112
+ preferences?: DeepPartial<DatingPreferences>;
113
+ notifications?: DeepPartial<UserNotifications & {
114
+ expoPushToken?: Partial<string>;
115
+ }>;
116
+ };
109
117
  export type AddImagesRequest = {
110
118
  images: string[];
111
119
  };
@@ -4,14 +4,14 @@ export type User = {
4
4
  email: string;
5
5
  created: Date;
6
6
  permissions: UserPermissions;
7
- profile: Profile;
7
+ profile: UserProfile;
8
8
  preferences: DatingPreferences;
9
9
  notifications: UserNotifications;
10
10
  };
11
11
  export type UserPermissions = {
12
12
  registrationReferralAllowed: boolean;
13
13
  };
14
- export type Profile = {
14
+ export type UserProfile = {
15
15
  intro: string;
16
16
  firstName: string;
17
17
  state: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartraite",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
4
4
  "description": "Heartraite npm package for common functionality",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "scripts": {
9
9
  "test": "jest",
10
10
  "build": "tsc",
11
- "prepublishOnly": "npm run build"
11
+ "prepublishOnly": "node version-bump.js && npm run build"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
@@ -28,4 +28,4 @@
28
28
  "typescript": "^5.6.3",
29
29
  "firebase": "^11.0.1"
30
30
  }
31
- }
31
+ }
@@ -0,0 +1,3 @@
1
+ export type DeepPartial<T> = {
2
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
3
+ };
@@ -1,5 +1,6 @@
1
1
  export * from "./assessment.types";
2
2
  export * from "./cloud-function-types";
3
+ export * from "./helper.types";
3
4
  export * from "./like.types";
4
5
  export * from "./match.types";
5
6
  export * from "./message.types";
@@ -1,5 +1,11 @@
1
1
  import { FeedbackAgreement, Gender, LikeType, ReportReason } from "../enum";
2
+ import { DeepPartial } from "./helper.types";
2
3
  import { Answer } from "./submission.types";
4
+ import {
5
+ DatingPreferences,
6
+ UserNotifications,
7
+ UserProfile,
8
+ } from "./user.types";
3
9
 
4
10
  // auth
5
11
  export type RegisterUserRequest = {
@@ -103,7 +109,13 @@ export type RegisterOnboardingRequest = {
103
109
  };
104
110
  };
105
111
  export type GetUserRequest = undefined;
106
- export type UpdateUserRequest = Partial<any>; // TODO; fix typing
112
+ export type UpdateUserRequest = {
113
+ profile?: DeepPartial<UserProfile>;
114
+ preferences?: DeepPartial<DatingPreferences>;
115
+ notifications?: DeepPartial<
116
+ UserNotifications & { expoPushToken?: Partial<string> }
117
+ >;
118
+ };
107
119
 
108
120
  // storage
109
121
  export type AddImagesRequest = { images: string[] };
@@ -5,7 +5,7 @@ export type User = {
5
5
  email: string;
6
6
  created: Date;
7
7
  permissions: UserPermissions;
8
- profile: Profile;
8
+ profile: UserProfile;
9
9
  preferences: DatingPreferences;
10
10
  notifications: UserNotifications;
11
11
  };
@@ -14,7 +14,7 @@ export type UserPermissions = {
14
14
  registrationReferralAllowed: boolean;
15
15
  };
16
16
 
17
- export type Profile = {
17
+ export type UserProfile = {
18
18
  intro: string;
19
19
  firstName: string;
20
20
  state: string;
package/version-bump.js CHANGED
@@ -1,21 +1,65 @@
1
1
  const fs = require("fs");
2
2
  const execSync = require("child_process").execSync;
3
3
 
4
- // Get the current version from package.json
5
- const packageJson = require("./package.json");
6
- const currentVersion = packageJson.version;
4
+ try {
5
+ // Load current version from package.json
6
+ const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
7
+ const currentVersion = packageJson.version;
7
8
 
8
- // Get the latest published version from npm registry
9
- const latestVersion = execSync("npm show heartraite version").toString().trim();
9
+ // Fetch the latest version from the registry
10
+ let latestVersion;
11
+ try {
12
+ latestVersion = execSync("npm show heartraite version", {
13
+ encoding: "utf8",
14
+ }).trim();
15
+ } catch (error) {
16
+ console.warn(
17
+ "Could not fetch latest version from npm. Defaulting to current version."
18
+ );
19
+ latestVersion = currentVersion;
20
+ }
10
21
 
11
- // Increment the version based on the latest version
12
- const versionParts = latestVersion.split(".");
13
- versionParts[2] = (parseInt(versionParts[2]) + 1).toString(); // Increment patch version
14
- const newVersion = versionParts.join(".");
22
+ console.log(`Current version: ${currentVersion}`);
23
+ console.log(`Latest published version: ${latestVersion}`);
15
24
 
16
- packageJson.version = newVersion;
25
+ // Determine the base version to increment
26
+ const baseVersion =
27
+ compareVersions(currentVersion, latestVersion) >= 0
28
+ ? currentVersion
29
+ : latestVersion;
17
30
 
18
- // Update the package.json with the new version
19
- fs.writeFileSync("package.json", JSON.stringify(packageJson, null, 2));
31
+ // Increment the patch version
32
+ const versionParts = baseVersion.split(".");
33
+ versionParts[2] = (parseInt(versionParts[2], 10) + 1).toString();
34
+ const newVersion = versionParts.join(".");
20
35
 
21
- console.log(`Version bumped from ${currentVersion} to ${newVersion}`);
36
+ if (newVersion === currentVersion) {
37
+ console.log("Version is already up-to-date. No changes made.");
38
+ process.exit(0);
39
+ }
40
+
41
+ // Update package.json with the new version
42
+ packageJson.version = newVersion;
43
+ fs.writeFileSync(
44
+ "package.json",
45
+ JSON.stringify(packageJson, null, 2) + "\n",
46
+ "utf8"
47
+ );
48
+
49
+ console.log(`Version bumped from ${currentVersion} to ${newVersion}`);
50
+ } catch (error) {
51
+ console.error("Error bumping version:", error.message);
52
+ process.exit(1);
53
+ }
54
+
55
+ // Compare two version strings (semver)
56
+ function compareVersions(v1, v2) {
57
+ const parts1 = v1.split(".").map(Number);
58
+ const parts2 = v2.split(".").map(Number);
59
+
60
+ for (let i = 0; i < parts1.length; i++) {
61
+ if (parts1[i] > parts2[i]) return 1;
62
+ if (parts1[i] < parts2[i]) return -1;
63
+ }
64
+ return 0;
65
+ }