@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.
Files changed (94) hide show
  1. package/README.md +14 -0
  2. package/dist/analytics.d.ts +1 -0
  3. package/dist/analytics.js +33 -0
  4. package/dist/body.d.ts +1 -24
  5. package/dist/body.js +40 -238
  6. package/dist/declared-9_jI3JXH.js +336 -0
  7. package/dist/delivery.d.ts +1 -211
  8. package/dist/integrations.d.ts +1 -0
  9. package/dist/integrations.js +16 -0
  10. package/dist/model.d.ts +1 -2
  11. package/dist/model.js +676 -1
  12. package/dist/preview.d.ts +1 -44
  13. package/dist/preview.js +1 -103
  14. package/dist/src-Baj-EC2G.js +205 -0
  15. package/dist/src-BrLwIWaT.js +7 -0
  16. package/dist/trace.d.ts +1 -0
  17. package/dist/trace.js +1 -0
  18. package/dist/types/access/src/index.d.ts +5 -0
  19. package/dist/types/access/src/jwt.d.ts +42 -0
  20. package/dist/types/access/src/oidc.d.ts +47 -0
  21. package/dist/types/access/src/signed.d.ts +47 -0
  22. package/dist/types/access/src/span.d.ts +23 -0
  23. package/dist/types/access/src/traceparent.d.ts +21 -0
  24. package/dist/types/analytics/src/day.d.ts +2 -0
  25. package/dist/types/analytics/src/index.d.ts +4 -0
  26. package/dist/types/analytics/src/record.d.ts +22 -0
  27. package/dist/types/analytics/src/schedule.d.ts +2 -0
  28. package/dist/types/analytics/src/source.d.ts +33 -0
  29. package/dist/types/analytics/src/store.d.ts +24 -0
  30. package/dist/types/body/src/components.d.ts +25 -0
  31. package/dist/types/body/src/declared.d.ts +34 -0
  32. package/dist/types/body/src/derive.d.ts +13 -0
  33. package/dist/types/body/src/description.d.ts +8 -0
  34. package/dist/types/body/src/href.d.ts +4 -0
  35. package/dist/types/body/src/index.d.ts +11 -0
  36. package/dist/types/body/src/library.d.ts +94 -0
  37. package/dist/types/body/src/markdown.d.ts +14 -0
  38. package/dist/types/body/src/normalize.d.ts +7 -0
  39. package/dist/types/body/src/profile.d.ts +48 -0
  40. package/dist/types/body/src/schema.d.ts +6 -0
  41. package/dist/types/body/src/standard.d.ts +20 -0
  42. package/dist/types/body/src/types.d.ts +91 -0
  43. package/dist/types/cms-contract/src/apiKeys.d.ts +13 -0
  44. package/dist/types/cms-contract/src/assets.d.ts +10 -0
  45. package/dist/types/cms-contract/src/builtins.d.ts +17 -0
  46. package/dist/types/cms-contract/src/embeds.d.ts +56 -0
  47. package/dist/types/cms-contract/src/errorLabels.d.ts +22 -0
  48. package/dist/types/cms-contract/src/errors.d.ts +97 -0
  49. package/dist/types/cms-contract/src/extensions.d.ts +75 -0
  50. package/dist/types/cms-contract/src/fieldRules.d.ts +37 -0
  51. package/dist/types/cms-contract/src/functions.d.ts +71 -0
  52. package/dist/types/cms-contract/src/index.d.ts +19 -0
  53. package/dist/types/cms-contract/src/labels.d.ts +6 -0
  54. package/dist/types/cms-contract/src/modules.d.ts +144 -0
  55. package/dist/types/cms-contract/src/paths.d.ts +6 -0
  56. package/dist/types/cms-contract/src/pending.d.ts +4 -0
  57. package/dist/types/cms-contract/src/permissions.d.ts +69 -0
  58. package/dist/types/cms-contract/src/roles.d.ts +35 -0
  59. package/dist/types/cms-contract/src/settings.d.ts +19 -0
  60. package/dist/types/cms-contract/src/transfer.d.ts +48 -0
  61. package/dist/types/cms-contract/src/views.d.ts +21 -0
  62. package/dist/types/cms-contract/src/webhooks.d.ts +45 -0
  63. package/dist/types/delivery-client/src/client.d.ts +62 -0
  64. package/dist/types/delivery-client/src/index.d.ts +5 -0
  65. package/dist/types/delivery-client/src/media.d.ts +12 -0
  66. package/dist/types/delivery-client/src/query.d.ts +68 -0
  67. package/dist/types/delivery-client/src/schema.d.ts +19 -0
  68. package/dist/types/delivery-client/src/values.d.ts +63 -0
  69. package/dist/types/model/src/asset.d.ts +89 -0
  70. package/dist/types/model/src/capabilities.d.ts +20 -0
  71. package/dist/types/model/src/changes.d.ts +23 -0
  72. package/dist/types/model/src/check.d.ts +10 -0
  73. package/dist/types/model/src/image.d.ts +38 -0
  74. package/dist/types/model/src/index.d.ts +14 -0
  75. package/dist/types/model/src/input.d.ts +26 -0
  76. package/dist/types/model/src/media.d.ts +5 -0
  77. package/dist/types/model/src/model.d.ts +190 -0
  78. package/dist/types/model/src/page.d.ts +47 -0
  79. package/dist/types/model/src/rules.d.ts +15 -0
  80. package/dist/types/model/src/schema.d.ts +3 -0
  81. package/dist/types/model/src/screens.d.ts +72 -0
  82. package/dist/types/model/src/time.d.ts +25 -0
  83. package/dist/types/model/src/values.d.ts +24 -0
  84. package/dist/types/sdk/src/analytics.d.ts +2 -0
  85. package/dist/types/sdk/src/body.d.ts +2 -0
  86. package/dist/types/sdk/src/defaults.d.ts +5 -0
  87. package/dist/types/sdk/src/delivery.d.ts +2 -0
  88. package/dist/types/sdk/src/integrations.d.ts +4 -0
  89. package/dist/types/sdk/src/model.d.ts +5 -0
  90. package/dist/types/sdk/src/preview.d.ts +2 -0
  91. package/dist/types/sdk/src/trace.d.ts +2 -0
  92. package/package.json +14 -2
  93. package/dist/index-57nirXxn.d.ts +0 -335
  94. package/dist/index-D11fUsoi.d.ts +0 -131
@@ -0,0 +1,25 @@
1
+ import type { Body } from './types.js';
2
+ /** 属性(Markdown の `{…}`、値は文字列) */
3
+ export type Attributes = Readonly<Record<string, string>>;
4
+ /** コンポーネントの Markdown の記法(to と from で往復して同じ props に戻ること) */
5
+ export type ComponentMarkdown<M> = Readonly<{
6
+ to(props: unknown): Readonly<{
7
+ attributes?: Attributes;
8
+ content?: Body<M>;
9
+ }>;
10
+ from(attributes: Attributes, content: Body<M>): unknown;
11
+ }>;
12
+ /** カスタムコンポーネントの定義(inline はインラインのコンポーネント、description と example は Markdown の説明に使用) */
13
+ export type ComponentDef<M> = Readonly<{
14
+ name: string;
15
+ inline?: boolean;
16
+ description?: string;
17
+ example?: string;
18
+ markdown?: ComponentMarkdown<M>;
19
+ }>;
20
+ /** 予約の名前(ブロック) */
21
+ export declare const RESERVED_BLOCK_NAMES: ReadonlySet<string>;
22
+ /** 予約の名前(インライン) */
23
+ export declare const RESERVED_INLINE_NAMES: ReadonlySet<string>;
24
+ /** 既定の記法: props を JSON のコードブロックに */
25
+ export declare const jsonMarkdown: ComponentMarkdown<never>;
@@ -0,0 +1,34 @@
1
+ import { z } from 'zod';
2
+ import { type ComponentDef } from './components.js';
3
+ /** 引数の型 */
4
+ export type PropType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
5
+ /** 1つの引数の形(title は管理画面の項目名、enum は文字列の選択肢、items は配列の要素、properties・required はオブジェクトの中) */
6
+ export type PropSchema = Readonly<{
7
+ type: PropType;
8
+ title?: string;
9
+ description?: string;
10
+ enum?: readonly string[];
11
+ items?: PropSchema;
12
+ properties?: Readonly<Record<string, PropSchema>>;
13
+ required?: readonly string[];
14
+ }>;
15
+ /** 引数の全体の形(最上位はオブジェクト) */
16
+ export type PropsSchema = Readonly<{
17
+ type: 'object';
18
+ properties: Readonly<Record<string, PropSchema>>;
19
+ required?: readonly string[];
20
+ }>;
21
+ /** 導入先が宣言する部品(label は管理画面の表示名、inline の省略はブロック) */
22
+ export type DeclaredComponent = Readonly<{
23
+ name: string;
24
+ label: string;
25
+ description?: string;
26
+ inline?: boolean;
27
+ props: PropsSchema;
28
+ }>;
29
+ /** 宣言の一覧の検査(名前の重複も拒否) */
30
+ export declare const declaredComponentsSchema: z.ZodType<readonly DeclaredComponent[]>;
31
+ /** 宣言した部品の引数の検査(宣言ごとに作成を再利用) */
32
+ export declare function declaredPropsZod(d: DeclaredComponent): z.ZodType;
33
+ /** 宣言から Markdown の変換と説明に使用する部品の定義(記法は既定の JSON) */
34
+ export declare const declaredDefOf: (d: DeclaredComponent) => ComponentDef<never>;
@@ -0,0 +1,13 @@
1
+ import type { Body, Rich } from './types.js';
2
+ /** 読了時間の既定の分速(字/分) */
3
+ export declare const READING_SPEED = 500;
4
+ /** 断片の列の文字(装飾・リンクは文字、インラインのコンポーネントは中の文字) */
5
+ export declare const plainOf: (rich: Rich) => string;
6
+ /** 本文の注が参照する出典の ID(出現の順、重複あり) */
7
+ export declare function citesOf<M>(body: Body<M>): string[];
8
+ /** 本文の導入の文字(最初の見出しまでの段落をつなげたもの、導入がなければ空) */
9
+ export declare function excerptOf<M>(body: Body<M>): string;
10
+ /** 読了時間(分、本文の文字列の字数を分速 speed で割った概算、1分以上) */
11
+ export declare const readMinOf: <M>(body: Body<M>, speed?: number) => number;
12
+ /** 本文にあるサイト内へのリンク先(`/` で始まる href、重複なし) */
13
+ export declare const linksOf: <M>(body: Body<M>) => string[];
@@ -0,0 +1,8 @@
1
+ /** meta description の長さの上限(検索結果で省略されにくい字数の目安) */
2
+ export declare const DESCRIPTION_MAX = 120;
3
+ /**
4
+ * 説明を meta description の長さに調整
5
+ * - 上限を超える場合: 上限までの最後の句点まで
6
+ * - 句点がない場合: 上限で切って省略の記号
7
+ */
8
+ export declare function descriptionOf(excerpt: string, max?: number): string;
@@ -0,0 +1,4 @@
1
+ /** 本文のリンク先として許可する形か(保存の検査とサイトの出力で共通) */
2
+ export declare const isSafeHref: (href: string) => boolean;
3
+ /** 許可しないリンク先の問題の文言 */
4
+ export declare const unsafeHrefMessage: (href: string) => string;
@@ -0,0 +1,11 @@
1
+ export type { ComponentDef } from './components.js';
2
+ export { type DeclaredComponent, declaredComponentsSchema, declaredDefOf, declaredPropsZod, type PropSchema, type PropsSchema, type PropType } from './declared.js';
3
+ export { DESCRIPTION_MAX, descriptionOf } from './description.js';
4
+ export { citesOf, excerptOf, linksOf, plainOf, READING_SPEED, readMinOf } from './derive.js';
5
+ export { CORE_COMPONENTS, coreComponentOf, type Chart, type ChartColor, type ChartDatum, type ComponentName, type ComponentProps, type CoreComponent } from './library.js';
6
+ export { isSafeHref } from './href.js';
7
+ export { fromMarkdown, toMarkdown, type MarkdownOptions } from './markdown.js';
8
+ export { checkBody, describeMarkdown, type BodyProfile } from './profile.js';
9
+ export { blockSchemaOf } from './schema.js';
10
+ export { bodyFromMarkdown, bodyToMarkdown, markdownGuide, type MarkdownResult, type MediaSyntax } from './standard.js';
11
+ export type { Block, Body, ComponentBlock, HeadingLevel, Inline, InlineComponent, Link, List, ListItem, Mark, Rich, StandardBlock, Text } from './types.js';
@@ -0,0 +1,94 @@
1
+ import { z } from 'zod';
2
+ import type { ComponentDef } from './components.js';
3
+ /** グラフの項目と値 */
4
+ export type ChartDatum = Readonly<{
5
+ label: string;
6
+ value: number;
7
+ }>;
8
+ /** グラフの色(テーマの系列の番号) */
9
+ export type ChartColor = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
10
+ /**
11
+ * グラフ(コンポーネント chart の props から caption を除いた形)
12
+ * - bar: 横棒、pie: 割合
13
+ * - line: 折れ線(series の values は labels と同じ長さ)
14
+ * - heat: 濃淡の表(rows の values は cols と同じ長さ)
15
+ */
16
+ export type Chart = Readonly<{
17
+ chart: 'bar';
18
+ data: readonly ChartDatum[];
19
+ unit: string;
20
+ color?: ChartColor;
21
+ } | {
22
+ chart: 'line';
23
+ labels: readonly string[];
24
+ series: readonly Readonly<{
25
+ name: string;
26
+ values: readonly number[];
27
+ }>[];
28
+ unit: string;
29
+ } | {
30
+ chart: 'pie';
31
+ data: readonly ChartDatum[];
32
+ unit: string;
33
+ } | {
34
+ chart: 'heat';
35
+ cols: readonly string[];
36
+ rows: readonly Readonly<{
37
+ label: string;
38
+ values: readonly number[];
39
+ }>[];
40
+ unit: string;
41
+ color?: ChartColor;
42
+ }>;
43
+ /** 核のコンポーネントの props(名前ごと、インラインは属性) */
44
+ export type ComponentProps<M> = Readonly<{
45
+ cite: Readonly<{
46
+ id: string;
47
+ }>;
48
+ pending: Readonly<Record<string, never>>;
49
+ speech: Readonly<{
50
+ text: string;
51
+ }>;
52
+ chart: Chart & Readonly<{
53
+ caption: string;
54
+ }>;
55
+ diagram: Readonly<{
56
+ source: string;
57
+ alt: string;
58
+ caption: string;
59
+ }>;
60
+ gallery: Readonly<{
61
+ items: readonly Readonly<{
62
+ media: M;
63
+ caption?: string;
64
+ }>[];
65
+ }>;
66
+ 'link-card': Readonly<{
67
+ href: `https://${string}`;
68
+ title: string;
69
+ site?: string;
70
+ desc?: string;
71
+ image?: M;
72
+ }>;
73
+ links: Readonly<{
74
+ label?: string;
75
+ items: readonly Readonly<{
76
+ href: `https://${string}`;
77
+ title: string;
78
+ site?: string;
79
+ }>[];
80
+ }>;
81
+ }>;
82
+ /** 核のコンポーネントの名前 */
83
+ export type ComponentName = keyof ComponentProps<unknown>;
84
+ /** 核のコンポーネントの定義(props は検査、インラインは属性の検査) */
85
+ export type CoreComponent = ComponentDef<unknown> & Readonly<{
86
+ name: ComponentName;
87
+ props: (media: z.ZodType) => z.ZodType;
88
+ }>;
89
+ /** 注のコンポーネントの名前(本文からの算出 citesOf が参照) */
90
+ export declare const CITE = "cite";
91
+ /** 核のコンポーネント(chart の Markdown は既定の JSON) */
92
+ export declare const CORE_COMPONENTS: readonly CoreComponent[];
93
+ /** 名前から核のコンポーネント(なければ undefined) */
94
+ export declare const coreComponentOf: (name: string) => CoreComponent | undefined;
@@ -0,0 +1,14 @@
1
+ import { type ComponentDef } from './components.js';
2
+ import type { Body } from './types.js';
3
+ /** マッパーの設定(media は画像の参照と Markdown の文字列の変換) */
4
+ export type MarkdownOptions<M> = Readonly<{
5
+ media: Readonly<{
6
+ toSrc(media: M): string;
7
+ fromSrc(src: string): M;
8
+ }>;
9
+ components?: readonly ComponentDef<M>[];
10
+ }>;
11
+ /** 本文を Markdown に */
12
+ export declare function toMarkdown<M>(body: Body<M>, options: MarkdownOptions<M>): string;
13
+ /** Markdown を本文に(解析できない構文は例外) */
14
+ export declare function fromMarkdown<M>(markdown: string, options: MarkdownOptions<M>): Body<M>;
@@ -0,0 +1,7 @@
1
+ import type { Body, Mark, Rich } from './types.js';
2
+ /** 装飾の順序(Markdown では外側から内側) */
3
+ export declare const MARK_ORDER: readonly Mark[];
4
+ /** インラインの断片の列を正規化 */
5
+ export declare function normalizeRich(rich: Rich): Rich;
6
+ /** 本文を正規化 */
7
+ export declare function normalizeBody<M>(body: Body<M>): Body<M>;
@@ -0,0 +1,48 @@
1
+ import type { ComponentDef } from './components.js';
2
+ import type { Body, HeadingLevel, Mark } from './types.js';
3
+ /** 本文の設定 */
4
+ export type BodyProfile = Readonly<{
5
+ headings: readonly HeadingLevel[];
6
+ marks: readonly Mark[];
7
+ /** 装飾の重ね掛けと装飾つきのリンク(既定は可) */
8
+ combineMarks?: boolean;
9
+ /** リンクの rel(なしは rel なしのリンクだけ) */
10
+ linkRels?: readonly string[];
11
+ /** 装飾・リンク・インラインのコンポーネントを使用できない場所 */
12
+ plain?: readonly ('heading' | 'tableHead')[];
13
+ list?: Readonly<{
14
+ ordered: boolean;
15
+ nested: boolean;
16
+ variants?: readonly string[];
17
+ }>;
18
+ quote?: Readonly<{
19
+ multiple: boolean;
20
+ cite: boolean;
21
+ }>;
22
+ /** コード(componentLangs はコンポーネントで書く言語とコンポーネントの名前、例: mermaid は図、その言語のフェンスだけのコードは不可) */
23
+ code?: Readonly<{
24
+ caption: boolean;
25
+ componentLangs?: Readonly<Record<string, string>>;
26
+ }>;
27
+ image?: Readonly<{
28
+ variants?: readonly string[];
29
+ }>;
30
+ table?: Readonly<{
31
+ head: 'required' | 'optional';
32
+ caption: 'required' | 'optional' | 'none';
33
+ }>;
34
+ divider?: true;
35
+ html?: true;
36
+ /** 使用できるコンポーネントの名前(ブロック・インライン) */
37
+ components: readonly string[];
38
+ }>;
39
+ /** 本文の設定に合わない箇所(index は本文のブロックの位置、0から) */
40
+ type BodyProblem = Readonly<{
41
+ index: number;
42
+ message: string;
43
+ }>;
44
+ /** 本文を設定で検査(合わない箇所をすべて返却) */
45
+ export declare function checkBody<M>(body: Body<M>, profile: BodyProfile): BodyProblem[];
46
+ /** 書き手と AI への Markdown の説明(使用できるものを記法の例つきで列挙し、使用できないものは末尾) */
47
+ export declare function describeMarkdown<M>(profile: BodyProfile, components?: readonly ComponentDef<M>[]): string;
48
+ export {};
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ import { type DeclaredComponent } from './declared.js';
3
+ import { type BodyProfile } from './profile.js';
4
+ import type { Block } from './types.js';
5
+ /** 本文の1ブロックの検査(profile は本文の設定、media は画像の参照の検査、declared は導入先が宣言した部品) */
6
+ export declare function blockSchemaOf<M>(profile: BodyProfile, media: z.ZodType<M>, declared?: readonly DeclaredComponent[]): z.ZodType<Block<M>>;
@@ -0,0 +1,20 @@
1
+ import { type DeclaredComponent } from './declared.js';
2
+ import { type MarkdownOptions } from './markdown.js';
3
+ import { type BodyProfile } from './profile.js';
4
+ import type { Body } from './types.js';
5
+ /** 画像の参照と Markdown の文字列の変換(example は説明の例の参照) */
6
+ export type MediaSyntax<M> = MarkdownOptions<M>['media'] & Readonly<{
7
+ example: string;
8
+ }>;
9
+ /** Markdown の解析の結果(problems は設定に合わない箇所のすべて) */
10
+ export type MarkdownResult<M> = Readonly<{
11
+ body: Body<M>;
12
+ }> | Readonly<{
13
+ problems: readonly string[];
14
+ }>;
15
+ /** 本文を Markdown に(declared は導入先が宣言した部品) */
16
+ export declare const bodyToMarkdown: <M>(body: Body<M>, media: MediaSyntax<M>, declared?: readonly DeclaredComponent[]) => string;
17
+ /** Markdown を本文に(解析できない・設定に合わない内容は problems、declared は導入先が宣言した部品) */
18
+ export declare function bodyFromMarkdown<M>(markdown: string, profile: BodyProfile, media: MediaSyntax<M>, declared?: readonly DeclaredComponent[]): MarkdownResult<M>;
19
+ /** 書き手と AI へ最初に提示する Markdown の説明(設定と核のコンポーネント・宣言した部品から作成) */
20
+ export declare const markdownGuide: (profile: BodyProfile, media: Pick<MediaSyntax<unknown>, "example">, declared?: readonly DeclaredComponent[]) => string;
@@ -0,0 +1,91 @@
1
+ /** インラインの装飾(strong・em・code・s・mark・sup・sub) */
2
+ export type Mark = 'strong' | 'em' | 'code' | 'strike' | 'mark' | 'sup' | 'sub';
3
+ /** リンク(HTML の a の href・title・rel) */
4
+ export type Link = Readonly<{
5
+ href: string;
6
+ title?: string;
7
+ rel?: string;
8
+ }>;
9
+ /** 装飾・リンクつきの文字列 */
10
+ export type Text = Readonly<{
11
+ text: string;
12
+ marks?: readonly Mark[];
13
+ link?: Link;
14
+ }>;
15
+ /** インラインのコンポーネント(例: 注、属性は文字列だけ、text は中の文字) */
16
+ export type InlineComponent = Readonly<{
17
+ component: string;
18
+ props?: Readonly<Record<string, string>>;
19
+ text?: string;
20
+ }>;
21
+ /** インラインの断片(文字列は装飾なし) */
22
+ export type Inline = string | Text | InlineComponent;
23
+ /** インラインの断片の列(1つの段落・見出し・セルの内容) */
24
+ export type Rich = readonly Inline[];
25
+ /** 見出しの段階 */
26
+ export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
27
+ /** リストの1項目(children は入れ子のリスト) */
28
+ export type ListItem = Readonly<{
29
+ content: Rich;
30
+ children?: List;
31
+ }>;
32
+ /** リスト */
33
+ export type List = Readonly<{
34
+ type: 'list';
35
+ ordered?: boolean;
36
+ items: readonly ListItem[];
37
+ variant?: string;
38
+ }>;
39
+ /** 標準のブロック */
40
+ export type StandardBlock<M> = Readonly<{
41
+ type: 'paragraph';
42
+ content: Rich;
43
+ variant?: string;
44
+ }> | Readonly<{
45
+ type: 'heading';
46
+ level: HeadingLevel;
47
+ content: Rich;
48
+ id?: string;
49
+ variant?: string;
50
+ }> | List | Readonly<{
51
+ type: 'quote';
52
+ content: readonly Rich[];
53
+ cite?: Readonly<{
54
+ label: string;
55
+ href?: string;
56
+ }>;
57
+ variant?: string;
58
+ }> | Readonly<{
59
+ type: 'code';
60
+ code: string;
61
+ lang?: string;
62
+ caption?: string;
63
+ variant?: string;
64
+ }> | Readonly<{
65
+ type: 'image';
66
+ media: M;
67
+ alt?: string;
68
+ caption?: string;
69
+ variant?: string;
70
+ }> | Readonly<{
71
+ type: 'table';
72
+ head?: readonly Rich[];
73
+ rows: readonly (readonly Rich[])[];
74
+ caption?: string;
75
+ variant?: string;
76
+ }> | Readonly<{
77
+ type: 'divider';
78
+ }> | Readonly<{
79
+ type: 'html';
80
+ html: string;
81
+ }>;
82
+ /** カスタムコンポーネントのブロック(props は JSON で表せる値) */
83
+ export type ComponentBlock = Readonly<{
84
+ type: 'component';
85
+ name: string;
86
+ props: unknown;
87
+ }>;
88
+ /** 本文のブロック */
89
+ export type Block<M> = StandardBlock<M> | ComponentBlock;
90
+ /** 本文 */
91
+ export type Body<M> = readonly Block<M>[];
@@ -0,0 +1,13 @@
1
+ /** 一覧に表示する API の鍵(tail は鍵の末尾、revokedAt は失効の日時で有効なら null) */
2
+ export type ApiKey = Readonly<{
3
+ id: string;
4
+ label: string;
5
+ tail: string;
6
+ createdAt: string;
7
+ revokedAt: string | null;
8
+ }>;
9
+ /** 公開のエンドポイントで鍵ごとの回数の上限(period は秒) */
10
+ export declare const API_KEY_RATE: {
11
+ readonly limit: 600;
12
+ readonly period: 60;
13
+ };
@@ -0,0 +1,10 @@
1
+ /** まとめての削除・元に戻すで1回のリクエストに指定できる画像の数(超える分は管理画面が分割して送信) */
2
+ export declare const ASSET_BULK_MAX = 500;
3
+ /**
4
+ * アップロード・取り込みで受け付ける画像の形式(判定はファイルの先頭のバイト、申告の種類は不使用)
5
+ * - SVG: スクリプトを含められ、CMS のオリジンで配信すると実行されうるため対象外
6
+ * - AVIF: OG 画像の生成(photon)が非対応のため対象外
7
+ */
8
+ export declare const ASSET_IMAGE_TYPES: readonly ["image/jpeg", "image/png", "image/webp", "image/gif"];
9
+ /** 画像1枚の大きさの上限(バイト、アップロード・取り込みで共通) */
10
+ export declare const ASSET_SIZE_MAX: number;
@@ -0,0 +1,17 @@
1
+ import type { ModuleManifest } from './modules.js';
2
+ /** 計測(閲覧数の集計・ダッシュボードの閲覧数) */
3
+ export declare const ANALYTICS_MODULE: ModuleManifest;
4
+ /** OG 画像の自動生成で選択できる書体(id と表示名、文字の範囲はサーバーの側の OG 画像のモジュール) */
5
+ export declare const OG_FONTS: {
6
+ readonly 'noto-serif-jp': "Noto Serif JP(明朝)";
7
+ };
8
+ /** OG 画像の書体の id */
9
+ export type OgFont = keyof typeof OG_FONTS;
10
+ /** OG 画像の設定値(font は自動生成の画像の書体、なしは書体の点検なし) */
11
+ export type OgSettings = Readonly<{
12
+ font?: OgFont;
13
+ }>;
14
+ /** OG 画像(自動生成の画像に付く規則、導入先の設定 modules の og に書体) */
15
+ export declare const OG_MODULE: ModuleManifest<OgSettings>;
16
+ /** コアに組み込みのモジュール(登録の順) */
17
+ export declare const BUILTIN_MODULES: readonly ModuleManifest<unknown>[];
@@ -0,0 +1,56 @@
1
+ /** 外の画面を表示する位置(編集画面のパネル) */
2
+ export declare const EMBED_PLACEMENTS: readonly ["panel"];
3
+ /** 外の画面を表示する位置 */
4
+ export type EmbedPlacement = (typeof EMBED_PLACEMENTS)[number];
5
+ /** 外の画面の登録(secret は末尾だけを伏せずに返す) */
6
+ export type ExternalScreen = Readonly<{
7
+ id: string;
8
+ label: string;
9
+ type: string;
10
+ url: string;
11
+ placement: EmbedPlacement;
12
+ secret: string;
13
+ enabled: boolean;
14
+ }>;
15
+ /** 編集画面に置く外の画面(鍵なし、編集できるアカウントに返す) */
16
+ export type EmbedEntry = Readonly<{
17
+ id: string;
18
+ label: string;
19
+ url: string;
20
+ placement: EmbedPlacement;
21
+ }>;
22
+ /** 署名つきの文脈の内容(id は行の ID で新規は null、origin は管理画面のオリジン) */
23
+ export type EmbedContext = Readonly<{
24
+ tenant: string;
25
+ account: Readonly<{
26
+ id: string;
27
+ role: string;
28
+ }>;
29
+ type: string;
30
+ id: string | null;
31
+ origin: string;
32
+ }>;
33
+ /** URL のクエリの名前(署名つきの文脈) */
34
+ export declare const EMBED_CONTEXT_PARAM = "ctx";
35
+ /** 文脈の有効期間(秒) */
36
+ export declare const EMBED_CONTEXT_TTL_SEC = 600;
37
+ /** postMessage の種類 */
38
+ export declare const EMBED_MESSAGES: {
39
+ readonly ready: "maezae:ready";
40
+ readonly values: "maezae:values";
41
+ readonly set: "maezae:set";
42
+ readonly height: "maezae:height";
43
+ };
44
+ /** 外の画面と管理画面の間のメッセージ */
45
+ export type EmbedMessage = Readonly<{
46
+ type: typeof EMBED_MESSAGES.ready;
47
+ }> | Readonly<{
48
+ type: typeof EMBED_MESSAGES.values;
49
+ values: Readonly<Record<string, unknown>>;
50
+ }> | Readonly<{
51
+ type: typeof EMBED_MESSAGES.set;
52
+ values: Readonly<Record<string, unknown>>;
53
+ }> | Readonly<{
54
+ type: typeof EMBED_MESSAGES.height;
55
+ height: number;
56
+ }>;
@@ -0,0 +1,22 @@
1
+ import { type ErrorCode, type ErrorParams, type ErrorTarget } from './errors.js';
2
+ /** コアの対象の表示名(エラーの文と操作の履歴で共通、モジュールの対象は ModuleManifest の targets) */
3
+ export declare const TARGET_LABELS: Record<ErrorTarget, string>;
4
+ /** 型の id・マスタの種類からエラーの対象(対象の一覧になければ fallback) */
5
+ export declare const targetOf: (id: string, fallback: ErrorTarget) => ErrorTarget;
6
+ /**
7
+ * 対象ごとの文の追加(モジュールの manifest の messages、キーは対象の id)
8
+ * - own: 自分のものだけを操作できるときの文
9
+ * - noLink: 結び付くエントリーがないアカウントの文、{name} は結び付くコンテンツタイプの表示名
10
+ */
11
+ export type TargetMessages = Readonly<{
12
+ own?: Readonly<Record<string, string>>;
13
+ noLink?: Readonly<Record<string, string>>;
14
+ }>;
15
+ /** エラーの文(targets は対象の表示名、messages は対象ごとの文の追加、サーバーはモジュールの対象と文を含めた表) */
16
+ export declare const errorLabel: (code: ErrorCode, params?: ErrorParams, targets?: Readonly<Record<string, string>>, messages?: TargetMessages) => string;
17
+ /** モジュールの対象ごとの文をまとめる(同じ対象はあとのモジュールの文) */
18
+ export declare const mergeMessages: (list: readonly (TargetMessages | undefined)[]) => TargetMessages;
19
+ /** エラーのトーストの見出し(項目ごとの理由がすべて未入力なら必須項目のエラー、スキーマの文は「〜が未入力」で統一) */
20
+ export declare const errorTitle: (code: ErrorCode, issues?: readonly {
21
+ message: string;
22
+ }[]) => string;
@@ -0,0 +1,97 @@
1
+ /** 変更の操作で受け付ける本文の大きさ(/api、バイト数、multipart のアップロードは ASSET_SIZE_MAX) */
2
+ export declare const JSON_BODY_MAX: number;
3
+ /** エラーのコードと HTTP の状態 */
4
+ export declare const ERROR_STATUS: {
5
+ readonly invalid_input: 400;
6
+ readonly submit_unmet: 400;
7
+ readonly publish_unmet: 400;
8
+ readonly save_unmet: 403;
9
+ readonly version_required: 400;
10
+ readonly file_required: 400;
11
+ readonly file_too_large: 400;
12
+ readonly unsupported_image: 400;
13
+ readonly invalid_dimensions: 400;
14
+ readonly https_required: 400;
15
+ readonly invalid_style: 400;
16
+ readonly login_required: 401;
17
+ readonly invalid_mcp_token: 401;
18
+ readonly preview_token_required: 401;
19
+ readonly api_key_required: 401;
20
+ readonly invalid_api_key: 401;
21
+ readonly account_not_found: 403;
22
+ readonly invalid_preview_token: 403;
23
+ readonly mcp_not_allowed: 403;
24
+ readonly admin_only: 403;
25
+ readonly forbidden: 403;
26
+ readonly editorial_only: 403;
27
+ readonly no_linked_entry: 403;
28
+ readonly own_only: 403;
29
+ readonly not_visible: 403;
30
+ readonly published_admin_only: 403;
31
+ readonly cannot_remove_self: 403;
32
+ readonly cannot_change_owner: 403;
33
+ readonly not_found: 404;
34
+ readonly read_only: 405;
35
+ readonly in_use: 409;
36
+ readonly duplicate_name: 409;
37
+ readonly duplicate_email: 409;
38
+ readonly duplicate_id: 409;
39
+ readonly version_conflict: 409;
40
+ readonly article_editing: 409;
41
+ readonly invalid_state: 409;
42
+ readonly unpublish_first: 409;
43
+ readonly body_too_large: 413;
44
+ readonly rate_limited: 429;
45
+ readonly upstream_failed: 502;
46
+ readonly not_configured: 503;
47
+ readonly unavailable: 503;
48
+ readonly job_failed: 500;
49
+ readonly internal_error: 500;
50
+ readonly network_error: 0;
51
+ };
52
+ /** エラーのコード(network_error は画面の側だけ、通信の失敗と JSON でない応答) */
53
+ export type ErrorCode = keyof typeof ERROR_STATUS;
54
+ /**
55
+ * コアの操作や表示の対象(not_found・own_only などの params.target)
56
+ * - 型の対象: 型の id、表示名はスキーマ
57
+ * - モジュールの対象: ModuleManifest の targets
58
+ */
59
+ export type ErrorTarget = 'request' | 'role' | 'media' | 'entry' | 'asset' | 'mcp' | 'version' | 'profile' | 'portrait' | 'extension' | 'account' | 'comment' | 'view' | 'webhook' | 'external_function' | 'external_screen' | 'api_key';
60
+ /** エラーの補足の値(コードごとに使用する項目だけ) */
61
+ export type ErrorParams = {
62
+ /**
63
+ * 対象: not_found・own_only・forbidden・not_visible・no_linked_entry・editorial_only
64
+ * - 文字列: モジュールの対象・コンテンツタイプの id
65
+ */
66
+ target?: ErrorTarget | (string & {});
67
+ /** 件数: in_use */
68
+ count?: number;
69
+ /** 使用先: in_use */
70
+ by?: 'uses' | 'places' | 'outputs' | 'entry' | 'writers' | 'members' | 'accounts';
71
+ /** 状態の不一致の理由: invalid_state */
72
+ reason?: 'not_draft' | 'not_in_review' | 'request_handled' | 'deleted' | 'not_deleted' | 'schema_confirm' | 'no_publishing' | 'no_review';
73
+ /** 取得の対象: upstream_failed */
74
+ resource?: 'page' | 'image' | 'webhook';
75
+ /**
76
+ * 名前
77
+ * - no_linked_entry: 結び付くコンテンツタイプの表示名、account_not_found: メールアドレス
78
+ * - not_configured: 設定の名前、job_failed: 失敗の理由、in_use の entry: 参照する型と項目
79
+ */
80
+ name?: string;
81
+ };
82
+ /**
83
+ * エラーの応答の本文
84
+ * - login: ログインなしのとき、CMS 自身が受け持つログインの入り口
85
+ * - requestId: 5xx の相関の ID(問い合わせのときにログと突き合わせ)
86
+ */
87
+ export type ErrorBody = {
88
+ code: ErrorCode;
89
+ params?: ErrorParams;
90
+ issues?: {
91
+ path: string;
92
+ message: string;
93
+ }[];
94
+ login?: string;
95
+ requestId?: string;
96
+ error: string;
97
+ };