@notion-headless-cms/core 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -175
- package/dist/cache/memory.d.mts +52 -0
- package/dist/cache/memory.mjs +115 -0
- package/dist/cache/memory.mjs.map +1 -0
- package/dist/cache/{noop.d.ts → noop.d.mts} +5 -3
- package/dist/cache/noop.mjs +44 -0
- package/dist/cache/noop.mjs.map +1 -0
- package/dist/cache-Av7HRw_s.d.mts +205 -0
- package/dist/content-BrwEY2_p.d.mts +53 -0
- package/dist/errors.d.mts +32 -0
- package/dist/errors.mjs +24 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/hooks-DCSAQkST.d.mts +60 -0
- package/dist/hooks.d.mts +2 -0
- package/dist/hooks.mjs +75 -0
- package/dist/hooks.mjs.map +1 -0
- package/dist/index.d.mts +349 -0
- package/dist/index.mjs +672 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +17 -16
- package/dist/cache/memory.d.ts +0 -54
- package/dist/cache/memory.js +0 -15
- package/dist/cache/memory.js.map +0 -1
- package/dist/cache/noop.js +0 -9
- package/dist/cache/noop.js.map +0 -1
- package/dist/cache-DvbyemBK.d.ts +0 -33
- package/dist/chunk-4KGKWKKI.js +0 -80
- package/dist/chunk-4KGKWKKI.js.map +0 -1
- package/dist/chunk-6DG63XUF.js +0 -42
- package/dist/chunk-6DG63XUF.js.map +0 -1
- package/dist/chunk-6LHROEPI.js +0 -104
- package/dist/chunk-6LHROEPI.js.map +0 -1
- package/dist/chunk-V6ML4QE5.js +0 -26
- package/dist/chunk-V6ML4QE5.js.map +0 -1
- package/dist/content-Biqf0l_o.d.ts +0 -51
- package/dist/errors.d.ts +0 -30
- package/dist/errors.js +0 -11
- package/dist/errors.js.map +0 -1
- package/dist/hooks-B83RUclt.d.ts +0 -41
- package/dist/hooks.d.ts +0 -2
- package/dist/hooks.js +0 -9
- package/dist/hooks.js.map +0 -1
- package/dist/index.d.ts +0 -278
- package/dist/index.js +0 -598
- package/dist/index.js.map +0 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { a as StorageBinary, i as CachedItemList, n as CMSSchemaProperties, r as CachedItem, t as BaseContentItem } from "./content-BrwEY2_p.mjs";
|
|
2
|
+
import { a as CollectionConfig, c as InferCollectionItem, d as ContentBlock, f as ContentResult, i as CMSSchema, l as InvalidateScope, m as InlineNode, n as DocumentCacheAdapter, o as DataSource, p as ImageRef, r as ImageCacheAdapter, s as DataSourceFactory, t as CacheConfig, u as WebhookConfig } from "./cache-Av7HRw_s.mjs";
|
|
3
|
+
import { a as Logger, i as definePlugin, n as mergeLoggers, o as CMSHooks, r as CMSPlugin, s as MaybePromise, t as mergeHooks } from "./hooks-DCSAQkST.mjs";
|
|
4
|
+
import { MemoryDocumentCacheOptions, MemoryImageCacheOptions, memoryCache, memoryDocumentCache, memoryImageCache } from "./cache/memory.mjs";
|
|
5
|
+
import { noopDocumentCache, noopImageCache } from "./cache/noop.mjs";
|
|
6
|
+
import { CMSError, CMSErrorCode, CMSErrorContext, isCMSError, isCMSErrorInNamespace } from "./errors.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/types/collection.d.ts
|
|
9
|
+
/** 並び順指定。 */
|
|
10
|
+
interface SortOption<T extends BaseContentItem = BaseContentItem> {
|
|
11
|
+
/** ソートするプロパティ名。 */
|
|
12
|
+
by: keyof T & string;
|
|
13
|
+
/** 昇順 / 降順。デフォルト "desc"。 */
|
|
14
|
+
direction?: "asc" | "desc";
|
|
15
|
+
}
|
|
16
|
+
/** `getList` のフィルタ / ソート / ページング。 */
|
|
17
|
+
interface GetListOptions<T extends BaseContentItem = BaseContentItem> {
|
|
18
|
+
/** ステータス絞り込み (`publishedStatuses` を上書き)。 */
|
|
19
|
+
statuses?: string[];
|
|
20
|
+
/** プロパティ一致フィルタ (in-memory フィルタ)。 */
|
|
21
|
+
where?: Partial<Record<keyof T, unknown>>;
|
|
22
|
+
/** タグ絞り込み (schema に tags: string[] フィールドがある場合)。 */
|
|
23
|
+
tag?: string;
|
|
24
|
+
/** ソート。デフォルトは publishedAt の降順。 */
|
|
25
|
+
sort?: SortOption<T>;
|
|
26
|
+
/** 最大件数。 */
|
|
27
|
+
limit?: number;
|
|
28
|
+
/** スキップ件数。 */
|
|
29
|
+
skip?: number;
|
|
30
|
+
}
|
|
31
|
+
/** `adjacent` の並び順指定。 */
|
|
32
|
+
interface AdjacencyOptions<T extends BaseContentItem = BaseContentItem> {
|
|
33
|
+
sort?: SortOption<T>;
|
|
34
|
+
}
|
|
35
|
+
/** `getItem` の返り値 (本文常時同梱)。 */
|
|
36
|
+
type ItemWithContent<T extends BaseContentItem> = T & {
|
|
37
|
+
content: ContentResult;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* コレクション別の CMS クライアント。
|
|
41
|
+
* `cms.posts.getItem(slug)` のようにアクセスする。
|
|
42
|
+
*/
|
|
43
|
+
interface CollectionClient<T extends BaseContentItem = BaseContentItem> {
|
|
44
|
+
/** スラッグで単件取得 (本文込み)。キャッシュを経由 (SWR)。 */
|
|
45
|
+
getItem(slug: string): Promise<ItemWithContent<T> | null>;
|
|
46
|
+
/** 公開済みアイテム一覧 (本文なし、一覧ページ向け)。 */
|
|
47
|
+
getList(opts?: GetListOptions<T>): Promise<T[]>;
|
|
48
|
+
/** Next App Router の `generateStaticParams` 向け。 */
|
|
49
|
+
getStaticParams(): Promise<{
|
|
50
|
+
slug: string;
|
|
51
|
+
}[]>;
|
|
52
|
+
/** SSG のパス一覧 (スラッグ配列)。 */
|
|
53
|
+
getStaticPaths(): Promise<string[]>;
|
|
54
|
+
/** 前後記事のナビゲーション。 */
|
|
55
|
+
adjacent(slug: string, opts?: AdjacencyOptions<T>): Promise<{
|
|
56
|
+
prev: T | null;
|
|
57
|
+
next: T | null;
|
|
58
|
+
}>;
|
|
59
|
+
/** 指定スコープのキャッシュを無効化する。 */
|
|
60
|
+
revalidate(scope?: "all" | {
|
|
61
|
+
slug: string;
|
|
62
|
+
}): Promise<void>;
|
|
63
|
+
/** 全コンテンツをプリフェッチしてキャッシュに保存。 */
|
|
64
|
+
prefetch(opts?: {
|
|
65
|
+
concurrency?: number;
|
|
66
|
+
onProgress?: (done: number, total: number) => void;
|
|
67
|
+
}): Promise<{
|
|
68
|
+
ok: number;
|
|
69
|
+
failed: number;
|
|
70
|
+
}>;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/types/config.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* renderer プラグインの不透明型。
|
|
76
|
+
* core は unified / remark / rehype に依存せず、このリストをそのまま renderer に渡すだけ。
|
|
77
|
+
*/
|
|
78
|
+
type RendererPluginList = any[];
|
|
79
|
+
/**
|
|
80
|
+
* render() オプション。core は renderer の実装を知らず、この型だけを扱う。
|
|
81
|
+
* @notion-headless-cms/renderer の renderMarkdown() はこのシグネチャと構造的に互換。
|
|
82
|
+
*/
|
|
83
|
+
interface RenderOptions {
|
|
84
|
+
imageProxyBase?: string;
|
|
85
|
+
cacheImage?: (url: string) => Promise<string>;
|
|
86
|
+
remarkPlugins?: RendererPluginList;
|
|
87
|
+
rehypePlugins?: RendererPluginList;
|
|
88
|
+
}
|
|
89
|
+
/** カスタムレンダラー関数の型。デフォルトは @notion-headless-cms/renderer の renderMarkdown。 */
|
|
90
|
+
type RendererFn = (markdown: string, opts?: RenderOptions) => Promise<string>;
|
|
91
|
+
/** レンダリング・コンテンツ処理設定。 */
|
|
92
|
+
interface ContentConfig {
|
|
93
|
+
/** 画像プロキシのベースURL。デフォルト: '/api/images' */
|
|
94
|
+
imageProxyBase?: string;
|
|
95
|
+
/** 追加する remark プラグイン。 */
|
|
96
|
+
remarkPlugins?: RendererPluginList;
|
|
97
|
+
/** 追加する rehype プラグイン。 */
|
|
98
|
+
rehypePlugins?: RendererPluginList;
|
|
99
|
+
}
|
|
100
|
+
/** レートリミット・リトライ設定。 */
|
|
101
|
+
interface RateLimiterConfig {
|
|
102
|
+
/** 同時実行数の上限。デフォルト: 3 */
|
|
103
|
+
maxConcurrent?: number;
|
|
104
|
+
/** リトライ対象の HTTP ステータスコード。デフォルト: [429, 502, 503] */
|
|
105
|
+
retryOn?: number[];
|
|
106
|
+
/** 最大リトライ回数。デフォルト: 4 */
|
|
107
|
+
maxRetries?: number;
|
|
108
|
+
/** リトライ時の基準待機時間(ミリ秒)。デフォルト: 1000 */
|
|
109
|
+
baseDelayMs?: number;
|
|
110
|
+
}
|
|
111
|
+
/** `createCMS({ dataSources })` の map 型。 */
|
|
112
|
+
type DataSourceMap = Record<string, DataSource<any>>;
|
|
113
|
+
/** `DataSourceMap` から各 T を抽出するユーティリティ型。 */
|
|
114
|
+
type InferDataSourceItem<D> = D extends DataSource<infer T> ? T : BaseContentItem;
|
|
115
|
+
/**
|
|
116
|
+
* `createCMS()` に渡すオプション。v1 の正式な入力シグネチャ。
|
|
117
|
+
* ユーザーは `nhc generate` が生成した `cmsDataSources` を渡すだけ。
|
|
118
|
+
*/
|
|
119
|
+
interface CreateCMSOptions<D extends DataSourceMap = DataSourceMap> {
|
|
120
|
+
/** コレクション名 → DataSource のマップ (CLI 生成の `cmsDataSources`)。 */
|
|
121
|
+
dataSources: D;
|
|
122
|
+
/**
|
|
123
|
+
* ランタイムプリセット。`cache` / `renderer` のデフォルトを自動設定する。
|
|
124
|
+
*
|
|
125
|
+
* - `"node"`: Node.js 向け。`memoryDocumentCache` + `memoryImageCache` を有効化。
|
|
126
|
+
* `ttlMs` と組み合わせて SWR の TTL を設定できる。
|
|
127
|
+
* - `"disabled"`: キャッシュを完全無効化する。
|
|
128
|
+
* - 省略: 従来の動作(`cache` / `renderer` をそのまま使用)。
|
|
129
|
+
* `...nodePreset({ ttlMs })` のスプレッドパターンも引き続き動作する。
|
|
130
|
+
*
|
|
131
|
+
* `cache` を明示的に指定した場合は `preset` より `cache` が優先される。
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* // Before(スプレッドが必要だった)
|
|
135
|
+
* const cms = createCMS({ ...nodePreset({ ttlMs: 5 * 60_000 }), dataSources });
|
|
136
|
+
*
|
|
137
|
+
* // After
|
|
138
|
+
* const cms = createCMS({ dataSources, preset: "node", ttlMs: 5 * 60_000 });
|
|
139
|
+
*/
|
|
140
|
+
preset?: "node" | "disabled";
|
|
141
|
+
/**
|
|
142
|
+
* SWR キャッシュの有効期間(ミリ秒)。`preset` と組み合わせて使用する。
|
|
143
|
+
* `cache` オブジェクトを直接渡す場合は `cache.ttlMs` を使用すること。
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* const cms = createCMS({ dataSources, preset: "node", ttlMs: 5 * 60_000 });
|
|
147
|
+
*/
|
|
148
|
+
ttlMs?: number;
|
|
149
|
+
/** レンダラー関数。未指定時は @notion-headless-cms/renderer の renderMarkdown を使用。 */
|
|
150
|
+
renderer?: RendererFn;
|
|
151
|
+
/** キャッシュ設定。未設定時はキャッシュなし。 */
|
|
152
|
+
cache?: CacheConfig;
|
|
153
|
+
/** レンダリング・コンテンツ処理設定。 */
|
|
154
|
+
content?: ContentConfig;
|
|
155
|
+
/** Cloudflare Workers の waitUntil に相当する非同期処理の登録関数。 */
|
|
156
|
+
waitUntil?: (p: Promise<unknown>) => void;
|
|
157
|
+
/** ライフサイクルフック (全コレクション共通)。 */
|
|
158
|
+
hooks?: CMSHooks<any>;
|
|
159
|
+
/** プラグイン配列。 */
|
|
160
|
+
plugins?: CMSPlugin<any>[];
|
|
161
|
+
/** ロガー。 */
|
|
162
|
+
logger?: Logger;
|
|
163
|
+
/** レートリミット・リトライ設定。 */
|
|
164
|
+
rateLimiter?: RateLimiterConfig;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/cache.d.ts
|
|
168
|
+
/** 文字列をSHA-256でハッシュ化し、16進数文字列として返す。画像キーの生成に使用。 */
|
|
169
|
+
declare function sha256Hex(input: string): Promise<string>;
|
|
170
|
+
/**
|
|
171
|
+
* キャッシュが有効期限切れかどうかを判定する。
|
|
172
|
+
* ttlMs が未指定の場合は常に false(無期限有効)を返す。
|
|
173
|
+
*/
|
|
174
|
+
declare function isStale(cachedAt: number, ttlMs?: number): boolean;
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/handler.d.ts
|
|
177
|
+
/** `$handler()` の挙動設定。 */
|
|
178
|
+
interface HandlerOptions {
|
|
179
|
+
/** マウントするベースパス。デフォルト `/api/cms`。 */
|
|
180
|
+
basePath?: string;
|
|
181
|
+
/** 画像プロキシのパス (basePath 相対)。デフォルト `/images/:hash`。 */
|
|
182
|
+
imagesPath?: string;
|
|
183
|
+
/** revalidate webhook のパス (basePath 相対)。デフォルト `/revalidate`。 */
|
|
184
|
+
revalidatePath?: string;
|
|
185
|
+
/** Webhook 署名検証用シークレット (未指定なら検証スキップ)。 */
|
|
186
|
+
webhookSecret?: string;
|
|
187
|
+
/** デフォルト実装を無効化する場合 true。 */
|
|
188
|
+
disabled?: boolean;
|
|
189
|
+
}
|
|
190
|
+
/** `$handler()` が内部で依存する CMS 機能の最小セット。 */
|
|
191
|
+
interface HandlerAdapter {
|
|
192
|
+
imageCache: ImageCacheAdapter;
|
|
193
|
+
/** コレクション名で DataSource を取り出し parseWebhook にフォワードする。 */
|
|
194
|
+
parseWebhook(req: Request, webhookSecret: string | undefined): Promise<InvalidateScope | null>;
|
|
195
|
+
revalidate(scope: InvalidateScope): Promise<void>;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Web Standard な Request → Response ルーター。
|
|
199
|
+
* Next.js / React Router / Hono / Cloudflare Workers いずれでも使える。
|
|
200
|
+
*
|
|
201
|
+
* ルート:
|
|
202
|
+
* - GET `{basePath}/images/:hash` — 画像プロキシ
|
|
203
|
+
* - POST `{basePath}/revalidate` — Webhook 受信 + $revalidate()
|
|
204
|
+
*/
|
|
205
|
+
declare function createHandler(adapter: HandlerAdapter, opts?: HandlerOptions): (req: Request) => Promise<Response>;
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/cms.d.ts
|
|
208
|
+
/** `CMSClient<D>` — コレクション別アクセス + グローバル操作の合成型。 */
|
|
209
|
+
type CMSClient<D extends DataSourceMap> = { [K in keyof D]: CollectionClient<InferDataSourceItem<D[K]>> } & CMSGlobalOps<D>;
|
|
210
|
+
/** `CMSClient` のグローバル名前空間。`$` プレフィックス。 */
|
|
211
|
+
interface CMSGlobalOps<D extends DataSourceMap> {
|
|
212
|
+
/** 登録されているコレクション名の一覧。 */
|
|
213
|
+
readonly $collections: readonly (keyof D & string)[];
|
|
214
|
+
/** 全コレクションまたは特定コレクションのキャッシュを無効化する。 */
|
|
215
|
+
$revalidate(scope?: InvalidateScope): Promise<void>;
|
|
216
|
+
/** Web Standard なルーティングハンドラ (画像プロキシ / webhook) を生成する。 */
|
|
217
|
+
$handler(opts?: HandlerOptions): (req: Request) => Promise<Response>;
|
|
218
|
+
/** ハッシュキーでキャッシュ画像を取得する。 */
|
|
219
|
+
$getCachedImage(hash: string): ReturnType<ImageCacheAdapter["get"]>;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* 複数の DataSource を束ねた CMS クライアントを生成する。
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* // Node.js(preset を使った簡潔な記法)
|
|
226
|
+
* const cms = createCMS({ dataSources: cmsDataSources, preset: "node", ttlMs: 5 * 60_000 });
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* // 従来の spread パターン(引き続き動作する)
|
|
230
|
+
* const cms = createCMS({ ...nodePreset({ ttlMs: 5 * 60_000 }), dataSources: cmsDataSources });
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* // キャッシュを細かく指定する場合
|
|
234
|
+
* const cms = createCMS({
|
|
235
|
+
* dataSources,
|
|
236
|
+
* cache: { document, image, ttlMs: 60_000 },
|
|
237
|
+
* });
|
|
238
|
+
*/
|
|
239
|
+
declare function createCMS<D extends DataSourceMap>(opts: CreateCMSOptions<D>): CMSClient<D>;
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/rendering.d.ts
|
|
242
|
+
/** `buildCachedItem` に必要な CMS の依存を束ねたコンテキスト。 */
|
|
243
|
+
interface RenderContext<T extends BaseContentItem> {
|
|
244
|
+
source: DataSource<T>;
|
|
245
|
+
rendererFn: RendererFn | undefined;
|
|
246
|
+
imgCache: ImageCacheAdapter;
|
|
247
|
+
hasImageCache: boolean;
|
|
248
|
+
imageProxyBase: string;
|
|
249
|
+
contentConfig: ContentConfig | undefined;
|
|
250
|
+
hooks: CMSHooks<T>;
|
|
251
|
+
logger: Logger | undefined;
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/retry.d.ts
|
|
255
|
+
interface RetryConfig {
|
|
256
|
+
retryOn: number[];
|
|
257
|
+
maxRetries: number;
|
|
258
|
+
baseDelayMs: number;
|
|
259
|
+
/** true のとき指数バックオフにランダムジッターを加える(Thundering Herd 対策)。デフォルト: true */
|
|
260
|
+
jitter?: boolean;
|
|
261
|
+
onRetry?: (attempt: number, status: number) => void;
|
|
262
|
+
}
|
|
263
|
+
declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
264
|
+
/** 指数バックオフ(オプションでジッター付き)でリトライする。retryOn に含まれる HTTP エラーのみ対象。 */
|
|
265
|
+
declare function withRetry<T>(fn: () => Promise<T>, config: RetryConfig): Promise<T>;
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/collection.d.ts
|
|
268
|
+
/**
|
|
269
|
+
* コレクション別キャッシュキーを生成する。
|
|
270
|
+
* item: `{collection}:{slug}` / list: `{collection}`
|
|
271
|
+
*/
|
|
272
|
+
declare function collectionKey(collection: string, slug?: string): string;
|
|
273
|
+
/** 単一コレクションの DataSource + SWR キャッシュ依存を束ねたコンテキスト。 */
|
|
274
|
+
interface CollectionContext<T extends BaseContentItem> {
|
|
275
|
+
collection: string;
|
|
276
|
+
source: DataSource<T>;
|
|
277
|
+
docCache: DocumentCacheAdapter<T>;
|
|
278
|
+
render: RenderContext<T>;
|
|
279
|
+
hooks: CMSHooks<T>;
|
|
280
|
+
logger: Logger | undefined;
|
|
281
|
+
ttlMs: number | undefined;
|
|
282
|
+
publishedStatuses: string[];
|
|
283
|
+
accessibleStatuses: string[];
|
|
284
|
+
retryConfig: RetryConfig;
|
|
285
|
+
maxConcurrent: number;
|
|
286
|
+
waitUntil: ((p: Promise<unknown>) => void) | undefined;
|
|
287
|
+
}
|
|
288
|
+
/** CollectionClient の実装。ユーザーは `createCMS` 経由でインスタンスを受け取る。 */
|
|
289
|
+
declare class CollectionClientImpl<T extends BaseContentItem> implements CollectionClient<T> {
|
|
290
|
+
private readonly ctx;
|
|
291
|
+
constructor(ctx: CollectionContext<T>);
|
|
292
|
+
getItem(slug: string): Promise<ItemWithContent<T> | null>;
|
|
293
|
+
getList(opts?: GetListOptions<T>): Promise<T[]>;
|
|
294
|
+
getStaticParams(): Promise<{
|
|
295
|
+
slug: string;
|
|
296
|
+
}[]>;
|
|
297
|
+
getStaticPaths(): Promise<string[]>;
|
|
298
|
+
adjacent(slug: string, opts?: AdjacencyOptions<T>): Promise<{
|
|
299
|
+
prev: T | null;
|
|
300
|
+
next: T | null;
|
|
301
|
+
}>;
|
|
302
|
+
revalidate(scope?: "all" | {
|
|
303
|
+
slug: string;
|
|
304
|
+
}): Promise<void>;
|
|
305
|
+
prefetch(opts?: {
|
|
306
|
+
concurrency?: number;
|
|
307
|
+
onProgress?: (done: number, total: number) => void;
|
|
308
|
+
}): Promise<{
|
|
309
|
+
ok: number;
|
|
310
|
+
failed: number;
|
|
311
|
+
}>;
|
|
312
|
+
private attachContent;
|
|
313
|
+
private fetchList;
|
|
314
|
+
private fetchListRaw;
|
|
315
|
+
private findRaw;
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/preset-node.d.ts
|
|
319
|
+
/** `nodePreset()` のオプション。 */
|
|
320
|
+
interface NodePresetOptions {
|
|
321
|
+
/**
|
|
322
|
+
* キャッシュ設定。
|
|
323
|
+
* - 省略時: memoryDocumentCache + memoryImageCache をデフォルト有効化
|
|
324
|
+
* - `"disabled"`: キャッシュを完全無効化
|
|
325
|
+
* - オブジェクト: 任意の cache adapter を差し込む
|
|
326
|
+
*/
|
|
327
|
+
cache?: CacheConfig | "disabled";
|
|
328
|
+
/** SWR の TTL (ミリ秒)。`cache` をオブジェクトで渡した場合はそちらが優先される。 */
|
|
329
|
+
ttlMs?: number;
|
|
330
|
+
/** カスタムレンダラー。未指定時は core が @notion-headless-cms/renderer を動的ロード。 */
|
|
331
|
+
renderer?: RendererFn;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Node.js ランタイム向けの `createCMS` オプションプリセット。
|
|
335
|
+
* メモリキャッシュをデフォルト有効にした `{ cache, renderer }` を返す。
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* import { createCMS, nodePreset } from "@notion-headless-cms/core";
|
|
339
|
+
* import { cmsDataSources } from "./generated/cms-schema";
|
|
340
|
+
*
|
|
341
|
+
* const cms = createCMS({
|
|
342
|
+
* ...nodePreset({ ttlMs: 5 * 60_000 }),
|
|
343
|
+
* dataSources: cmsDataSources,
|
|
344
|
+
* });
|
|
345
|
+
*/
|
|
346
|
+
declare function nodePreset(opts?: NodePresetOptions): Pick<CreateCMSOptions, "cache" | "renderer">;
|
|
347
|
+
//#endregion
|
|
348
|
+
export { type AdjacencyOptions, type BaseContentItem, type CMSClient, CMSError, type CMSErrorCode, type CMSErrorContext, type CMSGlobalOps, type CMSHooks, type CMSPlugin, type CMSSchema, type CMSSchemaProperties, type CacheConfig, type CachedItem, type CachedItemList, type CollectionClient, CollectionClientImpl, type CollectionConfig, type CollectionContext, type ContentBlock, type ContentConfig, type ContentResult, type CreateCMSOptions, DEFAULT_RETRY_CONFIG, type DataSource, type DataSourceFactory, type DataSourceMap, type DocumentCacheAdapter, type GetListOptions, type HandlerAdapter, type HandlerOptions, type ImageCacheAdapter, type ImageRef, type InferCollectionItem, type InferDataSourceItem, type InlineNode, type InvalidateScope, type ItemWithContent, type Logger, type MaybePromise, type MemoryDocumentCacheOptions, type MemoryImageCacheOptions, type NodePresetOptions, type RateLimiterConfig, type RenderOptions, type RendererFn, type RendererPluginList, type RetryConfig, type SortOption, type StorageBinary, type WebhookConfig, collectionKey, createCMS, createHandler, definePlugin, isCMSError, isCMSErrorInNamespace, isStale, memoryCache, memoryDocumentCache, memoryImageCache, mergeHooks, mergeLoggers, nodePreset, noopDocumentCache, noopImageCache, sha256Hex, withRetry };
|
|
349
|
+
//# sourceMappingURL=index.d.mts.map
|