@okam/directus-next 1.2.9 → 1.2.11

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,27 @@
1
+ ## 1.2.11 (2026-01-14)
2
+
3
+ ### 🚀 Features
4
+
5
+ - ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
6
+
7
+ ### 🩹 Fixes
8
+
9
+ - ⚠️ functions starting with "use" should be reserved to react hooks ([68f1f8f](https://github.com/OKAMca/stack/commit/68f1f8f))
10
+
11
+ ### ⚠️ Breaking Changes
12
+
13
+ - Consumers must now have react and react-dom in their own
14
+
15
+ ### 🧱 Updated Dependencies
16
+
17
+ - Updated stack-ui to 1.44.0
18
+ - Updated next-component to 1.2.4
19
+
20
+ ### ❤️ Thank You
21
+
22
+ - Marie-Maxime Tanguay @marie-maxime
23
+ - Pierre-Olivier Clerson @poclerson
24
+
1
25
  ## 1.2.8 (2025-11-01)
2
26
 
3
27
  ### 🧱 Updated Dependencies
package/draft/route.d.ts CHANGED
@@ -44,4 +44,4 @@ export type HandleDraftOptions = {
44
44
  * })
45
45
  * }
46
46
  */
47
- export default function handleDraftRoute({ url, getDirectusLanguage, getDraftSecret, getJsonError, }: HandleDraftOptions): Response | undefined;
47
+ export default function handleDraftRoute({ url, getDirectusLanguage, getDraftSecret, getJsonError, }: HandleDraftOptions): Promise<Response | undefined>;
package/index.d.ts CHANGED
@@ -4,5 +4,4 @@ export { logger as DirectusNextLogger } from './logger';
4
4
  export { directusRouteRouter } from './router/router';
5
5
  export { getJsonErrorResponse } from './response';
6
6
  export * from './types';
7
- export type { TPageSettings, TPageSettingsTranslation, TPageSettingsItemQuery, TPageSettingsItemDocument, TUsePageSettingsProps, } from './pageSettings/interface';
8
7
  export type { TFiles } from './files/interface';
package/index.js CHANGED
@@ -98,7 +98,7 @@ function getPathFromRoute(routeUrl, url, index = 0) {
98
98
  });
99
99
  return radashi.template(routeUrl, map);
100
100
  }
101
- function handleDraftRoute({
101
+ async function handleDraftRoute({
102
102
  url,
103
103
  getDirectusLanguage,
104
104
  getDraftSecret,
@@ -147,7 +147,7 @@ function handleDraftRoute({
147
147
  const withParams = redirectUrl.indexOf("?") !== -1;
148
148
  redirectUrl = `${redirectUrl}${withParams ? "&" : "?"}version=${encodeURIComponent(version)}`;
149
149
  }
150
- headers.draftMode().enable();
150
+ (await headers.draftMode()).enable();
151
151
  navigation.redirect(redirectUrl);
152
152
  return void 0;
153
153
  }
package/index.mjs CHANGED
@@ -97,7 +97,7 @@ function getPathFromRoute(routeUrl, url, index = 0) {
97
97
  });
98
98
  return template(routeUrl, map);
99
99
  }
100
- function handleDraftRoute({
100
+ async function handleDraftRoute({
101
101
  url,
102
102
  getDirectusLanguage,
103
103
  getDraftSecret,
@@ -146,7 +146,7 @@ function handleDraftRoute({
146
146
  const withParams = redirectUrl.indexOf("?") !== -1;
147
147
  redirectUrl = `${redirectUrl}${withParams ? "&" : "?"}version=${encodeURIComponent(version)}`;
148
148
  }
149
- draftMode().enable();
149
+ (await draftMode()).enable();
150
150
  redirect(redirectUrl);
151
151
  return void 0;
152
152
  }
package/logger.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import type { LogSeverity } from '@okam/logger';
2
- export declare const logger: import("@okam/logger").Logger;
1
+ import { LogSeverity } from '../../../stack/logger/src/index.ts';
2
+
3
+ export declare const logger: import('../../../stack/logger/src/index.ts').Logger;
3
4
  export declare function log(msg: string, context?: unknown, severity?: LogSeverity): void;
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.9",
4
+ "version": "1.2.11",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
7
7
  ".": {
@@ -34,9 +34,10 @@
34
34
  "dependencies": {
35
35
  "@okam/core-lib": "1.17.0",
36
36
  "@okam/directus-node": "0.6.2",
37
+ "@okam/stack-ui": "1.44.0",
37
38
  "@okam/logger": "1.1.0",
38
- "@okam/next-component": "1.2.2",
39
- "next": "^14.1.1",
39
+ "@okam/next-component": "1.2.4",
40
+ "next": "^15.0.0",
40
41
  "radashi": "^12.3.0",
41
42
  "@okam/directus-query": "1.4.2",
42
43
  "server-only": "0.0.1",
@@ -1,4 +1,6 @@
1
- import type { Variables } from 'graphql-request';
2
- import type { TPageSettingsQueryItem, TUsePageSettingsReturn } from './interface';
3
- export declare function pageSettingsContext<Item extends TPageSettingsQueryItem>(defaultValue?: TUsePageSettingsReturn<Item>): readonly [() => TUsePageSettingsReturn<Item> | undefined, (value: TUsePageSettingsReturn<Item> | undefined) => void];
1
+ import { Variables } from 'graphql-request';
2
+ import { TPageSettingsQueryItem } from '../types/pageSettings';
3
+ import { TGetPageSettingsReturn } from './interface';
4
+
5
+ export declare function pageSettingsContext<Item extends TPageSettingsQueryItem>(defaultValue?: TGetPageSettingsReturn<Item>): readonly [() => TGetPageSettingsReturn<Item> | undefined, (value: TGetPageSettingsReturn<Item> | undefined) => void];
4
6
  export declare function pageSettingsVariablesContext(variables?: Variables): readonly [() => object | undefined, (value: object | undefined) => void];
@@ -1,5 +1,7 @@
1
- import type { Variables } from 'graphql-request';
2
- import type { TUsePageSettingsProps, TPageSettingsQueryItem, TUsePageSettingsReturn } from './interface';
1
+ import { Variables } from 'graphql-request';
2
+ import { TPageSettingsQueryItem } from '../types/pageSettings';
3
+ import { TGetPageSettingsProps, TGetPageSettingsReturn } from './interface';
4
+
3
5
  /**
4
6
  * @param props Optional props. Passing new props will trigger a new query if the variables have changed compared to the value of the variables in the cache. Omitting props will return the cached value.
5
7
  * @param itemKey Required if the query has more than a single root field
@@ -27,4 +29,8 @@ import type { TUsePageSettingsProps, TPageSettingsQueryItem, TUsePageSettingsRet
27
29
  * ```
28
30
  * @returns The new queried page settings item or the cached value if the variables have not changed. If the query contains a fragment, the contents of the fragment will be returned.
29
31
  */
30
- export declare function usePageSettings<Item extends TPageSettingsQueryItem, ItemKey extends string = string, QueryVariables extends Variables = Variables>(props?: TUsePageSettingsProps<Item, ItemKey, QueryVariables>, itemKey?: Exclude<ItemKey, '__typename'>): Promise<TUsePageSettingsReturn<Item>>;
32
+ export declare function getPageSettings<Item extends TPageSettingsQueryItem, ItemKey extends string = string, QueryVariables extends Variables = Variables>(props?: TGetPageSettingsProps<Item, ItemKey, QueryVariables>, itemKey?: Exclude<ItemKey, '__typename'>): Promise<TGetPageSettingsReturn<Item>>;
33
+ /**
34
+ * @deprecated Use `getPageSettings` instead
35
+ */
36
+ export declare const usePageSettings: typeof getPageSettings;
@@ -1,3 +1,3 @@
1
1
  export * from './context';
2
- export type { TPageSettings, TPageSettingsTranslation, TPageSettingsItemDocument, TPageSettingsItemQuery, } from './interface';
3
- export * from './usePageSettings';
2
+ export type { TGetPageSettingsConfig, TGetPageSettingsProps, TGetPageSettingsReturn } from './interface';
3
+ export { getPageSettings, usePageSettings } from './getPageSettings';
@@ -1,59 +1,17 @@
1
- import { type TypedDocumentNode } from '@graphql-typed-document-node/core';
2
- import type { Variables } from 'graphql-request';
3
- import type { TFiles } from '../files/interface';
4
- import type { DirectusRouteConfig } from '../types/directusRouteConfig';
5
- export type Fragmentize<FragmentData, FragmentName extends string = string> = {
6
- ' $fragmentRefs'?: {
7
- [FragmentKey in FragmentName]?: FragmentData | null | undefined;
8
- } | null | undefined;
9
- } | null | undefined;
10
- export type MaybeArray<T> = T | (T | null | undefined)[] | null | undefined;
11
- /**
12
- * Directus page settings translations collection.
13
- */
14
- export type TPageSettingsTranslation = {
15
- slug?: string | null;
16
- title?: string | null;
17
- path?: string | null;
18
- languages_code?: {
19
- code: string;
20
- } | null;
21
- page_settings_id?: TPageSettings | null;
22
- canonical_url?: string | null;
23
- meta_description?: string | null;
24
- no_follow?: boolean | null;
25
- no_index?: boolean | null;
26
- og_image?: TFiles | null;
27
- };
28
- /**
29
- * Directus page settings collection.
30
- */
31
- export type TPageSettings = {
32
- id: string;
33
- belongs_to_collection?: string | null;
34
- belongs_to_key?: string | null;
35
- translations?: Array<TPageSettingsTranslation | null> | null;
36
- route?: {
37
- translations?: Array<{
38
- route?: string | null;
39
- } | null> | null;
40
- } | null;
41
- };
42
- export type TPageSettingsQueryItem = {
43
- page_settings?: TPageSettings | Fragmentize<TPageSettings, 'PageSettingsFragment'> | null | undefined;
44
- } | null | undefined;
45
- export type TPageSettingsItemQuery<Item extends TPageSettingsQueryItem, ItemKey extends string> = {
46
- __typename?: 'Query';
47
- } & {
48
- [Key in ItemKey]?: MaybeArray<Item> | MaybeArray<Fragmentize<Item>>;
49
- };
1
+ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { Nullable } from '../../../../stack/stack-ui/src/index.ts';
3
+ import { Variables } from 'graphql-request';
4
+ import { TDirectusRouteConfig } from '../types/directusRouteConfig';
5
+ import { Fragmentize } from '../types/Fragments';
6
+ import { TPageSettings, TPageSettingsItemQuery, TPageSettingsQueryItem } from '../types/pageSettings';
7
+
50
8
  export type TPageSettingsItemDocument<Item extends TPageSettingsQueryItem, ItemKey extends string, QueryVariables extends Variables> = TypedDocumentNode<TPageSettingsItemQuery<Item, ItemKey>, QueryVariables>;
51
- export type TUsePageSettingsConfig = DirectusRouteConfig | Record<string, string>;
9
+ export type TGetPageSettingsConfig = TDirectusRouteConfig | Record<string, string>;
52
10
  /**
53
11
  * If not using a fragment in the item key, all type parameters must be passed. Otherwise, only the `page_settings` field will be in the type definition.
54
12
  * If using a fragment in the item key, the return type will contain the fragment.
55
13
  */
56
- export interface TUsePageSettingsProps<Item extends TPageSettingsQueryItem, ItemKey extends string, QueryVariables extends Variables> {
14
+ export interface TGetPageSettingsProps<Item extends TPageSettingsQueryItem, ItemKey extends string, QueryVariables extends Variables> {
57
15
  document: TPageSettingsItemDocument<Item, ItemKey, QueryVariables>;
58
16
  /**
59
17
  * `variables.locale` is a special value that will get mapped according to the config.
@@ -62,8 +20,8 @@ export interface TUsePageSettingsProps<Item extends TPageSettingsQueryItem, Item
62
20
  /**
63
21
  * Either a directus route config or directly a locale map. Not passing a config while passing a document will result in direct usage of the `locale` variable.
64
22
  */
65
- config?: TUsePageSettingsConfig;
23
+ config?: TGetPageSettingsConfig;
66
24
  }
67
- export type TUsePageSettingsReturn<Item extends TPageSettingsQueryItem> = Omit<Item, 'page_settings'> & {
68
- page_settings?: Exclude<NonNullable<Item>['page_settings'], Fragmentize<TPageSettings, 'PageSettingsFragment'>> | null | undefined;
25
+ export type TGetPageSettingsReturn<Item extends TPageSettingsQueryItem> = Omit<Item, 'page_settings'> & {
26
+ page_settings?: Nullable<Exclude<NonNullable<Item>['page_settings'], Fragmentize<TPageSettings, 'PageSettingsFragment'>>>;
69
27
  };
@@ -1,4 +1,5 @@
1
- import type { HandleRedirectOptions } from './interface';
1
+ import { HandleRedirectOptions } from './interface';
2
+
2
3
  export declare function parseRedirectParams(url: string): {
3
4
  secret: string;
4
5
  };
@@ -1,8 +1,9 @@
1
- import type { TFetchRedirectsResponse } from '@okam/directus-node/edge';
2
- import type { DirectusRouteRedirectsModule } from '../../types/directusRouteConfig';
1
+ import { TFetchRedirectsResponse } from '../../../../directus-node/src/edge.ts';
2
+ import { TDirectusRouteRedirectsModule } from '../../types/directusRouteConfig';
3
+
3
4
  /**
4
5
  * Gets a response from `options.apiRoute`
5
- * @param {DirectusRouteRedirectsModule} options
6
+ * @param {TDirectusRouteRedirectsModule} options
6
7
  * @returns {Promise<TFetchRedirectsResponse>}
7
8
  */
8
- export declare function getRedirectsRoute({ apiRoute, getApiRouteUrl, getRedirectSecret, }?: DirectusRouteRedirectsModule): Promise<TFetchRedirectsResponse>;
9
+ export declare function getRedirectsRoute({ apiRoute, getApiRouteUrl, getRedirectSecret, }?: TDirectusRouteRedirectsModule): Promise<TFetchRedirectsResponse>;
@@ -1,7 +1,7 @@
1
- import type { NextRequest } from 'next/server';
2
- import { NextResponse } from 'next/server';
3
- import type { DirectusRouteRedirectsModule } from '../../types/directusRouteConfig';
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+ import { TDirectusRouteRedirectsModule } from '../../types/directusRouteConfig';
3
+
4
4
  /**
5
5
  * Handles next redirection using directus redirects
6
6
  */
7
- export declare function handleRedirect(request: NextRequest, options?: DirectusRouteRedirectsModule): Promise<NextResponse<unknown> | null>;
7
+ export declare function handleRedirect(request: NextRequest, options?: TDirectusRouteRedirectsModule): Promise<NextResponse<unknown> | null>;
@@ -1,16 +1,17 @@
1
- import type { NextRequest, NextResponse as NextResponseType } from 'next/server';
2
- import type { DirectusRouteConfig } from '../types/directusRouteConfig';
1
+ import { NextRequest, NextResponse as NextResponseType } from 'next/server';
2
+ import { TDirectusRouteConfig } from '../types/directusRouteConfig';
3
+
3
4
  /**
4
5
  * Handles incoming middleware requests and rewrites the path to the new format according to fetched page settings.
5
6
  * @param request - The NextRequest object
6
- * @param config - The DirectusRouteConfig object
7
+ * @param config - The TDirectusRouteConfig object
7
8
  * @deprecated Use `directusRouteRouter(request, config)` instead. NextResponse is now directly imported in this file.
8
9
  * @param NextResponse - The NextResponse object
9
10
  * @returns NextResponse
10
11
  *
11
12
  * @example
12
13
  * ```typescript
13
- * export const directusConfig: DirectusRouteConfig = {
14
+ * export const directusConfig: TDirectusRouteConfig = {
14
15
  * localeMap: {
15
16
  * 'fr-CA': 'fr',
16
17
  * 'en-CA': 'en',
@@ -27,7 +28,7 @@ import type { DirectusRouteConfig } from '../types/directusRouteConfig';
27
28
  * }
28
29
  * ```
29
30
  */
30
- export declare function directusRouteRouter(request: NextRequest, config: DirectusRouteConfig,
31
+ export declare function directusRouteRouter(request: NextRequest, config: TDirectusRouteConfig,
31
32
  /**
32
33
  * @deprecated Use `directusRouteRouter(request, config)` instead. NextResponse is now directly imported in this file.
33
34
  */
@@ -1,2 +1,3 @@
1
- import type { PageSettingsTranslation } from '../../types';
2
- export declare function fetchPageSettingsTranslation(path: string): Promise<PageSettingsTranslation[] | null>;
1
+ import { TPageSettingsTranslation } from '../../types';
2
+
3
+ export declare function fetchPageSettingsTranslation(path: string): Promise<TPageSettingsTranslation[] | null>;
@@ -1,18 +1,19 @@
1
- import type { DirectusRouteConfig } from '../../types';
1
+ import { TDirectusRouteConfig } from '../../types';
2
+
2
3
  /**
3
4
  * Validates if a given string is a valid locale from the directus route configuration.
4
5
  * @param maybeLocale The string to validate as a locale
5
6
  * @param config The Directus route configuration containing the locale map
6
7
  * @returns The validated locale string, or undefined if invalid
7
8
  */
8
- export declare function getValidLocale(maybeLocale: string | null | undefined, config: DirectusRouteConfig): string | undefined;
9
+ export declare function getValidLocale(maybeLocale: string | null | undefined, config: TDirectusRouteConfig): string | undefined;
9
10
  /**
10
11
  * Splits the locale from the pathname and returns the locale and the pathname without the locale.
11
12
  * @param pathname The pathname to split the locale from
12
13
  * @param config The Directus route configuration containing the locale map
13
14
  * @returns The locale and the pathname without the locale
14
15
  */
15
- export declare function splitLocaleFromPathname(pathname: string, config: DirectusRouteConfig): {
16
+ export declare function splitLocaleFromPathname(pathname: string, config: TDirectusRouteConfig): {
16
17
  locale: string;
17
18
  pathname: string;
18
19
  } | {
package/server.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { directusRouteRouter } from './router/router';
2
- export type { DirectusRouteConfig } from './types/directusRouteConfig';
2
+ export type { TDirectusRouteConfig } from './types/directusRouteConfig';
3
3
  export * from './pageSettings';
package/server.js CHANGED
@@ -15,20 +15,20 @@ function createServerContext(defaultValue) {
15
15
  return [getValue, setValue];
16
16
  }
17
17
  function pageSettingsContext(defaultValue) {
18
- const [pageSettings, setPageSettings2] = createServerContext(defaultValue);
19
- return [pageSettings, setPageSettings2];
18
+ const [pageSettings, setPageSettings] = createServerContext(defaultValue);
19
+ return [pageSettings, setPageSettings];
20
20
  }
21
21
  function pageSettingsVariablesContext(variables) {
22
22
  const [pageSettingsVariables, setPageSettingsVariables] = createServerContext(variables);
23
23
  return [pageSettingsVariables, setPageSettingsVariables];
24
24
  }
25
- const [getPageSettings, setPageSettings] = pageSettingsContext();
25
+ const [getPageSettingsContext, setPageSettingsContext] = pageSettingsContext();
26
26
  const [getVariables, setVariables] = pageSettingsVariablesContext();
27
- function isDirectusRouteConfig(config) {
27
+ function isTDirectusRouteConfig(config) {
28
28
  return !!config && "localeMap" in config;
29
29
  }
30
30
  function getDirectusVariables(variables, config) {
31
- const localeMap = isDirectusRouteConfig(config) ? config.localeMap : config;
31
+ const localeMap = isTDirectusRouteConfig(config) ? config.localeMap : config;
32
32
  if (!localeMap) {
33
33
  return variables;
34
34
  }
@@ -36,11 +36,11 @@ function getDirectusVariables(variables, config) {
36
36
  const directusLocale = radashi.invert(localeMap)[locale] ?? locale;
37
37
  return { ...variables, locale: directusLocale };
38
38
  }
39
- async function usePageSettings(props, itemKey) {
39
+ async function getPageSettings(props, itemKey) {
40
40
  var _a, _b, _c, _d, _e;
41
41
  const { variables, config } = props ?? {};
42
42
  const directusVariables = getDirectusVariables(variables, config);
43
- const defaultReturn = getPageSettings() ?? {};
43
+ const defaultReturn = getPageSettingsContext();
44
44
  if (!props || radashi.isEqual(getVariables(), directusVariables)) {
45
45
  router.log("Using cached page settings", { path: (_c = (_b = (_a = defaultReturn.page_settings) == null ? void 0 : _a.translations) == null ? void 0 : _b[0]) == null ? void 0 : _c.path });
46
46
  return defaultReturn;
@@ -62,11 +62,13 @@ async function usePageSettings(props, itemKey) {
62
62
  return defaultReturn;
63
63
  }
64
64
  router.log("Caching new page settings", { path: currentPath });
65
- setPageSettings(currentItem);
65
+ setPageSettingsContext(currentItem);
66
66
  setVariables(variables);
67
67
  return currentItem;
68
68
  }
69
+ const usePageSettings = getPageSettings;
69
70
  exports.directusRouteRouter = router.directusRouteRouter;
71
+ exports.getPageSettings = getPageSettings;
70
72
  exports.pageSettingsContext = pageSettingsContext;
71
73
  exports.pageSettingsVariablesContext = pageSettingsVariablesContext;
72
74
  exports.usePageSettings = usePageSettings;
package/server.mjs CHANGED
@@ -14,20 +14,20 @@ function createServerContext(defaultValue) {
14
14
  return [getValue, setValue];
15
15
  }
16
16
  function pageSettingsContext(defaultValue) {
17
- const [pageSettings, setPageSettings2] = createServerContext(defaultValue);
18
- return [pageSettings, setPageSettings2];
17
+ const [pageSettings, setPageSettings] = createServerContext(defaultValue);
18
+ return [pageSettings, setPageSettings];
19
19
  }
20
20
  function pageSettingsVariablesContext(variables) {
21
21
  const [pageSettingsVariables, setPageSettingsVariables] = createServerContext(variables);
22
22
  return [pageSettingsVariables, setPageSettingsVariables];
23
23
  }
24
- const [getPageSettings, setPageSettings] = pageSettingsContext();
24
+ const [getPageSettingsContext, setPageSettingsContext] = pageSettingsContext();
25
25
  const [getVariables, setVariables] = pageSettingsVariablesContext();
26
- function isDirectusRouteConfig(config) {
26
+ function isTDirectusRouteConfig(config) {
27
27
  return !!config && "localeMap" in config;
28
28
  }
29
29
  function getDirectusVariables(variables, config) {
30
- const localeMap = isDirectusRouteConfig(config) ? config.localeMap : config;
30
+ const localeMap = isTDirectusRouteConfig(config) ? config.localeMap : config;
31
31
  if (!localeMap) {
32
32
  return variables;
33
33
  }
@@ -35,11 +35,11 @@ function getDirectusVariables(variables, config) {
35
35
  const directusLocale = invert(localeMap)[locale] ?? locale;
36
36
  return { ...variables, locale: directusLocale };
37
37
  }
38
- async function usePageSettings(props, itemKey) {
38
+ async function getPageSettings(props, itemKey) {
39
39
  var _a, _b, _c, _d, _e;
40
40
  const { variables, config } = props ?? {};
41
41
  const directusVariables = getDirectusVariables(variables, config);
42
- const defaultReturn = getPageSettings() ?? {};
42
+ const defaultReturn = getPageSettingsContext();
43
43
  if (!props || isEqual(getVariables(), directusVariables)) {
44
44
  log("Using cached page settings", { path: (_c = (_b = (_a = defaultReturn.page_settings) == null ? void 0 : _a.translations) == null ? void 0 : _b[0]) == null ? void 0 : _c.path });
45
45
  return defaultReturn;
@@ -61,12 +61,14 @@ async function usePageSettings(props, itemKey) {
61
61
  return defaultReturn;
62
62
  }
63
63
  log("Caching new page settings", { path: currentPath });
64
- setPageSettings(currentItem);
64
+ setPageSettingsContext(currentItem);
65
65
  setVariables(variables);
66
66
  return currentItem;
67
67
  }
68
+ const usePageSettings = getPageSettings;
68
69
  export {
69
70
  d as directusRouteRouter,
71
+ getPageSettings,
70
72
  pageSettingsContext,
71
73
  pageSettingsVariablesContext,
72
74
  usePageSettings
@@ -0,0 +1,5 @@
1
+ export type Fragmentize<FragmentData, FragmentName extends string = string> = {
2
+ ' $fragmentRefs'?: {
3
+ [FragmentKey in FragmentName]?: FragmentData | null | undefined;
4
+ } | null | undefined;
5
+ } | null | undefined;
@@ -1,4 +1,4 @@
1
- export interface DirectusRouteRedirectsModule {
1
+ export interface TDirectusRouteRedirectsModule {
2
2
  /**
3
3
  * @default process.env.NEXT_API_REDIRECT_SECRET
4
4
  */
@@ -12,7 +12,7 @@ export interface DirectusRouteRedirectsModule {
12
12
  */
13
13
  apiRoute?: string;
14
14
  }
15
- export interface DirectusRouteConfig {
15
+ export interface TDirectusRouteConfig {
16
16
  localeMap?: Record<string, string>;
17
17
  collectionSettings: {
18
18
  [collection: string]: {
@@ -24,6 +24,6 @@ export interface DirectusRouteConfig {
24
24
  };
25
25
  };
26
26
  modules?: {
27
- redirects?: DirectusRouteRedirectsModule;
27
+ redirects?: TDirectusRouteRedirectsModule;
28
28
  };
29
29
  }
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export type { DirectusRouteConfig, DirectusRouteRedirectsModule } from './directusRouteConfig';
2
- export type { PageSettingsTranslation } from './pageSettings';
1
+ export type { TDirectusRouteConfig, TDirectusRouteRedirectsModule } from './directusRouteConfig';
2
+ export type { TPageSettingsTranslation, TPageSettings, TPageSettingsItemQuery, TPageSettingsQueryItem, } from './pageSettings';
@@ -1,13 +1,41 @@
1
- export interface PageSettingsTranslation {
2
- languages_code?: {
3
- code?: string | null | undefined;
4
- } | null | undefined;
1
+ import { Nullable } from '../../../../stack/stack-ui/src/index.ts';
2
+ import { TFiles } from '../files';
3
+ import { Fragmentize } from './Fragments';
4
+
5
+ export interface TPageSettingsTranslation {
6
+ languages_code?: Nullable<{
7
+ code?: Nullable<string>;
8
+ }>;
9
+ page_settings_id?: Nullable<{
10
+ belongs_to_collection?: Nullable<string>;
11
+ belongs_to_key?: Nullable<string>;
12
+ }>;
13
+ title?: Nullable<string>;
14
+ slug?: Nullable<string>;
15
+ path?: Nullable<string>;
16
+ meta_description?: Nullable<string>;
17
+ no_follow?: Nullable<boolean>;
18
+ no_index?: Nullable<boolean>;
19
+ og_image?: Nullable<TFiles>;
20
+ }
21
+ export interface TPageSettings {
5
22
  id: string;
6
- page_settings_id?: {
7
- belongs_to_collection?: string | null | undefined;
8
- belongs_to_key?: string | null | undefined;
9
- } | null | undefined;
10
- title?: string | null | undefined;
11
- slug?: string | null | undefined;
12
- path?: string | null | undefined;
23
+ belongs_to_collection?: Nullable<string>;
24
+ belongs_to_key?: Nullable<string>;
25
+ translations?: DeepNullableArray<TPageSettingsTranslation>;
26
+ route?: Nullable<{
27
+ translations?: DeepNullableArray<{
28
+ route?: Nullable<string>;
29
+ }>;
30
+ }>;
13
31
  }
32
+ export type TPageSettingsQueryItem = Nullable<{
33
+ page_settings?: TPageSettings | Fragmentize<TPageSettings, 'PageSettingsFragment'>;
34
+ }>;
35
+ export type TPageSettingsItemQuery<Item extends TPageSettingsQueryItem, ItemKey extends string> = {
36
+ [Key in ItemKey]?: MaybeArray<Item> | MaybeArray<Fragmentize<Item>>;
37
+ } & {
38
+ __typename?: 'Query';
39
+ };
40
+ export type DeepNullableArray<T> = Nullable<Nullable<T>[]>;
41
+ export type MaybeArray<T> = T | (T | null | undefined)[] | null | undefined;