create-nextjs-cms 0.8.7 → 0.8.9
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/LICENSE +21 -21
- package/README.md +71 -71
- package/dist/helpers/utils.js +16 -16
- package/dist/lib/section-creators.js +166 -166
- package/package.json +3 -3
- package/templates/default/.eslintrc.json +5 -5
- package/templates/default/.prettierignore +7 -7
- package/templates/default/.prettierrc.json +27 -27
- package/templates/default/CHANGELOG.md +140 -140
- package/templates/default/_gitignore +57 -57
- package/templates/default/app/(auth)/auth/login/LoginPage.tsx +192 -192
- package/templates/default/app/(auth)/auth/login/page.tsx +11 -11
- package/templates/default/app/(auth)/auth-locale-provider.tsx +34 -34
- package/templates/default/app/(auth)/layout.tsx +81 -81
- package/templates/default/app/(rootLayout)/(plugins)/[...slug]/page.tsx +40 -40
- package/templates/default/app/(rootLayout)/(plugins)/[...slug]/plugin-server-registry.ts +16 -16
- package/templates/default/app/(rootLayout)/admins/page.tsx +10 -10
- package/templates/default/app/(rootLayout)/browse/[section]/[page]/page.tsx +22 -22
- package/templates/default/app/(rootLayout)/categorized/[section]/page.tsx +15 -15
- package/templates/default/app/(rootLayout)/dashboard/page.tsx +63 -63
- package/templates/default/app/(rootLayout)/dashboard-new/page.tsx +7 -7
- package/templates/default/app/(rootLayout)/edit/[section]/[itemId]/page.tsx +17 -17
- package/templates/default/app/(rootLayout)/layout.tsx +81 -81
- package/templates/default/app/(rootLayout)/loading.tsx +10 -10
- package/templates/default/app/(rootLayout)/log/page.tsx +7 -7
- package/templates/default/app/(rootLayout)/new/[section]/page.tsx +15 -15
- package/templates/default/app/(rootLayout)/section/[section]/page.tsx +16 -16
- package/templates/default/app/(rootLayout)/settings/page.tsx +13 -13
- package/templates/default/app/_trpc/client.ts +3 -3
- package/templates/default/app/api/auth/csrf/route.ts +25 -25
- package/templates/default/app/api/auth/refresh/route.ts +10 -10
- package/templates/default/app/api/auth/route.ts +49 -49
- package/templates/default/app/api/auth/session/route.ts +20 -20
- package/templates/default/app/api/document/route.ts +165 -165
- package/templates/default/app/api/editor/photo/route.ts +49 -49
- package/templates/default/app/api/photo/route.ts +27 -27
- package/templates/default/app/api/submit/section/item/[slug]/route.ts +66 -66
- package/templates/default/app/api/submit/section/item/route.ts +56 -56
- package/templates/default/app/api/submit/section/simple/route.ts +57 -57
- package/templates/default/app/api/trpc/[trpc]/route.ts +33 -33
- package/templates/default/app/api/video/route.ts +174 -174
- package/templates/default/app/globals.css +219 -219
- package/templates/default/app/providers.tsx +152 -152
- package/templates/default/cms.config.ts +57 -60
- package/templates/default/components/AdminCard.tsx +166 -166
- package/templates/default/components/AdminEditPage.tsx +124 -124
- package/templates/default/components/AdminPrivilegeCard.tsx +185 -185
- package/templates/default/components/AdminsPage.tsx +43 -43
- package/templates/default/components/AnalyticsPage.tsx +128 -128
- package/templates/default/components/BarChartBox.tsx +42 -42
- package/templates/default/components/BrowsePage.tsx +106 -106
- package/templates/default/components/CategorizedSectionPage.tsx +31 -31
- package/templates/default/components/CategoryDeleteConfirmPage.tsx +130 -130
- package/templates/default/components/CategorySectionSelectInput.tsx +140 -140
- package/templates/default/components/ConditionalFields.tsx +49 -49
- package/templates/default/components/ContainerBox.tsx +24 -24
- package/templates/default/components/DashboardNewPage.tsx +253 -253
- package/templates/default/components/DashboardPage.tsx +188 -188
- package/templates/default/components/DashboardPageAlt.tsx +45 -45
- package/templates/default/components/DefaultNavItems.tsx +3 -3
- package/templates/default/components/Dropzone.tsx +154 -154
- package/templates/default/components/EmailCard.tsx +138 -138
- package/templates/default/components/EmailPasswordForm.tsx +85 -85
- package/templates/default/components/EmailQuotaForm.tsx +73 -73
- package/templates/default/components/EmailsPage.tsx +49 -49
- package/templates/default/components/ErrorComponent.tsx +16 -16
- package/templates/default/components/GalleryPhoto.tsx +93 -93
- package/templates/default/components/InfoCard.tsx +93 -93
- package/templates/default/components/ItemEditPage.tsx +214 -214
- package/templates/default/components/Layout.tsx +84 -84
- package/templates/default/components/LoadingSpinners.tsx +67 -67
- package/templates/default/components/LogPage.tsx +107 -107
- package/templates/default/components/Modal.tsx +166 -166
- package/templates/default/components/Navbar.tsx +258 -258
- package/templates/default/components/NewAdminForm.tsx +173 -173
- package/templates/default/components/NewEmailForm.tsx +132 -132
- package/templates/default/components/NewPage.tsx +205 -205
- package/templates/default/components/NewVariantComponent.tsx +229 -229
- package/templates/default/components/PhotoGallery.tsx +35 -35
- package/templates/default/components/PieChartBox.tsx +101 -101
- package/templates/default/components/ProgressBar.tsx +48 -48
- package/templates/default/components/ProtectedDocument.tsx +44 -44
- package/templates/default/components/ProtectedImage.tsx +143 -143
- package/templates/default/components/ProtectedVideo.tsx +76 -76
- package/templates/default/components/SectionIcon.tsx +8 -8
- package/templates/default/components/SectionItemCard.tsx +144 -144
- package/templates/default/components/SectionItemStatusBadge.tsx +17 -17
- package/templates/default/components/SectionPage.tsx +125 -125
- package/templates/default/components/SelectBox.tsx +98 -98
- package/templates/default/components/SelectInputButtons.tsx +125 -125
- package/templates/default/components/SettingsPage.tsx +232 -232
- package/templates/default/components/Sidebar.tsx +204 -204
- package/templates/default/components/SidebarDropdownItem.tsx +83 -83
- package/templates/default/components/SidebarItem.tsx +24 -24
- package/templates/default/components/ThemeProvider.tsx +8 -8
- package/templates/default/components/TooltipComponent.tsx +27 -27
- package/templates/default/components/VariantCard.tsx +124 -124
- package/templates/default/components/VariantEditPage.tsx +230 -230
- package/templates/default/components/analytics/BounceRate.tsx +70 -70
- package/templates/default/components/analytics/LivePageViews.tsx +55 -55
- package/templates/default/components/analytics/LiveUsersCount.tsx +33 -33
- package/templates/default/components/analytics/MonthlyPageViews.tsx +42 -42
- package/templates/default/components/analytics/TopCountries.tsx +52 -52
- package/templates/default/components/analytics/TopDevices.tsx +46 -46
- package/templates/default/components/analytics/TopMediums.tsx +58 -58
- package/templates/default/components/analytics/TopSources.tsx +45 -45
- package/templates/default/components/analytics/TotalPageViews.tsx +41 -41
- package/templates/default/components/analytics/TotalSessions.tsx +41 -41
- package/templates/default/components/analytics/TotalUniqueUsers.tsx +41 -41
- package/templates/default/components/custom/RightHomeRoomVariantCard.tsx +138 -138
- package/templates/default/components/dndKit/Draggable.tsx +21 -21
- package/templates/default/components/dndKit/Droppable.tsx +20 -20
- package/templates/default/components/dndKit/SortableItem.tsx +18 -18
- package/templates/default/components/form/DateRangeFormInput.tsx +57 -57
- package/templates/default/components/form/Form.tsx +317 -317
- package/templates/default/components/form/FormInputElement.tsx +70 -70
- package/templates/default/components/form/FormInputs.tsx +118 -118
- package/templates/default/components/form/helpers/_section-hot-reload.js +1 -1
- package/templates/default/components/form/helpers/util.ts +17 -17
- package/templates/default/components/form/inputs/CheckboxFormInput.tsx +46 -46
- package/templates/default/components/form/inputs/ColorFormInput.tsx +44 -44
- package/templates/default/components/form/inputs/DateFormInput.tsx +156 -156
- package/templates/default/components/form/inputs/DocumentFormInput.tsx +222 -222
- package/templates/default/components/form/inputs/MapFormInput.tsx +140 -140
- package/templates/default/components/form/inputs/MultipleSelectFormInput.tsx +85 -85
- package/templates/default/components/form/inputs/NumberFormInput.tsx +42 -42
- package/templates/default/components/form/inputs/PasswordFormInput.tsx +47 -47
- package/templates/default/components/form/inputs/PhotoFormInput.tsx +219 -219
- package/templates/default/components/form/inputs/RichTextFormInput.tsx +135 -135
- package/templates/default/components/form/inputs/SelectFormInput.tsx +175 -175
- package/templates/default/components/form/inputs/SlugFormInput.tsx +131 -131
- package/templates/default/components/form/inputs/TagsFormInput.tsx +260 -260
- package/templates/default/components/form/inputs/TextFormInput.tsx +48 -48
- package/templates/default/components/form/inputs/TextareaFormInput.tsx +47 -47
- package/templates/default/components/form/inputs/VideoFormInput.tsx +118 -118
- package/templates/default/components/locale-dropdown.tsx +74 -74
- package/templates/default/components/locale-picker.tsx +85 -85
- package/templates/default/components/login-locale-dropdown.tsx +46 -46
- package/templates/default/components/multi-select.tsx +1146 -1146
- package/templates/default/components/pagination/Pagination.tsx +36 -36
- package/templates/default/components/pagination/PaginationButtons.tsx +147 -147
- package/templates/default/components/theme-toggle.tsx +39 -39
- package/templates/default/components/ui/accordion.tsx +53 -53
- package/templates/default/components/ui/alert-dialog.tsx +157 -157
- package/templates/default/components/ui/alert.tsx +46 -46
- package/templates/default/components/ui/badge.tsx +38 -38
- package/templates/default/components/ui/button.tsx +62 -62
- package/templates/default/components/ui/calendar.tsx +166 -166
- package/templates/default/components/ui/card.tsx +43 -43
- package/templates/default/components/ui/checkbox.tsx +29 -29
- package/templates/default/components/ui/command.tsx +137 -137
- package/templates/default/components/ui/custom-alert-dialog.tsx +113 -113
- package/templates/default/components/ui/custom-dialog.tsx +123 -123
- package/templates/default/components/ui/dialog.tsx +123 -123
- package/templates/default/components/ui/direction.tsx +22 -22
- package/templates/default/components/ui/dropdown-menu.tsx +182 -182
- package/templates/default/components/ui/input-group.tsx +54 -54
- package/templates/default/components/ui/input.tsx +22 -22
- package/templates/default/components/ui/label.tsx +19 -19
- package/templates/default/components/ui/popover.tsx +42 -42
- package/templates/default/components/ui/progress.tsx +31 -31
- package/templates/default/components/ui/scroll-area.tsx +42 -42
- package/templates/default/components/ui/select.tsx +165 -165
- package/templates/default/components/ui/separator.tsx +28 -28
- package/templates/default/components/ui/sheet.tsx +103 -103
- package/templates/default/components/ui/spinner.tsx +16 -16
- package/templates/default/components/ui/switch.tsx +29 -29
- package/templates/default/components/ui/table.tsx +83 -83
- package/templates/default/components/ui/tabs.tsx +55 -55
- package/templates/default/components/ui/toast.tsx +113 -113
- package/templates/default/components/ui/toaster.tsx +35 -35
- package/templates/default/components/ui/tooltip.tsx +30 -30
- package/templates/default/components/ui/use-toast.ts +188 -188
- package/templates/default/components.json +21 -21
- package/templates/default/context/ModalProvider.tsx +53 -53
- package/templates/default/drizzle.config.ts +4 -4
- package/templates/default/dynamic-schemas/schema.ts +84 -19
- package/templates/default/env/env.js +130 -130
- package/templates/default/envConfig.ts +4 -4
- package/templates/default/hooks/useModal.ts +8 -8
- package/templates/default/lib/apiHelpers.ts +92 -92
- package/templates/default/lib/postinstall.js +14 -14
- package/templates/default/lib/utils.ts +6 -6
- package/templates/default/next-env.d.ts +6 -6
- package/templates/default/next.config.ts +23 -23
- package/templates/default/package.json +1 -1
- package/templates/default/postcss.config.mjs +6 -6
- package/templates/default/proxy.ts +32 -32
- package/templates/default/tsconfig.json +48 -48
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {mysqlTable,int,longtext,mysqlEnum,varchar,boolean,double,timestamp} from 'drizzle-orm/mysql-core'
|
|
1
|
+
import {mysqlTable,int,longtext,mysqlEnum,varchar,index,unique,boolean,double,timestamp} from 'drizzle-orm/mysql-core'
|
|
2
2
|
|
|
3
3
|
export const AppInfoTable = mysqlTable('app_info', {
|
|
4
4
|
id: int('id').autoincrement().notNull().primaryKey(),
|
|
@@ -21,7 +21,24 @@ export const UserReportsTable = mysqlTable('user_reports', {
|
|
|
21
21
|
appId: varchar('app_id', { length: 36 }).notNull(),
|
|
22
22
|
title: varchar('title', { length: 255 }).notNull(),
|
|
23
23
|
slug: varchar('slug', { length: 255 }).notNull()
|
|
24
|
-
})
|
|
24
|
+
}, (table) => [
|
|
25
|
+
index('unique_user_report_index').on(table.contentType, table.contentId, table.catId, table.appId),
|
|
26
|
+
unique('unique_user_report').on(table.contentType, table.contentId, table.catId, table.appId),
|
|
27
|
+
unique('slug_unique').on(table.slug)
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export const TestSectionTable = mysqlTable('test_section', {
|
|
32
|
+
id: int('id').autoincrement().notNull().primaryKey(),
|
|
33
|
+
contentType: mysqlEnum('content_type', ['ad', 'user']).notNull(),
|
|
34
|
+
price: int('price'),
|
|
35
|
+
appId: varchar('app_id', { length: 36 }).notNull(),
|
|
36
|
+
title: varchar('title', { length: 255 }).notNull()
|
|
37
|
+
}, (table) => [
|
|
38
|
+
index('unique_user_report_index').on(table.contentType, table.price, table.appId),
|
|
39
|
+
unique('unique_user_report').on(table.contentType, table.price, table.appId),
|
|
40
|
+
unique('price_unique').on(table.price)
|
|
41
|
+
]);
|
|
25
42
|
|
|
26
43
|
|
|
27
44
|
export const FeaturedSliderTable = mysqlTable('featured_slider', {
|
|
@@ -33,7 +50,11 @@ export const FeaturedSliderTable = mysqlTable('featured_slider', {
|
|
|
33
50
|
descEn: longtext('desc_en').notNull(),
|
|
34
51
|
descAr: longtext('desc_ar').notNull(),
|
|
35
52
|
descTr: longtext('desc_tr').notNull()
|
|
36
|
-
})
|
|
53
|
+
}, (table) => [
|
|
54
|
+
unique('title_en_unique').on(table.titleEn),
|
|
55
|
+
unique('title_ar_unique').on(table.titleAr),
|
|
56
|
+
unique('title_tr_unique').on(table.titleTr)
|
|
57
|
+
]);
|
|
37
58
|
|
|
38
59
|
|
|
39
60
|
export const MenuSettingsTable = mysqlTable('menu_settings', {
|
|
@@ -60,7 +81,10 @@ export const ServicesTable = mysqlTable('services', {
|
|
|
60
81
|
districtId: int('district_id').notNull(),
|
|
61
82
|
subDistrictId: int('sub_district_id'),
|
|
62
83
|
townId: int('town_id')
|
|
63
|
-
})
|
|
84
|
+
}, (table) => [
|
|
85
|
+
index('title_index').on(table.title),
|
|
86
|
+
unique('title_unique').on(table.title)
|
|
87
|
+
]);
|
|
64
88
|
|
|
65
89
|
|
|
66
90
|
export const RealestateTable = mysqlTable('realestate', {
|
|
@@ -100,7 +124,10 @@ export const RealestateTable = mysqlTable('realestate', {
|
|
|
100
124
|
districtId: int('district_id').notNull(),
|
|
101
125
|
subDistrictId: int('sub_district_id'),
|
|
102
126
|
townId: int('town_id')
|
|
103
|
-
})
|
|
127
|
+
}, (table) => [
|
|
128
|
+
index('title_index').on(table.title),
|
|
129
|
+
unique('title_unique').on(table.title)
|
|
130
|
+
]);
|
|
104
131
|
|
|
105
132
|
|
|
106
133
|
export const HomepageSliderTable = mysqlTable('homepage_slider', {
|
|
@@ -124,7 +151,9 @@ export const ContestSubscribersTable = mysqlTable('contest_subscribers', {
|
|
|
124
151
|
id: int('id').autoincrement().notNull().primaryKey(),
|
|
125
152
|
userId: int('user_id').notNull(),
|
|
126
153
|
contestId: varchar('contest_id', { length: 255 }).notNull()
|
|
127
|
-
})
|
|
154
|
+
}, (table) => [
|
|
155
|
+
unique('contest_subscriber_unique').on(table.contestId, table.userId)
|
|
156
|
+
]);
|
|
128
157
|
|
|
129
158
|
|
|
130
159
|
export const ContestsTable = mysqlTable('contests', {
|
|
@@ -143,7 +172,10 @@ export const NotificationsTable = mysqlTable('notifications', {
|
|
|
143
172
|
contentCatId: int('content_cat_id'),
|
|
144
173
|
userId: int('user_id'),
|
|
145
174
|
message: varchar('message', { length: 255 })
|
|
146
|
-
})
|
|
175
|
+
}, (table) => [
|
|
176
|
+
index('type_index').on(table.type),
|
|
177
|
+
unique('unique_notification').on(table.type, table.contentId, table.contentCatId)
|
|
178
|
+
]);
|
|
147
179
|
|
|
148
180
|
|
|
149
181
|
export const ModerationTable = mysqlTable('moderation', {
|
|
@@ -154,7 +186,10 @@ export const ModerationTable = mysqlTable('moderation', {
|
|
|
154
186
|
userId: int('user_id').notNull(),
|
|
155
187
|
flagged: int('flagged').notNull(),
|
|
156
188
|
result: varchar('result', { length: 255 }).notNull()
|
|
157
|
-
})
|
|
189
|
+
}, (table) => [
|
|
190
|
+
index('unique_user_report_index').on(table.contentType, table.contentId, table.catId, table.userId),
|
|
191
|
+
unique('unique_user_report').on(table.contentType, table.contentId, table.catId, table.userId)
|
|
192
|
+
]);
|
|
158
193
|
|
|
159
194
|
|
|
160
195
|
export const JobsTable = mysqlTable('jobs', {
|
|
@@ -178,7 +213,10 @@ export const JobsTable = mysqlTable('jobs', {
|
|
|
178
213
|
districtId: int('district_id').notNull(),
|
|
179
214
|
subDistrictId: int('sub_district_id'),
|
|
180
215
|
townId: int('town_id')
|
|
181
|
-
})
|
|
216
|
+
}, (table) => [
|
|
217
|
+
index('title_index').on(table.title),
|
|
218
|
+
unique('title_unique').on(table.title)
|
|
219
|
+
]);
|
|
182
220
|
|
|
183
221
|
|
|
184
222
|
export const FurnitureTable = mysqlTable('furniture', {
|
|
@@ -201,7 +239,10 @@ export const FurnitureTable = mysqlTable('furniture', {
|
|
|
201
239
|
districtId: int('district_id').notNull(),
|
|
202
240
|
subDistrictId: int('sub_district_id'),
|
|
203
241
|
townId: int('town_id')
|
|
204
|
-
})
|
|
242
|
+
}, (table) => [
|
|
243
|
+
index('title_index').on(table.title),
|
|
244
|
+
unique('title_unique').on(table.title)
|
|
245
|
+
]);
|
|
205
246
|
|
|
206
247
|
|
|
207
248
|
export const FiltersTable = mysqlTable('filters', {
|
|
@@ -212,7 +253,10 @@ export const FiltersTable = mysqlTable('filters', {
|
|
|
212
253
|
type: mysqlEnum('type', ['checkbox', 'select', 'text', 'finance', 'number', 'point']).notNull(),
|
|
213
254
|
tableName: varchar('table_name', { length: 255 }),
|
|
214
255
|
isMandatory: boolean('is_mandatory')
|
|
215
|
-
})
|
|
256
|
+
}, (table) => [
|
|
257
|
+
unique('title_unique').on(table.title),
|
|
258
|
+
unique('key_unique').on(table.Key)
|
|
259
|
+
]);
|
|
216
260
|
|
|
217
261
|
|
|
218
262
|
export const FaqTable = mysqlTable('faq', {
|
|
@@ -223,7 +267,11 @@ export const FaqTable = mysqlTable('faq', {
|
|
|
223
267
|
aEn: longtext('a_en').notNull(),
|
|
224
268
|
aAr: longtext('a_ar'),
|
|
225
269
|
aTr: longtext('a_tr')
|
|
226
|
-
})
|
|
270
|
+
}, (table) => [
|
|
271
|
+
unique('faq_q_en_unique').on(table.qEn),
|
|
272
|
+
unique('title_ar_unique').on(table.qAr),
|
|
273
|
+
unique('title_tr_unique').on(table.qTr)
|
|
274
|
+
]);
|
|
227
275
|
|
|
228
276
|
|
|
229
277
|
export const ErrorsTable = mysqlTable('errors', {
|
|
@@ -234,7 +282,9 @@ export const ErrorsTable = mysqlTable('errors', {
|
|
|
234
282
|
itemSlug: varchar('item_slug', { length: 255 }),
|
|
235
283
|
desc: longtext('desc'),
|
|
236
284
|
isResolved: boolean('is_resolved')
|
|
237
|
-
})
|
|
285
|
+
}, (table) => [
|
|
286
|
+
unique('key_unique').on(table.caseId)
|
|
287
|
+
]);
|
|
238
288
|
|
|
239
289
|
|
|
240
290
|
export const ElectronicsTable = mysqlTable('electronics', {
|
|
@@ -258,7 +308,10 @@ export const ElectronicsTable = mysqlTable('electronics', {
|
|
|
258
308
|
districtId: int('district_id').notNull(),
|
|
259
309
|
subDistrictId: int('sub_district_id'),
|
|
260
310
|
townId: int('town_id')
|
|
261
|
-
})
|
|
311
|
+
}, (table) => [
|
|
312
|
+
index('title_index').on(table.title),
|
|
313
|
+
unique('title_unique').on(table.title)
|
|
314
|
+
]);
|
|
262
315
|
|
|
263
316
|
|
|
264
317
|
export const ClothesTable = mysqlTable('clothes', {
|
|
@@ -281,7 +334,10 @@ export const ClothesTable = mysqlTable('clothes', {
|
|
|
281
334
|
districtId: int('district_id').notNull(),
|
|
282
335
|
subDistrictId: int('sub_district_id'),
|
|
283
336
|
townId: int('town_id')
|
|
284
|
-
})
|
|
337
|
+
}, (table) => [
|
|
338
|
+
index('title_index').on(table.title),
|
|
339
|
+
unique('title_unique').on(table.title)
|
|
340
|
+
]);
|
|
285
341
|
|
|
286
342
|
|
|
287
343
|
export const CatsTable = mysqlTable('cats', {
|
|
@@ -303,7 +359,9 @@ export const CatsTable = mysqlTable('cats', {
|
|
|
303
359
|
adCount: int('ad_count'),
|
|
304
360
|
parentId: int('parent_id'),
|
|
305
361
|
level: int('level')
|
|
306
|
-
})
|
|
362
|
+
}, (table) => [
|
|
363
|
+
unique('cats_slug_unique').on(table.slug)
|
|
364
|
+
]);
|
|
307
365
|
|
|
308
366
|
|
|
309
367
|
export const CarsTable = mysqlTable('cars', {
|
|
@@ -335,7 +393,9 @@ export const CarsTable = mysqlTable('cars', {
|
|
|
335
393
|
longitude: double('longitude'),
|
|
336
394
|
viewCount: int('view_count'),
|
|
337
395
|
status: mysqlEnum('status', ['pending_creation', 'active', 'pending_review', 'rejected', 'expired'])
|
|
338
|
-
})
|
|
396
|
+
}, (table) => [
|
|
397
|
+
index('title_index').on(table.title)
|
|
398
|
+
]);
|
|
339
399
|
|
|
340
400
|
|
|
341
401
|
export const CarsDbTable = mysqlTable('cars_db', {
|
|
@@ -343,7 +403,9 @@ export const CarsDbTable = mysqlTable('cars_db', {
|
|
|
343
403
|
name: varchar('name', { length: 255 }).notNull(),
|
|
344
404
|
parentId: int('parent_id'),
|
|
345
405
|
level: int('level')
|
|
346
|
-
})
|
|
406
|
+
}, (table) => [
|
|
407
|
+
index('cars_db_name_idx').on(table.name)
|
|
408
|
+
]);
|
|
347
409
|
|
|
348
410
|
|
|
349
411
|
export const BooksTable = mysqlTable('books', {
|
|
@@ -366,7 +428,10 @@ export const BooksTable = mysqlTable('books', {
|
|
|
366
428
|
districtId: int('district_id').notNull(),
|
|
367
429
|
subDistrictId: int('sub_district_id'),
|
|
368
430
|
townId: int('town_id')
|
|
369
|
-
})
|
|
431
|
+
}, (table) => [
|
|
432
|
+
index('title_index').on(table.title),
|
|
433
|
+
unique('title_unique').on(table.title)
|
|
434
|
+
]);
|
|
370
435
|
|
|
371
436
|
|
|
372
437
|
export const AddressTable = mysqlTable('address', {
|
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
import * as z from 'zod'
|
|
2
|
-
import { object } from 'zod';
|
|
3
|
-
|
|
4
|
-
function createEnv$1(opts) {
|
|
5
|
-
const runtimeEnv = opts.runtimeEnvStrict ?? opts.runtimeEnv ?? process.env;
|
|
6
|
-
const emptyStringAsUndefined = opts.emptyStringAsUndefined ?? false;
|
|
7
|
-
if (emptyStringAsUndefined) {
|
|
8
|
-
for (const [key, value] of Object.entries(runtimeEnv)){
|
|
9
|
-
if (value === "") {
|
|
10
|
-
delete runtimeEnv[key];
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const skip = !!opts.skipValidation;
|
|
15
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
16
|
-
if (skip) return runtimeEnv;
|
|
17
|
-
const _client = typeof opts.client === "object" ? opts.client : {};
|
|
18
|
-
const _server = typeof opts.server === "object" ? opts.server : {};
|
|
19
|
-
const _shared = typeof opts.shared === "object" ? opts.shared : {};
|
|
20
|
-
const client = object(_client);
|
|
21
|
-
const server = object(_server);
|
|
22
|
-
const shared = object(_shared);
|
|
23
|
-
const isServer = opts.isServer ?? (typeof window === "undefined" || "Deno" in window);
|
|
24
|
-
const allClient = client.merge(shared);
|
|
25
|
-
const allServer = server.merge(shared).merge(client);
|
|
26
|
-
const parsed = isServer ? allServer.safeParse(runtimeEnv) // on server we can validate all env vars
|
|
27
|
-
: allClient.safeParse(runtimeEnv); // on client we can only validate the ones that are exposed
|
|
28
|
-
const onValidationError = opts.onValidationError ?? ((error)=>{
|
|
29
|
-
console.error("❌ Invalid environment variables:", error.flatten().fieldErrors);
|
|
30
|
-
throw new Error("Invalid environment variables");
|
|
31
|
-
});
|
|
32
|
-
const onInvalidAccess = opts.onInvalidAccess ?? ((_variable)=>{
|
|
33
|
-
throw new Error("❌ Attempted to access a server-side environment variable on the client");
|
|
34
|
-
});
|
|
35
|
-
if (parsed.success === false) {
|
|
36
|
-
return onValidationError(parsed.error);
|
|
37
|
-
}
|
|
38
|
-
const isServerAccess = (prop)=>{
|
|
39
|
-
if (!opts.clientPrefix) return true;
|
|
40
|
-
return !prop.startsWith(opts.clientPrefix) && !(prop in shared.shape);
|
|
41
|
-
};
|
|
42
|
-
const isValidServerAccess = (prop)=>{
|
|
43
|
-
return isServer || !isServerAccess(prop);
|
|
44
|
-
};
|
|
45
|
-
const ignoreProp = (prop)=>{
|
|
46
|
-
return prop === "__esModule" || prop === "$$typeof";
|
|
47
|
-
};
|
|
48
|
-
const extendedObj = (opts.extends ?? []).reduce((acc, curr)=>{
|
|
49
|
-
return Object.assign(acc, curr);
|
|
50
|
-
}, {});
|
|
51
|
-
const fullObj = Object.assign(parsed.data, extendedObj);
|
|
52
|
-
const env = new Proxy(fullObj, {
|
|
53
|
-
get (target, prop) {
|
|
54
|
-
if (typeof prop !== "string") return undefined;
|
|
55
|
-
if (ignoreProp(prop)) return undefined;
|
|
56
|
-
if (!isValidServerAccess(prop)) return onInvalidAccess(prop);
|
|
57
|
-
return Reflect.get(target, prop);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
61
|
-
return env;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const CLIENT_PREFIX = "NEXT_PUBLIC_";
|
|
65
|
-
function createEnv(opts) {
|
|
66
|
-
const client = typeof opts.client === "object" ? opts.client : {};
|
|
67
|
-
const server = typeof opts.server === "object" ? opts.server : {};
|
|
68
|
-
const shared = opts.shared;
|
|
69
|
-
const runtimeEnv = opts.runtimeEnv ? opts.runtimeEnv : {
|
|
70
|
-
...process.env,
|
|
71
|
-
...opts.experimental__runtimeEnv
|
|
72
|
-
};
|
|
73
|
-
return createEnv$1({
|
|
74
|
-
...opts,
|
|
75
|
-
shared,
|
|
76
|
-
client,
|
|
77
|
-
server,
|
|
78
|
-
clientPrefix: CLIENT_PREFIX,
|
|
79
|
-
runtimeEnv
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const env = createEnv({
|
|
84
|
-
/**
|
|
85
|
-
* Specify your server-side environment variables schema here. This way you can ensure the app
|
|
86
|
-
* isn't built with invalid env vars.
|
|
87
|
-
*/
|
|
88
|
-
server: {
|
|
89
|
-
ACCESS_TOKEN_SECRET: z.string(),
|
|
90
|
-
REFRESH_TOKEN_SECRET: z.string(),
|
|
91
|
-
CSRF_TOKEN_SECRET: z.string(),
|
|
92
|
-
ACCESS_TOKEN_EXPIRATION: z.string(),
|
|
93
|
-
REFRESH_TOKEN_EXPIRATION: z.string(),
|
|
94
|
-
NODE_ENV: z
|
|
95
|
-
.enum(["development", "test", "production"])
|
|
96
|
-
.default("development"),
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Specify your client-side environment variables schema here. This way you can ensure the app
|
|
101
|
-
* isn't built with invalid env vars. To expose them to the client, prefix them with
|
|
102
|
-
* `NEXT_PUBLIC_`.
|
|
103
|
-
*/
|
|
104
|
-
client: {
|
|
105
|
-
NEXT_PUBLIC_RICHTEXT_INLINE_PUBLIC_URL: z.string().optional(),
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
|
|
110
|
-
* middlewares) or client-side so we need to destruct manually.
|
|
111
|
-
*/
|
|
112
|
-
runtimeEnv: {
|
|
113
|
-
ACCESS_TOKEN_SECRET: process.env.ACCESS_TOKEN_SECRET,
|
|
114
|
-
REFRESH_TOKEN_SECRET: process.env.REFRESH_TOKEN_SECRET,
|
|
115
|
-
CSRF_TOKEN_SECRET: process.env.CSRF_TOKEN_SECRET,
|
|
116
|
-
ACCESS_TOKEN_EXPIRATION: process.env.ACCESS_TOKEN_EXPIRATION,
|
|
117
|
-
REFRESH_TOKEN_EXPIRATION: process.env.REFRESH_TOKEN_EXPIRATION,
|
|
118
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
119
|
-
},
|
|
120
|
-
/**
|
|
121
|
-
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
|
|
122
|
-
* useful for Docker builds.
|
|
123
|
-
*/
|
|
124
|
-
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
|
125
|
-
/**
|
|
126
|
-
* Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
|
|
127
|
-
* `SOME_VAR=''` will throw an error.
|
|
128
|
-
*/
|
|
129
|
-
emptyStringAsUndefined: true,
|
|
130
|
-
});
|
|
1
|
+
import * as z from 'zod'
|
|
2
|
+
import { object } from 'zod';
|
|
3
|
+
|
|
4
|
+
function createEnv$1(opts) {
|
|
5
|
+
const runtimeEnv = opts.runtimeEnvStrict ?? opts.runtimeEnv ?? process.env;
|
|
6
|
+
const emptyStringAsUndefined = opts.emptyStringAsUndefined ?? false;
|
|
7
|
+
if (emptyStringAsUndefined) {
|
|
8
|
+
for (const [key, value] of Object.entries(runtimeEnv)){
|
|
9
|
+
if (value === "") {
|
|
10
|
+
delete runtimeEnv[key];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const skip = !!opts.skipValidation;
|
|
15
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
16
|
+
if (skip) return runtimeEnv;
|
|
17
|
+
const _client = typeof opts.client === "object" ? opts.client : {};
|
|
18
|
+
const _server = typeof opts.server === "object" ? opts.server : {};
|
|
19
|
+
const _shared = typeof opts.shared === "object" ? opts.shared : {};
|
|
20
|
+
const client = object(_client);
|
|
21
|
+
const server = object(_server);
|
|
22
|
+
const shared = object(_shared);
|
|
23
|
+
const isServer = opts.isServer ?? (typeof window === "undefined" || "Deno" in window);
|
|
24
|
+
const allClient = client.merge(shared);
|
|
25
|
+
const allServer = server.merge(shared).merge(client);
|
|
26
|
+
const parsed = isServer ? allServer.safeParse(runtimeEnv) // on server we can validate all env vars
|
|
27
|
+
: allClient.safeParse(runtimeEnv); // on client we can only validate the ones that are exposed
|
|
28
|
+
const onValidationError = opts.onValidationError ?? ((error)=>{
|
|
29
|
+
console.error("❌ Invalid environment variables:", error.flatten().fieldErrors);
|
|
30
|
+
throw new Error("Invalid environment variables");
|
|
31
|
+
});
|
|
32
|
+
const onInvalidAccess = opts.onInvalidAccess ?? ((_variable)=>{
|
|
33
|
+
throw new Error("❌ Attempted to access a server-side environment variable on the client");
|
|
34
|
+
});
|
|
35
|
+
if (parsed.success === false) {
|
|
36
|
+
return onValidationError(parsed.error);
|
|
37
|
+
}
|
|
38
|
+
const isServerAccess = (prop)=>{
|
|
39
|
+
if (!opts.clientPrefix) return true;
|
|
40
|
+
return !prop.startsWith(opts.clientPrefix) && !(prop in shared.shape);
|
|
41
|
+
};
|
|
42
|
+
const isValidServerAccess = (prop)=>{
|
|
43
|
+
return isServer || !isServerAccess(prop);
|
|
44
|
+
};
|
|
45
|
+
const ignoreProp = (prop)=>{
|
|
46
|
+
return prop === "__esModule" || prop === "$$typeof";
|
|
47
|
+
};
|
|
48
|
+
const extendedObj = (opts.extends ?? []).reduce((acc, curr)=>{
|
|
49
|
+
return Object.assign(acc, curr);
|
|
50
|
+
}, {});
|
|
51
|
+
const fullObj = Object.assign(parsed.data, extendedObj);
|
|
52
|
+
const env = new Proxy(fullObj, {
|
|
53
|
+
get (target, prop) {
|
|
54
|
+
if (typeof prop !== "string") return undefined;
|
|
55
|
+
if (ignoreProp(prop)) return undefined;
|
|
56
|
+
if (!isValidServerAccess(prop)) return onInvalidAccess(prop);
|
|
57
|
+
return Reflect.get(target, prop);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
61
|
+
return env;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const CLIENT_PREFIX = "NEXT_PUBLIC_";
|
|
65
|
+
function createEnv(opts) {
|
|
66
|
+
const client = typeof opts.client === "object" ? opts.client : {};
|
|
67
|
+
const server = typeof opts.server === "object" ? opts.server : {};
|
|
68
|
+
const shared = opts.shared;
|
|
69
|
+
const runtimeEnv = opts.runtimeEnv ? opts.runtimeEnv : {
|
|
70
|
+
...process.env,
|
|
71
|
+
...opts.experimental__runtimeEnv
|
|
72
|
+
};
|
|
73
|
+
return createEnv$1({
|
|
74
|
+
...opts,
|
|
75
|
+
shared,
|
|
76
|
+
client,
|
|
77
|
+
server,
|
|
78
|
+
clientPrefix: CLIENT_PREFIX,
|
|
79
|
+
runtimeEnv
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const env = createEnv({
|
|
84
|
+
/**
|
|
85
|
+
* Specify your server-side environment variables schema here. This way you can ensure the app
|
|
86
|
+
* isn't built with invalid env vars.
|
|
87
|
+
*/
|
|
88
|
+
server: {
|
|
89
|
+
ACCESS_TOKEN_SECRET: z.string(),
|
|
90
|
+
REFRESH_TOKEN_SECRET: z.string(),
|
|
91
|
+
CSRF_TOKEN_SECRET: z.string(),
|
|
92
|
+
ACCESS_TOKEN_EXPIRATION: z.string(),
|
|
93
|
+
REFRESH_TOKEN_EXPIRATION: z.string(),
|
|
94
|
+
NODE_ENV: z
|
|
95
|
+
.enum(["development", "test", "production"])
|
|
96
|
+
.default("development"),
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Specify your client-side environment variables schema here. This way you can ensure the app
|
|
101
|
+
* isn't built with invalid env vars. To expose them to the client, prefix them with
|
|
102
|
+
* `NEXT_PUBLIC_`.
|
|
103
|
+
*/
|
|
104
|
+
client: {
|
|
105
|
+
NEXT_PUBLIC_RICHTEXT_INLINE_PUBLIC_URL: z.string().optional(),
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
|
|
110
|
+
* middlewares) or client-side so we need to destruct manually.
|
|
111
|
+
*/
|
|
112
|
+
runtimeEnv: {
|
|
113
|
+
ACCESS_TOKEN_SECRET: process.env.ACCESS_TOKEN_SECRET,
|
|
114
|
+
REFRESH_TOKEN_SECRET: process.env.REFRESH_TOKEN_SECRET,
|
|
115
|
+
CSRF_TOKEN_SECRET: process.env.CSRF_TOKEN_SECRET,
|
|
116
|
+
ACCESS_TOKEN_EXPIRATION: process.env.ACCESS_TOKEN_EXPIRATION,
|
|
117
|
+
REFRESH_TOKEN_EXPIRATION: process.env.REFRESH_TOKEN_EXPIRATION,
|
|
118
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
|
|
122
|
+
* useful for Docker builds.
|
|
123
|
+
*/
|
|
124
|
+
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
|
125
|
+
/**
|
|
126
|
+
* Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
|
|
127
|
+
* `SOME_VAR=''` will throw an error.
|
|
128
|
+
*/
|
|
129
|
+
emptyStringAsUndefined: true,
|
|
130
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadEnvConfig } from '@next/env'
|
|
2
|
-
|
|
3
|
-
const projectDir = process.cwd()
|
|
4
|
-
loadEnvConfig(projectDir)
|
|
1
|
+
import { loadEnvConfig } from '@next/env'
|
|
2
|
+
|
|
3
|
+
const projectDir = process.cwd()
|
|
4
|
+
loadEnvConfig(projectDir)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useContext } from 'react'
|
|
2
|
-
import ModalContext from '@/context/ModalProvider'
|
|
3
|
-
|
|
4
|
-
const useModal = () => {
|
|
5
|
-
return useContext(ModalContext)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default useModal
|
|
1
|
+
import { useContext } from 'react'
|
|
2
|
+
import ModalContext from '@/context/ModalProvider'
|
|
3
|
+
|
|
4
|
+
const useModal = () => {
|
|
5
|
+
return useContext(ModalContext)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default useModal
|