@codewheel/jsonapi-frontend-client 1.0.2 → 1.0.4
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/README.md +59 -0
- package/dist/fetch.d.ts +2 -2
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetch.js +43 -15
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +1 -1
- package/dist/resolve.d.ts +2 -2
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +19 -7
- package/dist/url.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,65 @@ if (resolved.resolved && resolved.kind === "entity") {
|
|
|
24
24
|
}
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
## Astro / Vite (`import.meta.env`)
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { resolvePath, fetchJsonApi } from "@codewheel/jsonapi-frontend-client"
|
|
31
|
+
|
|
32
|
+
const baseUrl = import.meta.env.DRUPAL_BASE_URL
|
|
33
|
+
|
|
34
|
+
const resolved = await resolvePath("/about-us", { baseUrl })
|
|
35
|
+
if (resolved.resolved && resolved.kind === "entity") {
|
|
36
|
+
const doc = await fetchJsonApi(resolved.jsonapi_url, { baseUrl })
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Authentication (optional)
|
|
41
|
+
|
|
42
|
+
Keep credentials server-side. Pass headers via `options.headers`:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { resolvePath } from "@codewheel/jsonapi-frontend-client"
|
|
46
|
+
|
|
47
|
+
const baseUrl = process.env.DRUPAL_BASE_URL!
|
|
48
|
+
const auth = "Basic " + Buffer.from(`${process.env.DRUPAL_BASIC_USERNAME}:${process.env.DRUPAL_BASIC_PASSWORD}`).toString("base64")
|
|
49
|
+
|
|
50
|
+
await resolvePath("/about-us", {
|
|
51
|
+
baseUrl,
|
|
52
|
+
headers: { Authorization: auth },
|
|
53
|
+
})
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { resolvePath } from "@codewheel/jsonapi-frontend-client"
|
|
58
|
+
|
|
59
|
+
await resolvePath("/about-us", {
|
|
60
|
+
headers: { Authorization: `Bearer ${process.env.DRUPAL_JWT_TOKEN}` },
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Caching note (Next.js / SSR)
|
|
65
|
+
|
|
66
|
+
If you pass `Authorization` (or `Cookie`) headers, this client defaults to `cache: "no-store"` unless you explicitly set `options.init.cache`.
|
|
67
|
+
|
|
68
|
+
## Query building (optional)
|
|
69
|
+
|
|
70
|
+
This client doesn’t require a query builder, but `drupal-jsonapi-params` works well:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { DrupalJsonApiParams } from "drupal-jsonapi-params"
|
|
74
|
+
import { fetchJsonApi } from "@codewheel/jsonapi-frontend-client"
|
|
75
|
+
|
|
76
|
+
const baseUrl = process.env.DRUPAL_BASE_URL!
|
|
77
|
+
|
|
78
|
+
const params = new DrupalJsonApiParams()
|
|
79
|
+
.addFilter("status", "1")
|
|
80
|
+
.addFields("node--article", ["title", "path", "body"])
|
|
81
|
+
|
|
82
|
+
const url = `/jsonapi/node/article?${params.getQueryString()}`
|
|
83
|
+
await fetchJsonApi(url, { baseUrl })
|
|
84
|
+
```
|
|
85
|
+
|
|
27
86
|
## URL safety (recommended)
|
|
28
87
|
|
|
29
88
|
By default, `fetchJsonApi()` and `fetchView()` refuse to fetch absolute URLs on a different origin than your `DRUPAL_BASE_URL` (to avoid accidental SSRF in server environments).
|
package/dist/fetch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FetchInit, FetchLike } from "./transport";
|
|
2
|
-
import { JsonApiDocument } from "./types";
|
|
1
|
+
import { FetchInit, FetchLike } from "./transport.js";
|
|
2
|
+
import { JsonApiDocument } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Build cache tags for a JSON:API entity URL (e.g. /jsonapi/node/page/{uuid}).
|
|
5
5
|
*
|
package/dist/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAuD,MAAM,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAuD,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBlE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAa5D;AAwBD,wBAAsB,YAAY,CAAC,CAAC,GAAG,eAAe,EACpD,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,GACA,OAAO,CAAC,CAAC,CAAC,CAuDZ;AAED,wBAAsB,SAAS,CAAC,CAAC,GAAG,eAAe,EACjD,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACnD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,GACA,OAAO,CAAC,CAAC,CAAC,CAyDZ"}
|
package/dist/fetch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDrupalBaseUrlFromOptions, getFetch, mergeHeaders } from "./transport";
|
|
1
|
+
import { getDrupalBaseUrlFromOptions, getFetch, mergeHeaders } from "./transport.js";
|
|
2
2
|
/**
|
|
3
3
|
* Build cache tags for a JSON:API entity URL (e.g. /jsonapi/node/page/{uuid}).
|
|
4
4
|
*
|
|
@@ -46,6 +46,9 @@ function buildSafeUrl(input, base, options) {
|
|
|
46
46
|
}
|
|
47
47
|
return url;
|
|
48
48
|
}
|
|
49
|
+
function hasAuthLikeHeaders(headers) {
|
|
50
|
+
return headers.has("authorization") || headers.has("cookie");
|
|
51
|
+
}
|
|
49
52
|
export async function fetchJsonApi(jsonapiPath, options) {
|
|
50
53
|
const base = getDrupalBaseUrlFromOptions({ baseUrl: options?.baseUrl, envKey: options?.envKey });
|
|
51
54
|
const fetcher = getFetch(options?.fetch);
|
|
@@ -63,15 +66,28 @@ export async function fetchJsonApi(jsonapiPath, options) {
|
|
|
63
66
|
if (!headers.has("Accept")) {
|
|
64
67
|
headers.set("Accept", "application/vnd.api+json");
|
|
65
68
|
}
|
|
66
|
-
const
|
|
69
|
+
const hasExplicitCache = options?.init?.cache !== undefined;
|
|
70
|
+
const disableCaching = hasAuthLikeHeaders(headers) && !hasExplicitCache;
|
|
71
|
+
const init = {
|
|
67
72
|
...options?.init,
|
|
68
73
|
headers,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
|
+
if (disableCaching) {
|
|
76
|
+
init.cache = "no-store";
|
|
77
|
+
// Avoid mixing Next.js cache options with no-store.
|
|
78
|
+
delete init.next;
|
|
79
|
+
}
|
|
80
|
+
const fetchInit = disableCaching
|
|
81
|
+
? init
|
|
82
|
+
: {
|
|
83
|
+
...init,
|
|
84
|
+
next: {
|
|
85
|
+
...(options?.init?.next ?? {}),
|
|
86
|
+
revalidate: options?.revalidate,
|
|
87
|
+
tags: Array.from(new Set([...(options?.init?.next?.tags ?? []), ...tags])),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
const res = await fetcher(url.toString(), fetchInit);
|
|
75
91
|
if (!res.ok) {
|
|
76
92
|
throw new Error(`JSON:API fetch failed: ${res.status} ${res.statusText}`);
|
|
77
93
|
}
|
|
@@ -99,15 +115,27 @@ export async function fetchView(dataUrl, options) {
|
|
|
99
115
|
if (!headers.has("Accept")) {
|
|
100
116
|
headers.set("Accept", "application/vnd.api+json");
|
|
101
117
|
}
|
|
102
|
-
const
|
|
118
|
+
const hasExplicitCache = options?.init?.cache !== undefined;
|
|
119
|
+
const disableCaching = hasAuthLikeHeaders(headers) && !hasExplicitCache;
|
|
120
|
+
const init = {
|
|
103
121
|
...options?.init,
|
|
104
122
|
headers,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
123
|
+
};
|
|
124
|
+
if (disableCaching) {
|
|
125
|
+
init.cache = "no-store";
|
|
126
|
+
delete init.next;
|
|
127
|
+
}
|
|
128
|
+
const fetchInit = disableCaching
|
|
129
|
+
? init
|
|
130
|
+
: {
|
|
131
|
+
...init,
|
|
132
|
+
next: {
|
|
133
|
+
...(options?.init?.next ?? {}),
|
|
134
|
+
revalidate: options?.revalidate,
|
|
135
|
+
tags: Array.from(new Set([...(options?.init?.next?.tags ?? []), ...tags])),
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
const res = await fetcher(url.toString(), fetchInit);
|
|
111
139
|
if (!res.ok) {
|
|
112
140
|
throw new Error(`View fetch failed: ${res.status} ${res.statusText}`);
|
|
113
141
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { resolvePath } from "./resolve";
|
|
2
|
-
export { fetchJsonApi, fetchView } from "./fetch";
|
|
3
|
-
export { getDrupalBaseUrl, resolveFileUrl, getFileUrl, getImageStyleUrl } from "./url";
|
|
4
|
-
export { findIncluded, findIncludedByRelationship, findIncludedByRelationshipMultiple, extractImageFromFile, extractMedia, extractMediaField, extractPrimaryImage, extractEmbeddedMediaUuids, parseDrupalMediaTag, } from "./media";
|
|
5
|
-
export type { ResolveResponse, JsonApiDocument, JsonApiResource, JsonApiRelationship, JsonApiLinks, NodeAttributes, } from "./types";
|
|
6
|
-
export type { DrupalImageData, DrupalMediaData } from "./media";
|
|
7
|
-
export type { FetchInit, FetchLike } from "./transport";
|
|
1
|
+
export { resolvePath } from "./resolve.js";
|
|
2
|
+
export { fetchJsonApi, fetchView } from "./fetch.js";
|
|
3
|
+
export { getDrupalBaseUrl, resolveFileUrl, getFileUrl, getImageStyleUrl } from "./url.js";
|
|
4
|
+
export { findIncluded, findIncludedByRelationship, findIncludedByRelationshipMultiple, extractImageFromFile, extractMedia, extractMediaField, extractPrimaryImage, extractEmbeddedMediaUuids, parseDrupalMediaTag, } from "./media.js";
|
|
5
|
+
export type { ResolveResponse, JsonApiDocument, JsonApiResource, JsonApiRelationship, JsonApiLinks, NodeAttributes, } from "./types.js";
|
|
6
|
+
export type { DrupalImageData, DrupalMediaData } from "./media.js";
|
|
7
|
+
export type { FetchInit, FetchLike } from "./transport.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEpD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEzF,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,kCAAkC,EAClC,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAElE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { resolvePath } from "./resolve";
|
|
2
|
-
export { fetchJsonApi, fetchView } from "./fetch";
|
|
3
|
-
export { getDrupalBaseUrl, resolveFileUrl, getFileUrl, getImageStyleUrl } from "./url";
|
|
4
|
-
export { findIncluded, findIncludedByRelationship, findIncludedByRelationshipMultiple, extractImageFromFile, extractMedia, extractMediaField, extractPrimaryImage, extractEmbeddedMediaUuids, parseDrupalMediaTag, } from "./media";
|
|
1
|
+
export { resolvePath } from "./resolve.js";
|
|
2
|
+
export { fetchJsonApi, fetchView } from "./fetch.js";
|
|
3
|
+
export { getDrupalBaseUrl, resolveFileUrl, getFileUrl, getImageStyleUrl } from "./url.js";
|
|
4
|
+
export { findIncluded, findIncludedByRelationship, findIncludedByRelationshipMultiple, extractImageFromFile, extractMedia, extractMediaField, extractPrimaryImage, extractEmbeddedMediaUuids, parseDrupalMediaTag, } from "./media.js";
|
package/dist/media.d.ts
CHANGED
package/dist/media.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAGjE,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,cAAc,GAAG,OAAO,GAAG,SAAS,CAAA;IACvE,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,eAAe,CAAA;CAC1B;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,EACvC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,eAAe,GAAG,SAAS,CAE7B;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,EACvC,YAAY,EAAE,mBAAmB,GAAG,SAAS,GAC5C,eAAe,GAAG,SAAS,CAK7B;AAED,wBAAgB,kCAAkC,CAChD,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,EACvC,YAAY,EAAE,mBAAmB,GAAG,SAAS,GAC5C,eAAe,EAAE,CAUnB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,GAAG,SAAS,GAAG,eAAe,GAAG,IAAI,CAkB9F;AAcD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,eAAe,GAAG,SAAS,EAClC,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,GACtC,eAAe,GAAG,IAAI,CAgGxB;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,eAAe,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,GACtC,eAAe,EAAE,CAanB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,GAAG,eAAe,GAAG,IAAI,CAY5H;AAgBD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG/D;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAUhE"}
|
package/dist/media.js
CHANGED
package/dist/resolve.d.ts
CHANGED
package/dist/resolve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAuD,MAAM,gBAAgB,CAAA;AAE1G;;GAEG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,GACA,OAAO,CAAC,eAAe,CAAC,CA8C1B"}
|
package/dist/resolve.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDrupalBaseUrlFromOptions, getFetch, mergeHeaders } from "./transport";
|
|
1
|
+
import { getDrupalBaseUrlFromOptions, getFetch, mergeHeaders } from "./transport.js";
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a frontend path to a Drupal resource.
|
|
4
4
|
*/
|
|
@@ -15,14 +15,26 @@ export async function resolvePath(path, options) {
|
|
|
15
15
|
if (!headers.has("Accept")) {
|
|
16
16
|
headers.set("Accept", "application/vnd.api+json");
|
|
17
17
|
}
|
|
18
|
-
const
|
|
18
|
+
const hasExplicitCache = options?.init?.cache !== undefined;
|
|
19
|
+
const disableCaching = (headers.has("authorization") || headers.has("cookie")) && !hasExplicitCache;
|
|
20
|
+
const init = {
|
|
19
21
|
...options?.init,
|
|
20
22
|
headers,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
23
|
+
};
|
|
24
|
+
if (disableCaching) {
|
|
25
|
+
init.cache = "no-store";
|
|
26
|
+
delete init.next;
|
|
27
|
+
}
|
|
28
|
+
const fetchInit = disableCaching
|
|
29
|
+
? init
|
|
30
|
+
: {
|
|
31
|
+
...init,
|
|
32
|
+
next: {
|
|
33
|
+
...(options?.init?.next ?? {}),
|
|
34
|
+
revalidate: options?.revalidate,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const res = await fetcher(url.toString(), fetchInit);
|
|
26
38
|
if (!res.ok) {
|
|
27
39
|
throw new Error(`Resolver failed: ${res.status} ${res.statusText}`);
|
|
28
40
|
}
|
package/dist/url.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codewheel/jsonapi-frontend-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "TypeScript client helpers for Drupal drupal/jsonapi_frontend",
|
|
5
5
|
"homepage": "https://github.com/code-wheel/jsonapi-frontend-client#readme",
|
|
6
6
|
"repository": {
|