@readpress/wp-blog 1.0.0
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/LICENSE +21 -0
- package/README.md +35 -0
- package/dist/chunk-QKYYHVDQ.mjs +105 -0
- package/dist/index.d.mts +78 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +1326 -0
- package/dist/index.mjs +1196 -0
- package/dist/react.d.mts +16 -0
- package/dist/react.d.ts +16 -0
- package/dist/react.js +167 -0
- package/dist/react.mjs +51 -0
- package/dist/types-BDmCnhFG.d.mts +248 -0
- package/dist/types-BDmCnhFG.d.ts +248 -0
- package/dist/types-CRE-VxVN.d.mts +234 -0
- package/dist/types-CRE-VxVN.d.ts +234 -0
- package/dist/types-DUV474Vy.d.mts +211 -0
- package/dist/types-DUV474Vy.d.ts +211 -0
- package/dist/types-Ds1ProIy.d.mts +238 -0
- package/dist/types-Ds1ProIy.d.ts +238 -0
- package/package.json +59 -0
package/dist/react.d.mts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
import { W as WpContentPart } from './types-BDmCnhFG.mjs';
|
|
4
|
+
|
|
5
|
+
type WpPlaceholderComponents = Record<string, ComponentType<Record<string, unknown>>>;
|
|
6
|
+
interface WpContentProps {
|
|
7
|
+
contentHtml?: string;
|
|
8
|
+
contentParts?: WpContentPart[];
|
|
9
|
+
components?: WpPlaceholderComponents;
|
|
10
|
+
placeholderNamespace?: string;
|
|
11
|
+
maxPlaceholderPropsLength?: number;
|
|
12
|
+
unknownPlaceholder?: "ignore" | "comment";
|
|
13
|
+
}
|
|
14
|
+
declare function WpContent({ contentHtml, contentParts, components, placeholderNamespace, maxPlaceholderPropsLength, unknownPlaceholder, }: WpContentProps): react_jsx_runtime.JSX.Element;
|
|
15
|
+
|
|
16
|
+
export { WpContent, type WpContentProps, type WpPlaceholderComponents };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
import { W as WpContentPart } from './types-BDmCnhFG.js';
|
|
4
|
+
|
|
5
|
+
type WpPlaceholderComponents = Record<string, ComponentType<Record<string, unknown>>>;
|
|
6
|
+
interface WpContentProps {
|
|
7
|
+
contentHtml?: string;
|
|
8
|
+
contentParts?: WpContentPart[];
|
|
9
|
+
components?: WpPlaceholderComponents;
|
|
10
|
+
placeholderNamespace?: string;
|
|
11
|
+
maxPlaceholderPropsLength?: number;
|
|
12
|
+
unknownPlaceholder?: "ignore" | "comment";
|
|
13
|
+
}
|
|
14
|
+
declare function WpContent({ contentHtml, contentParts, components, placeholderNamespace, maxPlaceholderPropsLength, unknownPlaceholder, }: WpContentProps): react_jsx_runtime.JSX.Element;
|
|
15
|
+
|
|
16
|
+
export { WpContent, type WpContentProps, type WpPlaceholderComponents };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
+
for (let key of __getOwnPropNames(from))
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
+
}
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
|
|
34
|
+
// src/react.tsx
|
|
35
|
+
var react_exports = {};
|
|
36
|
+
__export(react_exports, {
|
|
37
|
+
WpContent: () => WpContent
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(react_exports);
|
|
40
|
+
|
|
41
|
+
// src/domain/placeholders.ts
|
|
42
|
+
var DEFAULT_NAMESPACE = "wpapp";
|
|
43
|
+
var DEFAULT_MAX_PROPS_LENGTH = 1e4;
|
|
44
|
+
var PLACEHOLDER_NAME_REGEX = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
45
|
+
function escapeRegex(value) {
|
|
46
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
47
|
+
}
|
|
48
|
+
function normalizeNamespace(value) {
|
|
49
|
+
const trimmed = value == null ? void 0 : value.trim();
|
|
50
|
+
if (!trimmed) {
|
|
51
|
+
return DEFAULT_NAMESPACE;
|
|
52
|
+
}
|
|
53
|
+
return trimmed;
|
|
54
|
+
}
|
|
55
|
+
function normalizeMaxPropsLength(value) {
|
|
56
|
+
if (!value || !Number.isInteger(value) || value <= 0) {
|
|
57
|
+
return DEFAULT_MAX_PROPS_LENGTH;
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
function parseProps(rawProps, maxPropsLength) {
|
|
62
|
+
const trimmed = rawProps == null ? void 0 : rawProps.trim();
|
|
63
|
+
if (!trimmed) {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
if (trimmed.length > maxPropsLength) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const parsed = JSON.parse(trimmed);
|
|
71
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return parsed;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function parseContentPlaceholders(contentHtml, options = {}) {
|
|
80
|
+
if (!contentHtml) {
|
|
81
|
+
return [{ type: "html", html: "" }];
|
|
82
|
+
}
|
|
83
|
+
const namespace = normalizeNamespace(options.namespace);
|
|
84
|
+
const maxPropsLength = normalizeMaxPropsLength(options.maxPropsLength);
|
|
85
|
+
const markerRegex = new RegExp(
|
|
86
|
+
`<!--\\s*${escapeRegex(namespace)}:([A-Za-z][A-Za-z0-9_-]*)(?:\\s+([\\s\\S]*?))?\\s*-->`,
|
|
87
|
+
"g"
|
|
88
|
+
);
|
|
89
|
+
const parts = [];
|
|
90
|
+
let cursor = 0;
|
|
91
|
+
let match;
|
|
92
|
+
while ((match = markerRegex.exec(contentHtml)) !== null) {
|
|
93
|
+
const [fullMatch, rawName, rawProps] = match;
|
|
94
|
+
const matchIndex = match.index;
|
|
95
|
+
if (matchIndex > cursor) {
|
|
96
|
+
parts.push({ type: "html", html: contentHtml.slice(cursor, matchIndex) });
|
|
97
|
+
}
|
|
98
|
+
const name = rawName == null ? void 0 : rawName.trim();
|
|
99
|
+
const props = parseProps(rawProps, maxPropsLength);
|
|
100
|
+
if (!name || !PLACEHOLDER_NAME_REGEX.test(name) || !props) {
|
|
101
|
+
parts.push({ type: "html", html: fullMatch });
|
|
102
|
+
cursor = markerRegex.lastIndex;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
parts.push({
|
|
106
|
+
type: "placeholder",
|
|
107
|
+
name,
|
|
108
|
+
props
|
|
109
|
+
});
|
|
110
|
+
cursor = markerRegex.lastIndex;
|
|
111
|
+
}
|
|
112
|
+
if (cursor < contentHtml.length) {
|
|
113
|
+
parts.push({ type: "html", html: contentHtml.slice(cursor) });
|
|
114
|
+
}
|
|
115
|
+
if (parts.length === 0) {
|
|
116
|
+
return [{ type: "html", html: contentHtml }];
|
|
117
|
+
}
|
|
118
|
+
return parts;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/react.tsx
|
|
122
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
123
|
+
function getParts(props) {
|
|
124
|
+
var _a;
|
|
125
|
+
if (props.contentParts) {
|
|
126
|
+
return props.contentParts;
|
|
127
|
+
}
|
|
128
|
+
const options = {
|
|
129
|
+
namespace: props.placeholderNamespace,
|
|
130
|
+
maxPropsLength: props.maxPlaceholderPropsLength
|
|
131
|
+
};
|
|
132
|
+
return parseContentPlaceholders((_a = props.contentHtml) != null ? _a : "", options);
|
|
133
|
+
}
|
|
134
|
+
function WpContent({
|
|
135
|
+
contentHtml,
|
|
136
|
+
contentParts,
|
|
137
|
+
components = {},
|
|
138
|
+
placeholderNamespace,
|
|
139
|
+
maxPlaceholderPropsLength,
|
|
140
|
+
unknownPlaceholder = "ignore"
|
|
141
|
+
}) {
|
|
142
|
+
const parts = getParts({
|
|
143
|
+
contentHtml,
|
|
144
|
+
contentParts,
|
|
145
|
+
components,
|
|
146
|
+
placeholderNamespace,
|
|
147
|
+
maxPlaceholderPropsLength,
|
|
148
|
+
unknownPlaceholder
|
|
149
|
+
});
|
|
150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: parts.map((part, index) => {
|
|
151
|
+
if (part.type === "html") {
|
|
152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { dangerouslySetInnerHTML: { __html: part.html } }, `html-${index}`);
|
|
153
|
+
}
|
|
154
|
+
const Component = components[part.name];
|
|
155
|
+
if (!Component) {
|
|
156
|
+
if (unknownPlaceholder === "comment") {
|
|
157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "data-wp-placeholder": part.name, hidden: true }, `unknown-${part.name}-${index}`);
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadValues({}, part.props), `placeholder-${part.name}-${index}`);
|
|
162
|
+
}) });
|
|
163
|
+
}
|
|
164
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
165
|
+
0 && (module.exports = {
|
|
166
|
+
WpContent
|
|
167
|
+
});
|
package/dist/react.mjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadValues,
|
|
3
|
+
parseContentPlaceholders
|
|
4
|
+
} from "./chunk-QKYYHVDQ.mjs";
|
|
5
|
+
|
|
6
|
+
// src/react.tsx
|
|
7
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
8
|
+
function getParts(props) {
|
|
9
|
+
var _a;
|
|
10
|
+
if (props.contentParts) {
|
|
11
|
+
return props.contentParts;
|
|
12
|
+
}
|
|
13
|
+
const options = {
|
|
14
|
+
namespace: props.placeholderNamespace,
|
|
15
|
+
maxPropsLength: props.maxPlaceholderPropsLength
|
|
16
|
+
};
|
|
17
|
+
return parseContentPlaceholders((_a = props.contentHtml) != null ? _a : "", options);
|
|
18
|
+
}
|
|
19
|
+
function WpContent({
|
|
20
|
+
contentHtml,
|
|
21
|
+
contentParts,
|
|
22
|
+
components = {},
|
|
23
|
+
placeholderNamespace,
|
|
24
|
+
maxPlaceholderPropsLength,
|
|
25
|
+
unknownPlaceholder = "ignore"
|
|
26
|
+
}) {
|
|
27
|
+
const parts = getParts({
|
|
28
|
+
contentHtml,
|
|
29
|
+
contentParts,
|
|
30
|
+
components,
|
|
31
|
+
placeholderNamespace,
|
|
32
|
+
maxPlaceholderPropsLength,
|
|
33
|
+
unknownPlaceholder
|
|
34
|
+
});
|
|
35
|
+
return /* @__PURE__ */ jsx(Fragment, { children: parts.map((part, index) => {
|
|
36
|
+
if (part.type === "html") {
|
|
37
|
+
return /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: part.html } }, `html-${index}`);
|
|
38
|
+
}
|
|
39
|
+
const Component = components[part.name];
|
|
40
|
+
if (!Component) {
|
|
41
|
+
if (unknownPlaceholder === "comment") {
|
|
42
|
+
return /* @__PURE__ */ jsx("span", { "data-wp-placeholder": part.name, hidden: true }, `unknown-${part.name}-${index}`);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return /* @__PURE__ */ jsx(Component, __spreadValues({}, part.props), `placeholder-${part.name}-${index}`);
|
|
47
|
+
}) });
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
WpContent
|
|
51
|
+
};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
interface WpRenderedField {
|
|
2
|
+
rendered: string;
|
|
3
|
+
}
|
|
4
|
+
interface WpFeaturedMedia {
|
|
5
|
+
source_url?: string;
|
|
6
|
+
}
|
|
7
|
+
interface WpTerm {
|
|
8
|
+
id: number;
|
|
9
|
+
slug?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
taxonomy?: string;
|
|
12
|
+
count?: number;
|
|
13
|
+
}
|
|
14
|
+
interface WpAuthor {
|
|
15
|
+
id: number;
|
|
16
|
+
name?: string;
|
|
17
|
+
slug?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
link?: string;
|
|
21
|
+
avatar_urls?: Record<string, string>;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
interface WpEmbedded {
|
|
25
|
+
"wp:featuredmedia"?: WpFeaturedMedia[];
|
|
26
|
+
"wp:term"?: WpTerm[][];
|
|
27
|
+
author?: WpAuthor[];
|
|
28
|
+
}
|
|
29
|
+
interface WpPost {
|
|
30
|
+
id: number;
|
|
31
|
+
slug: string;
|
|
32
|
+
link: string;
|
|
33
|
+
date: string;
|
|
34
|
+
modified: string;
|
|
35
|
+
title: WpRenderedField;
|
|
36
|
+
excerpt: WpRenderedField;
|
|
37
|
+
content: WpRenderedField;
|
|
38
|
+
_embedded?: WpEmbedded;
|
|
39
|
+
}
|
|
40
|
+
interface LinkRewriteContext {
|
|
41
|
+
href: string;
|
|
42
|
+
pathname: string;
|
|
43
|
+
search: string;
|
|
44
|
+
hash: string;
|
|
45
|
+
}
|
|
46
|
+
interface LinkRewriteRule {
|
|
47
|
+
source: string;
|
|
48
|
+
destination?: string;
|
|
49
|
+
action?: "ignore";
|
|
50
|
+
transform?: (context: LinkRewriteContext) => string;
|
|
51
|
+
}
|
|
52
|
+
type ClassNameMapMode = "append" | "replace" | "replace-all";
|
|
53
|
+
interface ClassNameMapRule {
|
|
54
|
+
className: string;
|
|
55
|
+
mode?: ClassNameMapMode;
|
|
56
|
+
}
|
|
57
|
+
type ClassNameMapValue = string | ClassNameMapRule;
|
|
58
|
+
type ClassNameMap = Record<string, ClassNameMapValue>;
|
|
59
|
+
type PlaceholderProps = Record<string, unknown>;
|
|
60
|
+
interface HtmlContentPart {
|
|
61
|
+
type: "html";
|
|
62
|
+
html: string;
|
|
63
|
+
}
|
|
64
|
+
interface PlaceholderContentPart {
|
|
65
|
+
type: "placeholder";
|
|
66
|
+
name: string;
|
|
67
|
+
props: PlaceholderProps;
|
|
68
|
+
}
|
|
69
|
+
type WpContentPart = HtmlContentPart | PlaceholderContentPart;
|
|
70
|
+
interface PlaceholderParseOptions {
|
|
71
|
+
namespace?: string;
|
|
72
|
+
maxPropsLength?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Normalized post shape returned by this package.
|
|
76
|
+
*/
|
|
77
|
+
interface BlogPostSummary {
|
|
78
|
+
id: number;
|
|
79
|
+
slug: string;
|
|
80
|
+
url: string;
|
|
81
|
+
date: string;
|
|
82
|
+
modified: string;
|
|
83
|
+
publishedDate: string;
|
|
84
|
+
updatedDate: string;
|
|
85
|
+
title: string;
|
|
86
|
+
excerpt: string;
|
|
87
|
+
featuredImageUrl: string | null;
|
|
88
|
+
author: BlogAuthor | null;
|
|
89
|
+
categories: BlogTerm[];
|
|
90
|
+
tags: BlogTerm[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Full post shape returned by single-post methods.
|
|
94
|
+
*/
|
|
95
|
+
interface BlogPost extends BlogPostSummary {
|
|
96
|
+
contentHtml: string;
|
|
97
|
+
}
|
|
98
|
+
interface BlogTerm {
|
|
99
|
+
id: number;
|
|
100
|
+
slug: string;
|
|
101
|
+
name: string;
|
|
102
|
+
count: number;
|
|
103
|
+
}
|
|
104
|
+
type BlogAuthor = WpAuthor;
|
|
105
|
+
type BlogTermOrder = "default" | "alphabetical" | "count";
|
|
106
|
+
interface GetTermsParams {
|
|
107
|
+
order?: BlogTermOrder;
|
|
108
|
+
}
|
|
109
|
+
interface GetAuthorsParams {
|
|
110
|
+
page?: number;
|
|
111
|
+
perPage?: number;
|
|
112
|
+
}
|
|
113
|
+
type BlogTextMode = "plain" | "html";
|
|
114
|
+
type BlogPostSummaryField = keyof BlogPostSummary;
|
|
115
|
+
type BlogPostField = keyof BlogPost;
|
|
116
|
+
type SelectFields<T, TSelect extends readonly (keyof T)[] | undefined> = TSelect extends readonly (keyof T)[] ? Pick<T, TSelect[number]> : T;
|
|
117
|
+
/**
|
|
118
|
+
* Pagination metadata returned from list endpoints.
|
|
119
|
+
*/
|
|
120
|
+
interface PaginationMeta {
|
|
121
|
+
page: number;
|
|
122
|
+
perPage: number;
|
|
123
|
+
totalItems: number;
|
|
124
|
+
totalPages: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Response returned by getPosts.
|
|
128
|
+
*/
|
|
129
|
+
interface PostListResult<TItem = BlogPostSummary> {
|
|
130
|
+
items: TItem[];
|
|
131
|
+
pagination: PaginationMeta;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Optional pagination parameters for getPosts.
|
|
135
|
+
*/
|
|
136
|
+
interface GetPostsParams<TSelect extends readonly BlogPostSummaryField[] | undefined = undefined> {
|
|
137
|
+
page?: number;
|
|
138
|
+
perPage?: number;
|
|
139
|
+
status?: "draft" | "private" | "publish" | "any";
|
|
140
|
+
categorySlug?: string;
|
|
141
|
+
tagSlug?: string;
|
|
142
|
+
textMode?: BlogTextMode;
|
|
143
|
+
select?: TSelect;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Parameters for searching published posts.
|
|
147
|
+
*/
|
|
148
|
+
interface SearchPostsParams<TSelect extends readonly BlogPostSummaryField[] | undefined = undefined> extends GetPostsParams<TSelect> {
|
|
149
|
+
query: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Options for creating an explicit WordPress client.
|
|
153
|
+
*/
|
|
154
|
+
interface WpClientOptions {
|
|
155
|
+
wpUrl?: string;
|
|
156
|
+
endpoint?: string;
|
|
157
|
+
perPage?: number;
|
|
158
|
+
auth?: WpAuthConfig;
|
|
159
|
+
rewriteLinks?: LinkRewriteRule[];
|
|
160
|
+
classNameMap?: ClassNameMap;
|
|
161
|
+
fetchImpl?: typeof fetch;
|
|
162
|
+
requestInit?: RequestInit;
|
|
163
|
+
}
|
|
164
|
+
type WpAuthType = "none" | "basic" | "bearer" | "headers";
|
|
165
|
+
interface WpAuthConfig {
|
|
166
|
+
type?: WpAuthType;
|
|
167
|
+
user?: string;
|
|
168
|
+
appPassword?: string;
|
|
169
|
+
token?: string;
|
|
170
|
+
headers?: Record<string, string>;
|
|
171
|
+
}
|
|
172
|
+
interface WpAuthResolvedConfig {
|
|
173
|
+
type: WpAuthType;
|
|
174
|
+
user?: string;
|
|
175
|
+
appPassword?: string;
|
|
176
|
+
token?: string;
|
|
177
|
+
headers?: Record<string, string>;
|
|
178
|
+
}
|
|
179
|
+
interface GetPostParams<TSelect extends readonly BlogPostField[] | undefined = undefined> {
|
|
180
|
+
status?: "draft" | "private" | "publish" | "any";
|
|
181
|
+
textMode?: BlogTextMode;
|
|
182
|
+
select?: TSelect;
|
|
183
|
+
}
|
|
184
|
+
interface QueryRawRestInput {
|
|
185
|
+
path: string;
|
|
186
|
+
params?: Record<string, string | number | boolean | null | undefined>;
|
|
187
|
+
method?: string;
|
|
188
|
+
body?: unknown;
|
|
189
|
+
headers?: Record<string, string>;
|
|
190
|
+
}
|
|
191
|
+
interface QueryRawParams {
|
|
192
|
+
rest?: QueryRawRestInput;
|
|
193
|
+
authRequired?: boolean;
|
|
194
|
+
}
|
|
195
|
+
interface QueryGraphqlParams {
|
|
196
|
+
query: string;
|
|
197
|
+
variables?: Record<string, unknown>;
|
|
198
|
+
}
|
|
199
|
+
interface QueryGraphqlResult<TData = unknown> {
|
|
200
|
+
data?: TData;
|
|
201
|
+
errors?: Array<Record<string, unknown>>;
|
|
202
|
+
}
|
|
203
|
+
interface WpBlogClient {
|
|
204
|
+
/**
|
|
205
|
+
* Fetches a page of published WordPress posts.
|
|
206
|
+
*/
|
|
207
|
+
getPosts<TSelect extends readonly BlogPostSummaryField[] | undefined = undefined>(params?: GetPostsParams<TSelect>): Promise<PostListResult<SelectFields<BlogPostSummary, TSelect>>>;
|
|
208
|
+
/**
|
|
209
|
+
* Searches posts using the WordPress REST search parameter.
|
|
210
|
+
*/
|
|
211
|
+
searchPosts<TSelect extends readonly BlogPostSummaryField[] | undefined = undefined>(params: SearchPostsParams<TSelect>): Promise<PostListResult<SelectFields<BlogPostSummary, TSelect>>>;
|
|
212
|
+
/**
|
|
213
|
+
* Fetches a single post by slug, or null when not found.
|
|
214
|
+
*/
|
|
215
|
+
getPostBySlug<TSelect extends readonly BlogPostField[] | undefined = undefined>(slug: string, params?: GetPostParams<TSelect>): Promise<SelectFields<BlogPost, TSelect> | null>;
|
|
216
|
+
/**
|
|
217
|
+
* Fetches a single published post by WordPress post ID, or null when not found.
|
|
218
|
+
*/
|
|
219
|
+
getPostById<TSelect extends readonly BlogPostField[] | undefined = undefined>(id: number, params?: GetPostParams<TSelect>): Promise<SelectFields<BlogPost, TSelect> | null>;
|
|
220
|
+
/**
|
|
221
|
+
* Executes a raw request against REST for custom fields/shapes.
|
|
222
|
+
* Use this as an escape hatch for custom fields/shapes.
|
|
223
|
+
*/
|
|
224
|
+
queryRaw<TData = unknown>(params: QueryRawParams): Promise<TData>;
|
|
225
|
+
/**
|
|
226
|
+
* Executes a raw GraphQL request.
|
|
227
|
+
* Uses WP_URL + WP_ENDPOINT and existing WP_AUTH_* auth config.
|
|
228
|
+
*/
|
|
229
|
+
queryGraphql<TData = unknown>(params: QueryGraphqlParams): Promise<QueryGraphqlResult<TData>>;
|
|
230
|
+
/**
|
|
231
|
+
* Fetches blog categories for archive navigation/sidebars.
|
|
232
|
+
*/
|
|
233
|
+
getCategories(params?: GetTermsParams): Promise<BlogTerm[]>;
|
|
234
|
+
/**
|
|
235
|
+
* Fetches blog tags for archive navigation/sidebars.
|
|
236
|
+
*/
|
|
237
|
+
getTags(params?: GetTermsParams): Promise<BlogTerm[]>;
|
|
238
|
+
/**
|
|
239
|
+
* Fetches a page of WordPress authors.
|
|
240
|
+
*/
|
|
241
|
+
getAuthors(params?: GetAuthorsParams): Promise<BlogAuthor[]>;
|
|
242
|
+
/**
|
|
243
|
+
* Fetches a single WordPress author by ID.
|
|
244
|
+
*/
|
|
245
|
+
getAuthorById(id: number): Promise<BlogAuthor | null>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export type { WpAuthResolvedConfig as A, BlogTerm as B, ClassNameMap as C, WpAuthType as D, WpEmbedded as E, WpFeaturedMedia as F, GetAuthorsParams as G, HtmlContentPart as H, WpPost as I, WpRenderedField as J, WpTerm as K, LinkRewriteContext as L, PlaceholderParseOptions as P, QueryGraphqlParams as Q, SelectFields as S, WpContentPart as W, WpClientOptions as a, WpBlogClient as b, WpAuthor as c, GetTermsParams as d, BlogPostField as e, GetPostParams as f, BlogPost as g, BlogPostSummaryField as h, GetPostsParams as i, PostListResult as j, BlogPostSummary as k, QueryGraphqlResult as l, QueryRawParams as m, SearchPostsParams as n, BlogAuthor as o, BlogTermOrder as p, BlogTextMode as q, ClassNameMapMode as r, ClassNameMapRule as s, ClassNameMapValue as t, LinkRewriteRule as u, PaginationMeta as v, PlaceholderContentPart as w, PlaceholderProps as x, QueryRawRestInput as y, WpAuthConfig as z };
|