@roottale/cms-core 0.77.0 → 0.78.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/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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @roottale/cms-core
|
|
2
2
|
|
|
3
|
+
## 0.78.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ef30690: PDF를 고객 사이트의 /files/ 주소로 여는 순수 URL 함수와 Next.js rewrite·응답 헤더를 추가합니다. 기존 저장소 주소는 유지하며 PDF 프록시의 Vercel 캐시와 미리보기 주소의 색인을 막습니다. 공개 site-files subpath와 외부 연동 예시를 제공합니다.
|
|
8
|
+
|
|
9
|
+
## 0.77.1
|
|
10
|
+
|
|
3
11
|
## 0.77.0
|
|
4
12
|
|
|
5
13
|
## 0.76.2
|
package/dist/index.cjs
CHANGED
|
@@ -172,6 +172,10 @@ __export(src_exports, {
|
|
|
172
172
|
serializeBlock: () => serializeBlock,
|
|
173
173
|
setContentValue: () => setContentValue,
|
|
174
174
|
setSitePatternPlacementRule: () => setSitePatternPlacementRule,
|
|
175
|
+
siteFileHeaders: () => siteFileHeaders,
|
|
176
|
+
siteFilePathFromKey: () => siteFilePathFromKey,
|
|
177
|
+
siteFilePathFromUrl: () => siteFilePathFromUrl,
|
|
178
|
+
siteFileRewrites: () => siteFileRewrites,
|
|
175
179
|
sitePatternButtonColor: () => sitePatternButtonColor,
|
|
176
180
|
sitePatternPresentationAttributes: () => sitePatternPresentationAttributes,
|
|
177
181
|
validateCollections: () => validateCollections,
|
|
@@ -3075,6 +3079,84 @@ function normalizeRedirectTarget(raw) {
|
|
|
3075
3079
|
return invalid;
|
|
3076
3080
|
}
|
|
3077
3081
|
}
|
|
3082
|
+
|
|
3083
|
+
// src/site-files.ts
|
|
3084
|
+
var import_zod10 = require("zod");
|
|
3085
|
+
function encodeFilename(name) {
|
|
3086
|
+
return encodeURIComponent(name).replace(
|
|
3087
|
+
/[!'()*]/g,
|
|
3088
|
+
(character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
|
|
3089
|
+
);
|
|
3090
|
+
}
|
|
3091
|
+
function siteFilePathFromKey(key, scope) {
|
|
3092
|
+
if (key.includes("..") || key.includes("\\")) return null;
|
|
3093
|
+
const sitePrefix = `tenants/${scope.tenantId}/sites/${scope.siteId}/media/`;
|
|
3094
|
+
const tenantPrefix = `tenants/${scope.tenantId}/media/`;
|
|
3095
|
+
let path;
|
|
3096
|
+
let name;
|
|
3097
|
+
if (key.startsWith(sitePrefix)) {
|
|
3098
|
+
const parts = key.slice(sitePrefix.length).split("/");
|
|
3099
|
+
if (parts.length === 3 && parts[0] === "originals" && /^[a-f0-9]{64}$/.test(parts[1])) {
|
|
3100
|
+
name = parts[2];
|
|
3101
|
+
path = `/files/${parts[1]}/`;
|
|
3102
|
+
} else if (parts.length === 1) {
|
|
3103
|
+
name = parts[0];
|
|
3104
|
+
path = "/files/";
|
|
3105
|
+
} else return null;
|
|
3106
|
+
} else if (key.startsWith(tenantPrefix)) {
|
|
3107
|
+
name = key.slice(tenantPrefix.length);
|
|
3108
|
+
path = "/files/t/";
|
|
3109
|
+
} else return null;
|
|
3110
|
+
if (!/^[\p{L}\p{N}._~-]+\.pdf$/u.test(name)) return null;
|
|
3111
|
+
try {
|
|
3112
|
+
return path + encodeFilename(name);
|
|
3113
|
+
} catch {
|
|
3114
|
+
return null;
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
function siteFilePathFromUrl(url, scope) {
|
|
3118
|
+
try {
|
|
3119
|
+
const parsed = new URL(url);
|
|
3120
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
|
|
3121
|
+
const rawPath = /^https?:\/\/[^/?#]*(\/[^?#]*)?/i.exec(url)?.[1];
|
|
3122
|
+
if (!rawPath || decodeURIComponent(rawPath).includes("..") || rawPath.includes("\\")) return null;
|
|
3123
|
+
const key = decodeURIComponent(parsed.pathname.slice(1));
|
|
3124
|
+
return siteFilePathFromKey(key, scope);
|
|
3125
|
+
} catch {
|
|
3126
|
+
return null;
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
function siteFileRewrites({
|
|
3130
|
+
tenantId,
|
|
3131
|
+
siteId,
|
|
3132
|
+
storageBaseUrl = "https://root-cdn.com"
|
|
3133
|
+
}) {
|
|
3134
|
+
const uuid = import_zod10.z.string().uuid();
|
|
3135
|
+
if (!uuid.safeParse(tenantId).success || !uuid.safeParse(siteId).success) {
|
|
3136
|
+
throw new Error("Site file scope requires UUID tenantId and siteId");
|
|
3137
|
+
}
|
|
3138
|
+
const base = storageBaseUrl.replace(/\/+$/, "");
|
|
3139
|
+
const media = `${base}/tenants/${tenantId}/sites/${siteId}/media`;
|
|
3140
|
+
const name = ":name((?:[^/%\\\\]|%[89a-fA-F][0-9a-fA-F])+\\.pdf)";
|
|
3141
|
+
return [
|
|
3142
|
+
{ source: `/files/t/${name}`, destination: `${base}/tenants/${tenantId}/media/:name` },
|
|
3143
|
+
{ source: `/files/${name}`, destination: `${media}/:name` },
|
|
3144
|
+
{ source: `/files/:hash([a-f0-9]{64})/${name}`, destination: `${media}/originals/:hash/:name` }
|
|
3145
|
+
];
|
|
3146
|
+
}
|
|
3147
|
+
function siteFileHeaders() {
|
|
3148
|
+
return [
|
|
3149
|
+
{
|
|
3150
|
+
source: "/files/:path*",
|
|
3151
|
+
headers: [{ key: "x-vercel-enable-rewrite-caching", value: "0" }]
|
|
3152
|
+
},
|
|
3153
|
+
{
|
|
3154
|
+
source: "/files/:path*",
|
|
3155
|
+
has: [{ type: "host", value: ".+\\.roottale\\.app" }],
|
|
3156
|
+
headers: [{ key: "X-Robots-Tag", value: "noindex" }]
|
|
3157
|
+
}
|
|
3158
|
+
];
|
|
3159
|
+
}
|
|
3078
3160
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3079
3161
|
0 && (module.exports = {
|
|
3080
3162
|
BLOCK_NAME_PATTERN,
|
|
@@ -3219,6 +3301,10 @@ function normalizeRedirectTarget(raw) {
|
|
|
3219
3301
|
serializeBlock,
|
|
3220
3302
|
setContentValue,
|
|
3221
3303
|
setSitePatternPlacementRule,
|
|
3304
|
+
siteFileHeaders,
|
|
3305
|
+
siteFilePathFromKey,
|
|
3306
|
+
siteFilePathFromUrl,
|
|
3307
|
+
siteFileRewrites,
|
|
3222
3308
|
sitePatternButtonColor,
|
|
3223
3309
|
sitePatternPresentationAttributes,
|
|
3224
3310
|
validateCollections,
|