@dyrected/next 2.5.32 → 2.5.34
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 +13 -1
- package/dist/admin.css +0 -4
- package/dist/handler.d.ts +20 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +46 -0
- package/dist/handler.js.map +1 -0
- package/dist/index.d.ts +4 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -21
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
# @dyrected/next
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Next.js App Router integration for Dyrected CMS.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
// app/dyrected/[...route]/route.ts
|
|
7
|
+
import { dyrectedNextHandler } from "@dyrected/next";
|
|
8
|
+
import config from "../../../dyrected.config";
|
|
9
|
+
|
|
10
|
+
export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } =
|
|
11
|
+
dyrectedNextHandler(config);
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The handler lazily initializes Dyrected and mounts it at `/dyrected`. Pass
|
|
15
|
+
`{ basePath: "/cms" }` as the second argument when using a different route prefix.
|
package/dist/admin.css
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DyrectedConfig } from "@dyrected/core";
|
|
2
|
+
export interface DyrectedNextHandlerOptions {
|
|
3
|
+
/** Path where the catch-all route is mounted. Defaults to `/dyrected`. */
|
|
4
|
+
basePath?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates a lazily initialized Next.js App Router handler for Dyrected CMS.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* export const { GET, POST, PATCH, DELETE } = dyrectedNextHandler(config);
|
|
11
|
+
*/
|
|
12
|
+
export declare function dyrectedNextHandler(config: DyrectedConfig, options?: DyrectedNextHandlerOptions): {
|
|
13
|
+
GET: (request: Request) => Promise<Response>;
|
|
14
|
+
POST: (request: Request) => Promise<Response>;
|
|
15
|
+
PATCH: (request: Request) => Promise<Response>;
|
|
16
|
+
DELETE: (request: Request) => Promise<Response>;
|
|
17
|
+
PUT: (request: Request) => Promise<Response>;
|
|
18
|
+
OPTIONS: (request: Request) => Promise<Response>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKrD,MAAM,WAAW,0BAA0B;IACzC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,EACtB,OAAO,GAAE,0BAA+B;mBAsBR,OAAO;oBAAP,OAAO;qBAAP,OAAO;sBAAP,OAAO;mBAAP,OAAO;uBAAP,OAAO;EAaxC"}
|
package/dist/handler.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createDyrectedApp } from "@dyrected/core/server";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { handle } from "hono/vercel";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a lazily initialized Next.js App Router handler for Dyrected CMS.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* export const { GET, POST, PATCH, DELETE } = dyrectedNextHandler(config);
|
|
9
|
+
*/
|
|
10
|
+
export function dyrectedNextHandler(config, options = {}) {
|
|
11
|
+
const basePath = normalizeBasePath(options.basePath ?? "/dyrected");
|
|
12
|
+
let handlerPromise;
|
|
13
|
+
const getHandler = async () => {
|
|
14
|
+
if (!handlerPromise) {
|
|
15
|
+
handlerPromise = createDyrectedApp(config).then((app) => {
|
|
16
|
+
const mountedApp = basePath ? new Hono().route(basePath, app) : app;
|
|
17
|
+
return handle(mountedApp);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
return await handlerPromise;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
// Allow a later request to retry initialization after a transient failure.
|
|
25
|
+
handlerPromise = undefined;
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const handler = async (request) => {
|
|
30
|
+
const resolvedHandler = await getHandler();
|
|
31
|
+
return resolvedHandler(request);
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
GET: handler,
|
|
35
|
+
POST: handler,
|
|
36
|
+
PATCH: handler,
|
|
37
|
+
DELETE: handler,
|
|
38
|
+
PUT: handler,
|
|
39
|
+
OPTIONS: handler,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function normalizeBasePath(basePath) {
|
|
43
|
+
const normalized = basePath.trim().replace(/^\/+|\/+$/g, "");
|
|
44
|
+
return normalized ? `/${normalized}` : "";
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAOrC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAsB,EACtB,UAAsC,EAAE;IAExC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,QAAQ,IAAI,WAAW,CAAC,CAAC;IACpE,IAAI,cAA8D,CAAC;IAEnE,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;QAC5B,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,cAAc,GAAG,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ected]/route.ts:
|
|
6
|
-
*
|
|
7
|
-
* export const { GET, POST, PATCH, DELETE } = dyrectedNextHandler(config);
|
|
8
|
-
*/
|
|
9
|
-
export declare function dyrectedNextHandler(config: DyrectedConfig): {
|
|
10
|
-
GET: (req: Request) => Response | Promise<Response>;
|
|
11
|
-
POST: (req: Request) => Response | Promise<Response>;
|
|
12
|
-
PATCH: (req: Request) => Response | Promise<Response>;
|
|
13
|
-
DELETE: (req: Request) => Response | Promise<Response>;
|
|
14
|
-
PUT: (req: Request) => Response | Promise<Response>;
|
|
15
|
-
OPTIONS: (req: Request) => Response | Promise<Response>;
|
|
16
|
-
};
|
|
2
|
+
export { dyrectedNextHandler } from "./handler.js";
|
|
3
|
+
export type { DyrectedNextHandlerOptions } from "./handler.js";
|
|
17
4
|
/**
|
|
18
5
|
* Returns a pre-configured Dyrected SDK client for server-side use.
|
|
19
6
|
* Reads environment variables DYRECTED_URL and DYRECTED_API_KEY.
|
|
20
7
|
*/
|
|
21
8
|
export declare function getDyrectedClient(): DyrectedClient;
|
|
22
|
-
export * from "./components/DyrectedMedia";
|
|
23
|
-
export * from "./components/DyrectedImage";
|
|
9
|
+
export * from "./components/DyrectedMedia.js";
|
|
10
|
+
export * from "./components/DyrectedImage.js";
|
|
24
11
|
export { DyrectedProvider, useDyrected, useLivePreview } from "@dyrected/react";
|
|
25
12
|
export type { DyrectedImageProps, DyrectedMediaProps } from "@dyrected/react";
|
|
26
13
|
export type { DyrectedAdminProps, AdminComponents, AdminSchemas, CollectionListSlotProps, DashboardSlotProps, } from "@dyrected/react/admin";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAQlD;AAED,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
import { createDyrectedApp } from "@dyrected/core/server";
|
|
2
1
|
import { createClient } from "@dyrected/sdk";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Creates a standard Next.js Route Handler for Dyrected CMS.
|
|
6
|
-
* Usage in app/dyrected/[...dyrected]/route.ts:
|
|
7
|
-
*
|
|
8
|
-
* export const { GET, POST, PATCH, DELETE } = dyrectedNextHandler(config);
|
|
9
|
-
*/
|
|
10
|
-
export function dyrectedNextHandler(config) {
|
|
11
|
-
const handler = handle(createDyrectedApp(config));
|
|
12
|
-
return {
|
|
13
|
-
GET: handler,
|
|
14
|
-
POST: handler,
|
|
15
|
-
PATCH: handler,
|
|
16
|
-
DELETE: handler,
|
|
17
|
-
PUT: handler,
|
|
18
|
-
OPTIONS: handler,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
2
|
+
export { dyrectedNextHandler } from "./handler.js";
|
|
21
3
|
/**
|
|
22
4
|
* Returns a pre-configured Dyrected SDK client for server-side use.
|
|
23
5
|
* Reads environment variables DYRECTED_URL and DYRECTED_API_KEY.
|
|
@@ -30,8 +12,8 @@ export function getDyrectedClient() {
|
|
|
30
12
|
apiKey,
|
|
31
13
|
});
|
|
32
14
|
}
|
|
33
|
-
export * from "./components/DyrectedMedia";
|
|
34
|
-
export * from "./components/DyrectedImage";
|
|
15
|
+
export * from "./components/DyrectedMedia.js";
|
|
16
|
+
export * from "./components/DyrectedImage.js";
|
|
35
17
|
// Re-export React integration layer so Next.js users have one package to import from
|
|
36
18
|
export { DyrectedProvider, useDyrected, useLivePreview } from "@dyrected/react";
|
|
37
19
|
export * from "@dyrected/sdk";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,uBAAuB,CAAC;IAC5G,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAExF,OAAO,YAAY,CAAC;QAClB,OAAO;QACP,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAE9C,qFAAqF;AACrF,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAUhF,cAAc,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dyrected/next",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.34",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"hono": "^4.0.0",
|
|
34
|
-
"@dyrected/core": "2.5.
|
|
35
|
-
"@dyrected/sdk": "2.5.
|
|
36
|
-
"@dyrected/react": "2.5.
|
|
34
|
+
"@dyrected/core": "2.5.34",
|
|
35
|
+
"@dyrected/sdk": "2.5.34",
|
|
36
|
+
"@dyrected/react": "2.5.34"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^20.12.12",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"description": "Next.js integration for Dyrected CMS",
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsc && tsc -p tsconfig.cjs.json && cp dist-cjs/config.js dist/config.cjs && cp ../admin/dist/admin.css dist/admin.css && rm -rf dist-cjs",
|
|
58
|
-
"dev": "tsc --watch"
|
|
58
|
+
"dev": "tsc --watch",
|
|
59
|
+
"test": "pnpm run build && node --test test/*.test.mjs"
|
|
59
60
|
}
|
|
60
61
|
}
|