@okam/directus-query 1.5.5 → 2.0.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.
- package/CHANGELOG.md +15 -0
- package/index.js +1 -1
- package/index.mjs +18 -18
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## 2.0.1 (2026-03-26)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- **directus-query:** admin client token falls back to regular token ([83444996](https://github.com/OKAMca/stack/commit/83444996))
|
|
6
|
+
- **directus-query:** default admin client uses correct env vars/fallbacks ([f551345d](https://github.com/OKAMca/stack/commit/f551345d))
|
|
7
|
+
|
|
8
|
+
### ❤️ Thank You
|
|
9
|
+
|
|
10
|
+
- poclerson
|
|
11
|
+
|
|
12
|
+
# 2.0.0 (2026-02-05)
|
|
13
|
+
|
|
14
|
+
This was a version bump only for directus-query to align it with other projects, there were no code changes.
|
|
15
|
+
|
|
1
16
|
## 1.5.5 (2026-01-23)
|
|
2
17
|
|
|
3
18
|
### 🧱 Updated Dependencies
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("graphql-request"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("graphql-request"),_=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 N(r,n,e=!1){const s=new u(r,n,e);return s.log("Logger initialized","info"),s}const y=N("[DirectusQuery]"),p=process.env.NEXT_PUBLIC_GRAPHQL_URL,h=process.env.NEXT_SERVER_GRAPHQL_URL,A=process.env.NEXT_GRAPHQL_URL_ADMIN,q=process.env.NEXT_PUBLIC_API_TOKEN??"",E=process.env.NEXT_API_TOKEN_ADMIN,g=new l.GraphQLClient(h||p,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${q}`}}),Q=new l.GraphQLClient(A||h||p,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${E||q}`}});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=g){return e.request(r,{...n})}function c(r,n){return[_.get(r,"definitions.0.name.value"),n]}function L(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],Q),...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 R(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=Q;exports.defaultGraphqlRequestClient=g;exports.getQueryValues=c;exports.initDirectusQuery=R;exports.queryGql=o;exports.useGqlQuery=L;exports.useSuspenseGqlQuery=d;exports.useSuspenseGqlQueryAdmin=f;
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphQLClient as c } from "graphql-request";
|
|
2
|
-
import { get as
|
|
3
|
-
import { QueryClient as
|
|
2
|
+
import { get as g } from "radashi";
|
|
3
|
+
import { QueryClient as y, QueryCache as N, useQuery as f, useSuspenseQuery as l } from "@tanstack/react-query";
|
|
4
4
|
class o {
|
|
5
5
|
constructor(n, e, s) {
|
|
6
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);
|
|
@@ -21,29 +21,29 @@ class o {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
o.getInstance();
|
|
24
|
-
function
|
|
24
|
+
function q(r, n, e = !1) {
|
|
25
25
|
const s = new o(r, n, e);
|
|
26
26
|
return s.log("Logger initialized", "info"), s;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
28
|
+
const A = q("[DirectusQuery]"), p = process.env.NEXT_PUBLIC_GRAPHQL_URL, h = process.env.NEXT_SERVER_GRAPHQL_URL, E = process.env.NEXT_GRAPHQL_URL_ADMIN, _ = process.env.NEXT_PUBLIC_API_TOKEN ?? "", L = process.env.NEXT_API_TOKEN_ADMIN, Q = new c(h || p, {
|
|
29
29
|
credentials: "include",
|
|
30
30
|
mode: "cors",
|
|
31
31
|
fetch,
|
|
32
32
|
headers: {
|
|
33
|
-
Authorization: `Bearer ${
|
|
33
|
+
Authorization: `Bearer ${_}`
|
|
34
34
|
}
|
|
35
|
-
}), T = new c(E, {
|
|
35
|
+
}), T = new c(E || h || p, {
|
|
36
36
|
credentials: "include",
|
|
37
37
|
mode: "cors",
|
|
38
38
|
fetch,
|
|
39
39
|
headers: {
|
|
40
|
-
Authorization: `Bearer ${L}`
|
|
40
|
+
Authorization: `Bearer ${L || _}`
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
-
new
|
|
44
|
-
queryCache: new
|
|
43
|
+
new y({
|
|
44
|
+
queryCache: new N({
|
|
45
45
|
onError: (r) => {
|
|
46
|
-
|
|
46
|
+
A.log("QueryClient Error", "error", { error: r });
|
|
47
47
|
}
|
|
48
48
|
}),
|
|
49
49
|
defaultOptions: {
|
|
@@ -58,11 +58,11 @@ async function u(r, n, e = Q) {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
function a(r, n) {
|
|
61
|
-
return [
|
|
61
|
+
return [g(r, "definitions.0.name.value"), n];
|
|
62
62
|
}
|
|
63
63
|
function m(r, n, e, s) {
|
|
64
64
|
const t = a(r, n);
|
|
65
|
-
return
|
|
65
|
+
return f({
|
|
66
66
|
queryKey: t,
|
|
67
67
|
queryFn: async ({ queryKey: i }) => u(r, i[1], s),
|
|
68
68
|
...e
|
|
@@ -76,7 +76,7 @@ function v(r, n, e) {
|
|
|
76
76
|
...e
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function D(r, n, e) {
|
|
80
80
|
const s = a(r, n);
|
|
81
81
|
return l({
|
|
82
82
|
queryKey: s,
|
|
@@ -84,15 +84,15 @@ function U(r, n, e) {
|
|
|
84
84
|
...e
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
const
|
|
87
|
+
const d = process.env.NEXT_PUBLIC_GRAPHQL_URL, P = process.env.NEXT_PUBLIC_API_TOKEN, R = {
|
|
88
88
|
credentials: "include",
|
|
89
89
|
mode: "cors",
|
|
90
90
|
fetch,
|
|
91
91
|
headers: {
|
|
92
|
-
Authorization: `Bearer ${
|
|
92
|
+
Authorization: `Bearer ${P}`
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
-
function O(r =
|
|
95
|
+
function O(r = d, n = R) {
|
|
96
96
|
const e = new c(r, n);
|
|
97
97
|
async function s(t, i) {
|
|
98
98
|
return u(t, i, e);
|
|
@@ -103,7 +103,7 @@ function O(r = P, n = R) {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
export {
|
|
106
|
-
|
|
106
|
+
A as DirectusQueryLogger,
|
|
107
107
|
T as defaultGraphqlRequestAdmin,
|
|
108
108
|
Q as defaultGraphqlRequestClient,
|
|
109
109
|
a as getQueryValues,
|
|
@@ -111,5 +111,5 @@ export {
|
|
|
111
111
|
u as queryGql,
|
|
112
112
|
m as useGqlQuery,
|
|
113
113
|
v as useSuspenseGqlQuery,
|
|
114
|
-
|
|
114
|
+
D as useSuspenseGqlQueryAdmin
|
|
115
115
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okam/directus-query",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://github.com/OKAMca/stack.git"
|
|
6
6
|
},
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@graphql-codegen/cli": "^6.1.1",
|
|
33
33
|
"@graphql-typed-document-node/core": "3.2.0",
|
|
34
|
-
"@okam/core-lib": "1.17.4",
|
|
35
34
|
"@okam/logger": "1.1.0",
|
|
35
|
+
"@okam/react-utils": "0.0.1",
|
|
36
36
|
"@tanstack/react-query": "^5.62.3",
|
|
37
37
|
"graphql-request": "^7.1.2",
|
|
38
38
|
"radashi": "^12.3.0"
|
|
@@ -40,4 +40,4 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"react": "^19.0.0"
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|