@reopt-ai/brandapp-sdk 4.3.0 → 4.5.0-platform.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 +31 -0
- package/README.md +1 -1
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.js +1 -1
- package/dist/ai-provider/index.js +76 -65
- package/dist/analytics/index.d.ts +1 -1
- package/dist/analytics/index.js +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/better-auth/index.d.ts +1 -1
- package/dist/better-auth/index.js +2 -2
- package/dist/{client-D5F6-YYU.d.ts → client-7I-mz3Dw.d.ts} +2 -2
- package/dist/{client-BMgVQ4U-.js → client-B0XUjOuP.js} +12 -5
- package/dist/{client-D4kUDFwW.js → client-B270eCrs.js} +2 -2
- package/dist/{client-BD1-resY.js → client-BIMl52kc.js} +3 -3
- package/dist/{client-p4LmfF27.js → client-BNht520A.js} +2 -2
- package/dist/{client-bXAnGNzC.d.ts → client-BSW0Ncjj.d.ts} +2 -2
- package/dist/{client-CNPfjmT0.d.ts → client-Bfutv3LK.d.ts} +2 -2
- package/dist/{client-Hc7SfeIf.js → client-BwgCbfXv.js} +2 -2
- package/dist/{client-vjIDamSf.js → client-C2ALt685.js} +3 -3
- package/dist/{client-DjgoTlfv.d.ts → client-C6OXGMMV.d.ts} +2 -2
- package/dist/{client-BpEWDfSl.js → client-CKi1NpMR.js} +2 -2
- package/dist/{client-B4CiEei5.d.ts → client-COKDtHO9.d.ts} +2 -2
- package/dist/{client-BOEyVc8V.d.ts → client-CniCGdmi.d.ts} +2 -2
- package/dist/{client-BVvAfEXG.js → client-Cv1bdMBf.js} +2 -2
- package/dist/{client-DA9ibl3G.d.ts → client-D1AFtJRw.d.ts} +2 -2
- package/dist/{client-CaWHvclV.js → client-DNzgX_md.js} +70 -6
- package/dist/{client-DYammrtw.d.ts → client-Dmvtr1nS.d.ts} +2 -2
- package/dist/{client-CRim5LCH.d.ts → client-IUSZDJio.d.ts} +2 -2
- package/dist/{client-CIUecAJE.js → client-WxPjMNy_.js} +2 -2
- package/dist/{client-BBxhqs8l.d.ts → client-yKeRJnIB.d.ts} +2 -2
- package/dist/cms/index.d.ts +1 -1
- package/dist/cms/index.js +1 -1
- package/dist/{config-D28P8iwm.d.ts → config-D3SblxWt.d.ts} +19 -2
- package/dist/{config-D8dSL6OQ.js → config-DkT0F-GG.js} +2 -2
- package/dist/eav/index.d.ts +3 -3
- package/dist/eav/index.js +3 -33
- package/dist/eav/migrate.d.ts +2 -2
- package/dist/eav/schema.d.ts +2 -2
- package/dist/feedback/index.d.ts +1 -1
- package/dist/feedback/index.js +1 -1
- package/dist/files/index.d.ts +1 -1
- package/dist/files/index.js +1 -1
- package/dist/{http-client-0Sp8wQGQ.js → http-client-BO5A5n4I.js} +2 -2
- package/dist/{index-DwIr8W3Y.d.ts → index-BnAYxnwq.d.ts} +12 -12
- package/dist/index.d.ts +4 -4
- package/dist/index.js +12 -12
- package/dist/logout/index.d.ts +1 -1
- package/dist/logout/index.js +1 -1
- package/dist/plans/index.d.ts +1 -1
- package/dist/plans/index.js +1 -1
- package/dist/push/index.d.ts +1 -1
- package/dist/push/index.js +1 -1
- package/dist/{query-C18XolkY.js → query-D08B_HFt.js} +2 -2
- package/dist/react/hooks.d.ts +4 -4
- package/dist/terms/index.d.ts +1 -1
- package/dist/terms/index.js +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/webhooks/index.d.ts +25 -2
- package/dist/workspace/index.d.ts +253 -0
- package/dist/workspace/index.js +335 -0
- package/docs/api-reference.md +16 -11
- package/docs/cms.md +3 -1
- package/package.json +10 -2
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/workspace/schemas.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* 플랫폼 API(RFC-0029) 와이어 계약 — zod 한 벌.
|
|
5
|
+
*
|
|
6
|
+
* 서버(`apps/web/server/hono/routes/platform-schemas.ts`)와 같은 모양이다. 패키지 경계 때문에
|
|
7
|
+
* 파일은 둘이지만 서버 테스트(`platform-sdk-parity.test.ts`)가 이 스키마로 서버 응답을 파싱해
|
|
8
|
+
* 파리티를 고정한다. 소비자(reopt-data 등)는 tRPC 입력·웹훅 검증에 그대로 쓴다.
|
|
9
|
+
*
|
|
10
|
+
* 🔑 `.default()`를 쓰지 않는다 — 생략(`undefined`)이 "건드리지 않는다"를 뜻하는 필드가 있다.
|
|
11
|
+
* 🔑 타입은 손으로 적고 스키마에 `z.ZodType<T>`를 단다 — 이 패키지는 `isolatedDeclarations`라
|
|
12
|
+
* 추론된 export가 빌드를 깬다(TS9010).
|
|
13
|
+
*/
|
|
14
|
+
declare const PLATFORM_TASK_PRIORITIES: readonly ["low", "medium", "high", "urgent"];
|
|
15
|
+
declare const PLATFORM_TASK_OUTCOMES: readonly ["completed", "canceled"];
|
|
16
|
+
declare const PLATFORM_WEBHOOK_TRIGGERS: readonly ["workTaskStageChanged"];
|
|
17
|
+
type PlatformTaskPriority = (typeof PLATFORM_TASK_PRIORITIES)[number];
|
|
18
|
+
type PlatformTaskOutcome = (typeof PLATFORM_TASK_OUTCOMES)[number] | null;
|
|
19
|
+
type PlatformWebhookTrigger = (typeof PLATFORM_WEBHOOK_TRIGGERS)[number];
|
|
20
|
+
/** 단계 지정 — outcome(의미론) 또는 stageId(정확한 단계) 중 하나 */
|
|
21
|
+
type PlatformTaskStage = {
|
|
22
|
+
outcome?: PlatformTaskOutcome;
|
|
23
|
+
stageId?: string;
|
|
24
|
+
};
|
|
25
|
+
type PlatformTaskUpsertInput = {
|
|
26
|
+
/** 소스 쪽 단조 증가 version(ms epoch 권장). 저장값 이하면 서버가 no-op으로 답한다 */
|
|
27
|
+
version: number;
|
|
28
|
+
title: string;
|
|
29
|
+
description?: string | null;
|
|
30
|
+
priority?: PlatformTaskPriority;
|
|
31
|
+
/** ISO 8601(offset 포함). null = 마감 없음, 생략 = 건드리지 않음 */
|
|
32
|
+
dueDate?: string | null;
|
|
33
|
+
/** studio Brand.id — 생략 시 클라이언트 브랜드 */
|
|
34
|
+
brandId?: string;
|
|
35
|
+
/** studio WorkPipeline.id — 생성 시에만 쓰이고 생략 시 기본 파이프라인 */
|
|
36
|
+
pipelineId?: string;
|
|
37
|
+
/** 소스 쪽 화면 딥링크 */
|
|
38
|
+
url?: string | null;
|
|
39
|
+
/** 소스 쪽 종류 라벨("ErrorIssue") */
|
|
40
|
+
label?: string | null;
|
|
41
|
+
stage?: PlatformTaskStage;
|
|
42
|
+
};
|
|
43
|
+
type PlatformTaskStageInput = {
|
|
44
|
+
version: number;
|
|
45
|
+
outcome?: PlatformTaskOutcome;
|
|
46
|
+
stageId?: string;
|
|
47
|
+
};
|
|
48
|
+
type PlatformWebhookUpsertInput = {
|
|
49
|
+
url: string;
|
|
50
|
+
triggers: PlatformWebhookTrigger[];
|
|
51
|
+
/** HMAC 서명 시크릿(≥16자). 생략하면 기존 값 유지 */
|
|
52
|
+
secret?: string;
|
|
53
|
+
};
|
|
54
|
+
/** 소스 쪽 식별자 — 경로 세그먼트라 슬래시·공백 금지, ≤255 */
|
|
55
|
+
declare const platformExternalIdSchema: z.ZodType<string>;
|
|
56
|
+
declare const platformTaskStageSchema: z.ZodType<PlatformTaskStage>;
|
|
57
|
+
declare const platformTaskUpsertInputSchema: z.ZodType<PlatformTaskUpsertInput>;
|
|
58
|
+
declare const platformTaskStageInputSchema: z.ZodType<PlatformTaskStageInput>;
|
|
59
|
+
declare const platformWebhookUpsertInputSchema: z.ZodType<PlatformWebhookUpsertInput>;
|
|
60
|
+
type PlatformTask = {
|
|
61
|
+
id: string;
|
|
62
|
+
workspaceId: string;
|
|
63
|
+
brandId: string | null;
|
|
64
|
+
title: string;
|
|
65
|
+
description: string | null;
|
|
66
|
+
priority: PlatformTaskPriority;
|
|
67
|
+
dueDate: string | null;
|
|
68
|
+
pipeline: {
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
} | null;
|
|
72
|
+
stage: {
|
|
73
|
+
id: string;
|
|
74
|
+
key: string;
|
|
75
|
+
label: string;
|
|
76
|
+
outcome: PlatformTaskOutcome;
|
|
77
|
+
} | null;
|
|
78
|
+
externalRef: {
|
|
79
|
+
source: string;
|
|
80
|
+
externalId: string;
|
|
81
|
+
url: string | null;
|
|
82
|
+
label: string | null;
|
|
83
|
+
version: number;
|
|
84
|
+
};
|
|
85
|
+
/** 스튜디오 업무 딥링크(절대 URL) */
|
|
86
|
+
url: string;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
updatedAt: string;
|
|
89
|
+
};
|
|
90
|
+
type PlatformWriteMeta = {
|
|
91
|
+
created: boolean;
|
|
92
|
+
applied: boolean;
|
|
93
|
+
};
|
|
94
|
+
type PlatformPipeline = {
|
|
95
|
+
id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
isDefault: boolean;
|
|
98
|
+
stages: Array<{
|
|
99
|
+
id: string;
|
|
100
|
+
key: string;
|
|
101
|
+
label: string;
|
|
102
|
+
order: number;
|
|
103
|
+
isEntry: boolean;
|
|
104
|
+
outcome: PlatformTaskOutcome;
|
|
105
|
+
}>;
|
|
106
|
+
};
|
|
107
|
+
type PlatformMe = {
|
|
108
|
+
clientId: string;
|
|
109
|
+
clientName: string;
|
|
110
|
+
/** 외부 참조 `source` — 이 클라이언트의 Brandapp slug */
|
|
111
|
+
source: string;
|
|
112
|
+
workspaceId: string;
|
|
113
|
+
brandappId: string;
|
|
114
|
+
defaultBrandId: string;
|
|
115
|
+
scopes: string[];
|
|
116
|
+
};
|
|
117
|
+
type PlatformWebhook = {
|
|
118
|
+
id: string;
|
|
119
|
+
url: string;
|
|
120
|
+
triggers: string[];
|
|
121
|
+
hasSecret: boolean;
|
|
122
|
+
};
|
|
123
|
+
type PlatformErrorBody = {
|
|
124
|
+
error: {
|
|
125
|
+
code: string;
|
|
126
|
+
message: string;
|
|
127
|
+
retryable: boolean;
|
|
128
|
+
fields?: Array<{
|
|
129
|
+
field: string;
|
|
130
|
+
message: string;
|
|
131
|
+
}>;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
/** 웹훅 `workTaskStageChanged`의 `data` — 역방향 동기화 수신 측이 이 스키마로 검증한다 */
|
|
135
|
+
type PlatformWorkTaskStageChangedEvent = {
|
|
136
|
+
id: string;
|
|
137
|
+
title: string;
|
|
138
|
+
pipelineId: string | null;
|
|
139
|
+
fromStageLabel: string | null;
|
|
140
|
+
toStageId: string;
|
|
141
|
+
toStageLabel: string;
|
|
142
|
+
toStageOutcome: PlatformTaskOutcome;
|
|
143
|
+
/** "studio" 또는 플랫폼 API 클라이언트의 source slug — 자기 것이면 무시 */
|
|
144
|
+
origin: string;
|
|
145
|
+
/** outbox 행 생성 시각(ms epoch) — 단조 비교 */
|
|
146
|
+
version: number;
|
|
147
|
+
externalRefs: Array<{
|
|
148
|
+
source: string;
|
|
149
|
+
externalId: string;
|
|
150
|
+
label: string | null;
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
153
|
+
declare const platformTaskSchema: z.ZodType<PlatformTask>;
|
|
154
|
+
declare const platformWriteMetaSchema: z.ZodType<PlatformWriteMeta>;
|
|
155
|
+
declare const platformPipelineSchema: z.ZodType<PlatformPipeline>;
|
|
156
|
+
declare const platformMeSchema: z.ZodType<PlatformMe>;
|
|
157
|
+
declare const platformWebhookSchema: z.ZodType<PlatformWebhook>;
|
|
158
|
+
declare const platformErrorSchema: z.ZodType<PlatformErrorBody>;
|
|
159
|
+
declare const platformWorkTaskStageChangedEventSchema: z.ZodType<PlatformWorkTaskStageChangedEvent>;
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/workspace/client.d.ts
|
|
162
|
+
/**
|
|
163
|
+
* 플랫폼 API(RFC-0029) 클라이언트 — **서버 전용**.
|
|
164
|
+
*
|
|
165
|
+
* `client_credentials`로 `platform.reopt.ai` audience 토큰을 받아(캐시·만료 60초 전 재발급·401 시 1회
|
|
166
|
+
* 재발급) `/v1/*`를 부른다. 브라우저에서 만들면 던진다 — clientSecret이 곧 워크스페이스 쓰기 권한이다.
|
|
167
|
+
*
|
|
168
|
+
* 기본 origin은 환경에서 파생하고(`isProduction` 또는 `REOPT_PLATFORM_URL`/`REOPT_ID_BASE_URL` env),
|
|
169
|
+
* 자체서명 dev 인증서는 `fetch` 주입(undici Agent 등)으로 요청 단위로 푼다 — 프로세스 전역
|
|
170
|
+
* `NODE_TLS_REJECT_UNAUTHORIZED`는 쓰지 않는다.
|
|
171
|
+
*/
|
|
172
|
+
declare const REOPT_PLATFORM_URLS: {
|
|
173
|
+
readonly production: "https://platform.reopt.ai";
|
|
174
|
+
readonly development: "https://platform.reopt.de:3443";
|
|
175
|
+
};
|
|
176
|
+
declare const REOPT_PLATFORM_ID_URLS: {
|
|
177
|
+
readonly production: "https://id.reopt.ai";
|
|
178
|
+
readonly development: "https://id.reopt.de:3443";
|
|
179
|
+
};
|
|
180
|
+
declare const DEFAULT_PLATFORM_SCOPES: readonly ["works:read", "works:write"];
|
|
181
|
+
type PlatformClientConfig = {
|
|
182
|
+
clientId: string;
|
|
183
|
+
clientSecret: string;
|
|
184
|
+
/** 플랫폼 API origin. 생략 시 `REOPT_PLATFORM_URL` env → `isProduction` 기본값 */
|
|
185
|
+
platformUrl?: string;
|
|
186
|
+
/** 토큰 발급(id 서버) origin. 생략 시 `REOPT_ID_BASE_URL` env → `isProduction` 기본값 */
|
|
187
|
+
idBaseUrl?: string;
|
|
188
|
+
/** 기본 `["works:read", "works:write"]` — 클라이언트의 clientCredentialsScopes 안이어야 한다 */
|
|
189
|
+
scopes?: readonly string[];
|
|
190
|
+
/** true: production 호스트 / false: dev 호스트 / 생략: `NODE_ENV === "production"` */
|
|
191
|
+
isProduction?: boolean;
|
|
192
|
+
/** 요청 타임아웃(ms). 기본 10_000 */
|
|
193
|
+
timeoutMs?: number;
|
|
194
|
+
/** fetch 주입 — 테스트·자체서명 인증서(undici dispatcher) 용 */
|
|
195
|
+
fetch?: typeof fetch;
|
|
196
|
+
/** 서버 로그 상관관계용 — 요청마다 `X-Request-Id`로 실린다(생략 시 UUID) */
|
|
197
|
+
requestId?: () => string;
|
|
198
|
+
};
|
|
199
|
+
type PlatformWriteResult<T> = {
|
|
200
|
+
data: T;
|
|
201
|
+
meta: PlatformWriteMeta;
|
|
202
|
+
};
|
|
203
|
+
declare class PlatformApiError extends Error {
|
|
204
|
+
readonly status: number;
|
|
205
|
+
readonly code: string;
|
|
206
|
+
readonly retryable: boolean;
|
|
207
|
+
readonly fields?: Array<{
|
|
208
|
+
field: string;
|
|
209
|
+
message: string;
|
|
210
|
+
}>;
|
|
211
|
+
readonly requestId?: string;
|
|
212
|
+
constructor(input: {
|
|
213
|
+
status: number;
|
|
214
|
+
code: string;
|
|
215
|
+
message: string;
|
|
216
|
+
retryable: boolean;
|
|
217
|
+
fields?: Array<{
|
|
218
|
+
field: string;
|
|
219
|
+
message: string;
|
|
220
|
+
}>;
|
|
221
|
+
requestId?: string;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
type PlatformUrls = {
|
|
225
|
+
platformUrl: string;
|
|
226
|
+
idBaseUrl: string;
|
|
227
|
+
};
|
|
228
|
+
declare function resolvePlatformUrls(config: Pick<PlatformClientConfig, "platformUrl" | "idBaseUrl" | "isProduction">): PlatformUrls;
|
|
229
|
+
type PlatformClient = {
|
|
230
|
+
/** 진단 — 이 자격이 어느 워크스페이스·source에 묶였는가 */
|
|
231
|
+
me: () => Promise<PlatformMe>;
|
|
232
|
+
works: {
|
|
233
|
+
listPipelines: () => Promise<PlatformPipeline[]>;
|
|
234
|
+
upsertTask: (externalId: string, input: PlatformTaskUpsertInput) => Promise<PlatformWriteResult<PlatformTask>>;
|
|
235
|
+
getTask: (externalId: string) => Promise<PlatformTask>;
|
|
236
|
+
setTaskStage: (externalId: string, input: PlatformTaskStageInput) => Promise<PlatformWriteResult<PlatformTask>>;
|
|
237
|
+
};
|
|
238
|
+
webhooks: {
|
|
239
|
+
list: () => Promise<PlatformWebhook[]>;
|
|
240
|
+
upsert: (input: PlatformWebhookUpsertInput) => Promise<PlatformWriteResult<PlatformWebhook>>;
|
|
241
|
+
delete: (id: string) => Promise<{
|
|
242
|
+
id: string;
|
|
243
|
+
deleted: boolean;
|
|
244
|
+
}>;
|
|
245
|
+
};
|
|
246
|
+
/** 테스트·진단용 — 캐시된 토큰을 버린다 */
|
|
247
|
+
invalidateToken: () => void;
|
|
248
|
+
urls: PlatformUrls;
|
|
249
|
+
};
|
|
250
|
+
declare function createPlatformClient(config: PlatformClientConfig): PlatformClient;
|
|
251
|
+
//#endregion
|
|
252
|
+
export { DEFAULT_PLATFORM_SCOPES, PLATFORM_TASK_OUTCOMES, PLATFORM_TASK_PRIORITIES, PLATFORM_WEBHOOK_TRIGGERS, PlatformApiError, type PlatformClient, type PlatformClientConfig, type PlatformErrorBody, type PlatformMe, type PlatformPipeline, type PlatformTask, type PlatformTaskOutcome, type PlatformTaskPriority, type PlatformTaskStage, type PlatformTaskStageInput, type PlatformTaskUpsertInput, type PlatformUrls, type PlatformWebhook, type PlatformWebhookTrigger, type PlatformWebhookUpsertInput, type PlatformWorkTaskStageChangedEvent, type PlatformWriteMeta, type PlatformWriteResult, REOPT_PLATFORM_ID_URLS, REOPT_PLATFORM_URLS, createPlatformClient, platformErrorSchema, platformExternalIdSchema, platformMeSchema, platformPipelineSchema, platformTaskSchema, platformTaskStageInputSchema, platformTaskStageSchema, platformTaskUpsertInputSchema, platformWebhookSchema, platformWebhookUpsertInputSchema, platformWorkTaskStageChangedEventSchema, platformWriteMetaSchema, resolvePlatformUrls };
|
|
253
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { n as SDK_VERSION } from "../config-DkT0F-GG.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/workspace/schemas.ts
|
|
5
|
+
/**
|
|
6
|
+
* 플랫폼 API(RFC-0029) 와이어 계약 — zod 한 벌.
|
|
7
|
+
*
|
|
8
|
+
* 서버(`apps/web/server/hono/routes/platform-schemas.ts`)와 같은 모양이다. 패키지 경계 때문에
|
|
9
|
+
* 파일은 둘이지만 서버 테스트(`platform-sdk-parity.test.ts`)가 이 스키마로 서버 응답을 파싱해
|
|
10
|
+
* 파리티를 고정한다. 소비자(reopt-data 등)는 tRPC 입력·웹훅 검증에 그대로 쓴다.
|
|
11
|
+
*
|
|
12
|
+
* 🔑 `.default()`를 쓰지 않는다 — 생략(`undefined`)이 "건드리지 않는다"를 뜻하는 필드가 있다.
|
|
13
|
+
* 🔑 타입은 손으로 적고 스키마에 `z.ZodType<T>`를 단다 — 이 패키지는 `isolatedDeclarations`라
|
|
14
|
+
* 추론된 export가 빌드를 깬다(TS9010).
|
|
15
|
+
*/
|
|
16
|
+
const PLATFORM_TASK_PRIORITIES = [
|
|
17
|
+
"low",
|
|
18
|
+
"medium",
|
|
19
|
+
"high",
|
|
20
|
+
"urgent"
|
|
21
|
+
];
|
|
22
|
+
const PLATFORM_TASK_OUTCOMES = ["completed", "canceled"];
|
|
23
|
+
const PLATFORM_WEBHOOK_TRIGGERS = ["workTaskStageChanged"];
|
|
24
|
+
/** 소스 쪽 식별자 — 경로 세그먼트라 슬래시·공백 금지, ≤255 */
|
|
25
|
+
const platformExternalIdSchema = z.string().trim().min(1).max(255).regex(/^[^/\s]+$/, "externalId must not contain slashes or whitespace");
|
|
26
|
+
const versionSchema = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
27
|
+
const exactlyOneOf = (value) => value.stageId === void 0 !== (value.outcome === void 0);
|
|
28
|
+
const platformTaskStageSchema = z.object({
|
|
29
|
+
outcome: z.enum(PLATFORM_TASK_OUTCOMES).nullable().optional(),
|
|
30
|
+
stageId: z.uuid().optional()
|
|
31
|
+
}).strict().refine(exactlyOneOf, "stage needs exactly one of outcome or stageId");
|
|
32
|
+
const platformTaskUpsertInputSchema = z.object({
|
|
33
|
+
version: versionSchema,
|
|
34
|
+
title: z.string().trim().min(1).max(255),
|
|
35
|
+
description: z.string().trim().max(8e3).nullable().optional(),
|
|
36
|
+
priority: z.enum(PLATFORM_TASK_PRIORITIES).optional(),
|
|
37
|
+
dueDate: z.iso.datetime({ offset: true }).nullable().optional(),
|
|
38
|
+
brandId: z.uuid().optional(),
|
|
39
|
+
pipelineId: z.uuid().optional(),
|
|
40
|
+
url: z.url().max(2e3).nullable().optional(),
|
|
41
|
+
label: z.string().trim().min(1).max(64).nullable().optional(),
|
|
42
|
+
stage: platformTaskStageSchema.optional()
|
|
43
|
+
}).strict();
|
|
44
|
+
const platformTaskStageInputSchema = z.object({
|
|
45
|
+
version: versionSchema,
|
|
46
|
+
outcome: z.enum(PLATFORM_TASK_OUTCOMES).nullable().optional(),
|
|
47
|
+
stageId: z.uuid().optional()
|
|
48
|
+
}).strict().refine(exactlyOneOf, "exactly one of outcome or stageId is required");
|
|
49
|
+
const platformWebhookUpsertInputSchema = z.object({
|
|
50
|
+
url: z.url().max(2e3),
|
|
51
|
+
triggers: z.array(z.enum(PLATFORM_WEBHOOK_TRIGGERS)).min(1),
|
|
52
|
+
secret: z.string().min(16).max(1024).optional()
|
|
53
|
+
}).strict();
|
|
54
|
+
const outcomeSchema = z.enum(PLATFORM_TASK_OUTCOMES).nullable();
|
|
55
|
+
const platformTaskSchema = z.object({
|
|
56
|
+
id: z.string(),
|
|
57
|
+
workspaceId: z.string(),
|
|
58
|
+
brandId: z.string().nullable(),
|
|
59
|
+
title: z.string(),
|
|
60
|
+
description: z.string().nullable(),
|
|
61
|
+
priority: z.enum(PLATFORM_TASK_PRIORITIES),
|
|
62
|
+
dueDate: z.string().nullable(),
|
|
63
|
+
pipeline: z.object({
|
|
64
|
+
id: z.string(),
|
|
65
|
+
name: z.string()
|
|
66
|
+
}).nullable(),
|
|
67
|
+
stage: z.object({
|
|
68
|
+
id: z.string(),
|
|
69
|
+
key: z.string(),
|
|
70
|
+
label: z.string(),
|
|
71
|
+
outcome: outcomeSchema
|
|
72
|
+
}).nullable(),
|
|
73
|
+
externalRef: z.object({
|
|
74
|
+
source: z.string(),
|
|
75
|
+
externalId: z.string(),
|
|
76
|
+
url: z.string().nullable(),
|
|
77
|
+
label: z.string().nullable(),
|
|
78
|
+
version: z.number()
|
|
79
|
+
}),
|
|
80
|
+
url: z.string(),
|
|
81
|
+
createdAt: z.string(),
|
|
82
|
+
updatedAt: z.string()
|
|
83
|
+
});
|
|
84
|
+
const platformWriteMetaSchema = z.object({
|
|
85
|
+
created: z.boolean(),
|
|
86
|
+
applied: z.boolean()
|
|
87
|
+
});
|
|
88
|
+
const platformPipelineSchema = z.object({
|
|
89
|
+
id: z.string(),
|
|
90
|
+
name: z.string(),
|
|
91
|
+
isDefault: z.boolean(),
|
|
92
|
+
stages: z.array(z.object({
|
|
93
|
+
id: z.string(),
|
|
94
|
+
key: z.string(),
|
|
95
|
+
label: z.string(),
|
|
96
|
+
order: z.number(),
|
|
97
|
+
isEntry: z.boolean(),
|
|
98
|
+
outcome: outcomeSchema
|
|
99
|
+
}))
|
|
100
|
+
});
|
|
101
|
+
const platformMeSchema = z.object({
|
|
102
|
+
clientId: z.string(),
|
|
103
|
+
clientName: z.string(),
|
|
104
|
+
source: z.string(),
|
|
105
|
+
workspaceId: z.string(),
|
|
106
|
+
brandappId: z.string(),
|
|
107
|
+
defaultBrandId: z.string(),
|
|
108
|
+
scopes: z.array(z.string())
|
|
109
|
+
});
|
|
110
|
+
const platformWebhookSchema = z.object({
|
|
111
|
+
id: z.string(),
|
|
112
|
+
url: z.string(),
|
|
113
|
+
triggers: z.array(z.string()),
|
|
114
|
+
hasSecret: z.boolean()
|
|
115
|
+
});
|
|
116
|
+
const platformErrorSchema = z.object({ error: z.object({
|
|
117
|
+
code: z.string(),
|
|
118
|
+
message: z.string(),
|
|
119
|
+
retryable: z.boolean(),
|
|
120
|
+
fields: z.array(z.object({
|
|
121
|
+
field: z.string(),
|
|
122
|
+
message: z.string()
|
|
123
|
+
})).optional()
|
|
124
|
+
}) });
|
|
125
|
+
const platformWorkTaskStageChangedEventSchema = z.object({
|
|
126
|
+
id: z.string(),
|
|
127
|
+
title: z.string(),
|
|
128
|
+
pipelineId: z.string().nullable(),
|
|
129
|
+
fromStageLabel: z.string().nullable(),
|
|
130
|
+
toStageId: z.string(),
|
|
131
|
+
toStageLabel: z.string(),
|
|
132
|
+
toStageOutcome: outcomeSchema,
|
|
133
|
+
origin: z.string(),
|
|
134
|
+
version: z.number(),
|
|
135
|
+
externalRefs: z.array(z.object({
|
|
136
|
+
source: z.string(),
|
|
137
|
+
externalId: z.string(),
|
|
138
|
+
label: z.string().nullable()
|
|
139
|
+
}))
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/workspace/client.ts
|
|
144
|
+
/**
|
|
145
|
+
* 플랫폼 API(RFC-0029) 클라이언트 — **서버 전용**.
|
|
146
|
+
*
|
|
147
|
+
* `client_credentials`로 `platform.reopt.ai` audience 토큰을 받아(캐시·만료 60초 전 재발급·401 시 1회
|
|
148
|
+
* 재발급) `/v1/*`를 부른다. 브라우저에서 만들면 던진다 — clientSecret이 곧 워크스페이스 쓰기 권한이다.
|
|
149
|
+
*
|
|
150
|
+
* 기본 origin은 환경에서 파생하고(`isProduction` 또는 `REOPT_PLATFORM_URL`/`REOPT_ID_BASE_URL` env),
|
|
151
|
+
* 자체서명 dev 인증서는 `fetch` 주입(undici Agent 등)으로 요청 단위로 푼다 — 프로세스 전역
|
|
152
|
+
* `NODE_TLS_REJECT_UNAUTHORIZED`는 쓰지 않는다.
|
|
153
|
+
*/
|
|
154
|
+
const REOPT_PLATFORM_URLS = {
|
|
155
|
+
production: "https://platform.reopt.ai",
|
|
156
|
+
development: "https://platform.reopt.de:3443"
|
|
157
|
+
};
|
|
158
|
+
const REOPT_PLATFORM_ID_URLS = {
|
|
159
|
+
production: "https://id.reopt.ai",
|
|
160
|
+
development: "https://id.reopt.de:3443"
|
|
161
|
+
};
|
|
162
|
+
const DEFAULT_PLATFORM_SCOPES = ["works:read", "works:write"];
|
|
163
|
+
var PlatformApiError = class PlatformApiError extends Error {
|
|
164
|
+
status;
|
|
165
|
+
code;
|
|
166
|
+
retryable;
|
|
167
|
+
fields;
|
|
168
|
+
requestId;
|
|
169
|
+
constructor(input) {
|
|
170
|
+
super(`[platform ${input.status} ${input.code}] ${input.message}`);
|
|
171
|
+
this.name = "PlatformApiError";
|
|
172
|
+
this.status = input.status;
|
|
173
|
+
this.code = input.code;
|
|
174
|
+
this.retryable = input.retryable;
|
|
175
|
+
this.fields = input.fields;
|
|
176
|
+
this.requestId = input.requestId;
|
|
177
|
+
Object.setPrototypeOf(this, PlatformApiError.prototype);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const REFRESH_SKEW_MS = 6e4;
|
|
181
|
+
function readEnv(name) {
|
|
182
|
+
const value = (globalThis.process?.env)?.[name];
|
|
183
|
+
return value && value.length > 0 ? value : void 0;
|
|
184
|
+
}
|
|
185
|
+
function trimSlash(value) {
|
|
186
|
+
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
187
|
+
}
|
|
188
|
+
function assertServerRuntime() {
|
|
189
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") throw new Error("@reopt-ai/brandapp-sdk/workspace is server-only — clientSecret grants workspace write access and must never reach the browser.");
|
|
190
|
+
}
|
|
191
|
+
function resolvePlatformUrls(config) {
|
|
192
|
+
const production = config.isProduction ?? readEnv("NODE_ENV") === "production";
|
|
193
|
+
return {
|
|
194
|
+
platformUrl: trimSlash(config.platformUrl ?? readEnv("REOPT_PLATFORM_URL") ?? (production ? REOPT_PLATFORM_URLS.production : REOPT_PLATFORM_URLS.development)),
|
|
195
|
+
idBaseUrl: trimSlash(config.idBaseUrl ?? readEnv("REOPT_ID_BASE_URL") ?? (production ? REOPT_PLATFORM_ID_URLS.production : REOPT_PLATFORM_ID_URLS.development))
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function createPlatformClient(config) {
|
|
199
|
+
assertServerRuntime();
|
|
200
|
+
if (!config.clientId || !config.clientSecret) throw new Error("createPlatformClient: clientId and clientSecret are required");
|
|
201
|
+
const { platformUrl, idBaseUrl } = resolvePlatformUrls(config);
|
|
202
|
+
const scopes = config.scopes ?? DEFAULT_PLATFORM_SCOPES;
|
|
203
|
+
const fetchImpl = config.fetch ?? globalThis.fetch;
|
|
204
|
+
const timeoutMs = config.timeoutMs ?? 1e4;
|
|
205
|
+
const nextRequestId = config.requestId ?? (() => crypto.randomUUID());
|
|
206
|
+
let token = null;
|
|
207
|
+
let inflight = null;
|
|
208
|
+
async function fetchToken() {
|
|
209
|
+
const body = new URLSearchParams({
|
|
210
|
+
grant_type: "client_credentials",
|
|
211
|
+
client_id: config.clientId,
|
|
212
|
+
client_secret: config.clientSecret,
|
|
213
|
+
scope: scopes.join(" "),
|
|
214
|
+
resource: platformUrl
|
|
215
|
+
});
|
|
216
|
+
const res = await fetchImpl(`${idBaseUrl}/api/auth/oauth2/token`, {
|
|
217
|
+
method: "POST",
|
|
218
|
+
headers: {
|
|
219
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
220
|
+
accept: "application/json",
|
|
221
|
+
"x-sdk-version": SDK_VERSION
|
|
222
|
+
},
|
|
223
|
+
body,
|
|
224
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
225
|
+
});
|
|
226
|
+
const json = await res.json().catch(() => null);
|
|
227
|
+
if (!res.ok || !json?.access_token) throw new PlatformApiError({
|
|
228
|
+
status: res.status,
|
|
229
|
+
code: json?.error ?? "TOKEN_ERROR",
|
|
230
|
+
message: json?.error_description ?? "Failed to obtain platform access token",
|
|
231
|
+
retryable: res.status >= 500 || res.status === 429
|
|
232
|
+
});
|
|
233
|
+
const ttlMs = (json.expires_in ?? 3600) * 1e3;
|
|
234
|
+
return {
|
|
235
|
+
accessToken: json.access_token,
|
|
236
|
+
expiresAt: Date.now() + ttlMs
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
async function getToken(force = false) {
|
|
240
|
+
if (!force && token && token.expiresAt - REFRESH_SKEW_MS > Date.now()) return token.accessToken;
|
|
241
|
+
if (!inflight) inflight = fetchToken().finally(() => {
|
|
242
|
+
inflight = null;
|
|
243
|
+
});
|
|
244
|
+
token = await inflight;
|
|
245
|
+
return token.accessToken;
|
|
246
|
+
}
|
|
247
|
+
async function request(method, path, options) {
|
|
248
|
+
const accessToken = await getToken(options.retried === true);
|
|
249
|
+
const requestId = nextRequestId();
|
|
250
|
+
const res = await fetchImpl(`${platformUrl}${path}`, {
|
|
251
|
+
method,
|
|
252
|
+
headers: {
|
|
253
|
+
authorization: `Bearer ${accessToken}`,
|
|
254
|
+
accept: "application/json",
|
|
255
|
+
"x-request-id": requestId,
|
|
256
|
+
"x-sdk-version": SDK_VERSION,
|
|
257
|
+
...options.body !== void 0 ? { "content-type": "application/json" } : {}
|
|
258
|
+
},
|
|
259
|
+
body: options.body !== void 0 ? JSON.stringify(options.body) : void 0,
|
|
260
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
261
|
+
});
|
|
262
|
+
if (res.status === 401 && !options.retried) {
|
|
263
|
+
token = null;
|
|
264
|
+
return request(method, path, {
|
|
265
|
+
...options,
|
|
266
|
+
retried: true
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
const text = await res.text();
|
|
270
|
+
const json = text ? JSON.parse(text) : null;
|
|
271
|
+
if (!res.ok) {
|
|
272
|
+
const parsed = platformErrorSchema.safeParse(json);
|
|
273
|
+
const error = parsed.success ? parsed.data.error : null;
|
|
274
|
+
throw new PlatformApiError({
|
|
275
|
+
status: res.status,
|
|
276
|
+
code: error?.code ?? "HTTP_ERROR",
|
|
277
|
+
message: error?.message ?? `Platform API responded ${res.status}`,
|
|
278
|
+
retryable: error?.retryable ?? (res.status >= 500 || res.status === 429),
|
|
279
|
+
fields: error?.fields,
|
|
280
|
+
requestId: res.headers.get("x-request-id") ?? requestId
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return options.parse(json);
|
|
284
|
+
}
|
|
285
|
+
const parseWrite = (value) => {
|
|
286
|
+
const envelope = value;
|
|
287
|
+
return {
|
|
288
|
+
data: platformTaskSchema.parse(envelope.data),
|
|
289
|
+
meta: platformWriteMetaSchema.parse(envelope.meta)
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
const parseData = (parse) => (value) => parse(value.data);
|
|
293
|
+
return {
|
|
294
|
+
/** 진단 — 이 자격이 어느 워크스페이스·source에 묶였는가 */
|
|
295
|
+
me: () => request("GET", "/v1/me", { parse: parseData((v) => platformMeSchema.parse(v)) }),
|
|
296
|
+
works: {
|
|
297
|
+
listPipelines: () => request("GET", "/v1/works/pipelines", { parse: parseData((v) => platformPipelineSchema.array().parse(v)) }),
|
|
298
|
+
upsertTask: (externalId, input) => request("PUT", `/v1/works/tasks/${encodeURIComponent(externalId)}`, {
|
|
299
|
+
body: input,
|
|
300
|
+
parse: parseWrite
|
|
301
|
+
}),
|
|
302
|
+
getTask: (externalId) => request("GET", `/v1/works/tasks/${encodeURIComponent(externalId)}`, { parse: parseData((v) => platformTaskSchema.parse(v)) }),
|
|
303
|
+
setTaskStage: (externalId, input) => request("PATCH", `/v1/works/tasks/${encodeURIComponent(externalId)}/stage`, {
|
|
304
|
+
body: input,
|
|
305
|
+
parse: parseWrite
|
|
306
|
+
})
|
|
307
|
+
},
|
|
308
|
+
webhooks: {
|
|
309
|
+
list: () => request("GET", "/v1/webhooks", { parse: parseData((v) => platformWebhookSchema.array().parse(v)) }),
|
|
310
|
+
upsert: (input) => request("PUT", "/v1/webhooks", {
|
|
311
|
+
body: input,
|
|
312
|
+
parse: (value) => {
|
|
313
|
+
const envelope = value;
|
|
314
|
+
return {
|
|
315
|
+
data: platformWebhookSchema.parse(envelope.data),
|
|
316
|
+
meta: platformWriteMetaSchema.parse(envelope.meta)
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}),
|
|
320
|
+
delete: (id) => request("DELETE", `/v1/webhooks/${encodeURIComponent(id)}`, { parse: parseData((v) => v) })
|
|
321
|
+
},
|
|
322
|
+
/** 테스트·진단용 — 캐시된 토큰을 버린다 */
|
|
323
|
+
invalidateToken: () => {
|
|
324
|
+
token = null;
|
|
325
|
+
},
|
|
326
|
+
urls: {
|
|
327
|
+
platformUrl,
|
|
328
|
+
idBaseUrl
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
//#endregion
|
|
334
|
+
export { DEFAULT_PLATFORM_SCOPES, PLATFORM_TASK_OUTCOMES, PLATFORM_TASK_PRIORITIES, PLATFORM_WEBHOOK_TRIGGERS, PlatformApiError, REOPT_PLATFORM_ID_URLS, REOPT_PLATFORM_URLS, createPlatformClient, platformErrorSchema, platformExternalIdSchema, platformMeSchema, platformPipelineSchema, platformTaskSchema, platformTaskStageInputSchema, platformTaskStageSchema, platformTaskUpsertInputSchema, platformWebhookSchema, platformWebhookUpsertInputSchema, platformWorkTaskStageChangedEventSchema, platformWriteMetaSchema, resolvePlatformUrls };
|
|
335
|
+
//# sourceMappingURL=index.js.map
|
package/docs/api-reference.md
CHANGED
|
@@ -314,8 +314,8 @@ await generateText({
|
|
|
314
314
|
});
|
|
315
315
|
|
|
316
316
|
// Image generation via AI SDK
|
|
317
|
-
import {
|
|
318
|
-
const { image } = await
|
|
317
|
+
import { generateImage } from "ai";
|
|
318
|
+
const { image } = await generateImage({
|
|
319
319
|
model: brandapp.imageModel("google/gemini-2.5-flash-image"),
|
|
320
320
|
prompt: "A brand banner",
|
|
321
321
|
providerOptions: { brandapp: { style: "minimalist", aspectRatio: "16:9" } },
|
|
@@ -329,17 +329,18 @@ BrandApp AI API는 멀티테넌트 안전을 위해 **텍스트·이미지 표
|
|
|
329
329
|
**지원**
|
|
330
330
|
|
|
331
331
|
- `generateText()`, `streamText()` — 텍스트 생성
|
|
332
|
-
- `
|
|
332
|
+
- `generateImage()` — 이미지 생성 (`brandapp.imageModel(...)`)
|
|
333
333
|
- `providerMetadata.brandapp` — `creditCost` / `creditsRemaining` / `responseId`
|
|
334
334
|
- `providerOptions.brandapp` — `customerId` / `style` / `negativePrompt` / `aspectRatio`
|
|
335
335
|
- `finishReason` — 서버가 보고하면 정확히 매핑(미보고 시 `stop`)
|
|
336
336
|
|
|
337
|
-
**미지원**
|
|
337
|
+
**미지원**
|
|
338
338
|
|
|
339
|
-
- tool/function calling — `tools
|
|
340
|
-
- 구조화 출력 —
|
|
341
|
-
- 비전·파일 입력 —
|
|
342
|
-
-
|
|
339
|
+
- tool/function calling — `tools` 또는 필수 `toolChoice` 요청은 HTTP 호출 전에 `UnsupportedFunctionalityError`
|
|
340
|
+
- 구조화 출력 — JSON response format 요청은 HTTP 호출 전에 `UnsupportedFunctionalityError`
|
|
341
|
+
- 비전·파일 입력 — 사용자·assistant·도구 결과의 이미지/파일은 HTTP 호출 전에 `UnsupportedFunctionalityError`
|
|
342
|
+
- 이미지 편집·참조·마스크 — 이미지 모델의 `files` / `mask` 요청도 HTTP 호출 전에 `UnsupportedFunctionalityError`
|
|
343
|
+
- `topP` / `topK` / `frequencyPenalty` / `presencePenalty` / `stopSequences` / `seed` — warning 후 생략
|
|
343
344
|
- 임베딩·음성·전사 모델 — `brandapp.embeddingModel(...)` 등은 `NoSuchModelError`
|
|
344
345
|
|
|
345
346
|
**에러** — provider는 `APICallError`(AI SDK 표준)를 던진다. `error.isRetryable`로 재시도
|
|
@@ -404,7 +405,7 @@ await sdk.eav.records.update(entityId, recordId, { expiresAt: null }); // TTL
|
|
|
404
405
|
| 속성/엔티티 | 100 | `LIMIT_EXCEEDED_ATTRIBUTES` |
|
|
405
406
|
| 레코드/엔티티 | 10,000 기본 (운영자 `BRANDAPP_EAV_MAX_RECORDS_PER_ENTITY`로 인상) — 만료 행 제외 | `LIMIT_EXCEEDED_RECORDS` (422) |
|
|
406
407
|
| 인메모리 후보 상한 | 10,000행 — 필터가 SQL로 못 내려가는 요청(`neq`/`not_in`/`after`/`before`, 커스텀 속성 정렬)만 해당 | `QUERY_TOO_BROAD` (422) |
|
|
407
|
-
| `list` limit | 최대 100, 기본 50
|
|
408
|
+
| `list` limit | 최대 100, 기본 50 — SDK가 요청 전에 거절(`RECORDS_PAGE_LIMIT_MAX`), 여러 페이지는 `listAll()` | 400 |
|
|
408
409
|
| bulk create/update/delete | 호출당 100건 | 400 |
|
|
409
410
|
| 레코드 값 직렬화 | 128KB/레코드 | `VALIDATION_ERROR` (422) |
|
|
410
411
|
| 엔티티·속성 name/label | 100자, description 500자 | 400 |
|
|
@@ -414,7 +415,9 @@ await sdk.eav.records.update(entityId, recordId, { expiresAt: null }); // TTL
|
|
|
414
415
|
|
|
415
416
|
```typescript
|
|
416
417
|
|
|
417
|
-
// Pagination (async generator)
|
|
418
|
+
// Pagination (async generator) — limit은 페이지 크기이고 총량이 아니다.
|
|
419
|
+
// list()에 100을 넘기면 400이 아니라 요청 전에 BadRequestError로 거절된다.
|
|
420
|
+
import { RECORDS_PAGE_LIMIT_MAX } from "@reopt-ai/brandapp-sdk/eav"; // 100
|
|
418
421
|
for await (const record of sdk.eav.records.listAll(entityId)) { ... }
|
|
419
422
|
```
|
|
420
423
|
|
|
@@ -508,7 +511,9 @@ export async function generateMetadata({ params }): Promise<Metadata> {
|
|
|
508
511
|
|
|
509
512
|
// app/sitemap.ts — Next.js MetadataRoute.Sitemap
|
|
510
513
|
export default async function sitemap() {
|
|
511
|
-
|
|
514
|
+
// limit 상한은 100 — 그 이상은 더 큰 페이지가 아니라 400이다. 글이 더 많으면
|
|
515
|
+
// page를 돌려 모은다(EAV는 sdk.eav.records.listAll()이 대신 돌아 준다).
|
|
516
|
+
const { records } = await sdk.cms.posts.list({ status: "published", limit: 100 });
|
|
512
517
|
return toSitemapItems(records, {
|
|
513
518
|
siteUrl: "https://www.example.com",
|
|
514
519
|
basePath?: "/blog", // Default "/blog"
|
package/docs/cms.md
CHANGED
|
@@ -149,9 +149,11 @@ import type { MetadataRoute } from "next";
|
|
|
149
149
|
import { toSitemapItems } from "@reopt-ai/brandapp-sdk/cms";
|
|
150
150
|
|
|
151
151
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
152
|
+
// limit 상한은 100 — 그 이상은 더 큰 페이지가 아니라 400이다.
|
|
153
|
+
// 글이 100개를 넘으면 page를 올려 가며 모은다.
|
|
152
154
|
const { records } = await sdk.cms.posts.list({
|
|
153
155
|
status: "published",
|
|
154
|
-
limit:
|
|
156
|
+
limit: 100,
|
|
155
157
|
sortBy: "publishedAt",
|
|
156
158
|
sortOrder: "desc",
|
|
157
159
|
});
|