@roottale/cms-core 0.77.1 → 0.78.1
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/CHANGELOG.md +8 -0
- package/dist/index.cjs +86 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -11770,4 +11770,37 @@ declare function isProtectedRedirectPath(path: string): boolean;
|
|
|
11770
11770
|
declare function normalizeRedirectSource(raw: string): NormalizedRedirectSourceResult;
|
|
11771
11771
|
declare function normalizeRedirectTarget(raw: string): NormalizedRedirectTargetResult;
|
|
11772
11772
|
|
|
11773
|
-
|
|
11773
|
+
interface SiteFileScope {
|
|
11774
|
+
tenantId: string;
|
|
11775
|
+
siteId: string;
|
|
11776
|
+
}
|
|
11777
|
+
/** 현재 고객·사이트의 저장된 PDF만 고객 사이트 경로로 투영한다. */
|
|
11778
|
+
declare function siteFilePathFromKey(key: string, scope: SiteFileScope): string | null;
|
|
11779
|
+
/** 호스트를 고정하지 않고 저장소 URL의 경로를 현재 범위로 검증한다. */
|
|
11780
|
+
declare function siteFilePathFromUrl(url: string, scope: SiteFileScope): string | null;
|
|
11781
|
+
declare function siteFileRewrites({ tenantId, siteId, storageBaseUrl, }: SiteFileScope & {
|
|
11782
|
+
storageBaseUrl?: string;
|
|
11783
|
+
}): {
|
|
11784
|
+
source: string;
|
|
11785
|
+
destination: string;
|
|
11786
|
+
}[];
|
|
11787
|
+
declare function siteFileHeaders(): ({
|
|
11788
|
+
source: string;
|
|
11789
|
+
headers: {
|
|
11790
|
+
key: string;
|
|
11791
|
+
value: string;
|
|
11792
|
+
}[];
|
|
11793
|
+
has?: undefined;
|
|
11794
|
+
} | {
|
|
11795
|
+
source: string;
|
|
11796
|
+
has: {
|
|
11797
|
+
type: "host";
|
|
11798
|
+
value: string;
|
|
11799
|
+
}[];
|
|
11800
|
+
headers: {
|
|
11801
|
+
key: string;
|
|
11802
|
+
value: string;
|
|
11803
|
+
}[];
|
|
11804
|
+
})[];
|
|
11805
|
+
|
|
11806
|
+
export { BLOCK_NAME_PATTERN, type BindingResolver, type Block, type BlockBinding, type BlockDefinition, type BlockRegistry, CMS_FONT_SIZES, CMS_IMAGE_WIDTHS, CMS_LINE_HEIGHTS, CMS_PARAGRAPH_SPACINGS, type CategoryTreeEntry, type CategoryTreeEntryCategory, type CategoryTreeEntryResolution, type CategoryTreePresentation, type CategoryTreeTerm, type ClientHydrationSpec, type ContentCandidate, type ContentCtaHiddenReason, type ContentCtaMode, type ContentCtaOptions, type ContentCtaResult, type ContentDependencyChange, type ContentDependencyEntity, type ContentPathDependency, type ContentPolicy, type ContentPolicyCheck, ContentPolicyCheckSchema, ContentPolicyFieldNameSchema, type ContentPolicyFieldRef, ContentPolicyInternalPathSchema, type ContentPolicyOptions, type ContentPolicyPost, type ContentPolicyResult, type ContentPolicyScalarCheck, ContentPolicyScalarCheckSchema, ContentPolicyScalarSchema, ContentPolicySchema, ContentPolicyWhenSchema, type ContentQuery, type ContentQueryCandidate, type ContentQueryDependency, ContentQueryFilterSchema, type ContentQueryOptions, type ContentQueryResult, ContentQuerySchema, type ContentScope, DEFAULT_SITE_PATTERN_PRESENTATION, 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, METADATA_FIELDS, type MetadataDefaultRules, MetadataDefaultRulesSchema, type MetadataDefaultsDeclaration, type MetadataDefaultsInput, type MetadataField, MetadataFieldSchema, type MetadataPatch, MetadataPatchSchema, type MetadataResolutionInput, type MetadataRobotsPolicy, MetadataRobotsPolicySchema, type MetadataTarget, type MetadataTargetKind, MetadataTargetKindSchema, type MetadataTextRule, MetadataTextRuleSchema, type MetadataValues, MetadataValuesSchema, type NormalizedEmbed, type NormalizedRedirectSourceResult, type NormalizedRedirectTargetResult, PHASE_1_CORE_BLOCKS, PHASE_1_CSP, POST_FOOTER_SLOT, type PatternSlots, type Phase1CoreBlockName, type PostBodySource, type PreviewTokenPayload, type ProfileQualificationInput, type ProfileQualificationProperties, type PublicPathContext, type PublicPathPost, type PublicPathPresentation, type PublicRouteMetadata, type RelatedContentGroup, type RelatedContentOptions, type RoutablePost, type RouteCollection, SITE_PATTERN_BUTTON_COLORS_MAX, SITE_PATTERN_KEY_PATTERN, SITE_PATTERN_PLACEMENTS_KEY, SITE_PATTERN_SLOTS, type SectionLock, type SectionLockViolation, type SectionLockViolationCode, type SiteFileScope, type SitePatternLayout, type SitePatternLinkStyle, type SitePatternPlacementRule, type SitePatternPlacements, type SitePatternPresentation, type SitePatternSlotKey, type VisibleFaqCandidate, type VisibleFaqEntry, applyBlockBindings, bindingSrcValue, bindingTextValue, blockSchema, boundFieldValue, chainResolvers, cmsFontSize, cmsImageAlign, cmsImageStyle, cmsImageWidth, cmsLineHeight, cmsParagraphSpacing, collectContentPolicyFieldRefs, collectContentQueryFieldRefs, collectMetadataDefaultFieldRefs, contentPolicyBodyText, contentPolicySafeHttpsUrl, createFieldBindingResolver, emptyPatternSlots, ensureImportedHtmlDocumentRoots, ensureStableIds, evaluateContentPolicy, evaluateContentQuery, extractFaqEntries, faqPageJsonLd, findInternalContentLinkTokens, findSectionLockViolations, findSitePatternPlacementRule, formatMetadataDefaults, formatSectionLockViolations, getContentValue, htmlToPlainText, injectStableIdsTree, internalContentKeyFromPath, internalContentLinkResolverFrom, internalContentPathIndex, isAllowedEmbedSrc, isAllowedMapEmbedSrc, isInCollectionMode, isProtectedRedirectPath, isReservedCategoryTreeSlug, isSectionContentPropPath, isSitePatternSlotKey, isValidBlock, isValidSitePatternKey, issuePreviewToken, matchesContentScalarCheck, mergeMetadataPatch, metadataBodyParagraphs, metadataContentImageUrl, metadataVideoThumbnail, normalizeEmbed, normalizeHexColor, normalizeImageAlt, normalizeRedirectPath, normalizeRedirectSource, normalizeRedirectTarget, parseBlock, postsForCollection, postsInAnyCollection, postsNotInAnyCollection, profileQualificationJsonLdProperties, readMetadataValues, readSitePatternPlacements, readSitePatternPresentation, referencedSitePatternKeys, renderInternalContentLinksInHtml, renderInternalContentLinksInText, resolveCategoryPath, resolveCategoryTreeChain, resolveCategoryTreeEntryCategory, resolveCategoryTreeEntryPath, resolveCategoryTreeHubPaths, resolveCategoryTreeSelection, resolveContentCta, resolveContentDependencyPaths, resolveMetadata, resolvePatternSlots, resolvePostBodySource, resolvePostCategorySlug, resolvePostCollection, resolvePostPath, resolvePostPublicPath, resolvePostUrl, sanitizeHtml, sanitizeImportedCss, sanitizeImportedHtml, scopeImportedCss, selectContentQuery, selectRelatedContent, selectVisibleFaqEntries, serializeBlock, setContentValue, setSitePatternPlacementRule, siteFileHeaders, siteFilePathFromKey, siteFilePathFromUrl, siteFileRewrites, sitePatternButtonColor, sitePatternPresentationAttributes, validateCollections, verifyPreviewToken, visibleFaqPageJsonLd };
|
package/dist/index.d.ts
CHANGED
|
@@ -11770,4 +11770,37 @@ declare function isProtectedRedirectPath(path: string): boolean;
|
|
|
11770
11770
|
declare function normalizeRedirectSource(raw: string): NormalizedRedirectSourceResult;
|
|
11771
11771
|
declare function normalizeRedirectTarget(raw: string): NormalizedRedirectTargetResult;
|
|
11772
11772
|
|
|
11773
|
-
|
|
11773
|
+
interface SiteFileScope {
|
|
11774
|
+
tenantId: string;
|
|
11775
|
+
siteId: string;
|
|
11776
|
+
}
|
|
11777
|
+
/** 현재 고객·사이트의 저장된 PDF만 고객 사이트 경로로 투영한다. */
|
|
11778
|
+
declare function siteFilePathFromKey(key: string, scope: SiteFileScope): string | null;
|
|
11779
|
+
/** 호스트를 고정하지 않고 저장소 URL의 경로를 현재 범위로 검증한다. */
|
|
11780
|
+
declare function siteFilePathFromUrl(url: string, scope: SiteFileScope): string | null;
|
|
11781
|
+
declare function siteFileRewrites({ tenantId, siteId, storageBaseUrl, }: SiteFileScope & {
|
|
11782
|
+
storageBaseUrl?: string;
|
|
11783
|
+
}): {
|
|
11784
|
+
source: string;
|
|
11785
|
+
destination: string;
|
|
11786
|
+
}[];
|
|
11787
|
+
declare function siteFileHeaders(): ({
|
|
11788
|
+
source: string;
|
|
11789
|
+
headers: {
|
|
11790
|
+
key: string;
|
|
11791
|
+
value: string;
|
|
11792
|
+
}[];
|
|
11793
|
+
has?: undefined;
|
|
11794
|
+
} | {
|
|
11795
|
+
source: string;
|
|
11796
|
+
has: {
|
|
11797
|
+
type: "host";
|
|
11798
|
+
value: string;
|
|
11799
|
+
}[];
|
|
11800
|
+
headers: {
|
|
11801
|
+
key: string;
|
|
11802
|
+
value: string;
|
|
11803
|
+
}[];
|
|
11804
|
+
})[];
|
|
11805
|
+
|
|
11806
|
+
export { BLOCK_NAME_PATTERN, type BindingResolver, type Block, type BlockBinding, type BlockDefinition, type BlockRegistry, CMS_FONT_SIZES, CMS_IMAGE_WIDTHS, CMS_LINE_HEIGHTS, CMS_PARAGRAPH_SPACINGS, type CategoryTreeEntry, type CategoryTreeEntryCategory, type CategoryTreeEntryResolution, type CategoryTreePresentation, type CategoryTreeTerm, type ClientHydrationSpec, type ContentCandidate, type ContentCtaHiddenReason, type ContentCtaMode, type ContentCtaOptions, type ContentCtaResult, type ContentDependencyChange, type ContentDependencyEntity, type ContentPathDependency, type ContentPolicy, type ContentPolicyCheck, ContentPolicyCheckSchema, ContentPolicyFieldNameSchema, type ContentPolicyFieldRef, ContentPolicyInternalPathSchema, type ContentPolicyOptions, type ContentPolicyPost, type ContentPolicyResult, type ContentPolicyScalarCheck, ContentPolicyScalarCheckSchema, ContentPolicyScalarSchema, ContentPolicySchema, ContentPolicyWhenSchema, type ContentQuery, type ContentQueryCandidate, type ContentQueryDependency, ContentQueryFilterSchema, type ContentQueryOptions, type ContentQueryResult, ContentQuerySchema, type ContentScope, DEFAULT_SITE_PATTERN_PRESENTATION, 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, METADATA_FIELDS, type MetadataDefaultRules, MetadataDefaultRulesSchema, type MetadataDefaultsDeclaration, type MetadataDefaultsInput, type MetadataField, MetadataFieldSchema, type MetadataPatch, MetadataPatchSchema, type MetadataResolutionInput, type MetadataRobotsPolicy, MetadataRobotsPolicySchema, type MetadataTarget, type MetadataTargetKind, MetadataTargetKindSchema, type MetadataTextRule, MetadataTextRuleSchema, type MetadataValues, MetadataValuesSchema, type NormalizedEmbed, type NormalizedRedirectSourceResult, type NormalizedRedirectTargetResult, PHASE_1_CORE_BLOCKS, PHASE_1_CSP, POST_FOOTER_SLOT, type PatternSlots, type Phase1CoreBlockName, type PostBodySource, type PreviewTokenPayload, type ProfileQualificationInput, type ProfileQualificationProperties, type PublicPathContext, type PublicPathPost, type PublicPathPresentation, type PublicRouteMetadata, type RelatedContentGroup, type RelatedContentOptions, type RoutablePost, type RouteCollection, SITE_PATTERN_BUTTON_COLORS_MAX, SITE_PATTERN_KEY_PATTERN, SITE_PATTERN_PLACEMENTS_KEY, SITE_PATTERN_SLOTS, type SectionLock, type SectionLockViolation, type SectionLockViolationCode, type SiteFileScope, type SitePatternLayout, type SitePatternLinkStyle, type SitePatternPlacementRule, type SitePatternPlacements, type SitePatternPresentation, type SitePatternSlotKey, type VisibleFaqCandidate, type VisibleFaqEntry, applyBlockBindings, bindingSrcValue, bindingTextValue, blockSchema, boundFieldValue, chainResolvers, cmsFontSize, cmsImageAlign, cmsImageStyle, cmsImageWidth, cmsLineHeight, cmsParagraphSpacing, collectContentPolicyFieldRefs, collectContentQueryFieldRefs, collectMetadataDefaultFieldRefs, contentPolicyBodyText, contentPolicySafeHttpsUrl, createFieldBindingResolver, emptyPatternSlots, ensureImportedHtmlDocumentRoots, ensureStableIds, evaluateContentPolicy, evaluateContentQuery, extractFaqEntries, faqPageJsonLd, findInternalContentLinkTokens, findSectionLockViolations, findSitePatternPlacementRule, formatMetadataDefaults, formatSectionLockViolations, getContentValue, htmlToPlainText, injectStableIdsTree, internalContentKeyFromPath, internalContentLinkResolverFrom, internalContentPathIndex, isAllowedEmbedSrc, isAllowedMapEmbedSrc, isInCollectionMode, isProtectedRedirectPath, isReservedCategoryTreeSlug, isSectionContentPropPath, isSitePatternSlotKey, isValidBlock, isValidSitePatternKey, issuePreviewToken, matchesContentScalarCheck, mergeMetadataPatch, metadataBodyParagraphs, metadataContentImageUrl, metadataVideoThumbnail, normalizeEmbed, normalizeHexColor, normalizeImageAlt, normalizeRedirectPath, normalizeRedirectSource, normalizeRedirectTarget, parseBlock, postsForCollection, postsInAnyCollection, postsNotInAnyCollection, profileQualificationJsonLdProperties, readMetadataValues, readSitePatternPlacements, readSitePatternPresentation, referencedSitePatternKeys, renderInternalContentLinksInHtml, renderInternalContentLinksInText, resolveCategoryPath, resolveCategoryTreeChain, resolveCategoryTreeEntryCategory, resolveCategoryTreeEntryPath, resolveCategoryTreeHubPaths, resolveCategoryTreeSelection, resolveContentCta, resolveContentDependencyPaths, resolveMetadata, resolvePatternSlots, resolvePostBodySource, resolvePostCategorySlug, resolvePostCollection, resolvePostPath, resolvePostPublicPath, resolvePostUrl, sanitizeHtml, sanitizeImportedCss, sanitizeImportedHtml, scopeImportedCss, selectContentQuery, selectRelatedContent, selectVisibleFaqEntries, serializeBlock, setContentValue, setSitePatternPlacementRule, siteFileHeaders, siteFilePathFromKey, siteFilePathFromUrl, siteFileRewrites, sitePatternButtonColor, sitePatternPresentationAttributes, validateCollections, verifyPreviewToken, visibleFaqPageJsonLd };
|
package/dist/index.js
CHANGED
|
@@ -2729,6 +2729,84 @@ function normalizeRedirectTarget(raw) {
|
|
|
2729
2729
|
return invalid;
|
|
2730
2730
|
}
|
|
2731
2731
|
}
|
|
2732
|
+
|
|
2733
|
+
// src/site-files.ts
|
|
2734
|
+
import { z as z8 } from "zod";
|
|
2735
|
+
function encodeFilename(name) {
|
|
2736
|
+
return encodeURIComponent(name).replace(
|
|
2737
|
+
/[!'()*]/g,
|
|
2738
|
+
(character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
|
|
2739
|
+
);
|
|
2740
|
+
}
|
|
2741
|
+
function siteFilePathFromKey(key, scope) {
|
|
2742
|
+
if (key.includes("..") || key.includes("\\")) return null;
|
|
2743
|
+
const sitePrefix = `tenants/${scope.tenantId}/sites/${scope.siteId}/media/`;
|
|
2744
|
+
const tenantPrefix = `tenants/${scope.tenantId}/media/`;
|
|
2745
|
+
let path;
|
|
2746
|
+
let name;
|
|
2747
|
+
if (key.startsWith(sitePrefix)) {
|
|
2748
|
+
const parts = key.slice(sitePrefix.length).split("/");
|
|
2749
|
+
if (parts.length === 3 && parts[0] === "originals" && /^[a-f0-9]{64}$/.test(parts[1])) {
|
|
2750
|
+
name = parts[2];
|
|
2751
|
+
path = `/files/${parts[1]}/`;
|
|
2752
|
+
} else if (parts.length === 1) {
|
|
2753
|
+
name = parts[0];
|
|
2754
|
+
path = "/files/";
|
|
2755
|
+
} else return null;
|
|
2756
|
+
} else if (key.startsWith(tenantPrefix)) {
|
|
2757
|
+
name = key.slice(tenantPrefix.length);
|
|
2758
|
+
path = "/files/t/";
|
|
2759
|
+
} else return null;
|
|
2760
|
+
if (!/^[\p{L}\p{N}._~-]+\.pdf$/u.test(name)) return null;
|
|
2761
|
+
try {
|
|
2762
|
+
return path + encodeFilename(name);
|
|
2763
|
+
} catch {
|
|
2764
|
+
return null;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
function siteFilePathFromUrl(url, scope) {
|
|
2768
|
+
try {
|
|
2769
|
+
const parsed = new URL(url);
|
|
2770
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
|
|
2771
|
+
const rawPath = /^https?:\/\/[^/?#]*(\/[^?#]*)?/i.exec(url)?.[1];
|
|
2772
|
+
if (!rawPath || decodeURIComponent(rawPath).includes("..") || rawPath.includes("\\")) return null;
|
|
2773
|
+
const key = decodeURIComponent(parsed.pathname.slice(1));
|
|
2774
|
+
return siteFilePathFromKey(key, scope);
|
|
2775
|
+
} catch {
|
|
2776
|
+
return null;
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
function siteFileRewrites({
|
|
2780
|
+
tenantId,
|
|
2781
|
+
siteId,
|
|
2782
|
+
storageBaseUrl = "https://root-cdn.com"
|
|
2783
|
+
}) {
|
|
2784
|
+
const uuid = z8.string().uuid();
|
|
2785
|
+
if (!uuid.safeParse(tenantId).success || !uuid.safeParse(siteId).success) {
|
|
2786
|
+
throw new Error("Site file scope requires UUID tenantId and siteId");
|
|
2787
|
+
}
|
|
2788
|
+
const base = storageBaseUrl.replace(/\/+$/, "");
|
|
2789
|
+
const media = `${base}/tenants/${tenantId}/sites/${siteId}/media`;
|
|
2790
|
+
const name = ":name((?:[^/%\\\\]|%[89a-fA-F][0-9a-fA-F])+\\.pdf)";
|
|
2791
|
+
return [
|
|
2792
|
+
{ source: `/files/t/${name}`, destination: `${base}/tenants/${tenantId}/media/:name` },
|
|
2793
|
+
{ source: `/files/${name}`, destination: `${media}/:name` },
|
|
2794
|
+
{ source: `/files/:hash([a-f0-9]{64})/${name}`, destination: `${media}/originals/:hash/:name` }
|
|
2795
|
+
];
|
|
2796
|
+
}
|
|
2797
|
+
function siteFileHeaders() {
|
|
2798
|
+
return [
|
|
2799
|
+
{
|
|
2800
|
+
source: "/files/:path*",
|
|
2801
|
+
headers: [{ key: "x-vercel-enable-rewrite-caching", value: "0" }]
|
|
2802
|
+
},
|
|
2803
|
+
{
|
|
2804
|
+
source: "/files/:path*",
|
|
2805
|
+
has: [{ type: "host", value: ".+\\.roottale\\.app" }],
|
|
2806
|
+
headers: [{ key: "X-Robots-Tag", value: "noindex" }]
|
|
2807
|
+
}
|
|
2808
|
+
];
|
|
2809
|
+
}
|
|
2732
2810
|
export {
|
|
2733
2811
|
BLOCK_NAME_PATTERN,
|
|
2734
2812
|
CMS_FONT_SIZES,
|
|
@@ -2872,6 +2950,10 @@ export {
|
|
|
2872
2950
|
serializeBlock,
|
|
2873
2951
|
setContentValue,
|
|
2874
2952
|
setSitePatternPlacementRule,
|
|
2953
|
+
siteFileHeaders,
|
|
2954
|
+
siteFilePathFromKey,
|
|
2955
|
+
siteFilePathFromUrl,
|
|
2956
|
+
siteFileRewrites,
|
|
2875
2957
|
sitePatternButtonColor,
|
|
2876
2958
|
sitePatternPresentationAttributes,
|
|
2877
2959
|
validateCollections,
|