@infuro/cms-core 1.0.52 → 1.0.53
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/admin.cjs +1 -1
- package/dist/admin.js +1 -1
- package/dist/middleware.d.cts +50 -0
- package/dist/middleware.d.ts +50 -0
- package/package.json +1 -1
package/dist/admin.cjs
CHANGED
|
@@ -887,7 +887,7 @@ var init_admin_config_context = __esm({
|
|
|
887
887
|
var CMS_VERSION;
|
|
888
888
|
var init_cms_version = __esm({
|
|
889
889
|
"src/lib/cms-version.ts"() {
|
|
890
|
-
CMS_VERSION = "1.0.
|
|
890
|
+
CMS_VERSION = "1.0.53" ;
|
|
891
891
|
}
|
|
892
892
|
});
|
|
893
893
|
function useCatalogCategories(enabled = true) {
|
package/dist/admin.js
CHANGED
|
@@ -853,7 +853,7 @@ var init_admin_config_context = __esm({
|
|
|
853
853
|
var CMS_VERSION;
|
|
854
854
|
var init_cms_version = __esm({
|
|
855
855
|
"src/lib/cms-version.ts"() {
|
|
856
|
-
CMS_VERSION = "1.0.
|
|
856
|
+
CMS_VERSION = "1.0.53" ;
|
|
857
857
|
}
|
|
858
858
|
});
|
|
859
859
|
function useCatalogCategories(enabled = true) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
interface CmsMiddlewareRequest {
|
|
2
|
+
nextUrl: {
|
|
3
|
+
pathname: string;
|
|
4
|
+
};
|
|
5
|
+
url: string;
|
|
6
|
+
method: string;
|
|
7
|
+
cookies: {
|
|
8
|
+
get: (name: string) => {
|
|
9
|
+
value?: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Full Next.js request (e.g. `NextRequest`). When provided, session is resolved via
|
|
14
|
+
* cookie presence or `getToken()`.
|
|
15
|
+
*/
|
|
16
|
+
req?: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface CmsMiddlewareConfig {
|
|
19
|
+
publicAdminPaths?: string[];
|
|
20
|
+
publicApiPaths?: string[];
|
|
21
|
+
/** path -> allowed methods */
|
|
22
|
+
publicApiMethods?: Record<string, string[]>;
|
|
23
|
+
signInPath?: string;
|
|
24
|
+
/** @deprecated Prefer passing `req` on the request; used only when `req` is omitted. */
|
|
25
|
+
getSessionToken?: (request: CmsMiddlewareRequest) => string | undefined;
|
|
26
|
+
secret?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Default public API paths (no auth). Sites should extend this with their own routes. */
|
|
29
|
+
declare const defaultPublicApiMethods: Record<string, string[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns middleware logic. Use from Next.js middleware:
|
|
32
|
+
* import { createCmsMiddleware } from '@infuro/cms-core';
|
|
33
|
+
* export async function middleware(request: NextRequest) {
|
|
34
|
+
* const result = await cmsMiddleware({ ...request fields, req: request });
|
|
35
|
+
* ...
|
|
36
|
+
* }
|
|
37
|
+
* export const config = { matcher: ['/admin/:path*', '/api/:path*'] };
|
|
38
|
+
*/
|
|
39
|
+
declare function createCmsMiddleware(config?: CmsMiddlewareConfig): (request: CmsMiddlewareRequest) => Promise<{
|
|
40
|
+
type: "next";
|
|
41
|
+
} | {
|
|
42
|
+
type: "redirect";
|
|
43
|
+
url: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: "json";
|
|
46
|
+
status: number;
|
|
47
|
+
body: unknown;
|
|
48
|
+
}>;
|
|
49
|
+
|
|
50
|
+
export { type CmsMiddlewareConfig, type CmsMiddlewareRequest, createCmsMiddleware, defaultPublicApiMethods };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
interface CmsMiddlewareRequest {
|
|
2
|
+
nextUrl: {
|
|
3
|
+
pathname: string;
|
|
4
|
+
};
|
|
5
|
+
url: string;
|
|
6
|
+
method: string;
|
|
7
|
+
cookies: {
|
|
8
|
+
get: (name: string) => {
|
|
9
|
+
value?: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Full Next.js request (e.g. `NextRequest`). When provided, session is resolved via
|
|
14
|
+
* cookie presence or `getToken()`.
|
|
15
|
+
*/
|
|
16
|
+
req?: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface CmsMiddlewareConfig {
|
|
19
|
+
publicAdminPaths?: string[];
|
|
20
|
+
publicApiPaths?: string[];
|
|
21
|
+
/** path -> allowed methods */
|
|
22
|
+
publicApiMethods?: Record<string, string[]>;
|
|
23
|
+
signInPath?: string;
|
|
24
|
+
/** @deprecated Prefer passing `req` on the request; used only when `req` is omitted. */
|
|
25
|
+
getSessionToken?: (request: CmsMiddlewareRequest) => string | undefined;
|
|
26
|
+
secret?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Default public API paths (no auth). Sites should extend this with their own routes. */
|
|
29
|
+
declare const defaultPublicApiMethods: Record<string, string[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns middleware logic. Use from Next.js middleware:
|
|
32
|
+
* import { createCmsMiddleware } from '@infuro/cms-core';
|
|
33
|
+
* export async function middleware(request: NextRequest) {
|
|
34
|
+
* const result = await cmsMiddleware({ ...request fields, req: request });
|
|
35
|
+
* ...
|
|
36
|
+
* }
|
|
37
|
+
* export const config = { matcher: ['/admin/:path*', '/api/:path*'] };
|
|
38
|
+
*/
|
|
39
|
+
declare function createCmsMiddleware(config?: CmsMiddlewareConfig): (request: CmsMiddlewareRequest) => Promise<{
|
|
40
|
+
type: "next";
|
|
41
|
+
} | {
|
|
42
|
+
type: "redirect";
|
|
43
|
+
url: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: "json";
|
|
46
|
+
status: number;
|
|
47
|
+
body: unknown;
|
|
48
|
+
}>;
|
|
49
|
+
|
|
50
|
+
export { type CmsMiddlewareConfig, type CmsMiddlewareRequest, createCmsMiddleware, defaultPublicApiMethods };
|