@infuro/cms-core 1.0.29 → 1.0.31
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/README.md +17 -13
- package/dist/admin.cjs +8522 -3281
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.d.cts +13 -2
- package/dist/admin.d.ts +13 -2
- package/dist/admin.js +8210 -2957
- package/dist/admin.js.map +1 -1
- package/dist/api.cjs +5099 -1167
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +2 -2
- package/dist/api.d.ts +2 -2
- package/dist/api.js +4847 -909
- package/dist/api.js.map +1 -1
- package/dist/auth.cjs +461 -62
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +73 -47
- package/dist/auth.d.ts +73 -47
- package/dist/auth.js +425 -38
- package/dist/auth.js.map +1 -1
- package/dist/cli.cjs +21 -14
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +21 -14
- package/dist/cli.js.map +1 -1
- package/dist/{index-D9SdaDJ0.d.ts → index-BcMRGNjS.d.cts} +36 -3
- package/dist/{index-BPQSXgXF.d.cts → index-Bda8D1Rm.d.ts} +36 -3
- package/dist/index.cjs +4753 -740
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +301 -36
- package/dist/index.d.ts +301 -36
- package/dist/index.js +4750 -768
- package/dist/index.js.map +1 -1
- package/dist/migrations/1775400000001-AddDiscountAndOrderAddresses.ts +274 -0
- package/dist/migrations/1775800000000-VendorsAndVendorUsers.ts +74 -0
- package/dist/migrations/1775900000000-StoreVendorIdColumns.ts +124 -0
- package/dist/migrations/1775910000000-VendorOwnerRbacSeed.ts +54 -0
- package/dist/migrations/1775920000000-VendorOwnerSettingsPermission.ts +25 -0
- package/dist/migrations/1775930000000-VendorGroupStorePermissions.ts +54 -0
- package/dist/migrations/1775940000000-VendorRls.ts +71 -0
- package/dist/migrations/1775950000000-VendorCustomers.ts +87 -0
- package/dist/migrations/1775950000001-VendorCustomersPermissions.ts +67 -0
- package/dist/migrations/1778652250860-CreateCurrencyTables.ts +16 -0
- package/dist/migrations/1778652250861-OrderAddressTables.ts +88 -0
- package/dist/migrations/1778652250862-UpdateDiscountandRules.ts +100 -0
- package/dist/migrations/1778652250863-MakeCouponCodeNullable.ts +19 -0
- package/dist/migrations/1778652250864-RemoveUniqueConstraintFromDiscountCouponCode.ts +22 -0
- package/dist/migrations/1778652250865-FixOrdersAddressForeignKeys.ts +71 -0
- package/dist/migrations/1778660000000-DiscountVendorId.ts +90 -0
- package/dist/migrations/1778660000001-FixOrdersAddressFkToOrderAddresses.ts +79 -0
- package/dist/migrations/1778660000002-VendorUserIdInviteStatus.ts +61 -0
- package/dist/theme.d.cts +2 -2
- package/dist/theme.d.ts +2 -2
- package/dist/{types-D34wmivy.d.cts → types-DCVaXlPV.d.cts} +1 -1
- package/dist/{types-D34wmivy.d.ts → types-DCVaXlPV.d.ts} +1 -1
- package/dist/vendor-scope-DTYhJk_I.d.cts +129 -0
- package/dist/vendor-scope-DTYhJk_I.d.ts +129 -0
- package/package.json +9 -2
- package/dist/helpers-dlrF_49e.d.cts +0 -60
- package/dist/helpers-dlrF_49e.d.ts +0 -60
package/README.md
CHANGED
|
@@ -173,21 +173,22 @@ import { getServerSession } from 'next-auth';
|
|
|
173
173
|
import { createCmsApiHandler } from '@infuro/cms-core/api';
|
|
174
174
|
import { CMS_ENTITY_MAP } from '@infuro/cms-core';
|
|
175
175
|
import { getDataSourceInitialized } from '@/lib/data-source';
|
|
176
|
-
import {
|
|
177
|
-
|
|
178
|
-
requireAdminAccess,
|
|
179
|
-
requireEntityPermission,
|
|
180
|
-
getAuthenticatedUser,
|
|
181
|
-
} from '@/lib/auth-helpers';
|
|
176
|
+
import { createCmsAuthBundle } from '@infuro/cms-core/auth';
|
|
177
|
+
import { authOptions } from '@/lib/auth-options';
|
|
182
178
|
import { getCms } from '@/lib/cms';
|
|
183
179
|
import bcrypt from 'bcryptjs';
|
|
184
180
|
|
|
185
181
|
const baseUrl = process.env.NEXTAUTH_URL || 'http://localhost:3000';
|
|
186
182
|
|
|
183
|
+
const auth = createCmsAuthBundle(
|
|
184
|
+
() => getServerSession(authOptions).then((s) => s ?? null),
|
|
185
|
+
NextResponse
|
|
186
|
+
);
|
|
187
|
+
|
|
187
188
|
async function requireAdminApiAuth(req: Request) {
|
|
188
|
-
const a = await requireAuth(req);
|
|
189
|
+
const a = await auth.requireAuth(req);
|
|
189
190
|
if (a) return a;
|
|
190
|
-
return requireAdminAccess(req);
|
|
191
|
+
return auth.requireAdminAccess(req);
|
|
191
192
|
}
|
|
192
193
|
|
|
193
194
|
let handlerPromise: Promise<ReturnType<typeof createCmsApiHandler>> | null = null;
|
|
@@ -200,8 +201,9 @@ async function getHandler() {
|
|
|
200
201
|
dataSource,
|
|
201
202
|
entityMap: CMS_ENTITY_MAP,
|
|
202
203
|
requireAuth: requireAdminApiAuth,
|
|
203
|
-
requireEntityPermission,
|
|
204
|
-
getSessionUser:
|
|
204
|
+
requireEntityPermission: auth.requireEntityPermission,
|
|
205
|
+
getSessionUser: auth.getSessionUser,
|
|
206
|
+
getAuthenticatedUser: auth.getAuthenticatedUser,
|
|
205
207
|
json: NextResponse.json.bind(NextResponse),
|
|
206
208
|
getCms,
|
|
207
209
|
userAuth: {
|
|
@@ -286,11 +288,13 @@ async function getOptions() {
|
|
|
286
288
|
const userRepo = dataSource.getRepository(CMS_ENTITY_MAP.users);
|
|
287
289
|
return getNextAuthOptions({
|
|
288
290
|
getUserByEmail: async (email: string) => {
|
|
289
|
-
|
|
291
|
+
const user = await userRepo.findOne({
|
|
290
292
|
where: { email },
|
|
291
293
|
relations: ['group', 'group.permissions'],
|
|
292
|
-
select: ['id', 'email', 'name', 'password', 'blocked', 'deleted', 'groupId'],
|
|
293
|
-
})
|
|
294
|
+
select: ['id', 'email', 'name', 'password', 'blocked', 'deleted', 'groupId', 'adminAccess'],
|
|
295
|
+
});
|
|
296
|
+
const { enrichUserWithVendorContext } = await import('@infuro/cms-core');
|
|
297
|
+
return enrichUserWithVendorContext(dataSource, user as any);
|
|
294
298
|
},
|
|
295
299
|
comparePassword: (plain, hash) => Promise.resolve(bcrypt.compareSync(plain, hash)),
|
|
296
300
|
signInPage: '/admin/signin',
|