@okam/directus-next 0.4.1 → 1.1.1

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/files/index.d.ts +1 -0
  3. package/files/interface.d.ts +24 -0
  4. package/index.d.ts +2 -0
  5. package/{directus/directus-next/src/lib → lib}/directusRouteRouter.js +12 -4
  6. package/{directus/directus-next/src/lib → lib}/directusRouteRouter.mjs +12 -4
  7. package/{directus/directus-next/src/logger.js → logger.js} +2 -3
  8. package/{directus/directus-next/src/logger.mjs → logger.mjs} +1 -2
  9. package/package.json +7 -2
  10. package/pageSettings/context.d.ts +4 -0
  11. package/pageSettings/context.js +14 -0
  12. package/pageSettings/context.mjs +14 -0
  13. package/pageSettings/index.d.ts +3 -0
  14. package/pageSettings/interface.d.ts +69 -0
  15. package/pageSettings/usePageSettings.d.ts +30 -0
  16. package/pageSettings/usePageSettings.js +51 -0
  17. package/pageSettings/usePageSettings.mjs +51 -0
  18. package/server.d.ts +1 -0
  19. package/server.js +9 -0
  20. package/server.mjs +9 -0
  21. package/directus/directus-next/src/server.js +0 -4
  22. package/directus/directus-next/src/server.mjs +0 -4
  23. package/stack/logger/src/lib/factoryLogger.js +0 -8
  24. package/stack/logger/src/lib/factoryLogger.mjs +0 -9
  25. package/stack/logger/src/lib/logger.js +0 -37
  26. package/stack/logger/src/lib/logger.mjs +0 -37
  27. /package/{directus/directus-next/src/draft → draft}/env.js +0 -0
  28. /package/{directus/directus-next/src/draft → draft}/env.mjs +0 -0
  29. /package/{directus/directus-next/src/draft → draft}/route.js +0 -0
  30. /package/{directus/directus-next/src/draft → draft}/route.mjs +0 -0
  31. /package/{directus/directus-next/src/index.js → index.js} +0 -0
  32. /package/{directus/directus-next/src/index.mjs → index.mjs} +0 -0
  33. /package/{directus/directus-next/src/response.js → response.js} +0 -0
  34. /package/{directus/directus-next/src/response.mjs → response.mjs} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## 1.1.1 (2025-07-09)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - **directus-next:** missing external deps for build ([8146c77](https://github.com/OKAMca/stack/commit/8146c77))
6
+ - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
7
+ - package deps error ([b665a45](https://github.com/OKAMca/stack/commit/b665a45))
8
+ - search field icon ([0850fde](https://github.com/OKAMca/stack/commit/0850fde))
9
+
10
+ ### ❤️ Thank You
11
+
12
+ - Marie-Maxime Tanguay
13
+ - Pierre-Olivier Clerson @poclerson
14
+ - poclerson
15
+
1
16
  ## 0.3.0 (2024-12-03)
2
17
 
3
18
 
@@ -0,0 +1 @@
1
+ export type { TFiles } from './interface';
@@ -0,0 +1,24 @@
1
+ export type TFiles = {
2
+ id?: string | null;
3
+ title?: string | null;
4
+ description?: string | null;
5
+ tags?: any | null;
6
+ location?: string | null;
7
+ storage?: string | null;
8
+ focal_point_divider?: string | null;
9
+ focal_point_x?: number | null;
10
+ focal_point_y?: number | null;
11
+ filename_disk?: string | null;
12
+ filename_download?: string | null;
13
+ type?: string | null;
14
+ width?: number | null;
15
+ height?: number | null;
16
+ duration?: number | null;
17
+ embed?: string | null;
18
+ caption?: string | null;
19
+ thumbhash?: string | null;
20
+ /**
21
+ * @deprecated Use `filename_download` instead
22
+ */
23
+ filenameDownload?: string | null;
24
+ };
package/index.d.ts CHANGED
@@ -2,3 +2,5 @@ export * from './draft';
2
2
  export { logger as DirectusNextLogger } from './logger';
3
3
  export { directusRouteRouter } from './lib/directusRouteRouter';
4
4
  export { getJsonErrorResponse } from './response';
5
+ export type { TPageSettings, TPageSettingsTranslation, TPageSettingsItemQuery, TPageSettingsItemDocument, TUsePageSettingsProps, } from './pageSettings/interface';
6
+ export type { TFiles } from './files/interface';
@@ -4,8 +4,11 @@ const logger = require("../logger.js");
4
4
  async function fetchPageSettingsTranslation(path) {
5
5
  const graphqlEndpoint = process.env.NEXT_SERVER_GRAPHQL_URL || process.env.NEXT_PUBLIC_GRAPHQL_URL;
6
6
  const graphqlApiKey = process.env.NEXT_PUBLIC_API_TOKEN;
7
- if (!graphqlEndpoint || !graphqlApiKey) {
8
- throw new Error("Missing GraphQL configuration");
7
+ if (!graphqlEndpoint) {
8
+ throw new Error("Missing GraphQL configuration `graphqlEndpoint`");
9
+ }
10
+ if (!graphqlApiKey) {
11
+ throw new Error("Missing GraphQL configuration `graphqlApiKey`");
9
12
  }
10
13
  const query = `
11
14
  query Languages_code($filter: page_settings_translations_filter) {
@@ -49,10 +52,15 @@ async function fetchPageSettingsTranslation(path) {
49
52
  return null;
50
53
  }
51
54
  }
55
+ function removeLocaleFromPathname(pathname, config) {
56
+ const currentLocale = Object.values(config.localeMap ?? {}).find((locale) => pathname.startsWith(`/${locale}/`));
57
+ return { locale: currentLocale, pathname: currentLocale ? pathname.replace(`/${currentLocale}/`, "/") : pathname };
58
+ }
52
59
  async function directusRouteRouter(request, config, NextResponse) {
53
60
  var _a, _b;
54
- const { pathname } = request.nextUrl;
55
- logger.log("Processing request for pathname:", pathname);
61
+ const { pathname: localizedPathname } = request.nextUrl;
62
+ const { locale, pathname } = removeLocaleFromPathname(localizedPathname, config);
63
+ logger.log("Processing request for pathname:", { locale, pathname });
56
64
  const translations = await fetchPageSettingsTranslation(pathname);
57
65
  if (!translations || translations.length === 0) {
58
66
  logger.log("No translation found for path:", pathname);
@@ -2,8 +2,11 @@ import { log } from "../logger.mjs";
2
2
  async function fetchPageSettingsTranslation(path) {
3
3
  const graphqlEndpoint = process.env.NEXT_SERVER_GRAPHQL_URL || process.env.NEXT_PUBLIC_GRAPHQL_URL;
4
4
  const graphqlApiKey = process.env.NEXT_PUBLIC_API_TOKEN;
5
- if (!graphqlEndpoint || !graphqlApiKey) {
6
- throw new Error("Missing GraphQL configuration");
5
+ if (!graphqlEndpoint) {
6
+ throw new Error("Missing GraphQL configuration `graphqlEndpoint`");
7
+ }
8
+ if (!graphqlApiKey) {
9
+ throw new Error("Missing GraphQL configuration `graphqlApiKey`");
7
10
  }
8
11
  const query = `
9
12
  query Languages_code($filter: page_settings_translations_filter) {
@@ -47,10 +50,15 @@ async function fetchPageSettingsTranslation(path) {
47
50
  return null;
48
51
  }
49
52
  }
53
+ function removeLocaleFromPathname(pathname, config) {
54
+ const currentLocale = Object.values(config.localeMap ?? {}).find((locale) => pathname.startsWith(`/${locale}/`));
55
+ return { locale: currentLocale, pathname: currentLocale ? pathname.replace(`/${currentLocale}/`, "/") : pathname };
56
+ }
50
57
  async function directusRouteRouter(request, config, NextResponse) {
51
58
  var _a, _b;
52
- const { pathname } = request.nextUrl;
53
- log("Processing request for pathname:", pathname);
59
+ const { pathname: localizedPathname } = request.nextUrl;
60
+ const { locale, pathname } = removeLocaleFromPathname(localizedPathname, config);
61
+ log("Processing request for pathname:", { locale, pathname });
54
62
  const translations = await fetchPageSettingsTranslation(pathname);
55
63
  if (!translations || translations.length === 0) {
56
64
  log("No translation found for path:", pathname);
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- require("../../../stack/logger/src/lib/logger.js");
4
- const factoryLogger = require("../../../stack/logger/src/lib/factoryLogger.js");
5
- const logger = factoryLogger("[DirectusNext]");
3
+ const logger$1 = require("@okam/logger");
4
+ const logger = logger$1.createLogger("[DirectusNext]");
6
5
  function log(msg, context, severity = "log") {
7
6
  if (process.env.NODE_ENV === "development") {
8
7
  logger.log(msg, severity, { context });
@@ -1,5 +1,4 @@
1
- import "../../../stack/logger/src/lib/logger.mjs";
2
- import createLogger from "../../../stack/logger/src/lib/factoryLogger.mjs";
1
+ import { createLogger } from "@okam/logger";
3
2
  const logger = createLogger("[DirectusNext]");
4
3
  function log(msg, context, severity = "log") {
5
4
  if (process.env.NODE_ENV === "development") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@okam/directus-next",
3
3
  "main": "./index.js",
4
- "version": "0.4.1",
4
+ "version": "1.1.1",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
7
7
  ".": {
@@ -34,6 +34,11 @@
34
34
  "dependencies": {
35
35
  "@okam/logger": "1.1.0",
36
36
  "next": "^14.1.1",
37
- "radashi": "^12.3.0"
37
+ "radashi": "^12.3.0",
38
+ "@okam/directus-query": "1.4.1",
39
+ "server-only": "0.0.1",
40
+ "graphql-request": "7.1.2",
41
+ "server-only-context": "0.1.0",
42
+ "@graphql-typed-document-node/core": "3.2.0"
38
43
  }
39
44
  }
@@ -0,0 +1,4 @@
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, (v: TUsePageSettingsReturn<Item> | undefined) => void];
4
+ export declare function pageSettingsVariablesContext(variables?: Variables): readonly [() => object | undefined, (v: object | undefined) => void];
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("server-only");
4
+ const createServerContext = require("server-only-context");
5
+ function pageSettingsContext(defaultValue) {
6
+ const [pageSettings, setPageSettings] = createServerContext(defaultValue);
7
+ return [pageSettings, setPageSettings];
8
+ }
9
+ function pageSettingsVariablesContext(variables) {
10
+ const [pageSettingsVariables, setPageSettingsVariables] = createServerContext(variables);
11
+ return [pageSettingsVariables, setPageSettingsVariables];
12
+ }
13
+ exports.pageSettingsContext = pageSettingsContext;
14
+ exports.pageSettingsVariablesContext = pageSettingsVariablesContext;
@@ -0,0 +1,14 @@
1
+ import "server-only";
2
+ import createServerContext from "server-only-context";
3
+ function pageSettingsContext(defaultValue) {
4
+ const [pageSettings, setPageSettings] = createServerContext(defaultValue);
5
+ return [pageSettings, setPageSettings];
6
+ }
7
+ function pageSettingsVariablesContext(variables) {
8
+ const [pageSettingsVariables, setPageSettingsVariables] = createServerContext(variables);
9
+ return [pageSettingsVariables, setPageSettingsVariables];
10
+ }
11
+ export {
12
+ pageSettingsContext,
13
+ pageSettingsVariablesContext
14
+ };
@@ -0,0 +1,3 @@
1
+ export * from './context';
2
+ export type { TPageSettings, TPageSettingsTranslation, TPageSettingsItemDocument, TPageSettingsItemQuery, } from './interface';
3
+ export * from './usePageSettings';
@@ -0,0 +1,69 @@
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
+ };
50
+ 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>;
52
+ /**
53
+ * 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
+ * If using a fragment in the item key, the return type will contain the fragment.
55
+ */
56
+ export interface TUsePageSettingsProps<Item extends TPageSettingsQueryItem, ItemKey extends string, QueryVariables extends Variables> {
57
+ document: TPageSettingsItemDocument<Item, ItemKey, QueryVariables>;
58
+ /**
59
+ * `variables.locale` is a special value that will get mapped according to the config.
60
+ */
61
+ variables?: QueryVariables;
62
+ /**
63
+ * 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
+ */
65
+ config?: TUsePageSettingsConfig;
66
+ }
67
+ export type TUsePageSettingsReturn<Item extends TPageSettingsQueryItem> = Omit<Item, 'page_settings'> & {
68
+ page_settings?: Exclude<NonNullable<Item>['page_settings'], Fragmentize<TPageSettings, 'PageSettingsFragment'>> | null | undefined;
69
+ };
@@ -0,0 +1,30 @@
1
+ import type { Variables } from 'graphql-request';
2
+ import type { TUsePageSettingsProps, TPageSettingsQueryItem, TUsePageSettingsReturn } from './interface';
3
+ /**
4
+ * @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
+ * @param itemKey Required if the query has more than a single root field
6
+ * @example
7
+ * #### `itemKey` not required
8
+ * ```graphql
9
+ * query PageById($id: ID!) {
10
+ * pages_by_id(id: $id) {
11
+ * ...Page
12
+ * }
13
+ * }
14
+ * ```
15
+ *
16
+ * #### `itemKey` required
17
+ * Otherwise the first root field will be used as the item key automatically (not necessarily the correct one)
18
+ * ```graphql
19
+ * query PageAndPostById($id: ID!) {
20
+ * pages_by_id(id: $id) {
21
+ * ...Page
22
+ * }
23
+ * posts_by_id(id: $id) {
24
+ * ...Post
25
+ * }
26
+ * }
27
+ * ```
28
+ * @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
+ */
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>>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const directusQuery = require("@okam/directus-query");
4
+ const radashi = require("radashi");
5
+ const logger = require("../logger.js");
6
+ const context = require("./context.js");
7
+ const [getPageSettings, setPageSettings] = context.pageSettingsContext();
8
+ const [getVariables, setVariables] = context.pageSettingsVariablesContext();
9
+ function isDirectusRouteConfig(config) {
10
+ return !!config && "localeMap" in config;
11
+ }
12
+ function getDirectusVariables(variables, config) {
13
+ const localeMap = isDirectusRouteConfig(config) ? config.localeMap : config;
14
+ if (!localeMap) {
15
+ return variables;
16
+ }
17
+ const locale = radashi.get(variables, "locale");
18
+ const directusLocale = radashi.invert(localeMap)[locale] ?? locale;
19
+ return { ...variables, locale: directusLocale };
20
+ }
21
+ async function usePageSettings(props, itemKey) {
22
+ var _a, _b, _c, _d, _e;
23
+ const { variables, config } = props ?? {};
24
+ const directusVariables = getDirectusVariables(variables, config);
25
+ const defaultReturn = getPageSettings() ?? {};
26
+ if (!props || radashi.isEqual(getVariables(), directusVariables)) {
27
+ logger.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 });
28
+ return defaultReturn;
29
+ }
30
+ const { document } = props;
31
+ const key = itemKey ?? radashi.get(document, "definitions[0].selectionSet.selections[0].name.value");
32
+ logger.log("Querying new page settings", directusVariables);
33
+ const result = await directusQuery.queryGql(document, directusVariables);
34
+ const items = result == null ? void 0 : result[key];
35
+ const currentItem = Array.isArray(items) ? items == null ? void 0 : items[0] : items;
36
+ const currentPageSettings = currentItem == null ? void 0 : currentItem.page_settings;
37
+ const currentPath = (_e = (_d = currentPageSettings == null ? void 0 : currentPageSettings.translations) == null ? void 0 : _d[0]) == null ? void 0 : _e.path;
38
+ if (!currentItem) {
39
+ logger.log("No item found. Falling back to cached page settings", { path: currentPath }, "warn");
40
+ return defaultReturn;
41
+ }
42
+ if (!currentPageSettings) {
43
+ logger.log("No page settings found. Falling back to cached page settings", { path: currentPath }, "warn");
44
+ return defaultReturn;
45
+ }
46
+ logger.log("Caching new page settings", { path: currentPath });
47
+ setPageSettings(currentItem);
48
+ setVariables(variables);
49
+ return currentItem;
50
+ }
51
+ exports.usePageSettings = usePageSettings;
@@ -0,0 +1,51 @@
1
+ import { queryGql } from "@okam/directus-query";
2
+ import { isEqual, get, invert } from "radashi";
3
+ import { log } from "../logger.mjs";
4
+ import { pageSettingsContext, pageSettingsVariablesContext } from "./context.mjs";
5
+ const [getPageSettings, setPageSettings] = pageSettingsContext();
6
+ const [getVariables, setVariables] = pageSettingsVariablesContext();
7
+ function isDirectusRouteConfig(config) {
8
+ return !!config && "localeMap" in config;
9
+ }
10
+ function getDirectusVariables(variables, config) {
11
+ const localeMap = isDirectusRouteConfig(config) ? config.localeMap : config;
12
+ if (!localeMap) {
13
+ return variables;
14
+ }
15
+ const locale = get(variables, "locale");
16
+ const directusLocale = invert(localeMap)[locale] ?? locale;
17
+ return { ...variables, locale: directusLocale };
18
+ }
19
+ async function usePageSettings(props, itemKey) {
20
+ var _a, _b, _c, _d, _e;
21
+ const { variables, config } = props ?? {};
22
+ const directusVariables = getDirectusVariables(variables, config);
23
+ const defaultReturn = getPageSettings() ?? {};
24
+ if (!props || isEqual(getVariables(), directusVariables)) {
25
+ 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 });
26
+ return defaultReturn;
27
+ }
28
+ const { document } = props;
29
+ const key = itemKey ?? get(document, "definitions[0].selectionSet.selections[0].name.value");
30
+ log("Querying new page settings", directusVariables);
31
+ const result = await queryGql(document, directusVariables);
32
+ const items = result == null ? void 0 : result[key];
33
+ const currentItem = Array.isArray(items) ? items == null ? void 0 : items[0] : items;
34
+ const currentPageSettings = currentItem == null ? void 0 : currentItem.page_settings;
35
+ const currentPath = (_e = (_d = currentPageSettings == null ? void 0 : currentPageSettings.translations) == null ? void 0 : _d[0]) == null ? void 0 : _e.path;
36
+ if (!currentItem) {
37
+ log("No item found. Falling back to cached page settings", { path: currentPath }, "warn");
38
+ return defaultReturn;
39
+ }
40
+ if (!currentPageSettings) {
41
+ log("No page settings found. Falling back to cached page settings", { path: currentPath }, "warn");
42
+ return defaultReturn;
43
+ }
44
+ log("Caching new page settings", { path: currentPath });
45
+ setPageSettings(currentItem);
46
+ setVariables(variables);
47
+ return currentItem;
48
+ }
49
+ export {
50
+ usePageSettings
51
+ };
package/server.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { directusRouteRouter } from './lib/directusRouteRouter';
2
2
  export type { DirectusRouteConfig } from './types/directusRouteConfig';
3
+ export * from './pageSettings';
package/server.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const directusRouteRouter = require("./lib/directusRouteRouter.js");
4
+ const context = require("./pageSettings/context.js");
5
+ const usePageSettings = require("./pageSettings/usePageSettings.js");
6
+ exports.directusRouteRouter = directusRouteRouter.directusRouteRouter;
7
+ exports.pageSettingsContext = context.pageSettingsContext;
8
+ exports.pageSettingsVariablesContext = context.pageSettingsVariablesContext;
9
+ exports.usePageSettings = usePageSettings.usePageSettings;
package/server.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import { directusRouteRouter } from "./lib/directusRouteRouter.mjs";
2
+ import { pageSettingsContext, pageSettingsVariablesContext } from "./pageSettings/context.mjs";
3
+ import { usePageSettings } from "./pageSettings/usePageSettings.mjs";
4
+ export {
5
+ directusRouteRouter,
6
+ pageSettingsContext,
7
+ pageSettingsVariablesContext,
8
+ usePageSettings
9
+ };
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const directusRouteRouter = require("./lib/directusRouteRouter.js");
4
- exports.directusRouteRouter = directusRouteRouter.directusRouteRouter;
@@ -1,4 +0,0 @@
1
- import { directusRouteRouter } from "./lib/directusRouteRouter.mjs";
2
- export {
3
- directusRouteRouter
4
- };
@@ -1,8 +0,0 @@
1
- "use strict";
2
- const logger = require("./logger.js");
3
- const createLogger = (name, logger$1, suppressConsole = false) => {
4
- const log = new logger.Logger(name, logger$1, suppressConsole);
5
- log.log(`Logger initialized`, "info");
6
- return log;
7
- };
8
- module.exports = createLogger;
@@ -1,9 +0,0 @@
1
- import { Logger } from "./logger.mjs";
2
- const createLogger = (name, logger, suppressConsole = false) => {
3
- const log = new Logger(name, logger, suppressConsole);
4
- log.log(`Logger initialized`, "info");
5
- return log;
6
- };
7
- export {
8
- createLogger as default
9
- };
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- class Logger {
4
- constructor(nameSpace, logger2, suppressConsole) {
5
- this.nameSpace = "[STACK]";
6
- this.suppressConsole = false;
7
- this.env = process.env["NODE_ENV"];
8
- this.nameSpace = nameSpace ?? this.nameSpace;
9
- this.suppressConsole = suppressConsole ?? this.suppressConsole;
10
- this.logger = logger2 ?? this.internalLogger;
11
- }
12
- internalLogger(message, severity, context) {
13
- if (this.env === "production") {
14
- return;
15
- }
16
- console[severity || "log"](`${this.nameSpace} ${message}`.trimStart(), context ?? "");
17
- }
18
- setLogger(logger2) {
19
- this.logger = (message, severity, context) => {
20
- if (this.suppressConsole) {
21
- this.internalLogger(message, severity, context);
22
- }
23
- logger2(message, severity, context);
24
- };
25
- }
26
- static getInstance() {
27
- if (!Logger.instance) {
28
- Logger.instance = new Logger();
29
- }
30
- return Logger.instance;
31
- }
32
- log(message, severity, context) {
33
- this.logger(message, severity, context);
34
- }
35
- }
36
- Logger.getInstance();
37
- exports.Logger = Logger;
@@ -1,37 +0,0 @@
1
- class Logger {
2
- constructor(nameSpace, logger2, suppressConsole) {
3
- this.nameSpace = "[STACK]";
4
- this.suppressConsole = false;
5
- this.env = process.env["NODE_ENV"];
6
- this.nameSpace = nameSpace ?? this.nameSpace;
7
- this.suppressConsole = suppressConsole ?? this.suppressConsole;
8
- this.logger = logger2 ?? this.internalLogger;
9
- }
10
- internalLogger(message, severity, context) {
11
- if (this.env === "production") {
12
- return;
13
- }
14
- console[severity || "log"](`${this.nameSpace} ${message}`.trimStart(), context ?? "");
15
- }
16
- setLogger(logger2) {
17
- this.logger = (message, severity, context) => {
18
- if (this.suppressConsole) {
19
- this.internalLogger(message, severity, context);
20
- }
21
- logger2(message, severity, context);
22
- };
23
- }
24
- static getInstance() {
25
- if (!Logger.instance) {
26
- Logger.instance = new Logger();
27
- }
28
- return Logger.instance;
29
- }
30
- log(message, severity, context) {
31
- this.logger(message, severity, context);
32
- }
33
- }
34
- Logger.getInstance();
35
- export {
36
- Logger
37
- };