@reopt-ai/brandapp-sdk 4.4.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 +11 -0
- package/dist/ai/index.js +1 -1
- package/dist/ai-provider/index.js +1 -1
- package/dist/analytics/index.js +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/better-auth/index.js +2 -2
- package/dist/{client-afAv7Ebi.js → client-B0XUjOuP.js} +4 -4
- package/dist/{client-CuM8MNS5.js → client-B270eCrs.js} +2 -2
- package/dist/{client-D_6WdWsc.js → client-BIMl52kc.js} +3 -3
- package/dist/{client-DYkDNPyN.js → client-BNht520A.js} +2 -2
- package/dist/{client-EG1p7FL0.js → client-BwgCbfXv.js} +2 -2
- package/dist/{client-DsM84EZZ.js → client-C2ALt685.js} +3 -3
- package/dist/{client-s2uJ3OML.js → client-CKi1NpMR.js} +2 -2
- package/dist/{client-mD6o-qVl.js → client-Cv1bdMBf.js} +2 -2
- package/dist/{client-C4sDbXto.js → client-DNzgX_md.js} +4 -4
- package/dist/{client-DuATTvcr.js → client-WxPjMNy_.js} +2 -2
- package/dist/cms/index.js +1 -1
- package/dist/{config-C_OFYAgP.js → config-DkT0F-GG.js} +2 -2
- package/dist/eav/index.js +2 -2
- package/dist/feedback/index.js +1 -1
- package/dist/files/index.js +1 -1
- package/dist/{http-client-BUbFBOvG.js → http-client-BO5A5n4I.js} +2 -2
- package/dist/index.js +12 -12
- package/dist/logout/index.js +1 -1
- package/dist/plans/index.js +1 -1
- package/dist/push/index.js +1 -1
- package/dist/{query-BkdTSuB5.js → query-D08B_HFt.js} +2 -2
- package/dist/terms/index.js +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 +1 -1
- package/package.json +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,17 @@ This project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.5.0-platform.0] - 2026-09-07
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `@reopt-ai/brandapp-sdk/workspace` — 플랫폼 API(RFC-0029, `platform.reopt.ai`) 클라이언트. **서버 전용.**
|
|
15
|
+
`createPlatformClient({ clientId, clientSecret })`가 `client_credentials`로 platform audience 토큰을 받아
|
|
16
|
+
`works.{listPipelines,upsertTask,getTask,setTaskStage}`·`webhooks.{list,upsert,delete}`·`me()`를 부른다
|
|
17
|
+
(토큰 캐시·만료 60초 전 재발급·401 시 1회 재발급·`fetch` 주입). 요청·응답·웹훅 payload zod 스키마와
|
|
18
|
+
타입을 함께 export한다. `zod`는 이 서브패스만 쓰는 optional peer.
|
|
19
|
+
- `webhooks`: `workTaskStageChanged` 이벤트 타입 + `WorkTaskStageChangedWebhookData`.
|
|
20
|
+
|
|
10
21
|
## [4.4.0] — 2026-09-07
|
|
11
22
|
|
|
12
23
|
### Added
|
package/dist/ai/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, r as assertBrowserSafe } from "../config-
|
|
1
|
+
import { i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, r as assertBrowserSafe } from "../config-DkT0F-GG.js";
|
|
2
2
|
import { t as createManagedAbort } from "../abort--nOBFN4M.js";
|
|
3
3
|
import { t as createAuthHeader } from "../encoding-Bwfm3iaE.js";
|
|
4
4
|
import { t as createSSELineProcessor } from "../sse-parser-FMjxM7sY.js";
|
package/dist/analytics/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createReoptAnalyticsClient, t as ReoptAnalyticsClient } from "../client-
|
|
1
|
+
import { n as createReoptAnalyticsClient, t as ReoptAnalyticsClient } from "../client-BwgCbfXv.js";
|
|
2
2
|
import { getInstance, identify, init, pageView, setConsent, track } from "@reopt-ai/data-sdk";
|
|
3
3
|
|
|
4
4
|
//#region src/analytics/browser.ts
|
package/dist/auth/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as isReoptSDKError, S as ReoptSDKError, a as resolveIdBaseUrl, s as AuthError, t as REOPT_BASE_URLS, w as ServerError, x as RateLimitError } from "../config-
|
|
2
|
-
import { t as BaseHttpClient } from "../http-client-
|
|
1
|
+
import { O as isReoptSDKError, S as ReoptSDKError, a as resolveIdBaseUrl, s as AuthError, t as REOPT_BASE_URLS, w as ServerError, x as RateLimitError } from "../config-DkT0F-GG.js";
|
|
2
|
+
import { t as BaseHttpClient } from "../http-client-BO5A5n4I.js";
|
|
3
3
|
import { n as REOPT_PROVIDER_ID, t as REOPT_DEFAULT_SCOPES } from "../types-DjDRszNj.js";
|
|
4
4
|
import { createAdapterFactory } from "better-auth/adapters";
|
|
5
5
|
import { genericOAuth } from "better-auth/plugins";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-
|
|
1
|
+
import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-DkT0F-GG.js";
|
|
2
2
|
import { t as createManagedAbort } from "./abort--nOBFN4M.js";
|
|
3
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
3
|
+
import { t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
4
4
|
import { n as parseSSEStream } from "./sse-parser-FMjxM7sY.js";
|
|
5
5
|
|
|
6
6
|
//#region src/ai/client.ts
|
|
@@ -231,7 +231,7 @@ var ReoptAiClient = class {
|
|
|
231
231
|
}
|
|
232
232
|
async fetchSSE(options) {
|
|
233
233
|
const url = `${this.http.requestBaseUrl}/chat/completions`;
|
|
234
|
-
const requestId = globalThis.crypto?.randomUUID?.() ?? `sdk-${"4.
|
|
234
|
+
const requestId = globalThis.crypto?.randomUUID?.() ?? `sdk-${"4.5.0-platform.0"}-${url.length}`;
|
|
235
235
|
const ctx = {
|
|
236
236
|
method: "POST",
|
|
237
237
|
url,
|
|
@@ -309,4 +309,4 @@ function createReoptAiClient(config) {
|
|
|
309
309
|
|
|
310
310
|
//#endregion
|
|
311
311
|
export { createReoptAiClient as n, ReoptAiClient as t };
|
|
312
|
-
//# sourceMappingURL=client-
|
|
312
|
+
//# sourceMappingURL=client-B0XUjOuP.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
2
2
|
|
|
3
3
|
//#region src/push/client.ts
|
|
4
4
|
var ReoptPushClient = class {
|
|
@@ -25,4 +25,4 @@ function createReoptPushClient(config) {
|
|
|
25
25
|
|
|
26
26
|
//#endregion
|
|
27
27
|
export { createReoptPushClient as n, ReoptPushClient as t };
|
|
28
|
-
//# sourceMappingURL=client-
|
|
28
|
+
//# sourceMappingURL=client-B270eCrs.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
2
|
-
import { t as buildQuery } from "./query-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
2
|
+
import { t as buildQuery } from "./query-D08B_HFt.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cms/client.ts
|
|
5
5
|
function createReoptCmsClient(config) {
|
|
@@ -52,4 +52,4 @@ async list(query) {
|
|
|
52
52
|
|
|
53
53
|
//#endregion
|
|
54
54
|
export { createReoptCmsClient as t };
|
|
55
|
-
//# sourceMappingURL=client-
|
|
55
|
+
//# sourceMappingURL=client-BIMl52kc.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
2
2
|
|
|
3
3
|
//#region src/feedback/client.ts
|
|
4
4
|
function buildListQuery(query) {
|
|
@@ -83,4 +83,4 @@ function createReoptFeedbackClient(config) {
|
|
|
83
83
|
|
|
84
84
|
//#endregion
|
|
85
85
|
export { createReoptFeedbackClient as n, ReoptFeedbackClient as t };
|
|
86
|
-
//# sourceMappingURL=client-
|
|
86
|
+
//# sourceMappingURL=client-BNht520A.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
2
2
|
|
|
3
3
|
//#region src/analytics/client.ts
|
|
4
4
|
var ReoptAnalyticsClient = class {
|
|
@@ -17,4 +17,4 @@ function createReoptAnalyticsClient(config) {
|
|
|
17
17
|
|
|
18
18
|
//#endregion
|
|
19
19
|
export { createReoptAnalyticsClient as n, ReoptAnalyticsClient as t };
|
|
20
|
-
//# sourceMappingURL=client-
|
|
20
|
+
//# sourceMappingURL=client-BwgCbfXv.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-
|
|
1
|
+
import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-DkT0F-GG.js";
|
|
2
2
|
import { t as createManagedAbort } from "./abort--nOBFN4M.js";
|
|
3
|
-
import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-
|
|
3
|
+
import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
4
4
|
|
|
5
5
|
//#region src/files/client.ts
|
|
6
6
|
var ReoptFileClient = class {
|
|
@@ -270,4 +270,4 @@ function createReoptFileClient(config) {
|
|
|
270
270
|
|
|
271
271
|
//#endregion
|
|
272
272
|
export { createReoptFileClient as n, ReoptFileClient as t };
|
|
273
|
-
//# sourceMappingURL=client-
|
|
273
|
+
//# sourceMappingURL=client-C2ALt685.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
2
2
|
|
|
3
3
|
//#region src/terms/client.ts
|
|
4
4
|
function unwrap(body) {
|
|
@@ -80,4 +80,4 @@ function createReoptTermsClient(config) {
|
|
|
80
80
|
|
|
81
81
|
//#endregion
|
|
82
82
|
export { createReoptTermsClient as n, ReoptTermsClient as t };
|
|
83
|
-
//# sourceMappingURL=client-
|
|
83
|
+
//# sourceMappingURL=client-CKi1NpMR.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plans/client.ts
|
|
4
4
|
function unwrap(body) {
|
|
@@ -78,4 +78,4 @@ function createReoptPlansClient(config) {
|
|
|
78
78
|
|
|
79
79
|
//#endregion
|
|
80
80
|
export { createReoptPlansClient as n, ReoptPlansClient as t };
|
|
81
|
-
//# sourceMappingURL=client-
|
|
81
|
+
//# sourceMappingURL=client-Cv1bdMBf.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as BadRequestError } from "./config-
|
|
2
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
3
|
-
import { t as buildQuery } from "./query-
|
|
1
|
+
import { u as BadRequestError } from "./config-DkT0F-GG.js";
|
|
2
|
+
import { t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
3
|
+
import { t as buildQuery } from "./query-D08B_HFt.js";
|
|
4
4
|
|
|
5
5
|
//#region src/eav/cache.ts
|
|
6
6
|
var SchemaCache = class {
|
|
@@ -564,4 +564,4 @@ function createReoptEavClient(config) {
|
|
|
564
564
|
|
|
565
565
|
//#endregion
|
|
566
566
|
export { RECORDS_PAGE_LIMIT_MAX as i, ATTRIBUTE_FILTER_LIST_MAX as n, ATTRIBUTE_FILTER_OPERATORS as r, createReoptEavClient as t };
|
|
567
|
-
//# sourceMappingURL=client-
|
|
567
|
+
//# sourceMappingURL=client-DNzgX_md.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
2
2
|
|
|
3
3
|
//#region src/auth/client.ts
|
|
4
4
|
function unwrap(body) {
|
|
@@ -50,4 +50,4 @@ function createReoptAuthClient(config) {
|
|
|
50
50
|
|
|
51
51
|
//#endregion
|
|
52
52
|
export { createReoptAuthClient as n, ReoptAuthClient as t };
|
|
53
|
-
//# sourceMappingURL=client-
|
|
53
|
+
//# sourceMappingURL=client-WxPjMNy_.js.map
|
package/dist/cms/index.js
CHANGED
|
@@ -319,7 +319,7 @@ function mapHttpStatusToError(status, code, message, ctx, fieldErrors) {
|
|
|
319
319
|
|
|
320
320
|
//#endregion
|
|
321
321
|
//#region src/core/config.ts
|
|
322
|
-
const SDK_VERSION = "4.
|
|
322
|
+
const SDK_VERSION = "4.5.0-platform.0";
|
|
323
323
|
/**
|
|
324
324
|
* Default API host for EAV / AI / Files / CMS / Terms. Consumers can override
|
|
325
325
|
* via `config.baseUrl` or the `REOPT_BASE_URL` env var.
|
|
@@ -498,4 +498,4 @@ function deriveIdFromBaseUrl(baseUrl) {
|
|
|
498
498
|
|
|
499
499
|
//#endregion
|
|
500
500
|
export { isValidationError as A, RequiredTermsError as C, isModelAccessError as D, isCreditLimitError as E, isReoptSDKError as O, ReoptSDKError as S, ValidationError as T, ModelAccessError as _, resolveIdBaseUrl as a, PreconditionFailedError as b, AuthUserNotFoundError as c, ConflictError as d, ContentFilterError as f, LimitExceededError as g, ForbiddenError as h, resolveBaseUrl as i, mapHttpStatusToError as j, isRequiredTermsError as k, AuthUserRecordExistsError as l, DuplicateAuthUserError as m, SDK_VERSION as n, validateConfig as o, CreditLimitError as p, assertBrowserSafe as r, AuthError as s, REOPT_BASE_URLS as t, BadRequestError as u, ModelNotFoundError as v, ServerError as w, RateLimitError as x, NotFoundError as y };
|
|
501
|
-
//# sourceMappingURL=config-
|
|
501
|
+
//# sourceMappingURL=config-DkT0F-GG.js.map
|
package/dist/eav/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as AuthUserNotFoundError, g as LimitExceededError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError } from "../config-
|
|
2
|
-
import { i as RECORDS_PAGE_LIMIT_MAX, n as ATTRIBUTE_FILTER_LIST_MAX, r as ATTRIBUTE_FILTER_OPERATORS, t as createReoptEavClient } from "../client-
|
|
1
|
+
import { c as AuthUserNotFoundError, g as LimitExceededError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError } from "../config-DkT0F-GG.js";
|
|
2
|
+
import { i as RECORDS_PAGE_LIMIT_MAX, n as ATTRIBUTE_FILTER_LIST_MAX, r as ATTRIBUTE_FILTER_OPERATORS, t as createReoptEavClient } from "../client-DNzgX_md.js";
|
|
3
3
|
|
|
4
4
|
//#region src/eav/verify.ts
|
|
5
5
|
async function verifyEavSchema(input) {
|
package/dist/feedback/index.js
CHANGED
package/dist/files/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ReoptSDKError, a as resolveIdBaseUrl, i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, w as ServerError, x as RateLimitError } from "./config-
|
|
1
|
+
import { S as ReoptSDKError, a as resolveIdBaseUrl, i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, w as ServerError, x as RateLimitError } from "./config-DkT0F-GG.js";
|
|
2
2
|
import { t as createAuthHeader } from "./encoding-Bwfm3iaE.js";
|
|
3
3
|
|
|
4
4
|
//#region src/core/debug.ts
|
|
@@ -383,4 +383,4 @@ function parseFieldErrors(body) {
|
|
|
383
383
|
|
|
384
384
|
//#endregion
|
|
385
385
|
export { parseFieldErrors as n, BaseHttpClient as t };
|
|
386
|
-
//# sourceMappingURL=http-client-
|
|
386
|
+
//# sourceMappingURL=http-client-BO5A5n4I.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { A as isValidationError, C as RequiredTermsError, D as isModelAccessError, E as isCreditLimitError, O as isReoptSDKError, S as ReoptSDKError, T as ValidationError, _ as ModelAccessError, b as PreconditionFailedError, c as AuthUserNotFoundError, d as ConflictError, f as ContentFilterError, g as LimitExceededError, h as ForbiddenError, i as resolveBaseUrl, j as mapHttpStatusToError, k as isRequiredTermsError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError, p as CreditLimitError, r as assertBrowserSafe, s as AuthError, t as REOPT_BASE_URLS, u as BadRequestError, v as ModelNotFoundError, w as ServerError, x as RateLimitError, y as NotFoundError } from "./config-
|
|
2
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
3
|
-
import { n as createReoptAiClient } from "./client-
|
|
4
|
-
import { n as createReoptAuthClient } from "./client-
|
|
5
|
-
import { t as createReoptCmsClient } from "./client-
|
|
6
|
-
import { t as createReoptEavClient } from "./client-
|
|
7
|
-
import { n as createReoptFeedbackClient } from "./client-
|
|
8
|
-
import { n as createReoptFileClient } from "./client-
|
|
9
|
-
import { n as createReoptAnalyticsClient } from "./client-
|
|
10
|
-
import { n as createReoptPlansClient } from "./client-
|
|
11
|
-
import { n as createReoptPushClient } from "./client-
|
|
12
|
-
import { n as createReoptTermsClient } from "./client-
|
|
1
|
+
import { A as isValidationError, C as RequiredTermsError, D as isModelAccessError, E as isCreditLimitError, O as isReoptSDKError, S as ReoptSDKError, T as ValidationError, _ as ModelAccessError, b as PreconditionFailedError, c as AuthUserNotFoundError, d as ConflictError, f as ContentFilterError, g as LimitExceededError, h as ForbiddenError, i as resolveBaseUrl, j as mapHttpStatusToError, k as isRequiredTermsError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError, p as CreditLimitError, r as assertBrowserSafe, s as AuthError, t as REOPT_BASE_URLS, u as BadRequestError, v as ModelNotFoundError, w as ServerError, x as RateLimitError, y as NotFoundError } from "./config-DkT0F-GG.js";
|
|
2
|
+
import { t as BaseHttpClient } from "./http-client-BO5A5n4I.js";
|
|
3
|
+
import { n as createReoptAiClient } from "./client-B0XUjOuP.js";
|
|
4
|
+
import { n as createReoptAuthClient } from "./client-WxPjMNy_.js";
|
|
5
|
+
import { t as createReoptCmsClient } from "./client-BIMl52kc.js";
|
|
6
|
+
import { t as createReoptEavClient } from "./client-DNzgX_md.js";
|
|
7
|
+
import { n as createReoptFeedbackClient } from "./client-BNht520A.js";
|
|
8
|
+
import { n as createReoptFileClient } from "./client-C2ALt685.js";
|
|
9
|
+
import { n as createReoptAnalyticsClient } from "./client-BwgCbfXv.js";
|
|
10
|
+
import { n as createReoptPlansClient } from "./client-Cv1bdMBf.js";
|
|
11
|
+
import { n as createReoptPushClient } from "./client-B270eCrs.js";
|
|
12
|
+
import { n as createReoptTermsClient } from "./client-CKi1NpMR.js";
|
|
13
13
|
|
|
14
14
|
//#region src/singleton.ts
|
|
15
15
|
let _instance;
|
package/dist/logout/index.js
CHANGED
package/dist/plans/index.js
CHANGED
package/dist/push/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ReoptSDKError } from "./config-
|
|
1
|
+
import { S as ReoptSDKError } from "./config-DkT0F-GG.js";
|
|
2
2
|
|
|
3
3
|
//#region src/core/query.ts
|
|
4
4
|
/**
|
|
@@ -32,4 +32,4 @@ function buildQuery(params) {
|
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
34
|
export { buildQuery as t };
|
|
35
|
-
//# sourceMappingURL=query-
|
|
35
|
+
//# sourceMappingURL=query-D08B_HFt.js.map
|
package/dist/terms/index.js
CHANGED
package/dist/webhooks/index.d.ts
CHANGED
|
@@ -15,7 +15,30 @@
|
|
|
15
15
|
* 실제 플랫폼 송신부와 불일치해 모든 프로덕션 웹훅을 401 거부했다. 이 모듈은 송신부에
|
|
16
16
|
* 정렬되어 있다.)
|
|
17
17
|
*/
|
|
18
|
-
type WebhookEventType = "contactCreated" | "contactUpdated" | "contactDeleted" | "workflowRunCompleted" | "workflowRunFailed" | "subscriptionActivated" | "subscriptionRenewed" | "subscriptionCanceled" | "subscriptionPaymentFailed";
|
|
18
|
+
type WebhookEventType = "contactCreated" | "contactUpdated" | "contactDeleted" | "workflowRunCompleted" | "workflowRunFailed" | "subscriptionActivated" | "subscriptionRenewed" | "subscriptionCanceled" | "subscriptionPaymentFailed" | "workTaskStageChanged";
|
|
19
|
+
/**
|
|
20
|
+
* `workTaskStageChanged` 페이로드 — 플랫폼 API(`@reopt-ai/brandapp-sdk/workspace`) 소비자의
|
|
21
|
+
* 역방향 동기화용. 수신 측 규칙: `origin`이 자기 source면 무시, `version`이 마지막 처리값 이하면
|
|
22
|
+
* 무시, `externalRefs`에서 자기 source의 `externalId`를 찾아 상태를 갱신한다.
|
|
23
|
+
*/
|
|
24
|
+
type WorkTaskStageChangedWebhookData = {
|
|
25
|
+
id: string;
|
|
26
|
+
title: string;
|
|
27
|
+
pipelineId: string | null;
|
|
28
|
+
fromStageLabel: string | null;
|
|
29
|
+
toStageId: string;
|
|
30
|
+
toStageLabel: string;
|
|
31
|
+
toStageOutcome: "completed" | "canceled" | null;
|
|
32
|
+
/** "studio"(사람·AI·자동화) 또는 플랫폼 API 클라이언트의 source slug */
|
|
33
|
+
origin: string;
|
|
34
|
+
/** outbox 행 생성 시각(ms epoch) — 단조 비교용 */
|
|
35
|
+
version: number;
|
|
36
|
+
externalRefs: Array<{
|
|
37
|
+
source: string;
|
|
38
|
+
externalId: string;
|
|
39
|
+
label: string | null;
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
19
42
|
/**
|
|
20
43
|
* 구독 이벤트 4종의 공통 페이로드(`WebhookPayload<SubscriptionWebhookData>`).
|
|
21
44
|
*
|
|
@@ -166,5 +189,5 @@ declare function createWebhookHandler(config: {
|
|
|
166
189
|
*/
|
|
167
190
|
declare function verifySignature(timestamp: string, body: string, signature: string, secret: string): Promise<boolean>;
|
|
168
191
|
//#endregion
|
|
169
|
-
export { DEFAULT_IDEMPOTENCY_TTL_MS, DEFAULT_WEBHOOK_TOLERANCE_MS, IdempotencyStore, SubscriptionWebhookData, WebhookEventType, WebhookHandlers, WebhookPayload, createMemoryIdempotencyStore, createWebhookHandler, verifySignature };
|
|
192
|
+
export { DEFAULT_IDEMPOTENCY_TTL_MS, DEFAULT_WEBHOOK_TOLERANCE_MS, IdempotencyStore, SubscriptionWebhookData, WebhookEventType, WebhookHandlers, WebhookPayload, WorkTaskStageChangedWebhookData, createMemoryIdempotencyStore, createWebhookHandler, verifySignature };
|
|
170
193
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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
|
@@ -405,7 +405,7 @@ await sdk.eav.records.update(entityId, recordId, { expiresAt: null }); // TTL
|
|
|
405
405
|
| 속성/엔티티 | 100 | `LIMIT_EXCEEDED_ATTRIBUTES` |
|
|
406
406
|
| 레코드/엔티티 | 10,000 기본 (운영자 `BRANDAPP_EAV_MAX_RECORDS_PER_ENTITY`로 인상) — 만료 행 제외 | `LIMIT_EXCEEDED_RECORDS` (422) |
|
|
407
407
|
| 인메모리 후보 상한 | 10,000행 — 필터가 SQL로 못 내려가는 요청(`neq`/`not_in`/`after`/`before`, 커스텀 속성 정렬)만 해당 | `QUERY_TOO_BROAD` (422) |
|
|
408
|
-
| `list` limit | 최대 100, 기본 50 — SDK가 요청 전에 거절(`RECORDS_PAGE_LIMIT_MAX`), 여러 페이지는 `listAll()`
|
|
408
|
+
| `list` limit | 최대 100, 기본 50 — SDK가 요청 전에 거절(`RECORDS_PAGE_LIMIT_MAX`), 여러 페이지는 `listAll()` | 400 |
|
|
409
409
|
| bulk create/update/delete | 호출당 100건 | 400 |
|
|
410
410
|
| 레코드 값 직렬화 | 128KB/레코드 | `VALIDATION_ERROR` (422) |
|
|
411
411
|
| 엔티티·속성 name/label | 100자, description 500자 | 400 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reopt-ai/brandapp-sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0-platform.0",
|
|
4
4
|
"description": "Reopt Brandapp SDK — Better Auth adapter, OAuth login, and EAV client",
|
|
5
5
|
"author": "Reopt",
|
|
6
6
|
"license": "MIT",
|
|
@@ -89,6 +89,10 @@
|
|
|
89
89
|
"types": "./dist/webhooks/index.d.ts",
|
|
90
90
|
"import": "./dist/webhooks/index.js"
|
|
91
91
|
},
|
|
92
|
+
"./workspace": {
|
|
93
|
+
"types": "./dist/workspace/index.d.ts",
|
|
94
|
+
"import": "./dist/workspace/index.js"
|
|
95
|
+
},
|
|
92
96
|
"./dev": {
|
|
93
97
|
"types": "./dist/dev/index.d.ts",
|
|
94
98
|
"import": "./dist/dev/index.js"
|
|
@@ -118,7 +122,8 @@
|
|
|
118
122
|
"better-auth": "^1.7.1",
|
|
119
123
|
"hono": ">=4.0.0",
|
|
120
124
|
"react": ">=18.0.0",
|
|
121
|
-
"@reopt-ai/data-sdk": ">=0.1.1"
|
|
125
|
+
"@reopt-ai/data-sdk": ">=0.1.1",
|
|
126
|
+
"zod": ">=4.0.0"
|
|
122
127
|
},
|
|
123
128
|
"peerDependenciesMeta": {
|
|
124
129
|
"@ai-sdk/provider": {
|
|
@@ -141,6 +146,9 @@
|
|
|
141
146
|
},
|
|
142
147
|
"@reopt-ai/data-sdk": {
|
|
143
148
|
"optional": true
|
|
149
|
+
},
|
|
150
|
+
"zod": {
|
|
151
|
+
"optional": true
|
|
144
152
|
}
|
|
145
153
|
},
|
|
146
154
|
"devDependencies": {
|