@phygitallabs/tapquest-core 6.7.0 → 6.7.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phygitallabs/tapquest-core",
3
- "version": "6.7.0",
3
+ "version": "6.7.2",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -55,7 +55,7 @@ const getActionsFromAchievementRule = (achievement: Achievement) => {
55
55
  if (!ruleList?.rules) return;
56
56
  ruleList?.rules?.forEach((rule) => {
57
57
  if (rule?.action) {
58
- actions.push(rule?.action)
58
+ actions.push(rule?.action);
59
59
  }
60
60
  });
61
61
  });
@@ -64,7 +64,7 @@ const getActionsFromAchievementRule = (achievement: Achievement) => {
64
64
 
65
65
  const isAchievementCompleted = (achievement: UserAchievementProgress) => {
66
66
  return achievement.isCompleted || achievement.overallPercentage === 100;
67
- }
67
+ };
68
68
 
69
69
  type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}`
70
70
  ? `${T}${Capitalize<SnakeToCamelCase<U>>}`
@@ -73,53 +73,44 @@ type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}`
73
73
  type ConvertSnakeToCamel<T> = T extends (infer U)[]
74
74
  ? ConvertSnakeToCamel<U>[]
75
75
  : T extends Record<string, unknown>
76
- ? {
77
- [K in keyof T as K extends string
78
- ? SnakeToCamelCase<K>
79
- : K]: ConvertSnakeToCamel<T[K]>;
80
- }
81
- : T;
76
+ ? {
77
+ [K in keyof T as K extends string ? SnakeToCamelCase<K> : K]: ConvertSnakeToCamel<T[K]>;
78
+ }
79
+ : T;
82
80
 
83
81
  /**
84
82
  * Converts snake_case keys to camelCase keys in an object or array of objects
85
83
  */
86
84
  export function convertSnakeToCamel<T>(obj: T): ConvertSnakeToCamel<T> {
87
- if (obj === null || obj === undefined) {
88
- return obj as ConvertSnakeToCamel<T>;
89
- }
90
-
91
- if (Array.isArray(obj)) {
92
- return obj.map((item) =>
93
- convertSnakeToCamel(item)
94
- ) as ConvertSnakeToCamel<T>;
95
- }
96
-
97
- if (typeof obj === "object" && obj.constructor === Object) {
98
- const converted: Record<string, unknown> = {};
99
-
100
- for (const key in obj) {
101
- if (obj.hasOwnProperty(key)) {
102
- const camelKey = key.replace(/_([a-z])/g, (_, letter) =>
103
- letter.toUpperCase()
104
- );
105
- converted[camelKey] = convertSnakeToCamel(
106
- (obj as Record<string, unknown>)[key]
107
- );
108
- }
85
+ if (obj === null || obj === undefined) {
86
+ return obj as ConvertSnakeToCamel<T>;
87
+ }
88
+
89
+ if (Array.isArray(obj)) {
90
+ return obj.map((item) => convertSnakeToCamel(item)) as ConvertSnakeToCamel<T>;
91
+ }
92
+
93
+ if (typeof obj === "object" && obj.constructor === Object) {
94
+ const converted: Record<string, unknown> = {};
95
+
96
+ for (const key in obj) {
97
+ if (obj.hasOwnProperty(key)) {
98
+ const camelKey = key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
99
+ converted[camelKey] = convertSnakeToCamel((obj as Record<string, unknown>)[key]);
109
100
  }
110
-
111
- return converted as ConvertSnakeToCamel<T>;
112
101
  }
113
-
114
- return obj as ConvertSnakeToCamel<T>;
102
+
103
+ return converted as ConvertSnakeToCamel<T>;
115
104
  }
116
-
105
+
106
+ return obj as ConvertSnakeToCamel<T>;
107
+ }
117
108
 
118
109
  export {
119
110
  getLocationIdsFromAchievementRule,
120
111
  getActionsFromAchievementRule,
121
112
  getSurveyIdsFromAchievementRule,
122
- isAchievementCompleted
123
- }
113
+ isAchievementCompleted,
114
+ };
124
115
 
125
- export { useClearAchievementProgressCache } from './useClearAchievementProgressCache';
116
+ export { useClearAchievementProgressCache } from "./useClearAchievementProgressCache";
@@ -5,10 +5,7 @@ export function useClearAchievementProgressCache() {
5
5
  const queryClient = useQueryClient();
6
6
 
7
7
  const clearCache = useCallback(
8
- (options?: {
9
- refetchActive?: boolean;
10
- refetchInactive?: boolean;
11
- }) => {
8
+ (options?: { refetchActive?: boolean; refetchInactive?: boolean }) => {
12
9
  const { refetchActive = true, refetchInactive = false } = options || {};
13
10
 
14
11
  // Clear all achievement progress related queries using predicate
@@ -21,16 +18,12 @@ export function useClearAchievementProgressCache() {
21
18
  predicate: (query) => {
22
19
  const queryKey = query.queryKey as string[];
23
20
  return (
24
- queryKey.includes("achievementProgressMany") || // For logged in users
25
- queryKey.includes("achievementProgress") || // For device UID (api-core)
21
+ queryKey.includes("achievementProgressMany") || // For logged in users
22
+ queryKey.includes("achievementProgress") || // For device UID (api-core)
26
23
  queryKey.includes("deviceUidAchievementProgressMany") // For device UID (achievement pkg)
27
24
  );
28
25
  },
29
- refetchType: refetchActive
30
- ? refetchInactive
31
- ? "all"
32
- : "active"
33
- : "none",
26
+ refetchType: refetchActive ? (refetchInactive ? "all" : "active") : "none",
34
27
  });
35
28
 
36
29
  console.log("🔄 Achievement progress cache cleared");
@@ -1,17 +1,7 @@
1
- import {
2
- createContext,
3
- useContext,
4
- useEffect,
5
- useMemo,
6
- useCallback,
7
- useRef,
8
- } from "react";
1
+ import { createContext, useContext, useEffect, useMemo, useCallback, useRef } from "react";
9
2
  import { useDataTracking } from "../../data-tracking";
10
3
  import { useNotificationStore } from "../../notification";
11
- import {
12
- getActionsFromAchievementRule,
13
- AchievementType,
14
- } from "../../achievement";
4
+ import { getActionsFromAchievementRule, AchievementType } from "../../achievement";
15
5
  import type {
16
6
  AchievementTrackingContextValue,
17
7
  AchievementTrackingProviderProps,
@@ -19,9 +9,9 @@ import type {
19
9
  } from "../types";
20
10
  import type { Achievement } from "../../achievement/types";
21
11
 
22
- const AchievementTrackingContext = createContext<
23
- AchievementTrackingContextValue | undefined
24
- >(undefined);
12
+ const AchievementTrackingContext = createContext<AchievementTrackingContextValue | undefined>(
13
+ undefined
14
+ );
25
15
 
26
16
  export function AchievementTrackingProvider({
27
17
  children,
@@ -50,7 +40,6 @@ export function AchievementTrackingProvider({
50
40
 
51
41
  useEffect(() => {
52
42
  const unsubscribe = useNotificationStore.subscribe((state) => {
53
-
54
43
  const notifications = state.notifications;
55
44
  if (notifications.length === 0) return;
56
45
 
@@ -96,9 +85,7 @@ export function AchievementTrackingProvider({
96
85
  });
97
86
 
98
87
  if (matchingAchievements.length === 0) {
99
- console.error(
100
- `[AchievementTracking] No achievement found for action: ${actionType}`
101
- );
88
+ console.error(`[AchievementTracking] No achievement found for action: ${actionType}`);
102
89
  return;
103
90
  }
104
91
 
@@ -145,9 +132,7 @@ export function AchievementTrackingProvider({
145
132
  export function useAchievementTracking(): AchievementTrackingContextValue {
146
133
  const context = useContext(AchievementTrackingContext);
147
134
  if (!context) {
148
- throw new Error(
149
- "useAchievementTracking must be used within AchievementTrackingProvider"
150
- );
135
+ throw new Error("useAchievementTracking must be used within AchievementTrackingProvider");
151
136
  }
152
137
  return context;
153
138
  }
package/tsup.config.ts CHANGED
@@ -8,6 +8,7 @@ export default defineConfig((options: Options) => ({
8
8
  },
9
9
  format: ["esm", "cjs"],
10
10
  outExtension: ({ format }) => ({ js: format === "cjs" ? ".cjs" : ".js" }),
11
+ target: "es2019", // Transpile optional chaining (?.) and nullish coalescing (??) for CJS Node.js SSR compatibility
11
12
  dts: true,
12
13
  clean: true,
13
14
  external: [