@mohasinac/appkit 2.8.5 → 2.8.6
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/_internal/server/features/checkout/actions.js +2 -1
- package/dist/_internal/server/features/grouped/data.js +9 -8
- package/dist/_internal/server/features/products/data.js +2 -1
- package/dist/_internal/server/features/refunds/actions.js +2 -1
- package/dist/_internal/server/features/seo/sitemap.js +2 -1
- package/dist/_internal/server/jobs/core/countersReconcile.js +4 -4
- package/dist/_internal/shared/features/blog/schema.d.ts +4 -4
- package/dist/_internal/shared/features/categories/bundle-schemas.d.ts +8 -8
- package/dist/constants/field-names.d.ts +3 -0
- package/dist/constants/field-names.js +3 -0
- package/dist/features/admin/repository/chat.repository.js +7 -6
- package/dist/features/auctions/components/AuctionBottomActions.js +3 -4
- package/dist/features/auctions/repository/bid.repository.js +12 -12
- package/dist/features/blog/actions/blog-actions.d.ts +2 -2
- package/dist/features/blog/schemas/index.d.ts +1 -1
- package/dist/features/cart/repository/cart.repository.js +2 -1
- package/dist/features/categories/repository/categories.repository.js +26 -25
- package/dist/features/categories/schemas/firestore.d.ts +1 -0
- package/dist/features/categories/schemas/firestore.js +1 -0
- package/dist/features/categories/schemas/index.d.ts +10 -10
- package/dist/features/events/components/EventParticipateView.js +2 -1
- package/dist/features/events/schemas/index.d.ts +3 -3
- package/dist/features/faq/actions/faq-actions.d.ts +6 -6
- package/dist/features/faq/repository/faqs.repository.js +21 -20
- package/dist/features/faq/schemas/index.d.ts +2 -2
- package/dist/features/homepage/repository/carousel.repository.js +8 -7
- package/dist/features/homepage/repository/carousels.repository.js +2 -1
- package/dist/features/homepage/repository/homepage-sections.repository.js +6 -5
- package/dist/features/messages/repository/conversations.repository.js +5 -4
- package/dist/features/orders/repository/orders.repository.js +13 -13
- package/dist/features/products/repository/product-features.repository.js +7 -6
- package/dist/features/products/repository/product-templates.repository.js +4 -3
- package/dist/features/products/repository/products.repository.js +4 -4
- package/dist/features/promotions/repository/claimed-coupons.repository.js +2 -1
- package/dist/features/promotions/repository/coupons.repository.js +4 -4
- package/dist/features/reviews/repository/reviews.repository.js +2 -2
- package/dist/features/scams/repository/scammer.repository.js +3 -3
- package/dist/features/search/components/Search.js +11 -0
- package/dist/features/support/repository/support.repository.js +8 -7
- package/dist/seed/products-auctions-seed-data.js +107 -0
- package/package.json +1 -1
|
@@ -23,12 +23,12 @@ export declare const categoryDisplaySchema: z.ZodObject<{
|
|
|
23
23
|
showInMenu: z.ZodOptional<z.ZodBoolean>;
|
|
24
24
|
}, "strip", z.ZodTypeAny, {
|
|
25
25
|
icon?: string | undefined;
|
|
26
|
-
showInMenu?: boolean | undefined;
|
|
27
26
|
coverImage?: string | undefined;
|
|
27
|
+
showInMenu?: boolean | undefined;
|
|
28
28
|
}, {
|
|
29
29
|
icon?: string | undefined;
|
|
30
|
-
showInMenu?: boolean | undefined;
|
|
31
30
|
coverImage?: string | undefined;
|
|
31
|
+
showInMenu?: boolean | undefined;
|
|
32
32
|
}>;
|
|
33
33
|
export declare const categoryMetricsSchema: z.ZodObject<{
|
|
34
34
|
productCount: z.ZodNumber;
|
|
@@ -104,12 +104,12 @@ export declare const categoryItemSchema: z.ZodObject<{
|
|
|
104
104
|
showInMenu: z.ZodOptional<z.ZodBoolean>;
|
|
105
105
|
}, "strip", z.ZodTypeAny, {
|
|
106
106
|
icon?: string | undefined;
|
|
107
|
-
showInMenu?: boolean | undefined;
|
|
108
107
|
coverImage?: string | undefined;
|
|
108
|
+
showInMenu?: boolean | undefined;
|
|
109
109
|
}, {
|
|
110
110
|
icon?: string | undefined;
|
|
111
|
-
showInMenu?: boolean | undefined;
|
|
112
111
|
coverImage?: string | undefined;
|
|
112
|
+
showInMenu?: boolean | undefined;
|
|
113
113
|
}>>;
|
|
114
114
|
createdAt: z.ZodOptional<z.ZodString>;
|
|
115
115
|
updatedAt: z.ZodOptional<z.ZodString>;
|
|
@@ -125,8 +125,8 @@ export declare const categoryItemSchema: z.ZodObject<{
|
|
|
125
125
|
updatedAt?: string | undefined;
|
|
126
126
|
display?: {
|
|
127
127
|
icon?: string | undefined;
|
|
128
|
-
showInMenu?: boolean | undefined;
|
|
129
128
|
coverImage?: string | undefined;
|
|
129
|
+
showInMenu?: boolean | undefined;
|
|
130
130
|
} | undefined;
|
|
131
131
|
order?: number | undefined;
|
|
132
132
|
isFeatured?: boolean | undefined;
|
|
@@ -137,8 +137,8 @@ export declare const categoryItemSchema: z.ZodObject<{
|
|
|
137
137
|
ogImage?: string | undefined;
|
|
138
138
|
} | undefined;
|
|
139
139
|
rootId?: string | undefined;
|
|
140
|
-
parentIds?: string[] | undefined;
|
|
141
140
|
isLeaf?: boolean | undefined;
|
|
141
|
+
parentIds?: string[] | undefined;
|
|
142
142
|
featuredPriority?: number | undefined;
|
|
143
143
|
childrenIds?: string[] | undefined;
|
|
144
144
|
metrics?: {
|
|
@@ -158,8 +158,8 @@ export declare const categoryItemSchema: z.ZodObject<{
|
|
|
158
158
|
updatedAt?: string | undefined;
|
|
159
159
|
display?: {
|
|
160
160
|
icon?: string | undefined;
|
|
161
|
-
showInMenu?: boolean | undefined;
|
|
162
161
|
coverImage?: string | undefined;
|
|
162
|
+
showInMenu?: boolean | undefined;
|
|
163
163
|
} | undefined;
|
|
164
164
|
order?: number | undefined;
|
|
165
165
|
isFeatured?: boolean | undefined;
|
|
@@ -170,8 +170,8 @@ export declare const categoryItemSchema: z.ZodObject<{
|
|
|
170
170
|
ogImage?: string | undefined;
|
|
171
171
|
} | undefined;
|
|
172
172
|
rootId?: string | undefined;
|
|
173
|
-
parentIds?: string[] | undefined;
|
|
174
173
|
isLeaf?: boolean | undefined;
|
|
174
|
+
parentIds?: string[] | undefined;
|
|
175
175
|
featuredPriority?: number | undefined;
|
|
176
176
|
childrenIds?: string[] | undefined;
|
|
177
177
|
metrics?: {
|
|
@@ -194,14 +194,14 @@ export declare const categoryListParamsSchema: z.ZodObject<{
|
|
|
194
194
|
q?: string | undefined;
|
|
195
195
|
page?: number | undefined;
|
|
196
196
|
perPage?: number | undefined;
|
|
197
|
-
tier?: number | undefined;
|
|
198
197
|
parentId?: string | undefined;
|
|
198
|
+
tier?: number | undefined;
|
|
199
199
|
}, {
|
|
200
200
|
type?: "category" | "brand" | "collection" | "concern" | undefined;
|
|
201
201
|
featured?: boolean | undefined;
|
|
202
202
|
q?: string | undefined;
|
|
203
203
|
page?: number | undefined;
|
|
204
204
|
perPage?: number | undefined;
|
|
205
|
-
tier?: number | undefined;
|
|
206
205
|
parentId?: string | undefined;
|
|
206
|
+
tier?: number | undefined;
|
|
207
207
|
}>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Div } from "../../../ui";
|
|
3
|
+
import { Skeleton } from "../../../ui/components/Skeleton";
|
|
3
4
|
export function EventParticipateView({ isLoading = false, isSubmitted = false, renderEventInfo, renderForm, renderAction, renderSuccess, renderSkeleton, renderAuthGate, className = "", }) {
|
|
4
5
|
if (isLoading) {
|
|
5
6
|
if (renderSkeleton)
|
|
6
7
|
return _jsx(_Fragment, { children: renderSkeleton() });
|
|
7
|
-
return
|
|
8
|
+
return (_jsxs(Div, { className: "max-w-xl mx-auto space-y-4 py-6", children: [_jsx(Skeleton, { variant: "rectangular", height: "32px" }), _jsx(Skeleton, { variant: "rectangular", height: "80px" }), _jsx(Skeleton, { variant: "rectangular", height: "48px" })] }));
|
|
8
9
|
}
|
|
9
10
|
if (renderAuthGate)
|
|
10
11
|
return _jsx(_Fragment, { children: renderAuthGate() });
|
|
@@ -275,6 +275,8 @@ export declare const eventItemSchema: z.ZodObject<{
|
|
|
275
275
|
approvedEntries: number;
|
|
276
276
|
flaggedEntries: number;
|
|
277
277
|
};
|
|
278
|
+
startsAt: string;
|
|
279
|
+
endsAt: string;
|
|
278
280
|
createdBy: string;
|
|
279
281
|
coverImage: {
|
|
280
282
|
url: string;
|
|
@@ -287,8 +289,6 @@ export declare const eventItemSchema: z.ZodObject<{
|
|
|
287
289
|
url: string;
|
|
288
290
|
type: "image";
|
|
289
291
|
} | null;
|
|
290
|
-
startsAt: string;
|
|
291
|
-
endsAt: string;
|
|
292
292
|
additionalImages: {
|
|
293
293
|
url: string;
|
|
294
294
|
type: "image" | "video" | "file";
|
|
@@ -346,9 +346,9 @@ export declare const eventItemSchema: z.ZodObject<{
|
|
|
346
346
|
approvedEntries: number;
|
|
347
347
|
flaggedEntries: number;
|
|
348
348
|
};
|
|
349
|
-
createdBy: string;
|
|
350
349
|
startsAt: string;
|
|
351
350
|
endsAt: string;
|
|
351
|
+
createdBy: string;
|
|
352
352
|
coverImage?: string | {
|
|
353
353
|
url: string;
|
|
354
354
|
type: "image" | "video" | "file";
|
|
@@ -31,12 +31,12 @@ export declare const faqCreateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
31
31
|
priority: number;
|
|
32
32
|
isActive: boolean;
|
|
33
33
|
question: string;
|
|
34
|
-
showInFooter: boolean;
|
|
35
34
|
showOnHomepage: boolean;
|
|
36
35
|
answer: {
|
|
37
36
|
text: string;
|
|
38
37
|
format: "html" | "plain" | "markdown";
|
|
39
38
|
};
|
|
39
|
+
showInFooter: boolean;
|
|
40
40
|
isPinned: boolean;
|
|
41
41
|
useSiteSettings: boolean;
|
|
42
42
|
tags?: string[] | undefined;
|
|
@@ -56,8 +56,8 @@ export declare const faqCreateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
56
56
|
priority?: number | undefined;
|
|
57
57
|
isActive?: boolean | undefined;
|
|
58
58
|
variables?: Record<string, string> | undefined;
|
|
59
|
-
showInFooter?: boolean | undefined;
|
|
60
59
|
showOnHomepage?: boolean | undefined;
|
|
60
|
+
showInFooter?: boolean | undefined;
|
|
61
61
|
isPinned?: boolean | undefined;
|
|
62
62
|
relatedFAQs?: string[] | undefined;
|
|
63
63
|
useSiteSettings?: boolean | undefined;
|
|
@@ -67,12 +67,12 @@ export declare const faqCreateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
67
67
|
priority: number;
|
|
68
68
|
isActive: boolean;
|
|
69
69
|
question: string;
|
|
70
|
-
showInFooter: boolean;
|
|
71
70
|
showOnHomepage: boolean;
|
|
72
71
|
answer: {
|
|
73
72
|
text: string;
|
|
74
73
|
format: "html" | "plain" | "markdown";
|
|
75
74
|
};
|
|
75
|
+
showInFooter: boolean;
|
|
76
76
|
isPinned: boolean;
|
|
77
77
|
useSiteSettings: boolean;
|
|
78
78
|
tags?: string[] | undefined;
|
|
@@ -92,8 +92,8 @@ export declare const faqCreateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
92
92
|
priority?: number | undefined;
|
|
93
93
|
isActive?: boolean | undefined;
|
|
94
94
|
variables?: Record<string, string> | undefined;
|
|
95
|
-
showInFooter?: boolean | undefined;
|
|
96
95
|
showOnHomepage?: boolean | undefined;
|
|
96
|
+
showInFooter?: boolean | undefined;
|
|
97
97
|
isPinned?: boolean | undefined;
|
|
98
98
|
relatedFAQs?: string[] | undefined;
|
|
99
99
|
useSiteSettings?: boolean | undefined;
|
|
@@ -131,12 +131,12 @@ export declare const faqUpdateSchema: z.ZodObject<{
|
|
|
131
131
|
isActive?: boolean | undefined;
|
|
132
132
|
variables?: Record<string, string> | undefined;
|
|
133
133
|
question?: string | undefined;
|
|
134
|
-
showInFooter?: boolean | undefined;
|
|
135
134
|
showOnHomepage?: boolean | undefined;
|
|
136
135
|
answer?: {
|
|
137
136
|
text: string;
|
|
138
137
|
format: "html" | "plain" | "markdown";
|
|
139
138
|
} | undefined;
|
|
139
|
+
showInFooter?: boolean | undefined;
|
|
140
140
|
isPinned?: boolean | undefined;
|
|
141
141
|
relatedFAQs?: string[] | undefined;
|
|
142
142
|
useSiteSettings?: boolean | undefined;
|
|
@@ -149,12 +149,12 @@ export declare const faqUpdateSchema: z.ZodObject<{
|
|
|
149
149
|
isActive?: boolean | undefined;
|
|
150
150
|
variables?: Record<string, string> | undefined;
|
|
151
151
|
question?: string | undefined;
|
|
152
|
-
showInFooter?: boolean | undefined;
|
|
153
152
|
showOnHomepage?: boolean | undefined;
|
|
154
153
|
answer?: {
|
|
155
154
|
text: string;
|
|
156
155
|
format?: "html" | "plain" | "markdown" | undefined;
|
|
157
156
|
} | undefined;
|
|
157
|
+
showInFooter?: boolean | undefined;
|
|
158
158
|
isPinned?: boolean | undefined;
|
|
159
159
|
relatedFAQs?: string[] | undefined;
|
|
160
160
|
useSiteSettings?: boolean | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseRepository, prepareForFirestore, } from "../../../providers/db-firebase";
|
|
2
2
|
import { DatabaseError } from "../../../errors";
|
|
3
3
|
import { increment } from "../../../contracts/field-ops";
|
|
4
|
+
import { FAQ_FIELDS } from "../../../constants/field-names";
|
|
4
5
|
import { FAQS_COLLECTION, createFAQId, slugifyQuestion, } from "../schemas";
|
|
5
6
|
export class FAQsRepository {
|
|
6
7
|
constructor(repo) {
|
|
@@ -116,16 +117,16 @@ export class FirebaseFAQsRepository extends BaseRepository {
|
|
|
116
117
|
throw new DatabaseError("Combining FAQ tag filters and token search requires a dedicated search index");
|
|
117
118
|
}
|
|
118
119
|
if (tags.length === 1) {
|
|
119
|
-
baseQuery = baseQuery.where(
|
|
120
|
+
baseQuery = baseQuery.where(FAQ_FIELDS.TAGS, "array-contains", tags[0]);
|
|
120
121
|
}
|
|
121
122
|
else if (tags.length > 1) {
|
|
122
|
-
baseQuery = baseQuery.where(
|
|
123
|
+
baseQuery = baseQuery.where(FAQ_FIELDS.TAGS, "array-contains-any", tags.slice(0, 10));
|
|
123
124
|
}
|
|
124
125
|
if (searchTokens.length === 1) {
|
|
125
|
-
baseQuery = baseQuery.where(
|
|
126
|
+
baseQuery = baseQuery.where(FAQ_FIELDS.SEARCH_TOKENS, "array-contains", searchTokens[0]);
|
|
126
127
|
}
|
|
127
128
|
else if (searchTokens.length > 1) {
|
|
128
|
-
baseQuery = baseQuery.where(
|
|
129
|
+
baseQuery = baseQuery.where(FAQ_FIELDS.SEARCH_TOKENS, "array-contains-any", searchTokens);
|
|
129
130
|
}
|
|
130
131
|
return this.sieveQuery(model, FirebaseFAQsRepository.SIEVE_FIELDS, { baseQuery });
|
|
131
132
|
}
|
|
@@ -142,53 +143,53 @@ export class FirebaseFAQsRepository extends BaseRepository {
|
|
|
142
143
|
async getFAQsByCategory(category) {
|
|
143
144
|
const snapshot = await this.db
|
|
144
145
|
.collection(this.collection)
|
|
145
|
-
.where(
|
|
146
|
-
.where(
|
|
147
|
-
.orderBy(
|
|
146
|
+
.where(FAQ_FIELDS.CATEGORY, "==", category)
|
|
147
|
+
.where(FAQ_FIELDS.IS_ACTIVE, "==", true)
|
|
148
|
+
.orderBy(FAQ_FIELDS.ORDER, "asc")
|
|
148
149
|
.get();
|
|
149
150
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
150
151
|
}
|
|
151
152
|
async getHomepageFAQs() {
|
|
152
153
|
const snapshot = await this.db
|
|
153
154
|
.collection(this.collection)
|
|
154
|
-
.where(
|
|
155
|
-
.where(
|
|
156
|
-
.orderBy(
|
|
155
|
+
.where(FAQ_FIELDS.SHOW_ON_HOMEPAGE, "==", true)
|
|
156
|
+
.where(FAQ_FIELDS.IS_ACTIVE, "==", true)
|
|
157
|
+
.orderBy(FAQ_FIELDS.PRIORITY, "desc")
|
|
157
158
|
.get();
|
|
158
159
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
159
160
|
}
|
|
160
161
|
async getFooterFAQs() {
|
|
161
162
|
const snapshot = await this.db
|
|
162
163
|
.collection(this.collection)
|
|
163
|
-
.where(
|
|
164
|
-
.where(
|
|
165
|
-
.orderBy(
|
|
164
|
+
.where(FAQ_FIELDS.SHOW_IN_FOOTER, "==", true)
|
|
165
|
+
.where(FAQ_FIELDS.IS_ACTIVE, "==", true)
|
|
166
|
+
.orderBy(FAQ_FIELDS.ORDER, "asc")
|
|
166
167
|
.get();
|
|
167
168
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
168
169
|
}
|
|
169
170
|
async getPinnedFAQs(category) {
|
|
170
171
|
let query = this.db
|
|
171
172
|
.collection(this.collection)
|
|
172
|
-
.where(
|
|
173
|
-
.where(
|
|
173
|
+
.where(FAQ_FIELDS.IS_PINNED, "==", true)
|
|
174
|
+
.where(FAQ_FIELDS.IS_ACTIVE, "==", true);
|
|
174
175
|
if (category) {
|
|
175
|
-
query = query.where(
|
|
176
|
+
query = query.where(FAQ_FIELDS.CATEGORY, "==", category);
|
|
176
177
|
}
|
|
177
|
-
const snapshot = await query.orderBy(
|
|
178
|
+
const snapshot = await query.orderBy(FAQ_FIELDS.ORDER, "asc").get();
|
|
178
179
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
179
180
|
}
|
|
180
181
|
async searchByTag(tag) {
|
|
181
182
|
const snapshot = await this.db
|
|
182
183
|
.collection(this.collection)
|
|
183
|
-
.where(
|
|
184
|
-
.where(
|
|
184
|
+
.where(FAQ_FIELDS.TAGS, "array-contains", tag)
|
|
185
|
+
.where(FAQ_FIELDS.IS_ACTIVE, "==", true)
|
|
185
186
|
.get();
|
|
186
187
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
187
188
|
}
|
|
188
189
|
async getMostHelpful(limit = 10) {
|
|
189
190
|
const snapshot = await this.db
|
|
190
191
|
.collection(this.collection)
|
|
191
|
-
.where(
|
|
192
|
+
.where(FAQ_FIELDS.IS_ACTIVE, "==", true)
|
|
192
193
|
.orderBy("stats.helpful", "desc")
|
|
193
194
|
.limit(limit)
|
|
194
195
|
.get();
|
|
@@ -103,8 +103,8 @@ export declare const faqSchema: z.ZodObject<{
|
|
|
103
103
|
seo?: {
|
|
104
104
|
slug?: string | undefined;
|
|
105
105
|
} | undefined;
|
|
106
|
-
showInFooter?: boolean | undefined;
|
|
107
106
|
showOnHomepage?: boolean | undefined;
|
|
107
|
+
showInFooter?: boolean | undefined;
|
|
108
108
|
isPinned?: boolean | undefined;
|
|
109
109
|
relatedFAQs?: string[] | undefined;
|
|
110
110
|
}, {
|
|
@@ -129,8 +129,8 @@ export declare const faqSchema: z.ZodObject<{
|
|
|
129
129
|
seo?: {
|
|
130
130
|
slug?: string | undefined;
|
|
131
131
|
} | undefined;
|
|
132
|
-
showInFooter?: boolean | undefined;
|
|
133
132
|
showOnHomepage?: boolean | undefined;
|
|
133
|
+
showInFooter?: boolean | undefined;
|
|
134
134
|
isPinned?: boolean | undefined;
|
|
135
135
|
relatedFAQs?: string[] | undefined;
|
|
136
136
|
}>;
|
|
@@ -7,6 +7,7 @@ import { BaseRepository, getFirestoreCount, prepareForFirestore, } from "../../.
|
|
|
7
7
|
import { increment } from "../../../contracts/field-ops";
|
|
8
8
|
import { CAROUSEL_SLIDES_COLLECTION, MAX_ACTIVE_SLIDES, DEFAULT_CAROUSEL_SLIDE_DATA, canActivateSlide, createCarouselId, } from "../schemas";
|
|
9
9
|
import { DatabaseError } from "../../../errors";
|
|
10
|
+
import { CAROUSEL_FIELDS } from "../../../constants/field-names";
|
|
10
11
|
/**
|
|
11
12
|
* Repository for carousel slide management
|
|
12
13
|
*/
|
|
@@ -48,8 +49,8 @@ export class CarouselRepository extends BaseRepository {
|
|
|
48
49
|
try {
|
|
49
50
|
const snapshot = await this.db
|
|
50
51
|
.collection(this.collection)
|
|
51
|
-
.where(
|
|
52
|
-
.orderBy(
|
|
52
|
+
.where(CAROUSEL_FIELDS.ACTIVE, "==", true)
|
|
53
|
+
.orderBy(CAROUSEL_FIELDS.ORDER, "asc")
|
|
53
54
|
.limit(MAX_ACTIVE_SLIDES)
|
|
54
55
|
.get();
|
|
55
56
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
@@ -67,8 +68,8 @@ export class CarouselRepository extends BaseRepository {
|
|
|
67
68
|
try {
|
|
68
69
|
const snapshot = await this.db
|
|
69
70
|
.collection(this.collection)
|
|
70
|
-
.where(
|
|
71
|
-
.orderBy(
|
|
71
|
+
.where(CAROUSEL_FIELDS.ACTIVE, "==", false)
|
|
72
|
+
.orderBy(CAROUSEL_FIELDS.CREATED_AT, "desc")
|
|
72
73
|
.get();
|
|
73
74
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
74
75
|
}
|
|
@@ -86,8 +87,8 @@ export class CarouselRepository extends BaseRepository {
|
|
|
86
87
|
try {
|
|
87
88
|
const snapshot = await this.db
|
|
88
89
|
.collection(this.collection)
|
|
89
|
-
.where(
|
|
90
|
-
.orderBy(
|
|
90
|
+
.where(CAROUSEL_FIELDS.CREATED_BY, "==", userId)
|
|
91
|
+
.orderBy(CAROUSEL_FIELDS.CREATED_AT, "desc")
|
|
91
92
|
.get();
|
|
92
93
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
93
94
|
}
|
|
@@ -193,7 +194,7 @@ export class CarouselRepository extends BaseRepository {
|
|
|
193
194
|
*/
|
|
194
195
|
async getActiveCount() {
|
|
195
196
|
try {
|
|
196
|
-
return await getFirestoreCount(this.db.collection(this.collection).where(
|
|
197
|
+
return await getFirestoreCount(this.db.collection(this.collection).where(CAROUSEL_FIELDS.ACTIVE, "==", true));
|
|
197
198
|
}
|
|
198
199
|
catch (error) {
|
|
199
200
|
throw new DatabaseError(`Failed to count active slides: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
@@ -9,6 +9,7 @@ import { BaseRepository, prepareForFirestore, } from "../../../providers/db-fire
|
|
|
9
9
|
import { CAROUSELS_COLLECTION, MAX_SLIDES_PER_CAROUSEL, TooManySlidesError, } from "../schemas";
|
|
10
10
|
import { DatabaseError } from "../../../errors";
|
|
11
11
|
import { getAdminDb } from "../../../providers/db-firebase";
|
|
12
|
+
import { CAROUSEL_FIELDS } from "../../../constants/field-names";
|
|
12
13
|
export class CarouselsRepository extends BaseRepository {
|
|
13
14
|
constructor() {
|
|
14
15
|
super(CAROUSELS_COLLECTION);
|
|
@@ -19,7 +20,7 @@ export class CarouselsRepository extends BaseRepository {
|
|
|
19
20
|
const db = getAdminDb();
|
|
20
21
|
const snap = await db
|
|
21
22
|
.collection(CAROUSELS_COLLECTION)
|
|
22
|
-
.orderBy(
|
|
23
|
+
.orderBy(CAROUSEL_FIELDS.NAME)
|
|
23
24
|
.get();
|
|
24
25
|
return snap.docs.map((d) => ({ id: d.id, ...d.data() }));
|
|
25
26
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Manages homepage section configuration and ordering.
|
|
5
5
|
*/
|
|
6
6
|
import { DatabaseError } from "../../../errors";
|
|
7
|
+
import { HOMEPAGE_SECTION_FIELDS } from "../../../constants/field-names";
|
|
7
8
|
import { BaseRepository, prepareForFirestore, } from "../../../providers/db-firebase";
|
|
8
9
|
import { HOMEPAGE_SECTIONS_COLLECTION, createHomepageSectionId, } from "../schemas";
|
|
9
10
|
export class HomepageSectionsRepository extends BaseRepository {
|
|
@@ -30,8 +31,8 @@ export class HomepageSectionsRepository extends BaseRepository {
|
|
|
30
31
|
try {
|
|
31
32
|
const snapshot = await this.db
|
|
32
33
|
.collection(this.collection)
|
|
33
|
-
.where(
|
|
34
|
-
.orderBy(
|
|
34
|
+
.where(HOMEPAGE_SECTION_FIELDS.ENABLED, "==", true)
|
|
35
|
+
.orderBy(HOMEPAGE_SECTION_FIELDS.ORDER, "asc")
|
|
35
36
|
.get();
|
|
36
37
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
37
38
|
}
|
|
@@ -43,8 +44,8 @@ export class HomepageSectionsRepository extends BaseRepository {
|
|
|
43
44
|
try {
|
|
44
45
|
const snapshot = await this.db
|
|
45
46
|
.collection(this.collection)
|
|
46
|
-
.where(
|
|
47
|
-
.orderBy(
|
|
47
|
+
.where(HOMEPAGE_SECTION_FIELDS.ENABLED, "==", false)
|
|
48
|
+
.orderBy(HOMEPAGE_SECTION_FIELDS.ORDER, "asc")
|
|
48
49
|
.get();
|
|
49
50
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
50
51
|
}
|
|
@@ -56,7 +57,7 @@ export class HomepageSectionsRepository extends BaseRepository {
|
|
|
56
57
|
try {
|
|
57
58
|
const snapshot = await this.db
|
|
58
59
|
.collection(this.collection)
|
|
59
|
-
.where(
|
|
60
|
+
.where(HOMEPAGE_SECTION_FIELDS.TYPE, "==", type)
|
|
60
61
|
.limit(1)
|
|
61
62
|
.get();
|
|
62
63
|
if (snapshot.empty)
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { getAdminDb } from "../../../providers/db-firebase";
|
|
12
12
|
import { serverLogger } from "../../../monitoring";
|
|
13
|
+
import { CONVERSATION_FIELDS } from "../../../constants/field-names";
|
|
13
14
|
import { CONVERSATIONS_COLLECTION, } from "../schemas/firestore";
|
|
14
15
|
function toDate(raw) {
|
|
15
16
|
if (raw instanceof Date)
|
|
@@ -112,15 +113,15 @@ export class ConversationsRepository {
|
|
|
112
113
|
}
|
|
113
114
|
async listByBuyer(buyerId) {
|
|
114
115
|
const snap = await this.collection()
|
|
115
|
-
.where(
|
|
116
|
-
.orderBy(
|
|
116
|
+
.where(CONVERSATION_FIELDS.BUYER_ID, "==", buyerId)
|
|
117
|
+
.orderBy(CONVERSATION_FIELDS.LAST_MESSAGE_AT, "desc")
|
|
117
118
|
.get();
|
|
118
119
|
return snap.docs.map((d) => normaliseDoc(d.id, d.data()));
|
|
119
120
|
}
|
|
120
121
|
async listByStore(storeId) {
|
|
121
122
|
const snap = await this.collection()
|
|
122
|
-
.where(
|
|
123
|
-
.orderBy(
|
|
123
|
+
.where(CONVERSATION_FIELDS.STORE_ID, "==", storeId)
|
|
124
|
+
.orderBy(CONVERSATION_FIELDS.LAST_MESSAGE_AT, "desc")
|
|
124
125
|
.get();
|
|
125
126
|
return snap.docs.map((d) => normaliseDoc(d.id, d.data()));
|
|
126
127
|
}
|
|
@@ -90,9 +90,9 @@ class OrderRepository extends BaseRepository {
|
|
|
90
90
|
const now = new Date();
|
|
91
91
|
const snapshot = await this.db
|
|
92
92
|
.collection(this.collection)
|
|
93
|
-
.where(
|
|
94
|
-
.where(
|
|
95
|
-
.orderBy(
|
|
93
|
+
.where(ORDER_FIELDS.USER_ID, "==", userId)
|
|
94
|
+
.where(ORDER_FIELDS.ORDER_DATE, ">=", new Date(now.getTime() - 90 * 24 * 60 * 60 * 1000))
|
|
95
|
+
.orderBy(ORDER_FIELDS.ORDER_DATE, "desc")
|
|
96
96
|
.get();
|
|
97
97
|
return snapshot.docs.map((doc) => this.decryptOrder({
|
|
98
98
|
id: doc.id,
|
|
@@ -147,7 +147,7 @@ class OrderRepository extends BaseRepository {
|
|
|
147
147
|
async deleteByUser(userId) {
|
|
148
148
|
try {
|
|
149
149
|
const snapshot = await this.getCollection()
|
|
150
|
-
.where(
|
|
150
|
+
.where(ORDER_FIELDS.USER_ID, "==", userId)
|
|
151
151
|
.get();
|
|
152
152
|
if (snapshot.empty)
|
|
153
153
|
return 0;
|
|
@@ -228,9 +228,9 @@ class OrderRepository extends BaseRepository {
|
|
|
228
228
|
cutoff.setHours(cutoff.getHours() - hours);
|
|
229
229
|
const snap = await this.db
|
|
230
230
|
.collection(this.collection)
|
|
231
|
-
.where(
|
|
232
|
-
.where(
|
|
233
|
-
.where(
|
|
231
|
+
.where(ORDER_FIELDS.STATUS, "==", OrderStatusValues.PENDING)
|
|
232
|
+
.where(ORDER_FIELDS.PAYMENT_STATUS, "==", "pending")
|
|
233
|
+
.where(ORDER_FIELDS.CREATED_AT, "<", cutoff)
|
|
234
234
|
.limit(500)
|
|
235
235
|
.get();
|
|
236
236
|
return snap.docs.map((d) => ({
|
|
@@ -245,9 +245,9 @@ class OrderRepository extends BaseRepository {
|
|
|
245
245
|
async getEligibleShiprocket() {
|
|
246
246
|
const snap = await this.db
|
|
247
247
|
.collection(this.collection)
|
|
248
|
-
.where(
|
|
249
|
-
.where(
|
|
250
|
-
.where(
|
|
248
|
+
.where(ORDER_FIELDS.PAYOUT_STATUS, "==", "eligible")
|
|
249
|
+
.where(ORDER_FIELDS.SHIPPING_METHOD, "==", "shiprocket")
|
|
250
|
+
.where(ORDER_FIELDS.STATUS, "==", OrderStatusValues.DELIVERED)
|
|
251
251
|
.limit(500)
|
|
252
252
|
.get();
|
|
253
253
|
return snap.docs.map((d) => ({
|
|
@@ -264,9 +264,9 @@ class OrderRepository extends BaseRepository {
|
|
|
264
264
|
async getEligibleAutomatic(cutoff) {
|
|
265
265
|
const snap = await this.db
|
|
266
266
|
.collection(this.collection)
|
|
267
|
-
.where(
|
|
268
|
-
.where(
|
|
269
|
-
.where(
|
|
267
|
+
.where(ORDER_FIELDS.PAYOUT_STATUS, "==", "eligible")
|
|
268
|
+
.where(ORDER_FIELDS.STATUS, "==", OrderStatusValues.DELIVERED)
|
|
269
|
+
.where(ORDER_FIELDS.UPDATED_AT, "<=", cutoff)
|
|
270
270
|
.limit(500)
|
|
271
271
|
.get();
|
|
272
272
|
return snap.docs.map((d) => ({
|
|
@@ -3,6 +3,7 @@ import { ERROR_MESSAGES } from "../../../errors/messages";
|
|
|
3
3
|
import { BaseRepository, prepareForFirestore, } from "../../../providers/db-firebase";
|
|
4
4
|
import { MAX_STORE_CUSTOM_FEATURES, PRODUCT_FEATURES_COLLECTION, PRODUCT_FEATURE_PREFIX, PRODUCT_FEATURE_SIEVE_FIELDS, } from "../schemas/product-features";
|
|
5
5
|
import { PRODUCT_COLLECTION } from "../schemas/firestore";
|
|
6
|
+
import { PRODUCT_FIELDS, COUPON_FIELDS } from "../../../constants/field-names";
|
|
6
7
|
function slugify(value) {
|
|
7
8
|
return value
|
|
8
9
|
.toLowerCase()
|
|
@@ -31,11 +32,11 @@ export class ProductFeaturesRepository extends BaseRepository {
|
|
|
31
32
|
try {
|
|
32
33
|
let q = this.getCollection();
|
|
33
34
|
if (filter.scope)
|
|
34
|
-
q = q.where(
|
|
35
|
+
q = q.where(COUPON_FIELDS.SCOPE, "==", filter.scope);
|
|
35
36
|
if (filter.storeId)
|
|
36
|
-
q = q.where(
|
|
37
|
+
q = q.where(PRODUCT_FIELDS.STORE_ID, "==", filter.storeId);
|
|
37
38
|
if (typeof filter.isActive === "boolean") {
|
|
38
|
-
q = q.where("isActive", "==", filter.isActive);
|
|
39
|
+
q = q.where("isActive", "==", filter.isActive); // audit-field-name-ok — product_features collection has no dedicated FIELDS constant
|
|
39
40
|
}
|
|
40
41
|
const snap = await q.get();
|
|
41
42
|
let docs = snap.docs.map((d) => this.mapDoc(d));
|
|
@@ -111,7 +112,7 @@ export class ProductFeaturesRepository extends BaseRepository {
|
|
|
111
112
|
try {
|
|
112
113
|
const referencing = await this.db
|
|
113
114
|
.collection(PRODUCT_COLLECTION)
|
|
114
|
-
.where(
|
|
115
|
+
.where(PRODUCT_FIELDS.FEATURES, "array-contains", id)
|
|
115
116
|
.limit(1)
|
|
116
117
|
.get();
|
|
117
118
|
if (!referencing.empty) {
|
|
@@ -128,8 +129,8 @@ export class ProductFeaturesRepository extends BaseRepository {
|
|
|
128
129
|
async countByStore(storeId) {
|
|
129
130
|
try {
|
|
130
131
|
const snap = await this.getCollection()
|
|
131
|
-
.where(
|
|
132
|
-
.where(
|
|
132
|
+
.where(COUPON_FIELDS.SCOPE, "==", "store")
|
|
133
|
+
.where(PRODUCT_FIELDS.STORE_ID, "==", storeId)
|
|
133
134
|
.get();
|
|
134
135
|
return snap.size;
|
|
135
136
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseRepository, prepareForFirestore, } from "../../../providers/db-firebase";
|
|
2
2
|
import { PRODUCT_TEMPLATE_COLLECTION, PRODUCT_TEMPLATE_PREFIX, } from "../schemas/product-templates";
|
|
3
|
+
import { PRODUCT_FIELDS } from "../../../constants/field-names";
|
|
3
4
|
function slugify(name) {
|
|
4
5
|
return name
|
|
5
6
|
.toLowerCase()
|
|
@@ -42,13 +43,13 @@ export class ProductTemplateRepository extends BaseRepository {
|
|
|
42
43
|
async findByStore(storeId) {
|
|
43
44
|
const snap = await this.db
|
|
44
45
|
.collection(this.collection)
|
|
45
|
-
.where(
|
|
46
|
-
.orderBy(
|
|
46
|
+
.where(PRODUCT_FIELDS.STORE_ID, "==", storeId)
|
|
47
|
+
.orderBy(PRODUCT_FIELDS.CREATED_AT, "desc")
|
|
47
48
|
.get();
|
|
48
49
|
return snap.docs.map((d) => this.mapDoc(d));
|
|
49
50
|
}
|
|
50
51
|
async listByStore(storeId, model) {
|
|
51
|
-
const baseQuery = this.getCollection().where(
|
|
52
|
+
const baseQuery = this.getCollection().where(PRODUCT_FIELDS.STORE_ID, "==", storeId);
|
|
52
53
|
return this.sieveQuery(model, {
|
|
53
54
|
name: { canFilter: true, canSort: true },
|
|
54
55
|
createdAt: { canFilter: false, canSort: true },
|
|
@@ -334,10 +334,10 @@ export class ProductRepository extends BaseRepository {
|
|
|
334
334
|
// Firestore cannot combine two array operators in one query
|
|
335
335
|
}
|
|
336
336
|
else if (searchTokens.length === 1) {
|
|
337
|
-
baseQuery = baseQuery.where(
|
|
337
|
+
baseQuery = baseQuery.where(PRODUCT_FIELDS.SEARCH_TOKENS, "array-contains", searchTokens[0]);
|
|
338
338
|
}
|
|
339
339
|
else if (searchTokens.length > 1) {
|
|
340
|
-
baseQuery = baseQuery.where(
|
|
340
|
+
baseQuery = baseQuery.where(PRODUCT_FIELDS.SEARCH_TOKENS, "array-contains-any", searchTokens);
|
|
341
341
|
}
|
|
342
342
|
if (searchTokens.length === 0 && opts?.categoriesIn && opts.categoriesIn.length > 0) {
|
|
343
343
|
baseQuery = baseQuery.where(PRODUCT_FIELDS.CATEGORY_SLUGS, "array-contains-any", opts.categoriesIn);
|
|
@@ -435,8 +435,8 @@ export class ProductRepository extends BaseRepository {
|
|
|
435
435
|
async getStaleDraftRefs(cutoff) {
|
|
436
436
|
const snap = await this.db
|
|
437
437
|
.collection(this.collection)
|
|
438
|
-
.where(
|
|
439
|
-
.where(
|
|
438
|
+
.where(PRODUCT_FIELDS.STATUS, "==", "draft")
|
|
439
|
+
.where(PRODUCT_FIELDS.UPDATED_AT, "<", cutoff)
|
|
440
440
|
.limit(200)
|
|
441
441
|
.get();
|
|
442
442
|
return snap.docs.map((d) => d.ref);
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { BaseRepository, prepareForFirestore, } from "../../../providers/db-firebase";
|
|
9
9
|
import { CLAIMED_COUPONS_COLLECTION, createClaimedCouponId, } from "../schemas";
|
|
10
10
|
import { DatabaseError } from "../../../errors";
|
|
11
|
+
import { COUPON_USAGE_FIELDS } from "../../../constants/field-names";
|
|
11
12
|
export class ClaimedCouponsRepository extends BaseRepository {
|
|
12
13
|
constructor() {
|
|
13
14
|
super(CLAIMED_COUPONS_COLLECTION);
|
|
@@ -49,7 +50,7 @@ export class ClaimedCouponsRepository extends BaseRepository {
|
|
|
49
50
|
try {
|
|
50
51
|
const snap = await this.db
|
|
51
52
|
.collection(this.collection)
|
|
52
|
-
.where(
|
|
53
|
+
.where(COUPON_USAGE_FIELDS.USER_ID, "==", userId)
|
|
53
54
|
.get();
|
|
54
55
|
const now = Date.now();
|
|
55
56
|
const rows = [];
|
|
@@ -97,8 +97,8 @@ export class CouponsRepository extends BaseRepository {
|
|
|
97
97
|
try {
|
|
98
98
|
const snapshot = await this.db
|
|
99
99
|
.collection(this.collection)
|
|
100
|
-
.where(
|
|
101
|
-
.orderBy(
|
|
100
|
+
.where(COUPON_FIELDS.TYPE, "==", type)
|
|
101
|
+
.orderBy(COUPON_FIELDS.CREATED_AT, "desc")
|
|
102
102
|
.get();
|
|
103
103
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
104
104
|
}
|
|
@@ -116,8 +116,8 @@ export class CouponsRepository extends BaseRepository {
|
|
|
116
116
|
try {
|
|
117
117
|
const snapshot = await this.db
|
|
118
118
|
.collection(this.collection)
|
|
119
|
-
.where(
|
|
120
|
-
.orderBy(
|
|
119
|
+
.where(COUPON_FIELDS.CREATED_BY, "==", userId)
|
|
120
|
+
.orderBy(COUPON_FIELDS.CREATED_AT, "desc")
|
|
121
121
|
.get();
|
|
122
122
|
return snapshot.docs.map((doc) => this.mapDoc(doc));
|
|
123
123
|
}
|