@ryusenkei/maezae 0.1.0 → 0.3.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/README.md +14 -0
- package/dist/analytics.d.ts +1 -0
- package/dist/analytics.js +33 -0
- package/dist/body.d.ts +1 -24
- package/dist/body.js +40 -238
- package/dist/declared-9_jI3JXH.js +336 -0
- package/dist/delivery.d.ts +1 -211
- package/dist/integrations.d.ts +1 -0
- package/dist/integrations.js +16 -0
- package/dist/model.d.ts +1 -2
- package/dist/model.js +676 -1
- package/dist/preview.d.ts +1 -44
- package/dist/preview.js +1 -103
- package/dist/src-Baj-EC2G.js +205 -0
- package/dist/src-BrLwIWaT.js +7 -0
- package/dist/trace.d.ts +1 -0
- package/dist/trace.js +1 -0
- package/dist/types/access/src/index.d.ts +5 -0
- package/dist/types/access/src/jwt.d.ts +42 -0
- package/dist/types/access/src/oidc.d.ts +47 -0
- package/dist/types/access/src/signed.d.ts +47 -0
- package/dist/types/access/src/span.d.ts +23 -0
- package/dist/types/access/src/traceparent.d.ts +21 -0
- package/dist/types/analytics/src/day.d.ts +2 -0
- package/dist/types/analytics/src/index.d.ts +4 -0
- package/dist/types/analytics/src/record.d.ts +22 -0
- package/dist/types/analytics/src/schedule.d.ts +2 -0
- package/dist/types/analytics/src/source.d.ts +33 -0
- package/dist/types/analytics/src/store.d.ts +24 -0
- package/dist/types/body/src/components.d.ts +25 -0
- package/dist/types/body/src/declared.d.ts +34 -0
- package/dist/types/body/src/derive.d.ts +13 -0
- package/dist/types/body/src/description.d.ts +8 -0
- package/dist/types/body/src/href.d.ts +4 -0
- package/dist/types/body/src/index.d.ts +11 -0
- package/dist/types/body/src/library.d.ts +94 -0
- package/dist/types/body/src/markdown.d.ts +14 -0
- package/dist/types/body/src/normalize.d.ts +7 -0
- package/dist/types/body/src/profile.d.ts +48 -0
- package/dist/types/body/src/schema.d.ts +6 -0
- package/dist/types/body/src/standard.d.ts +20 -0
- package/dist/types/body/src/types.d.ts +91 -0
- package/dist/types/cms-contract/src/apiKeys.d.ts +13 -0
- package/dist/types/cms-contract/src/assets.d.ts +10 -0
- package/dist/types/cms-contract/src/builtins.d.ts +17 -0
- package/dist/types/cms-contract/src/embeds.d.ts +56 -0
- package/dist/types/cms-contract/src/errorLabels.d.ts +22 -0
- package/dist/types/cms-contract/src/errors.d.ts +97 -0
- package/dist/types/cms-contract/src/extensions.d.ts +75 -0
- package/dist/types/cms-contract/src/fieldRules.d.ts +37 -0
- package/dist/types/cms-contract/src/functions.d.ts +71 -0
- package/dist/types/cms-contract/src/index.d.ts +19 -0
- package/dist/types/cms-contract/src/labels.d.ts +6 -0
- package/dist/types/cms-contract/src/modules.d.ts +144 -0
- package/dist/types/cms-contract/src/paths.d.ts +6 -0
- package/dist/types/cms-contract/src/pending.d.ts +4 -0
- package/dist/types/cms-contract/src/permissions.d.ts +69 -0
- package/dist/types/cms-contract/src/roles.d.ts +35 -0
- package/dist/types/cms-contract/src/settings.d.ts +19 -0
- package/dist/types/cms-contract/src/transfer.d.ts +48 -0
- package/dist/types/cms-contract/src/views.d.ts +21 -0
- package/dist/types/cms-contract/src/webhooks.d.ts +45 -0
- package/dist/types/delivery-client/src/client.d.ts +62 -0
- package/dist/types/delivery-client/src/index.d.ts +5 -0
- package/dist/types/delivery-client/src/media.d.ts +12 -0
- package/dist/types/delivery-client/src/query.d.ts +68 -0
- package/dist/types/delivery-client/src/schema.d.ts +19 -0
- package/dist/types/delivery-client/src/values.d.ts +63 -0
- package/dist/types/model/src/asset.d.ts +89 -0
- package/dist/types/model/src/capabilities.d.ts +20 -0
- package/dist/types/model/src/changes.d.ts +23 -0
- package/dist/types/model/src/check.d.ts +10 -0
- package/dist/types/model/src/image.d.ts +38 -0
- package/dist/types/model/src/index.d.ts +14 -0
- package/dist/types/model/src/input.d.ts +26 -0
- package/dist/types/model/src/media.d.ts +5 -0
- package/dist/types/model/src/model.d.ts +190 -0
- package/dist/types/model/src/page.d.ts +47 -0
- package/dist/types/model/src/rules.d.ts +15 -0
- package/dist/types/model/src/schema.d.ts +3 -0
- package/dist/types/model/src/screens.d.ts +72 -0
- package/dist/types/model/src/time.d.ts +25 -0
- package/dist/types/model/src/values.d.ts +24 -0
- package/dist/types/sdk/src/analytics.d.ts +2 -0
- package/dist/types/sdk/src/body.d.ts +2 -0
- package/dist/types/sdk/src/defaults.d.ts +5 -0
- package/dist/types/sdk/src/delivery.d.ts +2 -0
- package/dist/types/sdk/src/integrations.d.ts +4 -0
- package/dist/types/sdk/src/model.d.ts +5 -0
- package/dist/types/sdk/src/preview.d.ts +2 -0
- package/dist/types/sdk/src/trace.d.ts +2 -0
- package/package.json +14 -2
- package/dist/index-57nirXxn.d.ts +0 -335
- package/dist/index-D11fUsoi.d.ts +0 -131
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ../body/src/components.ts
|
|
3
|
+
/** 予約の名前(ブロック) */
|
|
4
|
+
const RESERVED_BLOCK_NAMES = /* @__PURE__ */ new Set(["block"]);
|
|
5
|
+
/** 予約の名前(インライン) */
|
|
6
|
+
const RESERVED_INLINE_NAMES = /* @__PURE__ */ new Set([
|
|
7
|
+
"mark",
|
|
8
|
+
"sup",
|
|
9
|
+
"sub",
|
|
10
|
+
"link"
|
|
11
|
+
]);
|
|
12
|
+
// ../body/src/library.ts
|
|
13
|
+
/** 注のコンポーネントの名前(本文からの算出 citesOf が参照) */
|
|
14
|
+
const CITE = "cite";
|
|
15
|
+
const https = z.string().regex(/^https:\/\//, "URL は https://");
|
|
16
|
+
const caption = z.string().min(1, "注記が未入力");
|
|
17
|
+
const datum = z.object({
|
|
18
|
+
label: z.string(),
|
|
19
|
+
value: z.number()
|
|
20
|
+
});
|
|
21
|
+
const color = z.union([
|
|
22
|
+
z.literal(1),
|
|
23
|
+
z.literal(2),
|
|
24
|
+
z.literal(3),
|
|
25
|
+
z.literal(4),
|
|
26
|
+
z.literal(5),
|
|
27
|
+
z.literal(6),
|
|
28
|
+
z.literal(7),
|
|
29
|
+
z.literal(8)
|
|
30
|
+
]);
|
|
31
|
+
const chart = z.union([
|
|
32
|
+
z.object({
|
|
33
|
+
chart: z.literal("bar"),
|
|
34
|
+
data: z.array(datum),
|
|
35
|
+
unit: z.string(),
|
|
36
|
+
color: color.optional(),
|
|
37
|
+
caption
|
|
38
|
+
}),
|
|
39
|
+
z.object({
|
|
40
|
+
chart: z.literal("line"),
|
|
41
|
+
labels: z.array(z.string()),
|
|
42
|
+
series: z.array(z.object({
|
|
43
|
+
name: z.string(),
|
|
44
|
+
values: z.array(z.number())
|
|
45
|
+
})),
|
|
46
|
+
unit: z.string(),
|
|
47
|
+
caption
|
|
48
|
+
}),
|
|
49
|
+
z.object({
|
|
50
|
+
chart: z.literal("pie"),
|
|
51
|
+
data: z.array(datum),
|
|
52
|
+
unit: z.string(),
|
|
53
|
+
caption
|
|
54
|
+
}),
|
|
55
|
+
z.object({
|
|
56
|
+
chart: z.literal("heat"),
|
|
57
|
+
cols: z.array(z.string()),
|
|
58
|
+
rows: z.array(z.object({
|
|
59
|
+
label: z.string(),
|
|
60
|
+
values: z.array(z.number())
|
|
61
|
+
})),
|
|
62
|
+
unit: z.string(),
|
|
63
|
+
color: color.optional(),
|
|
64
|
+
caption
|
|
65
|
+
})
|
|
66
|
+
]);
|
|
67
|
+
const optional = (attrs, keys) => Object.fromEntries(keys.filter((k) => attrs[k] !== void 0).map((k) => [k, attrs[k]]));
|
|
68
|
+
const plain = (rich) => rich.map((i) => typeof i === "string" ? i : "text" in i ? i.text ?? "" : "").join("");
|
|
69
|
+
/** 核のコンポーネント(chart の Markdown は既定の JSON) */
|
|
70
|
+
const CORE_COMPONENTS = [
|
|
71
|
+
{
|
|
72
|
+
name: CITE,
|
|
73
|
+
inline: true,
|
|
74
|
+
description: "注(出典の ID を参照、出典は記事に結び付けが必要)",
|
|
75
|
+
example: ":cite{#出典の ID}",
|
|
76
|
+
props: () => z.object({ id: z.string().min(1, "注の出典が未入力") })
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "pending",
|
|
80
|
+
inline: true,
|
|
81
|
+
description: "未定の値(方針のページで値が決まっていない箇所)",
|
|
82
|
+
example: ":pending[未定]",
|
|
83
|
+
props: () => z.object({})
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "speech",
|
|
87
|
+
description: "発言(会話の一言を大きく引く、1段落)",
|
|
88
|
+
example: ":::speech\n大きく引く一言\n:::",
|
|
89
|
+
markdown: {
|
|
90
|
+
to: (p) => ({ content: [{
|
|
91
|
+
type: "paragraph",
|
|
92
|
+
content: [p.text]
|
|
93
|
+
}] }),
|
|
94
|
+
from: (_, content) => ({ text: content[0]?.type === "paragraph" ? plain(content[0].content) : "" })
|
|
95
|
+
},
|
|
96
|
+
props: () => z.object({ text: z.string().min(1, "発言が未入力") })
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "chart",
|
|
100
|
+
description: "グラフ(中は JSON、chart は bar・line・pie・heat、caption は必須)",
|
|
101
|
+
example: ":::chart\n```json\n{\"chart\": \"bar\", \"unit\": \"%\", \"data\": [{\"label\": \"A\", \"value\": 40}], \"caption\": \"説明\"}\n```\n:::",
|
|
102
|
+
props: () => chart
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "diagram",
|
|
106
|
+
description: "図(中は Mermaid、alt は図の内容の説明、caption は必須)",
|
|
107
|
+
example: ":::diagram{alt=\"内容の説明\" caption=\"説明\"}\n```mermaid\nflowchart LR\n A --> B\n```\n:::",
|
|
108
|
+
markdown: {
|
|
109
|
+
to: (p) => ({
|
|
110
|
+
attributes: {
|
|
111
|
+
alt: p.alt,
|
|
112
|
+
caption: p.caption
|
|
113
|
+
},
|
|
114
|
+
content: [{
|
|
115
|
+
type: "code",
|
|
116
|
+
lang: "mermaid",
|
|
117
|
+
code: p.source
|
|
118
|
+
}]
|
|
119
|
+
}),
|
|
120
|
+
from: (attrs, content) => ({
|
|
121
|
+
source: content[0]?.type === "code" ? content[0].code : "",
|
|
122
|
+
alt: attrs.alt ?? "",
|
|
123
|
+
caption: attrs.caption ?? ""
|
|
124
|
+
})
|
|
125
|
+
},
|
|
126
|
+
props: () => z.object({
|
|
127
|
+
source: z.string().min(1, "図の記法が未入力"),
|
|
128
|
+
alt: z.string().min(1, "図の代替テキストが未入力"),
|
|
129
|
+
caption
|
|
130
|
+
})
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "gallery",
|
|
134
|
+
description: "複数の画像を2列で配置(画像は2枚以上)",
|
|
135
|
+
example: ":::gallery\n\n\n\n:::",
|
|
136
|
+
markdown: {
|
|
137
|
+
to: (p) => ({ content: p.items.map((i) => ({
|
|
138
|
+
type: "image",
|
|
139
|
+
media: i.media,
|
|
140
|
+
...i.caption ? { caption: i.caption } : {}
|
|
141
|
+
})) }),
|
|
142
|
+
from: (_, content) => ({ items: content.flatMap((b) => b.type === "image" ? [{
|
|
143
|
+
media: b.media,
|
|
144
|
+
...b.caption ? { caption: b.caption } : {}
|
|
145
|
+
}] : []) })
|
|
146
|
+
},
|
|
147
|
+
props: (media) => z.object({ items: z.array(z.object({
|
|
148
|
+
media,
|
|
149
|
+
caption: z.string().optional()
|
|
150
|
+
})).min(2, "ギャラリーの画像は2枚以上") })
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: "link-card",
|
|
154
|
+
description: "外部リンクのカード(https のみ、site・desc・画像は任意)",
|
|
155
|
+
example: ":::link-card{href=\"https://…\" title=\"ページの題\" site=\"サイト名\" desc=\"説明\"}\n:::",
|
|
156
|
+
markdown: {
|
|
157
|
+
to: (p) => {
|
|
158
|
+
const { href, title, site, desc, image } = p;
|
|
159
|
+
return {
|
|
160
|
+
attributes: {
|
|
161
|
+
href,
|
|
162
|
+
title,
|
|
163
|
+
...site ? { site } : {},
|
|
164
|
+
...desc ? { desc } : {}
|
|
165
|
+
},
|
|
166
|
+
content: image ? [{
|
|
167
|
+
type: "image",
|
|
168
|
+
media: image
|
|
169
|
+
}] : []
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
from: (attrs, content) => ({
|
|
173
|
+
href: attrs.href,
|
|
174
|
+
title: attrs.title,
|
|
175
|
+
...optional(attrs, ["site", "desc"]),
|
|
176
|
+
...content[0]?.type === "image" ? { image: content[0].media } : {}
|
|
177
|
+
})
|
|
178
|
+
},
|
|
179
|
+
props: (media) => z.object({
|
|
180
|
+
href: https,
|
|
181
|
+
title: z.string().min(1, "リンクのタイトルが未入力"),
|
|
182
|
+
site: z.string().optional(),
|
|
183
|
+
desc: z.string().optional(),
|
|
184
|
+
image: media.optional()
|
|
185
|
+
})
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: "links",
|
|
189
|
+
description: "外部リンクの一覧(1件1行、リンクの title はサイト名、label は小見出しで既定は「参考」)",
|
|
190
|
+
example: ":::links{label=\"参考\"}\n- [ページの題](https://… \"サイト名\")\n:::",
|
|
191
|
+
markdown: {
|
|
192
|
+
to: (p) => {
|
|
193
|
+
const { label, items } = p;
|
|
194
|
+
const content = [{
|
|
195
|
+
type: "list",
|
|
196
|
+
items: items.map((i) => ({ content: [{
|
|
197
|
+
text: i.title,
|
|
198
|
+
link: {
|
|
199
|
+
href: i.href,
|
|
200
|
+
...i.site ? { title: i.site } : {}
|
|
201
|
+
}
|
|
202
|
+
}] }))
|
|
203
|
+
}];
|
|
204
|
+
return {
|
|
205
|
+
attributes: label ? { label } : void 0,
|
|
206
|
+
content
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
from: (attrs, content) => ({
|
|
210
|
+
...optional(attrs, ["label"]),
|
|
211
|
+
items: content[0]?.type === "list" ? content[0].items.flatMap((i) => i.content.flatMap((x) => typeof x !== "string" && "link" in x && x.link ? [{
|
|
212
|
+
href: x.link.href,
|
|
213
|
+
title: x.text,
|
|
214
|
+
...x.link.title ? { site: x.link.title } : {}
|
|
215
|
+
}] : [])) : []
|
|
216
|
+
})
|
|
217
|
+
},
|
|
218
|
+
props: () => z.object({
|
|
219
|
+
label: z.string().optional(),
|
|
220
|
+
items: z.array(z.object({
|
|
221
|
+
href: https,
|
|
222
|
+
title: z.string().min(1, "リンクのタイトルが未入力"),
|
|
223
|
+
site: z.string().optional()
|
|
224
|
+
}))
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
];
|
|
228
|
+
/** 名前から核のコンポーネント(なければ undefined) */
|
|
229
|
+
const coreComponentOf = (name) => CORE_COMPONENTS.find((c) => c.name === name);
|
|
230
|
+
// ../body/src/declared.ts
|
|
231
|
+
const NAME = /^[A-Za-z][A-Za-z0-9-]*$/;
|
|
232
|
+
const KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
233
|
+
const propSchema = z.lazy(() => z.object({
|
|
234
|
+
type: z.enum([
|
|
235
|
+
"string",
|
|
236
|
+
"number",
|
|
237
|
+
"integer",
|
|
238
|
+
"boolean",
|
|
239
|
+
"array",
|
|
240
|
+
"object"
|
|
241
|
+
]),
|
|
242
|
+
title: z.string().min(1).optional(),
|
|
243
|
+
description: z.string().optional(),
|
|
244
|
+
enum: z.array(z.string().min(1)).min(1).optional(),
|
|
245
|
+
items: propSchema.optional(),
|
|
246
|
+
properties: z.record(z.string().regex(KEY, "引数の名前は英字で始まる英数字"), propSchema).optional(),
|
|
247
|
+
required: z.array(z.string()).optional()
|
|
248
|
+
}).strict().superRefine((p, ctx) => {
|
|
249
|
+
if (p.enum && p.type !== "string") ctx.addIssue({
|
|
250
|
+
code: "custom",
|
|
251
|
+
message: "選択肢 enum は文字列の引数だけ",
|
|
252
|
+
path: ["enum"]
|
|
253
|
+
});
|
|
254
|
+
if (p.type === "array" !== (p.items !== void 0)) ctx.addIssue({
|
|
255
|
+
code: "custom",
|
|
256
|
+
message: "配列の引数は items が必要(ほかの型は不可)",
|
|
257
|
+
path: ["items"]
|
|
258
|
+
});
|
|
259
|
+
if ((p.properties || p.required) && p.type !== "object") ctx.addIssue({
|
|
260
|
+
code: "custom",
|
|
261
|
+
message: "properties・required はオブジェクトの引数だけ",
|
|
262
|
+
path: ["properties"]
|
|
263
|
+
});
|
|
264
|
+
for (const key of p.required ?? []) if (!p.properties?.[key]) ctx.addIssue({
|
|
265
|
+
code: "custom",
|
|
266
|
+
message: `必須の引数 ${key} が properties にない`,
|
|
267
|
+
path: ["required"]
|
|
268
|
+
});
|
|
269
|
+
}));
|
|
270
|
+
const declaredComponent = z.object({
|
|
271
|
+
name: z.string().regex(NAME, "部品の名前は英字で始まる英数字とハイフン"),
|
|
272
|
+
label: z.string().min(1, "部品の表示名が未入力"),
|
|
273
|
+
description: z.string().optional(),
|
|
274
|
+
inline: z.boolean().optional(),
|
|
275
|
+
props: z.object({
|
|
276
|
+
type: z.literal("object"),
|
|
277
|
+
properties: z.record(z.string().regex(KEY, "引数の名前は英字で始まる英数字"), propSchema),
|
|
278
|
+
required: z.array(z.string()).optional()
|
|
279
|
+
}).strict()
|
|
280
|
+
}).strict().superRefine((d, ctx) => {
|
|
281
|
+
if (coreComponentOf(d.name) || RESERVED_BLOCK_NAMES.has(d.name) || RESERVED_INLINE_NAMES.has(d.name)) ctx.addIssue({
|
|
282
|
+
code: "custom",
|
|
283
|
+
message: `部品の名前 ${d.name} はコアの部品・予約の名前と重複`,
|
|
284
|
+
path: ["name"]
|
|
285
|
+
});
|
|
286
|
+
for (const key of d.props.required ?? []) if (!d.props.properties[key]) ctx.addIssue({
|
|
287
|
+
code: "custom",
|
|
288
|
+
message: `必須の引数 ${key} が properties にない`,
|
|
289
|
+
path: ["props", "required"]
|
|
290
|
+
});
|
|
291
|
+
if (d.inline) {
|
|
292
|
+
for (const [key, p] of Object.entries(d.props.properties)) if (p.type !== "string") ctx.addIssue({
|
|
293
|
+
code: "custom",
|
|
294
|
+
message: `インラインの部品の引数は文字列だけ: ${key}`,
|
|
295
|
+
path: [
|
|
296
|
+
"props",
|
|
297
|
+
"properties",
|
|
298
|
+
key
|
|
299
|
+
]
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
/** 宣言の一覧の検査(名前の重複も拒否) */
|
|
304
|
+
const declaredComponentsSchema = z.array(declaredComponent).superRefine((list, ctx) => {
|
|
305
|
+
const seen = /* @__PURE__ */ new Set();
|
|
306
|
+
list.forEach((d, i) => {
|
|
307
|
+
if (seen.has(d.name)) ctx.addIssue({
|
|
308
|
+
code: "custom",
|
|
309
|
+
message: `部品の名前 ${d.name} が重複`,
|
|
310
|
+
path: [i, "name"]
|
|
311
|
+
});
|
|
312
|
+
seen.add(d.name);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
/** 1つの引数の検査(label はメッセージの項目名) */
|
|
316
|
+
function propZod(p, label) {
|
|
317
|
+
const wrong = { error: (iss) => iss.input === void 0 ? `${label}が未入力` : `${label}の形が不正` };
|
|
318
|
+
switch (p.type) {
|
|
319
|
+
case "string": return p.enum ? z.enum(p.enum, wrong) : z.string(wrong);
|
|
320
|
+
case "number": return z.number(wrong);
|
|
321
|
+
case "integer": return z.number(wrong).int(`${label}は整数`);
|
|
322
|
+
case "boolean": return z.boolean(wrong);
|
|
323
|
+
case "array": return z.array(propZod(p.items, label), wrong);
|
|
324
|
+
case "object": return objectZod(p.properties ?? {}, p.required ?? [], wrong);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/** オブジェクトの引数の検査(必須でない引数は省略可、宣言にない引数は除去) */
|
|
328
|
+
const objectZod = (properties, required, error) => z.object(Object.fromEntries(Object.entries(properties).map(([key, p]) => [key, required.includes(key) ? propZod(p, p.title ?? key) : propZod(p, p.title ?? key).optional()])), error);
|
|
329
|
+
const propsCache = /* @__PURE__ */ new WeakMap();
|
|
330
|
+
/** 宣言した部品の引数の検査(宣言ごとに作成を再利用) */
|
|
331
|
+
function declaredPropsZod(d) {
|
|
332
|
+
let schema = propsCache.get(d);
|
|
333
|
+
if (!schema) propsCache.set(d, schema = objectZod(d.props.properties, d.props.required ?? [], { error: () => `${d.label}の引数の形が不正` }));
|
|
334
|
+
return schema;
|
|
335
|
+
}
|
|
336
|
+
export { coreComponentOf as a, CORE_COMPONENTS as i, declaredPropsZod as n, CITE as r, declaredComponentsSchema as t };
|
package/dist/delivery.d.ts
CHANGED
|
@@ -1,211 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { i as Body } from "./index-D11fUsoi.js";
|
|
3
|
-
/** 配信 API の1件の値(項目の key と id・updated_at) */
|
|
4
|
-
type Item = Readonly<Record<string, unknown>>;
|
|
5
|
-
/** 配信 API が解決した実体(hotspot・crop は元の画像に対する割合) */
|
|
6
|
-
type DeliveredAsset = Readonly<{
|
|
7
|
-
id: string;
|
|
8
|
-
kind: 'image' | 'video';
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
alt: string;
|
|
12
|
-
hotspot?: Hotspot;
|
|
13
|
-
crop?: Crop;
|
|
14
|
-
poster?: DeliveredAsset | null;
|
|
15
|
-
}>;
|
|
16
|
-
/** 項目の1つ分の値(複数の値を持つ項目は FieldValue が配列に、query.ts の絞り込みの値と共通) */
|
|
17
|
-
type SingleValue<F extends FieldDef> = F extends {
|
|
18
|
-
type: 'text' | 'textarea';
|
|
19
|
-
} ? string : F extends {
|
|
20
|
-
type: 'number';
|
|
21
|
-
} ? number : F extends {
|
|
22
|
-
type: 'checkbox';
|
|
23
|
-
} ? boolean : F extends {
|
|
24
|
-
type: 'date';
|
|
25
|
-
} ? DateString : F extends {
|
|
26
|
-
type: 'datetime';
|
|
27
|
-
} ? string : F extends {
|
|
28
|
-
type: 'select';
|
|
29
|
-
options: readonly (infer O extends {
|
|
30
|
-
value: string;
|
|
31
|
-
})[];
|
|
32
|
-
} ? O['value'] : F extends {
|
|
33
|
-
type: 'reference';
|
|
34
|
-
} ? string : F extends {
|
|
35
|
-
type: 'media';
|
|
36
|
-
} ? DeliveredAsset | null : F extends {
|
|
37
|
-
type: 'body';
|
|
38
|
-
} ? Body<DeliveredAsset | null> : F extends {
|
|
39
|
-
type: 'group';
|
|
40
|
-
fields: readonly (infer G extends FieldDef)[];
|
|
41
|
-
} ? GroupValue<G> : unknown;
|
|
42
|
-
/** まとまりの値(中の項目の key ごと) */
|
|
43
|
-
type GroupValue<G extends FieldDef> = { readonly [K in G as K['key']]: FieldValue<K>; };
|
|
44
|
-
/**
|
|
45
|
-
* 項目の値(種類ごと: 文字は string、日付は YYYY-MM-DD、日時は `ISO 8601` の UTC、参照は参照先の id、メディアは実体、本文は標準のブロック)
|
|
46
|
-
* - multiple の項目: 値の配列
|
|
47
|
-
* - 値なし: null
|
|
48
|
-
*/
|
|
49
|
-
type FieldValue<F extends FieldDef> = (F extends {
|
|
50
|
-
multiple: true;
|
|
51
|
-
} ? readonly SingleValue<F>[] : SingleValue<F>) | null;
|
|
52
|
-
/** 型の項目(コアの項目と追加の項目) */
|
|
53
|
-
type FieldsOf<T extends ContentType> = (T['core'] extends readonly (infer C extends FieldDef)[] ? C : never) | T['fields'][number];
|
|
54
|
-
/** 型の宣言から導く1件の値(id・更新日時と、項目の key ごとの値) */
|
|
55
|
-
type ItemOf<T extends ContentType> = Readonly<{
|
|
56
|
-
id: string;
|
|
57
|
-
updated_at: string;
|
|
58
|
-
} & { [F in FieldsOf<T> as F['key']]: FieldValue<F>; }>;
|
|
59
|
-
/** 範囲の指定(両端を含む) */
|
|
60
|
-
type Range<V> = Readonly<{
|
|
61
|
-
gte?: V;
|
|
62
|
-
lte?: V;
|
|
63
|
-
}>;
|
|
64
|
-
type Scalar<F extends FieldDef> = NonNullable<SingleValue<F>>;
|
|
65
|
-
/** 項目の種類ごとの絞り込みの値(選択肢・参照は一致か in、チェックボックスは一致、数値・日付は一致か範囲、日時は範囲) */
|
|
66
|
-
type FilterValue<F extends FieldDef> = F extends {
|
|
67
|
-
private: true;
|
|
68
|
-
} ? never : F extends {
|
|
69
|
-
type: 'select' | 'reference';
|
|
70
|
-
} ? Scalar<F> | Readonly<{
|
|
71
|
-
in: readonly Scalar<F>[];
|
|
72
|
-
}> : F extends {
|
|
73
|
-
type: 'checkbox';
|
|
74
|
-
} ? boolean : F extends {
|
|
75
|
-
type: 'number' | 'date';
|
|
76
|
-
} ? Scalar<F> | Range<Scalar<F>> : F extends {
|
|
77
|
-
type: 'datetime';
|
|
78
|
-
} ? Range<string> : never;
|
|
79
|
-
/** 並べ替えできる項目の key(単数の文字・数値・日付・日時・選択肢・チェックボックス) */
|
|
80
|
-
type SortableKey<T extends ContentType> = FieldsOf<T> extends (infer F) ? (F extends {
|
|
81
|
-
private: true;
|
|
82
|
-
} | {
|
|
83
|
-
multiple: true;
|
|
84
|
-
} ? never : F extends {
|
|
85
|
-
type: 'text' | 'number' | 'date' | 'datetime' | 'select' | 'checkbox';
|
|
86
|
-
key: infer K extends string;
|
|
87
|
-
} ? K : never) : never;
|
|
88
|
-
/** 並べ替えの key(項目・公開日時・更新日時・id) */
|
|
89
|
-
type OrderKey<T extends ContentType> = SortableKey<T> | 'published_at' | 'updated_at' | 'id';
|
|
90
|
-
/** 絞り込みの指定(項目の key ごと、公開日時・更新日時は範囲) */
|
|
91
|
-
type ListFilter<T extends ContentType = ContentType> = Readonly<{ [F in FieldsOf<T> as [FilterValue<F>] extends [never] ? never : F['key']]?: FilterValue<F>; } & {
|
|
92
|
-
published_at?: Range<string>;
|
|
93
|
-
updated_at?: Range<string>;
|
|
94
|
-
}>;
|
|
95
|
-
/**
|
|
96
|
-
* 型の一覧の指定
|
|
97
|
-
* - limit: 1ページの件数(サーバーの上限は100)
|
|
98
|
-
* - cursor: 前のページの next
|
|
99
|
-
* - order: 並べ替えの key の配列(`-` の接頭辞で降順、最後に id を自動で追加)
|
|
100
|
-
* - filter: 項目の key ごとの絞り込み(複数の値の項目は値を含む行)
|
|
101
|
-
*/
|
|
102
|
-
type ListQuery<T extends ContentType = ContentType> = Readonly<{
|
|
103
|
-
limit?: number;
|
|
104
|
-
cursor?: string | null;
|
|
105
|
-
order?: readonly (OrderKey<T> | `-${OrderKey<T>}`)[];
|
|
106
|
-
filter?: ListFilter<T>;
|
|
107
|
-
}>;
|
|
108
|
-
/** ページ送りの応答(next は次のページの cursor、最後のページは null) */
|
|
109
|
-
type Page<I = Item> = Readonly<{
|
|
110
|
-
items: readonly I[];
|
|
111
|
-
next: string | null;
|
|
112
|
-
}>;
|
|
113
|
-
/** どの型の一覧の指定も受け取る形(型の検査は ListQuery の側) */
|
|
114
|
-
type QueryShape = Readonly<{
|
|
115
|
-
limit?: number;
|
|
116
|
-
cursor?: string | null;
|
|
117
|
-
order?: readonly string[];
|
|
118
|
-
filter?: Readonly<Record<string, unknown>>;
|
|
119
|
-
}>;
|
|
120
|
-
/** 一覧の指定をクエリの組に(find・get・subPath の params、一式の path に使用) */
|
|
121
|
-
export declare function listParams(query: QueryShape): Record<string, string>;
|
|
122
|
-
/** 配信 API のパスの前半 */
|
|
123
|
-
export declare const DELIVERY_PATH = "/content/v1";
|
|
124
|
-
/** 配信 API への接続(path は /content/v1 から始まるパスとクエリ) */
|
|
125
|
-
type Delivery = (path: string, init?: RequestInit) => Promise<Response>;
|
|
126
|
-
/** 一式の経路ごとの結果(body は経路の応答の JSON) */
|
|
127
|
-
type BundleResult = Readonly<{
|
|
128
|
-
status: number;
|
|
129
|
-
body: unknown;
|
|
130
|
-
}>;
|
|
131
|
-
/**
|
|
132
|
-
* 一式の取得の結果
|
|
133
|
-
* - notModified: ETag が一致、etag: 応答の ETag、stale: 失敗のため最後に成功した値
|
|
134
|
-
* - partial: 一部の経路が 5xx の一式 x-partial(最後に成功した値や描画の結果として保存しない)
|
|
135
|
-
*/
|
|
136
|
-
type Prefetched = Readonly<{
|
|
137
|
-
notModified: boolean;
|
|
138
|
-
etag: string | null;
|
|
139
|
-
stale: boolean;
|
|
140
|
-
partial: boolean;
|
|
141
|
-
}>;
|
|
142
|
-
/** 配信 API の取得の失敗(call: 失敗した経路、status: 応答のステータス) */
|
|
143
|
-
export declare class DeliveryError extends Error {
|
|
144
|
-
readonly call: string;
|
|
145
|
-
readonly status: number;
|
|
146
|
-
constructor(call: string, status: number, body: string);
|
|
147
|
-
}
|
|
148
|
-
/** 配信 API の中のパスとクエリ(一式の path と結果のキー) */
|
|
149
|
-
export declare const subPath: (path: string, params?: Readonly<Record<string, string>>) => string;
|
|
150
|
-
/**
|
|
151
|
-
* 配信 API の読み取り
|
|
152
|
-
* - drafts: 下書き・予約なども含める(プレビュー用、署名は接続の側で付与)
|
|
153
|
-
* - at: 公開の基準の日時(なしは今)
|
|
154
|
-
*/
|
|
155
|
-
export declare function createDeliveryClient(delivery: Delivery, { drafts, at }?: {
|
|
156
|
-
drafts?: boolean;
|
|
157
|
-
at?: string;
|
|
158
|
-
}): {
|
|
159
|
-
find: <T>(path: string, params?: Readonly<Record<string, string>>) => Promise<T | undefined>;
|
|
160
|
-
get: <T>(path: string, params?: Readonly<Record<string, string>>) => Promise<T>;
|
|
161
|
-
page: <I = Readonly<Record<string, unknown>>, T extends ContentType = Readonly<{
|
|
162
|
-
id: string;
|
|
163
|
-
label: string;
|
|
164
|
-
description?: string;
|
|
165
|
-
format?: ContentFormat;
|
|
166
|
-
publishing?: Publishing;
|
|
167
|
-
table?: string;
|
|
168
|
-
core?: readonly FieldDef[];
|
|
169
|
-
fields: readonly FieldDef[];
|
|
170
|
-
pages?: readonly PageDef[];
|
|
171
|
-
counts?: readonly CountDef[];
|
|
172
|
-
og?: string;
|
|
173
|
-
}>>(path: string, query: ListQuery<T> & Readonly<{
|
|
174
|
-
limit: number;
|
|
175
|
-
}>) => Promise<Page<I>>;
|
|
176
|
-
prefetch: (paths: readonly string[], { ifNoneMatch }?: {
|
|
177
|
-
ifNoneMatch?: string;
|
|
178
|
-
}) => Promise<Prefetched>;
|
|
179
|
-
};
|
|
180
|
-
/** 配信 API の読み取り(createDeliveryClient の戻り値) */
|
|
181
|
-
type DeliveryClient = ReturnType<typeof createDeliveryClient>;
|
|
182
|
-
/** 配信する画像の URL(元の URL と、元画像の画素での切り抜きの範囲から、配信の側で変換する URL) */
|
|
183
|
-
type ImageUrl = (src: string, rect?: CropRect) => string;
|
|
184
|
-
/** 実体から表示の素材(見つからない実体はなし) */
|
|
185
|
-
type MediaOf = (asset: unknown) => Media | undefined;
|
|
186
|
-
/**
|
|
187
|
-
* 実体から表示の素材への変換(動画は代わりの画像も)
|
|
188
|
-
* - base: 実体の URL の前半(URL は base/<ID>)
|
|
189
|
-
* - 画像の変換: imageUrl があれば画像(動画の実体は除く)を変換の URL に、切り抜きは切り抜いた画像の URL・寸法・見せたい点
|
|
190
|
-
* - imageUrl なし: 元の画像のまま(手元の開発)
|
|
191
|
-
*/
|
|
192
|
-
export declare function mediaOf(base: string, imageUrl?: ImageUrl): MediaOf;
|
|
193
|
-
/** 選択肢の項目から表示名の表(値 → 表示名、key はまとまりの中なら `links.kind` の形、選択肢の項目でなければ空) */
|
|
194
|
-
export declare const optionLabels: <K extends string = string>(schema: ContentModel, type: string, key: string) => Readonly<Record<K, string>>;
|
|
195
|
-
/** 型の項目(コアの項目と追加の項目から、なければ例外: 導入先の設定の誤り) */
|
|
196
|
-
export declare function fieldOf(schema: ContentModel, type: string, key: string): FieldDef;
|
|
197
|
-
/** 項目の宣言の上限(宣言がなければ例外) */
|
|
198
|
-
export declare function limitOf(field: FieldDef, name: 'maxItems' | 'maxLength'): number;
|
|
199
|
-
/** ページのパス(型の宣言 pages から、ページのない型は例外) */
|
|
200
|
-
export declare function pagePath(schema: ContentModel, type: string, entry: PageEntry): string;
|
|
201
|
-
/** 媒体のタイムゾーンでの日時の変換(表示用の日付と日時の組 dated を含む) */
|
|
202
|
-
type DeliveryClock = Clock & Readonly<{
|
|
203
|
-
/** 日時の項目から、表示用のタイムゾーンの日付と `ISO 8601` の日時(日時の形でない値はそのまま) */
|
|
204
|
-
dated: (value: string) => Readonly<{
|
|
205
|
-
date: DateString;
|
|
206
|
-
at: string;
|
|
207
|
-
}>;
|
|
208
|
-
}>;
|
|
209
|
-
/** 日時の変換を作成(timeZone は媒体の設定にある IANA の名前) */
|
|
210
|
-
export declare function createDeliveryClock(timeZone: string): DeliveryClock;
|
|
211
|
-
export type { BundleResult, DeliveredAsset, Delivery, DeliveryClient, DeliveryClock, FieldValue, ImageUrl, Item, ItemOf, ListFilter, ListQuery, MediaOf, Page, Prefetched };
|
|
1
|
+
export * from './types/sdk/src/delivery.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/sdk/src/integrations.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { a as openValue, i as SIGNED_HEADERS, l as verifyRequest } from "./src-Baj-EC2G.js";
|
|
2
|
+
import "./src-BrLwIWaT.js";
|
|
3
|
+
// ../cms-contract/src/embeds.ts
|
|
4
|
+
/** URL のクエリの名前(署名つきの文脈) */
|
|
5
|
+
const EMBED_CONTEXT_PARAM = "ctx";
|
|
6
|
+
/** postMessage の種類 */
|
|
7
|
+
const EMBED_MESSAGES = {
|
|
8
|
+
ready: "maezae:ready",
|
|
9
|
+
values: "maezae:values",
|
|
10
|
+
set: "maezae:set",
|
|
11
|
+
height: "maezae:height"
|
|
12
|
+
};
|
|
13
|
+
// ../cms-contract/src/functions.ts
|
|
14
|
+
/** 依頼する時点(save_check は型の保存前、publish_check は提出・公開の前の検査) */
|
|
15
|
+
const FUNCTION_HOOKS = ["save_check", "publish_check"];
|
|
16
|
+
export { EMBED_CONTEXT_PARAM, EMBED_MESSAGES, FUNCTION_HOOKS, SIGNED_HEADERS, openValue, verifyRequest };
|
package/dist/model.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { type Asset, type AssetRef, type Clock, type ContentModel, type ContentType, type Crop, type CropRect, type DateString, type FieldDef, type Hotspot, type LocalImage, type Media, type PageDef, type PageEntry, coverPosition, coverStart, createClock, cropRect, croppedHotspot, isDateOnly, mediaSchema, objectPosition, pagePathOf, publicPathOf, stillOf, typeOf };
|
|
1
|
+
export * from './types/sdk/src/model.js';
|