@okam/directus-next 1.2.15 → 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 CHANGED
@@ -1,3 +1,32 @@
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
+
1
30
  ## 1.2.15 (2026-01-16)
2
31
 
3
32
  ### 🩹 Fixes
@@ -23,6 +52,7 @@
23
52
  ### 🚀 Features
24
53
 
25
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
26
56
 
27
57
  ### 🩹 Fixes
28
58
 
@@ -30,10 +60,6 @@
30
60
  - **directus-next:** draft route handler uses zod, returns draft isEnabled whenever possible ([#376](https://github.com/OKAMca/stack/pull/376))
31
61
  - ⚠️ functions starting with "use" should be reserved to react hooks ([68f1f8f](https://github.com/OKAMca/stack/commit/68f1f8f))
32
62
 
33
- ### ⚠️ Breaking Changes
34
-
35
- - Consumers must now have react and react-dom in their own
36
-
37
63
  ### ❤️ Thank You
38
64
 
39
65
  - Marie-Maxime Tanguay @marie-maxime
@@ -45,6 +71,7 @@
45
71
  ### 🚀 Features
46
72
 
47
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
48
75
 
49
76
  ### 🩹 Fixes
50
77
 
@@ -52,10 +79,6 @@
52
79
  - **directus-next:** draft route handler uses zod, returns draft isEnabled whenever possible ([#376](https://github.com/OKAMca/stack/pull/376))
53
80
  - ⚠️ functions starting with "use" should be reserved to react hooks ([68f1f8f](https://github.com/OKAMca/stack/commit/68f1f8f))
54
81
 
55
- ### ⚠️ Breaking Changes
56
-
57
- - Consumers must now have react and react-dom in their own
58
-
59
82
  ### 🧱 Updated Dependencies
60
83
 
61
84
  - Updated next-component to 1.3.0
@@ -71,15 +94,12 @@
71
94
  ### 🚀 Features
72
95
 
73
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
74
98
 
75
99
  ### 🩹 Fixes
76
100
 
77
101
  - ⚠️ functions starting with "use" should be reserved to react hooks ([68f1f8f](https://github.com/OKAMca/stack/commit/68f1f8f))
78
102
 
79
- ### ⚠️ Breaking Changes
80
-
81
- - Consumers must now have react and react-dom in their own
82
-
83
103
  ### 🧱 Updated Dependencies
84
104
 
85
105
  - Updated stack-ui to 1.44.0
@@ -270,4 +290,4 @@
270
290
  - Jérôme Trottier
271
291
  - Marie-Maxime Tanguay @marie-maxime
272
292
  - Pierre-Olivier Clerson @poclerson
273
- - 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 logger = require("@okam/logger");
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 { logger } from "@okam/logger";
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.15",
4
+ "version": "1.2.19",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
7
7
  ".": {
@@ -33,12 +33,12 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@okam/core-lib": "1.17.0",
36
- "@okam/directus-node": "0.6.2",
36
+ "@okam/directus-node": "0.7.0",
37
37
  "@okam/logger": "1.1.0",
38
- "@okam/next-component": "1.3.0",
38
+ "@okam/next-component": "1.3.1",
39
39
  "next": "^15.0.0",
40
40
  "radashi": "^12.3.0",
41
- "@okam/directus-query": "1.4.2",
41
+ "@okam/directus-query": "1.5.0",
42
42
  "graphql-request": "^7.1.2",
43
43
  "@graphql-typed-document-node/core": "3.2.0",
44
44
  "zod": "^4.3.5",
package/server.js CHANGED
@@ -5,26 +5,13 @@ const router = require("./router-DTZYUtal.js");
5
5
  const directusQuery = require("@okam/directus-query");
6
6
  const radashi = require("radashi");
7
7
  require("server-only");
8
- require("react/jsx-runtime");
9
- require("@okam/stack-ui");
10
- require("next/headers");
11
- const coreLib = require("@okam/core-lib");
12
- const react = require("react");
13
- const [useDraftMode, DraftModeProvider] = coreLib.createCtx();
14
- function createServerContext(defaultValue) {
15
- const getRef = react.cache(() => ({ current: defaultValue }));
16
- const getValue = () => getRef().current;
17
- const setValue = (value) => {
18
- getRef().current = value;
19
- };
20
- return [getValue, setValue];
21
- }
8
+ const server = require("@okam/next-component/server");
22
9
  function pageSettingsContext(defaultValue) {
23
- const [pageSettings, setPageSettings] = createServerContext(defaultValue);
10
+ const [pageSettings, setPageSettings] = server.createServerContext(defaultValue);
24
11
  return [pageSettings, setPageSettings];
25
12
  }
26
13
  function pageSettingsVariablesContext(variables) {
27
- const [pageSettingsVariables, setPageSettingsVariables] = createServerContext(variables);
14
+ const [pageSettingsVariables, setPageSettingsVariables] = server.createServerContext(variables);
28
15
  return [pageSettingsVariables, setPageSettingsVariables];
29
16
  }
30
17
  const [getPageSettingsContext, setPageSettingsContext] = pageSettingsContext();
package/server.mjs CHANGED
@@ -4,20 +4,7 @@ import { d } from "./router-CA4ItnAc.mjs";
4
4
  import { queryGql } from "@okam/directus-query";
5
5
  import { isEqual, get, invert } from "radashi";
6
6
  import "server-only";
7
- import "react/jsx-runtime";
8
- import "@okam/stack-ui";
9
- import "next/headers";
10
- import { createCtx } from "@okam/core-lib";
11
- import { cache } from "react";
12
- const [useDraftMode, DraftModeProvider] = createCtx();
13
- function createServerContext(defaultValue) {
14
- const getRef = cache(() => ({ current: defaultValue }));
15
- const getValue = () => getRef().current;
16
- const setValue = (value) => {
17
- getRef().current = value;
18
- };
19
- return [getValue, setValue];
20
- }
7
+ import { createServerContext } from "@okam/next-component/server";
21
8
  function pageSettingsContext(defaultValue) {
22
9
  const [pageSettings, setPageSettings] = createServerContext(defaultValue);
23
10
  return [pageSettings, setPageSettings];