@okam/directus-next 1.2.14 → 1.2.19
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/CHANGELOG.md +43 -13
- package/index.js +2 -105
- package/index.mjs +1 -104
- package/package.json +4 -5
- package/pageSettings/interface.d.ts +1 -2
- package/server.js +3 -2560
- package/server.mjs +8 -2565
- package/types/pageSettings.d.ts +22 -23
- package/ErrorIcon-DM65zoku.mjs +0 -14
- package/ErrorIcon-Vnk7YKtL.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
## 1.2.19 (2026-01-16)
|
|
2
|
+
|
|
3
|
+
### 🧱 Updated Dependencies
|
|
4
|
+
|
|
5
|
+
- Updated next-component to 1.3.1
|
|
6
|
+
|
|
7
|
+
## 1.2.18 (2026-01-16)
|
|
8
|
+
|
|
9
|
+
### 🧱 Updated Dependencies
|
|
10
|
+
|
|
11
|
+
- Updated directus-query to 1.5.0
|
|
12
|
+
|
|
13
|
+
## 1.2.17 (2026-01-16)
|
|
14
|
+
|
|
15
|
+
### 🧱 Updated Dependencies
|
|
16
|
+
|
|
17
|
+
- Updated directus-node to 0.7.0
|
|
18
|
+
|
|
19
|
+
## 1.2.16 (2026-01-16)
|
|
20
|
+
|
|
21
|
+
### 🩹 Fixes
|
|
22
|
+
|
|
23
|
+
- **directus-next:** remove breaking changes tag ([368332c](https://github.com/OKAMca/stack/commit/368332c))
|
|
24
|
+
- **directus-next:** stop bundling okam libs ([04b2d27](https://github.com/OKAMca/stack/commit/04b2d27))
|
|
25
|
+
|
|
26
|
+
### ❤️ Thank You
|
|
27
|
+
|
|
28
|
+
- poclerson
|
|
29
|
+
|
|
30
|
+
## 1.2.15 (2026-01-16)
|
|
31
|
+
|
|
32
|
+
### 🩹 Fixes
|
|
33
|
+
|
|
34
|
+
- **directus-next:** stop depending on stack-ui ([cc1e033](https://github.com/OKAMca/stack/commit/cc1e033))
|
|
35
|
+
|
|
36
|
+
### ❤️ Thank You
|
|
37
|
+
|
|
38
|
+
- poclerson
|
|
39
|
+
|
|
1
40
|
## 1.2.14 (2026-01-15)
|
|
2
41
|
|
|
3
42
|
### 🩹 Fixes
|
|
@@ -13,6 +52,7 @@
|
|
|
13
52
|
### 🚀 Features
|
|
14
53
|
|
|
15
54
|
- ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
|
|
55
|
+
- Consumers must now have react and react-dom in their own
|
|
16
56
|
|
|
17
57
|
### 🩹 Fixes
|
|
18
58
|
|
|
@@ -20,10 +60,6 @@
|
|
|
20
60
|
- **directus-next:** draft route handler uses zod, returns draft isEnabled whenever possible ([#376](https://github.com/OKAMca/stack/pull/376))
|
|
21
61
|
- ⚠️ functions starting with "use" should be reserved to react hooks ([68f1f8f](https://github.com/OKAMca/stack/commit/68f1f8f))
|
|
22
62
|
|
|
23
|
-
### ⚠️ Breaking Changes
|
|
24
|
-
|
|
25
|
-
- Consumers must now have react and react-dom in their own
|
|
26
|
-
|
|
27
63
|
### ❤️ Thank You
|
|
28
64
|
|
|
29
65
|
- Marie-Maxime Tanguay @marie-maxime
|
|
@@ -35,6 +71,7 @@
|
|
|
35
71
|
### 🚀 Features
|
|
36
72
|
|
|
37
73
|
- ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
|
|
74
|
+
- Consumers must now have react and react-dom in their own
|
|
38
75
|
|
|
39
76
|
### 🩹 Fixes
|
|
40
77
|
|
|
@@ -42,10 +79,6 @@
|
|
|
42
79
|
- **directus-next:** draft route handler uses zod, returns draft isEnabled whenever possible ([#376](https://github.com/OKAMca/stack/pull/376))
|
|
43
80
|
- ⚠️ functions starting with "use" should be reserved to react hooks ([68f1f8f](https://github.com/OKAMca/stack/commit/68f1f8f))
|
|
44
81
|
|
|
45
|
-
### ⚠️ Breaking Changes
|
|
46
|
-
|
|
47
|
-
- Consumers must now have react and react-dom in their own
|
|
48
|
-
|
|
49
82
|
### 🧱 Updated Dependencies
|
|
50
83
|
|
|
51
84
|
- Updated next-component to 1.3.0
|
|
@@ -61,15 +94,12 @@
|
|
|
61
94
|
### 🚀 Features
|
|
62
95
|
|
|
63
96
|
- ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
|
|
97
|
+
- Consumers must now have react and react-dom in their own
|
|
64
98
|
|
|
65
99
|
### 🩹 Fixes
|
|
66
100
|
|
|
67
101
|
- ⚠️ functions starting with "use" should be reserved to react hooks ([68f1f8f](https://github.com/OKAMca/stack/commit/68f1f8f))
|
|
68
102
|
|
|
69
|
-
### ⚠️ Breaking Changes
|
|
70
|
-
|
|
71
|
-
- Consumers must now have react and react-dom in their own
|
|
72
|
-
|
|
73
103
|
### 🧱 Updated Dependencies
|
|
74
104
|
|
|
75
105
|
- Updated stack-ui to 1.44.0
|
|
@@ -260,4 +290,4 @@
|
|
|
260
290
|
- Jérôme Trottier
|
|
261
291
|
- Marie-Maxime Tanguay @marie-maxime
|
|
262
292
|
- Pierre-Olivier Clerson @poclerson
|
|
263
|
-
- Yan Morin
|
|
293
|
+
- Yan Morin
|
package/index.js
CHANGED
|
@@ -5,8 +5,7 @@ const navigation = require("next/navigation");
|
|
|
5
5
|
const radashi = require("radashi");
|
|
6
6
|
const zod = require("zod");
|
|
7
7
|
const router = require("./router-DTZYUtal.js");
|
|
8
|
-
const
|
|
9
|
-
const coreLib = require("@okam/core-lib");
|
|
8
|
+
const edge = require("@okam/directus-node/edge");
|
|
10
9
|
function _interopNamespaceDefault(e) {
|
|
11
10
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
12
11
|
if (e) {
|
|
@@ -176,108 +175,6 @@ async function handleDraftRoute({
|
|
|
176
175
|
}
|
|
177
176
|
return new Response(JSON.stringify({ isEnabled: draft.isEnabled }), { status: 200 });
|
|
178
177
|
}
|
|
179
|
-
function isRedirect(redirect) {
|
|
180
|
-
return !!redirect && typeof redirect === "object" && "source" in redirect && "destination" in redirect;
|
|
181
|
-
}
|
|
182
|
-
function normalizeRedirects(redirects) {
|
|
183
|
-
if (!redirects || !Array.isArray(redirects)) return [];
|
|
184
|
-
return redirects.flatMap((redirect) => {
|
|
185
|
-
const { source, destination, ...rest } = redirect ?? {};
|
|
186
|
-
if (!redirect || !source || !destination || !isRedirect(redirect)) return [];
|
|
187
|
-
return [
|
|
188
|
-
{
|
|
189
|
-
...rest,
|
|
190
|
-
source: coreLib.normalizePath(source),
|
|
191
|
-
destination: coreLib.normalizePath(destination)
|
|
192
|
-
}
|
|
193
|
-
];
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
const redirectDefaultLimit = 2e3;
|
|
197
|
-
function getDefaultConfig() {
|
|
198
|
-
return {
|
|
199
|
-
graphqlEndpoint: process.env["NEXT_REDIRECT_GRAPHQL_URL"] || process.env["NEXT_PUBLIC_GRAPHQL_URL"] || "",
|
|
200
|
-
graphqlApiKey: process.env["NEXT_API_TOKEN_ADMIN"] || "",
|
|
201
|
-
redirectsFilename: "./redirect/redirects.json",
|
|
202
|
-
rewritesFilename: "./redirect/rewrites.json",
|
|
203
|
-
limit: redirectDefaultLimit
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
async function fetchRedirectsData(config, init) {
|
|
207
|
-
const {
|
|
208
|
-
graphqlApiKey: defaultGraphqlApiKey,
|
|
209
|
-
graphqlEndpoint: defaultGraphqlEndpoint,
|
|
210
|
-
limit: defaultLimit
|
|
211
|
-
} = getDefaultConfig();
|
|
212
|
-
const {
|
|
213
|
-
graphqlEndpoint = defaultGraphqlEndpoint,
|
|
214
|
-
graphqlApiKey = defaultGraphqlApiKey,
|
|
215
|
-
limit = defaultLimit
|
|
216
|
-
} = config;
|
|
217
|
-
if (!graphqlEndpoint) {
|
|
218
|
-
throw new Error(
|
|
219
|
-
"Missing fetchRedirects configuration `graphqlEndpoint`. Check environment variables NEXT_REDIRECT_GRAPHQL_URL or NEXT_PUBLIC_GRAPHQL_URL"
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
if (!graphqlApiKey) {
|
|
223
|
-
throw new Error(
|
|
224
|
-
"Missing fetchRedirects configuration `graphqlApiKey`. Check environment variable NEXT_API_TOKEN_ADMIN"
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
const query = `query fetchRedirects($limit: Int = 2000) {
|
|
228
|
-
redirects(filter: {status:{_eq:"published"},isrewrite:{_eq:false}}, sort: "sort", limit: $limit) {
|
|
229
|
-
source
|
|
230
|
-
destination
|
|
231
|
-
permanent
|
|
232
|
-
locale
|
|
233
|
-
}
|
|
234
|
-
rewrites: redirects(filter: {status:{_eq:"published"},isrewrite:{_eq:true}}, sort: "sort", limit: $limit) {
|
|
235
|
-
source
|
|
236
|
-
destination
|
|
237
|
-
permanent
|
|
238
|
-
locale
|
|
239
|
-
}
|
|
240
|
-
}`;
|
|
241
|
-
const graphqlBody = {
|
|
242
|
-
query,
|
|
243
|
-
// "operationName": "",
|
|
244
|
-
variables: {
|
|
245
|
-
limit: Number(limit) || redirectDefaultLimit
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
try {
|
|
249
|
-
const response = await fetch(graphqlEndpoint, {
|
|
250
|
-
...init,
|
|
251
|
-
method: "POST",
|
|
252
|
-
headers: {
|
|
253
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
254
|
-
"Content-Type": "application/json",
|
|
255
|
-
Authorization: `Bearer ${graphqlApiKey}`
|
|
256
|
-
},
|
|
257
|
-
body: JSON.stringify(graphqlBody)
|
|
258
|
-
});
|
|
259
|
-
const { data } = await response.json();
|
|
260
|
-
const { redirects, rewrites } = data ?? {};
|
|
261
|
-
if (!(redirects == null ? void 0 : redirects.length) && !(rewrites == null ? void 0 : rewrites.length)) {
|
|
262
|
-
logger.logger.log("No redirects/rewrites found", "warn");
|
|
263
|
-
return {
|
|
264
|
-
redirects: [],
|
|
265
|
-
rewrites: []
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
logger.logger.log(`Fetch redirects count: ${(redirects == null ? void 0 : redirects.length) || 0}, rewrites count: ${(rewrites == null ? void 0 : rewrites.length) || 0}`);
|
|
269
|
-
return {
|
|
270
|
-
redirects: normalizeRedirects(redirects),
|
|
271
|
-
rewrites: normalizeRedirects(rewrites)
|
|
272
|
-
};
|
|
273
|
-
} catch (e) {
|
|
274
|
-
logger.logger.log(`Error fetching redirects: ${e.message}`, "error");
|
|
275
|
-
}
|
|
276
|
-
return {
|
|
277
|
-
redirects: [],
|
|
278
|
-
rewrites: []
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
178
|
function parseRedirectParams(url) {
|
|
282
179
|
const { searchParams } = new URL(url);
|
|
283
180
|
const secret = searchParams.get("secret") || "";
|
|
@@ -298,7 +195,7 @@ async function handleRedirectsRoute({
|
|
|
298
195
|
}
|
|
299
196
|
const graphqlEndpoint = getDirectusGraphqlUrl == null ? void 0 : getDirectusGraphqlUrl();
|
|
300
197
|
const graphqlApiKey = getDirectusApiToken == null ? void 0 : getDirectusApiToken();
|
|
301
|
-
const { redirects, rewrites } = await fetchRedirectsData({ graphqlEndpoint, graphqlApiKey, limit }, init);
|
|
198
|
+
const { redirects, rewrites } = await edge.fetchRedirectsData({ graphqlEndpoint, graphqlApiKey, limit }, init);
|
|
302
199
|
return new Response(JSON.stringify({ redirects, rewrites }), { status: 200 });
|
|
303
200
|
}
|
|
304
201
|
exports.DirectusNextLogger = router.logger;
|
package/index.mjs
CHANGED
|
@@ -4,8 +4,7 @@ import { template } from "radashi";
|
|
|
4
4
|
import * as zod from "zod";
|
|
5
5
|
import { g as getRedirectSecretDefault } from "./router-CA4ItnAc.mjs";
|
|
6
6
|
import { l, d, b, a, h } from "./router-CA4ItnAc.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import { normalizePath } from "@okam/core-lib";
|
|
7
|
+
import { fetchRedirectsData } from "@okam/directus-node/edge";
|
|
9
8
|
function getJsonErrorResponse(data, status) {
|
|
10
9
|
const headers = {
|
|
11
10
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -158,108 +157,6 @@ async function handleDraftRoute({
|
|
|
158
157
|
}
|
|
159
158
|
return new Response(JSON.stringify({ isEnabled: draft.isEnabled }), { status: 200 });
|
|
160
159
|
}
|
|
161
|
-
function isRedirect(redirect2) {
|
|
162
|
-
return !!redirect2 && typeof redirect2 === "object" && "source" in redirect2 && "destination" in redirect2;
|
|
163
|
-
}
|
|
164
|
-
function normalizeRedirects(redirects) {
|
|
165
|
-
if (!redirects || !Array.isArray(redirects)) return [];
|
|
166
|
-
return redirects.flatMap((redirect2) => {
|
|
167
|
-
const { source, destination, ...rest } = redirect2 ?? {};
|
|
168
|
-
if (!redirect2 || !source || !destination || !isRedirect(redirect2)) return [];
|
|
169
|
-
return [
|
|
170
|
-
{
|
|
171
|
-
...rest,
|
|
172
|
-
source: normalizePath(source),
|
|
173
|
-
destination: normalizePath(destination)
|
|
174
|
-
}
|
|
175
|
-
];
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
const redirectDefaultLimit = 2e3;
|
|
179
|
-
function getDefaultConfig() {
|
|
180
|
-
return {
|
|
181
|
-
graphqlEndpoint: process.env["NEXT_REDIRECT_GRAPHQL_URL"] || process.env["NEXT_PUBLIC_GRAPHQL_URL"] || "",
|
|
182
|
-
graphqlApiKey: process.env["NEXT_API_TOKEN_ADMIN"] || "",
|
|
183
|
-
redirectsFilename: "./redirect/redirects.json",
|
|
184
|
-
rewritesFilename: "./redirect/rewrites.json",
|
|
185
|
-
limit: redirectDefaultLimit
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
async function fetchRedirectsData(config, init) {
|
|
189
|
-
const {
|
|
190
|
-
graphqlApiKey: defaultGraphqlApiKey,
|
|
191
|
-
graphqlEndpoint: defaultGraphqlEndpoint,
|
|
192
|
-
limit: defaultLimit
|
|
193
|
-
} = getDefaultConfig();
|
|
194
|
-
const {
|
|
195
|
-
graphqlEndpoint = defaultGraphqlEndpoint,
|
|
196
|
-
graphqlApiKey = defaultGraphqlApiKey,
|
|
197
|
-
limit = defaultLimit
|
|
198
|
-
} = config;
|
|
199
|
-
if (!graphqlEndpoint) {
|
|
200
|
-
throw new Error(
|
|
201
|
-
"Missing fetchRedirects configuration `graphqlEndpoint`. Check environment variables NEXT_REDIRECT_GRAPHQL_URL or NEXT_PUBLIC_GRAPHQL_URL"
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
if (!graphqlApiKey) {
|
|
205
|
-
throw new Error(
|
|
206
|
-
"Missing fetchRedirects configuration `graphqlApiKey`. Check environment variable NEXT_API_TOKEN_ADMIN"
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
const query = `query fetchRedirects($limit: Int = 2000) {
|
|
210
|
-
redirects(filter: {status:{_eq:"published"},isrewrite:{_eq:false}}, sort: "sort", limit: $limit) {
|
|
211
|
-
source
|
|
212
|
-
destination
|
|
213
|
-
permanent
|
|
214
|
-
locale
|
|
215
|
-
}
|
|
216
|
-
rewrites: redirects(filter: {status:{_eq:"published"},isrewrite:{_eq:true}}, sort: "sort", limit: $limit) {
|
|
217
|
-
source
|
|
218
|
-
destination
|
|
219
|
-
permanent
|
|
220
|
-
locale
|
|
221
|
-
}
|
|
222
|
-
}`;
|
|
223
|
-
const graphqlBody = {
|
|
224
|
-
query,
|
|
225
|
-
// "operationName": "",
|
|
226
|
-
variables: {
|
|
227
|
-
limit: Number(limit) || redirectDefaultLimit
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
try {
|
|
231
|
-
const response = await fetch(graphqlEndpoint, {
|
|
232
|
-
...init,
|
|
233
|
-
method: "POST",
|
|
234
|
-
headers: {
|
|
235
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
236
|
-
"Content-Type": "application/json",
|
|
237
|
-
Authorization: `Bearer ${graphqlApiKey}`
|
|
238
|
-
},
|
|
239
|
-
body: JSON.stringify(graphqlBody)
|
|
240
|
-
});
|
|
241
|
-
const { data } = await response.json();
|
|
242
|
-
const { redirects, rewrites } = data ?? {};
|
|
243
|
-
if (!(redirects == null ? void 0 : redirects.length) && !(rewrites == null ? void 0 : rewrites.length)) {
|
|
244
|
-
logger.log("No redirects/rewrites found", "warn");
|
|
245
|
-
return {
|
|
246
|
-
redirects: [],
|
|
247
|
-
rewrites: []
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
logger.log(`Fetch redirects count: ${(redirects == null ? void 0 : redirects.length) || 0}, rewrites count: ${(rewrites == null ? void 0 : rewrites.length) || 0}`);
|
|
251
|
-
return {
|
|
252
|
-
redirects: normalizeRedirects(redirects),
|
|
253
|
-
rewrites: normalizeRedirects(rewrites)
|
|
254
|
-
};
|
|
255
|
-
} catch (e) {
|
|
256
|
-
logger.log(`Error fetching redirects: ${e.message}`, "error");
|
|
257
|
-
}
|
|
258
|
-
return {
|
|
259
|
-
redirects: [],
|
|
260
|
-
rewrites: []
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
160
|
function parseRedirectParams(url) {
|
|
264
161
|
const { searchParams } = new URL(url);
|
|
265
162
|
const secret = searchParams.get("secret") || "";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okam/directus-next",
|
|
3
3
|
"main": "./index.js",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.19",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -33,13 +33,12 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@okam/core-lib": "1.17.0",
|
|
36
|
-
"@okam/directus-node": "0.
|
|
37
|
-
"@okam/stack-ui": "1.44.0",
|
|
36
|
+
"@okam/directus-node": "0.7.0",
|
|
38
37
|
"@okam/logger": "1.1.0",
|
|
39
|
-
"@okam/next-component": "1.3.
|
|
38
|
+
"@okam/next-component": "1.3.1",
|
|
40
39
|
"next": "^15.0.0",
|
|
41
40
|
"radashi": "^12.3.0",
|
|
42
|
-
"@okam/directus-query": "1.
|
|
41
|
+
"@okam/directus-query": "1.5.0",
|
|
43
42
|
"graphql-request": "^7.1.2",
|
|
44
43
|
"@graphql-typed-document-node/core": "3.2.0",
|
|
45
44
|
"zod": "^4.3.5",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
-
import { Nullable } from '../../../../stack/stack-ui/src/index.ts';
|
|
3
2
|
import { Variables } from 'graphql-request';
|
|
4
3
|
import { TDirectusRouteConfig } from '../types/directusRouteConfig';
|
|
5
4
|
import { Fragmentize } from '../types/Fragments';
|
|
@@ -23,5 +22,5 @@ export interface TGetPageSettingsProps<Item extends TPageSettingsQueryItem, Item
|
|
|
23
22
|
config?: TGetPageSettingsConfig;
|
|
24
23
|
}
|
|
25
24
|
export type TGetPageSettingsReturn<Item extends TPageSettingsQueryItem> = Omit<Item, 'page_settings'> & {
|
|
26
|
-
page_settings?:
|
|
25
|
+
page_settings?: Exclude<NonNullable<Item>['page_settings'], Fragmentize<TPageSettings, 'PageSettingsFragment'>> | null | undefined;
|
|
27
26
|
};
|