@ryusenkei/maezae 0.2.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 +2 -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 +1 -333
  6. package/dist/declared-9_jI3JXH.js +336 -0
  7. package/dist/delivery.d.ts +1 -211
  8. package/dist/integrations.d.ts +1 -72
  9. package/dist/integrations.js +12 -2
  10. package/dist/model.d.ts +1 -82
  11. package/dist/model.js +338 -1
  12. package/dist/preview.d.ts +1 -2
  13. package/dist/preview.js +1 -1
  14. package/dist/{src-CA_67dWy.js → src-Baj-EC2G.js} +105 -3
  15. package/dist/trace.d.ts +1 -0
  16. package/dist/trace.js +1 -0
  17. package/dist/types/access/src/index.d.ts +5 -0
  18. package/dist/types/access/src/jwt.d.ts +42 -0
  19. package/dist/types/access/src/oidc.d.ts +47 -0
  20. package/dist/types/access/src/signed.d.ts +47 -0
  21. package/dist/types/access/src/span.d.ts +23 -0
  22. package/dist/types/access/src/traceparent.d.ts +21 -0
  23. package/dist/types/analytics/src/day.d.ts +2 -0
  24. package/dist/types/analytics/src/index.d.ts +4 -0
  25. package/dist/types/analytics/src/record.d.ts +22 -0
  26. package/dist/types/analytics/src/schedule.d.ts +2 -0
  27. package/dist/types/analytics/src/source.d.ts +33 -0
  28. package/dist/types/analytics/src/store.d.ts +24 -0
  29. package/dist/types/body/src/components.d.ts +25 -0
  30. package/dist/types/body/src/declared.d.ts +34 -0
  31. package/dist/types/body/src/derive.d.ts +13 -0
  32. package/dist/types/body/src/description.d.ts +8 -0
  33. package/dist/types/body/src/href.d.ts +4 -0
  34. package/dist/types/body/src/index.d.ts +11 -0
  35. package/dist/types/body/src/library.d.ts +94 -0
  36. package/dist/types/body/src/markdown.d.ts +14 -0
  37. package/dist/types/body/src/normalize.d.ts +7 -0
  38. package/dist/types/body/src/profile.d.ts +48 -0
  39. package/dist/types/body/src/schema.d.ts +6 -0
  40. package/dist/types/body/src/standard.d.ts +20 -0
  41. package/dist/types/body/src/types.d.ts +91 -0
  42. package/dist/types/cms-contract/src/apiKeys.d.ts +13 -0
  43. package/dist/types/cms-contract/src/assets.d.ts +10 -0
  44. package/dist/types/cms-contract/src/builtins.d.ts +17 -0
  45. package/dist/types/cms-contract/src/embeds.d.ts +56 -0
  46. package/dist/types/cms-contract/src/errorLabels.d.ts +22 -0
  47. package/dist/types/cms-contract/src/errors.d.ts +97 -0
  48. package/dist/types/cms-contract/src/extensions.d.ts +75 -0
  49. package/dist/types/cms-contract/src/fieldRules.d.ts +37 -0
  50. package/dist/types/cms-contract/src/functions.d.ts +71 -0
  51. package/dist/types/cms-contract/src/index.d.ts +19 -0
  52. package/dist/types/cms-contract/src/labels.d.ts +6 -0
  53. package/dist/types/cms-contract/src/modules.d.ts +144 -0
  54. package/dist/types/cms-contract/src/paths.d.ts +6 -0
  55. package/dist/types/cms-contract/src/pending.d.ts +4 -0
  56. package/dist/types/cms-contract/src/permissions.d.ts +69 -0
  57. package/dist/types/cms-contract/src/roles.d.ts +35 -0
  58. package/dist/types/cms-contract/src/settings.d.ts +19 -0
  59. package/dist/types/cms-contract/src/transfer.d.ts +48 -0
  60. package/dist/types/cms-contract/src/views.d.ts +21 -0
  61. package/dist/types/cms-contract/src/webhooks.d.ts +45 -0
  62. package/dist/types/delivery-client/src/client.d.ts +62 -0
  63. package/dist/types/delivery-client/src/index.d.ts +5 -0
  64. package/dist/types/delivery-client/src/media.d.ts +12 -0
  65. package/dist/types/delivery-client/src/query.d.ts +68 -0
  66. package/dist/types/delivery-client/src/schema.d.ts +19 -0
  67. package/dist/types/delivery-client/src/values.d.ts +63 -0
  68. package/dist/types/model/src/asset.d.ts +89 -0
  69. package/dist/types/model/src/capabilities.d.ts +20 -0
  70. package/dist/types/model/src/changes.d.ts +23 -0
  71. package/dist/types/model/src/check.d.ts +10 -0
  72. package/dist/types/model/src/image.d.ts +38 -0
  73. package/dist/types/model/src/index.d.ts +14 -0
  74. package/dist/types/model/src/input.d.ts +26 -0
  75. package/dist/types/model/src/media.d.ts +5 -0
  76. package/dist/types/model/src/model.d.ts +190 -0
  77. package/dist/types/model/src/page.d.ts +47 -0
  78. package/dist/types/model/src/rules.d.ts +15 -0
  79. package/dist/types/model/src/schema.d.ts +3 -0
  80. package/dist/types/model/src/screens.d.ts +72 -0
  81. package/dist/types/model/src/time.d.ts +25 -0
  82. package/dist/types/model/src/values.d.ts +24 -0
  83. package/dist/types/sdk/src/analytics.d.ts +2 -0
  84. package/dist/types/sdk/src/body.d.ts +2 -0
  85. package/dist/types/sdk/src/defaults.d.ts +5 -0
  86. package/dist/types/sdk/src/delivery.d.ts +2 -0
  87. package/dist/types/sdk/src/integrations.d.ts +4 -0
  88. package/dist/types/sdk/src/model.d.ts +5 -0
  89. package/dist/types/sdk/src/preview.d.ts +2 -0
  90. package/dist/types/sdk/src/trace.d.ts +2 -0
  91. package/package.json +10 -2
  92. package/dist/index-C8duwjns.d.ts +0 -157
  93. package/dist/index-CLDe_wBc.d.ts +0 -340
  94. package/dist/signed-B_58gV21.d.ts +0 -44
@@ -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
+ };
@@ -0,0 +1,75 @@
1
+ import type { ConnectionPoint, ContentTypePoint, ModuleBase, PermissionTarget, SettingField } from './modules.js';
2
+ /** 拡張機能の状態(API /api/extensions の行) */
3
+ export type ExtensionState = Readonly<{
4
+ id: string;
5
+ label: string;
6
+ description: string;
7
+ /** コアに組み込みのモジュール */
8
+ builtIn: boolean;
9
+ /** 導入先の設定でオフにできない(常にオン) */
10
+ required: boolean;
11
+ enabled: boolean;
12
+ contentTypes: Required<ContentTypePoint>;
13
+ permissions: readonly PermissionTarget[];
14
+ /** 必要な外部の接続と、接続済みか */
15
+ connections: readonly (ConnectionPoint & Readonly<{
16
+ connected: boolean;
17
+ }>)[];
18
+ settingFields: readonly SettingField[];
19
+ /** 設定のページで編集する項目の現在値(キーは settingFields の key) */
20
+ settings: Readonly<Record<string, unknown>>;
21
+ /** 設定値の入力(導入先の指定に画面で保存した値を重ねたもの、管理画面・MCP が manifest.settings で解釈、組み込みのモジュールは空) */
22
+ settingsInput: Readonly<Record<string, unknown>>;
23
+ /** サーバーの側が追加するもの(定期の処理・記事の規則は表示名) */
24
+ adds: Readonly<{
25
+ jobs: readonly string[];
26
+ rules: readonly string[];
27
+ calendar: boolean;
28
+ delivery: boolean;
29
+ }>;
30
+ }>;
31
+ /** 拡張機能の切り替えと設定の保存(PUT /api/extensions/:id の本文) */
32
+ export type ExtensionUpdate = Readonly<{
33
+ enabled?: boolean;
34
+ settings?: Readonly<Record<string, unknown>>;
35
+ }>;
36
+ /**
37
+ * カレンダーの予定(API /api/calendar の行、at は ISO 8601、path は管理画面の経路)
38
+ * - source: 記事の公開は core、モジュールはその id、設定で掲載する日付のフィールドは calendarFieldSource
39
+ */
40
+ export type CalendarItem = Readonly<{
41
+ source: string;
42
+ id: string;
43
+ title: string;
44
+ at: string;
45
+ path: string | null;
46
+ }>;
47
+ /** カレンダーに掲載する日付のフィールド(type はコンテンツタイプの id、field は最上位の date・datetime のフィールドのキー) */
48
+ export type CalendarField = Readonly<{
49
+ type: string;
50
+ field: string;
51
+ }>;
52
+ /** 日付のフィールドの予定が持つ source(`field:<型>.<フィールド>`) */
53
+ export declare const calendarFieldSource: (f: CalendarField) => string;
54
+ /**
55
+ * ダッシュボードの対応待ちの行(API /api/dashboard の overall.pending)
56
+ * - kind: レビュー待ちは review、承認待ちは request、モジュールはその id
57
+ * - type: 対象のコンテンツタイプの id(件数だけの行は null)
58
+ * - title: 対象の名前で件数だけの行は null、count: 件数で1件の行は1
59
+ * - by: 提出・依頼した人、at: 最新の日時(UTC の ISO 8601)、path: 管理画面の経路
60
+ */
61
+ export type PendingItem = Readonly<{
62
+ kind: string;
63
+ type: string | null;
64
+ title: string | null;
65
+ count: number;
66
+ by: string | null;
67
+ at: string | null;
68
+ path: string | null;
69
+ }>;
70
+ /** 拡張機能が持つフィールドの持ち主(キーは `型/フィールド`、値はモジュールの id、重複は例外) */
71
+ export declare function fieldOwnersOf(modules: readonly Pick<ModuleBase, 'id' | 'about'>[]): ReadonlyMap<string, string>;
72
+ /** 権限の対象の一覧(モジュールの id つき、id の重複は例外) */
73
+ export declare function permissionTargetsOf(modules: readonly Pick<ModuleBase, 'id' | 'about'>[]): readonly (PermissionTarget & Readonly<{
74
+ module: string;
75
+ }>)[];
@@ -0,0 +1,37 @@
1
+ import type { FieldRef } from './modules.js';
2
+ type Values = Readonly<Record<string, unknown>>;
3
+ /** 拡張機能のフィールドの規則(type・key の項目に対する宣言) */
4
+ export type FieldRule = FieldRef & Readonly<{
5
+ /** 値を拡張機能が決定(人と AI の入力の対象外) */
6
+ auto?: boolean;
7
+ /** ほかの項目の値で決まる値(項目 from の値ごとの値、表にない値は otherwise) */
8
+ derive?: Readonly<{
9
+ from: string;
10
+ map: Readonly<Record<string, string>>;
11
+ otherwise: string;
12
+ }>;
13
+ /** 表示の条件(項目 key の値が in のいずれかのときだけ表示、条件に合わないときは値を空に) */
14
+ when?: Readonly<{
15
+ key: string;
16
+ in: readonly string[];
17
+ }>;
18
+ /** 型の公開が可のアカウントだけが選択できる選択肢(AI は選択不可、message は拒否の理由) */
19
+ restricted?: Readonly<{
20
+ values: readonly string[];
21
+ message: string;
22
+ }>;
23
+ }>;
24
+ /** 表示の条件に合わない項目の key */
25
+ export declare const hiddenFieldsOf: (rules: readonly FieldRule[], type: string, values: Values) => ReadonlySet<string>;
26
+ /** 値を拡張機能が決定する項目の key */
27
+ export declare const autoFieldsOf: (rules: readonly FieldRule[], type: string) => ReadonlySet<string>;
28
+ /** 規則を適用した値(決まる値を設定し、表示の条件に合わない項目は空に) */
29
+ export declare function applyFieldRules<V extends Values>(rules: readonly FieldRule[], type: string, values: V): V;
30
+ /** 選択できない選択肢の値(項目の key ごと、公開が可のアカウントでは空、AI の候補は publisher を false で判定) */
31
+ export declare function restrictedChoicesOf(rules: readonly FieldRule[], type: string, publisher: boolean): Readonly<Record<string, readonly string[]>>;
32
+ /** 選択できない選択肢を選択した値の問題(path は項目の key) */
33
+ export declare const restrictedProblemsOf: (rules: readonly FieldRule[], type: string, values: Values, publisher: boolean) => Readonly<{
34
+ path: string;
35
+ message: string;
36
+ }>[];
37
+ export {};
@@ -0,0 +1,71 @@
1
+ /** 依頼する時点(save_check は型の保存前、publish_check は提出・公開の前の検査) */
2
+ export declare const FUNCTION_HOOKS: readonly ["save_check", "publish_check"];
3
+ /** 依頼する時点 */
4
+ export type FunctionHook = (typeof FUNCTION_HOOKS)[number];
5
+ /** 時点の表示名 */
6
+ export declare const FUNCTION_HOOK_LABELS: Readonly<Record<FunctionHook, string>>;
7
+ /** 時間切れ・失敗・不正な応答のときの扱い(block は保存・提出・公開を拒否、pass は通過) */
8
+ export type FunctionOnError = 'block' | 'pass';
9
+ /** 外の関数の登録(url・secret は末尾だけを伏せずに返す、lastStatus は最新の呼び出しで返った HTTP の状態、送れなかったときは0) */
10
+ export type ExternalFunction = Readonly<{
11
+ id: string;
12
+ label: string;
13
+ hook: FunctionHook;
14
+ type: string;
15
+ url: string;
16
+ secret: string;
17
+ onError: FunctionOnError;
18
+ enabled: boolean;
19
+ lastStatus: number | null;
20
+ lastAt: string | null;
21
+ }>;
22
+ /** 保存前の検査の本文(id は作成なら null、values は宣言と拡張機能で補正した後の項目の値、user は操作した人のアカウントの ID とロール) */
23
+ export type SaveCheckRequest = Readonly<{
24
+ hook: 'save_check';
25
+ type: string;
26
+ id: string | null;
27
+ values: Readonly<Record<string, unknown>>;
28
+ user: Readonly<{
29
+ id: string;
30
+ role: string;
31
+ }>;
32
+ at: string;
33
+ }>;
34
+ /**
35
+ * 保存前の検査の応答(HTTP の状態は 2xx)
36
+ * - problems: 1件でもあれば保存を拒否(path は項目の key、message は画面に表示する理由)
37
+ * - values: 補正する項目だけの値(入力に重ねる、なしは補正なし)
38
+ */
39
+ export type SaveCheckResponse = Readonly<{
40
+ problems?: readonly Readonly<{
41
+ path: string;
42
+ message: string;
43
+ }>[];
44
+ values?: Readonly<Record<string, unknown>>;
45
+ }>;
46
+ /** 提出・公開前の検査の本文(stage は submit か publish、values は保存済みの行の値、id はテストの呼び出しだけ null) */
47
+ export type PublishCheckRequest = Readonly<{
48
+ hook: 'publish_check';
49
+ type: string;
50
+ id: string | null;
51
+ stage: 'submit' | 'publish';
52
+ values: Readonly<Record<string, unknown>>;
53
+ user: Readonly<{
54
+ id: string;
55
+ role: string;
56
+ }>;
57
+ at: string;
58
+ }>;
59
+ /** 提出・公開前の検査の応答(HTTP の状態は 2xx、problems が1件でもあれば提出・公開を拒否、値の補正はなし) */
60
+ export type PublishCheckResponse = Readonly<{
61
+ problems?: readonly Readonly<{
62
+ path: string;
63
+ message: string;
64
+ }>[];
65
+ }>;
66
+ /** 外の関数への依頼の本文 */
67
+ export type FunctionRequest = SaveCheckRequest | PublishCheckRequest;
68
+ /** 送信記録の出来事(<型の id>.<時点>) */
69
+ export declare const functionEventOf: (type: string, hook: FunctionHook) => string;
70
+ /** 送信記録の出来事の表示名(types は型の id と表示名、形が違えばそのまま) */
71
+ export declare function functionEventLabel(event: string, types: Readonly<Record<string, string>>): string;
@@ -0,0 +1,19 @@
1
+ export { API_KEY_RATE, type ApiKey } from './apiKeys.js';
2
+ export { ASSET_BULK_MAX, ASSET_IMAGE_TYPES, ASSET_SIZE_MAX } from './assets.js';
3
+ export { errorLabel, errorTitle, mergeMessages, TARGET_LABELS, targetOf, type TargetMessages } from './errorLabels.js';
4
+ export { ERROR_STATUS, JSON_BODY_MAX, type ErrorBody, type ErrorCode, type ErrorParams, type ErrorTarget } from './errors.js';
5
+ export { STATUS } from './labels.js';
6
+ export { ANALYTICS_MODULE, BUILTIN_MODULES, OG_FONTS, OG_MODULE, type OgFont, type OgSettings } from './builtins.js';
7
+ export { type CalendarField, calendarFieldSource, type CalendarItem, type ExtensionState, type ExtensionUpdate, fieldOwnersOf, type PendingItem, permissionTargetsOf } from './extensions.js';
8
+ export { type CallApi, type ConnectionPoint, type ContentTypePoint, createModules, type FieldRef, type McpModule, type McpModuleContext, type McpParts, type McpTool, type ModuleAbout, type ModuleBase, moduleBaseOf, type ModuleContext, type ModuleInstance, type ModuleManifest, type ModuleSettingsInput, type ModuleSide, moduleTargetsOf, type PermissionTarget, type SettingField } from './modules.js';
9
+ export { applyFieldRules, autoFieldsOf, type FieldRule, hiddenFieldsOf, restrictedChoicesOf, restrictedProblemsOf } from './fieldRules.js';
10
+ export { pendingIds, pendingValue } from './pending.js';
11
+ export { type AccountLink, type Action, ACTION_LEVELS, ACTIONS, allows, ANY_TARGET, canChangeRow, canDeleteContent, canEditContent, canPublishContent, canReadContent, canReadRow, canSubmitContent, checkPermissions, type ContentAccess, type Level, LEVELS, levelOf, ownsContent, ownsRow, type Permissions, type RowAccess } from './permissions.js';
12
+ export { ADMIN_PERMISSIONS, ADMIN_ROLE, isAdmin, rolePermissionsOf, type Role, SYSTEM_ROLES, type User, WRITER_ROLE } from './roles.js';
13
+ export { isServerPath, OPS_PATHS, SERVER_PATHS } from './paths.js';
14
+ export { CONFIG_FORMAT, type ConfigBundle, type ConfigPreview } from './transfer.js';
15
+ export { EMBED_CONTEXT_PARAM, EMBED_CONTEXT_TTL_SEC, EMBED_MESSAGES, EMBED_PLACEMENTS, type EmbedContext, type EmbedEntry, type EmbedMessage, type EmbedPlacement, type ExternalScreen } from './embeds.js';
16
+ export { type ExternalFunction, FUNCTION_HOOK_LABELS, FUNCTION_HOOKS, functionEventLabel, functionEventOf, type FunctionHook, type FunctionOnError, type FunctionRequest, type PublishCheckRequest, type PublishCheckResponse, type SaveCheckRequest, type SaveCheckResponse } from './functions.js';
17
+ export { parseWebhookEvent, type Webhook, WEBHOOK_ACTION_LABELS, type WebhookBody, WEBHOOK_ACTIONS, type WebhookAction, type WebhookEvent, webhookEventLabel, webhookEventOf, type WebhookKind } from './webhooks.js';
18
+ export { type SavedView, VIEW_ACTIONS, type ViewAction, type ViewDefinition } from './views.js';
19
+ export { canManageSettings, isSettingsTarget, managedAreasOf, SETTINGS_AREA_LABELS, SETTINGS_AREAS, type SettingsArea, settingsTarget } from './settings.js';
@@ -0,0 +1,6 @@
1
+ /** 公開の状態 */
2
+ export declare const STATUS: {
3
+ readonly draft: "下書き";
4
+ readonly review: "レビュー待ち";
5
+ readonly published: "公開済み";
6
+ };
@@ -0,0 +1,144 @@
1
+ import type { FieldRule } from './fieldRules.js';
2
+ import type { TargetMessages } from './errorLabels.js';
3
+ /** 導入先が有効にするモジュール(キーはモジュールの id、値はモジュールの設定値) */
4
+ export type ModuleSettingsInput = Readonly<Record<string, Readonly<Record<string, unknown>>>>;
5
+ /** 拡張機能が持つフィールド(type はコンテンツタイプの id、key はフィールドのキー) */
6
+ export type FieldRef = Readonly<{
7
+ type: string;
8
+ key: string;
9
+ }>;
10
+ /** 拡張機能が追加するコンテンツタイプとフィールド(types は型の id、fields はほかの型へ追加するフィールド) */
11
+ export type ContentTypePoint = Readonly<{
12
+ types?: readonly string[];
13
+ fields?: readonly FieldRef[];
14
+ }>;
15
+ /** 権限の対象(id は役割の表の識別子) */
16
+ export type PermissionTarget = Readonly<{
17
+ id: string;
18
+ label: string;
19
+ }>;
20
+ /** 拡張機能が必要とする外部の接続(接続の状態はサーバーの側の connections で判定) */
21
+ export type ConnectionPoint = Readonly<{
22
+ id: string;
23
+ label: string;
24
+ }>;
25
+ /** 設定のページの項目(key は設定値のキー、kind は入力の種類) */
26
+ export type SettingField = Readonly<{
27
+ key: string;
28
+ label: string;
29
+ kind: 'number' | 'text' | 'boolean';
30
+ min?: number;
31
+ unit?: string;
32
+ }>;
33
+ /** 設定値から作成する値(メソッドの形で引数を双変にし、ModuleManifest<unknown> の一覧に入れられるように) */
34
+ type FromSettings<S, T> = {
35
+ make(settings: S): T;
36
+ }['make'];
37
+ /** モジュールの共通の定義(S はモジュールの設定値) */
38
+ export type ModuleManifest<S = Readonly<Record<string, never>>> = Readonly<{
39
+ id: string;
40
+ label: string;
41
+ /** 拡張機能の画面に表示する説明(1文) */
42
+ description?: string;
43
+ /** エラーの文と操作の履歴の対象(キーは対象の id、値は表示名) */
44
+ targets?: Readonly<Record<string, string>>;
45
+ /** 対象ごとのエラーの文(自分のものだけの操作・結び付くエントリーがないアカウント、対象の型が設定値のモジュールは設定値から作成) */
46
+ messages?: TargetMessages | FromSettings<S, TargetMessages>;
47
+ /** 導入先の指定・画面で保存した値からモジュールの設定値(不正な値は例外) */
48
+ settings: (input: Readonly<Record<string, unknown>>) => S;
49
+ /** コンテンツタイプの口(対象の型が設定値のモジュールは設定値から作成) */
50
+ contentTypes?: ContentTypePoint | FromSettings<S, ContentTypePoint>;
51
+ /** 権限の対象の口 */
52
+ permissions?: readonly PermissionTarget[];
53
+ /** 必要な外部の接続 */
54
+ connections?: readonly ConnectionPoint[];
55
+ /** 設定のページで編集できる項目(画面で保存した値は導入先の指定より優先) */
56
+ settingFields?: readonly SettingField[];
57
+ /** フィールドの宣言(設定値から作成、例: 種類で決まる名義) */
58
+ fieldRules?(settings: S): readonly FieldRule[];
59
+ /** 拡張機能が送る Webhook の出来事(キーは出来事の名前 <対象>.<操作>、値は表示名、設定の「連携」で選択) */
60
+ webhookEvents?: Readonly<Record<string, string>>;
61
+ }>;
62
+ /** 拡張機能の宣言(組み立てたモジュールの about、拡張機能の画面と口の判定に使用) */
63
+ export type ModuleAbout = Readonly<{
64
+ description: string;
65
+ contentTypes: Required<ContentTypePoint>;
66
+ permissions: readonly PermissionTarget[];
67
+ connections: readonly ConnectionPoint[];
68
+ settingFields: readonly SettingField[];
69
+ }>;
70
+ /** 各側の create の引数(site は導入先の設定値) */
71
+ export type ModuleContext<S> = Readonly<{
72
+ settings: S;
73
+ site: Readonly<{
74
+ id: string;
75
+ name: string;
76
+ origin: string;
77
+ timeZone: string;
78
+ }>;
79
+ }>;
80
+ /** 各側のモジュール(P は側ごとの内容、create は組み立ての時点で1回) */
81
+ export type ModuleSide<S, P> = Readonly<{
82
+ manifest: ModuleManifest<S>;
83
+ create(ctx: ModuleContext<S>): P;
84
+ }>;
85
+ /** 組み立てたモジュールの共通の部分(fieldRules・messages は組み立ての時点の設定値で作成) */
86
+ export type ModuleBase = Readonly<{
87
+ id: string;
88
+ label: string;
89
+ targets: Readonly<Record<string, string>>;
90
+ about: ModuleAbout;
91
+ fieldRules: readonly FieldRule[];
92
+ messages: TargetMessages;
93
+ webhookEvents: Readonly<Record<string, string>>;
94
+ }>;
95
+ /** 組み立てたモジュール(共通の定義と、側ごとの内容) */
96
+ export type ModuleInstance<P> = ModuleBase & P;
97
+ /** manifest から組み立てたモジュールの共通の部分(コアに組み込みのモジュールも使用、settings はモジュールの設定値) */
98
+ export declare function moduleBaseOf<S>(manifest: ModuleManifest<S>, settings?: S): ModuleBase;
99
+ /** MCP の側から CMS の API の呼び出し(パスと JSON の本文、応答は JSON) */
100
+ export type CallApi = (method: string, path: string, body?: unknown) => Promise<{
101
+ status: number;
102
+ data: unknown;
103
+ }>;
104
+ /** MCP のツール */
105
+ export type McpTool = {
106
+ name: string;
107
+ description: string;
108
+ inputSchema: Record<string, unknown>;
109
+ /** クライアント向けの付加情報(ChatGPT の openai/fileParams など) */
110
+ _meta?: Record<string, unknown>;
111
+ run: (args: Record<string, unknown>, api: CallApi) => Promise<{
112
+ status: number;
113
+ data: unknown;
114
+ }>;
115
+ };
116
+ /** MCP の側の内容 */
117
+ export type McpParts = Readonly<{
118
+ tools?: readonly McpTool[];
119
+ }>;
120
+ /** MCP の側の引数(本文の Markdown への変換は CMS の API の /api/body/markdown) */
121
+ export type McpModuleContext<S> = ModuleContext<S>;
122
+ /** MCP の側のモジュール */
123
+ export type McpModule<S = unknown> = Readonly<{
124
+ manifest: ModuleManifest<S>;
125
+ create(ctx: McpModuleContext<S>): McpParts;
126
+ }>;
127
+ /**
128
+ * 登録した側のモジュールを導入先の設定で組み立て
129
+ * - 登録は導入先の設定 modules にある id だけ(ない id・重複は例外)
130
+ * - complete: 設定にある id がすべて登録されているか(サーバーの側、DB と migration を持つため、builtins は組み込みのモジュールの id で設定値だけを持つ)
131
+ */
132
+ export declare function createModules<P>(registered: readonly ModuleSide<unknown, P>[], config: Readonly<{
133
+ settings: ModuleContext<unknown>['site'];
134
+ modules?: ModuleSettingsInput;
135
+ }>, options?: Readonly<{
136
+ complete?: boolean;
137
+ builtins?: readonly string[];
138
+ }>): ModuleInstance<P>[];
139
+ /** モジュールの対象の表示名をまとめた表(キーの重複は例外) */
140
+ export declare function moduleTargetsOf(modules: readonly Readonly<{
141
+ id: string;
142
+ targets: Readonly<Record<string, string>>;
143
+ }>[], core: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
144
+ export {};
@@ -0,0 +1,6 @@
1
+ /** サーバーが受け持つパスの頭(API・画像・プレビュー・ログインの入り口) */
2
+ export declare const SERVER_PATHS: readonly ["/api", "/media", "/preview", "/auth"];
3
+ /** 運営者の経路とヘルスチェックのパス(Access の内側で転送、サーバーの ops.ts が鍵で保護) */
4
+ export declare const OPS_PATHS: readonly ["/healthz", "/ops"];
5
+ /** サーバーが受け持つパスか(パスの頭と一致、または頭の下、運営者の経路を含む) */
6
+ export declare const isServerPath: (pathname: string) => boolean;
@@ -0,0 +1,4 @@
1
+ /** 追加の依頼を記事に付ける値 */
2
+ export declare const pendingValue: (requestId: string) => string;
3
+ /** 記事の値のうち、承認待ちの依頼の ID */
4
+ export declare const pendingIds: (values: readonly string[]) => string[];
@@ -0,0 +1,69 @@
1
+ import type { User } from './roles.js';
2
+ /** 操作 */
3
+ export declare const ACTIONS: readonly ["read", "create", "update", "publish", "delete"];
4
+ /** 操作 */
5
+ export type Action = (typeof ACTIONS)[number];
6
+ /** 段階 */
7
+ export declare const LEVELS: readonly ["all", "own", "approval", "none"];
8
+ /** 段階 */
9
+ export type Level = (typeof LEVELS)[number];
10
+ /** 操作ごとに選択できる段階(作成に持ち主はなく、承認は作成と公開だけ) */
11
+ export declare const ACTION_LEVELS: Readonly<Record<Action, readonly Level[]>>;
12
+ /** 権限の表(キーは対象の id、'*' は表にない対象の既定、操作がなければ不可) */
13
+ export type Permissions = Readonly<Record<string, Readonly<Partial<Record<Action, Level>>>>>;
14
+ /** 表にない対象の既定のキー */
15
+ export declare const ANY_TARGET = "*";
16
+ type Holder = Pick<User, 'permissions'>;
17
+ /** 対象と操作の段階 */
18
+ export declare const levelOf: (user: Holder, target: string, action: Action) => Level;
19
+ /** 操作できるか(owned は自分が持ち主の行か、承認が必要は不可) */
20
+ export declare const allows: (user: Holder, target: string, action: Action, owned?: boolean) => boolean;
21
+ /** 行の値(持ち主か・公開中か) */
22
+ export type RowAccess = Readonly<{
23
+ owned: boolean;
24
+ published: boolean;
25
+ }>;
26
+ /** 行を閲覧できるか */
27
+ export declare const canReadRow: (user: Holder, target: string, row: RowAccess) => boolean;
28
+ /** 行を変更・削除できるか(公開中の行は公開の権限も必要) */
29
+ export declare const canChangeRow: (user: Holder, target: string, action: "update" | "delete", row: RowAccess) => boolean;
30
+ /**
31
+ * 権限の表の検査(不正な値は理由の文の配列)
32
+ * - targets: 対象の id('*' は常に可)
33
+ */
34
+ export declare function checkPermissions(input: unknown, targets: readonly string[]): {
35
+ value: Permissions;
36
+ } | {
37
+ problems: string[];
38
+ };
39
+ /** アカウントの結び付き(設定): type はアカウントが結び付くコンテンツタイプ、owners は対象ごとに持ち主を表す参照の項目の key */
40
+ export type AccountLink = Readonly<{
41
+ type: string | null;
42
+ owners: Readonly<Record<string, string>>;
43
+ }>;
44
+ type Owner = Pick<User, 'id' | 'entryId' | 'link'>;
45
+ /**
46
+ * 行の持ち主か
47
+ * - 持ち主の項目がある対象: 項目の値に、アカウントが結び付くエントリーを含む
48
+ * - 結び付くコンテンツタイプの行: 結び付くエントリーそのもの
49
+ * - ほかの対象: 作成したアカウント(行の created_by、アカウントの ID)
50
+ */
51
+ export declare const ownsRow: (user: Owner, target: string, row: Readonly<Record<string, unknown>>) => boolean;
52
+ type Subject = Pick<User, 'permissions' | 'id' | 'entryId' | 'link'>;
53
+ /** 権限の判定で使用する行の値(行のまま、持ち主の項目を含む) */
54
+ export type ContentAccess = Readonly<Record<string, unknown>> & Readonly<{
55
+ status: string;
56
+ }>;
57
+ /** 行の持ち主か(ownsRow、持ち主のいない行は公開が全体で可のアカウント) */
58
+ export declare const ownsContent: (user: Subject, target: string, a: ContentAccess) => boolean;
59
+ /** 行を編集できるか(公開中の行は公開の権限も必要、サーバーは公開中の行の拒否を別のエラーで返す) */
60
+ export declare const canEditContent: (user: Subject, target: string, a: ContentAccess) => boolean;
61
+ /** 行を閲覧できるか */
62
+ export declare const canReadContent: (user: Subject, target: string, a: ContentAccess) => boolean;
63
+ /** 行を公開・予約・差し戻し・非公開にできるか(本文を変更しない操作のため、編集の権限は不要) */
64
+ export declare const canPublishContent: (user: Subject, target: string, a: ContentAccess) => boolean;
65
+ /** 行をレビューに提出できるか(編集でき、公開が承認が必要以上) */
66
+ export declare const canSubmitContent: (user: Subject, target: string, a: ContentAccess) => boolean;
67
+ /** 行を削除できるか */
68
+ export declare const canDeleteContent: (user: Subject, target: string, a: ContentAccess) => boolean;
69
+ export {};
@@ -0,0 +1,35 @@
1
+ import { type AccountLink, type Permissions } from './permissions.js';
2
+ /** 管理者のロールの ID */
3
+ export declare const ADMIN_ROLE = "admin";
4
+ /** ライターのロールの ID(新しいアカウントの既定・MCP の権限) */
5
+ export declare const WRITER_ROLE = "writer";
6
+ /** 管理者の権限の表(すべての対象・操作が可、DB の値より優先) */
7
+ export declare const ADMIN_PERMISSIONS: Permissions;
8
+ /** ロールの権限の表(管理者のロールは固定の表、ほかは保存した表) */
9
+ export declare const rolePermissionsOf: (roleId: string, stored: Permissions) => Permissions;
10
+ /** 削除できないロールの ID */
11
+ export declare const SYSTEM_ROLES: readonly string[];
12
+ /** ロール(API /api/roles の行) */
13
+ export type Role = Readonly<{
14
+ id: string;
15
+ label: string;
16
+ permissions: Permissions;
17
+ }>;
18
+ /**
19
+ * ログイン中のアカウント
20
+ * - id: アカウントの ID(操作の履歴・版の作成者・担当者などに保存する値、メールアドレスは表 accounts だけ)
21
+ * - role: ロールの ID、entryId: 結び付くエントリー(なしは null)、link: 結び付きの設定
22
+ * - token: MCP のログインの方式(MCP からの操作だけ)
23
+ */
24
+ export type User = Readonly<{
25
+ id: string;
26
+ email: string;
27
+ role: string;
28
+ roleLabel: string;
29
+ permissions: Permissions;
30
+ entryId: string | null;
31
+ link: AccountLink;
32
+ token?: string;
33
+ }>;
34
+ /** 設定を扱える(管理者のロールの)アカウントか */
35
+ export declare const isAdmin: (user: Pick<User, "role">) => boolean;