@reopt-ai/brandapp-sdk 3.3.0 → 3.5.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 +115 -0
- package/README.md +10 -1
- package/dist/abort--nOBFN4M.js +50 -0
- package/dist/ai/index.d.ts +2 -314
- package/dist/ai/index.js +3 -8
- package/dist/ai-provider/index.d.ts +79 -163
- package/dist/ai-provider/index.js +752 -685
- package/dist/auth/index.d.ts +27 -27
- package/dist/auth/index.js +41 -34
- package/dist/better-auth/client.d.ts +6 -5
- package/dist/better-auth/client.js +28 -5
- package/dist/better-auth/index.d.ts +19 -17
- package/dist/better-auth/index.js +180 -144
- package/dist/client-61ldOHMz.js +503 -0
- package/dist/client-7PCoxVhZ.js +28 -0
- package/dist/client-B7rZQ8Zi.d.ts +272 -0
- package/dist/client-BGGd_cpV.d.ts +103 -0
- package/dist/client-BoIuyx4S.js +273 -0
- package/dist/client-BruP5_nU.d.ts +147 -0
- package/dist/client-BxtZt405.js +305 -0
- package/dist/client-ByN3EQdk.js +83 -0
- package/dist/client-CAghoGD_.js +53 -0
- package/dist/client-C_pHsPlj.js +81 -0
- package/dist/client-D0eBxh8j.d.ts +284 -0
- package/dist/client-D6gs61w8.d.ts +53 -0
- package/dist/client-DDw5yz_h.d.ts +53 -0
- package/dist/client-Dxg8_DIH.d.ts +71 -0
- package/dist/client-aMR4CRB8.d.ts +211 -0
- package/dist/client-lk6wBu_0.d.ts +48 -0
- package/dist/client-wEVKLdly.js +55 -0
- package/dist/client-zF1RG2uA.js +86 -0
- package/dist/cms/index.d.ts +52 -108
- package/dist/cms/index.js +103 -86
- package/dist/config-CRytOPPl.d.ts +394 -0
- package/dist/config-aml9oQpX.js +487 -0
- package/dist/dev/index.d.ts +2 -528
- package/dist/dev/index.js +3047 -2967
- package/dist/eav/coerce.d.ts +3 -1
- package/dist/eav/coerce.js +72 -46
- package/dist/eav/index.d.ts +72 -100
- package/dist/eav/index.js +158 -126
- package/dist/eav/migrate.d.ts +112 -109
- package/dist/eav/migrate.js +230 -196
- package/dist/eav/schema.d.ts +111 -150
- package/dist/eav/schema.js +624 -603
- package/dist/encoding-Bwfm3iaE.js +21 -0
- package/dist/{errors-BjDFIyA6.d.ts → errors-CRCcErNC.d.ts} +55 -53
- package/dist/feedback/index.d.ts +2 -132
- package/dist/feedback/index.js +3 -6
- package/dist/files/index.d.ts +14 -14
- package/dist/files/index.js +41 -25
- package/dist/http-client-BZc2mngq.js +386 -0
- package/dist/index-1j_738qk.d.ts +470 -0
- package/dist/index-CeOLGdyL.d.ts +169 -0
- package/dist/index.d.ts +6 -230
- package/dist/index.js +119 -71
- package/dist/logout/index.d.ts +56 -53
- package/dist/logout/index.js +232 -289
- package/dist/plans/index.d.ts +2 -236
- package/dist/plans/index.js +3 -6
- package/dist/push/index.d.ts +2 -79
- package/dist/push/index.js +3 -6
- package/dist/query-xWqtfkvR.js +35 -0
- package/dist/react/hooks.d.ts +157 -100
- package/dist/react/hooks.js +862 -406
- package/dist/sse-parser-FMjxM7sY.js +86 -0
- package/dist/terms/index.d.ts +3 -79
- package/dist/terms/index.js +3 -6
- package/dist/testing/index.d.ts +52 -104
- package/dist/testing/index.js +94 -72
- package/dist/types-B-SMkH6s.d.ts +26 -0
- package/dist/types-BXDcoJHG.d.ts +131 -0
- package/dist/types-BrghN2rJ.d.ts +105 -0
- package/dist/types-DjDRszNj.js +11 -0
- package/dist/webhooks/index.d.ts +77 -50
- package/dist/webhooks/index.js +150 -127
- package/docs/api-reference.md +121 -8
- package/docs/errors.md +19 -0
- package/docs/files.md +165 -7
- package/package.json +7 -6
- package/dist/chunk-2LSCQHAU.js +0 -21
- package/dist/chunk-4U4ZPPL4.js +0 -599
- package/dist/chunk-55KHY5GH.js +0 -96
- package/dist/chunk-C5VTRZWX.js +0 -458
- package/dist/chunk-F7BXBTZI.js +0 -54
- package/dist/chunk-FJUCWXX3.js +0 -350
- package/dist/chunk-H33OTQEN.js +0 -112
- package/dist/chunk-L4DHB36G.js +0 -75
- package/dist/chunk-OG7R3UAR.js +0 -105
- package/dist/chunk-PF24XU54.js +0 -32
- package/dist/chunk-QN3QD67K.js +0 -49
- package/dist/chunk-REIKXSMY.js +0 -7
- package/dist/chunk-UGBBXCZE.js +0 -157
- package/dist/chunk-UVT2E6KD.js +0 -81
- package/dist/chunk-YPLT3RFL.js +0 -63
- package/dist/chunk-YTKSAWV2.js +0 -463
- package/dist/client-BkcO-0C2.d.ts +0 -216
- package/dist/client-CN5_tNOC.d.ts +0 -147
- package/dist/client-DttyeM_h.d.ts +0 -102
- package/dist/config-CtxyJsDR.d.ts +0 -397
- package/dist/typed-client-BxOVIiMU.d.ts +0 -40
- package/dist/types-6E3ZLL9X.d.ts +0 -24
- package/dist/types-DskYLVb8.d.ts +0 -104
- package/dist/types-ckmDDW3N.d.ts +0 -129
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
|
|
2
|
+
import { a as CreateConsentsResult, f as WithdrawConsentResult, i as CreateConsentsRequest, l as TermsListResponse, n as ConsentRecord, o as ListTermsOptions, s as TermsItem } from "./types-BrghN2rJ.js";
|
|
3
|
+
//#region src/terms/client.d.ts
|
|
4
|
+
declare class ReoptTermsClient {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(config: ReoptSDKConfig);
|
|
7
|
+
/**
|
|
8
|
+
* List active terms for this Brandapp with their currently-published
|
|
9
|
+
* version. Works with either Basic Auth (default) or Bearer Auth — when
|
|
10
|
+
* called from a server handler that has the user's access token, pass
|
|
11
|
+
* `accessToken` to avoid sending app credentials.
|
|
12
|
+
*
|
|
13
|
+
* Accepts either an `accessToken` string (legacy) or an options object
|
|
14
|
+
* (`country`/`locale`/`jurisdiction`/`accessToken`) for jurisdiction-aware
|
|
15
|
+
* matching. When `country` / `locale` are omitted, the server falls back to
|
|
16
|
+
* request headers (`x-vercel-ip-country`, `Accept-Language`).
|
|
17
|
+
*
|
|
18
|
+
* Returns the matched terms array. For matching metadata
|
|
19
|
+
* (jurisdiction, locale, source) use {@link listWithMeta}.
|
|
20
|
+
*/
|
|
21
|
+
list(optionsOrToken?: string | ListTermsOptions): Promise<TermsItem[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Same as {@link list} but returns the full {@link TermsListResponse} including
|
|
24
|
+
* matched jurisdiction, country and locale — useful for displaying "약관이
|
|
25
|
+
* 어떤 국가 기준으로 적용됐는지" hint in the signup UX.
|
|
26
|
+
*/
|
|
27
|
+
listWithMeta(optionsOrToken?: string | ListTermsOptions): Promise<TermsListResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Fetch the consent history (granted / withdrawn / pendingReConsent) for
|
|
30
|
+
* the OAuth user represented by `accessToken`.
|
|
31
|
+
*/
|
|
32
|
+
listMyConsents(accessToken: string): Promise<ConsentRecord[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Record consent for one or more terms versions. The server rejects the
|
|
35
|
+
* call with `REQUIRED_NOT_CONSENTED` (422) if any required term is missing
|
|
36
|
+
* or marked as `consented: false`.
|
|
37
|
+
*/
|
|
38
|
+
consent(input: CreateConsentsRequest, accessToken: string): Promise<CreateConsentsResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Withdraw a previously-granted consent. The server returns 409 for
|
|
41
|
+
* required terms or already-withdrawn records.
|
|
42
|
+
*/
|
|
43
|
+
withdraw(consentId: string, accessToken: string): Promise<WithdrawConsentResult>;
|
|
44
|
+
}
|
|
45
|
+
declare function createReoptTermsClient(config: ReoptSDKConfig): ReoptTermsClient;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { createReoptTermsClient as n, ReoptTermsClient as t };
|
|
48
|
+
//# sourceMappingURL=client-lk6wBu_0.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
|
|
2
|
+
import { t as buildQuery } from "./query-xWqtfkvR.js";
|
|
3
|
+
|
|
4
|
+
//#region src/cms/client.ts
|
|
5
|
+
function createReoptCmsClient(config) {
|
|
6
|
+
const http = new BaseHttpClient(config, `/api/v1/brandapp/${config.brandappId}/cms`);
|
|
7
|
+
return {
|
|
8
|
+
posts: {
|
|
9
|
+
async list(query) {
|
|
10
|
+
const qs = buildQuery(query ?? {});
|
|
11
|
+
return (await http.fetch("GET", `/posts${qs}`)).data;
|
|
12
|
+
},
|
|
13
|
+
async get(postId) {
|
|
14
|
+
return (await http.fetch("GET", `/posts/${encodeURIComponent(postId)}`)).data;
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* Slug 기반 단건 조회. URL 라우트(`/blog/[slug]`)에서 id 매핑 없이 사용.
|
|
18
|
+
* 같은 slug가 여러 그룹에 있을 수 있는 경우 `groupId` 또는 `groupSlug`로 좁힐 수 있다.
|
|
19
|
+
*/
|
|
20
|
+
async getBySlug(slug, opts) {
|
|
21
|
+
const qs = buildQuery({
|
|
22
|
+
groupId: opts?.groupId,
|
|
23
|
+
groupSlug: opts?.groupSlug
|
|
24
|
+
});
|
|
25
|
+
return (await http.fetch("GET", `/posts/by-slug/${encodeURIComponent(slug)}${qs}`)).data;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
postGroups: {
|
|
29
|
+
async list(query) {
|
|
30
|
+
const qs = buildQuery(query ?? {});
|
|
31
|
+
return (await http.fetch("GET", `/post-groups${qs}`)).data;
|
|
32
|
+
},
|
|
33
|
+
async get(groupId) {
|
|
34
|
+
return (await http.fetch("GET", `/post-groups/${encodeURIComponent(groupId)}`)).data;
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* Slug 기반 그룹 단건 조회. env var(`REOPT_*_GROUP_ID`) 대신 slug 하드코딩
|
|
38
|
+
* 패턴(`CONTENT_GROUPS.blog.slug`)을 권장.
|
|
39
|
+
*/
|
|
40
|
+
async getBySlug(slug) {
|
|
41
|
+
return (await http.fetch("GET", `/post-groups/by-slug/${encodeURIComponent(slug)}`)).data;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
tags: {
|
|
45
|
+
/** Brand 범위 안에서 사용된 포스트 태그 목록을 반환. */
|
|
46
|
+
async list(query) {
|
|
47
|
+
const qs = buildQuery(query ?? {});
|
|
48
|
+
return (await http.fetch("GET", `/tags${qs}`)).data;
|
|
49
|
+
} }
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { createReoptCmsClient as t };
|
|
55
|
+
//# sourceMappingURL=client-wEVKLdly.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
|
|
2
|
+
|
|
3
|
+
//#region src/feedback/client.ts
|
|
4
|
+
function buildListQuery(query) {
|
|
5
|
+
const params = new URLSearchParams();
|
|
6
|
+
if (query.status) params.set("status", query.status);
|
|
7
|
+
if (query.customerId) params.set("customerId", query.customerId);
|
|
8
|
+
if (query.page != null) params.set("page", String(query.page));
|
|
9
|
+
if (query.limit != null) params.set("limit", String(query.limit));
|
|
10
|
+
const qs = params.toString();
|
|
11
|
+
return qs ? `?${qs}` : "";
|
|
12
|
+
}
|
|
13
|
+
var ReoptFeedbackClient = class {
|
|
14
|
+
http;
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.http = new BaseHttpClient(config, `/api/v1/brandapp/${config.brandappId}/feedback`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a feedback with app credentials (server-to-server collection).
|
|
20
|
+
* Pass `customerId` to attribute it to a customer linked to this brandapp.
|
|
21
|
+
*/
|
|
22
|
+
async create(input) {
|
|
23
|
+
return (await this.http.fetch("POST", "", input)).data;
|
|
24
|
+
}
|
|
25
|
+
/** List feedback this brandapp collected (app credentials). */
|
|
26
|
+
async list(query = {}) {
|
|
27
|
+
const body = await this.http.fetch("GET", buildListQuery(query));
|
|
28
|
+
return {
|
|
29
|
+
feedbacks: body.data,
|
|
30
|
+
meta: body.meta
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Fetch one feedback with its reply thread (app credentials). */
|
|
34
|
+
async get(feedbackId) {
|
|
35
|
+
return (await this.http.fetch("GET", `/${encodeURIComponent(feedbackId)}`)).data;
|
|
36
|
+
}
|
|
37
|
+
/** End-user surface — requires the signed-in user's OAuth access token. */
|
|
38
|
+
me = {
|
|
39
|
+
/**
|
|
40
|
+
* Create a feedback as the signed-in user. The server resolves the
|
|
41
|
+
* token's linked customer; unlinked users get 403 `LINK_REQUIRED`
|
|
42
|
+
* (call `sdk.auth.linkCurrentUser` first).
|
|
43
|
+
*/
|
|
44
|
+
create: async (input, accessToken) => {
|
|
45
|
+
return (await this.http.fetch("POST", "/me", input, { bearerToken: accessToken })).data;
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* List the signed-in user's own feedback (all collection sources —
|
|
49
|
+
* brand form submissions included).
|
|
50
|
+
*/
|
|
51
|
+
list: async (accessToken, query = {}) => {
|
|
52
|
+
const body = await this.http.fetch("GET", `/me${buildListQuery(query)}`, void 0, { bearerToken: accessToken });
|
|
53
|
+
return {
|
|
54
|
+
feedbacks: body.data,
|
|
55
|
+
meta: body.meta
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
/** Fetch one of the signed-in user's feedback with its thread. */
|
|
59
|
+
get: async (feedbackId, accessToken) => {
|
|
60
|
+
return (await this.http.fetch("GET", `/me/${encodeURIComponent(feedbackId)}`, void 0, { bearerToken: accessToken })).data;
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Reply to a staff answer on the signed-in user's own feedback, continuing
|
|
64
|
+
* the thread instead of filing a new feedback. An already-answered feedback
|
|
65
|
+
* flips back to `reopened` and the workspace is notified.
|
|
66
|
+
*/
|
|
67
|
+
reply: async (feedbackId, content, accessToken) => {
|
|
68
|
+
return (await this.http.fetch("POST", `/me/${encodeURIComponent(feedbackId)}/replies`, { content }, { bearerToken: accessToken })).data;
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Rate a staff reply's usefulness (`true` helpful / `false` not helpful /
|
|
72
|
+
* `null` to clear). Rating alone does not reopen the feedback — send a
|
|
73
|
+
* `reply` when the customer still needs something.
|
|
74
|
+
*/
|
|
75
|
+
rateReply: async (feedbackId, replyId, helpful, accessToken) => {
|
|
76
|
+
return (await this.http.fetch("PUT", `/me/${encodeURIComponent(feedbackId)}/replies/${encodeURIComponent(replyId)}/rating`, { helpful }, { bearerToken: accessToken })).data;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
function createReoptFeedbackClient(config) {
|
|
81
|
+
return new ReoptFeedbackClient(config);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { createReoptFeedbackClient as n, ReoptFeedbackClient as t };
|
|
86
|
+
//# sourceMappingURL=client-zF1RG2uA.js.map
|
package/dist/cms/index.d.ts
CHANGED
|
@@ -1,120 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Reopt CMS Client
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { createReoptSDK } from "@reopt-ai/brandapp-sdk";
|
|
11
|
-
*
|
|
12
|
-
* const sdk = createReoptSDK({
|
|
13
|
-
* clientId: process.env.BRANDAPP_CLIENT_ID!,
|
|
14
|
-
* clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
|
|
15
|
-
* brandappId: process.env.BRANDAPP_ID!,
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* const { records: posts } = await sdk.cms.posts.list({ status: "published" });
|
|
19
|
-
* const post = await sdk.cms.posts.get(postId);
|
|
20
|
-
* const post = await sdk.cms.posts.getBySlug("hello-world");
|
|
21
|
-
* const tags = await sdk.cms.tags.list();
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
type ReoptCmsClient = ReturnType<typeof createReoptCmsClient>;
|
|
25
|
-
declare function createReoptCmsClient(config: ReoptSDKConfig): {
|
|
26
|
-
posts: {
|
|
27
|
-
list(query?: ListPostsQuery): Promise<CmsPaginatedResponse<Post>>;
|
|
28
|
-
get(postId: string): Promise<PostDetail>;
|
|
29
|
-
/**
|
|
30
|
-
* Slug 기반 단건 조회. URL 라우트(`/blog/[slug]`)에서 id 매핑 없이 사용.
|
|
31
|
-
* 같은 slug가 여러 그룹에 있을 수 있는 경우 `groupId` 또는 `groupSlug`로 좁힐 수 있다.
|
|
32
|
-
*/
|
|
33
|
-
getBySlug(slug: string, opts?: {
|
|
34
|
-
groupId?: string;
|
|
35
|
-
groupSlug?: string;
|
|
36
|
-
}): Promise<PostDetail>;
|
|
37
|
-
};
|
|
38
|
-
postGroups: {
|
|
39
|
-
list(query?: ListPostGroupsQuery): Promise<CmsPaginatedResponse<PostGroup>>;
|
|
40
|
-
get(groupId: string): Promise<PostGroup>;
|
|
41
|
-
/**
|
|
42
|
-
* Slug 기반 그룹 단건 조회. env var(`REOPT_*_GROUP_ID`) 대신 slug 하드코딩
|
|
43
|
-
* 패턴(`CONTENT_GROUPS.blog.slug`)을 권장.
|
|
44
|
-
*/
|
|
45
|
-
getBySlug(slug: string): Promise<PostGroup>;
|
|
46
|
-
};
|
|
47
|
-
tags: {
|
|
48
|
-
/** Brand 범위 안에서 사용된 포스트 태그 목록을 반환. */
|
|
49
|
-
list(query?: ListTagsQuery): Promise<Tag[]>;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* CMS 헬퍼 — SEO 메타데이터, 사이트맵, RSS 피드 생성.
|
|
55
|
-
*
|
|
56
|
-
* 모두 순수 함수. Next.js / React 의존 없음. 외부 마케팅 사이트가
|
|
57
|
-
* `cms.posts.list()` / `cms.posts.getBySlug()` 결과를 그대로 넘기면
|
|
58
|
-
* 표준 출력 형식으로 변환된다.
|
|
59
|
-
*/
|
|
60
|
-
|
|
1
|
+
import { a as ListTagsQuery, c as PostGroup, d as Tag, i as ListPostsQuery, l as PostSeo, n as EditorSpec, o as Post, r as ListPostGroupsQuery, s as PostDetail, t as CmsPaginatedResponse, u as PostStatus } from "../types-BXDcoJHG.js";
|
|
2
|
+
import { n as createReoptCmsClient, t as ReoptCmsClient } from "../client-DDw5yz_h.js";
|
|
3
|
+
//#region src/cms/helpers.d.ts
|
|
61
4
|
type SeoMetadata = {
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
keywords?: string;
|
|
8
|
+
alternates?: {
|
|
9
|
+
canonical?: string;
|
|
10
|
+
};
|
|
11
|
+
openGraph?: {
|
|
12
|
+
type?: "article" | "website";
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
images?: {
|
|
17
|
+
url: string;
|
|
18
|
+
}[];
|
|
19
|
+
publishedTime?: string;
|
|
20
|
+
modifiedTime?: string;
|
|
21
|
+
authors?: string[];
|
|
22
|
+
};
|
|
23
|
+
twitter?: {
|
|
24
|
+
card?: "summary" | "summary_large_image";
|
|
62
25
|
title?: string;
|
|
63
26
|
description?: string;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
canonical?: string;
|
|
67
|
-
};
|
|
68
|
-
openGraph?: {
|
|
69
|
-
type?: "article" | "website";
|
|
70
|
-
title?: string;
|
|
71
|
-
description?: string;
|
|
72
|
-
url?: string;
|
|
73
|
-
images?: {
|
|
74
|
-
url: string;
|
|
75
|
-
}[];
|
|
76
|
-
publishedTime?: string;
|
|
77
|
-
modifiedTime?: string;
|
|
78
|
-
authors?: string[];
|
|
79
|
-
};
|
|
80
|
-
twitter?: {
|
|
81
|
-
card?: "summary" | "summary_large_image";
|
|
82
|
-
title?: string;
|
|
83
|
-
description?: string;
|
|
84
|
-
images?: string[];
|
|
85
|
-
};
|
|
27
|
+
images?: string[];
|
|
28
|
+
};
|
|
86
29
|
};
|
|
87
30
|
type SitemapItem = {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
31
|
+
url: string;
|
|
32
|
+
lastModified?: string;
|
|
33
|
+
changeFrequency?: "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
|
|
34
|
+
priority?: number;
|
|
92
35
|
};
|
|
93
36
|
type ToMetadataOptions = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
37
|
+
/** 사이트 origin. 끝 슬래시 없음. e.g. "https://www.reopt.ai" */
|
|
38
|
+
siteUrl: string;
|
|
39
|
+
/** 포스트 URL prefix. 기본 "/blog". */
|
|
40
|
+
basePath?: string;
|
|
98
41
|
};
|
|
99
42
|
type ToSitemapOptions = {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
43
|
+
siteUrl: string;
|
|
44
|
+
/** 포스트 URL prefix. 기본 "/blog". */
|
|
45
|
+
basePath?: string;
|
|
46
|
+
/** 모든 항목에 적용. 기본 "weekly". */
|
|
47
|
+
changeFrequency?: SitemapItem["changeFrequency"];
|
|
48
|
+
/** 모든 항목에 적용. 기본 0.7. */
|
|
49
|
+
priority?: number;
|
|
107
50
|
};
|
|
108
51
|
type ToRssOptions = {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
52
|
+
siteUrl: string;
|
|
53
|
+
/** 채널 제목. */
|
|
54
|
+
title: string;
|
|
55
|
+
/** 채널 설명. */
|
|
56
|
+
description: string;
|
|
57
|
+
/** 포스트 URL prefix. 기본 "/blog". */
|
|
58
|
+
basePath?: string;
|
|
59
|
+
/** 채널 언어 코드. 기본 "ko". */
|
|
60
|
+
language?: string;
|
|
118
61
|
};
|
|
119
62
|
/**
|
|
120
63
|
* Post → Next.js Metadata. Post.seo 필드가 우선이고, 없으면 title/document로
|
|
@@ -133,5 +76,6 @@ type ToRssOptions = {
|
|
|
133
76
|
declare function toMetadata(post: PostDetail | Post, opts: ToMetadataOptions): SeoMetadata;
|
|
134
77
|
declare function toSitemapItems(posts: Post[], opts: ToSitemapOptions): SitemapItem[];
|
|
135
78
|
declare function toRssFeed(posts: (Post | PostDetail)[], opts: ToRssOptions): string;
|
|
136
|
-
|
|
137
|
-
export { CmsPaginatedResponse, ListPostGroupsQuery, ListPostsQuery, ListTagsQuery, Post, PostDetail, PostGroup, type ReoptCmsClient, type SeoMetadata, type SitemapItem, Tag, type ToMetadataOptions, type ToRssOptions, type ToSitemapOptions, createReoptCmsClient, toMetadata, toRssFeed, toSitemapItems };
|
|
79
|
+
//#endregion
|
|
80
|
+
export { type CmsPaginatedResponse, type EditorSpec, type ListPostGroupsQuery, type ListPostsQuery, type ListTagsQuery, type Post, type PostDetail, type PostGroup, type PostSeo, type PostStatus, type ReoptCmsClient, type SeoMetadata, type SitemapItem, type Tag, type ToMetadataOptions, type ToRssOptions, type ToSitemapOptions, createReoptCmsClient, toMetadata, toRssFeed, toSitemapItems };
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/cms/index.js
CHANGED
|
@@ -1,105 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
import '../chunk-PF24XU54.js';
|
|
3
|
-
import '../chunk-YTKSAWV2.js';
|
|
4
|
-
import '../chunk-2LSCQHAU.js';
|
|
5
|
-
import '../chunk-C5VTRZWX.js';
|
|
1
|
+
import { t as createReoptCmsClient } from "../client-wEVKLdly.js";
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
//#region src/cms/helpers.ts
|
|
8
4
|
function joinUrl(siteUrl, path) {
|
|
9
|
-
|
|
10
|
-
const suffix = path.startsWith("/") ? path : `/${path}`;
|
|
11
|
-
return `${base}${suffix}`;
|
|
5
|
+
return `${siteUrl.replace(/\/+$/, "")}${path.startsWith("/") ? path : `/${path}`}`;
|
|
12
6
|
}
|
|
13
7
|
function postUrl(post, opts) {
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
const basePath = opts.basePath ?? "/blog";
|
|
9
|
+
return joinUrl(opts.siteUrl, `${basePath}/${post.slug}`);
|
|
16
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* XML 1.0에서 문서 어디에도 올 수 없는 제어문자(C0 제어문자 중 탭·LF·CR 제외)를
|
|
13
|
+
* 제거한다. 이 문자들은 숫자 엔티티로도 표현할 수 없어 이스케이프가 불가능하므로,
|
|
14
|
+
* 하나라도 남으면 피드 전체가 not-well-formed가 되어 모든 항목이 파싱 실패한다.
|
|
15
|
+
* (PDF·워드에서 붙여넣은 텍스트에 \x0B/\x0C가 흔히 섞인다.)
|
|
16
|
+
*/
|
|
17
17
|
function stripXmlInvalidChars(input) {
|
|
18
|
-
|
|
18
|
+
return input.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "");
|
|
19
19
|
}
|
|
20
20
|
function escapeXml(input) {
|
|
21
|
-
|
|
21
|
+
return stripXmlInvalidChars(input).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* CDATA 섹션 안에 안전하게 넣도록 `]]>` 종료 시퀀스를 분할한다. 내용에 `]]>`가
|
|
25
|
+
* 포함되면 CDATA가 조기 종료돼 RSS XML이 파손되거나 마크업이 주입될 수 있다.
|
|
26
|
+
* escapeXml을 거치지 않는 경로이므로 여기서도 XML-불법 제어문자를 제거한다.
|
|
27
|
+
*/
|
|
23
28
|
function cdataSafe(input) {
|
|
24
|
-
|
|
29
|
+
return stripXmlInvalidChars(input).replace(/]]>/g, "]]]]><![CDATA[>");
|
|
25
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Post → Next.js Metadata. Post.seo 필드가 우선이고, 없으면 title/document로
|
|
33
|
+
* fallback. 외부 사용자는 결과를 `Metadata`로 cast하면 그대로 사용 가능.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import type { Metadata } from "next";
|
|
38
|
+
*
|
|
39
|
+
* export async function generateMetadata({ params }): Promise<Metadata> {
|
|
40
|
+
* const post = await sdk.cms.posts.getBySlug(params.slug);
|
|
41
|
+
* return toMetadata(post, { siteUrl: "https://www.reopt.ai" });
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
26
45
|
function toMetadata(post, opts) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
const url = postUrl(post, opts);
|
|
47
|
+
const title = post.seo?.metaTitle ?? post.title;
|
|
48
|
+
const description = post.seo?.metaDescription ?? ("document" in post ? post.document.content.slice(0, 160) : void 0) ?? void 0;
|
|
49
|
+
const images = post.coverImage?.url ? [{ url: post.coverImage.url }] : void 0;
|
|
50
|
+
const authorName = post.author?.name;
|
|
51
|
+
const meta = {
|
|
52
|
+
title,
|
|
53
|
+
alternates: { canonical: url },
|
|
54
|
+
openGraph: {
|
|
55
|
+
type: "article",
|
|
56
|
+
title,
|
|
57
|
+
description,
|
|
58
|
+
url,
|
|
59
|
+
images,
|
|
60
|
+
publishedTime: post.publishedAt ?? void 0,
|
|
61
|
+
modifiedTime: post.updatedAt,
|
|
62
|
+
authors: authorName ? [authorName] : void 0
|
|
63
|
+
},
|
|
64
|
+
twitter: {
|
|
65
|
+
card: post.coverImage?.url ? "summary_large_image" : "summary",
|
|
66
|
+
title,
|
|
67
|
+
description,
|
|
68
|
+
images: post.coverImage?.url ? [post.coverImage.url] : void 0
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
if (description) meta.description = description;
|
|
72
|
+
if (post.seo?.metaKeywords) meta.keywords = post.seo.metaKeywords;
|
|
73
|
+
return meta;
|
|
55
74
|
}
|
|
56
75
|
function toSitemapItems(posts, opts) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
const changeFrequency = opts.changeFrequency ?? "weekly";
|
|
77
|
+
const priority = opts.priority ?? .7;
|
|
78
|
+
return posts.map((post) => ({
|
|
79
|
+
url: postUrl(post, opts),
|
|
80
|
+
lastModified: post.updatedAt,
|
|
81
|
+
changeFrequency,
|
|
82
|
+
priority
|
|
83
|
+
}));
|
|
65
84
|
}
|
|
66
85
|
function toRssFeed(posts, opts) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"</rss>"
|
|
100
|
-
].join("\n");
|
|
86
|
+
const language = opts.language ?? "ko";
|
|
87
|
+
const channelLink = opts.siteUrl.replace(/\/+$/, "");
|
|
88
|
+
const lastBuildDate = (/* @__PURE__ */ new Date()).toUTCString();
|
|
89
|
+
const items = posts.map((post) => {
|
|
90
|
+
const link = postUrl(post, opts);
|
|
91
|
+
const pubDate = post.publishedAt ? new Date(post.publishedAt).toUTCString() : new Date(post.createdAt).toUTCString();
|
|
92
|
+
const description = post.seo?.metaDescription ?? ("document" in post ? post.document.content.slice(0, 280) : "");
|
|
93
|
+
return [
|
|
94
|
+
" <item>",
|
|
95
|
+
` <title>${escapeXml(post.title)}</title>`,
|
|
96
|
+
` <link>${escapeXml(link)}</link>`,
|
|
97
|
+
` <guid isPermaLink="true">${escapeXml(link)}</guid>`,
|
|
98
|
+
` <pubDate>${pubDate}</pubDate>`,
|
|
99
|
+
description ? ` <description><![CDATA[${cdataSafe(description)}]]></description>` : "",
|
|
100
|
+
` <author>${escapeXml(post.author?.name ?? "")}</author>`,
|
|
101
|
+
...post.tags.map((tag) => ` <category>${escapeXml(tag.text)}</category>`),
|
|
102
|
+
" </item>"
|
|
103
|
+
].filter((line) => line.length > 0).join("\n");
|
|
104
|
+
}).join("\n");
|
|
105
|
+
return [
|
|
106
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
|
|
107
|
+
"<rss version=\"2.0\">",
|
|
108
|
+
" <channel>",
|
|
109
|
+
` <title>${escapeXml(opts.title)}</title>`,
|
|
110
|
+
` <link>${escapeXml(channelLink)}</link>`,
|
|
111
|
+
` <description>${escapeXml(opts.description)}</description>`,
|
|
112
|
+
` <language>${escapeXml(language)}</language>`,
|
|
113
|
+
` <lastBuildDate>${lastBuildDate}</lastBuildDate>`,
|
|
114
|
+
items,
|
|
115
|
+
" </channel>",
|
|
116
|
+
"</rss>"
|
|
117
|
+
].join("\n");
|
|
101
118
|
}
|
|
102
119
|
|
|
103
|
-
|
|
104
|
-
|
|
120
|
+
//#endregion
|
|
121
|
+
export { createReoptCmsClient, toMetadata, toRssFeed, toSitemapItems };
|
|
105
122
|
//# sourceMappingURL=index.js.map
|