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