@reopt-ai/workspace-sdk 0.0.0-stage → 0.1.0-rc.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.
@@ -0,0 +1,72 @@
1
+ import { i as ClientPrivateJwk, r as ClientKeyRing } from "./keys-B2pA8EkU.js";
2
+ //#region src/machine/client.d.ts
3
+ type MachineClientConfig = {
4
+ /** `purpose: machine`(또는 `adapter`) 클라이언트의 client_id */
5
+ clientId: string;
6
+ /**
7
+ * 개인키 JWK(kid·alg 포함) 또는 키 링. 생략하면 env `REOPT_CLIENT_PRIVATE_KEY_JWK`(+`_NEXT`)를 읽는다.
8
+ * 🔴 브라우저에서 호출하면 throw — 개인키는 서버에만 있다.
9
+ */
10
+ privateKeyJwk?: ClientPrivateJwk;
11
+ keyRing?: ClientKeyRing;
12
+ /**
13
+ * 토큰 audience — 부를 서비스의 origin(RFC 8707 `resource`). 플랫폼 API `https://platform.reopt.ai`,
14
+ * 브랜드앱 API `https://brandapp.reopt.ai`, reopt-data `https://data.reopt.ai`. 하나만(여러 resource는
15
+ * 서버가 scope 교집합으로 좁혀 거절될 수 있다).
16
+ */
17
+ resource: string;
18
+ /** 요청 scope — 클라이언트 행의 `clientCredentialsScopes`·리소스 `allowedScopes` 안이어야 한다 */
19
+ scopes: readonly string[];
20
+ /** id 서버 origin — 생략하면 `REOPT_ID_BASE_URL` / `REOPT_BASE_URL` 유도 */
21
+ idBaseUrl?: string;
22
+ /** DPoP 바인딩 — 기본 true(불변식 2). false면 Bearer 토큰(리소스가 허용할 때만) */
23
+ dpop?: boolean;
24
+ fetch?: typeof globalThis.fetch;
25
+ timeoutMs?: number;
26
+ /** 테스트용 시계 */
27
+ now?: () => number;
28
+ };
29
+ type MachineTokenState = {
30
+ accessToken: string;
31
+ tokenType: "DPoP" | "Bearer";
32
+ expiresAt: number;
33
+ scope: string;
34
+ };
35
+ type MachineClient = {
36
+ readonly clientId: string;
37
+ readonly resource: string;
38
+ /** 현재 서명·DPoP 키의 kid(회전 관측용) */
39
+ readonly kid: string;
40
+ /** 유효한 access token(만료 60초 전 재발급). `force`면 캐시를 버리고 새로 받는다 */
41
+ getToken(force?: boolean): Promise<string>;
42
+ /** 요청 하나에 붙일 인증 헤더 — `Authorization` + (`DPoP`). URL·메서드가 증명에 묶이므로 요청마다 새로 만든다 */
43
+ headers(request: {
44
+ method: string;
45
+ url: string;
46
+ }): Promise<Record<string, string>>;
47
+ /** `fetch`에 인증 헤더를 붙이고, 401이면 토큰을 한 번 재발급해 재시도한다 */
48
+ fetch(input: string | URL, init?: RequestInit): Promise<Response>;
49
+ /** 캐시된 토큰을 버린다(진단·테스트) */
50
+ invalidateToken(): void;
51
+ };
52
+ declare class MachineTokenError extends Error {
53
+ readonly status: number;
54
+ readonly code: string;
55
+ constructor(input: {
56
+ status: number;
57
+ code: string;
58
+ message: string;
59
+ });
60
+ }
61
+ /** DPoP 증명(RFC 9449 §4) — htm·htu(쿼리·프래그먼트 제거)·jti·iat, 리소스 요청이면 ath. */
62
+ declare function createDpopProof(input: {
63
+ key: ClientPrivateJwk;
64
+ method: string;
65
+ url: string;
66
+ accessToken?: string;
67
+ now?: number;
68
+ }): Promise<string>;
69
+ declare function createMachineClient(config: MachineClientConfig): MachineClient;
70
+ //#endregion
71
+ export { createDpopProof as a, MachineTokenState as i, MachineClientConfig as n, createMachineClient as o, MachineTokenError as r, MachineClient as t };
72
+ //# sourceMappingURL=client-DlgVNj3w.d.ts.map
@@ -0,0 +1,191 @@
1
+ import { resolveIdBaseUrl } from "./urls.js";
2
+ import { o as readClientKeyRing, s as toPublicJwk } from "./keys-6gwtNd0g.js";
3
+ import { createPrivateKeyJwtClientAssertionGetter } from "@better-auth/core/oauth2";
4
+ import * as jose from "jose";
5
+
6
+ //#region src/machine/client.ts
7
+ /**
8
+ * 기계 클라이언트 (RFC-0034 §3.2) — `private_key_jwt` 단언으로 `client_credentials` 토큰을 받고,
9
+ * 매 요청에 DPoP 증명을 붙인다. 리옵트 플랫폼 API·브랜드앱 API·서브 제품 리소스(reopt-data 등)
10
+ * 전부 같은 클라이언트로 부른다 — **호출 대상(resource)마다 토큰이 따로**다(aud 하나, RFC-0034 §3.2).
11
+ *
12
+ * 서버 전용이다. 개인키는 env(`REOPT_CLIENT_PRIVATE_KEY_JWK`)에서 읽고 브라우저 번들에 들어갈 수 없다.
13
+ *
14
+ * 흐름:
15
+ * token(): POST {id}/api/auth/oauth2/token
16
+ * grant_type=client_credentials · client_assertion(JWS, exp≤5m, jti) · scope · resource
17
+ * 헤더 DPoP: 증명(htm=POST, htu=token endpoint) → access_token(`cnf.jkt` 바인딩)
18
+ * headers(): Authorization: DPoP <token> · DPoP: 증명(htm, htu=요청 URL, ath=sha256(token))
19
+ *
20
+ * 🔑 better-auth core가 단언 서명(`createPrivateKeyJwtClientAssertionGetter`)과 서버 쪽 DPoP 검증을
21
+ * 내장하므로 클라이언트 쪽 DPoP 증명만 jose로 만든다(core의 `clientCredentialsToken`은 DPoP 헤더를
22
+ * 싣지 않아 토큰 요청은 직접 조립한다).
23
+ */
24
+ var MachineTokenError = class extends Error {
25
+ status;
26
+ code;
27
+ constructor(input) {
28
+ super(input.message);
29
+ this.name = "MachineTokenError";
30
+ this.status = input.status;
31
+ this.code = input.code;
32
+ }
33
+ };
34
+ const REFRESH_SKEW_MS = 6e4;
35
+ const CLIENT_ASSERTION_TTL_SECONDS = 120;
36
+ function assertServerRuntime() {
37
+ if (typeof window !== "undefined") throw new Error("[@reopt-ai/workspace-sdk/machine] createMachineClient() must be called on the server — it holds the client private key.");
38
+ }
39
+ async function importPrivateKey(jwk) {
40
+ return jose.importJWK(jwk, jwk.alg);
41
+ }
42
+ /** DPoP 증명(RFC 9449 §4) — htm·htu(쿼리·프래그먼트 제거)·jti·iat, 리소스 요청이면 ath. */
43
+ async function createDpopProof(input) {
44
+ const parsed = new URL(input.url);
45
+ const htu = `${parsed.origin}${parsed.pathname}`;
46
+ const payload = {
47
+ htm: input.method.toUpperCase(),
48
+ htu,
49
+ jti: crypto.randomUUID()
50
+ };
51
+ if (input.accessToken) {
52
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(input.accessToken));
53
+ payload.ath = jose.base64url.encode(new Uint8Array(digest));
54
+ }
55
+ return new jose.SignJWT(payload).setProtectedHeader({
56
+ alg: input.key.alg,
57
+ typ: "dpop+jwt",
58
+ jwk: toPublicJwk(input.key)
59
+ }).setIssuedAt(input.now !== void 0 ? Math.floor(input.now / 1e3) : void 0).sign(await importPrivateKey(input.key));
60
+ }
61
+ function createMachineClient(config) {
62
+ assertServerRuntime();
63
+ if (!config.clientId) throw new Error("[@reopt-ai/workspace-sdk/machine] clientId is required");
64
+ if (!config.resource) throw new Error("[@reopt-ai/workspace-sdk/machine] resource (token audience) is required");
65
+ const ring = config.keyRing ?? (config.privateKeyJwk ? {
66
+ signing: config.privateKeyJwk,
67
+ published: [config.privateKeyJwk]
68
+ } : null) ?? readClientKeyRing();
69
+ if (!ring) throw new Error("[@reopt-ai/workspace-sdk/machine] no client private key — pass privateKeyJwk or set REOPT_CLIENT_PRIVATE_KEY_JWK (generate with `npx -p @reopt-ai/workspace-sdk reopt-keygen`)");
70
+ const key = ring.signing;
71
+ const useDpop = config.dpop ?? true;
72
+ const tokenEndpoint = `${resolveIdBaseUrl({ ...config.idBaseUrl ? { idBaseUrl: config.idBaseUrl } : {} })}/api/auth/oauth2/token`;
73
+ const fetchImpl = config.fetch ?? globalThis.fetch;
74
+ const timeoutMs = config.timeoutMs ?? 1e4;
75
+ const now = config.now ?? (() => Date.now());
76
+ const scope = config.scopes.join(" ");
77
+ const getClientAssertion = createPrivateKeyJwtClientAssertionGetter({
78
+ privateKeyJwk: key,
79
+ kid: key.kid,
80
+ algorithm: key.alg,
81
+ expiresIn: CLIENT_ASSERTION_TTL_SECONDS
82
+ });
83
+ let state = null;
84
+ let inflight = null;
85
+ async function requestToken() {
86
+ const assertion = await getClientAssertion({
87
+ clientId: config.clientId,
88
+ tokenEndpoint,
89
+ grantType: "client_credentials"
90
+ });
91
+ const body = new URLSearchParams({
92
+ grant_type: "client_credentials",
93
+ client_id: config.clientId,
94
+ client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
95
+ client_assertion: assertion,
96
+ ...scope ? { scope } : {},
97
+ resource: config.resource
98
+ });
99
+ const headers = {
100
+ "content-type": "application/x-www-form-urlencoded",
101
+ accept: "application/json"
102
+ };
103
+ if (useDpop) headers.DPoP = await createDpopProof({
104
+ key,
105
+ method: "POST",
106
+ url: tokenEndpoint,
107
+ now: now()
108
+ });
109
+ const res = await fetchImpl(tokenEndpoint, {
110
+ method: "POST",
111
+ headers,
112
+ body,
113
+ signal: AbortSignal.timeout(timeoutMs)
114
+ });
115
+ const json = await res.json().catch(() => null);
116
+ if (!res.ok || !json?.access_token) throw new MachineTokenError({
117
+ status: res.status,
118
+ code: json?.error ?? "token_error",
119
+ message: json?.error_description ?? `Failed to obtain machine access token (${res.status})`
120
+ });
121
+ const tokenType = (json.token_type ?? (useDpop ? "DPoP" : "Bearer")).toLowerCase() === "dpop" ? "DPoP" : "Bearer";
122
+ if (useDpop && tokenType !== "DPoP") throw new MachineTokenError({
123
+ status: res.status,
124
+ code: "dpop_not_bound",
125
+ message: "Token endpoint returned a Bearer token although DPoP was requested — is `dpopBoundAccessTokens` set on the client?"
126
+ });
127
+ return {
128
+ accessToken: json.access_token,
129
+ tokenType,
130
+ expiresAt: now() + (json.expires_in ?? 3600) * 1e3,
131
+ scope: json.scope ?? scope
132
+ };
133
+ }
134
+ async function getToken(force = false) {
135
+ if (!force && state && state.expiresAt - REFRESH_SKEW_MS > now()) return state.accessToken;
136
+ if (!inflight) inflight = requestToken().finally(() => {
137
+ inflight = null;
138
+ });
139
+ state = await inflight;
140
+ return state.accessToken;
141
+ }
142
+ async function headers(request) {
143
+ const token = await getToken();
144
+ if (!useDpop) return { Authorization: `Bearer ${token}` };
145
+ return {
146
+ Authorization: `DPoP ${token}`,
147
+ DPoP: await createDpopProof({
148
+ key,
149
+ method: request.method,
150
+ url: request.url,
151
+ accessToken: token,
152
+ now: now()
153
+ })
154
+ };
155
+ }
156
+ async function authedFetch(input, init = {}) {
157
+ const url = typeof input === "string" ? input : input.toString();
158
+ const method = (init.method ?? "GET").toUpperCase();
159
+ const send = async () => fetchImpl(url, {
160
+ ...init,
161
+ method,
162
+ headers: {
163
+ ...init.headers,
164
+ ...await headers({
165
+ method,
166
+ url
167
+ })
168
+ }
169
+ });
170
+ const first = await send();
171
+ if (first.status !== 401) return first;
172
+ state = null;
173
+ await getToken(true);
174
+ return send();
175
+ }
176
+ return {
177
+ clientId: config.clientId,
178
+ resource: config.resource,
179
+ kid: key.kid,
180
+ getToken,
181
+ headers,
182
+ fetch: authedFetch,
183
+ invalidateToken: () => {
184
+ state = null;
185
+ }
186
+ };
187
+ }
188
+
189
+ //#endregion
190
+ export { createDpopProof as n, createMachineClient as r, MachineTokenError as t };
191
+ //# sourceMappingURL=client-XAvKlbbn.js.map
@@ -0,0 +1,350 @@
1
+ import { $ as PlatformResources, $t as platformWriteMetaSchema, A as PlatformEavBrandappResources, At as platformOAuthClientImportInputSchema, B as PlatformOAuthClientImportInput, Bt as platformPublishedPostSchema, C as PlatformBrandImportInput, Ct as platformEavSchemaApplyResultSchema, D as PlatformBrandappUpsertInput, Dt as platformLockAcquiredSchema, E as PlatformBrandappResource, Et as platformExternalIdSchema, F as PlatformErrorBody, Ft as platformPipelineSchema, G as PlatformPipelineImportInput, Gt as platformTaskSchema, H as PlatformOAuthClientResource, Ht as platformResourceKeySchema, I as PlatformLockAcquired, It as platformPipelineStageInputSchema, J as PlatformPipelineUpsertInput, Jt as platformTaskUpsertInputSchema, K as PlatformPipelineResource, Kt as platformTaskStageInputSchema, L as PlatformLockReleased, Lt as platformPipelineUpsertInputSchema, M as PlatformEavSchemaApplyInput, Mt as platformOAuthClientUpsertInputSchema, N as PlatformEavSchemaApplyResult, Nt as platformPipelineImportInputSchema, O as PlatformCustomerUpsertInput, Ot as platformLockReleasedSchema, P as PlatformEavSchemaOperation, Pt as platformPipelineResourceSchema, Q as PlatformPublishedPostSummary, Qt as platformWorkTaskStageChangedEventSchema, R as PlatformManagedBy, Rt as platformPublishedPostListQuerySchema, S as PLATFORM_WEBHOOK_TRIGGERS, St as platformEavSchemaApplyInputSchema, T as PlatformBrandUpsertInput, Tt as platformErrorSchema, U as PlatformOAuthClientUpsertInput, Ut as platformResourcesSchema, V as PlatformOAuthClientPurpose, Vt as platformPublishedPostSummarySchema, W as PlatformPipeline, Wt as platformResourcesV2Schema, X as PlatformPublishedPostListOptions, Xt as platformWebhookSchema, Y as PlatformPublishedPost, Yt as platformWebhookResourceSchema, Z as PlatformPublishedPostPage, Zt as platformWebhookUpsertInputSchema, _ as PLATFORM_OAUTH_GRANT_TYPES, _t as platformBrandappResourceSchema, a as PlatformUrls, at as PlatformTaskStage, b as PLATFORM_TASK_PRIORITIES, bt as platformEavBrandappResourcesSchema, c as REOPT_PLATFORM_URLS, ct as PlatformWebhook, d as PLATFORM_ADMIN_SCOPE, dt as PlatformWebhookUpsertInput, et as PlatformResourcesV2, f as PLATFORM_BRANDAPP_STATUSES, ft as PlatformWorkTaskStageChangedEvent, g as PLATFORM_OAUTH_CLIENT_PURPOSES, gt as platformBrandUpsertInputSchema, h as PLATFORM_OAUTH_APPLICATION_TYPES, ht as platformBrandResourceSchema, i as PlatformClientConfig, it as PlatformTaskPriority, j as PlatformEavEntityResource, jt as platformOAuthClientResourceSchema, k as PlatformDomainStatus, kt as platformMeSchema, l as createPlatformClient, lt as PlatformWebhookResource, m as PLATFORM_MANAGED_BY_VALUES, mt as platformBrandImportInputSchema, n as PlatformApiError, nt as PlatformTask, o as PlatformWriteResult, ot as PlatformTaskStageInput, p as PLATFORM_DOMAIN_STATUSES, pt as PlatformWriteMeta, q as PlatformPipelineStageInput, qt as platformTaskStageSchema, r as PlatformClient, rt as PlatformTaskOutcome, s as REOPT_PLATFORM_ID_URLS, st as PlatformTaskUpsertInput, t as DEFAULT_PLATFORM_SCOPES, tt as PlatformStageColor, u as resolvePlatformUrls, ut as PlatformWebhookTrigger, v as PLATFORM_STAGE_COLORS, vt as platformBrandappUpsertInputSchema, w as PlatformBrandResource, wt as platformEavSchemaOperationSchema, x as PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS, xt as platformEavEntityResourceSchema, y as PLATFORM_TASK_OUTCOMES, yt as platformCustomerUpsertInputSchema, z as PlatformMe, zt as platformPublishedPostPageSchema } from "./client-C5qUNFSq.js";
2
+ import { z } from "zod";
3
+ //#region src/workspace/connect.d.ts
4
+ /**
5
+ * RFC-0043 — 사용자 위임 표면(`/v1/connect/*`) 클라이언트. 워크스페이스 앱의 직원이 리옵트로 로그인하면(설치의
6
+ * `connect` 클라이언트, authorization_code) 받은 **그 사람의** 토큰으로 워크스페이스 데이터를 읽고 쓴다.
7
+ *
8
+ * - 워크스페이스는 요청에 없다 — 동의 화면에서 고른 워크스페이스로 서버가 정한다.
9
+ * - 행위자도 요청에 없다 — 토큰의 사용자다(업무 작성자·활동 기록·파일 업로더·감사 기록).
10
+ * - 권한은 scope(`workspace:read`·`workspace:write`·`customer:read`) ∩ 그 사람의 워크스페이스 역할이다.
11
+ * `me()`의 `permissions`로 버튼을 숨기고, 판정의 정본은 언제나 서버다(거절은 `PlatformApiError` 403).
12
+ *
13
+ * 응답 스키마는 SDK가 **약속하는 필드만** 검사하고 나머지는 통과시킨다(서버가 필드를 더해도 깨지지 않는다).
14
+ */
15
+ type ConnectAccessToken = string | (() => string | Promise<string>);
16
+ type ConnectClientConfig = {
17
+ /** 위임 액세스 토큰 — 문자열 또는 요청마다 부르는 함수(만료 시 갱신은 호출자의 몫) */
18
+ accessToken: ConnectAccessToken;
19
+ /** 기본: `NODE_ENV` 기준 `https://platform.reopt.ai` / `https://platform.local.reopt.io` */
20
+ platformUrl?: string;
21
+ fetch?: typeof fetch;
22
+ timeoutMs?: number;
23
+ };
24
+ type ConnectMe = {
25
+ principal: "user";
26
+ clientId: string;
27
+ clientName: string;
28
+ user: {
29
+ id: string;
30
+ name: string | null;
31
+ email: string | null;
32
+ };
33
+ workspace: {
34
+ id: string;
35
+ name: string;
36
+ tier: string;
37
+ };
38
+ scopes: string[];
39
+ member: {
40
+ id: string;
41
+ role: string;
42
+ };
43
+ /** 이 멤버가 지금 가진 권한 키(예: `works:update`, `post:publish`) */
44
+ permissions: string[];
45
+ };
46
+ type ConnectMember = {
47
+ memberId: string;
48
+ userId: string;
49
+ name: string;
50
+ image: string | null;
51
+ };
52
+ type ConnectStageOutcome = "completed" | "canceled";
53
+ type ConnectPipeline = {
54
+ id: string;
55
+ name: string;
56
+ isDefault: boolean;
57
+ isArchived: boolean;
58
+ key: string | null;
59
+ stages: Array<{
60
+ id: string;
61
+ key: string;
62
+ label: string;
63
+ color: string;
64
+ order: number;
65
+ isEntry: boolean;
66
+ outcome: ConnectStageOutcome | null;
67
+ }>;
68
+ };
69
+ type ConnectTaskPriority = "low" | "medium" | "high" | "urgent";
70
+ type ConnectTask = {
71
+ id: string;
72
+ title: string;
73
+ description: string | null;
74
+ priority: ConnectTaskPriority;
75
+ dueDate: string | null;
76
+ startDate: string | null;
77
+ isTimed: boolean;
78
+ sortOrder: number;
79
+ pipeline: {
80
+ id: string;
81
+ name: string;
82
+ } | null;
83
+ stage: {
84
+ id: string;
85
+ key: string;
86
+ label: string;
87
+ outcome: ConnectStageOutcome | null;
88
+ } | null;
89
+ assignees: Array<{
90
+ kind: "member";
91
+ member: ConnectMember;
92
+ } | {
93
+ kind: "group";
94
+ group: {
95
+ id: string;
96
+ name: string;
97
+ };
98
+ }>;
99
+ creator: ConnectMember | null;
100
+ createdAt: string;
101
+ updatedAt: string;
102
+ };
103
+ type ConnectPostGroup = {
104
+ id: string;
105
+ name: string;
106
+ slug: string;
107
+ kind: string;
108
+ brand: {
109
+ id: string;
110
+ name: string;
111
+ } | null;
112
+ };
113
+ type ConnectPostStatus = "draft" | "published";
114
+ type ConnectPostSummary = {
115
+ id: string;
116
+ title: string;
117
+ slug: string;
118
+ status: string;
119
+ groupId: string;
120
+ publishedAt: string | null;
121
+ updatedAt: string;
122
+ excerpt: string;
123
+ coverImage: {
124
+ id: string;
125
+ url: string;
126
+ } | null;
127
+ };
128
+ type ConnectPost = Omit<ConnectPostSummary, "excerpt"> & {
129
+ authorUserId: string | null;
130
+ /** 에디터 스펙 JSON(`{ root, elements, version }`) */
131
+ contentRich: unknown;
132
+ /** 본문을 고칠 때 `baseVersion`으로 돌려준다 — 그 사이 누가 고쳤으면 409 */
133
+ version: number;
134
+ };
135
+ type ConnectFolder = {
136
+ id: string;
137
+ name: string;
138
+ parentId: string | null;
139
+ kind: string;
140
+ brandId: string | null;
141
+ createdAt: string;
142
+ };
143
+ type ConnectFile = {
144
+ id: string;
145
+ name: string;
146
+ size: number;
147
+ contentType: string | null;
148
+ visibility: string;
149
+ folderId: string | null;
150
+ /** 공개 파일만 주소가 있다. 워크스페이스 범위 파일은 `files.content(id)`로 받는다 */
151
+ url: string | null;
152
+ createdAt: string;
153
+ };
154
+ type ConnectForm = {
155
+ id: string;
156
+ name: string;
157
+ slug: string;
158
+ type: string;
159
+ status: string;
160
+ brandId: string | null;
161
+ publishedAt: string | null;
162
+ };
163
+ type ConnectInquiry = {
164
+ submissionId: string;
165
+ formId: string;
166
+ formName: string;
167
+ brandId: string | null;
168
+ submittedAt: string;
169
+ customerId: string | null;
170
+ customerName: string | null;
171
+ customerEmail: string | null;
172
+ customerPhone: string | null;
173
+ taskId: string | null;
174
+ stageId: string | null;
175
+ stageKey: string | null;
176
+ stageLabel: string | null;
177
+ answers: Record<string, unknown>;
178
+ highlights: Array<{
179
+ label: string;
180
+ value: string;
181
+ }>;
182
+ details: Array<{
183
+ label: string;
184
+ value: string;
185
+ multiline: boolean;
186
+ }>;
187
+ };
188
+ type ConnectTaskListQuery = {
189
+ pipelineId?: string;
190
+ stageId?: string;
191
+ assigneeMemberId?: string;
192
+ priority?: ConnectTaskPriority;
193
+ q?: string;
194
+ outcome?: "active" | "completed" | "canceled";
195
+ };
196
+ type ConnectTaskCreateInput = {
197
+ title: string;
198
+ pipelineId: string;
199
+ description?: string | null;
200
+ /** 생략하면 파이프라인의 시작 단계 */
201
+ stageId?: string | null;
202
+ priority?: ConnectTaskPriority;
203
+ dueDate?: string | null;
204
+ startDate?: string | null;
205
+ isTimed?: boolean;
206
+ assigneeMemberIds?: string[];
207
+ assigneeGroupIds?: string[];
208
+ brandId?: string | null;
209
+ goalId?: string | null;
210
+ };
211
+ type ConnectTaskUpdateInput = Partial<Omit<ConnectTaskCreateInput, "pipelineId" | "stageId">> & {
212
+ pipelineId?: string;
213
+ stageId?: string;
214
+ };
215
+ type ConnectTaskMoveInput = {
216
+ stageId: string;
217
+ sortOrder: number;
218
+ };
219
+ type ConnectPostSpec = {
220
+ root: string[];
221
+ elements: Record<string, unknown>;
222
+ version?: number;
223
+ };
224
+ type ConnectPostCreateInput = {
225
+ postGroupId: string;
226
+ title: string;
227
+ slug: string;
228
+ contentRich?: ConnectPostSpec;
229
+ };
230
+ type ConnectPostUpdateInput = {
231
+ title?: string;
232
+ slug?: string;
233
+ /** 본문을 보내면 `baseVersion`(읽었던 `version`)이 필수다 */
234
+ contentRich?: ConnectPostSpec;
235
+ baseVersion?: number;
236
+ coverImageId?: string | null;
237
+ };
238
+ declare const connectMeSchema: z.ZodType<ConnectMe>;
239
+ declare const connectMemberSchema: z.ZodType<ConnectMember>;
240
+ declare const connectPipelineSchema: z.ZodType<ConnectPipeline>;
241
+ declare const connectTaskSchema: z.ZodType<ConnectTask>;
242
+ declare const connectPostGroupSchema: z.ZodType<ConnectPostGroup>;
243
+ declare const connectPostSummarySchema: z.ZodType<ConnectPostSummary>;
244
+ declare const connectPostSchema: z.ZodType<ConnectPost>;
245
+ declare const connectFolderSchema: z.ZodType<ConnectFolder>;
246
+ declare const connectFileSchema: z.ZodType<ConnectFile>;
247
+ declare const connectFormSchema: z.ZodType<ConnectForm>;
248
+ declare const connectInquirySchema: z.ZodType<ConnectInquiry>;
249
+ type ConnectClient = {
250
+ me: () => Promise<ConnectMe>;
251
+ members: () => Promise<ConnectMember[]>;
252
+ works: {
253
+ listPipelines: () => Promise<ConnectPipeline[]>;
254
+ listTasks: (query?: ConnectTaskListQuery) => Promise<ConnectTask[]>;
255
+ createTask: (input: ConnectTaskCreateInput) => Promise<{
256
+ id: string;
257
+ }>;
258
+ updateTask: (id: string, input: ConnectTaskUpdateInput) => Promise<{
259
+ id: string;
260
+ }>;
261
+ moveTask: (id: string, input: ConnectTaskMoveInput) => Promise<{
262
+ id: string;
263
+ }>;
264
+ deleteTask: (id: string) => Promise<{
265
+ id: string;
266
+ }>;
267
+ };
268
+ posts: {
269
+ listGroups: () => Promise<ConnectPostGroup[]>;
270
+ list: (query?: {
271
+ groupId?: string;
272
+ status?: ConnectPostStatus;
273
+ }) => Promise<ConnectPostSummary[]>;
274
+ get: (id: string) => Promise<ConnectPost>;
275
+ create: (input: ConnectPostCreateInput) => Promise<{
276
+ id: string;
277
+ slug: string;
278
+ groupId: string;
279
+ }>;
280
+ /** 본문 충돌은 `PlatformApiError` code `CONFLICT`(409) — 다시 읽고 합친다 */
281
+ update: (id: string, input: ConnectPostUpdateInput) => Promise<{
282
+ id: string;
283
+ version: number | null;
284
+ }>;
285
+ publish: (id: string) => Promise<{
286
+ id: string;
287
+ status: string;
288
+ }>;
289
+ unpublish: (id: string) => Promise<{
290
+ id: string;
291
+ status: string;
292
+ }>;
293
+ delete: (id: string) => Promise<{
294
+ id: string;
295
+ }>;
296
+ };
297
+ folders: {
298
+ list: (query?: {
299
+ parentId?: string;
300
+ }) => Promise<ConnectFolder[]>;
301
+ create: (input: {
302
+ name: string;
303
+ parentId?: string | null;
304
+ }) => Promise<{
305
+ folderId: string;
306
+ }>;
307
+ };
308
+ files: {
309
+ list: (query?: {
310
+ folderId?: string;
311
+ }) => Promise<ConnectFile[]>;
312
+ /** 4MB까지(서버가 바이트를 받는다). svg·html 같은 활성 콘텐츠는 거절된다 */
313
+ upload: (file: Blob, options?: {
314
+ name?: string;
315
+ folderId?: string;
316
+ }) => Promise<ConnectFile>;
317
+ update: (id: string, input: {
318
+ name?: string;
319
+ folderId?: string | null;
320
+ }) => Promise<{
321
+ fileId: string;
322
+ }>;
323
+ delete: (id: string) => Promise<{
324
+ fileId: string;
325
+ }>;
326
+ /** 원본 바이트(`Response` 그대로 — 스트리밍·헤더를 호출자가 쓴다) */
327
+ content: (id: string) => Promise<Response>;
328
+ };
329
+ forms: {
330
+ list: () => Promise<ConnectForm[]>;
331
+ };
332
+ /** 문의 = 브랜드폼 제출 + 운영 보드 단계. 목록은 `customer:read`가 필요하다(연락처) */
333
+ inquiries: {
334
+ list: (query: {
335
+ formIds: string[];
336
+ limit?: number;
337
+ }) => Promise<ConnectInquiry[]>;
338
+ moveStage: (submissionId: string, stageId: string) => Promise<{
339
+ submissionId: string;
340
+ taskId: string;
341
+ fromStageLabel: string | null;
342
+ toStageLabel: string;
343
+ }>;
344
+ };
345
+ platformUrl: string;
346
+ };
347
+ declare function createConnectClient(config: ConnectClientConfig): ConnectClient;
348
+ //#endregion
349
+ export { type ConnectAccessToken, type ConnectClient, type ConnectClientConfig, type ConnectFile, type ConnectFolder, type ConnectForm, type ConnectInquiry, type ConnectMe, type ConnectMember, type ConnectPipeline, type ConnectPost, type ConnectPostCreateInput, type ConnectPostGroup, type ConnectPostSpec, type ConnectPostStatus, type ConnectPostSummary, type ConnectPostUpdateInput, type ConnectStageOutcome, type ConnectTask, type ConnectTaskCreateInput, type ConnectTaskListQuery, type ConnectTaskMoveInput, type ConnectTaskPriority, type ConnectTaskUpdateInput, DEFAULT_PLATFORM_SCOPES, PLATFORM_ADMIN_SCOPE, PLATFORM_BRANDAPP_STATUSES, PLATFORM_DOMAIN_STATUSES, PLATFORM_MANAGED_BY_VALUES, PLATFORM_OAUTH_APPLICATION_TYPES, PLATFORM_OAUTH_CLIENT_PURPOSES, PLATFORM_OAUTH_GRANT_TYPES, PLATFORM_STAGE_COLORS, PLATFORM_TASK_OUTCOMES, PLATFORM_TASK_PRIORITIES, PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS, PLATFORM_WEBHOOK_TRIGGERS, PlatformApiError, type PlatformBrandImportInput, type PlatformBrandResource, type PlatformBrandUpsertInput, type PlatformBrandappResource, type PlatformBrandappUpsertInput, type PlatformClient, type PlatformClientConfig, type PlatformCustomerUpsertInput, type PlatformDomainStatus, type PlatformEavBrandappResources, type PlatformEavEntityResource, type PlatformEavSchemaApplyInput, type PlatformEavSchemaApplyResult, type PlatformEavSchemaOperation, type PlatformErrorBody, type PlatformLockAcquired, type PlatformLockReleased, type PlatformManagedBy, type PlatformMe, type PlatformOAuthClientImportInput, type PlatformOAuthClientPurpose, type PlatformOAuthClientResource, type PlatformOAuthClientUpsertInput, type PlatformPipeline, type PlatformPipelineImportInput, type PlatformPipelineResource, type PlatformPipelineStageInput, type PlatformPipelineUpsertInput, type PlatformPublishedPost, type PlatformPublishedPostListOptions, type PlatformPublishedPostPage, type PlatformPublishedPostSummary, type PlatformResources, type PlatformResourcesV2, type PlatformStageColor, type PlatformTask, type PlatformTaskOutcome, type PlatformTaskPriority, type PlatformTaskStage, type PlatformTaskStageInput, type PlatformTaskUpsertInput, type PlatformUrls, type PlatformWebhook, type PlatformWebhookResource, type PlatformWebhookTrigger, type PlatformWebhookUpsertInput, type PlatformWorkTaskStageChangedEvent, type PlatformWriteMeta, type PlatformWriteResult, REOPT_PLATFORM_ID_URLS, REOPT_PLATFORM_URLS, connectFileSchema, connectFolderSchema, connectFormSchema, connectInquirySchema, connectMeSchema, connectMemberSchema, connectPipelineSchema, connectPostGroupSchema, connectPostSchema, connectPostSummarySchema, connectTaskSchema, createConnectClient, createPlatformClient, platformBrandImportInputSchema, platformBrandResourceSchema, platformBrandUpsertInputSchema, platformBrandappResourceSchema, platformBrandappUpsertInputSchema, platformCustomerUpsertInputSchema, platformEavBrandappResourcesSchema, platformEavEntityResourceSchema, platformEavSchemaApplyInputSchema, platformEavSchemaApplyResultSchema, platformEavSchemaOperationSchema, platformErrorSchema, platformExternalIdSchema, platformLockAcquiredSchema, platformLockReleasedSchema, platformMeSchema, platformOAuthClientImportInputSchema, platformOAuthClientResourceSchema, platformOAuthClientUpsertInputSchema, platformPipelineImportInputSchema, platformPipelineResourceSchema, platformPipelineSchema, platformPipelineStageInputSchema, platformPipelineUpsertInputSchema, platformPublishedPostListQuerySchema, platformPublishedPostPageSchema, platformPublishedPostSchema, platformPublishedPostSummarySchema, platformResourceKeySchema, platformResourcesSchema, platformResourcesV2Schema, platformTaskSchema, platformTaskStageInputSchema, platformTaskStageSchema, platformTaskUpsertInputSchema, platformWebhookResourceSchema, platformWebhookSchema, platformWebhookUpsertInputSchema, platformWorkTaskStageChangedEventSchema, platformWriteMetaSchema, resolvePlatformUrls };
350
+ //# sourceMappingURL=index.d.ts.map