@reopt-ai/workspace-sdk 0.1.0-rc.12 → 0.1.0-rc.14
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 +48 -0
- package/README.md +6 -2
- package/dist/{client-CJekFhCW.js → client-BkRONcRm.js} +3 -3
- package/dist/{connect-3zkyD_-0.d.ts → connect-aWLB141V.d.ts} +88 -6
- package/dist/connect.d.ts +3 -3
- package/dist/connect.js +2 -2
- package/dist/{errors-CkgGRAPR.js → errors-COUem1Rg.js} +2 -2
- package/dist/forms.d.ts +167 -0
- package/dist/forms.js +224 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/installation/index.js +1 -1
- package/dist/machine/keygen-cli.js +4 -2
- package/dist/{page-CV3oG_Zu.js → page-CJObTXTG.js} +62 -9
- package/dist/{permissions-LF1orSvQ.d.ts → permissions-D5-qPHua.d.ts} +2 -2
- package/dist/permissions.d.ts +1 -1
- package/dist/permissions.js +32 -1
- package/dist/social/index.js +2 -2
- package/dist/testing/index.d.ts +22 -3
- package/dist/testing/index.js +143 -16
- package/dist/{transport-BVPl0lgF.js → transport-DIZFMpfn.js} +2 -2
- package/docs/forms.md +100 -0
- package/docs/testing.md +10 -6
- package/docs/workspace.md +47 -0
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,54 @@ This project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.0-rc.14] — 2026-11-22
|
|
11
|
+
|
|
12
|
+
Pre-release (`npm i @reopt-ai/workspace-sdk@next`). 깨지는 변경 없음.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **문의 목록 필터** — `inquiries.list({ formIds, stageIds, customerId, submittedAfter, submittedBefore })`. 지금까지는 폼으로만
|
|
17
|
+
좁힐 수 있어 앱이 최근 N건을 읽어 메모리에서 걸렀다(그 밖의 문의에는 닿지 못했다). 빈 `stageIds`는 결과 없음이다.
|
|
18
|
+
- **문의 요약** — `inquiries.summary({ formIds })` → `{ total, byStage, last7Days, previous7Days }`. 목록을 읽지 않고 세므로
|
|
19
|
+
상한이 없다. 건수뿐이라 `customer:read` scope 없이 읽는다. `/testing`도 같다.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- **`inquiries.moveStage`는 `customer:read` scope도 요구한다**(서버). 응답에 문의 전체(연락처·답)가 실리는데 쓰기 scope만
|
|
24
|
+
보던 탓에, 연락처 scope가 없는 연결이 단계를 옮기는 것으로 연락처를 읽을 수 있었다. 문의를 읽는 앱은 이미 그 scope를
|
|
25
|
+
갖고 있어 달라지는 것이 없다. `CONNECT_OPERATIONS["inquiries.moveStage"].alsoScopes`와 `canCall`이 같은 조건을 말한다.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- `/forms` — 응답 본문을 읽는 도중의 제한 시간·취소가 "JSON이 아님"으로 삼켜져 다시 시도할 수 없는 `INVALID_RESPONSE`가
|
|
30
|
+
됐다. 이제 `TIMEOUT`(다시 시도 가능) 또는 호출자의 `AbortError`다. `labelAnswers`는 답의 자기 속성만 읽는다.
|
|
31
|
+
- `reopt-keygen --next`가 옛 회전 순서("서명은 NEXT로 간다")를 안내했다 — rc.12에서 서명 순서를 바꾸며 이 문구를 놓쳤다.
|
|
32
|
+
지금 동작(게시 → 리옵트가 새 키를 앎 → 승격)대로 안내한다.
|
|
33
|
+
- 서버가 `inquiries.list`의 `offset`을 읽지 않았다 — 둘째 장을 청해도 첫 장이 왔고 `listAll(inquiries.list)`는 같은 장을
|
|
34
|
+
되풀이했다. 서버 수정이라 이 버전 이전의 SDK도 배포 뒤부터 바로 맞게 동작한다.
|
|
35
|
+
|
|
36
|
+
## [0.1.0-rc.13] — 2026-11-22
|
|
37
|
+
|
|
38
|
+
Pre-release (`npm i @reopt-ai/workspace-sdk@next`). 깨지는 변경 없음.
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- **알림** — `notifications.list({ unseen })`·`unseenCount()`·`markSeen(id)`·`markAllSeen()`. 로그인한 직원이 리옵트에서 받은
|
|
43
|
+
알림 중 이 연결로 읽을 수 있는 종류만 온다(업무 담당 지정·댓글·멘션·단계 이동·마감 임박, 폼 제출, 신규 고객 —
|
|
44
|
+
역할·scope·플랜으로 판정). 결제·보안 알림은 오지 않고 `markAllSeen`도 건드리지 않는다. `entity`(`task`·`form`)로 앱의 화면에
|
|
45
|
+
잇는다. 읽음 상태는 Studio와 같은 값이다. `/testing`은 `seed.notifications`로 채운다.
|
|
46
|
+
- **`@reopt-ai/workspace-sdk/forms`** — 공개 폼(브랜드폼) 클라이언트. 의존이 없고 방문자 브라우저에서 돈다:
|
|
47
|
+
`createPublicFormClient().get(formId)`(게시된 정의 — 필드·선택지·동의 항목)·`submit(formId, { values, consents, meta })`,
|
|
48
|
+
실패는 `PublicFormError`(`code`·칸별 `fieldErrors`·`retryable`), 관리 화면용 `labelAnswers(fields, answers)`.
|
|
49
|
+
지금까지는 앱이 제출 주소와 오류 해석을 손으로 짰다. 문서 `docs/forms.md`.
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- `/testing` — 공개 폼 응답이 실제 서버와 달랐다: 칸별 오류를 `fields`로 실었고(실제는 `fieldErrors` — 그 키를 읽는 앱에는
|
|
54
|
+
dev 모드에서 칸별 문구가 보이지 않았다), 필드 타입을 `text`·`tel`·`checkbox`로 냈으며(실제는 `string`·`boolean` +
|
|
55
|
+
`appearance`·`inputPurpose`), 선택지를 문자열로도 냈다(실제는 언제나 `{ value, label }`). 같은 계약 시나리오를
|
|
56
|
+
에뮬레이터와 실제 라우터에 돌려 고정했다.
|
|
57
|
+
|
|
10
58
|
## [0.1.0-rc.12] — 2026-11-22
|
|
11
59
|
|
|
12
60
|
Pre-release (`npm i @reopt-ai/workspace-sdk@next`). 깨지는 변경 없음.
|
package/README.md
CHANGED
|
@@ -7,13 +7,17 @@ a company site, a service that files work into Studio) rather than being one bra
|
|
|
7
7
|
published posts for a public site, declarative workspace resources, webhooks.
|
|
8
8
|
- **Delegated access** (`createConnectClient`, also at `/connect`) — a staff member signs in with
|
|
9
9
|
Reopt and your app acts as **them**: Works tasks, posts, files and folders, forms and
|
|
10
|
-
inquiries, brands, members and the app's own tables, limited
|
|
10
|
+
inquiries, customers, their notifications, brands, members and the app's own tables, limited
|
|
11
|
+
by their workspace role.
|
|
11
12
|
Every list is a page (`{ items, nextOffset }`), every write returns the object, every failure
|
|
12
13
|
is a `PlatformApiError` with a typed `code`.
|
|
13
14
|
- **Permissions** (`/permissions`, no dependencies — safe in client components) — the permission
|
|
14
15
|
keys and `can(me, "post:publish")` / `canCall(me, "works.deleteTask")`.
|
|
15
16
|
- **Dev platform** (`/testing`) — an in-memory Reopt for dev mode and E2E: keep the real clients,
|
|
16
17
|
swap their `fetch`. See `docs/testing.md`.
|
|
18
|
+
- **Public forms** (`/forms`, no dependencies — runs in the visitor's browser) — read a published
|
|
19
|
+
form and submit to it directly: `createPublicFormClient()`, typed `PublicFormError` with
|
|
20
|
+
per-field messages, `labelAnswers` for admin screens. See `docs/forms.md`.
|
|
17
21
|
- **Mentions** (`/mentions`, no dependencies) — `mentionToken`, `splitMentions` for task comments.
|
|
18
22
|
- **Webhooks** (`/webhooks`, no dependencies) — receive Reopt's events with the signature and
|
|
19
23
|
replay window checked: `createWebhookHandler({ secret, handlers })`.
|
|
@@ -21,7 +25,7 @@ a company site, a service that files work into Studio) rather than being one bra
|
|
|
21
25
|
- **Installations** (`/installation`) — declare, sign and request your app's connection.
|
|
22
26
|
- **Resource verifier** (`/resource`), **social operations** (`/social`), **id host resolution** (`/urls`).
|
|
23
27
|
|
|
24
|
-
Server-only (it holds private keys and tokens) except `/permissions`, `/operator` and `/urls`
|
|
28
|
+
Server-only (it holds private keys and tokens) except `/forms`, `/mentions`, `/permissions`, `/operator` and `/urls`
|
|
25
29
|
(`/webhooks` runs anywhere Web Crypto does, but holds your webhook secret — keep it on the server).
|
|
26
30
|
Optional peers: `zod` for `.`, `/connect`, `/social` and `/installation`; `@better-auth/core` for
|
|
27
31
|
`.`, `/machine` and `/resource` (the platform client signs DPoP proofs with it). An app that only
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as SDK_VERSION, n as PlatformApiError } from "./errors-
|
|
2
|
-
import { n as readPlatformFailure } from "./transport-
|
|
1
|
+
import { l as SDK_VERSION, n as PlatformApiError } from "./errors-COUem1Rg.js";
|
|
2
|
+
import { n as readPlatformFailure } from "./transport-DIZFMpfn.js";
|
|
3
3
|
import { resolvePlatformUrls } from "./urls.js";
|
|
4
4
|
import { o as readClientKeyRing } from "./keys--ef_VwZ-.js";
|
|
5
5
|
import { r as createMachineClient } from "./client-BLaFMBbS.js";
|
|
@@ -272,4 +272,4 @@ function createPlatformClient(config) {
|
|
|
272
272
|
|
|
273
273
|
//#endregion
|
|
274
274
|
export { createPlatformClient as n, createPlatformRequester as r, DEFAULT_PLATFORM_SCOPES as t };
|
|
275
|
-
//# sourceMappingURL=client-
|
|
275
|
+
//# sourceMappingURL=client-BkRONcRm.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as WorkspacePermissionKey, o as ConnectScope } from "./permissions-
|
|
1
|
+
import { c as WorkspacePermissionKey, o as ConnectScope } from "./permissions-D5-qPHua.js";
|
|
2
2
|
import { i as SortOf, n as Page, r as PageQuery, t as CountedPage } from "./page-j1OCu4of.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/workspace/transport.d.ts
|
|
@@ -318,6 +318,60 @@ type ConnectSignedUrl = {
|
|
|
318
318
|
};
|
|
319
319
|
type ConnectFormType = "feedback" | "inquiry" | "consultation" | "custom" | "booking" | (string & {});
|
|
320
320
|
type ConnectFormStatus = "draft" | "published" | "archived";
|
|
321
|
+
type ConnectInquiryListQuery = {
|
|
322
|
+
/** 1~50개 */
|
|
323
|
+
formIds: string[];
|
|
324
|
+
/**
|
|
325
|
+
* 운영 보드의 이 단계들에 있는 문의만. 카드가 없는 문의는 빠진다. 빈 배열은 "거르지 않음"이 아니라 **결과 없음**이다
|
|
326
|
+
* (요청을 보내지 않고 빈 장을 돌려준다).
|
|
327
|
+
*/
|
|
328
|
+
stageIds?: string[];
|
|
329
|
+
/** 이 고객이 낸 문의만 — 고객 상세 화면의 "문의 내역" */
|
|
330
|
+
customerId?: string;
|
|
331
|
+
/** 접수 시각 구간 — `submittedAfter` 이상, `submittedBefore` 미만. 문자열은 시간대가 붙은 ISO 시각(`…T00:00:00+09:00`·`…Z`) */
|
|
332
|
+
submittedAfter?: string | Date;
|
|
333
|
+
submittedBefore?: string | Date;
|
|
334
|
+
} & PageQuery;
|
|
335
|
+
/** 문의 건수 — 목록을 다 읽지 않고 센 값(대시보드, 단계 탭의 숫자) */
|
|
336
|
+
type ConnectInquirySummary = {
|
|
337
|
+
total: number;
|
|
338
|
+
/** 단계별 건수(많은 순). 카드가 없는 문의는 `stageId: null` 한 줄. 0건인 단계는 없다 */
|
|
339
|
+
byStage: Array<{
|
|
340
|
+
stageId: string | null;
|
|
341
|
+
count: number;
|
|
342
|
+
}>;
|
|
343
|
+
/** 지금부터 7일 안에 접수된 건수와 그 앞 7일의 건수 */
|
|
344
|
+
last7Days: number;
|
|
345
|
+
previous7Days: number;
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* 앱에 열리는 알림 종류 — 업무(담당 지정·댓글·멘션·단계 이동·마감 임박), 폼 제출, 신규 고객. 리옵트의 다른 알림
|
|
349
|
+
* (결제·보안·구성원)은 이 표면에 오지 않는다.
|
|
350
|
+
*/
|
|
351
|
+
type ConnectNotificationKind = "task_assigned" | "task_comment" | "task_mention" | "task_stage_changed" | "task_due_soon" | "form_submitted" | "customer_created";
|
|
352
|
+
type ConnectNotification = {
|
|
353
|
+
id: string;
|
|
354
|
+
/** 목록에 없는 종류가 나중에 더해질 수 있다 — 모르는 값은 `subject`·`content`만 보여 주면 된다 */
|
|
355
|
+
kind: ConnectNotificationKind | (string & {});
|
|
356
|
+
/** 한 줄 제목(업무 알림은 업무 제목) */
|
|
357
|
+
subject: string | null;
|
|
358
|
+
/** 사람이 읽는 문장 — 리옵트가 쓴 그대로 */
|
|
359
|
+
content: string;
|
|
360
|
+
/** 읽은 시각 — 안 읽었으면 null */
|
|
361
|
+
seenAt: string | null;
|
|
362
|
+
createdAt: string;
|
|
363
|
+
/** 알림을 일으킨 사람(시스템이 낸 알림은 null) */
|
|
364
|
+
actorName: string | null;
|
|
365
|
+
actorImage: string | null;
|
|
366
|
+
/**
|
|
367
|
+
* 알림이 가리키는 것 — 앱이 자기 화면으로 보낼 때 쓴다(`task` → `works.getTask(id)`, `form` → 그 폼의 문의 목록).
|
|
368
|
+
* 여러 건을 묶은 알림("오늘 신규 고객 3명")은 가리키는 것이 없어 null.
|
|
369
|
+
*/
|
|
370
|
+
entity: {
|
|
371
|
+
type: "task" | "form" | (string & {});
|
|
372
|
+
id: string;
|
|
373
|
+
} | null;
|
|
374
|
+
};
|
|
321
375
|
type ConnectForm = {
|
|
322
376
|
id: string;
|
|
323
377
|
name: string;
|
|
@@ -639,6 +693,8 @@ declare const connectPostSchema: z.ZodType<ConnectPost>;
|
|
|
639
693
|
declare const connectFolderSchema: z.ZodType<ConnectFolder>;
|
|
640
694
|
declare const connectFileSchema: z.ZodType<ConnectFile>;
|
|
641
695
|
declare const connectFileUsageSchema: z.ZodType<ConnectFileUsage>;
|
|
696
|
+
declare const connectNotificationSchema: z.ZodType<ConnectNotification>;
|
|
697
|
+
declare const connectInquirySummarySchema: z.ZodType<ConnectInquirySummary>;
|
|
642
698
|
declare const connectFormSchema: z.ZodType<ConnectForm>;
|
|
643
699
|
declare const connectInquirySchema: z.ZodType<ConnectInquiry>;
|
|
644
700
|
declare const connectInquiryDetailSchema: z.ZodType<ConnectInquiryDetail>;
|
|
@@ -779,12 +835,38 @@ type ConnectClient = {
|
|
|
779
835
|
forms: {
|
|
780
836
|
list: (options?: Options) => Promise<Page<ConnectForm>>;
|
|
781
837
|
};
|
|
838
|
+
/**
|
|
839
|
+
* 알림 — 로그인한 직원이 리옵트에서 받은 것 중 **이 앱에 열린 범위의 것**(업무 담당 지정·댓글·멘션·단계 이동·마감 임박,
|
|
840
|
+
* 폼 제출, 신규 고객). 어느 종류가 오는지는 리옵트가 그 직원의 역할·동의한 scope·플랜으로 정한다(예: `customer_created`는
|
|
841
|
+
* `customer:read` scope가 있어야 온다). 결제·보안 알림은 오지 않는다.
|
|
842
|
+
*
|
|
843
|
+
* 읽음 상태는 Studio와 같은 값이다 — 여기서 읽으면 Studio 벨에서도 읽은 것이 되고, 그 반대도 같다.
|
|
844
|
+
*/
|
|
845
|
+
notifications: {
|
|
846
|
+
/** 최근순. `limit`을 안 주면 한 장에 20건(최대 50). `unseen: true`면 안 읽은 것만 */
|
|
847
|
+
list: (query?: {
|
|
848
|
+
unseen?: boolean;
|
|
849
|
+
} & PageQuery, options?: Options) => Promise<Page<ConnectNotification>>;
|
|
850
|
+
/** 벨의 숫자 — 100에서 멈춘다(100이면 "99+"로 보이면 된다) */
|
|
851
|
+
unseenCount: (options?: Options) => Promise<number>;
|
|
852
|
+
/** 한 건 읽음. 이미 읽은 것이면 처음 읽은 시각이 그대로 온다 */
|
|
853
|
+
markSeen: (id: string, options?: Options) => Promise<{
|
|
854
|
+
id: string;
|
|
855
|
+
seenAt: string | null;
|
|
856
|
+
}>;
|
|
857
|
+
/** 이 앱에 보이는 알림만 모두 읽음 — 보이지 않는 종류(결제·보안)는 건드리지 않는다. `count`는 바뀐 건수 */
|
|
858
|
+
markAllSeen: (options?: Options) => Promise<{
|
|
859
|
+
count: number;
|
|
860
|
+
}>;
|
|
861
|
+
};
|
|
782
862
|
/** 문의 = 브랜드폼 제출 + 운영 보드 단계. 읽기는 `customer:read` scope가 필요하다(연락처) */
|
|
783
863
|
inquiries: {
|
|
784
|
-
/** `formIds`는 1~50개. `limit`을 안 주면 한 장에 100건(최대 500) */
|
|
785
|
-
list: (query:
|
|
864
|
+
/** 접수 최신순. `formIds`는 1~50개. `limit`을 안 주면 한 장에 100건(최대 500). 단계·고객·기간으로 좁힌다 */
|
|
865
|
+
list: (query: ConnectInquiryListQuery, options?: Options) => Promise<Page<ConnectInquiry>>;
|
|
866
|
+
/** 건수 요약 — 전체·단계별·최근 7일. 연락처가 없어 `customer:read` scope 없이도 읽는다 */
|
|
867
|
+
summary: (query: {
|
|
786
868
|
formIds: string[];
|
|
787
|
-
}
|
|
869
|
+
}, options?: Options) => Promise<ConnectInquirySummary>;
|
|
788
870
|
get: (submissionId: string, options?: Options) => Promise<ConnectInquiryDetail>;
|
|
789
871
|
moveStage: (submissionId: string, stageId: string, options?: Options) => Promise<ConnectInquiryMoveResult>;
|
|
790
872
|
};
|
|
@@ -845,5 +927,5 @@ type ConnectClient = {
|
|
|
845
927
|
};
|
|
846
928
|
declare function createConnectClient(config: ConnectClientConfig): ConnectClient;
|
|
847
929
|
//#endregion
|
|
848
|
-
export {
|
|
849
|
-
//# sourceMappingURL=connect-
|
|
930
|
+
export { ConnectSignedUrl as $, ConnectInquiryListQuery as A, connectMemberSchema as At, ConnectPostAuthor as B, createConnectClient as Bt, ConnectFolder as C, connectFolderSchema as Ct, ConnectFormType as D, connectInquirySchema as Dt, ConnectFormStatus as E, connectInquiryMoveResultSchema as Et, ConnectMemberRole as F, connectPostSummarySchema as Ft, ConnectPostMetaInput as G, ConnectPostGroup as H, ConnectNotification as I, connectPostTagSchema as It, ConnectPostStatus as J, ConnectPostSortField as K, ConnectNotificationKind as L, connectTaskCommentSchema as Lt, ConnectInquirySummary as M, connectPipelineSchema as Mt, ConnectMe as N, connectPostGroupSchema as Nt, ConnectInquiry as O, connectInquirySummarySchema as Ot, ConnectMember as P, connectPostSchema as Pt, ConnectRequestOptions as Q, ConnectPipeline as R, connectTaskFeedItemSchema as Rt, ConnectFileVisibility as S, connectFileUsageSchema as St, ConnectForm as T, connectInquiryDetailSchema as Tt, ConnectPostGroupKind as U, ConnectPostCreateInput as V, ConnectPostListQuery as W, ConnectPostTag as X, ConnectPostSummary as Y, ConnectPostUpdateInput as Z, ConnectEavRecord as _, connectCustomerSchema as _t, ConnectClientConfig as a, ConnectTaskComment as at, ConnectFileSortField as b, connectEavRecordSchema as bt, ConnectCustomerEvent as c, ConnectTaskFeedMember as ct, ConnectCustomerNote as d, ConnectTaskPriority as dt, ConnectSignedUrlOptions as et, ConnectCustomerRecord as f, ConnectTaskSortField as ft, ConnectEavEntity as g, connectCustomerNoteSchema as gt, ConnectCustomerUpdateInput as h, connectBrandSchema as ht, ConnectClient as i, ConnectTaskActivity as it, ConnectInquiryMoveResult as j, connectNotificationSchema as jt, ConnectInquiryDetail as k, connectMeSchema as kt, ConnectCustomerField as l, ConnectTaskListQuery as lt, ConnectCustomerTag as m, ConnectWorkspaceTier as mt, ConnectAnswerValue as n, ConnectStageOutcome as nt, ConnectCustomer as o, ConnectTaskCreateInput as ot, ConnectCustomerSummary as p, ConnectTaskUpdateInput as pt, ConnectPostSpec as q, ConnectBrand as r, ConnectTask as rt, ConnectCustomerCreateInput as s, ConnectTaskFeedItem as st, ConnectAccessToken as t, ConnectStageColor as tt, ConnectCustomerListQuery as u, ConnectTaskMoveInput as ut, ConnectFile as v, connectCustomerSummarySchema as vt, ConnectFolderKind as w, connectFormSchema as wt, ConnectFileUsage as x, connectFileSchema as xt, ConnectFileListQuery as y, connectEavEntitySchema as yt, ConnectPost as z, connectTaskSchema as zt };
|
|
931
|
+
//# sourceMappingURL=connect-aWLB141V.d.ts.map
|
package/dist/connect.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as ConnectOperationRule, c as WorkspacePermissionKey, d as canAny, f as canCall, i as ConnectOperation, l as can, n as CONNECT_OPERATION_NAMES, o as ConnectScope, r as CONNECT_SCOPES, s as WORKSPACE_PERMISSION_KEYS, t as CONNECT_OPERATIONS, u as canAll } from "./permissions-
|
|
1
|
+
import { a as ConnectOperationRule, c as WorkspacePermissionKey, d as canAny, f as canCall, i as ConnectOperation, l as can, n as CONNECT_OPERATION_NAMES, o as ConnectScope, r as CONNECT_SCOPES, s as WORKSPACE_PERMISSION_KEYS, t as CONNECT_OPERATIONS, u as canAll } from "./permissions-D5-qPHua.js";
|
|
2
2
|
import { a as iterate, i as SortOf, n as Page, o as listAll, r as PageQuery, t as CountedPage } from "./page-j1OCu4of.js";
|
|
3
3
|
import { a as PlatformSdkErrorCode, c as isNotImplemented, d as isPlatformError, f as isSignInRequired, i as PlatformFieldError, l as isPermissionDenied, n as PlatformApiError, o as PlatformServerErrorCode, r as PlatformErrorCode, s as SDK_ERROR_CODES, t as PLATFORM_ERROR_CODES, u as isPlatformApiError } from "./errors-CLUuzCNG.js";
|
|
4
|
-
import { $ as
|
|
4
|
+
import { $ as ConnectSignedUrl, A as ConnectInquiryListQuery, At as connectMemberSchema, B as ConnectPostAuthor, Bt as createConnectClient, C as ConnectFolder, Ct as connectFolderSchema, D as ConnectFormType, Dt as connectInquirySchema, E as ConnectFormStatus, Et as connectInquiryMoveResultSchema, F as ConnectMemberRole, Ft as connectPostSummarySchema, G as ConnectPostMetaInput, H as ConnectPostGroup, I as ConnectNotification, It as connectPostTagSchema, J as ConnectPostStatus, K as ConnectPostSortField, L as ConnectNotificationKind, Lt as connectTaskCommentSchema, M as ConnectInquirySummary, Mt as connectPipelineSchema, N as ConnectMe, Nt as connectPostGroupSchema, O as ConnectInquiry, Ot as connectInquirySummarySchema, P as ConnectMember, Pt as connectPostSchema, Q as ConnectRequestOptions, R as ConnectPipeline, Rt as connectTaskFeedItemSchema, S as ConnectFileVisibility, St as connectFileUsageSchema, T as ConnectForm, Tt as connectInquiryDetailSchema, U as ConnectPostGroupKind, V as ConnectPostCreateInput, W as ConnectPostListQuery, X as ConnectPostTag, Y as ConnectPostSummary, Z as ConnectPostUpdateInput, _ as ConnectEavRecord, _t as connectCustomerSchema, a as ConnectClientConfig, at as ConnectTaskComment, b as ConnectFileSortField, bt as connectEavRecordSchema, c as ConnectCustomerEvent, ct as ConnectTaskFeedMember, d as ConnectCustomerNote, dt as ConnectTaskPriority, et as ConnectSignedUrlOptions, f as ConnectCustomerRecord, ft as ConnectTaskSortField, g as ConnectEavEntity, gt as connectCustomerNoteSchema, h as ConnectCustomerUpdateInput, ht as connectBrandSchema, i as ConnectClient, it as ConnectTaskActivity, j as ConnectInquiryMoveResult, jt as connectNotificationSchema, k as ConnectInquiryDetail, kt as connectMeSchema, l as ConnectCustomerField, lt as ConnectTaskListQuery, m as ConnectCustomerTag, mt as ConnectWorkspaceTier, n as ConnectAnswerValue, nt as ConnectStageOutcome, o as ConnectCustomer, ot as ConnectTaskCreateInput, p as ConnectCustomerSummary, pt as ConnectTaskUpdateInput, q as ConnectPostSpec, r as ConnectBrand, rt as ConnectTask, s as ConnectCustomerCreateInput, st as ConnectTaskFeedItem, t as ConnectAccessToken, tt as ConnectStageColor, u as ConnectCustomerListQuery, ut as ConnectTaskMoveInput, v as ConnectFile, vt as connectCustomerSummarySchema, w as ConnectFolderKind, wt as connectFormSchema, x as ConnectFileUsage, xt as connectFileSchema, y as ConnectFileListQuery, yt as connectEavEntitySchema, z as ConnectPost, zt as connectTaskSchema } from "./connect-aWLB141V.js";
|
|
5
5
|
import { n as mentionToken, r as splitMentions, t as MentionSegment } from "./mentions-BMI2c7O6.js";
|
|
6
|
-
export { CONNECT_OPERATIONS, CONNECT_OPERATION_NAMES, CONNECT_SCOPES, type ConnectAccessToken, type ConnectAnswerValue, type ConnectBrand, type ConnectClient, type ConnectClientConfig, type ConnectCustomer, type ConnectCustomerCreateInput, type ConnectCustomerEvent, type ConnectCustomerField, type ConnectCustomerListQuery, type ConnectCustomerNote, type ConnectCustomerRecord, type ConnectCustomerSummary, type ConnectCustomerTag, type ConnectCustomerUpdateInput, type ConnectEavEntity, type ConnectEavRecord, type ConnectFile, type ConnectFileListQuery, type ConnectFileSortField, type ConnectFileUsage, type ConnectFileVisibility, type ConnectFolder, type ConnectFolderKind, type ConnectForm, type ConnectFormStatus, type ConnectFormType, type ConnectInquiry, type ConnectInquiryDetail, type ConnectInquiryMoveResult, type ConnectMe, type ConnectMember, type ConnectMemberRole, type ConnectOperation, type ConnectOperationRule, type ConnectPipeline, type ConnectPost, type ConnectPostAuthor, type ConnectPostCreateInput, type ConnectPostGroup, type ConnectPostGroupKind, type ConnectPostListQuery, type ConnectPostMetaInput, type ConnectPostSortField, type ConnectPostSpec, type ConnectPostStatus, type ConnectPostSummary, type ConnectPostTag, type ConnectPostUpdateInput, type ConnectRequestOptions, type ConnectScope, type ConnectSignedUrl, type ConnectSignedUrlOptions, type ConnectStageColor, type ConnectStageOutcome, type ConnectTask, type ConnectTaskActivity, type ConnectTaskComment, type ConnectTaskCreateInput, type ConnectTaskFeedItem, type ConnectTaskFeedMember, type ConnectTaskListQuery, type ConnectTaskMoveInput, type ConnectTaskPriority, type ConnectTaskSortField, type ConnectTaskUpdateInput, type ConnectWorkspaceTier, type CountedPage, type MentionSegment, PLATFORM_ERROR_CODES, type Page, type PageQuery, PlatformApiError, type PlatformErrorCode, type PlatformFieldError, type PlatformSdkErrorCode, type PlatformServerErrorCode, SDK_ERROR_CODES, type SortOf, WORKSPACE_PERMISSION_KEYS, type WorkspacePermissionKey, can, canAll, canAny, canCall, connectBrandSchema, type connectCustomerNoteSchema, type connectCustomerSchema, type connectCustomerSummarySchema, connectEavEntitySchema, connectEavRecordSchema, connectFileSchema, connectFileUsageSchema, connectFolderSchema, connectFormSchema, connectInquiryDetailSchema, type connectInquiryMoveResultSchema, connectInquirySchema, connectMeSchema, connectMemberSchema, connectPipelineSchema, connectPostGroupSchema, connectPostSchema, connectPostSummarySchema, connectPostTagSchema, type connectTaskCommentSchema, type connectTaskFeedItemSchema, connectTaskSchema, createConnectClient, isNotImplemented, isPermissionDenied, isPlatformApiError, isPlatformError, isSignInRequired, iterate, listAll, mentionToken, splitMentions };
|
|
6
|
+
export { CONNECT_OPERATIONS, CONNECT_OPERATION_NAMES, CONNECT_SCOPES, type ConnectAccessToken, type ConnectAnswerValue, type ConnectBrand, type ConnectClient, type ConnectClientConfig, type ConnectCustomer, type ConnectCustomerCreateInput, type ConnectCustomerEvent, type ConnectCustomerField, type ConnectCustomerListQuery, type ConnectCustomerNote, type ConnectCustomerRecord, type ConnectCustomerSummary, type ConnectCustomerTag, type ConnectCustomerUpdateInput, type ConnectEavEntity, type ConnectEavRecord, type ConnectFile, type ConnectFileListQuery, type ConnectFileSortField, type ConnectFileUsage, type ConnectFileVisibility, type ConnectFolder, type ConnectFolderKind, type ConnectForm, type ConnectFormStatus, type ConnectFormType, type ConnectInquiry, type ConnectInquiryDetail, type ConnectInquiryListQuery, type ConnectInquiryMoveResult, type ConnectInquirySummary, type ConnectMe, type ConnectMember, type ConnectMemberRole, type ConnectNotification, type ConnectNotificationKind, type ConnectOperation, type ConnectOperationRule, type ConnectPipeline, type ConnectPost, type ConnectPostAuthor, type ConnectPostCreateInput, type ConnectPostGroup, type ConnectPostGroupKind, type ConnectPostListQuery, type ConnectPostMetaInput, type ConnectPostSortField, type ConnectPostSpec, type ConnectPostStatus, type ConnectPostSummary, type ConnectPostTag, type ConnectPostUpdateInput, type ConnectRequestOptions, type ConnectScope, type ConnectSignedUrl, type ConnectSignedUrlOptions, type ConnectStageColor, type ConnectStageOutcome, type ConnectTask, type ConnectTaskActivity, type ConnectTaskComment, type ConnectTaskCreateInput, type ConnectTaskFeedItem, type ConnectTaskFeedMember, type ConnectTaskListQuery, type ConnectTaskMoveInput, type ConnectTaskPriority, type ConnectTaskSortField, type ConnectTaskUpdateInput, type ConnectWorkspaceTier, type CountedPage, type MentionSegment, PLATFORM_ERROR_CODES, type Page, type PageQuery, PlatformApiError, type PlatformErrorCode, type PlatformFieldError, type PlatformSdkErrorCode, type PlatformServerErrorCode, SDK_ERROR_CODES, type SortOf, WORKSPACE_PERMISSION_KEYS, type WorkspacePermissionKey, can, canAll, canAny, canCall, connectBrandSchema, type connectCustomerNoteSchema, type connectCustomerSchema, type connectCustomerSummarySchema, connectEavEntitySchema, connectEavRecordSchema, connectFileSchema, connectFileUsageSchema, connectFolderSchema, connectFormSchema, connectInquiryDetailSchema, type connectInquiryMoveResultSchema, connectInquirySchema, type connectInquirySummarySchema, connectMeSchema, connectMemberSchema, type connectNotificationSchema, connectPipelineSchema, connectPostGroupSchema, connectPostSchema, connectPostSummarySchema, connectPostTagSchema, type connectTaskCommentSchema, type connectTaskFeedItemSchema, connectTaskSchema, createConnectClient, isNotImplemented, isPermissionDenied, isPlatformApiError, isPlatformError, isSignInRequired, iterate, listAll, mentionToken, splitMentions };
|
package/dist/connect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as isPermissionDenied, c as isSignInRequired, i as isNotImplemented, n as PlatformApiError, o as isPlatformApiError, r as SDK_ERROR_CODES, s as isPlatformError, t as PLATFORM_ERROR_CODES } from "./errors-
|
|
1
|
+
import { a as isPermissionDenied, c as isSignInRequired, i as isNotImplemented, n as PlatformApiError, o as isPlatformApiError, r as SDK_ERROR_CODES, s as isPlatformError, t as PLATFORM_ERROR_CODES } from "./errors-COUem1Rg.js";
|
|
2
2
|
import { CONNECT_OPERATIONS, CONNECT_OPERATION_NAMES, CONNECT_SCOPES, WORKSPACE_PERMISSION_KEYS, can, canAll, canAny, canCall } from "./permissions.js";
|
|
3
3
|
import { mentionToken, splitMentions } from "./mentions.js";
|
|
4
|
-
import { _ as connectPostSummarySchema, a as connectEavRecordSchema, b as createConnectClient, c as connectFolderSchema, d as connectInquirySchema, f as connectMeSchema, g as connectPostSchema, h as connectPostGroupSchema, i as connectEavEntitySchema, l as connectFormSchema, m as connectPipelineSchema, n as listAll, o as connectFileSchema, p as connectMemberSchema, r as connectBrandSchema, s as connectFileUsageSchema, t as iterate, u as connectInquiryDetailSchema, v as connectPostTagSchema, y as connectTaskSchema } from "./page-
|
|
4
|
+
import { _ as connectPostSummarySchema, a as connectEavRecordSchema, b as createConnectClient, c as connectFolderSchema, d as connectInquirySchema, f as connectMeSchema, g as connectPostSchema, h as connectPostGroupSchema, i as connectEavEntitySchema, l as connectFormSchema, m as connectPipelineSchema, n as listAll, o as connectFileSchema, p as connectMemberSchema, r as connectBrandSchema, s as connectFileUsageSchema, t as iterate, u as connectInquiryDetailSchema, v as connectPostTagSchema, y as connectTaskSchema } from "./page-CJObTXTG.js";
|
|
5
5
|
|
|
6
6
|
export { CONNECT_OPERATIONS, CONNECT_OPERATION_NAMES, CONNECT_SCOPES, PLATFORM_ERROR_CODES, PlatformApiError, SDK_ERROR_CODES, WORKSPACE_PERMISSION_KEYS, can, canAll, canAny, canCall, connectBrandSchema, connectEavEntitySchema, connectEavRecordSchema, connectFileSchema, connectFileUsageSchema, connectFolderSchema, connectFormSchema, connectInquiryDetailSchema, connectInquirySchema, connectMeSchema, connectMemberSchema, connectPipelineSchema, connectPostGroupSchema, connectPostSchema, connectPostSummarySchema, connectPostTagSchema, connectTaskSchema, createConnectClient, isNotImplemented, isPermissionDenied, isPlatformApiError, isPlatformError, isSignInRequired, iterate, listAll, mentionToken, splitMentions };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/version.ts
|
|
2
2
|
/** 이 패키지(`@reopt-ai/workspace-sdk`)의 버전 — 빌드가 package.json에서 주입한다(미번들 실행은 `0.0.0-dev`). */
|
|
3
|
-
const SDK_VERSION = "0.1.0-rc.
|
|
3
|
+
const SDK_VERSION = "0.1.0-rc.14";
|
|
4
4
|
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/workspace/errors.ts
|
|
@@ -120,4 +120,4 @@ function isPermissionDenied(error) {
|
|
|
120
120
|
|
|
121
121
|
//#endregion
|
|
122
122
|
export { isPermissionDenied as a, isSignInRequired as c, isNotImplemented as i, SDK_VERSION as l, PlatformApiError as n, isPlatformApiError as o, SDK_ERROR_CODES as r, isPlatformError as s, PLATFORM_ERROR_CODES as t };
|
|
123
|
-
//# sourceMappingURL=errors-
|
|
123
|
+
//# sourceMappingURL=errors-COUem1Rg.js.map
|
package/dist/forms.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
//#region src/forms.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* `@reopt-ai/workspace-sdk/forms` — 공개 폼(브랜드폼) 클라이언트. 방문자 브라우저가 리옵트에 **직접** 제출한다.
|
|
4
|
+
*
|
|
5
|
+
* 의존이 없다 — 클라이언트 컴포넌트에서 쓴다. 인증도 없다: 폼 id는 비밀이 아니고, 게시된 폼만 열린다.
|
|
6
|
+
*
|
|
7
|
+
* 🔑 **앱 서버로 중계하지 않는다.** 리옵트의 제출 한도는 방문자 IP 기준이라, 서버가 대신 보내면 모든 방문자가 서버 IP
|
|
8
|
+
* 하나로 묶여 그 한도를 나눠 쓴다. 리옵트는 이 주소에 CORS를 열어 두었고 쿠키는 받지 않는다(RFC-0043 §3.6).
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const forms = createPublicFormClient();
|
|
12
|
+
* const form = await forms.get(formId); // 게시된 정의 — 필드·동의 항목·버튼 문구
|
|
13
|
+
* try {
|
|
14
|
+
* const { successMessage } = await forms.submit(formId, { values, consents, meta: { hp } });
|
|
15
|
+
* } catch (error) {
|
|
16
|
+
* if (isPublicFormError(error)) showErrors(error.fieldErrors, error.message);
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
/** 리옵트 Studio 호스트 — 공개 폼 주소가 여기에 있다. */
|
|
21
|
+
declare const REOPT_STUDIO_URL: string;
|
|
22
|
+
type PublicFormFieldType = "string" | "number" | "boolean" | "date" | "email" | "url" | "select" | "multiselect" | "textarea" | "file";
|
|
23
|
+
type PublicFormField = {
|
|
24
|
+
/** 제출 본문 `values`의 키이자 문의 `answers`의 키 */
|
|
25
|
+
name: string;
|
|
26
|
+
label: string;
|
|
27
|
+
type: PublicFormFieldType | (string & {});
|
|
28
|
+
required: boolean;
|
|
29
|
+
placeholder: string | null;
|
|
30
|
+
description: string | null;
|
|
31
|
+
/** 선택형의 선택지 — 제출 값은 `value`다 */
|
|
32
|
+
options: {
|
|
33
|
+
value: string;
|
|
34
|
+
label: string;
|
|
35
|
+
}[] | null;
|
|
36
|
+
/** 브라우저 자동완성에 쓰는 의미(이름·이메일·전화) */
|
|
37
|
+
inputPurpose?: "name" | "email" | "tel" | null;
|
|
38
|
+
/** 저장 타입은 그대로 두고 입력 모양만 바꾸는 표현(전화·시간·별점 등) */
|
|
39
|
+
appearance?: string | null;
|
|
40
|
+
scaleMax?: number | null;
|
|
41
|
+
};
|
|
42
|
+
type PublicFormConsentItem = {
|
|
43
|
+
/** 제출 본문 `consents`의 키 */
|
|
44
|
+
id: string;
|
|
45
|
+
label: string;
|
|
46
|
+
details?: string | null;
|
|
47
|
+
/** 필수 동의 — 빠지면 리옵트가 `CONSENT_REQUIRED`로 거절한다 */
|
|
48
|
+
required: boolean;
|
|
49
|
+
/** 약관 전문 주소 */
|
|
50
|
+
linkUrl: string | null;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 게시된 폼의 정의. 여기 적힌 필드는 약속이고, 그 밖의 것(테마·페이지 분할·예약 정보 등 리옵트 렌더러가 쓰는 값)도
|
|
54
|
+
* 그대로 실려 온다 — 이름을 약속하지 않으므로 타입에는 없다.
|
|
55
|
+
*/
|
|
56
|
+
type PublicForm = {
|
|
57
|
+
formId: string;
|
|
58
|
+
name: string;
|
|
59
|
+
fields: PublicFormField[];
|
|
60
|
+
/** 제출 버튼 문구 — 없으면 앱이 정한다 */
|
|
61
|
+
submitLabel: string | null;
|
|
62
|
+
/** 제출 뒤 보여 줄 문구 */
|
|
63
|
+
successMessage: string | null;
|
|
64
|
+
/** 동의 항목 — 없으면 빈 배열 */
|
|
65
|
+
consent: PublicFormConsentItem[];
|
|
66
|
+
[extra: string]: unknown;
|
|
67
|
+
};
|
|
68
|
+
type PublicFormSubmitMeta = {
|
|
69
|
+
/**
|
|
70
|
+
* 허니팟 — 사람에게 보이지 않는 입력의 값. 채워져 있으면 리옵트는 **성공처럼 답하고 버린다**
|
|
71
|
+
* (`submissionId: null`). 봇에게 단서를 주지 않으려는 것이니 앱도 평소처럼 완료 화면을 보인다.
|
|
72
|
+
*/
|
|
73
|
+
hp?: string;
|
|
74
|
+
locale?: string;
|
|
75
|
+
/** 폼이 놓인 페이지 경로 */
|
|
76
|
+
pagePath?: string;
|
|
77
|
+
/** 유입 주소 — 리옵트가 origin + 경로만 남긴다 */
|
|
78
|
+
referrer?: string;
|
|
79
|
+
/** 추천 코드 */
|
|
80
|
+
ref?: string;
|
|
81
|
+
utm?: Partial<Record<"utm_source" | "utm_medium" | "utm_campaign" | "utm_term" | "utm_content", string>>;
|
|
82
|
+
/** 예약 폼 — 고른 시각(ISO)과 방문자 타임존 */
|
|
83
|
+
bookedAt?: string;
|
|
84
|
+
timezone?: string;
|
|
85
|
+
};
|
|
86
|
+
type PublicFormSubmission = {
|
|
87
|
+
/** 필드 `name` → 값. 비운 답(빈 문자열·null)은 "답하지 않음"으로 읽는다 */
|
|
88
|
+
values: Record<string, unknown>;
|
|
89
|
+
/** 동의 항목 `id` → 동의 여부 */
|
|
90
|
+
consents?: Record<string, boolean>;
|
|
91
|
+
meta?: PublicFormSubmitMeta;
|
|
92
|
+
};
|
|
93
|
+
type PublicFormSubmitResult = {
|
|
94
|
+
/** 허니팟에 걸린 제출은 null */
|
|
95
|
+
submissionId: string | null;
|
|
96
|
+
successMessage: string | null;
|
|
97
|
+
};
|
|
98
|
+
/** 리옵트가 내는 코드(앞의 여섯) + 클라이언트가 만드는 코드(뒤의 셋). 목록 밖의 코드도 문자열로 그대로 온다. */
|
|
99
|
+
type PublicFormErrorCode = "FORM_NOT_FOUND" | "VALIDATION_ERROR" | "CONSENT_REQUIRED" | "RATE_LIMITED" | "PAYLOAD_TOO_LARGE" | "SUBMISSION_IN_PROGRESS" | "NETWORK_ERROR" | "TIMEOUT" | "INVALID_RESPONSE" | (string & {});
|
|
100
|
+
/**
|
|
101
|
+
* 공개 폼 요청의 실패 — 이 클라이언트가 던지는 것은 언제나 이것이다(요청을 취소한 `AbortError`만 예외).
|
|
102
|
+
*
|
|
103
|
+
* - `fieldErrors` — 칸별 문구(필드 `name` 또는 동의 항목 `id` → 문구). 없으면 빈 객체
|
|
104
|
+
* - `message` — 방문자에게 그대로 보여도 되는 문구(리옵트가 준 것). 클라이언트가 만든 코드는 영문이다
|
|
105
|
+
* - `retryable` — 잠시 뒤 같은 요청을 다시 보내도 되는가(한도 초과·처리 중·네트워크)
|
|
106
|
+
*/
|
|
107
|
+
declare class PublicFormError extends Error {
|
|
108
|
+
readonly code: PublicFormErrorCode;
|
|
109
|
+
/** HTTP 상태 — 응답을 받지 못했으면 0 */
|
|
110
|
+
readonly status: number;
|
|
111
|
+
readonly fieldErrors: Record<string, string>;
|
|
112
|
+
readonly retryable: boolean;
|
|
113
|
+
constructor(input: {
|
|
114
|
+
code: PublicFormErrorCode;
|
|
115
|
+
message: string;
|
|
116
|
+
status: number;
|
|
117
|
+
fieldErrors?: Record<string, string>;
|
|
118
|
+
retryable?: boolean;
|
|
119
|
+
cause?: unknown;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** `instanceof` 대신 — 번들이 둘로 갈려도(서버·클라이언트 사본) 맞는다. */
|
|
123
|
+
declare function isPublicFormError(error: unknown): error is PublicFormError;
|
|
124
|
+
type PublicFormClientOptions = {
|
|
125
|
+
/** 리옵트 Studio 주소 — 기본 `https://studio.reopt.ai`. 개발에서는 에뮬레이터의 `browserBaseUrl` */
|
|
126
|
+
studioUrl?: string;
|
|
127
|
+
fetch?: typeof globalThis.fetch;
|
|
128
|
+
/** 응답을 기다리는 상한(ms) — 기본 15000 */
|
|
129
|
+
timeoutMs?: number;
|
|
130
|
+
};
|
|
131
|
+
type PublicFormRequestOptions = {
|
|
132
|
+
signal?: AbortSignal;
|
|
133
|
+
};
|
|
134
|
+
type PublicFormClient = {
|
|
135
|
+
/** 정의를 읽는 주소 */
|
|
136
|
+
url: (formId: string) => string;
|
|
137
|
+
/** 제출 주소 — JS 없이 동작하는 `<form>`을 직접 짜거나 CSP `connect-src`에 넣을 때 */
|
|
138
|
+
submitUrl: (formId: string) => string;
|
|
139
|
+
/** 게시된 폼의 정의. 게시되지 않았거나 없는 폼은 `FORM_NOT_FOUND` */
|
|
140
|
+
get: (formId: string, options?: PublicFormRequestOptions) => Promise<PublicForm>;
|
|
141
|
+
/** 제출. 칸이 틀리면 `VALIDATION_ERROR`·`CONSENT_REQUIRED`에 `fieldErrors`가 실린다 */
|
|
142
|
+
submit: (formId: string, submission: PublicFormSubmission, options?: PublicFormRequestOptions) => Promise<PublicFormSubmitResult>;
|
|
143
|
+
};
|
|
144
|
+
declare function createPublicFormClient(options?: PublicFormClientOptions): PublicFormClient;
|
|
145
|
+
type LabeledAnswer = {
|
|
146
|
+
/** 필드 `name` */
|
|
147
|
+
name: string;
|
|
148
|
+
/** 폼의 라벨 — 지금 폼에 없는 칸(나중에 지운 필드)의 답이면 `name` 그대로 */
|
|
149
|
+
label: string;
|
|
150
|
+
value: unknown;
|
|
151
|
+
/** 사람이 읽는 값 — 선택형은 선택지 라벨, 여러 값은 쉼표로, 예/아니오 */
|
|
152
|
+
text: string;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* 제출된 답(`answers`)에 폼의 라벨을 붙인다 — 관리 화면이 필드 이름을 손으로 적지 않게.
|
|
156
|
+
* 순서는 폼의 필드 순서이고, 폼에 없는 키의 답은 뒤에 붙는다(지운 필드의 옛 답을 숨기지 않는다).
|
|
157
|
+
* 비어 있는 답은 뺀다.
|
|
158
|
+
*
|
|
159
|
+
* ```ts
|
|
160
|
+
* const form = await forms.get(inquiry.formId);
|
|
161
|
+
* labelAnswers(form.fields, inquiry.answers).map(({ label, text }) => …);
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
declare function labelAnswers(fields: readonly PublicFormField[], answers: Readonly<Record<string, unknown>>): LabeledAnswer[];
|
|
165
|
+
//#endregion
|
|
166
|
+
export { LabeledAnswer, PublicForm, PublicFormClient, PublicFormClientOptions, PublicFormConsentItem, PublicFormError, PublicFormErrorCode, PublicFormField, PublicFormFieldType, PublicFormRequestOptions, PublicFormSubmission, PublicFormSubmitMeta, PublicFormSubmitResult, REOPT_STUDIO_URL, createPublicFormClient, isPublicFormError, labelAnswers };
|
|
167
|
+
//# sourceMappingURL=forms.d.ts.map
|