@wpnuxt/core 1.0.0-edge.13 → 1.0.0-edge.15
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 +9 -1
- package/dist/module.d.ts +9 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -3
- package/dist/runtime/components/StagingBanner.vue +2 -1
- package/dist/runtime/composables/usePrevNextPost.js +2 -1
- package/dist/runtime/composables/useWPContent.d.ts +2 -1
- package/dist/runtime/composables/useWPContent.js +2 -1
- package/dist/runtime/server/api/wpContent.post.js +4 -2
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
|
@@ -63,6 +63,14 @@ interface WPNuxtConfigQueries {
|
|
|
63
63
|
outputDir?: string
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
type WPNuxtQuery = {
|
|
67
|
+
name: string
|
|
68
|
+
nodes?: string[]
|
|
69
|
+
fragments: string[]
|
|
70
|
+
params: Record<string, string>
|
|
71
|
+
operation: OperationTypeNode
|
|
72
|
+
}
|
|
73
|
+
|
|
66
74
|
declare const _default: _nuxt_schema.NuxtModule<WPNuxtConfig, WPNuxtConfig, false>;
|
|
67
75
|
|
|
68
76
|
declare module '@nuxt/schema' {
|
|
@@ -86,4 +94,4 @@ declare module '@nuxt/schema' {
|
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
96
|
|
|
89
|
-
export { _default as default };
|
|
97
|
+
export { type WPNuxtConfig, type WPNuxtConfigQueries, type WPNuxtQuery, _default as default };
|
package/dist/module.d.ts
CHANGED
|
@@ -63,6 +63,14 @@ interface WPNuxtConfigQueries {
|
|
|
63
63
|
outputDir?: string
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
type WPNuxtQuery = {
|
|
67
|
+
name: string
|
|
68
|
+
nodes?: string[]
|
|
69
|
+
fragments: string[]
|
|
70
|
+
params: Record<string, string>
|
|
71
|
+
operation: OperationTypeNode
|
|
72
|
+
}
|
|
73
|
+
|
|
66
74
|
declare const _default: _nuxt_schema.NuxtModule<WPNuxtConfig, WPNuxtConfig, false>;
|
|
67
75
|
|
|
68
76
|
declare module '@nuxt/schema' {
|
|
@@ -86,4 +94,4 @@ declare module '@nuxt/schema' {
|
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
96
|
|
|
89
|
-
export { _default as default };
|
|
97
|
+
export { type WPNuxtConfig, type WPNuxtConfigQueries, type WPNuxtQuery, _default as default };
|
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.15";
|
|
11
11
|
|
|
12
12
|
const loggerRef = ref();
|
|
13
13
|
const initLogger = (logLevel) => {
|
|
@@ -49,7 +49,8 @@ const _parseDoc = async (doc) => {
|
|
|
49
49
|
name: operationDefinition.name.value.trim(),
|
|
50
50
|
nodes: [],
|
|
51
51
|
fragments: [],
|
|
52
|
-
params: {}
|
|
52
|
+
params: {},
|
|
53
|
+
operation: operationDefinition.operation
|
|
53
54
|
};
|
|
54
55
|
processSelections(operationDefinition.selectionSet.selections, 0, query);
|
|
55
56
|
return query;
|
|
@@ -81,7 +82,7 @@ async function prepareContext(ctx) {
|
|
|
81
82
|
const fnExp = (q, typed = false) => {
|
|
82
83
|
const functionName = fnName(q.name);
|
|
83
84
|
if (!typed) {
|
|
84
|
-
return `export const ${functionName} = (params) => useWPContent('${q.name}', [${q.nodes?.map((n) => `'${n}'`).join(",")}], false, params)`;
|
|
85
|
+
return `export const ${functionName} = (params) => useWPContent('${q.operation}', '${q.name}', [${q.nodes?.map((n) => `'${n}'`).join(",")}], false, params)`;
|
|
85
86
|
}
|
|
86
87
|
const fragmentSuffix = q.fragments?.length && q.nodes?.includes("nodes") ? "[]" : "";
|
|
87
88
|
const fragments = q.fragments?.length ? q.fragments.map((f) => `${f}Fragment${fragmentSuffix}`).join(" | ") : "any";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { OperationTypeNode } from 'graphql'
|
|
2
3
|
import { useWPUri } from '../composables/useWPUri'
|
|
3
4
|
import { useWPContent } from '../composables'
|
|
4
5
|
import WPNuxtLogo from './WPNuxtLogo.vue'
|
|
@@ -27,7 +28,7 @@ if (uri.startsWith('/')) {
|
|
|
27
28
|
if (uri.endsWith('/')) {
|
|
28
29
|
uri = uri.substring(0, uri.length - 1)
|
|
29
30
|
}
|
|
30
|
-
const { data: post } = await useWPContent('NodeByUri', ['nodeByUri'], false, { uri: uri })
|
|
31
|
+
const { data: post } = await useWPContent(OperationTypeNode.QUERY, 'NodeByUri', ['nodeByUri'], false, { uri: uri })
|
|
31
32
|
|
|
32
33
|
if (import.meta.client) {
|
|
33
34
|
document.body.style.marginBottom = '40px'
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OperationTypeNode } from "graphql";
|
|
1
2
|
import { useWPContent } from "./useWPContent.js";
|
|
2
3
|
const _usePrevNextPost = async (currentPostSlug) => {
|
|
3
4
|
const allPosts = await getAllPosts();
|
|
@@ -11,7 +12,7 @@ const _usePrevNextPost = async (currentPostSlug) => {
|
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
const getAllPosts = async () => {
|
|
14
|
-
const { data: allPosts } = await useWPContent("Posts", ["posts", "nodes"], false);
|
|
15
|
+
const { data: allPosts } = await useWPContent(OperationTypeNode.QUERY, "Posts", ["posts", "nodes"], false);
|
|
15
16
|
if (allPosts) {
|
|
16
17
|
return {
|
|
17
18
|
slugs: allPosts?.map((post) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FetchError } from 'ofetch';
|
|
2
|
-
|
|
2
|
+
import type { OperationTypeNode } from 'graphql';
|
|
3
|
+
export declare const useWPContent: <T>(operation: OperationTypeNode, queryName: string, nodes: string[], fixImagePaths: boolean, params?: T) => Promise<{
|
|
3
4
|
data: unknown;
|
|
4
5
|
error: import("vue").Ref<FetchError<any> | null>;
|
|
5
6
|
}>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getRelativeImagePath } from "../util/images.js";
|
|
2
|
-
const _useWPContent = async (queryName, nodes, fixImagePaths, params) => {
|
|
2
|
+
const _useWPContent = async (operation, queryName, nodes, fixImagePaths, params) => {
|
|
3
3
|
const { data, error } = await $fetch("/api/wpContent", {
|
|
4
4
|
method: "POST",
|
|
5
5
|
body: {
|
|
6
|
+
operation,
|
|
6
7
|
queryName,
|
|
7
8
|
params
|
|
8
9
|
}
|
|
@@ -7,8 +7,10 @@ export default defineCachedEventHandler(async (event) => {
|
|
|
7
7
|
"The request must contain a queryName"
|
|
8
8
|
);
|
|
9
9
|
}
|
|
10
|
-
return $fetch("/api/graphql_middleware/query/" + body.queryName, {
|
|
11
|
-
|
|
10
|
+
return $fetch("/api/graphql_middleware/" + (body.operation || "query") + "/" + body.queryName, {
|
|
11
|
+
method: body.operation === "mutation" ? "POST" : "GET",
|
|
12
|
+
params: body.operation === "query" ? buildRequestParams(body.params) : void 0,
|
|
13
|
+
body: body.operation === "mutation" ? body.params : void 0,
|
|
12
14
|
headers: {
|
|
13
15
|
Authorization: `Bearer ${event.context.accessToken}`
|
|
14
16
|
}
|
package/dist/types.d.mts
CHANGED
|
@@ -4,4 +4,4 @@ import type { default as Module } from './module.js'
|
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
-
export { default } from './module.js'
|
|
7
|
+
export { type WPNuxtConfig, type WPNuxtConfigQueries, type WPNuxtQuery, default } from './module.js'
|
package/dist/types.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ import type { default as Module } from './module'
|
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
-
export { default } from './module'
|
|
7
|
+
export { type WPNuxtConfig, type WPNuxtConfigQueries, type WPNuxtQuery, default } from './module'
|