cmx-sdk 0.1.8 → 0.1.9
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/index.d.ts +55 -0
- package/dist/index.js +29 -0
- package/package.json +3 -1
- package/src/index.ts +100 -0
package/dist/index.d.ts
CHANGED
|
@@ -82,3 +82,58 @@ export declare function getDataEntries(typeSlug: string, options?: {
|
|
|
82
82
|
* データエントリ詳細を取得
|
|
83
83
|
*/
|
|
84
84
|
export declare function getDataEntry(typeSlug: string, id: string): Promise<unknown>;
|
|
85
|
+
export interface PreviewPost {
|
|
86
|
+
id: string;
|
|
87
|
+
slug: string;
|
|
88
|
+
title: string;
|
|
89
|
+
description: string | null;
|
|
90
|
+
mdx: string;
|
|
91
|
+
status: string;
|
|
92
|
+
environment: string;
|
|
93
|
+
}
|
|
94
|
+
export interface PreviewCollection {
|
|
95
|
+
id: string;
|
|
96
|
+
slug: string;
|
|
97
|
+
name: string;
|
|
98
|
+
type: string;
|
|
99
|
+
}
|
|
100
|
+
export interface References {
|
|
101
|
+
posts: Record<string, PostReference>;
|
|
102
|
+
assets: Record<string, AssetReference>;
|
|
103
|
+
}
|
|
104
|
+
export interface PreviewResponse {
|
|
105
|
+
post: PreviewPost;
|
|
106
|
+
collection: PreviewCollection | null;
|
|
107
|
+
references: References;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* プレビュートークンで記事を取得
|
|
111
|
+
*/
|
|
112
|
+
export declare function getPreviewByToken(token: string): Promise<PreviewResponse>;
|
|
113
|
+
export interface SubmissionResponse {
|
|
114
|
+
success: true;
|
|
115
|
+
id: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* フォームデータを送信
|
|
119
|
+
*/
|
|
120
|
+
export declare function submitFormData(typeSlug: string, data: Record<string, unknown>, options?: {
|
|
121
|
+
honeypot?: string;
|
|
122
|
+
}): Promise<SubmissionResponse>;
|
|
123
|
+
export interface DataListResponse {
|
|
124
|
+
type: string;
|
|
125
|
+
items: unknown[];
|
|
126
|
+
count: number;
|
|
127
|
+
}
|
|
128
|
+
export interface DataEntryItem {
|
|
129
|
+
id: string;
|
|
130
|
+
[key: string]: unknown;
|
|
131
|
+
_meta: {
|
|
132
|
+
sortOrder: number;
|
|
133
|
+
createdAt: string;
|
|
134
|
+
updatedAt: string;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export { Callout, Embed, Button, BlogCard, Image, mdxComponents } from "@cmx/mdx";
|
|
138
|
+
export { CACHE_TAGS } from "@cmx/api-client/core";
|
|
139
|
+
export { sdkFetchWithTags } from "@cmx/api-client/core";
|
package/dist/index.js
CHANGED
|
@@ -47,3 +47,32 @@ export async function getDataEntry(typeSlug, id) {
|
|
|
47
47
|
const response = await client.request("GET", `/data/${typeSlug}/${id}`);
|
|
48
48
|
return response;
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* プレビュートークンで記事を取得
|
|
52
|
+
*/
|
|
53
|
+
export async function getPreviewByToken(token) {
|
|
54
|
+
const client = createApiClient();
|
|
55
|
+
const response = await client.request("GET", `/preview/${token}`);
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* フォームデータを送信
|
|
60
|
+
*/
|
|
61
|
+
export async function submitFormData(typeSlug, data, options) {
|
|
62
|
+
const client = createApiClient();
|
|
63
|
+
const body = {
|
|
64
|
+
data,
|
|
65
|
+
_hp: options?.honeypot || "",
|
|
66
|
+
};
|
|
67
|
+
const response = await client.request("POST", `/submissions/${typeSlug}`, body);
|
|
68
|
+
return response;
|
|
69
|
+
}
|
|
70
|
+
// ============================================
|
|
71
|
+
// Re-exports from other packages
|
|
72
|
+
// ============================================
|
|
73
|
+
// MDX Components (from @cmx/mdx)
|
|
74
|
+
export { Callout, Embed, Button, BlogCard, Image, mdxComponents } from "@cmx/mdx";
|
|
75
|
+
// Cache Tags (from @cmx/api-client/core)
|
|
76
|
+
export { CACHE_TAGS } from "@cmx/api-client/core";
|
|
77
|
+
// SDK Fetch with Tags
|
|
78
|
+
export { sdkFetchWithTags } from "@cmx/api-client/core";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cmx-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "CMX SDK - CLI tool for managing CMX schemas and content",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
"clean": "rm -rf dist"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@cmx/api-client": "workspace:*",
|
|
24
|
+
"@cmx/mdx": "workspace:*",
|
|
23
25
|
"commander": "^12.1.0",
|
|
24
26
|
"dotenv": "^16.4.7"
|
|
25
27
|
},
|
package/src/index.ts
CHANGED
|
@@ -127,3 +127,103 @@ export async function getDataEntry(
|
|
|
127
127
|
const response = await client.request("GET", `/data/${typeSlug}/${id}`)
|
|
128
128
|
return response
|
|
129
129
|
}
|
|
130
|
+
|
|
131
|
+
// ============================================
|
|
132
|
+
// Preview API
|
|
133
|
+
// ============================================
|
|
134
|
+
|
|
135
|
+
export interface PreviewPost {
|
|
136
|
+
id: string
|
|
137
|
+
slug: string
|
|
138
|
+
title: string
|
|
139
|
+
description: string | null
|
|
140
|
+
mdx: string
|
|
141
|
+
status: string
|
|
142
|
+
environment: string
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface PreviewCollection {
|
|
146
|
+
id: string
|
|
147
|
+
slug: string
|
|
148
|
+
name: string
|
|
149
|
+
type: string
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface References {
|
|
153
|
+
posts: Record<string, PostReference>
|
|
154
|
+
assets: Record<string, AssetReference>
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface PreviewResponse {
|
|
158
|
+
post: PreviewPost
|
|
159
|
+
collection: PreviewCollection | null
|
|
160
|
+
references: References
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* プレビュートークンで記事を取得
|
|
165
|
+
*/
|
|
166
|
+
export async function getPreviewByToken(token: string): Promise<PreviewResponse> {
|
|
167
|
+
const client = createApiClient()
|
|
168
|
+
const response = await client.request("GET", `/preview/${token}`)
|
|
169
|
+
return response as PreviewResponse
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// ============================================
|
|
173
|
+
// Form Submissions API
|
|
174
|
+
// ============================================
|
|
175
|
+
|
|
176
|
+
export interface SubmissionResponse {
|
|
177
|
+
success: true
|
|
178
|
+
id: string
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* フォームデータを送信
|
|
183
|
+
*/
|
|
184
|
+
export async function submitFormData(
|
|
185
|
+
typeSlug: string,
|
|
186
|
+
data: Record<string, unknown>,
|
|
187
|
+
options?: { honeypot?: string }
|
|
188
|
+
): Promise<SubmissionResponse> {
|
|
189
|
+
const client = createApiClient()
|
|
190
|
+
const body = {
|
|
191
|
+
data,
|
|
192
|
+
_hp: options?.honeypot || "",
|
|
193
|
+
}
|
|
194
|
+
const response = await client.request("POST", `/submissions/${typeSlug}`, body)
|
|
195
|
+
return response as SubmissionResponse
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// ============================================
|
|
199
|
+
// Type Aliases
|
|
200
|
+
// ============================================
|
|
201
|
+
|
|
202
|
+
export interface DataListResponse {
|
|
203
|
+
type: string
|
|
204
|
+
items: unknown[]
|
|
205
|
+
count: number
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface DataEntryItem {
|
|
209
|
+
id: string
|
|
210
|
+
[key: string]: unknown
|
|
211
|
+
_meta: {
|
|
212
|
+
sortOrder: number
|
|
213
|
+
createdAt: string
|
|
214
|
+
updatedAt: string
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ============================================
|
|
219
|
+
// Re-exports from other packages
|
|
220
|
+
// ============================================
|
|
221
|
+
|
|
222
|
+
// MDX Components (from @cmx/mdx)
|
|
223
|
+
export { Callout, Embed, Button, BlogCard, Image, mdxComponents } from "@cmx/mdx"
|
|
224
|
+
|
|
225
|
+
// Cache Tags (from @cmx/api-client/core)
|
|
226
|
+
export { CACHE_TAGS } from "@cmx/api-client/core"
|
|
227
|
+
|
|
228
|
+
// SDK Fetch with Tags
|
|
229
|
+
export { sdkFetchWithTags } from "@cmx/api-client/core"
|