@notion-headless-cms/core 0.3.21 → 0.3.22

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.
@@ -1,2 +1,25 @@
1
- import { i as memoryCache, n as MemoryDocumentOptions, r as MemoryImageOptions, t as MemoryCacheOptions } from "../memory-BT9rLPr1.mjs";
2
- export { MemoryCacheOptions, MemoryDocumentOptions, MemoryImageOptions, memoryCache };
1
+ import { t as CacheAdapter } from "../cache-DS81aOcC.mjs";
2
+
3
+ //#region src/cache/memory.d.ts
4
+ interface MemoryDocumentOptions {
5
+ /** アイテム保持上限。未指定時は上限なし。超過時は LRU で古いものから削除。 */
6
+ maxItems?: number;
7
+ }
8
+ interface MemoryImageOptions {
9
+ /** エントリ保持上限。未指定時は上限なし。超過時は LRU で古いものから削除。 */
10
+ maxItems?: number;
11
+ /** 合計保持サイズ上限(バイト)。未指定時は上限なし。超過時は LRU で古いものから削除。 */
12
+ maxSizeBytes?: number;
13
+ }
14
+ interface MemoryCacheOptions extends MemoryDocumentOptions, MemoryImageOptions {}
15
+ /**
16
+ * インメモリのキャッシュアダプタ。document + image 両方を担当する。
17
+ * プロセス再起動でクリアされるため、ローカル開発・SSG ビルド・テスト用途。
18
+ *
19
+ * @example
20
+ * cache: [memoryCache({ maxItems: 1000 })]
21
+ */
22
+ declare function memoryCache(options?: MemoryCacheOptions): CacheAdapter;
23
+ //#endregion
24
+ export { MemoryCacheOptions, MemoryDocumentOptions, MemoryImageOptions, memoryCache };
25
+ //# sourceMappingURL=memory.d.mts.map
@@ -133,26 +133,5 @@ interface CacheAdapter {
133
133
  img?: ImageCacheOps;
134
134
  }
135
135
  //#endregion
136
- //#region src/cache/memory.d.ts
137
- interface MemoryDocumentOptions {
138
- /** アイテム保持上限。未指定時は上限なし。超過時は LRU で古いものから削除。 */
139
- maxItems?: number;
140
- }
141
- interface MemoryImageOptions {
142
- /** エントリ保持上限。未指定時は上限なし。超過時は LRU で古いものから削除。 */
143
- maxItems?: number;
144
- /** 合計保持サイズ上限(バイト)。未指定時は上限なし。超過時は LRU で古いものから削除。 */
145
- maxSizeBytes?: number;
146
- }
147
- interface MemoryCacheOptions extends MemoryDocumentOptions, MemoryImageOptions {}
148
- /**
149
- * インメモリのキャッシュアダプタ。document + image 両方を担当する。
150
- * プロセス再起動でクリアされるため、ローカル開発・SSG ビルド・テスト用途。
151
- *
152
- * @example
153
- * cache: [memoryCache({ maxItems: 1000 })]
154
- */
155
- declare function memoryCache(options?: MemoryCacheOptions): CacheAdapter;
156
- //#endregion
157
- export { CacheAdapter as a, DataSource as c, PropertyDef as d, PropertyMap as f, memoryCache as i, InvalidateKind as l, MemoryDocumentOptions as n, DocumentCacheOps as o, WebhookConfig as p, MemoryImageOptions as r, ImageCacheOps as s, MemoryCacheOptions as t, InvalidateScope as u };
158
- //# sourceMappingURL=memory-BT9rLPr1.d.mts.map
136
+ export { InvalidateKind as a, PropertyMap as c, DataSource as i, WebhookConfig as l, DocumentCacheOps as n, InvalidateScope as o, ImageCacheOps as r, PropertyDef as s, CacheAdapter as t };
137
+ //# sourceMappingURL=cache-DS81aOcC.d.mts.map
@@ -0,0 +1,150 @@
1
+ import { t as BaseContentItem } from "./content-DwsfWZao.mjs";
2
+ import { i as DataSource, t as CacheAdapter } from "./cache-DS81aOcC.mjs";
3
+ import { i as CMSHooks, r as Logger, t as CMSPlugin } from "./plugin-B795Ok3X.mjs";
4
+
5
+ //#region src/types/sources.d.ts
6
+ /**
7
+ * CMS データソースアダプターのインターフェース。
8
+ * 各アダプターパッケージ (`@notion-headless-cms/notion-source` 等) が実装し、
9
+ * `createClient({ sources: { ... } })` に渡される。
10
+ */
11
+ interface CMSAdapter<C extends CollectionsConfig = CollectionsConfig> {
12
+ readonly collections: C;
13
+ }
14
+ /**
15
+ * アダプターパッケージが宣言マージで拡張する空インターフェース。
16
+ * import するだけでキーが補完候補に現れる (Fastify プラグインと同じパターン)。
17
+ *
18
+ * @example
19
+ * declare module "@notion-headless-cms/core" {
20
+ * interface CMSSources {
21
+ * notion?: CMSAdapter;
22
+ * }
23
+ * }
24
+ */
25
+ interface CMSSources {}
26
+ type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
27
+ /** 全ソースの collections を交差型でマージする。 */
28
+ type MergeSourceCollections<S extends CMSSources> = UnionToIntersection<{ [K in keyof S]: S[K] extends CMSAdapter<infer C> ? C : never }[keyof S]>;
29
+ //#endregion
30
+ //#region src/types/config.d.ts
31
+ /** `Logger` の出力を絞り込むログレベル。指定したレベル未満のログを抑制する。 */
32
+ type LogLevel = "debug" | "info" | "warn" | "error";
33
+ /**
34
+ * renderer プラグインの不透明型。
35
+ * core は unified / remark / rehype に依存せず、このリストをそのまま renderer に渡すだけ。
36
+ */
37
+ type RendererPluginList = unknown[];
38
+ /**
39
+ * render() オプション。core は renderer の実装を知らず、この型だけを扱う。
40
+ * @notion-headless-cms/markdown-html の renderMarkdown() はこのシグネチャと構造的に互換。
41
+ */
42
+ interface RenderOptions {
43
+ imageProxyBase?: string;
44
+ cacheImage?: (url: string) => Promise<string>;
45
+ remarkPlugins?: RendererPluginList;
46
+ rehypePlugins?: RendererPluginList;
47
+ }
48
+ /** カスタムレンダラー関数の型。デフォルトは @notion-headless-cms/markdown-html の renderMarkdown。 */
49
+ type RendererFn = (markdown: string, opts?: RenderOptions) => Promise<string>;
50
+ /** レンダリング・コンテンツ処理設定。 */
51
+ interface ContentConfig {
52
+ /** 追加する remark プラグイン。 */
53
+ remarkPlugins?: RendererPluginList;
54
+ /** 追加する rehype プラグイン。 */
55
+ rehypePlugins?: RendererPluginList;
56
+ }
57
+ /** SWR(Stale-While-Revalidate)設定。 */
58
+ interface SWRConfig {
59
+ /** SWR の有効期間 (ミリ秒)。未設定時は TTL なし(失効まで stale を返す)。 */
60
+ ttlMs?: number;
61
+ }
62
+ /** レートリミット・リトライ設定。 */
63
+ interface RateLimiterConfig {
64
+ /** 同時実行数の上限。デフォルト: 3 */
65
+ maxConcurrent?: number;
66
+ /** リトライ対象の HTTP ステータスコード。デフォルト: [429, 502, 503] */
67
+ retryOn?: number[];
68
+ /** 最大リトライ回数。デフォルト: 4 */
69
+ maxRetries?: number;
70
+ /** リトライ時の基準待機時間(ミリ秒)。デフォルト: 1000 */
71
+ baseDelayMs?: number;
72
+ }
73
+ /**
74
+ * コレクション 1 件の定義。CLI が生成する `nhc.ts` から `createClient` に渡される。
75
+ *
76
+ * `source` は notion-orm 等の DataSource 実装。
77
+ * `slugField` / `statusField` は TS フィールド名 (DataSource の `properties` キーと一致)。
78
+ */
79
+ interface CollectionDef<T extends BaseContentItem = BaseContentItem> {
80
+ /** Notion etc. のデータソース実装。 */
81
+ source: DataSource<T>;
82
+ /** slug として使う TS フィールド名 (必須)。`source.properties[slugField]` で Notion プロパティ名を解決する。 */
83
+ slugField: string;
84
+ /** ステータスとして使う TS フィールド名。 */
85
+ statusField?: string;
86
+ /** 公開扱いするステータス値。`list()` のデフォルト絞り込みに使う。 */
87
+ publishedStatuses?: readonly string[];
88
+ /** アクセス許可するステータス値。`get()` の閲覧可否判定に使う。 */
89
+ accessibleStatuses?: readonly string[];
90
+ /** コレクション固有のライフサイクルフック。グローバル hooks の後に実行される。 */
91
+ hooks?: CMSHooks<T>;
92
+ }
93
+ /**
94
+ * `createClient({ collections })` の map 型。
95
+ * キーがコレクション名、値が `CollectionDef<T>`。
96
+ */
97
+ type CollectionsConfig = Record<string, CollectionDef<BaseContentItem>>;
98
+ /** `CollectionsConfig` から各 T を抽出するユーティリティ型。 */
99
+ type InferCollectionItem<C> = C extends CollectionDef<infer T> ? T : BaseContentItem;
100
+ /**
101
+ * `createClient()` の入力。
102
+ *
103
+ * @example
104
+ * import { createClient, nodePreset } from "@notion-headless-cms/core";
105
+ * import { notionSource } from "@notion-headless-cms/notion-source";
106
+ * import { schema } from "./generated/nhc.schema";
107
+ *
108
+ * const cms = createClient({
109
+ * sources: { notion: notionSource({ schema, token: process.env.NOTION_TOKEN! }) },
110
+ * ...nodePreset(),
111
+ * });
112
+ */
113
+ interface CreateClientOptions<S extends CMSSources = CMSSources> {
114
+ /** データソースアダプター (`@notion-headless-cms/notion-source` 等) のマップ。 */
115
+ sources?: S;
116
+ /**
117
+ * キャッシュアダプタ (配列)。未指定時はキャッシュなし。
118
+ * - `memoryCache()` のように doc + image 両方を担当するもの
119
+ * - `r2Cache()` (image のみ)、`kvCache()` (doc のみ) のように片側のみ担当するもの
120
+ * - 複数 adapter を配列で組み合わせると、各 adapter の `handles` で振り分けられる
121
+ */
122
+ cache?: readonly CacheAdapter[];
123
+ /** SWR(Stale-While-Revalidate)設定。 */
124
+ swr?: SWRConfig;
125
+ /**
126
+ * Markdown→HTML レンダラー。
127
+ * 省略時は `@notion-headless-cms/markdown-html` の `renderMarkdown` を動的 import で使用する。
128
+ * カスタム実装も `RendererFn` 型を満たせば使用可能。
129
+ */
130
+ renderer?: RendererFn;
131
+ /** 画像プロキシのベース URL。デフォルト `/api/images`。 */
132
+ imageProxyBase?: string;
133
+ /** Cloudflare Workers の `waitUntil` に相当する非同期処理の登録関数。 */
134
+ waitUntil?: (p: Promise<unknown>) => void;
135
+ /** ライフサイクルフック (全コレクション共通)。 */
136
+ hooks?: CMSHooks<BaseContentItem>;
137
+ /** プラグイン配列。 */
138
+ plugins?: CMSPlugin<BaseContentItem>[];
139
+ /** ロガー。 */
140
+ logger?: Logger;
141
+ /** ログレベルの下限。指定したレベル未満のログを内部で抑制する。 */
142
+ logLevel?: LogLevel;
143
+ /** レートリミット・リトライ設定。 */
144
+ rateLimiter?: RateLimiterConfig;
145
+ /** レンダリング・コンテンツ処理設定。 */
146
+ content?: ContentConfig;
147
+ }
148
+ //#endregion
149
+ export { InferCollectionItem as a, RenderOptions as c, SWRConfig as d, CMSAdapter as f, CreateClientOptions as i, RendererFn as l, MergeSourceCollections as m, CollectionsConfig as n, LogLevel as o, CMSSources as p, ContentConfig as r, RateLimiterConfig as s, CollectionDef as t, RendererPluginList as u };
150
+ //# sourceMappingURL=config-D4JQ_pmq.d.mts.map
@@ -51,16 +51,27 @@ declare class CMSError extends Error {
51
51
  readonly code: CMSErrorCode;
52
52
  readonly cause?: unknown;
53
53
  readonly context: CMSErrorContext;
54
+ /** エラーを解消するための次のアクション(表示用)。 */
55
+ readonly nextSteps?: readonly string[];
56
+ /** 詳細ドキュメントへの URL(表示用)。 */
57
+ readonly docsUrl?: string;
54
58
  constructor(params: {
55
59
  code: CMSErrorCode;
56
60
  message: string;
57
61
  cause?: unknown;
58
62
  context: CMSErrorContext;
63
+ nextSteps?: readonly string[];
64
+ docsUrl?: string;
59
65
  });
60
66
  /** エラーコードが指定した値と一致するか判定する。 */
61
67
  is(code: CMSErrorCode): boolean;
62
68
  /** エラーコードが指定した名前空間に属するか判定する(例: `"source/"`)。 */
63
69
  inNamespace(namespace: string): boolean;
70
+ /**
71
+ * nextSteps と docsUrl を含む人間向けの詳細メッセージを返す。
72
+ * エラーダイアログ・ログ出力時に使う。
73
+ */
74
+ format(): string;
64
75
  }
65
76
  declare function isCMSError(error: unknown): error is CMSError;
66
77
  /** エラーコードが特定の名前空間に属するかを判定する(例: "source/")。 */
@@ -81,4 +92,4 @@ declare function matchCMSError<R>(error: unknown, handlers: Partial<Record<CMSEr
81
92
  }): R | undefined;
82
93
  //#endregion
83
94
  export { isCMSError as a, CMSErrorContext as i, CMSError as n, isCMSErrorInNamespace as o, CMSErrorCode as r, matchCMSError as s, BuiltInCMSErrorCode as t };
84
- //# sourceMappingURL=errors-CC_x98vG.d.mts.map
95
+ //# sourceMappingURL=errors-DTt9ii0i.d.mts.map
package/dist/errors.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as isCMSError, i as CMSErrorContext, n as CMSError, o as isCMSErrorInNamespace, r as CMSErrorCode, s as matchCMSError, t as BuiltInCMSErrorCode } from "./errors-CC_x98vG.mjs";
1
+ import { a as isCMSError, i as CMSErrorContext, n as CMSError, o as isCMSErrorInNamespace, r as CMSErrorCode, s as matchCMSError, t as BuiltInCMSErrorCode } from "./errors-DTt9ii0i.mjs";
2
2
  export { BuiltInCMSErrorCode, CMSError, CMSErrorCode, CMSErrorContext, isCMSError, isCMSErrorInNamespace, matchCMSError };
package/dist/errors.mjs CHANGED
@@ -3,12 +3,18 @@ var CMSError = class extends Error {
3
3
  code;
4
4
  cause;
5
5
  context;
6
+ /** エラーを解消するための次のアクション(表示用)。 */
7
+ nextSteps;
8
+ /** 詳細ドキュメントへの URL(表示用)。 */
9
+ docsUrl;
6
10
  constructor(params) {
7
11
  super(params.message, { cause: params.cause });
8
12
  this.name = "CMSError";
9
13
  this.code = params.code;
10
14
  this.cause = params.cause;
11
15
  this.context = params.context;
16
+ this.nextSteps = params.nextSteps;
17
+ this.docsUrl = params.docsUrl;
12
18
  }
13
19
  /** エラーコードが指定した値と一致するか判定する。 */
14
20
  is(code) {
@@ -18,6 +24,19 @@ var CMSError = class extends Error {
18
24
  inNamespace(namespace) {
19
25
  return this.code.startsWith(namespace);
20
26
  }
27
+ /**
28
+ * nextSteps と docsUrl を含む人間向けの詳細メッセージを返す。
29
+ * エラーダイアログ・ログ出力時に使う。
30
+ */
31
+ format() {
32
+ const lines = [this.message];
33
+ if (this.nextSteps?.length) {
34
+ lines.push("\n次にやること:");
35
+ for (const step of this.nextSteps) lines.push(` - ${step}`);
36
+ }
37
+ if (this.docsUrl) lines.push(`\n詳細: ${this.docsUrl}`);
38
+ return lines.join("\n");
39
+ }
21
40
  };
22
41
  function isCMSError(error) {
23
42
  return error instanceof CMSError;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * ライブラリ組み込みの CMS エラーコード。\n *\n * | コード | 発生条件 |\n * |---|---|\n * | `core/config_invalid` | 設定不備(token 未設定など) |\n * | `core/schema_invalid` | schema/mapping の型不整合 |\n * | `core/notion_orm_missing` | `@notion-headless-cms/notion-orm` の動的ロード失敗 |\n * | `core/sort_unsupported_type` | ソートキーの値型が string / number でない |\n * | `webhook/signature_invalid` | Webhook 署名検証失敗 |\n * | `webhook/payload_invalid` | Webhook ペイロード形式不正 |\n * | `webhook/unknown_collection` | Webhook の対象コレクションが未知 |\n * | `webhook/not_implemented` | DataSource が parseWebhook を実装していない |\n * | `source/fetch_items_failed` | `DataSource.list()` 失敗 |\n * | `source/fetch_item_failed` | `DataSource.findByProp()` 失敗 |\n * | `source/load_markdown_failed` | `DataSource.loadMarkdown()` 失敗 |\n * | `source/load_blocks_failed` | `DataSource.loadBlocks()` 失敗 |\n * | `cache/io_failed` | document / image キャッシュの I/O 失敗 |\n * | `cache/image_fetch_failed` | Notion 画像の HTTP 取得失敗 |\n * | `cache/image_invalid_content_type` | 画像レスポンスの Content-Type が不正 |\n * | `renderer/failed` | Markdown → HTML 変換失敗 |\n * | `swr/item_check_failed` | SWR バックグラウンドのアイテム差分チェック失敗 |\n * | `swr/list_check_failed` | SWR バックグラウンドのリスト差分チェック失敗 |\n * | `swr/content_rebuild_failed` | SWR バックグラウンドの本文再生成失敗 |\n * | `cli/config_invalid` | `nhc.config.ts` の内容不整合 |\n * | `cli/config_load_failed` | 設定ファイルの読み込み / 評価失敗 |\n * | `cli/schema_invalid` | CLI が受け取ったスキーマ / マッピング不整合 |\n * | `cli/generate_failed` | `nhc generate` の処理失敗 |\n * | `cli/init_failed` | `nhc init` の処理失敗 |\n * | `cli/notion_api_failed` | CLI が Notion API を呼び出す際の失敗 |\n * | `cli/env_file_not_found` | `--env-file` で指定したファイルが存在しない |\n *\n * サードパーティアダプタが独自コードを追加したい場合は `CMSErrorCode` を参照。\n */\nexport type BuiltInCMSErrorCode =\n | \"core/config_invalid\"\n | \"core/schema_invalid\"\n | \"core/notion_orm_missing\"\n | \"core/sort_unsupported_type\"\n | \"webhook/signature_invalid\"\n | \"webhook/payload_invalid\"\n | \"webhook/unknown_collection\"\n | \"webhook/not_implemented\"\n | \"source/fetch_items_failed\"\n | \"source/fetch_item_failed\"\n | \"source/load_markdown_failed\"\n | \"source/load_blocks_failed\"\n | \"cache/io_failed\"\n | \"cache/image_fetch_failed\"\n | \"cache/image_invalid_content_type\"\n | \"renderer/failed\"\n | \"swr/item_check_failed\"\n | \"swr/list_check_failed\"\n | \"swr/content_rebuild_failed\"\n | \"cli/config_invalid\"\n | \"cli/config_load_failed\"\n | \"cli/schema_invalid\"\n | \"cli/generate_failed\"\n | \"cli/init_failed\"\n | \"cli/notion_api_failed\"\n | \"cli/env_file_not_found\";\n\n/**\n * CMS エラーコード。\n * `BuiltInCMSErrorCode` のリテラル補完を維持しつつ、\n * サードパーティアダプタが独自コードを定義できるよう `string & {}` で拡張可能にする。\n */\nexport type CMSErrorCode = BuiltInCMSErrorCode | (string & {});\n\nexport interface CMSErrorContext {\n operation: string;\n slug?: string;\n dataSourceId?: string;\n pageId?: string;\n [key: string]: string | number | boolean | null | undefined;\n}\n\nexport class CMSError extends Error {\n readonly code: CMSErrorCode;\n override readonly cause?: unknown;\n readonly context: CMSErrorContext;\n\n constructor(params: {\n code: CMSErrorCode;\n message: string;\n cause?: unknown;\n context: CMSErrorContext;\n }) {\n super(params.message, { cause: params.cause });\n this.name = \"CMSError\";\n this.code = params.code;\n this.cause = params.cause;\n this.context = params.context;\n }\n\n /** エラーコードが指定した値と一致するか判定する。 */\n is(code: CMSErrorCode): boolean {\n return this.code === code;\n }\n\n /** エラーコードが指定した名前空間に属するか判定する(例: `\"source/\"`)。 */\n inNamespace(namespace: string): boolean {\n return this.code.startsWith(namespace);\n }\n}\n\nexport function isCMSError(error: unknown): error is CMSError {\n return error instanceof CMSError;\n}\n\n/** エラーコードが特定の名前空間に属するかを判定する(例: \"source/\")。 */\nexport function isCMSErrorInNamespace(\n error: unknown,\n namespace: string,\n): error is CMSError {\n return isCMSError(error) && error.code.startsWith(namespace);\n}\n\ntype CMSErrorHandler<R> = (err: CMSError) => R;\n\n/**\n * `CMSError` を switch 式のように分岐して処理するユーティリティ。\n * `_` キーはフォールバック(CMSError 以外 or 未マッチ時)に使われる。\n *\n * @example\n * matchCMSError(err, {\n * \"source/fetch_items_failed\": (e) => handleFetchError(e),\n * _: (e) => { throw e; },\n * });\n */\nexport function matchCMSError<R>(\n error: unknown,\n handlers: Partial<Record<CMSErrorCode, CMSErrorHandler<R>>> & {\n _?: (err: unknown) => R;\n },\n): R | undefined {\n if (!isCMSError(error)) {\n return handlers._?.(error);\n }\n const handler =\n handlers[error.code as CMSErrorCode] ??\n (handlers._ as CMSErrorHandler<R> | undefined);\n return handler?.(error);\n}\n"],"mappings":";AA6EA,IAAa,WAAb,cAA8B,MAAM;CAClC;CACA;CACA;CAEA,YAAY,QAKT;AACD,QAAM,OAAO,SAAS,EAAE,OAAO,OAAO,OAAO,CAAC;AAC9C,OAAK,OAAO;AACZ,OAAK,OAAO,OAAO;AACnB,OAAK,QAAQ,OAAO;AACpB,OAAK,UAAU,OAAO;;;CAIxB,GAAG,MAA6B;AAC9B,SAAO,KAAK,SAAS;;;CAIvB,YAAY,WAA4B;AACtC,SAAO,KAAK,KAAK,WAAW,UAAU;;;AAI1C,SAAgB,WAAW,OAAmC;AAC5D,QAAO,iBAAiB;;;AAI1B,SAAgB,sBACd,OACA,WACmB;AACnB,QAAO,WAAW,MAAM,IAAI,MAAM,KAAK,WAAW,UAAU;;;;;;;;;;;;AAe9D,SAAgB,cACd,OACA,UAGe;AACf,KAAI,CAAC,WAAW,MAAM,CACpB,QAAO,SAAS,IAAI,MAAM;AAK5B,SAFE,SAAS,MAAM,SACd,SAAS,KACK,MAAM"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * ライブラリ組み込みの CMS エラーコード。\n *\n * | コード | 発生条件 |\n * |---|---|\n * | `core/config_invalid` | 設定不備(token 未設定など) |\n * | `core/schema_invalid` | schema/mapping の型不整合 |\n * | `core/notion_orm_missing` | `@notion-headless-cms/notion-orm` の動的ロード失敗 |\n * | `core/sort_unsupported_type` | ソートキーの値型が string / number でない |\n * | `webhook/signature_invalid` | Webhook 署名検証失敗 |\n * | `webhook/payload_invalid` | Webhook ペイロード形式不正 |\n * | `webhook/unknown_collection` | Webhook の対象コレクションが未知 |\n * | `webhook/not_implemented` | DataSource が parseWebhook を実装していない |\n * | `source/fetch_items_failed` | `DataSource.list()` 失敗 |\n * | `source/fetch_item_failed` | `DataSource.findByProp()` 失敗 |\n * | `source/load_markdown_failed` | `DataSource.loadMarkdown()` 失敗 |\n * | `source/load_blocks_failed` | `DataSource.loadBlocks()` 失敗 |\n * | `cache/io_failed` | document / image キャッシュの I/O 失敗 |\n * | `cache/image_fetch_failed` | Notion 画像の HTTP 取得失敗 |\n * | `cache/image_invalid_content_type` | 画像レスポンスの Content-Type が不正 |\n * | `renderer/failed` | Markdown → HTML 変換失敗 |\n * | `swr/item_check_failed` | SWR バックグラウンドのアイテム差分チェック失敗 |\n * | `swr/list_check_failed` | SWR バックグラウンドのリスト差分チェック失敗 |\n * | `swr/content_rebuild_failed` | SWR バックグラウンドの本文再生成失敗 |\n * | `cli/config_invalid` | `nhc.config.ts` の内容不整合 |\n * | `cli/config_load_failed` | 設定ファイルの読み込み / 評価失敗 |\n * | `cli/schema_invalid` | CLI が受け取ったスキーマ / マッピング不整合 |\n * | `cli/generate_failed` | `nhc generate` の処理失敗 |\n * | `cli/init_failed` | `nhc init` の処理失敗 |\n * | `cli/notion_api_failed` | CLI が Notion API を呼び出す際の失敗 |\n * | `cli/env_file_not_found` | `--env-file` で指定したファイルが存在しない |\n *\n * サードパーティアダプタが独自コードを追加したい場合は `CMSErrorCode` を参照。\n */\nexport type BuiltInCMSErrorCode =\n | \"core/config_invalid\"\n | \"core/schema_invalid\"\n | \"core/notion_orm_missing\"\n | \"core/sort_unsupported_type\"\n | \"webhook/signature_invalid\"\n | \"webhook/payload_invalid\"\n | \"webhook/unknown_collection\"\n | \"webhook/not_implemented\"\n | \"source/fetch_items_failed\"\n | \"source/fetch_item_failed\"\n | \"source/load_markdown_failed\"\n | \"source/load_blocks_failed\"\n | \"cache/io_failed\"\n | \"cache/image_fetch_failed\"\n | \"cache/image_invalid_content_type\"\n | \"renderer/failed\"\n | \"swr/item_check_failed\"\n | \"swr/list_check_failed\"\n | \"swr/content_rebuild_failed\"\n | \"cli/config_invalid\"\n | \"cli/config_load_failed\"\n | \"cli/schema_invalid\"\n | \"cli/generate_failed\"\n | \"cli/init_failed\"\n | \"cli/notion_api_failed\"\n | \"cli/env_file_not_found\";\n\n/**\n * CMS エラーコード。\n * `BuiltInCMSErrorCode` のリテラル補完を維持しつつ、\n * サードパーティアダプタが独自コードを定義できるよう `string & {}` で拡張可能にする。\n */\nexport type CMSErrorCode = BuiltInCMSErrorCode | (string & {});\n\nexport interface CMSErrorContext {\n operation: string;\n slug?: string;\n dataSourceId?: string;\n pageId?: string;\n [key: string]: string | number | boolean | null | undefined;\n}\n\nexport class CMSError extends Error {\n readonly code: CMSErrorCode;\n override readonly cause?: unknown;\n readonly context: CMSErrorContext;\n /** エラーを解消するための次のアクション(表示用)。 */\n readonly nextSteps?: readonly string[];\n /** 詳細ドキュメントへの URL(表示用)。 */\n readonly docsUrl?: string;\n\n constructor(params: {\n code: CMSErrorCode;\n message: string;\n cause?: unknown;\n context: CMSErrorContext;\n nextSteps?: readonly string[];\n docsUrl?: string;\n }) {\n super(params.message, { cause: params.cause });\n this.name = \"CMSError\";\n this.code = params.code;\n this.cause = params.cause;\n this.context = params.context;\n this.nextSteps = params.nextSteps;\n this.docsUrl = params.docsUrl;\n }\n\n /** エラーコードが指定した値と一致するか判定する。 */\n is(code: CMSErrorCode): boolean {\n return this.code === code;\n }\n\n /** エラーコードが指定した名前空間に属するか判定する(例: `\"source/\"`)。 */\n inNamespace(namespace: string): boolean {\n return this.code.startsWith(namespace);\n }\n\n /**\n * nextSteps と docsUrl を含む人間向けの詳細メッセージを返す。\n * エラーダイアログ・ログ出力時に使う。\n */\n format(): string {\n const lines: string[] = [this.message];\n if (this.nextSteps?.length) {\n lines.push(\"\\n次にやること:\");\n for (const step of this.nextSteps) {\n lines.push(` - ${step}`);\n }\n }\n if (this.docsUrl) {\n lines.push(`\\n詳細: ${this.docsUrl}`);\n }\n return lines.join(\"\\n\");\n }\n}\n\nexport function isCMSError(error: unknown): error is CMSError {\n return error instanceof CMSError;\n}\n\n/** エラーコードが特定の名前空間に属するかを判定する(例: \"source/\")。 */\nexport function isCMSErrorInNamespace(\n error: unknown,\n namespace: string,\n): error is CMSError {\n return isCMSError(error) && error.code.startsWith(namespace);\n}\n\ntype CMSErrorHandler<R> = (err: CMSError) => R;\n\n/**\n * `CMSError` を switch 式のように分岐して処理するユーティリティ。\n * `_` キーはフォールバック(CMSError 以外 or 未マッチ時)に使われる。\n *\n * @example\n * matchCMSError(err, {\n * \"source/fetch_items_failed\": (e) => handleFetchError(e),\n * _: (e) => { throw e; },\n * });\n */\nexport function matchCMSError<R>(\n error: unknown,\n handlers: Partial<Record<CMSErrorCode, CMSErrorHandler<R>>> & {\n _?: (err: unknown) => R;\n },\n): R | undefined {\n if (!isCMSError(error)) {\n return handlers._?.(error);\n }\n const handler =\n handlers[error.code as CMSErrorCode] ??\n (handlers._ as CMSErrorHandler<R> | undefined);\n return handler?.(error);\n}\n"],"mappings":";AA6EA,IAAa,WAAb,cAA8B,MAAM;CAClC;CACA;CACA;;CAEA;;CAEA;CAEA,YAAY,QAOT;AACD,QAAM,OAAO,SAAS,EAAE,OAAO,OAAO,OAAO,CAAC;AAC9C,OAAK,OAAO;AACZ,OAAK,OAAO,OAAO;AACnB,OAAK,QAAQ,OAAO;AACpB,OAAK,UAAU,OAAO;AACtB,OAAK,YAAY,OAAO;AACxB,OAAK,UAAU,OAAO;;;CAIxB,GAAG,MAA6B;AAC9B,SAAO,KAAK,SAAS;;;CAIvB,YAAY,WAA4B;AACtC,SAAO,KAAK,KAAK,WAAW,UAAU;;;;;;CAOxC,SAAiB;EACf,MAAM,QAAkB,CAAC,KAAK,QAAQ;AACtC,MAAI,KAAK,WAAW,QAAQ;AAC1B,SAAM,KAAK,YAAY;AACvB,QAAK,MAAM,QAAQ,KAAK,UACtB,OAAM,KAAK,OAAO,OAAO;;AAG7B,MAAI,KAAK,QACP,OAAM,KAAK,SAAS,KAAK,UAAU;AAErC,SAAO,MAAM,KAAK,KAAK;;;AAI3B,SAAgB,WAAW,OAAmC;AAC5D,QAAO,iBAAiB;;;AAI1B,SAAgB,sBACd,OACA,WACmB;AACnB,QAAO,WAAW,MAAM,IAAI,MAAM,KAAK,WAAW,UAAU;;;;;;;;;;;;AAe9D,SAAgB,cACd,OACA,UAGe;AACf,KAAI,CAAC,WAAW,MAAM,CACpB,QAAO,SAAS,IAAI,MAAM;AAK5B,SAFE,SAAS,MAAM,SACd,SAAS,KACK,MAAM"}
package/dist/hooks.d.mts CHANGED
@@ -1,2 +1,17 @@
1
- import { n as mergeLoggers, t as mergeHooks } from "./hooks-C6F2PG8x.mjs";
2
- export { mergeHooks, mergeLoggers };
1
+ import { t as BaseContentItem } from "./content-DwsfWZao.mjs";
2
+ import { i as CMSHooks, r as Logger, t as CMSPlugin } from "./plugin-B795Ok3X.mjs";
3
+
4
+ //#region src/hooks.d.ts
5
+ /**
6
+ * プラグイン配列とダイレクトフックを合成して単一の CMSHooks を返す。
7
+ * beforeCacheMeta / beforeCacheContent / afterRender はパイプライン(前の出力が次の入力)。
8
+ * オブザーバー系は全員に同じ値を渡し、例外は logger に流して握りつぶす。
9
+ */
10
+ declare function mergeHooks<T extends BaseContentItem>(plugins: CMSPlugin<T>[], directHooks?: CMSHooks<T>, logger?: Logger): CMSHooks<T>;
11
+ /** プラグイン配列とダイレクトロガーを合成して単一の Logger を返す。 */
12
+ declare function mergeLoggers(plugins: Array<{
13
+ logger?: Partial<Logger>;
14
+ }>, directLogger?: Logger): Logger | undefined;
15
+ //#endregion
16
+ export { mergeHooks, mergeLoggers };
17
+ //# sourceMappingURL=hooks.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,7 +1,11 @@
1
1
  import { a as CachedItemMeta, c as ContentResult, i as CachedItemList, l as ImageRef, n as CMSSchemaProperties, o as StorageBinary, r as CachedItemContent, s as ContentBlock, t as BaseContentItem, u as InlineNode } from "./content-DwsfWZao.mjs";
2
- import { a as CacheAdapter, c as DataSource, d as PropertyDef, f as PropertyMap, i as memoryCache, l as InvalidateKind, o as DocumentCacheOps, p as WebhookConfig, s as ImageCacheOps, t as MemoryCacheOptions, u as InvalidateScope } from "./memory-BT9rLPr1.mjs";
3
- import { a as isCMSError, i as CMSErrorContext, n as CMSError, o as isCMSErrorInNamespace, r as CMSErrorCode, s as matchCMSError, t as BuiltInCMSErrorCode } from "./errors-CC_x98vG.mjs";
4
- import { a as Logger, i as definePlugin, n as mergeLoggers, o as CMSHooks, r as CMSPlugin, s as MaybePromise, t as mergeHooks } from "./hooks-C6F2PG8x.mjs";
2
+ import { a as InvalidateKind, c as PropertyMap, i as DataSource, l as WebhookConfig, n as DocumentCacheOps, o as InvalidateScope, r as ImageCacheOps, s as PropertyDef, t as CacheAdapter } from "./cache-DS81aOcC.mjs";
3
+ import { a as isCMSError, i as CMSErrorContext, n as CMSError, o as isCMSErrorInNamespace, r as CMSErrorCode, s as matchCMSError, t as BuiltInCMSErrorCode } from "./errors-DTt9ii0i.mjs";
4
+ import { a as MaybePromise, i as CMSHooks, n as definePlugin, r as Logger, t as CMSPlugin } from "./plugin-B795Ok3X.mjs";
5
+ import { a as InferCollectionItem, c as RenderOptions, d as SWRConfig, i as CreateClientOptions, l as RendererFn, m as MergeSourceCollections, n as CollectionsConfig, o as LogLevel, p as CMSSources, r as ContentConfig, s as RateLimiterConfig, u as RendererPluginList } from "./config-D4JQ_pmq.mjs";
6
+ import { MemoryCacheOptions, memoryCache } from "./cache/memory.mjs";
7
+ import { mergeHooks, mergeLoggers } from "./hooks.mjs";
8
+ import { NodePresetOptions, nodePreset } from "./preset/node.mjs";
5
9
 
6
10
  //#region src/types/collection.d.ts
7
11
  /**
@@ -136,162 +140,6 @@ interface CollectionClient<T extends BaseContentItem = BaseContentItem> {
136
140
  cache: CollectionCacheOps<T>;
137
141
  }
138
142
  //#endregion
139
- //#region src/types/sources.d.ts
140
- /**
141
- * CMS データソースアダプターのインターフェース。
142
- * 各アダプターパッケージ (`@notion-headless-cms/notion-source` 等) が実装し、
143
- * `createClient({ sources: { ... } })` に渡される。
144
- */
145
- interface CMSAdapter<C extends CollectionsConfig = CollectionsConfig> {
146
- readonly collections: C;
147
- }
148
- /**
149
- * アダプターパッケージが宣言マージで拡張する空インターフェース。
150
- * import するだけでキーが補完候補に現れる (Fastify プラグインと同じパターン)。
151
- *
152
- * @example
153
- * declare module "@notion-headless-cms/core" {
154
- * interface CMSSources {
155
- * notion?: CMSAdapter;
156
- * }
157
- * }
158
- */
159
- interface CMSSources {}
160
- type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
161
- /** 全ソースの collections を交差型でマージする。 */
162
- type MergeSourceCollections<S extends CMSSources> = UnionToIntersection<{ [K in keyof S]: S[K] extends CMSAdapter<infer C> ? C : never }[keyof S]>;
163
- //#endregion
164
- //#region src/types/config.d.ts
165
- /** `Logger` の出力を絞り込むログレベル。指定したレベル未満のログを抑制する。 */
166
- type LogLevel = "debug" | "info" | "warn" | "error";
167
- /**
168
- * renderer プラグインの不透明型。
169
- * core は unified / remark / rehype に依存せず、このリストをそのまま renderer に渡すだけ。
170
- */
171
- type RendererPluginList = unknown[];
172
- /**
173
- * render() オプション。core は renderer の実装を知らず、この型だけを扱う。
174
- * @notion-headless-cms/renderer の renderMarkdown() はこのシグネチャと構造的に互換。
175
- */
176
- interface RenderOptions {
177
- imageProxyBase?: string;
178
- cacheImage?: (url: string) => Promise<string>;
179
- remarkPlugins?: RendererPluginList;
180
- rehypePlugins?: RendererPluginList;
181
- }
182
- /** カスタムレンダラー関数の型。デフォルトは @notion-headless-cms/renderer の renderMarkdown。 */
183
- type RendererFn = (markdown: string, opts?: RenderOptions) => Promise<string>;
184
- /** レンダリング・コンテンツ処理設定。 */
185
- interface ContentConfig {
186
- /** 画像プロキシのベースURL。デフォルト: '/api/images' */
187
- imageProxyBase?: string;
188
- /** 追加する remark プラグイン。 */
189
- remarkPlugins?: RendererPluginList;
190
- /** 追加する rehype プラグイン。 */
191
- rehypePlugins?: RendererPluginList;
192
- }
193
- /** SWR(Stale-While-Revalidate)設定。 */
194
- interface SWRConfig {
195
- /** SWR の有効期間 (ミリ秒)。未設定時は TTL なし(失効まで stale を返す)。 */
196
- ttlMs?: number;
197
- }
198
- /** レートリミット・リトライ設定。 */
199
- interface RateLimiterConfig {
200
- /** 同時実行数の上限。デフォルト: 3 */
201
- maxConcurrent?: number;
202
- /** リトライ対象の HTTP ステータスコード。デフォルト: [429, 502, 503] */
203
- retryOn?: number[];
204
- /** 最大リトライ回数。デフォルト: 4 */
205
- maxRetries?: number;
206
- /** リトライ時の基準待機時間(ミリ秒)。デフォルト: 1000 */
207
- baseDelayMs?: number;
208
- }
209
- /**
210
- * コレクション 1 件の定義。CLI が生成する `nhc.ts` から `createClient` に渡される。
211
- *
212
- * `source` は notion-orm 等の DataSource 実装。
213
- * `slugField` / `statusField` は TS フィールド名 (DataSource の `properties` キーと一致)。
214
- */
215
- interface CollectionDef<T extends BaseContentItem = BaseContentItem> {
216
- /** Notion etc. のデータソース実装。 */
217
- source: DataSource<T>;
218
- /** slug として使う TS フィールド名 (必須)。`source.properties[slugField]` で Notion プロパティ名を解決する。 */
219
- slugField: string;
220
- /** ステータスとして使う TS フィールド名。 */
221
- statusField?: string;
222
- /** 公開扱いするステータス値。`list()` のデフォルト絞り込みに使う。 */
223
- publishedStatuses?: readonly string[];
224
- /** アクセス許可するステータス値。`get()` の閲覧可否判定に使う。 */
225
- accessibleStatuses?: readonly string[];
226
- /** コレクション固有のライフサイクルフック。グローバル hooks の後に実行される。 */
227
- hooks?: CMSHooks<T>;
228
- }
229
- /**
230
- * `createClient({ collections })` の map 型。
231
- * キーがコレクション名、値が `CollectionDef<T>`。
232
- */
233
- type CollectionsConfig = Record<string, CollectionDef<BaseContentItem>>;
234
- /** `CollectionsConfig` から各 T を抽出するユーティリティ型。 */
235
- type InferCollectionItem<C> = C extends CollectionDef<infer T> ? T : BaseContentItem;
236
- /**
237
- * `createClient()` の入力。
238
- * 通常は CLI が生成した `nhc.ts` の `createClient` がこの型をラップする。
239
- *
240
- * @example
241
- * createClient({
242
- * collections: {
243
- * posts: {
244
- * source: createNotionCollection({ token, dataSourceId, properties }),
245
- * slugField: "slug",
246
- * statusField: "status",
247
- * publishedStatuses: ["公開済み"],
248
- * }
249
- * },
250
- * cache: [memoryCache()],
251
- * swr: { ttlMs: 5 * 60_000 },
252
- * });
253
- */
254
- interface CreateClientOptions<C extends CollectionsConfig = CollectionsConfig, S extends CMSSources = CMSSources> {
255
- /**
256
- * データソースアダプター (`@notion-headless-cms/notion-source` 等) のマップ。
257
- * `sources` を指定する場合 `collections` は不要。両方指定された場合は `sources` が優先される。
258
- */
259
- sources?: S;
260
- /** コレクション定義のマップ。`sources` を使う場合は不要。 */
261
- collections?: C;
262
- /**
263
- * キャッシュアダプタ (配列)。未指定時はキャッシュなし。
264
- * - `memoryCache()` のように doc + image 両方を担当するもの
265
- * - `r2Cache()` (image のみ)、`kvCache()` (doc のみ) のように片側のみ担当するもの
266
- * - 複数 adapter を配列で組み合わせると、各 adapter の `handles` で振り分けられる
267
- */
268
- cache?: readonly CacheAdapter[];
269
- /** SWR(Stale-While-Revalidate)設定。 */
270
- swr?: SWRConfig;
271
- /**
272
- * Markdown→HTML レンダラー。
273
- * 省略時は `@notion-headless-cms/renderer` の `renderMarkdown` を動的 import で使用する。
274
- * カスタム実装も `RendererFn` 型を満たせば使用可能。
275
- */
276
- renderer?: RendererFn;
277
- /** 画像プロキシのベース URL。デフォルト `/api/images`。 */
278
- imageProxyBase?: string;
279
- /** Cloudflare Workers の `waitUntil` に相当する非同期処理の登録関数。 */
280
- waitUntil?: (p: Promise<unknown>) => void;
281
- /** ライフサイクルフック (全コレクション共通)。 */
282
- hooks?: CMSHooks<BaseContentItem>;
283
- /** プラグイン配列。 */
284
- plugins?: CMSPlugin<BaseContentItem>[];
285
- /** ロガー。 */
286
- logger?: Logger;
287
- /** ログレベルの下限。指定したレベル未満のログを内部で抑制する。 */
288
- logLevel?: LogLevel;
289
- /** レートリミット・リトライ設定。 */
290
- rateLimiter?: RateLimiterConfig;
291
- /** レンダリング・コンテンツ処理設定。 */
292
- content?: ContentConfig;
293
- }
294
- //#endregion
295
143
  //#region src/cache.d.ts
296
144
  /** 文字列をSHA-256でハッシュ化し、16進数文字列として返す。画像キーの生成に使用。 */
297
145
  declare function sha256Hex(input: string): Promise<string>;
@@ -361,40 +209,21 @@ interface CMSGlobalOps {
361
209
  readonly imageProxyBase: string;
362
210
  }
363
211
  /**
364
- * 複数の `CollectionDef` を束ねた CMS クライアントを生成する。
365
- *
366
- * 通常はユーザーが直接呼ぶことはなく、CLI 生成の `nhc.ts` の `createClient`
367
- * (低レベルのこの関数をラップしたもの) を経由する。
212
+ * CMS クライアントを生成する。
368
213
  *
369
214
  * @example
370
- * createClient({
371
- * collections: {
372
- * posts: {
373
- * source: createNotionCollection({ token, dataSourceId, properties }),
374
- * slugField: "slug",
375
- * statusField: "status",
376
- * publishedStatuses: ["公開済み"],
377
- * }
378
- * },
379
- * cache: [memoryCache()],
380
- * swr: { ttlMs: 5 * 60_000 },
215
+ * import { createClient, nodePreset } from "@notion-headless-cms/core";
216
+ * import { notionSource } from "@notion-headless-cms/notion-source";
217
+ * import { schema } from "./generated/nhc.schema";
218
+ *
219
+ * const cms = createClient({
220
+ * sources: { notion: notionSource({ schema, token: process.env.NOTION_TOKEN! }) },
221
+ * ...nodePreset(),
381
222
  * });
223
+ *
224
+ * const posts = await cms.posts.list();
382
225
  */
383
- declare function createClient<C extends CollectionsConfig = CollectionsConfig, S extends CMSSources = CMSSources>(opts: CreateClientOptions<C, S>): CMSClient<MergeSourceCollections<S> extends CollectionsConfig ? MergeSourceCollections<S> : C>;
384
- //#endregion
385
- //#region src/rendering.d.ts
386
- /** 本文レンダリングに必要な依存を束ねたコンテキスト。 */
387
- interface RenderContext<T extends BaseContentItem> {
388
- source: DataSource<T>;
389
- rendererFn: RendererFn | undefined;
390
- imgCache: ImageCacheOps;
391
- imgCacheName: string;
392
- hasImageCache: boolean;
393
- imageProxyBase: string;
394
- contentConfig: ContentConfig | undefined;
395
- hooks: CMSHooks<T>;
396
- logger: Logger | undefined;
397
- }
226
+ declare function createClient<S extends CMSSources = CMSSources>(opts: CreateClientOptions<S>): CMSClient<MergeSourceCollections<S> extends CollectionsConfig ? MergeSourceCollections<S> : CollectionsConfig>;
398
227
  //#endregion
399
228
  //#region src/retry.d.ts
400
229
  interface RetryConfig {
@@ -416,62 +245,5 @@ declare const DEFAULT_RETRY_CONFIG: RetryConfig;
416
245
  */
417
246
  declare function withRetry<T>(fn: () => Promise<T>, config: RetryConfig): Promise<T>;
418
247
  //#endregion
419
- //#region src/collection.d.ts
420
- /**
421
- * コレクション別キャッシュキーを生成する (item: `{collection}:{slug}` / list: `{collection}`)。
422
- *
423
- * 各 cache adapter は内部で独自のキー戦略を持つが、ログ出力や差分再計算で
424
- * 同一表現が必要になるため core 側にも公開する。
425
- */
426
- declare function collectionKey(collection: string, slug?: string): string;
427
- interface CollectionContext<T extends BaseContentItem> {
428
- collection: string;
429
- source: DataSource<T>;
430
- docCache: DocumentCacheOps;
431
- docCacheName: string;
432
- render: RenderContext<T>;
433
- hooks: CMSHooks<T>;
434
- logger: Logger | undefined;
435
- ttlMs: number | undefined;
436
- publishedStatuses: string[];
437
- accessibleStatuses: string[];
438
- retryConfig: RetryConfig;
439
- maxConcurrent: number;
440
- waitUntil: ((p: Promise<unknown>) => void) | undefined;
441
- /**
442
- * slug として使うフィールド名。`source.properties[slugField].notion` を
443
- * Notion プロパティ名として `findByProp` を呼び出す。
444
- */
445
- slugField: string;
446
- }
447
- declare class CollectionClientImpl<T extends BaseContentItem> implements CollectionClient<T> {
448
- private readonly ctx;
449
- readonly cache: CollectionCacheOps<T>;
450
- constructor(ctx: CollectionContext<T>);
451
- find(slug: string, opts?: FindOptions): Promise<ItemWithContent<T> | null>;
452
- list(opts?: ListOptions<T>): Promise<T[]>;
453
- params(): Promise<string[]>;
454
- check(slug: string, currentVersion: string): Promise<CheckResult<T> | null>;
455
- adjacent(slug: string, opts?: AdjacencyOptions<T>): Promise<{
456
- prev: T | null;
457
- next: T | null;
458
- }>;
459
- private invalidateImpl;
460
- private invalidateItemImpl;
461
- private warmImpl;
462
- private persistMeta;
463
- private invalidateContentEntry;
464
- /** 本文キャッシュ。メタとの整合 (`notionUpdatedAt`) が崩れていれば再生成して書き戻す。 */
465
- private loadOrBuildContent;
466
- /** メタ既知の状態で本文だけ再生成する。エラーは onSwrError フックに通知して握り潰す。 */
467
- private rebuildContentBg;
468
- private attachLazyContent;
469
- private fetchList;
470
- private checkAndUpdateItemBg;
471
- private checkAndUpdateListBg;
472
- private fetchListRaw;
473
- private fetchRaw;
474
- }
475
- //#endregion
476
- export { type AdjacencyOptions, type BaseContentItem, type BuiltInCMSErrorCode, type CMSAdapter, type CMSClient, CMSError, type CMSErrorCode, type CMSErrorContext, type CMSGlobalOps, type CMSHooks, type CMSPlugin, type CMSSchemaProperties, type CMSSources, type CacheAdapter, type CachedItemContent, type CachedItemList, type CachedItemMeta, type CheckResult, type CollectionCacheOps, type CollectionClient, CollectionClientImpl, type CollectionContext, type CollectionDef, type CollectionsConfig, type ContentBlock, type ContentConfig, type ContentResult, type CreateClientOptions, DEFAULT_RETRY_CONFIG, type DataSource, type DocumentCacheOps, type FindOptions, type HandlerAdapter, type HandlerOptions, type ImageCacheOps, type ImageRef, type InferCollectionItem, type InlineNode, type InvalidateKind, type InvalidateScope, type ItemWithContent, type ListOptions, type LogLevel, type Logger, type MaybePromise, type MemoryCacheOptions, type MergeSourceCollections, type PropertyDef, type PropertyMap, type RateLimiterConfig, type RenderOptions, type RendererFn, type RendererPluginList, type RetryConfig, type SWRConfig, type SortOption, type StorageBinary, type WarmOptions, type WarmResult, type WebhookConfig, collectionKey, createClient, createHandler, definePlugin, isCMSError, isCMSErrorInNamespace, isStale, matchCMSError, memoryCache, mergeHooks, mergeLoggers, noopDocOps, noopImgOps, sha256Hex, withRetry };
248
+ export { type AdjacencyOptions, type BaseContentItem, type BuiltInCMSErrorCode, type CMSClient, CMSError, type CMSErrorCode, type CMSErrorContext, type CMSGlobalOps, type CMSHooks, type CMSPlugin, type CMSSchemaProperties, type CMSSources, type CacheAdapter, type CachedItemContent, type CachedItemList, type CachedItemMeta, type CheckResult, type CollectionCacheOps, type CollectionClient, type ContentBlock, type ContentConfig, type ContentResult, type CreateClientOptions, DEFAULT_RETRY_CONFIG, type DataSource, type DocumentCacheOps, type FindOptions, type HandlerAdapter, type HandlerOptions, type ImageCacheOps, type ImageRef, type InlineNode, type InvalidateKind, type InvalidateScope, type ItemWithContent, type ListOptions, type LogLevel, type Logger, type MaybePromise, type MemoryCacheOptions, type NodePresetOptions, type PropertyDef, type PropertyMap, type RateLimiterConfig, type RenderOptions, type RendererFn, type RendererPluginList, type RetryConfig, type SWRConfig, type SortOption, type StorageBinary, type WarmOptions, type WarmResult, type WebhookConfig, createClient, createHandler, definePlugin, isCMSError, isCMSErrorInNamespace, isStale, matchCMSError, memoryCache, mergeHooks, mergeLoggers, nodePreset, noopDocOps, noopImgOps, sha256Hex, withRetry };
477
249
  //# sourceMappingURL=index.d.mts.map