@okam/directus-query 1.4.2 → 1.5.0

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.5.0 (2026-01-16)
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
+ - **directus-query:** stop bundling okam libs ([ebb2885](https://github.com/OKAMca/stack/commit/ebb2885))
10
+ - **directus-next:** draft route handler uses zod, returns draft isEnabled whenever possible ([#376](https://github.com/OKAMca/stack/pull/376))
11
+ - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
12
+ - package deps error ([b665a45](https://github.com/OKAMca/stack/commit/b665a45))
13
+ - search field icon ([0850fde](https://github.com/OKAMca/stack/commit/0850fde))
14
+
15
+ ### ⚠️ Breaking Changes
16
+
17
+ - Consumers must now have react and react-dom in their own
18
+
19
+ ### ❤️ Thank You
20
+
21
+ - Marie-Maxime Tanguay @marie-maxime
22
+ - Pierre-Olivier Clerson @poclerson
23
+ - poclerson
24
+
1
25
  ## 1.4.2 (2025-07-24)
2
26
 
3
27
  ### 🩹 Fixes
package/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './lib/hooks';
2
2
  export * from './lib/query';
3
3
  export { logger as DirectusQueryLogger } from './logger';
4
4
  export { default as initDirectusQuery } from './lib/init';
5
+ export { graphqlRequestClient as defaultGraphqlRequestClient, graphqlRequestAdmin as defaultGraphqlRequestAdmin, } from './lib/request';
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@tanstack/react-query"),p=require("radashi"),l=require("graphql-request");class u{constructor(s,e,r){this.nameSpace="[STACK]",this.suppressConsole=!1,this.env=process.env.NODE_ENV,this.nameSpace=s??this.nameSpace,this.suppressConsole=r??this.suppressConsole,this.logger=e??this.internalLogger}internalLogger(s,e,r){this.env!=="production"&&console[e||"log"](`${this.nameSpace} ${s}`.trimStart(),r??"")}setLogger(s){this.logger=(e,r,t)=>{this.suppressConsole&&this.internalLogger(e,r,t),s(e,r,t)}}static getInstance(){return u.instance||(u.instance=new u),u.instance}log(s,e,r){this.logger(s,e,r)}}u.getInstance();const h=(n,s,e=!1)=>{const r=new u(n,s,e);return r.log("Logger initialized","info"),r},y=h("[DirectusQuery]"),g=process.env.NEXT_PUBLIC_GRAPHQL_URL,q=process.env.NEXT_SERVER_GRAPHQL_URL,Q=process.env.NEXT_GRAPHQL_URL_ADMIN,_=process.env.NEXT_PUBLIC_API_TOKEN??"",N=process.env.NEXT_PUBLIC_API_TOKEN,E=new l.GraphQLClient(q||g,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${_}`}}),L=new l.GraphQLClient(Q,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${N}`}});new o.QueryClient({queryCache:new o.QueryCache({onError:n=>{y.log("QueryClient Error","error",{error:n})}}),defaultOptions:{queries:{staleTime:5*1e3}}});function i(n,s,e=E){return e.request(n,{...s})}function c(n,s){return[p.get(n,"definitions.0.name.value"),s]}function A(n,s,e,r){const t=c(n,s);return o.useQuery({queryKey:t,queryFn:async({queryKey:a})=>i(n,a[1],r),...e})}function T(n,s,e){const r=c(n,s);return o.useSuspenseQuery({queryKey:r,queryFn:async({queryKey:t})=>i(n,t[1]),...e})}function P(n,s,e){const r=c(n,s);return o.useSuspenseQuery({queryKey:r,queryFn:async({queryKey:t})=>i(n,t[1],L),...e})}const G=process.env.NEXT_PUBLIC_GRAPHQL_URL,d=process.env.NEXT_PUBLIC_API_TOKEN,f={credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${d}`}},C=(n=G,s=f)=>{const e=new l.GraphQLClient(n,s);function r(t,a){return i(t,a,e)}return{queryGql:r,client:e}};exports.DirectusQueryLogger=y;exports.getQueryValues=c;exports.initDirectusQuery=C;exports.queryGql=i;exports.useGqlQuery=A;exports.useSuspenseGqlQuery=T;exports.useSuspenseGqlQueryAdmin=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@tanstack/react-query"),_=require("radashi"),l=require("graphql-request"),Q=require("@okam/logger"),a=Q.createLogger("[DirectusQuery]"),A=process.env.NEXT_PUBLIC_GRAPHQL_URL,N=process.env.NEXT_SERVER_GRAPHQL_URL,p=process.env.NEXT_GRAPHQL_URL_ADMIN,E=process.env.NEXT_PUBLIC_API_TOKEN??"",G=process.env.NEXT_PUBLIC_API_TOKEN,y=new l.GraphQLClient(N||A,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${E}`}}),q=new l.GraphQLClient(p,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${G}`}});new t.QueryClient({queryCache:new t.QueryCache({onError:e=>{a.log("QueryClient Error","error",{error:e})}}),defaultOptions:{queries:{staleTime:5*1e3}}});function o(e,r,n=y){return n.request(e,{...r})}function c(e,r){return[_.get(e,"definitions.0.name.value"),r]}function L(e,r,n,u){const s=c(e,r);return t.useQuery({queryKey:s,queryFn:async({queryKey:i})=>o(e,i[1],u),...n})}function P(e,r,n){const u=c(e,r);return t.useSuspenseQuery({queryKey:u,queryFn:async({queryKey:s})=>o(e,s[1]),...n})}function T(e,r,n){const u=c(e,r);return t.useSuspenseQuery({queryKey:u,queryFn:async({queryKey:s})=>o(e,s[1],q),...n})}const d=process.env.NEXT_PUBLIC_GRAPHQL_URL,R=process.env.NEXT_PUBLIC_API_TOKEN,h={credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${R}`}},g=(e=d,r=h)=>{const n=new l.GraphQLClient(e,r);function u(s,i){return o(s,i,n)}return{queryGql:u,client:n}};exports.DirectusQueryLogger=a;exports.defaultGraphqlRequestAdmin=q;exports.defaultGraphqlRequestClient=y;exports.getQueryValues=c;exports.initDirectusQuery=g;exports.queryGql=o;exports.useGqlQuery=L;exports.useSuspenseGqlQuery=P;exports.useSuspenseGqlQueryAdmin=T;
package/index.mjs CHANGED
@@ -1,48 +1,26 @@
1
- import { QueryClient as p, QueryCache as h, useQuery as _, useSuspenseQuery as l } from "@tanstack/react-query";
2
- import { get as g } from "radashi";
1
+ import { QueryClient as l, QueryCache as _, useQuery as y, useSuspenseQuery as a } from "@tanstack/react-query";
2
+ import { get as q } from "radashi";
3
3
  import { GraphQLClient as c } from "graphql-request";
4
- class o {
5
- constructor(n, e, s) {
6
- this.nameSpace = "[STACK]", this.suppressConsole = !1, this.env = process.env.NODE_ENV, this.nameSpace = n ?? this.nameSpace, this.suppressConsole = s ?? this.suppressConsole, this.logger = e ?? this.internalLogger;
7
- }
8
- internalLogger(n, e, s) {
9
- this.env !== "production" && console[e || "log"](`${this.nameSpace} ${n}`.trimStart(), s ?? "");
10
- }
11
- setLogger(n) {
12
- this.logger = (e, s, t) => {
13
- this.suppressConsole && this.internalLogger(e, s, t), n(e, s, t);
14
- };
15
- }
16
- static getInstance() {
17
- return o.instance || (o.instance = new o()), o.instance;
18
- }
19
- log(n, e, s) {
20
- this.logger(n, e, s);
21
- }
22
- }
23
- o.getInstance();
24
- const y = (r, n, e = !1) => {
25
- const s = new o(r, n, e);
26
- return s.log("Logger initialized", "info"), s;
27
- }, N = y("[DirectusQuery]"), E = process.env.NEXT_PUBLIC_GRAPHQL_URL, A = process.env.NEXT_SERVER_GRAPHQL_URL, L = process.env.NEXT_GRAPHQL_URL_ADMIN, f = process.env.NEXT_PUBLIC_API_TOKEN ?? "", Q = process.env.NEXT_PUBLIC_API_TOKEN, T = new c(A || E, {
4
+ import { createLogger as N } from "@okam/logger";
5
+ const A = N("[DirectusQuery]"), E = process.env.NEXT_PUBLIC_GRAPHQL_URL, Q = process.env.NEXT_SERVER_GRAPHQL_URL, p = process.env.NEXT_GRAPHQL_URL_ADMIN, L = process.env.NEXT_PUBLIC_API_TOKEN ?? "", P = process.env.NEXT_PUBLIC_API_TOKEN, T = new c(Q || E, {
28
6
  credentials: "include",
29
7
  mode: "cors",
30
8
  fetch,
31
9
  headers: {
32
- Authorization: `Bearer ${f}`
10
+ Authorization: `Bearer ${L}`
33
11
  }
34
- }), q = new c(L, {
12
+ }), R = new c(p, {
35
13
  credentials: "include",
36
14
  mode: "cors",
37
15
  fetch,
38
16
  headers: {
39
- Authorization: `Bearer ${Q}`
17
+ Authorization: `Bearer ${P}`
40
18
  }
41
19
  });
42
- new p({
43
- queryCache: new h({
44
- onError: (r) => {
45
- N.log("QueryClient Error", "error", { error: r });
20
+ new l({
21
+ queryCache: new _({
22
+ onError: (e) => {
23
+ A.log("QueryClient Error", "error", { error: e });
46
24
  }
47
25
  }),
48
26
  defaultOptions: {
@@ -51,61 +29,63 @@ new p({
51
29
  }
52
30
  }
53
31
  });
54
- function i(r, n, e = T) {
55
- return e.request(r, {
56
- ...n
32
+ function u(e, r, n = T) {
33
+ return n.request(e, {
34
+ ...r
57
35
  });
58
36
  }
59
- function a(r, n) {
60
- return [g(r, "definitions.0.name.value"), n];
37
+ function i(e, r) {
38
+ return [q(e, "definitions.0.name.value"), r];
61
39
  }
62
- function G(r, n, e, s) {
63
- const t = a(r, n);
64
- return _({
40
+ function v(e, r, n, s) {
41
+ const t = i(e, r);
42
+ return y({
65
43
  queryKey: t,
66
- queryFn: async ({ queryKey: u }) => i(r, u[1], s),
67
- ...e
44
+ queryFn: async ({ queryKey: o }) => u(e, o[1], s),
45
+ ...n
68
46
  });
69
47
  }
70
- function m(r, n, e) {
71
- const s = a(r, n);
72
- return l({
48
+ function U(e, r, n) {
49
+ const s = i(e, r);
50
+ return a({
73
51
  queryKey: s,
74
- queryFn: async ({ queryKey: t }) => i(r, t[1]),
75
- ...e
52
+ queryFn: async ({ queryKey: t }) => u(e, t[1]),
53
+ ...n
76
54
  });
77
55
  }
78
- function U(r, n, e) {
79
- const s = a(r, n);
80
- return l({
56
+ function g(e, r, n) {
57
+ const s = i(e, r);
58
+ return a({
81
59
  queryKey: s,
82
- queryFn: async ({ queryKey: t }) => i(r, t[1], q),
83
- ...e
60
+ queryFn: async ({ queryKey: t }) => u(e, t[1], R),
61
+ ...n
84
62
  });
85
63
  }
86
- const P = process.env.NEXT_PUBLIC_GRAPHQL_URL, C = process.env.NEXT_PUBLIC_API_TOKEN, I = {
64
+ const f = process.env.NEXT_PUBLIC_GRAPHQL_URL, d = process.env.NEXT_PUBLIC_API_TOKEN, G = {
87
65
  credentials: "include",
88
66
  mode: "cors",
89
67
  fetch,
90
68
  headers: {
91
- Authorization: `Bearer ${C}`
69
+ Authorization: `Bearer ${d}`
92
70
  }
93
- }, O = (r = P, n = I) => {
94
- const e = new c(r, n);
95
- function s(t, u) {
96
- return i(t, u, e);
71
+ }, H = (e = f, r = G) => {
72
+ const n = new c(e, r);
73
+ function s(t, o) {
74
+ return u(t, o, n);
97
75
  }
98
76
  return {
99
77
  queryGql: s,
100
- client: e
78
+ client: n
101
79
  };
102
80
  };
103
81
  export {
104
- N as DirectusQueryLogger,
105
- a as getQueryValues,
106
- O as initDirectusQuery,
107
- i as queryGql,
108
- G as useGqlQuery,
109
- m as useSuspenseGqlQuery,
110
- U as useSuspenseGqlQueryAdmin
82
+ A as DirectusQueryLogger,
83
+ R as defaultGraphqlRequestAdmin,
84
+ T as defaultGraphqlRequestClient,
85
+ i as getQueryValues,
86
+ H as initDirectusQuery,
87
+ u as queryGql,
88
+ v as useGqlQuery,
89
+ U as useSuspenseGqlQuery,
90
+ g as useSuspenseGqlQueryAdmin
111
91
  };
package/lib/config.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { RequestConfig } from 'node_modules/graphql-request/build/legacy/helpers/types';
1
+ import { RequestConfig } from 'node_modules/graphql-request/build/legacy/helpers/types';
2
+
2
3
  export declare const GRAPHQL_ENDPOINT: string;
3
4
  export declare const AUTH_TOKEN: string;
4
5
  export declare const defaultConfig: RequestConfig;
@@ -1,8 +1,6 @@
1
- import { type TypedDocumentNode } from '@graphql-typed-document-node/core';
2
- import type { QueryOptions, UseQueryResult } from '@tanstack/react-query';
3
- import type { GraphQLClient, Variables } from 'graphql-request';
4
- export declare function useGqlQuery<TResult, TVariables extends Variables>(document: TypedDocumentNode<TResult, TVariables>, variables?: TVariables, options?: QueryOptions & {
5
- enabled: boolean;
6
- useErrorBoundary: boolean;
7
- }, client?: GraphQLClient): UseQueryResult<TResult>;
1
+ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
3
+ import { GraphQLClient, Variables } from 'graphql-request';
4
+
5
+ export declare function useGqlQuery<TResult, TVariables extends Variables>(document: TypedDocumentNode<TResult, TVariables>, variables?: TVariables, options?: Omit<UseQueryOptions<TResult, Error, TResult>, 'queryKey' | 'queryFn'>, client?: GraphQLClient): UseQueryResult<TResult, Error>;
8
6
  export default useGqlQuery;
@@ -1,6 +1,7 @@
1
- import { type TypedDocumentNode } from '@graphql-typed-document-node/core';
2
- import type { QueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query';
3
- import type { Variables } from 'graphql-request';
1
+ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { QueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query';
3
+ import { Variables } from 'graphql-request';
4
+
4
5
  export declare function useSuspenseGqlQuery<TResult, TVariables extends Variables>(document: TypedDocumentNode<TResult, TVariables>, variables?: TVariables, options?: Omit<QueryOptions, 'queryFn'> & {
5
6
  enabled: boolean;
6
7
  useErrorBoundary: boolean;
package/lib/init.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { type TypedDocumentNode } from '@graphql-typed-document-node/core';
2
- import { GraphQLClient } from 'graphql-request';
3
- import type { Variables } from 'graphql-request';
4
- import type { RequestConfig } from 'node_modules/graphql-request/build/legacy/helpers/types';
1
+ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { GraphQLClient, Variables } from 'graphql-request';
3
+ import { RequestConfig } from 'node_modules/graphql-request/build/legacy/helpers/types';
4
+
5
5
  declare const initDirectusQuery: (graphqlEndPoint?: string, requestConfig?: RequestConfig) => {
6
6
  queryGql: <TResult, TVariables extends Variables>(document: TypedDocumentNode<TResult, TVariables>, queryKey?: TVariables) => Promise<TResult>;
7
7
  client: GraphQLClient;
@@ -1,4 +1,5 @@
1
- import type { TGQLQueryContextProps, TGQLQueryProviderProps } from './interface';
1
+ import { TGQLQueryContextProps, TGQLQueryProviderProps } from './interface';
2
+
2
3
  declare const useGql: () => TGQLQueryContextProps;
3
4
  export { useGql };
4
5
  export declare function GqlQueryContextProvider({ children, client }: Readonly<TGQLQueryProviderProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,8 @@
1
- import { type TypedDocumentNode } from '@graphql-typed-document-node/core';
2
- import type { UseQueryResult } from '@tanstack/react-query';
3
- import type { GraphQLClient, Variables } from 'graphql-request';
4
- import type React from 'react';
1
+ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { GraphQLClient, Variables } from 'graphql-request';
4
+ import { default as React } from 'react';
5
+
5
6
  export type TGQLQueryProviderProps = {
6
7
  children: React.ReactNode;
7
8
  client: GraphQLClient;
package/lib/query.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { type TypedDocumentNode } from '@graphql-typed-document-node/core';
2
- import type { Variables } from 'graphql-request';
3
- export declare function queryGql<TResult, TVariables extends Variables>(document: TypedDocumentNode<TResult, TVariables>, queryKey?: TVariables, client?: import("graphql-request").GraphQLClient): Promise<TResult>;
1
+ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { Variables } from 'graphql-request';
3
+
4
+ export declare function queryGql<TResult, TVariables extends Variables>(document: TypedDocumentNode<TResult, TVariables>, queryKey?: TVariables, client?: import('graphql-request').GraphQLClient): Promise<TResult>;
4
5
  export declare function getQueryValues<TResult, TVariables extends Variables>(document: TypedDocumentNode<TResult, TVariables>, variables?: TVariables): readonly [string, TVariables | undefined];
package/lib/request.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { QueryClient } from '@tanstack/react-query';
2
2
  import { GraphQLClient } from 'graphql-request';
3
+
3
4
  export declare const grapqhlGetDefaultEndpoint: () => string;
4
5
  export declare const grapqhlGetDefaultAdminEndpoint: () => string;
5
6
  export declare const graphqlRequestClient: GraphQLClient;
package/logger.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const logger: import("@okam/logger").Logger;
1
+ export declare const logger: import('../../../stack/logger/src/index.ts').Logger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okam/directus-query",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -28,7 +28,12 @@
28
28
  "@okam/logger": "1.1.0",
29
29
  "@tanstack/react-query": "^5.62.3",
30
30
  "graphql-request": "^7.1.2",
31
- "radashi": "^12.3.0",
32
- "react": "18.3.1"
31
+ "radashi": "^12.3.0"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "^18.0.0 || ^19.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "react": "^19.0.0"
33
38
  }
34
39
  }
package/server.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './lib/query';
2
2
  export { default as initDirectusQuery } from './lib/init';
3
3
  export { logger as DirectusQueryLogger } from './logger';
4
+ export { graphqlRequestClient as defaultGraphqlRequestClient, graphqlRequestAdmin as defaultGraphqlRequestAdmin, } from './lib/request';