@myrjfa/state 3.0.8 → 3.0.10
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/lib/actions/application.d.ts +5 -3
- package/dist/lib/actions/application.d.ts.map +1 -1
- package/dist/lib/actions/application.js +45 -2
- package/dist/lib/actions/auth.d.ts +20 -3
- package/dist/lib/actions/auth.d.ts.map +1 -1
- package/dist/lib/actions/auth.js +31 -0
- package/dist/lib/actions/blog.d.ts.map +1 -1
- package/dist/lib/actions/blog.js +3 -2
- package/dist/lib/actions/booking.d.ts +29 -1
- package/dist/lib/actions/booking.d.ts.map +1 -1
- package/dist/lib/actions/booking.js +186 -0
- package/dist/lib/actions/brand.d.ts +7 -0
- package/dist/lib/actions/brand.d.ts.map +1 -1
- package/dist/lib/actions/brand.js +4 -0
- package/dist/lib/actions/chat.d.ts +3 -0
- package/dist/lib/actions/chat.d.ts.map +1 -1
- package/dist/lib/actions/chat.js +40 -1
- package/dist/lib/actions/community.d.ts +2 -1
- package/dist/lib/actions/community.d.ts.map +1 -1
- package/dist/lib/actions/community.js +10 -4
- package/dist/lib/actions/companion.d.ts +13 -7
- package/dist/lib/actions/companion.d.ts.map +1 -1
- package/dist/lib/actions/companion.js +6 -4
- package/dist/lib/actions/companionUpload.d.ts +2 -1
- package/dist/lib/actions/companionUpload.d.ts.map +1 -1
- package/dist/lib/actions/companionUpload.js +2 -1
- package/dist/lib/actions/event.d.ts +1 -1
- package/dist/lib/actions/event.d.ts.map +1 -1
- package/dist/lib/actions/event.js +5 -2
- package/dist/lib/actions/fetcher.d.ts +7 -1
- package/dist/lib/actions/fetcher.d.ts.map +1 -1
- package/dist/lib/actions/fetcher.js +82 -62
- package/dist/lib/actions/guide.js +1 -0
- package/dist/lib/actions/homeBanner.d.ts +8 -0
- package/dist/lib/actions/homeBanner.d.ts.map +1 -0
- package/dist/lib/actions/homeBanner.js +33 -0
- package/dist/lib/actions/hostDashboard.d.ts +1 -11
- package/dist/lib/actions/hostDashboard.d.ts.map +1 -1
- package/dist/lib/actions/hostDashboard.js +1 -146
- package/dist/lib/actions/itinerary.d.ts +1 -1
- package/dist/lib/actions/itinerary.d.ts.map +1 -1
- package/dist/lib/actions/itinerary.js +2 -2
- package/dist/lib/actions/listingInterest.d.ts +2 -5
- package/dist/lib/actions/listingInterest.d.ts.map +1 -1
- package/dist/lib/actions/listingInterest.js +18 -3
- package/dist/lib/actions/location.d.ts +4 -0
- package/dist/lib/actions/location.d.ts.map +1 -1
- package/dist/lib/actions/location.js +10 -6
- package/dist/lib/actions/marketplaceContract.d.ts.map +1 -1
- package/dist/lib/actions/marketplaceContract.js +3 -2
- package/dist/lib/actions/nativeTransport.d.ts +25 -0
- package/dist/lib/actions/nativeTransport.d.ts.map +1 -0
- package/dist/lib/actions/nativeTransport.js +50 -0
- package/dist/lib/actions/notification.d.ts +3 -3
- package/dist/lib/actions/package.d.ts +5 -3
- package/dist/lib/actions/package.d.ts.map +1 -1
- package/dist/lib/actions/package.js +11 -6
- package/dist/lib/actions/profile.d.ts +5 -0
- package/dist/lib/actions/profile.d.ts.map +1 -1
- package/dist/lib/actions/profile.js +12 -0
- package/dist/lib/actions/review.d.ts +7 -0
- package/dist/lib/actions/review.d.ts.map +1 -1
- package/dist/lib/actions/review.js +64 -31
- package/dist/lib/actions/serverActions.d.ts.map +1 -1
- package/dist/lib/actions/serverActions.js +3 -2
- package/dist/lib/actions/serverActions.native.d.ts +4 -0
- package/dist/lib/actions/serverActions.native.d.ts.map +1 -0
- package/dist/lib/actions/serverActions.native.js +5 -0
- package/dist/lib/actions/socket.d.ts.map +1 -1
- package/dist/lib/actions/socket.js +6 -5
- package/dist/lib/actions/stay.d.ts +14 -1
- package/dist/lib/actions/stay.d.ts.map +1 -1
- package/dist/lib/actions/stay.js +29 -2
- package/dist/lib/actions/store.d.ts +1 -0
- package/dist/lib/actions/store.d.ts.map +1 -1
- package/dist/lib/actions/store.js +9 -0
- package/dist/lib/actions/user.d.ts +2 -0
- package/dist/lib/actions/user.d.ts.map +1 -1
- package/dist/lib/actions/user.js +5 -0
- package/dist/lib/authSessionManager.d.ts.map +1 -1
- package/dist/lib/authSessionManager.js +42 -39
- package/dist/lib/authSessionPolicy.d.ts +2 -0
- package/dist/lib/authSessionPolicy.d.ts.map +1 -1
- package/dist/lib/authSessionPolicy.js +3 -1
- package/dist/lib/data/catalogueLocations.d.ts +3 -0
- package/dist/lib/data/catalogueLocations.d.ts.map +1 -0
- package/dist/lib/data/catalogueLocations.js +21 -0
- package/dist/lib/data/skills.d.ts +5 -0
- package/dist/lib/data/skills.d.ts.map +1 -0
- package/dist/lib/data/skills.js +97 -0
- package/dist/lib/forms/application.d.ts +4 -0
- package/dist/lib/forms/application.d.ts.map +1 -0
- package/dist/lib/forms/application.js +17 -0
- package/dist/lib/forms/packageEnquiry.d.ts +4 -0
- package/dist/lib/forms/packageEnquiry.d.ts.map +1 -0
- package/dist/lib/forms/packageEnquiry.js +12 -0
- package/dist/lib/forms/review.d.ts +6 -0
- package/dist/lib/forms/review.d.ts.map +1 -0
- package/dist/lib/forms/review.js +20 -0
- package/dist/lib/models/application.d.ts +21 -0
- package/dist/lib/models/application.d.ts.map +1 -1
- package/dist/lib/models/authorization.d.ts +1 -1
- package/dist/lib/models/authorization.d.ts.map +1 -1
- package/dist/lib/models/authorization.js +2 -0
- package/dist/lib/models/booking.d.ts +3 -0
- package/dist/lib/models/booking.d.ts.map +1 -1
- package/dist/lib/models/chat.d.ts +8 -0
- package/dist/lib/models/chat.d.ts.map +1 -1
- package/dist/lib/models/chat.js +10 -0
- package/dist/lib/models/community.d.ts +2 -0
- package/dist/lib/models/community.d.ts.map +1 -1
- package/dist/lib/models/community.js +2 -1
- package/dist/lib/models/companion.d.ts +42 -0
- package/dist/lib/models/companion.d.ts.map +1 -1
- package/dist/lib/models/discount.d.ts +8 -8
- package/dist/lib/models/enquiry.d.ts +13 -0
- package/dist/lib/models/enquiry.d.ts.map +1 -1
- package/dist/lib/models/homeBanner.d.ts +17 -0
- package/dist/lib/models/homeBanner.d.ts.map +1 -0
- package/dist/lib/models/homeBanner.js +1 -0
- package/dist/lib/models/interest.d.ts +42 -0
- package/dist/lib/models/interest.d.ts.map +1 -0
- package/dist/lib/models/interest.js +1 -0
- package/dist/lib/models/location.d.ts +1 -0
- package/dist/lib/models/location.d.ts.map +1 -1
- package/dist/lib/models/notifications.d.ts +2 -2
- package/dist/lib/models/opportunities/freelance.d.ts +37 -4
- package/dist/lib/models/opportunities/freelance.d.ts.map +1 -1
- package/dist/lib/models/opportunities/internship.d.ts +37 -4
- package/dist/lib/models/opportunities/internship.d.ts.map +1 -1
- package/dist/lib/models/opportunities/job.d.ts +37 -4
- package/dist/lib/models/opportunities/job.d.ts.map +1 -1
- package/dist/lib/models/opportunities/opportunity.d.ts +38 -5
- package/dist/lib/models/opportunities/opportunity.d.ts.map +1 -1
- package/dist/lib/models/opportunities/opportunity.js +1 -1
- package/dist/lib/models/opportunities/volunteerJob.d.ts +37 -4
- package/dist/lib/models/opportunities/volunteerJob.d.ts.map +1 -1
- package/dist/lib/models/pricing.d.ts +2 -0
- package/dist/lib/models/pricing.d.ts.map +1 -1
- package/dist/lib/models/pricing.js +4 -0
- package/dist/lib/models/props.d.ts +4 -43
- package/dist/lib/models/props.d.ts.map +1 -1
- package/dist/lib/models/props.js +3 -121
- package/dist/lib/models/question.d.ts +14 -0
- package/dist/lib/models/question.d.ts.map +1 -0
- package/dist/lib/models/question.js +6 -0
- package/dist/lib/models/review.d.ts +13 -1
- package/dist/lib/models/review.d.ts.map +1 -1
- package/dist/lib/models/review.js +4 -0
- package/dist/lib/models/tile.d.ts +7 -1
- package/dist/lib/models/tile.d.ts.map +1 -1
- package/dist/lib/models/travelPackage.d.ts +37 -4
- package/dist/lib/models/travelPackage.d.ts.map +1 -1
- package/dist/lib/models/travelPackage.js +1 -1
- package/dist/lib/models/user.d.ts +25 -2
- package/dist/lib/models/user.d.ts.map +1 -1
- package/dist/lib/models/user.js +1 -0
- package/dist/lib/userAtom.d.ts +30 -5
- package/dist/lib/userAtom.d.ts.map +1 -1
- package/dist/lib/userAtom.js +16 -25
- package/dist/lib/utils/authCookies.d.ts +3 -0
- package/dist/lib/utils/authCookies.d.ts.map +1 -0
- package/dist/lib/utils/authCookies.js +4 -0
- package/dist/lib/utils/entityTiles.d.ts.map +1 -1
- package/dist/lib/utils/entityTiles.js +3 -2
- package/dist/lib/utils/htmlDescription.d.ts +3 -0
- package/dist/lib/utils/htmlDescription.d.ts.map +1 -0
- package/dist/lib/utils/htmlDescription.js +7 -0
- package/dist/lib/utils/htmlDescription.native.d.ts +3 -0
- package/dist/lib/utils/htmlDescription.native.d.ts.map +1 -0
- package/dist/lib/utils/htmlDescription.native.js +7 -0
- package/dist/lib/utils/text.d.ts +3 -1
- package/dist/lib/utils/text.d.ts.map +1 -1
- package/dist/lib/utils/text.js +5 -6
- package/dist/lib/utils/uploadFile.d.ts +9 -0
- package/dist/lib/utils/uploadFile.d.ts.map +1 -0
- package/dist/lib/utils/uploadFile.js +9 -0
- package/dist/lib/utils/uploadTasks.d.ts.map +1 -1
- package/dist/lib/utils/uploadTasks.js +9 -1
- package/package.json +1 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCookieHeader } from "./serverActions";
|
|
2
2
|
import { normalizeRefreshFailureStatus } from "../authSessionPolicy";
|
|
3
|
+
import { acceptNativeSession, getNativeTransport, nativeSessionGeneration } from "./nativeTransport";
|
|
3
4
|
// Custom API error class — do NOT import from next/dist internals
|
|
4
5
|
class ApiError extends Error {
|
|
5
6
|
constructor(statusCode, message, data) {
|
|
@@ -20,7 +21,7 @@ function uploadWithProgress(url, init, onProgress) {
|
|
|
20
21
|
}
|
|
21
22
|
const request = new XMLHttpRequest();
|
|
22
23
|
request.open(init.method || 'POST', url);
|
|
23
|
-
request.withCredentials =
|
|
24
|
+
request.withCredentials = init.credentials === 'include';
|
|
24
25
|
new Headers(init.headers).forEach((value, key) => request.setRequestHeader(key, value));
|
|
25
26
|
const abort = () => request.abort();
|
|
26
27
|
const cleanup = () => {
|
|
@@ -50,7 +51,7 @@ function uploadWithProgress(url, init, onProgress) {
|
|
|
50
51
|
* Survives browser sessions (unlike cookies which can expire/be cleared).
|
|
51
52
|
* Generated once per browser using crypto.randomUUID().
|
|
52
53
|
*/
|
|
53
|
-
function getOrCreateDeviceId() {
|
|
54
|
+
export function getOrCreateDeviceId() {
|
|
54
55
|
if (typeof window === 'undefined')
|
|
55
56
|
return null; // SSR guard
|
|
56
57
|
try {
|
|
@@ -67,22 +68,33 @@ function getOrCreateDeviceId() {
|
|
|
67
68
|
}
|
|
68
69
|
async function customFetch(input, method, body, options = {}) {
|
|
69
70
|
const { includeAuth = false, retry = true, signal, keepalive } = options;
|
|
70
|
-
const
|
|
71
|
+
const native = getNativeTransport();
|
|
72
|
+
const nativeEpoch = nativeSessionGeneration();
|
|
73
|
+
if (!native && !baseURL)
|
|
74
|
+
throw new ApiError(503, 'API configuration is missing');
|
|
75
|
+
const url = `${native?.apiUrl.replace(/\/$/, '') ?? baseURL}${input}`;
|
|
71
76
|
const isFormData = typeof FormData !== 'undefined' && body instanceof FormData;
|
|
72
77
|
let headers = isFormData
|
|
73
78
|
? { Accept: 'application/json' }
|
|
74
79
|
: { 'Content-Type': 'application/json', Accept: 'application/json' };
|
|
75
80
|
// #2: Attach stable device ID so backend can correctly identify the same browser
|
|
76
|
-
const deviceId = getOrCreateDeviceId();
|
|
81
|
+
const deviceId = native?.deviceId ?? getOrCreateDeviceId();
|
|
77
82
|
if (deviceId) {
|
|
78
83
|
headers['X-Device-Id'] = deviceId;
|
|
79
84
|
}
|
|
80
85
|
headers = { ...headers, ...(options.headers || {}) };
|
|
86
|
+
if (native) {
|
|
87
|
+
const token = includeAuth ? native.accessToken() : null;
|
|
88
|
+
if (token || /^\/users\/(login|verify-otp|refresh-token)(?:$|\?)/.test(input))
|
|
89
|
+
headers = { ...headers, 'X-Trippeaze-Client': 'native' };
|
|
90
|
+
if (token)
|
|
91
|
+
headers = { ...headers, Authorization: `Bearer ${token}` };
|
|
92
|
+
}
|
|
81
93
|
// Browsers attach HTTP-only cookies through credentials. Calling a Next
|
|
82
94
|
// server action here creates an avoidable production-only RSC round trip
|
|
83
95
|
// and can block the actual REST request. Explicit Cookie forwarding is
|
|
84
96
|
// needed only for fetches executing on the server.
|
|
85
|
-
if (includeAuth && typeof window === 'undefined') {
|
|
97
|
+
if (!native && includeAuth && typeof window === 'undefined') {
|
|
86
98
|
try {
|
|
87
99
|
const cookieHeader = await getCookieHeader();
|
|
88
100
|
headers = { ...headers, Cookie: cookieHeader };
|
|
@@ -97,17 +109,22 @@ async function customFetch(input, method, body, options = {}) {
|
|
|
97
109
|
}
|
|
98
110
|
const init = {
|
|
99
111
|
method,
|
|
100
|
-
credentials: includeAuth ? 'include' : 'omit',
|
|
112
|
+
credentials: !native && includeAuth ? 'include' : 'omit',
|
|
101
113
|
headers,
|
|
102
114
|
signal,
|
|
103
115
|
keepalive,
|
|
104
116
|
...(body ? { body: isFormData ? body : JSON.stringify(body) } : {}),
|
|
105
117
|
};
|
|
106
|
-
const response = options.onUploadProgress && isFormData && includeAuth && typeof window !== 'undefined'
|
|
118
|
+
const response = options.onUploadProgress && isFormData && includeAuth && (native || typeof window !== 'undefined')
|
|
107
119
|
? await uploadWithProgress(url, init, options.onUploadProgress)
|
|
108
120
|
: await fetch(url, init);
|
|
121
|
+
if (native && (getNativeTransport() !== native || nativeEpoch !== nativeSessionGeneration()))
|
|
122
|
+
throw new ApiError(401, 'The account changed. Return to your draft before continuing.');
|
|
109
123
|
if (response.ok) {
|
|
110
|
-
|
|
124
|
+
const result = response.status !== 204 ? (await response.json()) : {};
|
|
125
|
+
if (native && (getNativeTransport() !== native || nativeEpoch !== nativeSessionGeneration()))
|
|
126
|
+
throw new ApiError(401, 'The account changed. Return to your draft before continuing.');
|
|
127
|
+
return result;
|
|
111
128
|
}
|
|
112
129
|
// Token refresh logic on 401 (only for authenticated requests)
|
|
113
130
|
if (response.status === 401 && retry && includeAuth && !input.includes('/login')) {
|
|
@@ -124,71 +141,74 @@ async function customFetch(input, method, body, options = {}) {
|
|
|
124
141
|
error: typeof error === 'string' ? error : 'Unknown error',
|
|
125
142
|
};
|
|
126
143
|
}
|
|
127
|
-
throw new ApiError(errorBody.statusCode, errorBody.error
|
|
144
|
+
throw new ApiError(errorBody.statusCode || response.status, errorBody.error || errorBody.message || `Request failed (${response.status})`, errorBody.data);
|
|
128
145
|
}
|
|
129
146
|
// Single in-flight refresh promise — prevents concurrent 401s from firing multiple refresh calls
|
|
130
147
|
let refreshPromise = null;
|
|
131
148
|
// Token refresh function — internal only, not exported
|
|
132
149
|
async function refreshToken(input, method, body, options = {}) {
|
|
133
|
-
|
|
134
|
-
if (
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
// CSR or static context — credentials:'include' handles cookie forwarding to backend
|
|
158
|
-
}
|
|
159
|
-
const response = await fetch(`${baseURL}${refreshEndpoint}`, {
|
|
160
|
-
method: 'POST',
|
|
161
|
-
credentials: 'include',
|
|
162
|
-
headers: refreshHeaders,
|
|
163
|
-
});
|
|
164
|
-
if (!response.ok) {
|
|
165
|
-
const data = await response.json();
|
|
166
|
-
// A rejected refresh means this browser no longer has a usable
|
|
167
|
-
// session, regardless of whether validation/auth middleware
|
|
168
|
-
// returned 400, 401, 403, or 422. Normalize client-side refresh
|
|
169
|
-
// failures to 401 so expected signed-out initialization stays
|
|
170
|
-
// quiet instead of surfacing as a Next.js error overlay.
|
|
171
|
-
const statusCode = normalizeRefreshFailureStatus(response.status);
|
|
172
|
-
throw { statusCode, error: data.error || data.message || 'Session expired' };
|
|
173
|
-
}
|
|
174
|
-
})().finally(() => { refreshPromise = null; });
|
|
175
|
-
}
|
|
176
|
-
try {
|
|
150
|
+
const native = getNativeTransport();
|
|
151
|
+
if (native) {
|
|
152
|
+
const generation = nativeSessionGeneration();
|
|
153
|
+
if (!refreshPromise)
|
|
154
|
+
refreshPromise = (async () => {
|
|
155
|
+
const refresh = await native.refreshToken();
|
|
156
|
+
if (!refresh)
|
|
157
|
+
throw new ApiError(401, 'Please sign in again');
|
|
158
|
+
const response = await fetch(`${native.apiUrl.replace(/\/$/, '')}/users/refresh-token`, {
|
|
159
|
+
method: 'POST', credentials: 'omit',
|
|
160
|
+
headers: { 'Content-Type': 'application/json', 'X-Device-Id': native.deviceId, 'X-Trippeaze-Client': 'native' },
|
|
161
|
+
body: JSON.stringify({ refreshToken: refresh }),
|
|
162
|
+
});
|
|
163
|
+
const payload = await response.json();
|
|
164
|
+
if (generation !== nativeSessionGeneration())
|
|
165
|
+
throw new ApiError(401, 'Session changed');
|
|
166
|
+
if (!response.ok) {
|
|
167
|
+
if ([400, 401, 403, 422].includes(response.status))
|
|
168
|
+
await native.clearSession();
|
|
169
|
+
throw new ApiError(normalizeRefreshFailureStatus(response.status), payload.error || 'Session expired');
|
|
170
|
+
}
|
|
171
|
+
await acceptNativeSession(payload.data?.session, generation);
|
|
172
|
+
})().finally(() => { refreshPromise = null; });
|
|
177
173
|
await refreshPromise;
|
|
174
|
+
if (generation !== nativeSessionGeneration())
|
|
175
|
+
throw new ApiError(401, 'Session changed');
|
|
178
176
|
return customFetch(input, method, body, { ...options, includeAuth: true, retry: false });
|
|
179
177
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
// Rendering cannot reliably deliver Set-Cookie. Browser bootstrap owns
|
|
179
|
+
// rotation; server requests must never consume its refresh credential.
|
|
180
|
+
if (typeof window === "undefined")
|
|
181
|
+
throw new ApiError(401, 'Browser session requires client refresh');
|
|
182
|
+
const refresh = async () => {
|
|
183
|
+
const deviceId = getOrCreateDeviceId();
|
|
184
|
+
const response = await fetch(`${baseURL}/auth/session/refresh`, {
|
|
185
|
+
// Rotation consumes the old credential. Let the browser receive
|
|
186
|
+
// replacement cookies even if this document navigates away.
|
|
187
|
+
method: 'POST', credentials: 'include', keepalive: true,
|
|
188
|
+
headers: deviceId ? { 'X-Device-Id': deviceId } : {},
|
|
189
|
+
});
|
|
190
|
+
if (!response.ok) {
|
|
191
|
+
const data = await response.json();
|
|
192
|
+
throw new ApiError(normalizeRefreshFailureStatus(response.status), data.error || data.message || 'Session expired');
|
|
185
193
|
}
|
|
186
|
-
|
|
194
|
+
};
|
|
195
|
+
if (!refreshPromise) {
|
|
196
|
+
const locks = typeof navigator !== 'undefined' ? navigator.locks : undefined;
|
|
197
|
+
refreshPromise = (locks ? locks.request(`trippeaze-refresh:${baseURL}`, async () => {
|
|
198
|
+
const probe = await fetch(`${baseURL}/auth/session`, { credentials: 'include' });
|
|
199
|
+
if (probe.ok)
|
|
200
|
+
return;
|
|
201
|
+
if (probe.status !== 401)
|
|
202
|
+
throw new ApiError(probe.status, 'Session validation temporarily unavailable');
|
|
203
|
+
await refresh();
|
|
204
|
+
}) : refresh()).finally(() => { refreshPromise = null; });
|
|
187
205
|
}
|
|
206
|
+
await refreshPromise;
|
|
207
|
+
return customFetch(input, method, body, { ...options, includeAuth: true, retry: false });
|
|
188
208
|
}
|
|
189
209
|
// ✅ Server-safe exported functions
|
|
190
|
-
export async function get(url, includeAuth = true) {
|
|
191
|
-
return customFetch(url, 'GET', undefined, { includeAuth });
|
|
210
|
+
export async function get(url, includeAuth = true, options = {}) {
|
|
211
|
+
return customFetch(url, 'GET', undefined, { includeAuth, ...options });
|
|
192
212
|
}
|
|
193
213
|
export async function post(url, body, includeAuth = true, options = {}) {
|
|
194
214
|
return customFetch(url, 'POST', body, { includeAuth, ...options });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HomeBanner, HomeBannerInput } from "../models/homeBanner";
|
|
2
|
+
export declare function getPublicHomeBanners(): Promise<HomeBanner[]>;
|
|
3
|
+
export declare function getStaffHomeBanners(): Promise<HomeBanner[]>;
|
|
4
|
+
export declare function createHomeBanner(input: HomeBannerInput): Promise<HomeBanner>;
|
|
5
|
+
export declare function updateHomeBanner(id: string, input: HomeBannerInput): Promise<HomeBanner>;
|
|
6
|
+
export declare function reorderHomeBanners(ids: string[]): Promise<void>;
|
|
7
|
+
export declare function deleteHomeBanner(id: string): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=homeBanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"homeBanner.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/homeBanner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIxE,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAGlE;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAGjE;AAYD,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAGlF;AAED,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAG9F;AAED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAErE;AAED,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { del, get, patch, post, put } from "./fetcher";
|
|
2
|
+
export async function getPublicHomeBanners() {
|
|
3
|
+
const response = await get("/home-banners", false);
|
|
4
|
+
return response.data;
|
|
5
|
+
}
|
|
6
|
+
export async function getStaffHomeBanners() {
|
|
7
|
+
const response = await get("/home-banners/admin");
|
|
8
|
+
return response.data;
|
|
9
|
+
}
|
|
10
|
+
function form(input) {
|
|
11
|
+
const body = new FormData();
|
|
12
|
+
body.set("description", input.description);
|
|
13
|
+
body.set("buttonLabel", input.buttonLabel || "");
|
|
14
|
+
body.set("href", input.href);
|
|
15
|
+
body.set("published", String(Boolean(input.published)));
|
|
16
|
+
if (input.photo)
|
|
17
|
+
body.set("photo", input.photo);
|
|
18
|
+
return body;
|
|
19
|
+
}
|
|
20
|
+
export async function createHomeBanner(input) {
|
|
21
|
+
const response = await post("/home-banners/admin", form(input));
|
|
22
|
+
return response.data;
|
|
23
|
+
}
|
|
24
|
+
export async function updateHomeBanner(id, input) {
|
|
25
|
+
const response = await patch(`/home-banners/admin/${encodeURIComponent(id)}`, form(input));
|
|
26
|
+
return response.data;
|
|
27
|
+
}
|
|
28
|
+
export async function reorderHomeBanners(ids) {
|
|
29
|
+
await put("/home-banners/admin/order", { ids });
|
|
30
|
+
}
|
|
31
|
+
export async function deleteHomeBanner(id) {
|
|
32
|
+
await del(`/home-banners/admin/${encodeURIComponent(id)}`);
|
|
33
|
+
}
|
|
@@ -173,17 +173,7 @@ export declare function getHostBookingDetail(id: string, type: string): Promise<
|
|
|
173
173
|
error: any;
|
|
174
174
|
type?: undefined;
|
|
175
175
|
}>;
|
|
176
|
-
export
|
|
177
|
-
success: boolean;
|
|
178
|
-
bookings: any[];
|
|
179
|
-
packageEnquiries: any[];
|
|
180
|
-
error?: undefined;
|
|
181
|
-
} | {
|
|
182
|
-
success: boolean;
|
|
183
|
-
bookings: never[];
|
|
184
|
-
packageEnquiries: never[];
|
|
185
|
-
error: any;
|
|
186
|
-
}>;
|
|
176
|
+
export { getMyBookings } from "./booking";
|
|
187
177
|
export declare function verifyBookingCodeHost(code: string): Promise<any>;
|
|
188
178
|
export declare function manageAdventureSlots(id: string, slots: any[]): Promise<{
|
|
189
179
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostDashboard.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/hostDashboard.ts"],"names":[],"mappings":"AAEA,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,oBAG9E;
|
|
1
|
+
{"version":3,"file":"hostDashboard.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/hostDashboard.ts"],"names":[],"mappings":"AAEA,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,oBAG9E;AAGD,wBAAsB,wBAAwB;;;;;;;;GAS7C;AAGD,wBAAsB,wBAAwB,CAAC,MAAM,CAAC,EAAE;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,gBAkBA;AAED,wBAAsB,0BAA0B,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;GAU5E;AAED,wBAAsB,2BAA2B,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;GAU7E;AAED,wBAAsB,2BAA2B,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;GAU7E;AAED,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;;;;GAW7B;AAED,wBAAsB,2BAA2B,CAC/C,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;GAY9C;AAED,wBAAsB,q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I,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,gBAgBA;AAGD,wBAAsB,wBAAwB,iBAO7C;AAED,wBAAsB,uBAAuB,CAAC,MAAM,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,gBAWxG;AAGD,wBAAsB,yBAAyB,CAC7C,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,sBAAsB,GAAG,sBAAsB,GAAG,mBAAmB,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;GAQjK;AAGD,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;;;;;;;;GAOlE;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,gBAOvD;AAED,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE;;;;;;;;GASlE;AAED,wBAAsB,8BAA8B,CAClD,EAAE,EAAE,MAAM,EACV,kBAAkB,EAAE,MAAM;;;;;;;;GAU3B"}
|
|
@@ -3,112 +3,6 @@ export async function updateHostBankDetails(bankDetails) {
|
|
|
3
3
|
const response = await patch("/hosts/update", { bankDetails });
|
|
4
4
|
return response.data;
|
|
5
5
|
}
|
|
6
|
-
function resolvePaymentStatus(record) {
|
|
7
|
-
if (record.paymentStatus === "paid" || record.paymentStatus === "refunded" || record.paymentStatus === "failed") {
|
|
8
|
-
return record.paymentStatus;
|
|
9
|
-
}
|
|
10
|
-
if (record.paymentId && record.paymentStatus !== "failed") {
|
|
11
|
-
return "paid";
|
|
12
|
-
}
|
|
13
|
-
if (["confirmed", "completed", "attended"].includes(record.status)) {
|
|
14
|
-
return "paid";
|
|
15
|
-
}
|
|
16
|
-
return "pending";
|
|
17
|
-
}
|
|
18
|
-
function normalizeGenericBooking(booking) {
|
|
19
|
-
const rawHostId = booking.hostId || booking.operatorId || booking.entityId?.host || booking.entityId?.hostId || booking.host;
|
|
20
|
-
const hostId = typeof rawHostId === "object" ? (rawHostId?._id || "") : (rawHostId || "");
|
|
21
|
-
return {
|
|
22
|
-
...booking,
|
|
23
|
-
hostId: hostId || booking.hostId,
|
|
24
|
-
paymentStatus: resolvePaymentStatus(booking),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function normalizeStayBooking(booking) {
|
|
28
|
-
const rawHostId = booking.hostId || booking.stayId?.host || booking.stayId?.hostId || booking.entityId?.host || booking.host;
|
|
29
|
-
const hostId = typeof rawHostId === "object" ? (rawHostId?._id || "") : (rawHostId || "");
|
|
30
|
-
return {
|
|
31
|
-
...booking,
|
|
32
|
-
hostId: hostId || booking.hostId,
|
|
33
|
-
entityId: booking.entityId || booking.stayId,
|
|
34
|
-
entityType: "Stay",
|
|
35
|
-
startDate: booking.startDate || booking.checkIn,
|
|
36
|
-
endDate: booking.endDate || booking.checkOut,
|
|
37
|
-
numberOfPeople: booking.numberOfPeople || booking.guests || 1,
|
|
38
|
-
totalPrice: booking.totalPrice || 0,
|
|
39
|
-
currency: booking.currency || "INR",
|
|
40
|
-
paymentStatus: resolvePaymentStatus(booking),
|
|
41
|
-
bookingCode: booking.bookingCode,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function normalizeEventBooking(booking) {
|
|
45
|
-
const rawHostId = booking.hostId || booking.eventId?.host || booking.eventId?.hostId || booking.entityId?.host || booking.host;
|
|
46
|
-
const hostId = typeof rawHostId === "object" ? (rawHostId?._id || "") : (rawHostId || "");
|
|
47
|
-
return {
|
|
48
|
-
...booking,
|
|
49
|
-
hostId: hostId || booking.hostId,
|
|
50
|
-
entityId: booking.entityId || booking.eventId,
|
|
51
|
-
entityType: "Event",
|
|
52
|
-
startDate: booking.startDate || booking.eventDate,
|
|
53
|
-
numberOfPeople: booking.numberOfPeople || booking.numberOfSeats || 1,
|
|
54
|
-
totalPrice: booking.totalPrice || 0,
|
|
55
|
-
currency: booking.currency || "INR",
|
|
56
|
-
paymentStatus: resolvePaymentStatus(booking),
|
|
57
|
-
bookingCode: booking.bookingCode,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function normalizePackageEnquiry(enquiry) {
|
|
61
|
-
const rawHostId = enquiry.operatorId || enquiry.hostId || enquiry.packageId?.host || enquiry.packageId?.hostId;
|
|
62
|
-
const hostId = typeof rawHostId === "object" ? (rawHostId?._id || "") : (rawHostId || "");
|
|
63
|
-
return {
|
|
64
|
-
...enquiry,
|
|
65
|
-
hostId: hostId || enquiry.operatorId,
|
|
66
|
-
operatorId: hostId || enquiry.operatorId,
|
|
67
|
-
entityId: {
|
|
68
|
-
_id: enquiry.packageId?._id || enquiry.packageId,
|
|
69
|
-
title: enquiry.packageTitle,
|
|
70
|
-
slug: enquiry.packageSlug,
|
|
71
|
-
host: hostId || enquiry.operatorId,
|
|
72
|
-
},
|
|
73
|
-
entityType: "TravelPackage",
|
|
74
|
-
bookingKind: "package_enquiry",
|
|
75
|
-
entityLabel: "Package Enquiry",
|
|
76
|
-
startDate: enquiry.createdAt,
|
|
77
|
-
endDate: undefined,
|
|
78
|
-
numberOfPeople: (Number(enquiry.males) || 0) + (Number(enquiry.females) || 0) || 1,
|
|
79
|
-
totalPrice: enquiry.totalPrice || 0,
|
|
80
|
-
currency: enquiry.currency || "INR",
|
|
81
|
-
paymentStatus: "not_applicable",
|
|
82
|
-
bookingCode: enquiry.bookingCode,
|
|
83
|
-
status: enquiry.status === "denied" ? "cancelled" : enquiry.status,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function dedupeBookings(bookings) {
|
|
87
|
-
const seen = new Set();
|
|
88
|
-
return bookings.filter((booking) => {
|
|
89
|
-
const key = String(booking._id || "") || `${booking.entityType}:${booking.bookingCode || booking.startDate}`;
|
|
90
|
-
if (seen.has(key))
|
|
91
|
-
return false;
|
|
92
|
-
seen.add(key);
|
|
93
|
-
return true;
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
function hideSupersededPackageEnquiries(bookings) {
|
|
97
|
-
const bookedPackageIds = new Set(bookings
|
|
98
|
-
.filter((booking) => booking.entityType === "TravelPackage" &&
|
|
99
|
-
booking.bookingKind !== "package_enquiry")
|
|
100
|
-
.map((booking) => {
|
|
101
|
-
const packageId = booking.entityId?._id || booking.entityId;
|
|
102
|
-
return String(packageId || "");
|
|
103
|
-
})
|
|
104
|
-
.filter(Boolean));
|
|
105
|
-
return bookings.filter((booking) => {
|
|
106
|
-
if (booking.bookingKind !== "package_enquiry")
|
|
107
|
-
return true;
|
|
108
|
-
const packageId = booking.entityId?._id || booking.packageId || booking.entityId;
|
|
109
|
-
return !bookedPackageIds.has(String(packageId || ""));
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
6
|
// ── Overview ──────────────────────────────────────────────────────────────────
|
|
113
7
|
export async function getHostDashboardOverview() {
|
|
114
8
|
try {
|
|
@@ -363,46 +257,7 @@ export async function getHostBookingDetail(id, type) {
|
|
|
363
257
|
return { success: false, booking: null, error: error.message };
|
|
364
258
|
}
|
|
365
259
|
}
|
|
366
|
-
export
|
|
367
|
-
try {
|
|
368
|
-
const [genericResult, stayResult, eventResult, packageResult] = await Promise.allSettled([
|
|
369
|
-
get("/bookings/my"),
|
|
370
|
-
get("/stays/bookings/me"),
|
|
371
|
-
get("/events/bookings/me"),
|
|
372
|
-
get("/enquiries/my"),
|
|
373
|
-
]);
|
|
374
|
-
const genericBookings = genericResult.status === "fulfilled"
|
|
375
|
-
? (genericResult.value?.data || []).map((booking) => ({
|
|
376
|
-
...normalizeGenericBooking(booking),
|
|
377
|
-
entityLabel: booking.entityType === "TravelPackage"
|
|
378
|
-
? "Package Booking"
|
|
379
|
-
: booking.entityType,
|
|
380
|
-
}))
|
|
381
|
-
: [];
|
|
382
|
-
const stayBookings = stayResult.status === "fulfilled"
|
|
383
|
-
? (stayResult.value?.data || []).map(normalizeStayBooking)
|
|
384
|
-
: [];
|
|
385
|
-
const eventBookings = eventResult.status === "fulfilled"
|
|
386
|
-
? (eventResult.value?.data || []).map(normalizeEventBooking)
|
|
387
|
-
: [];
|
|
388
|
-
const packageBookings = packageResult.status === "fulfilled"
|
|
389
|
-
? (packageResult.value?.data || []).map(normalizePackageEnquiry)
|
|
390
|
-
: [];
|
|
391
|
-
const combined = hideSupersededPackageEnquiries(dedupeBookings([
|
|
392
|
-
...genericBookings,
|
|
393
|
-
...stayBookings,
|
|
394
|
-
...eventBookings,
|
|
395
|
-
...packageBookings,
|
|
396
|
-
])).sort((a, b) => new Date(b.createdAt || b.startDate || 0).getTime() -
|
|
397
|
-
new Date(a.createdAt || a.startDate || 0).getTime());
|
|
398
|
-
const packageEnquiries = combined.filter((booking) => booking.bookingKind === "package_enquiry");
|
|
399
|
-
const bookings = combined.filter((booking) => booking.bookingKind !== "package_enquiry");
|
|
400
|
-
return { success: true, bookings, packageEnquiries };
|
|
401
|
-
}
|
|
402
|
-
catch (error) {
|
|
403
|
-
return { success: false, bookings: [], packageEnquiries: [], error: error.message };
|
|
404
|
-
}
|
|
405
|
-
}
|
|
260
|
+
export { getMyBookings } from "./booking";
|
|
406
261
|
export async function verifyBookingCodeHost(code) {
|
|
407
262
|
try {
|
|
408
263
|
const data = (await get(`/bookings/verify/${code}`));
|
|
@@ -17,7 +17,7 @@ export declare function getContextualDestinationSuggestions(route: ItineraryRout
|
|
|
17
17
|
suggestions: ContextualDestinationSuggestion[];
|
|
18
18
|
error?: string;
|
|
19
19
|
}>;
|
|
20
|
-
export declare function getItineraryById<T = any>(id: string): Promise<T>;
|
|
20
|
+
export declare function getItineraryById<T = any>(id: string, signal?: AbortSignal): Promise<T>;
|
|
21
21
|
export declare function getMyItineraries(): Promise<{
|
|
22
22
|
success: boolean;
|
|
23
23
|
itineraries: ItinerarySummary[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itinerary.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/itinerary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,+BAA+B,EAC/B,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,+BAA+B,EAC/B,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAK7B,wBAAsB,sBAAsB,CAAC,KAAK,SAAI,GAAG,OAAO,CAAC;IAC/D,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAeD;AAED,wBAAsB,iBAAiB,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CACpF;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,CAAC,CAAA;CAAE,GAC/B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CACpC,CAcA;AAED,wBAAsB,mCAAmC,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC;IAC7F,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAWD;AAED,wBAAsB,gBAAgB,CAAC,CAAC,GAAG,GAAG,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"itinerary.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/itinerary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,+B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GAAG,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAOxF;AAED,wBAAsB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAM1E"}
|
|
@@ -47,8 +47,8 @@ export async function getContextualDestinationSuggestions(route) {
|
|
|
47
47
|
return { success: false, suggestions: [] };
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
export async function getItineraryById(id) {
|
|
51
|
-
const payload = await get(`/itineraries/${encodeURIComponent(id)}`, true);
|
|
50
|
+
export async function getItineraryById(id, signal) {
|
|
51
|
+
const payload = await get(`/itineraries/${encodeURIComponent(id)}`, true, { signal });
|
|
52
52
|
return payload.data;
|
|
53
53
|
}
|
|
54
54
|
export async function getMyItineraries() {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type { Interest } from "../models/
|
|
2
|
-
export declare function submitInterestRequest(data: Interest): Promise<
|
|
3
|
-
success: boolean;
|
|
4
|
-
error?: string;
|
|
5
|
-
}>;
|
|
1
|
+
import type { Interest, InterestResult } from "../models/interest";
|
|
2
|
+
export declare function submitInterestRequest(data: Interest): Promise<InterestResult>;
|
|
6
3
|
//# sourceMappingURL=listingInterest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listingInterest.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/listingInterest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"listingInterest.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/listingInterest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAYnE,wBAAsB,qBAAqB,CACvC,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,cAAc,CAAC,CAwBzB"}
|
|
@@ -9,10 +9,25 @@ const INTEREST_ENDPOINTS = {
|
|
|
9
9
|
};
|
|
10
10
|
export async function submitInterestRequest(data) {
|
|
11
11
|
try {
|
|
12
|
-
await post(INTEREST_ENDPOINTS[data.type] ?? "/interest", data);
|
|
13
|
-
|
|
12
|
+
const result = await post(INTEREST_ENDPOINTS[data.type] ?? "/interest", data);
|
|
13
|
+
const saved = result?.data;
|
|
14
|
+
if (!saved || typeof saved._id !== "string" ||
|
|
15
|
+
!/^[a-zA-Z0-9_-]{1,100}$/.test(saved._id) || saved.type !== data.type) {
|
|
16
|
+
return {
|
|
17
|
+
success: false,
|
|
18
|
+
outcome: "uncertain",
|
|
19
|
+
error: "The request outcome could not be confirmed. It may already have been received.",
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return { success: true, receipt: { id: saved._id, type: data.type } };
|
|
14
23
|
}
|
|
15
24
|
catch (error) {
|
|
16
|
-
|
|
25
|
+
// The controller saves before sending its notification email. A 5xx or
|
|
26
|
+
// lost response cannot establish absence and must never invite replay.
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
error: error?.message || "Could not submit your request",
|
|
30
|
+
outcome: "uncertain",
|
|
31
|
+
};
|
|
17
32
|
}
|
|
18
33
|
}
|
|
@@ -31,6 +31,8 @@ export declare function fetchThreads(locationId: string, opts?: {
|
|
|
31
31
|
}): Promise<{
|
|
32
32
|
threads: ForumThread[];
|
|
33
33
|
total: number;
|
|
34
|
+
success: boolean;
|
|
35
|
+
error?: string;
|
|
34
36
|
}>;
|
|
35
37
|
export declare function createThread(payload: {
|
|
36
38
|
locationId: string;
|
|
@@ -48,6 +50,8 @@ export declare function createThread(payload: {
|
|
|
48
50
|
export declare function fetchComments(threadId: string, page?: number): Promise<{
|
|
49
51
|
comments: ForumComment[];
|
|
50
52
|
total: number;
|
|
53
|
+
success: boolean;
|
|
54
|
+
error?: string;
|
|
51
55
|
}>;
|
|
52
56
|
export declare function fetchThread(threadId: string): Prom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KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAOtE;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,SAAI,GACP,OAAO,CAAC;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CASxF;AAED,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAOrE;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACzF,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,YAAY,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAOvE;AAED,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,GAC7B,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAO/C"}
|
|
@@ -64,10 +64,12 @@ export async function fetchThreads(locationId, opts = {}) {
|
|
|
64
64
|
if (opts.category)
|
|
65
65
|
params.set("category", opts.category);
|
|
66
66
|
const data = await get(`/locations/${locationId}/threads?${params}`);
|
|
67
|
-
|
|
67
|
+
if (!data.data || !Array.isArray(data.data.threads) || !Number.isFinite(data.data.total) || data.data.total < 0)
|
|
68
|
+
throw new Error("Discussions response was incomplete. Please retry.");
|
|
69
|
+
return { ...data.data, success: true };
|
|
68
70
|
}
|
|
69
|
-
catch {
|
|
70
|
-
return { threads: [], total: 0 };
|
|
71
|
+
catch (error) {
|
|
72
|
+
return { threads: [], total: 0, success: false, error: error instanceof Error ? error.message : "Discussions could not load." };
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
export async function createThread(payload) {
|
|
@@ -82,10 +84,12 @@ export async function createThread(payload) {
|
|
|
82
84
|
export async function fetchComments(threadId, page = 1) {
|
|
83
85
|
try {
|
|
84
86
|
const data = await get(`/locations/threads/${threadId}/comments?page=${page}&limit=50`);
|
|
85
|
-
|
|
87
|
+
if (!data.data || !Array.isArray(data.data.comments) || !Number.isFinite(data.data.total) || data.data.total < 0)
|
|
88
|
+
throw new Error("Replies response was incomplete. Please retry.");
|
|
89
|
+
return { ...data.data, success: true };
|
|
86
90
|
}
|
|
87
|
-
catch {
|
|
88
|
-
return { comments: [], total: 0 };
|
|
91
|
+
catch (error) {
|
|
92
|
+
return { comments: [], total: 0, success: false, error: error instanceof Error ? error.message : "Replies could not load." };
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
export async function fetchThread(threadId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketplaceContract.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/marketplaceContract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"marketplaceContract.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/marketplaceContract.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGrF,eAAO,MAAM,uBAAuB,sCAA0F,CAAC;AAC/H,eAAO,MAAM,sBAAsB,GAAU,cAAc,MAAM,iCAAkH,CAAC;AACpL,eAAO,MAAM,yBAAyB,GAAU,OAAO,OAAO,iCAAuF,CAAC;AACtJ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