@wpnuxt/core 1.0.0-edge.11 → 1.0.0-edge.12
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/dist/module.d.mts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -7
- package/dist/runtime/components/ContentRenderer.vue +2 -2
- package/dist/runtime/composables/useWPContent.d.ts +1 -1
- package/dist/runtime/server/api/wpContent.post.d.ts +1 -4
- package/dist/runtime/server/api/wpContent.post.js +13 -19
- package/package.json +9 -9
- package/dist/runtime/server/api/purgeCache.get.d.ts +0 -5
- package/dist/runtime/server/api/purgeCache.get.js +0 -9
- package/dist/runtime/server/storage.d.ts +0 -3
- package/dist/runtime/server/storage.js +0 -11
package/dist/module.d.mts
CHANGED
|
@@ -63,7 +63,7 @@ interface WPNuxtConfigQueries {
|
|
|
63
63
|
outputDir?: string
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
declare const _default: _nuxt_schema.NuxtModule<WPNuxtConfig>;
|
|
66
|
+
declare const _default: _nuxt_schema.NuxtModule<WPNuxtConfig, WPNuxtConfig, false>;
|
|
67
67
|
|
|
68
68
|
declare module '@nuxt/schema' {
|
|
69
69
|
interface RuntimeConfig {
|
package/dist/module.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ interface WPNuxtConfigQueries {
|
|
|
63
63
|
outputDir?: string
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
declare const _default: _nuxt_schema.NuxtModule<WPNuxtConfig>;
|
|
66
|
+
declare const _default: _nuxt_schema.NuxtModule<WPNuxtConfig, WPNuxtConfig, false>;
|
|
67
67
|
|
|
68
68
|
declare module '@nuxt/schema' {
|
|
69
69
|
interface RuntimeConfig {
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { upperFirst } from 'scule';
|
|
|
7
7
|
import { parse } from 'graphql';
|
|
8
8
|
|
|
9
9
|
const name = "@wpnuxt/core";
|
|
10
|
-
const version = "1.0.0-edge.
|
|
10
|
+
const version = "1.0.0-edge.12";
|
|
11
11
|
|
|
12
12
|
const loggerRef = ref();
|
|
13
13
|
const initLogger = (logLevel) => {
|
|
@@ -217,10 +217,6 @@ const module = defineNuxtModule({
|
|
|
217
217
|
route: "/api/wpContent",
|
|
218
218
|
handler: resolveRuntimeModule("./server/api/wpContent.post")
|
|
219
219
|
});
|
|
220
|
-
addServerHandler({
|
|
221
|
-
route: "/api/purgeCache",
|
|
222
|
-
handler: resolveRuntimeModule("./server/api/purgeCache.get")
|
|
223
|
-
});
|
|
224
220
|
await installModule("@vueuse/nuxt", {});
|
|
225
221
|
const queryOutputPath = resolve((nuxt.options.srcDir || nuxt.options.rootDir) + "/.queries/");
|
|
226
222
|
await promises.rm(queryOutputPath, { recursive: true, force: true });
|
|
@@ -331,9 +327,9 @@ const module = defineNuxtModule({
|
|
|
331
327
|
autoimports.push(...ctx.fnImports || []);
|
|
332
328
|
});
|
|
333
329
|
nuxt.hook("nitro:init", async (nitro) => {
|
|
334
|
-
const keys = await nitro.storage.getKeys("cache:
|
|
330
|
+
const keys = await nitro.storage.getKeys("cache:api:wpContent");
|
|
335
331
|
keys.forEach(async (key) => {
|
|
336
|
-
if (key.startsWith("cache:
|
|
332
|
+
if (key.startsWith("cache:api:wpContent"))
|
|
337
333
|
await nitro.storage.removeItem(key);
|
|
338
334
|
});
|
|
339
335
|
});
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import type { NodeWithContentEditorFragment } from '#build/graphql-operations'
|
|
3
3
|
|
|
4
4
|
defineProps<{
|
|
5
|
-
|
|
5
|
+
node: NodeWithContentEditorFragment
|
|
6
6
|
}>()
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
10
|
<div
|
|
11
|
-
v-sanitize="
|
|
11
|
+
v-sanitize="node.content"
|
|
12
12
|
/>
|
|
13
13
|
</template>
|
|
@@ -1,39 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { useRuntimeConfig } from "#imports";
|
|
5
|
-
export default defineEventHandler(async (event) => {
|
|
6
|
-
const config = useRuntimeConfig();
|
|
1
|
+
import { readBody } from "h3";
|
|
2
|
+
import { defineCachedEventHandler } from "#internal/nitro";
|
|
3
|
+
export default defineCachedEventHandler(async (event) => {
|
|
7
4
|
const body = await readBody(event);
|
|
8
|
-
const staging = await isStaging();
|
|
9
5
|
if (!body || !body.queryName) {
|
|
10
6
|
throw new Error(
|
|
11
7
|
"The request must contain a queryName"
|
|
12
8
|
);
|
|
13
9
|
}
|
|
14
|
-
const cacheKey = `wpContent-${body.queryName}-${body.params ? JSON.stringify(body.params).replaceAll('"', "").replaceAll(":", "-") : ""}`;
|
|
15
|
-
if (config.public.wpNuxt.enableCache && !staging) {
|
|
16
|
-
const cachedContent = await cacheStorage.getItem(cacheKey);
|
|
17
|
-
if (cachedContent) {
|
|
18
|
-
return {
|
|
19
|
-
data: cachedContent,
|
|
20
|
-
errors: []
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
10
|
return $fetch("/api/graphql_middleware/query/" + body.queryName, {
|
|
25
11
|
params: buildRequestParams(body.params),
|
|
26
12
|
headers: {
|
|
27
13
|
Authorization: `Bearer ${event.context.accessToken}`
|
|
28
14
|
}
|
|
29
15
|
}).then((v) => {
|
|
30
|
-
cacheStorage.setItem(cacheKey, v.data).catch(() => {
|
|
31
|
-
});
|
|
32
16
|
return {
|
|
33
17
|
data: v.data,
|
|
34
18
|
errors: v.errors || []
|
|
35
19
|
};
|
|
36
20
|
});
|
|
21
|
+
}, {
|
|
22
|
+
group: "api",
|
|
23
|
+
name: "wpContent",
|
|
24
|
+
getKey: async (event) => {
|
|
25
|
+
const body = await readBody(event);
|
|
26
|
+
return `${body.queryName}${body.params ? "_" + JSON.stringify(body.params).replaceAll('"', "").replaceAll(":", "_") : ""}`;
|
|
27
|
+
},
|
|
28
|
+
swr: true,
|
|
29
|
+
maxAge: 60 * 5
|
|
30
|
+
// 5 minutes
|
|
37
31
|
});
|
|
38
32
|
export function buildRequestParams(variables) {
|
|
39
33
|
if (!variables) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wpnuxt/core",
|
|
3
|
-
"version": "1.0.0-edge.
|
|
3
|
+
"version": "1.0.0-edge.12",
|
|
4
4
|
"description": "WPNuxt",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"start": "pnpm run wp-env:create && pnpm run dev"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@nuxt/kit": "3.
|
|
55
|
+
"@nuxt/kit": "3.13.0",
|
|
56
56
|
"@vueuse/nuxt": "^11.0.0",
|
|
57
57
|
"defu": "^6.1.4",
|
|
58
58
|
"graphql": "^16.9.0",
|
|
@@ -65,27 +65,27 @@
|
|
|
65
65
|
"@graphql-codegen/cli": "^5.0.2",
|
|
66
66
|
"@graphql-codegen/client-preset": "^4.3.3",
|
|
67
67
|
"@graphql-codegen/typescript-operations": "^4.2.3",
|
|
68
|
-
"@nuxt/devtools": "^1.3.
|
|
69
|
-
"@nuxt/eslint-config": "^0.5.
|
|
68
|
+
"@nuxt/devtools": "^1.3.14",
|
|
69
|
+
"@nuxt/eslint-config": "^0.5.2",
|
|
70
70
|
"@nuxt/module-builder": "^0.8.3",
|
|
71
|
-
"@nuxt/schema": "3.
|
|
71
|
+
"@nuxt/schema": "3.13.0",
|
|
72
72
|
"@nuxt/test-utils": "^3.14.1",
|
|
73
73
|
"@rollup/rollup-linux-arm64-gnu": "^4.20.0",
|
|
74
74
|
"@rollup/rollup-linux-arm64-musl": "^4.20.0",
|
|
75
|
-
"@types/node": "22.
|
|
75
|
+
"@types/node": "22.5.0",
|
|
76
76
|
"@vitest/coverage-v8": "^2.0.5",
|
|
77
77
|
"@vue/test-utils": "^2.4.6",
|
|
78
|
-
"@wordpress/env": "^10.
|
|
78
|
+
"@wordpress/env": "^10.6.0",
|
|
79
79
|
"changelogen": "^0.5.5",
|
|
80
80
|
"markdownlint-cli": "^0.41.0",
|
|
81
|
-
"nuxt": "^3.
|
|
81
|
+
"nuxt": "^3.13.0",
|
|
82
82
|
"nuxt-content-twoslash": "^0.1.1",
|
|
83
83
|
"release-it": "^17.6.0",
|
|
84
84
|
"shiki": "^1.13.0",
|
|
85
85
|
"twoslash": "^0.2.9",
|
|
86
86
|
"typescript": "^5.5.4",
|
|
87
87
|
"untyped": "1.4.2",
|
|
88
|
-
"vite": "^5.4.
|
|
88
|
+
"vite": "^5.4.2",
|
|
89
89
|
"vitest": "^2.0.5",
|
|
90
90
|
"vue-docgen-web-types": "^0.1.8",
|
|
91
91
|
"vue-tsc": "2.0.29"
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { prefixStorage } from "unstorage";
|
|
2
|
-
import { useLogger } from "../util/logger.js";
|
|
3
|
-
import { useStorage } from "#imports";
|
|
4
|
-
export const cacheStorage = prefixStorage(useStorage(), "cache:wpnuxt-content");
|
|
5
|
-
export const purgeCache = async () => {
|
|
6
|
-
const keys = await cacheStorage.getKeys("cache:wpnuxt-content");
|
|
7
|
-
keys.forEach(async (key) => {
|
|
8
|
-
await cacheStorage.removeItem(key);
|
|
9
|
-
});
|
|
10
|
-
useLogger().info("ServerSide cache purged!");
|
|
11
|
-
};
|