@roottale/cms-core 0.55.0 → 0.57.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/dist/index.d.cts CHANGED
@@ -233,6 +233,54 @@ declare function resolveCategoryTreeHubPaths(presentation: CategoryTreePresentat
233
233
  /** 계층형 분류 모델 항목의 정규 상세 주소. */
234
234
  declare function resolveCategoryTreeEntryPath(presentation: CategoryTreePresentation, entry: CategoryTreeEntry, terms: readonly CategoryTreeTerm[]): string | null;
235
235
 
236
+ /**
237
+ * 글의 정규 공개 경로 — 플랫폼 전체가 쓰는 **하나의** 계산기 (ADR-0105 개정).
238
+ *
239
+ * 우선순위: 콘텐츠 모델 presentation(fixed_page → detail → category_tree) →
240
+ * 호환 컬렉션(`resolvePostPath`) → 레거시 `/blog/{slug}`. `data_only` 모델은
241
+ * 상세 주소가 없으므로 호환 컬렉션이 있으면 그 규칙을, 없으면 null 을 돌려준다.
242
+ *
243
+ * 이 값은 저장 시 `posts.public_path` 로 물질화되고(경로 이력 포함), 웹훅·사이트맵·
244
+ * 단축링크·내부 링크 키·리다이렉트는 저장된 값을 읽는다. 여기 말고 다른 곳에서
245
+ * 주소를 다시 계산하지 않는다.
246
+ */
247
+
248
+ /** 콘텐츠 모델 presentation 의 구조적 최소형(cms-models 스키마와 호환). */
249
+ type PublicPathPresentation = {
250
+ readonly kind: "data_only";
251
+ } | {
252
+ readonly kind: "fixed_page";
253
+ readonly path: string;
254
+ } | {
255
+ readonly kind: "detail";
256
+ readonly detailPath: string;
257
+ } | {
258
+ readonly kind: "category_tree";
259
+ readonly basePath: string;
260
+ readonly categoryDepth: number;
261
+ };
262
+ interface PublicPathPost {
263
+ readonly slug: string;
264
+ readonly collectionKey?: string | null;
265
+ readonly modelKey?: string | null;
266
+ readonly terms: ReadonlyArray<{
267
+ readonly id: string;
268
+ readonly taxonomy: string;
269
+ readonly slug: string;
270
+ }>;
271
+ }
272
+ interface PublicPathContext {
273
+ /** 글의 모델 presentation. 모델 글이 아니거나 모델을 못 찾으면 null. */
274
+ readonly presentation: PublicPathPresentation | null;
275
+ /** 모델의 호환 컬렉션 key(`compatibilityCollectionKey`, 미지정이면 모델 key). */
276
+ readonly compatibilityCollectionKey?: string | null;
277
+ readonly collections: readonly RouteCollection[];
278
+ readonly categories: readonly CategoryTreeTerm[];
279
+ }
280
+ declare const LEGACY_BLOG_DETAIL_PATH = "/blog";
281
+ /** 글의 정규 공개 경로(origin 제외). 상세 주소가 없으면 null. */
282
+ declare function resolvePostPublicPath(post: PublicPathPost, context: PublicPathContext): string | null;
283
+
236
284
  interface ClientHydrationSpec {
237
285
  hydration?: "visible" | "idle" | "load" | "media" | "only";
238
286
  module?: string;
@@ -334,6 +382,58 @@ declare function ensureImportedHtmlDocumentRoots(html: string, allowedAssetUrls?
334
382
  /** 저장된 안전 CSS가 같은 importedHtml 블록 밖으로 새지 않도록 범위를 고정한다. */
335
383
  declare function scopeImportedCss(css: string, scope: string, allowedAssetUrls?: readonly string[]): string;
336
384
 
385
+ declare const INTERNAL_CONTENT_LINK_TOKEN_SOURCE: string;
386
+ interface InternalContentLinkToken {
387
+ /** 토큰이 시작하는 문자 인덱스(텍스트 기준). */
388
+ readonly index: number;
389
+ /** 원문 토큰 전체(`[[internal:…|…]]`). */
390
+ readonly raw: string;
391
+ /** 소문자로 정규화한 키. */
392
+ readonly key: string;
393
+ /** 표시 문구(앞뒤 공백 제거). */
394
+ readonly label: string;
395
+ }
396
+ /** 텍스트 안의 토큰을 앞에서부터 모두 찾는다. 겹치지 않는다. */
397
+ declare function findInternalContentLinkTokens(text: string): InternalContentLinkToken[];
398
+ /** 공개 경로(`/faq/a/b/slug`) → 키(`faq.a.b.slug`). 조각이 없으면 null. */
399
+ declare function internalContentKeyFromPath(path: string | null | undefined): string | null;
400
+ /** 키 → 공개 경로. 없으면 null(문구만 표시). */
401
+ type InternalContentLinkResolver = (key: string) => string | null;
402
+ interface InternalContentPathEntry {
403
+ /** 저장된 정규 공개 경로(`/faq/a/b/slug`). 없으면 대상이 아니다. */
404
+ readonly path?: string | null;
405
+ /** 옛 slug 목록 — 옛 키로 남은 본문도 현재 주소로 이어 준다. */
406
+ readonly previousSlugs?: readonly string[] | null;
407
+ }
408
+ /**
409
+ * 발행 글 목록에서 "키 → 현재 경로" 색인을 만든다. 옛 slug 도 같은 글로 등록한다
410
+ * (경로 마지막 조각을 옛 slug 로 바꾼 키). 현재 경로가 옛 키와 겹치면 현재가 이긴다.
411
+ */
412
+ declare function internalContentPathIndex(entries: Iterable<InternalContentPathEntry>): Map<string, string>;
413
+ /** Map 이나 함수 어느 쪽이든 resolver 로. */
414
+ declare function internalContentLinkResolverFrom(source: InternalContentLinkResolver | ReadonlyMap<string, string> | null | undefined): InternalContentLinkResolver;
415
+ /** 링크로 렌더된 토큰의 class — 사이트 CSS 가 잡을 고리. */
416
+ declare const INTERNAL_CONTENT_LINK_CLASS = "rt-internal-link";
417
+ /** 대상이 아직 없어 문구만 남긴 토큰의 class·data 속성. */
418
+ declare const INTERNAL_CONTENT_LINK_PENDING_CLASS = "rt-internal-link--pending";
419
+ declare const INTERNAL_CONTENT_LINK_PENDING_ATTR = "data-rt-internal-link-pending";
420
+ /**
421
+ * 이미 이스케이프된 텍스트 한 구간의 토큰을 HTML 로 바꾼다. 텍스트 부분은 다시
422
+ * 이스케이프하지 않는다(정화기가 이미 처리한 값). 토큰이 없으면 원문 그대로.
423
+ */
424
+ declare function renderInternalContentLinksInText(text: string, resolve: InternalContentLinkResolver): {
425
+ readonly html: string;
426
+ readonly hasTokens: boolean;
427
+ };
428
+ /**
429
+ * 정화된 HTML(원문 보존 블록 등)의 텍스트 구간에만 토큰을 적용한다. `<a>`·`<code>`·
430
+ * `<pre>` 안과 태그 속성값은 건드리지 않는다.
431
+ */
432
+ declare function renderInternalContentLinksInHtml(html: string, resolve: InternalContentLinkResolver): {
433
+ readonly html: string;
434
+ readonly hasTokens: boolean;
435
+ };
436
+
337
437
  interface PreviewTokenPayload {
338
438
  postId: string;
339
439
  expiresAt: Date;
@@ -371,4 +471,77 @@ declare function injectStableIdsTree(blocks: readonly (Omit<Block, "_id"> & {
371
471
  _id?: string;
372
472
  })[]): Block[];
373
473
 
374
- export { BLOCK_NAME_PATTERN, type BindingResolver, type Block, type BlockBinding, type BlockDefinition, type BlockRegistry, type CategoryTreeEntry, type CategoryTreePresentation, type CategoryTreeTerm, type ClientHydrationSpec, type EmbedProvider, FIELD_BINDING_SOURCE, FIELD_BINDING_SOURCE_ALIAS, type FaqEntry, IMAGE_ALT_MAX_LENGTH, type NormalizedEmbed, PHASE_1_CORE_BLOCKS, PHASE_1_CSP, type Phase1CoreBlockName, type PreviewTokenPayload, type RoutablePost, type RouteCollection, applyBlockBindings, bindingSrcValue, bindingTextValue, blockSchema, boundFieldValue, chainResolvers, createFieldBindingResolver, ensureImportedHtmlDocumentRoots, ensureStableIds, extractFaqEntries, faqPageJsonLd, htmlToPlainText, injectStableIdsTree, isAllowedEmbedSrc, isAllowedMapEmbedSrc, isInCollectionMode, isValidBlock, issuePreviewToken, normalizeEmbed, normalizeImageAlt, parseBlock, postsForCollection, postsInAnyCollection, postsNotInAnyCollection, resolveCategoryPath, resolveCategoryTreeChain, resolveCategoryTreeEntryPath, resolveCategoryTreeHubPaths, resolvePostCategorySlug, resolvePostCollection, resolvePostPath, resolvePostUrl, sanitizeHtml, sanitizeImportedCss, sanitizeImportedHtml, scopeImportedCss, serializeBlock, validateCollections, verifyPreviewToken };
474
+ /**
475
+ * 공통 블록(Site Patterns) — 여러 글에 같은 자리로 붙는 재사용 블록의 순수 규칙.
476
+ *
477
+ * 블록 본문은 ROOT-ADMIN 이 `site_patterns` 에 저장하고, "어느 자리(slot)에 어느
478
+ * 유형(collection)의 글이면 어떤 블록"인지는 배치 규칙(`settings.site_pattern_placements`)
479
+ * 으로 정한다. 공개 API 는 글마다 `pattern_slots`(자리 → 블록 key | null) 를 계산해
480
+ * 내려주므로 FRONT 는 규칙을 몰라도 된다. 이 파일은 api-core(계산)·tenant-admin(편집)·
481
+ * cms-renderer-next(렌더)가 같은 판정을 공유하기 위한 프레임워크 비의존 모듈이다.
482
+ *
483
+ * 규칙 판정:
484
+ * - 자리는 `SITE_PATTERN_SLOTS` 에 선언된 것만 계산한다(미선언 자리는 무시).
485
+ * - 글의 `collectionKey` 와 같은 규칙이 있으면 그 규칙(블록 없음 = null 도 명시적 결정).
486
+ * - 없으면 `collectionKey: null`(모든 글 기본) 규칙.
487
+ * - 가리키는 블록이 발행 상태가 아니면 null(FRONT 가 미발행 블록을 그리지 않게).
488
+ */
489
+ /** 블록을 놓을 수 있는 자리. key 는 공개 API `pattern_slots` 의 키와 같다. */
490
+ declare const SITE_PATTERN_SLOTS: readonly [{
491
+ readonly key: "post_footer";
492
+ readonly label: "글 하단";
493
+ readonly description: "글 본문 바로 아래";
494
+ }];
495
+ type SitePatternSlotKey = (typeof SITE_PATTERN_SLOTS)[number]["key"];
496
+ declare const POST_FOOTER_SLOT: SitePatternSlotKey;
497
+ /** 배치 규칙을 담는 `settings` 키. */
498
+ declare const SITE_PATTERN_PLACEMENTS_KEY = "site_pattern_placements";
499
+ /** 블록 key 형식 — 소문자·숫자·`-`·`_`, 64자 이하, 영숫자로 시작. */
500
+ declare const SITE_PATTERN_KEY_PATTERN: RegExp;
501
+ declare function isValidSitePatternKey(key: string): boolean;
502
+ declare function isSitePatternSlotKey(value: string): value is SitePatternSlotKey;
503
+ /**
504
+ * 배치 규칙 1건. `collectionKey: null` = 모든 글의 기본값, 문자열 = 그 유형의 글만.
505
+ * `patternKey: null` = 이 자리에 블록을 놓지 않는다(유형 규칙이면 기본값 덮어쓰기).
506
+ */
507
+ interface SitePatternPlacementRule {
508
+ readonly slot: SitePatternSlotKey;
509
+ readonly collectionKey: string | null;
510
+ readonly patternKey: string | null;
511
+ }
512
+ interface SitePatternPlacements {
513
+ readonly rules: readonly SitePatternPlacementRule[];
514
+ }
515
+ declare const EMPTY_SITE_PATTERN_PLACEMENTS: SitePatternPlacements;
516
+ /** 글 1건의 자리별 블록 key. 선언된 모든 자리를 키로 가진다(없으면 null). */
517
+ type PatternSlots = Record<string, string | null>;
518
+ /**
519
+ * 저장된 값(unknown) → 정규화된 배치 규칙. 형식이 틀린 항목·미선언 자리는 버리고,
520
+ * 같은 (slot, collectionKey) 는 마지막 항목이 이긴다. 이중 인코딩된 JSON 문자열도 받는다.
521
+ */
522
+ declare function readSitePatternPlacements(raw: unknown): SitePatternPlacements;
523
+ /** (slot, collectionKey) 에 해당하는 규칙. 없으면 undefined(= 기본값으로 위임). */
524
+ declare function findSitePatternPlacementRule(placements: SitePatternPlacements, slot: SitePatternSlotKey, collectionKey: string | null): SitePatternPlacementRule | undefined;
525
+ /**
526
+ * 규칙 1건을 갈아 끼운 새 배치 규칙을 돌려준다(불변). `patternKey: undefined` 는
527
+ * "규칙 삭제 = 기본값으로 위임"이다 — 유형 규칙에서 "표시 안 함"(null)과 구분된다.
528
+ */
529
+ declare function setSitePatternPlacementRule(placements: SitePatternPlacements, target: {
530
+ slot: SitePatternSlotKey;
531
+ collectionKey: string | null;
532
+ }, patternKey: string | null | undefined): SitePatternPlacements;
533
+ /** 선언된 자리마다 null 인 빈 결과 — 규칙이나 발행 블록이 없을 때의 기본 응답. */
534
+ declare function emptyPatternSlots(): PatternSlots;
535
+ /**
536
+ * 글 1건의 자리별 블록 key 를 계산한다. `publishedKeys` 에 없는 블록(미발행·삭제)은 null.
537
+ */
538
+ declare function resolvePatternSlots(post: {
539
+ readonly collectionKey: string | null;
540
+ }, placements: SitePatternPlacements, publishedKeys: ReadonlySet<string>): PatternSlots;
541
+ /**
542
+ * 규칙에서 참조하는 블록 key 집합 — 어드민이 "이 블록은 어디에 쓰이는가"를 표시하거나
543
+ * 삭제 전 경고할 때 쓴다.
544
+ */
545
+ declare function referencedSitePatternKeys(placements: SitePatternPlacements): ReadonlySet<string>;
546
+
547
+ export { BLOCK_NAME_PATTERN, type BindingResolver, type Block, type BlockBinding, type BlockDefinition, type BlockRegistry, type CategoryTreeEntry, type CategoryTreePresentation, type CategoryTreeTerm, type ClientHydrationSpec, EMPTY_SITE_PATTERN_PLACEMENTS, type EmbedProvider, FIELD_BINDING_SOURCE, FIELD_BINDING_SOURCE_ALIAS, type FaqEntry, IMAGE_ALT_MAX_LENGTH, INTERNAL_CONTENT_LINK_CLASS, INTERNAL_CONTENT_LINK_PENDING_ATTR, INTERNAL_CONTENT_LINK_PENDING_CLASS, INTERNAL_CONTENT_LINK_TOKEN_SOURCE, type InternalContentLinkResolver, type InternalContentLinkToken, LEGACY_BLOG_DETAIL_PATH, type NormalizedEmbed, PHASE_1_CORE_BLOCKS, PHASE_1_CSP, POST_FOOTER_SLOT, type PatternSlots, type Phase1CoreBlockName, type PreviewTokenPayload, type PublicPathContext, type PublicPathPost, type PublicPathPresentation, type RoutablePost, type RouteCollection, SITE_PATTERN_KEY_PATTERN, SITE_PATTERN_PLACEMENTS_KEY, SITE_PATTERN_SLOTS, type SitePatternPlacementRule, type SitePatternPlacements, type SitePatternSlotKey, applyBlockBindings, bindingSrcValue, bindingTextValue, blockSchema, boundFieldValue, chainResolvers, createFieldBindingResolver, emptyPatternSlots, ensureImportedHtmlDocumentRoots, ensureStableIds, extractFaqEntries, faqPageJsonLd, findInternalContentLinkTokens, findSitePatternPlacementRule, htmlToPlainText, injectStableIdsTree, internalContentKeyFromPath, internalContentLinkResolverFrom, internalContentPathIndex, isAllowedEmbedSrc, isAllowedMapEmbedSrc, isInCollectionMode, isSitePatternSlotKey, isValidBlock, isValidSitePatternKey, issuePreviewToken, normalizeEmbed, normalizeImageAlt, parseBlock, postsForCollection, postsInAnyCollection, postsNotInAnyCollection, readSitePatternPlacements, referencedSitePatternKeys, renderInternalContentLinksInHtml, renderInternalContentLinksInText, resolveCategoryPath, resolveCategoryTreeChain, resolveCategoryTreeEntryPath, resolveCategoryTreeHubPaths, resolvePatternSlots, resolvePostCategorySlug, resolvePostCollection, resolvePostPath, resolvePostPublicPath, resolvePostUrl, sanitizeHtml, sanitizeImportedCss, sanitizeImportedHtml, scopeImportedCss, serializeBlock, setSitePatternPlacementRule, validateCollections, verifyPreviewToken };
package/dist/index.d.ts CHANGED
@@ -233,6 +233,54 @@ declare function resolveCategoryTreeHubPaths(presentation: CategoryTreePresentat
233
233
  /** 계층형 분류 모델 항목의 정규 상세 주소. */
234
234
  declare function resolveCategoryTreeEntryPath(presentation: CategoryTreePresentation, entry: CategoryTreeEntry, terms: readonly CategoryTreeTerm[]): string | null;
235
235
 
236
+ /**
237
+ * 글의 정규 공개 경로 — 플랫폼 전체가 쓰는 **하나의** 계산기 (ADR-0105 개정).
238
+ *
239
+ * 우선순위: 콘텐츠 모델 presentation(fixed_page → detail → category_tree) →
240
+ * 호환 컬렉션(`resolvePostPath`) → 레거시 `/blog/{slug}`. `data_only` 모델은
241
+ * 상세 주소가 없으므로 호환 컬렉션이 있으면 그 규칙을, 없으면 null 을 돌려준다.
242
+ *
243
+ * 이 값은 저장 시 `posts.public_path` 로 물질화되고(경로 이력 포함), 웹훅·사이트맵·
244
+ * 단축링크·내부 링크 키·리다이렉트는 저장된 값을 읽는다. 여기 말고 다른 곳에서
245
+ * 주소를 다시 계산하지 않는다.
246
+ */
247
+
248
+ /** 콘텐츠 모델 presentation 의 구조적 최소형(cms-models 스키마와 호환). */
249
+ type PublicPathPresentation = {
250
+ readonly kind: "data_only";
251
+ } | {
252
+ readonly kind: "fixed_page";
253
+ readonly path: string;
254
+ } | {
255
+ readonly kind: "detail";
256
+ readonly detailPath: string;
257
+ } | {
258
+ readonly kind: "category_tree";
259
+ readonly basePath: string;
260
+ readonly categoryDepth: number;
261
+ };
262
+ interface PublicPathPost {
263
+ readonly slug: string;
264
+ readonly collectionKey?: string | null;
265
+ readonly modelKey?: string | null;
266
+ readonly terms: ReadonlyArray<{
267
+ readonly id: string;
268
+ readonly taxonomy: string;
269
+ readonly slug: string;
270
+ }>;
271
+ }
272
+ interface PublicPathContext {
273
+ /** 글의 모델 presentation. 모델 글이 아니거나 모델을 못 찾으면 null. */
274
+ readonly presentation: PublicPathPresentation | null;
275
+ /** 모델의 호환 컬렉션 key(`compatibilityCollectionKey`, 미지정이면 모델 key). */
276
+ readonly compatibilityCollectionKey?: string | null;
277
+ readonly collections: readonly RouteCollection[];
278
+ readonly categories: readonly CategoryTreeTerm[];
279
+ }
280
+ declare const LEGACY_BLOG_DETAIL_PATH = "/blog";
281
+ /** 글의 정규 공개 경로(origin 제외). 상세 주소가 없으면 null. */
282
+ declare function resolvePostPublicPath(post: PublicPathPost, context: PublicPathContext): string | null;
283
+
236
284
  interface ClientHydrationSpec {
237
285
  hydration?: "visible" | "idle" | "load" | "media" | "only";
238
286
  module?: string;
@@ -334,6 +382,58 @@ declare function ensureImportedHtmlDocumentRoots(html: string, allowedAssetUrls?
334
382
  /** 저장된 안전 CSS가 같은 importedHtml 블록 밖으로 새지 않도록 범위를 고정한다. */
335
383
  declare function scopeImportedCss(css: string, scope: string, allowedAssetUrls?: readonly string[]): string;
336
384
 
385
+ declare const INTERNAL_CONTENT_LINK_TOKEN_SOURCE: string;
386
+ interface InternalContentLinkToken {
387
+ /** 토큰이 시작하는 문자 인덱스(텍스트 기준). */
388
+ readonly index: number;
389
+ /** 원문 토큰 전체(`[[internal:…|…]]`). */
390
+ readonly raw: string;
391
+ /** 소문자로 정규화한 키. */
392
+ readonly key: string;
393
+ /** 표시 문구(앞뒤 공백 제거). */
394
+ readonly label: string;
395
+ }
396
+ /** 텍스트 안의 토큰을 앞에서부터 모두 찾는다. 겹치지 않는다. */
397
+ declare function findInternalContentLinkTokens(text: string): InternalContentLinkToken[];
398
+ /** 공개 경로(`/faq/a/b/slug`) → 키(`faq.a.b.slug`). 조각이 없으면 null. */
399
+ declare function internalContentKeyFromPath(path: string | null | undefined): string | null;
400
+ /** 키 → 공개 경로. 없으면 null(문구만 표시). */
401
+ type InternalContentLinkResolver = (key: string) => string | null;
402
+ interface InternalContentPathEntry {
403
+ /** 저장된 정규 공개 경로(`/faq/a/b/slug`). 없으면 대상이 아니다. */
404
+ readonly path?: string | null;
405
+ /** 옛 slug 목록 — 옛 키로 남은 본문도 현재 주소로 이어 준다. */
406
+ readonly previousSlugs?: readonly string[] | null;
407
+ }
408
+ /**
409
+ * 발행 글 목록에서 "키 → 현재 경로" 색인을 만든다. 옛 slug 도 같은 글로 등록한다
410
+ * (경로 마지막 조각을 옛 slug 로 바꾼 키). 현재 경로가 옛 키와 겹치면 현재가 이긴다.
411
+ */
412
+ declare function internalContentPathIndex(entries: Iterable<InternalContentPathEntry>): Map<string, string>;
413
+ /** Map 이나 함수 어느 쪽이든 resolver 로. */
414
+ declare function internalContentLinkResolverFrom(source: InternalContentLinkResolver | ReadonlyMap<string, string> | null | undefined): InternalContentLinkResolver;
415
+ /** 링크로 렌더된 토큰의 class — 사이트 CSS 가 잡을 고리. */
416
+ declare const INTERNAL_CONTENT_LINK_CLASS = "rt-internal-link";
417
+ /** 대상이 아직 없어 문구만 남긴 토큰의 class·data 속성. */
418
+ declare const INTERNAL_CONTENT_LINK_PENDING_CLASS = "rt-internal-link--pending";
419
+ declare const INTERNAL_CONTENT_LINK_PENDING_ATTR = "data-rt-internal-link-pending";
420
+ /**
421
+ * 이미 이스케이프된 텍스트 한 구간의 토큰을 HTML 로 바꾼다. 텍스트 부분은 다시
422
+ * 이스케이프하지 않는다(정화기가 이미 처리한 값). 토큰이 없으면 원문 그대로.
423
+ */
424
+ declare function renderInternalContentLinksInText(text: string, resolve: InternalContentLinkResolver): {
425
+ readonly html: string;
426
+ readonly hasTokens: boolean;
427
+ };
428
+ /**
429
+ * 정화된 HTML(원문 보존 블록 등)의 텍스트 구간에만 토큰을 적용한다. `<a>`·`<code>`·
430
+ * `<pre>` 안과 태그 속성값은 건드리지 않는다.
431
+ */
432
+ declare function renderInternalContentLinksInHtml(html: string, resolve: InternalContentLinkResolver): {
433
+ readonly html: string;
434
+ readonly hasTokens: boolean;
435
+ };
436
+
337
437
  interface PreviewTokenPayload {
338
438
  postId: string;
339
439
  expiresAt: Date;
@@ -371,4 +471,77 @@ declare function injectStableIdsTree(blocks: readonly (Omit<Block, "_id"> & {
371
471
  _id?: string;
372
472
  })[]): Block[];
373
473
 
374
- export { BLOCK_NAME_PATTERN, type BindingResolver, type Block, type BlockBinding, type BlockDefinition, type BlockRegistry, type CategoryTreeEntry, type CategoryTreePresentation, type CategoryTreeTerm, type ClientHydrationSpec, type EmbedProvider, FIELD_BINDING_SOURCE, FIELD_BINDING_SOURCE_ALIAS, type FaqEntry, IMAGE_ALT_MAX_LENGTH, type NormalizedEmbed, PHASE_1_CORE_BLOCKS, PHASE_1_CSP, type Phase1CoreBlockName, type PreviewTokenPayload, type RoutablePost, type RouteCollection, applyBlockBindings, bindingSrcValue, bindingTextValue, blockSchema, boundFieldValue, chainResolvers, createFieldBindingResolver, ensureImportedHtmlDocumentRoots, ensureStableIds, extractFaqEntries, faqPageJsonLd, htmlToPlainText, injectStableIdsTree, isAllowedEmbedSrc, isAllowedMapEmbedSrc, isInCollectionMode, isValidBlock, issuePreviewToken, normalizeEmbed, normalizeImageAlt, parseBlock, postsForCollection, postsInAnyCollection, postsNotInAnyCollection, resolveCategoryPath, resolveCategoryTreeChain, resolveCategoryTreeEntryPath, resolveCategoryTreeHubPaths, resolvePostCategorySlug, resolvePostCollection, resolvePostPath, resolvePostUrl, sanitizeHtml, sanitizeImportedCss, sanitizeImportedHtml, scopeImportedCss, serializeBlock, validateCollections, verifyPreviewToken };
474
+ /**
475
+ * 공통 블록(Site Patterns) — 여러 글에 같은 자리로 붙는 재사용 블록의 순수 규칙.
476
+ *
477
+ * 블록 본문은 ROOT-ADMIN 이 `site_patterns` 에 저장하고, "어느 자리(slot)에 어느
478
+ * 유형(collection)의 글이면 어떤 블록"인지는 배치 규칙(`settings.site_pattern_placements`)
479
+ * 으로 정한다. 공개 API 는 글마다 `pattern_slots`(자리 → 블록 key | null) 를 계산해
480
+ * 내려주므로 FRONT 는 규칙을 몰라도 된다. 이 파일은 api-core(계산)·tenant-admin(편집)·
481
+ * cms-renderer-next(렌더)가 같은 판정을 공유하기 위한 프레임워크 비의존 모듈이다.
482
+ *
483
+ * 규칙 판정:
484
+ * - 자리는 `SITE_PATTERN_SLOTS` 에 선언된 것만 계산한다(미선언 자리는 무시).
485
+ * - 글의 `collectionKey` 와 같은 규칙이 있으면 그 규칙(블록 없음 = null 도 명시적 결정).
486
+ * - 없으면 `collectionKey: null`(모든 글 기본) 규칙.
487
+ * - 가리키는 블록이 발행 상태가 아니면 null(FRONT 가 미발행 블록을 그리지 않게).
488
+ */
489
+ /** 블록을 놓을 수 있는 자리. key 는 공개 API `pattern_slots` 의 키와 같다. */
490
+ declare const SITE_PATTERN_SLOTS: readonly [{
491
+ readonly key: "post_footer";
492
+ readonly label: "글 하단";
493
+ readonly description: "글 본문 바로 아래";
494
+ }];
495
+ type SitePatternSlotKey = (typeof SITE_PATTERN_SLOTS)[number]["key"];
496
+ declare const POST_FOOTER_SLOT: SitePatternSlotKey;
497
+ /** 배치 규칙을 담는 `settings` 키. */
498
+ declare const SITE_PATTERN_PLACEMENTS_KEY = "site_pattern_placements";
499
+ /** 블록 key 형식 — 소문자·숫자·`-`·`_`, 64자 이하, 영숫자로 시작. */
500
+ declare const SITE_PATTERN_KEY_PATTERN: RegExp;
501
+ declare function isValidSitePatternKey(key: string): boolean;
502
+ declare function isSitePatternSlotKey(value: string): value is SitePatternSlotKey;
503
+ /**
504
+ * 배치 규칙 1건. `collectionKey: null` = 모든 글의 기본값, 문자열 = 그 유형의 글만.
505
+ * `patternKey: null` = 이 자리에 블록을 놓지 않는다(유형 규칙이면 기본값 덮어쓰기).
506
+ */
507
+ interface SitePatternPlacementRule {
508
+ readonly slot: SitePatternSlotKey;
509
+ readonly collectionKey: string | null;
510
+ readonly patternKey: string | null;
511
+ }
512
+ interface SitePatternPlacements {
513
+ readonly rules: readonly SitePatternPlacementRule[];
514
+ }
515
+ declare const EMPTY_SITE_PATTERN_PLACEMENTS: SitePatternPlacements;
516
+ /** 글 1건의 자리별 블록 key. 선언된 모든 자리를 키로 가진다(없으면 null). */
517
+ type PatternSlots = Record<string, string | null>;
518
+ /**
519
+ * 저장된 값(unknown) → 정규화된 배치 규칙. 형식이 틀린 항목·미선언 자리는 버리고,
520
+ * 같은 (slot, collectionKey) 는 마지막 항목이 이긴다. 이중 인코딩된 JSON 문자열도 받는다.
521
+ */
522
+ declare function readSitePatternPlacements(raw: unknown): SitePatternPlacements;
523
+ /** (slot, collectionKey) 에 해당하는 규칙. 없으면 undefined(= 기본값으로 위임). */
524
+ declare function findSitePatternPlacementRule(placements: SitePatternPlacements, slot: SitePatternSlotKey, collectionKey: string | null): SitePatternPlacementRule | undefined;
525
+ /**
526
+ * 규칙 1건을 갈아 끼운 새 배치 규칙을 돌려준다(불변). `patternKey: undefined` 는
527
+ * "규칙 삭제 = 기본값으로 위임"이다 — 유형 규칙에서 "표시 안 함"(null)과 구분된다.
528
+ */
529
+ declare function setSitePatternPlacementRule(placements: SitePatternPlacements, target: {
530
+ slot: SitePatternSlotKey;
531
+ collectionKey: string | null;
532
+ }, patternKey: string | null | undefined): SitePatternPlacements;
533
+ /** 선언된 자리마다 null 인 빈 결과 — 규칙이나 발행 블록이 없을 때의 기본 응답. */
534
+ declare function emptyPatternSlots(): PatternSlots;
535
+ /**
536
+ * 글 1건의 자리별 블록 key 를 계산한다. `publishedKeys` 에 없는 블록(미발행·삭제)은 null.
537
+ */
538
+ declare function resolvePatternSlots(post: {
539
+ readonly collectionKey: string | null;
540
+ }, placements: SitePatternPlacements, publishedKeys: ReadonlySet<string>): PatternSlots;
541
+ /**
542
+ * 규칙에서 참조하는 블록 key 집합 — 어드민이 "이 블록은 어디에 쓰이는가"를 표시하거나
543
+ * 삭제 전 경고할 때 쓴다.
544
+ */
545
+ declare function referencedSitePatternKeys(placements: SitePatternPlacements): ReadonlySet<string>;
546
+
547
+ export { BLOCK_NAME_PATTERN, type BindingResolver, type Block, type BlockBinding, type BlockDefinition, type BlockRegistry, type CategoryTreeEntry, type CategoryTreePresentation, type CategoryTreeTerm, type ClientHydrationSpec, EMPTY_SITE_PATTERN_PLACEMENTS, type EmbedProvider, FIELD_BINDING_SOURCE, FIELD_BINDING_SOURCE_ALIAS, type FaqEntry, IMAGE_ALT_MAX_LENGTH, INTERNAL_CONTENT_LINK_CLASS, INTERNAL_CONTENT_LINK_PENDING_ATTR, INTERNAL_CONTENT_LINK_PENDING_CLASS, INTERNAL_CONTENT_LINK_TOKEN_SOURCE, type InternalContentLinkResolver, type InternalContentLinkToken, LEGACY_BLOG_DETAIL_PATH, type NormalizedEmbed, PHASE_1_CORE_BLOCKS, PHASE_1_CSP, POST_FOOTER_SLOT, type PatternSlots, type Phase1CoreBlockName, type PreviewTokenPayload, type PublicPathContext, type PublicPathPost, type PublicPathPresentation, type RoutablePost, type RouteCollection, SITE_PATTERN_KEY_PATTERN, SITE_PATTERN_PLACEMENTS_KEY, SITE_PATTERN_SLOTS, type SitePatternPlacementRule, type SitePatternPlacements, type SitePatternSlotKey, applyBlockBindings, bindingSrcValue, bindingTextValue, blockSchema, boundFieldValue, chainResolvers, createFieldBindingResolver, emptyPatternSlots, ensureImportedHtmlDocumentRoots, ensureStableIds, extractFaqEntries, faqPageJsonLd, findInternalContentLinkTokens, findSitePatternPlacementRule, htmlToPlainText, injectStableIdsTree, internalContentKeyFromPath, internalContentLinkResolverFrom, internalContentPathIndex, isAllowedEmbedSrc, isAllowedMapEmbedSrc, isInCollectionMode, isSitePatternSlotKey, isValidBlock, isValidSitePatternKey, issuePreviewToken, normalizeEmbed, normalizeImageAlt, parseBlock, postsForCollection, postsInAnyCollection, postsNotInAnyCollection, readSitePatternPlacements, referencedSitePatternKeys, renderInternalContentLinksInHtml, renderInternalContentLinksInText, resolveCategoryPath, resolveCategoryTreeChain, resolveCategoryTreeEntryPath, resolveCategoryTreeHubPaths, resolvePatternSlots, resolvePostCategorySlug, resolvePostCollection, resolvePostPath, resolvePostPublicPath, resolvePostUrl, sanitizeHtml, sanitizeImportedCss, sanitizeImportedHtml, scopeImportedCss, serializeBlock, setSitePatternPlacementRule, validateCollections, verifyPreviewToken };