@reopt-ai/brandapp-sdk 4.4.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +1 -0
  3. package/dist/ai/index.js +1 -1
  4. package/dist/ai-provider/index.js +1 -1
  5. package/dist/analytics/index.js +1 -1
  6. package/dist/auth/index.js +1 -1
  7. package/dist/better-auth/index.js +2 -2
  8. package/dist/{client-afAv7Ebi.js → client-BlKXDOUb.js} +4 -4
  9. package/dist/{client-EG1p7FL0.js → client-BnRfa5hI.js} +2 -2
  10. package/dist/{client-D_6WdWsc.js → client-CU9KBiDi.js} +3 -3
  11. package/dist/{client-DuATTvcr.js → client-Cg_gl0Gk.js} +2 -2
  12. package/dist/{client-s2uJ3OML.js → client-D9QA4f3H.js} +2 -2
  13. package/dist/{client-C4sDbXto.js → client-DLvWSpaz.js} +4 -4
  14. package/dist/{client-CuM8MNS5.js → client-NQ0p6XSB.js} +2 -2
  15. package/dist/{client-DsM84EZZ.js → client-d0EwZNc4.js} +3 -3
  16. package/dist/{client-mD6o-qVl.js → client-ijQDMf1X.js} +2 -2
  17. package/dist/{client-DYkDNPyN.js → client-p-tpQ1xj.js} +2 -2
  18. package/dist/cms/index.js +1 -1
  19. package/dist/{config-C_OFYAgP.js → config-DCFgtfSu.js} +2 -2
  20. package/dist/eav/index.js +2 -2
  21. package/dist/feedback/index.js +1 -1
  22. package/dist/files/index.js +1 -1
  23. package/dist/{http-client-BUbFBOvG.js → http-client-CHXNS9TI.js} +2 -2
  24. package/dist/index.js +12 -12
  25. package/dist/logout/index.js +1 -1
  26. package/dist/plans/index.js +1 -1
  27. package/dist/push/index.js +1 -1
  28. package/dist/{query-BkdTSuB5.js → query-ZVC28Rp8.js} +2 -2
  29. package/dist/terms/index.js +1 -1
  30. package/dist/webhooks/index.d.ts +25 -2
  31. package/dist/workspace/index.d.ts +602 -0
  32. package/dist/workspace/index.js +688 -0
  33. package/docs/api-reference.md +5 -1
  34. package/docs/workspace.md +141 -0
  35. package/package.json +10 -2
@@ -0,0 +1,602 @@
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
+ /** RFC-0030 소유 표식. `"code"` = CLI가 관리(UI 편집 잠금) · null = 표식 해제 · 생략 = 유지 */
54
+ managedBy?: "code" | null;
55
+ };
56
+ /** 소스 쪽 식별자 — 경로 세그먼트라 슬래시·공백 금지, ≤255 */
57
+ declare const platformExternalIdSchema: z.ZodType<string>;
58
+ declare const platformTaskStageSchema: z.ZodType<PlatformTaskStage>;
59
+ declare const platformTaskUpsertInputSchema: z.ZodType<PlatformTaskUpsertInput>;
60
+ declare const platformTaskStageInputSchema: z.ZodType<PlatformTaskStageInput>;
61
+ declare const platformWebhookUpsertInputSchema: z.ZodType<PlatformWebhookUpsertInput>;
62
+ type PlatformTask = {
63
+ id: string;
64
+ workspaceId: string;
65
+ brandId: string | null;
66
+ title: string;
67
+ description: string | null;
68
+ priority: PlatformTaskPriority;
69
+ dueDate: string | null;
70
+ pipeline: {
71
+ id: string;
72
+ name: string;
73
+ } | null;
74
+ stage: {
75
+ id: string;
76
+ key: string;
77
+ label: string;
78
+ outcome: PlatformTaskOutcome;
79
+ } | null;
80
+ externalRef: {
81
+ source: string;
82
+ externalId: string;
83
+ url: string | null;
84
+ label: string | null;
85
+ version: number;
86
+ };
87
+ /** 스튜디오 업무 딥링크(절대 URL) */
88
+ url: string;
89
+ createdAt: string;
90
+ updatedAt: string;
91
+ };
92
+ type PlatformWriteMeta = {
93
+ created: boolean;
94
+ applied: boolean;
95
+ };
96
+ type PlatformPipeline = {
97
+ id: string;
98
+ name: string;
99
+ isDefault: boolean;
100
+ stages: Array<{
101
+ id: string;
102
+ key: string;
103
+ label: string;
104
+ order: number;
105
+ isEntry: boolean;
106
+ outcome: PlatformTaskOutcome;
107
+ }>;
108
+ };
109
+ type PlatformMe = {
110
+ clientId: string;
111
+ clientName: string;
112
+ /** 외부 참조 `source` — 이 클라이언트의 Brandapp slug */
113
+ source: string;
114
+ workspaceId: string;
115
+ brandappId: string;
116
+ defaultBrandId: string;
117
+ scopes: string[];
118
+ };
119
+ type PlatformWebhook = {
120
+ id: string;
121
+ url: string;
122
+ triggers: string[];
123
+ hasSecret: boolean;
124
+ };
125
+ type PlatformErrorBody = {
126
+ error: {
127
+ code: string;
128
+ message: string;
129
+ retryable: boolean;
130
+ fields?: Array<{
131
+ field: string;
132
+ message: string;
133
+ }>;
134
+ };
135
+ };
136
+ /** 웹훅 `workTaskStageChanged`의 `data` — 역방향 동기화 수신 측이 이 스키마로 검증한다 */
137
+ type PlatformWorkTaskStageChangedEvent = {
138
+ id: string;
139
+ title: string;
140
+ pipelineId: string | null;
141
+ fromStageLabel: string | null;
142
+ toStageId: string;
143
+ toStageLabel: string;
144
+ toStageOutcome: PlatformTaskOutcome;
145
+ /** "studio" 또는 플랫폼 API 클라이언트의 source slug — 자기 것이면 무시 */
146
+ origin: string;
147
+ /** outbox 행 생성 시각(ms epoch) — 단조 비교 */
148
+ version: number;
149
+ externalRefs: Array<{
150
+ source: string;
151
+ externalId: string;
152
+ label: string | null;
153
+ }>;
154
+ };
155
+ declare const platformTaskSchema: z.ZodType<PlatformTask>;
156
+ declare const platformWriteMetaSchema: z.ZodType<PlatformWriteMeta>;
157
+ declare const platformPipelineSchema: z.ZodType<PlatformPipeline>;
158
+ declare const platformMeSchema: z.ZodType<PlatformMe>;
159
+ declare const platformWebhookSchema: z.ZodType<PlatformWebhook>;
160
+ declare const platformErrorSchema: z.ZodType<PlatformErrorBody>;
161
+ declare const platformWorkTaskStageChangedEventSchema: z.ZodType<PlatformWorkTaskStageChangedEvent>;
162
+ declare const PLATFORM_ADMIN_SCOPE: "workspace:admin";
163
+ declare const PLATFORM_MANAGED_BY_VALUES: readonly ["code"];
164
+ type PlatformManagedBy = (typeof PLATFORM_MANAGED_BY_VALUES)[number];
165
+ /** 단계 색 어휘 — `packages/studio-ui/composites/stage-colors.ts` STAGE_COLORS와 같은 집합(apps/web 파리티 테스트가 고정) */
166
+ declare const PLATFORM_STAGE_COLORS: readonly ["slate", "gray", "red", "rose", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "pink"];
167
+ type PlatformStageColor = (typeof PLATFORM_STAGE_COLORS)[number];
168
+ /** `/^[a-z0-9][a-z0-9-]{0,59}$/` — 선언 파일의 키이자 URL 경로 세그먼트 */
169
+ declare const platformResourceKeySchema: z.ZodType<string>;
170
+ type PlatformPipelineStageInput = {
171
+ key: string;
172
+ label: string;
173
+ /** 생략 = 서버 기본 `"slate"`(생성) / 유지(갱신) */
174
+ color?: PlatformStageColor;
175
+ /** 파이프라인당 정확히 하나 */
176
+ isEntry?: boolean;
177
+ /** null·생략 = 진행 단계 */
178
+ outcome?: PlatformTaskOutcome;
179
+ };
180
+ type PlatformPipelineUpsertInput = {
181
+ name: string;
182
+ description?: string | null;
183
+ /** true면 기존 기본 파이프라인의 기본을 내린다. false를 현재 기본에 주면 422 */
184
+ isDefault?: boolean;
185
+ /** 선언 순서가 곧 `order`. 빠진 기존 단계는 **삭제**된다(업무는 stageId null) */
186
+ stages: PlatformPipelineStageInput[];
187
+ /**
188
+ * 업무가 남아 있는 단계를 지우는 요청은 이 플래그 없이는 409 `DESTRUCTIVE_BLOCKED`.
189
+ * 서버도 fail-closed다 — CLI 게이트(`--allow-destructive`)가 뚫려도 서버가 한 번 더 막는다.
190
+ */
191
+ allowDestructive?: boolean;
192
+ };
193
+ type PlatformPipelineResource = {
194
+ id: string;
195
+ /** 선언 키 — UI로 만든 파이프라인은 null(import로 결속) */
196
+ key: string | null;
197
+ name: string;
198
+ description: string | null;
199
+ isDefault: boolean;
200
+ isArchived: boolean;
201
+ order: number;
202
+ managedBy: PlatformManagedBy | null;
203
+ /** 이 파이프라인에 속한 업무 수(단계 미배정 포함) — 삭제 plan의 영향 수 */
204
+ taskCount: number;
205
+ stages: Array<{
206
+ id: string;
207
+ key: string;
208
+ label: string;
209
+ color: string;
210
+ order: number;
211
+ isEntry: boolean;
212
+ outcome: PlatformTaskOutcome;
213
+ /** 이 단계에 있는 업무 수 — 단계 삭제 plan의 영향 수 */
214
+ taskCount: number;
215
+ }>;
216
+ };
217
+ type PlatformWebhookResource = PlatformWebhook & {
218
+ managedBy: PlatformManagedBy | null;
219
+ };
220
+ /** `GET /v1/resources` — plan이 한 왕복으로 읽는 워크스페이스 자원 전부 */
221
+ type PlatformResources = {
222
+ workspaceId: string;
223
+ pipelines: PlatformPipelineResource[];
224
+ webhooks: PlatformWebhookResource[];
225
+ };
226
+ type PlatformPipelineImportInput = {
227
+ pipelineId: string;
228
+ };
229
+ type PlatformLockAcquired = {
230
+ acquired: true;
231
+ expiresAt: string;
232
+ };
233
+ type PlatformLockReleased = {
234
+ released: boolean;
235
+ };
236
+ declare const platformPipelineStageInputSchema: z.ZodType<PlatformPipelineStageInput>;
237
+ declare const platformPipelineUpsertInputSchema: z.ZodType<PlatformPipelineUpsertInput>;
238
+ declare const platformPipelineImportInputSchema: z.ZodType<PlatformPipelineImportInput>;
239
+ declare const platformPipelineResourceSchema: z.ZodType<PlatformPipelineResource>;
240
+ declare const platformWebhookResourceSchema: z.ZodType<PlatformWebhookResource>;
241
+ declare const platformResourcesSchema: z.ZodType<PlatformResources>;
242
+ declare const platformLockAcquiredSchema: z.ZodType<PlatformLockAcquired>;
243
+ declare const platformLockReleasedSchema: z.ZodType<PlatformLockReleased>;
244
+ declare const PLATFORM_DOMAIN_STATUSES: readonly ["active", "inactive", "pending", "suspended"];
245
+ type PlatformDomainStatus = (typeof PLATFORM_DOMAIN_STATUSES)[number];
246
+ type PlatformBrandResource = {
247
+ id: string;
248
+ /** 선언 키 — UI로 만든 브랜드는 null(import로 결속) */
249
+ key: string | null;
250
+ name: string;
251
+ logo: string | null;
252
+ description: string | null;
253
+ isSystemBrand: boolean;
254
+ managedBy: PlatformManagedBy | null;
255
+ /** 이 브랜드의 도메인들 — 선언의 `domain`은 isPrimary인 것 하나에 대응한다 */
256
+ domains: Array<{
257
+ id: string;
258
+ domain: string;
259
+ isPrimary: boolean;
260
+ status: PlatformDomainStatus;
261
+ }>;
262
+ /** 1:1 형제 브랜드앱의 slug(있으면) */
263
+ brandappSlug: string | null;
264
+ };
265
+ type PlatformBrandUpsertInput = {
266
+ name: string;
267
+ logo?: string | null;
268
+ description?: string | null;
269
+ /** 시스템 브랜드(리옵트 내부 서브 제품) 표식 — 생략 = 유지 */
270
+ isSystemBrand?: boolean;
271
+ /**
272
+ * 기본(primary) 도메인 호스트명. 생략 = 유지. 다른 값이면 새 Domain을 만들어 primary로 올리고 옛 것은
273
+ * primary만 내린다(지우지 않는다 — 브랜드프론트 페이지가 물려 있을 수 있다).
274
+ */
275
+ domain?: string;
276
+ };
277
+ type PlatformBrandImportInput = {
278
+ brandId: string;
279
+ };
280
+ declare const PLATFORM_BRANDAPP_STATUSES: readonly ["draft", "active", "suspended", "archived"];
281
+ type PlatformBrandappResource = {
282
+ id: string;
283
+ /** 선언 키 = slug */
284
+ slug: string;
285
+ name: string;
286
+ description: string | null;
287
+ logo: string | null;
288
+ status: string;
289
+ aiEnabled: boolean;
290
+ isSystemBrandapp: boolean;
291
+ brandId: string;
292
+ /** 브랜드의 선언 키(있으면) */
293
+ brandKey: string | null;
294
+ domainId: string | null;
295
+ settings: Record<string, unknown> | null;
296
+ managedBy: PlatformManagedBy | null;
297
+ };
298
+ type PlatformBrandappUpsertInput = {
299
+ name: string;
300
+ /** 브랜드 선언 키 — 같은 워크스페이스의 `brand/<key>`. Brand:Brandapp은 1:1 */
301
+ brand: string;
302
+ description?: string | null;
303
+ logo?: string | null;
304
+ aiEnabled?: boolean;
305
+ isSystemBrandapp?: boolean;
306
+ /** 생략 = 유지. 주면 통째로 교체 */
307
+ settings?: Record<string, unknown>;
308
+ };
309
+ declare const PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS: readonly ["client_secret_post", "client_secret_basic", "none"];
310
+ declare const PLATFORM_OAUTH_GRANT_TYPES: readonly ["authorization_code", "refresh_token", "client_credentials"];
311
+ declare const PLATFORM_OAUTH_APPLICATION_TYPES: readonly ["web", "native"];
312
+ type PlatformOAuthClientResource = {
313
+ id: string;
314
+ key: string | null;
315
+ clientId: string;
316
+ name: string | null;
317
+ /** 결속된 브랜드앱 slug(metadata.brandappId) — 없으면 플랫폼 API가 거절하는 클라이언트 */
318
+ brandappSlug: string | null;
319
+ disabled: boolean;
320
+ scopes: string[];
321
+ clientCredentialsScopes: string[];
322
+ grantTypes: string[];
323
+ redirectUris: string[];
324
+ postLogoutRedirectUris: string[];
325
+ tokenEndpointAuthMethod: string | null;
326
+ requirePKCE: boolean;
327
+ skipConsent: boolean;
328
+ enableEndSession: boolean;
329
+ applicationType: string | null;
330
+ hasSecret: boolean;
331
+ managedBy: PlatformManagedBy | null;
332
+ /**
333
+ * 🔴 **생성·회전 응답에만** 실린다 — 서버는 해시만 저장하므로 다시 읽을 수 없다. CLI가 마스킹하거나
334
+ * `--secrets-out`(0600)으로 쓴다.
335
+ */
336
+ clientSecret?: string;
337
+ };
338
+ type PlatformOAuthClientUpsertInput = {
339
+ /** 브랜드앱 slug — 워크스페이스·source 도출 축(metadata.brandappId) */
340
+ brandapp: string;
341
+ name?: string;
342
+ scopes: string[];
343
+ grantTypes: string[];
344
+ redirectUris?: string[];
345
+ postLogoutRedirectUris?: string[];
346
+ /** 생략 = 생성 시 client_secret_post / 갱신 시 유지. `none`은 public client(시크릿 없음) */
347
+ tokenEndpointAuthMethod?: (typeof PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS)[number];
348
+ requirePKCE?: boolean;
349
+ skipConsent?: boolean;
350
+ enableEndSession?: boolean;
351
+ applicationType?: (typeof PLATFORM_OAUTH_APPLICATION_TYPES)[number];
352
+ disabled?: boolean;
353
+ };
354
+ type PlatformOAuthClientImportInput = {
355
+ clientId: string;
356
+ };
357
+ /** EAV 엔티티 자원 — SDK `EavEntity & { attributes }`와 같은 어휘(computeDiff 입력으로 그대로 쓴다) */
358
+ type PlatformEavEntityResource = {
359
+ id: string;
360
+ name: string;
361
+ description: string | null;
362
+ icon: string | null;
363
+ linkedTo: string;
364
+ attributes: Array<{
365
+ id: string;
366
+ name: string;
367
+ label: string;
368
+ dataType: string;
369
+ isRequired: boolean;
370
+ isUnique: boolean;
371
+ defaultValue: string | null;
372
+ validation: unknown;
373
+ options: unknown;
374
+ sortOrder: number;
375
+ }>;
376
+ /** 이 엔티티의 레코드 수 — 삭제 plan의 영향 수 */
377
+ recordCount: number;
378
+ };
379
+ type PlatformEavBrandappResources = {
380
+ brandappId: string;
381
+ brandappSlug: string;
382
+ entities: PlatformEavEntityResource[];
383
+ };
384
+ /**
385
+ * 선언형 EAV 적용 연산 — 마이그레이션 러너의 `MigrationOperation`에 update 둘을 더한 집합.
386
+ * 서버가 한 트랜잭션으로 실행한다. 레코드가 남은 엔티티·값이 남은 속성 제거는 `allowDestructive` 없이 409.
387
+ */
388
+ type PlatformEavSchemaOperation = {
389
+ kind: "addEntity";
390
+ name: string;
391
+ def?: {
392
+ description?: string | null;
393
+ icon?: string | null;
394
+ linkedTo?: "brandapp" | "brandappAuthUser";
395
+ };
396
+ } | {
397
+ kind: "updateEntity";
398
+ name: string;
399
+ changes: {
400
+ description?: string | null;
401
+ icon?: string | null;
402
+ };
403
+ } | {
404
+ kind: "removeEntity";
405
+ name: string;
406
+ } | {
407
+ kind: "addAttribute";
408
+ entity: string;
409
+ name: string;
410
+ def: Record<string, unknown>;
411
+ } | {
412
+ kind: "updateAttribute";
413
+ entity: string;
414
+ name: string;
415
+ changes: Record<string, unknown>;
416
+ } | {
417
+ kind: "removeAttribute";
418
+ entity: string;
419
+ name: string;
420
+ } | {
421
+ kind: "renameAttribute";
422
+ entity: string;
423
+ oldName: string;
424
+ newName: string;
425
+ };
426
+ type PlatformEavSchemaApplyInput = {
427
+ /** 브랜드앱 slug — 생략 = 호출 클라이언트의 브랜드앱 */
428
+ brandapp?: string;
429
+ operations: PlatformEavSchemaOperation[];
430
+ allowDestructive?: boolean;
431
+ };
432
+ type PlatformEavSchemaApplyResult = {
433
+ applied: number;
434
+ entities: PlatformEavEntityResource[];
435
+ };
436
+ declare const platformBrandUpsertInputSchema: z.ZodType<PlatformBrandUpsertInput>;
437
+ declare const platformBrandImportInputSchema: z.ZodType<PlatformBrandImportInput>;
438
+ declare const platformBrandResourceSchema: z.ZodType<PlatformBrandResource>;
439
+ declare const platformBrandappUpsertInputSchema: z.ZodType<PlatformBrandappUpsertInput>;
440
+ declare const platformBrandappResourceSchema: z.ZodType<PlatformBrandappResource>;
441
+ declare const platformOAuthClientUpsertInputSchema: z.ZodType<PlatformOAuthClientUpsertInput>;
442
+ declare const platformOAuthClientImportInputSchema: z.ZodType<PlatformOAuthClientImportInput>;
443
+ declare const platformOAuthClientResourceSchema: z.ZodType<PlatformOAuthClientResource>;
444
+ declare const platformEavEntityResourceSchema: z.ZodType<PlatformEavEntityResource>;
445
+ declare const platformEavBrandappResourcesSchema: z.ZodType<PlatformEavBrandappResources>;
446
+ declare const platformEavSchemaOperationSchema: z.ZodType<PlatformEavSchemaOperation>;
447
+ declare const platformEavSchemaApplyInputSchema: z.ZodType<PlatformEavSchemaApplyInput>;
448
+ declare const platformEavSchemaApplyResultSchema: z.ZodType<PlatformEavSchemaApplyResult>;
449
+ /** `GET /v1/resources` 전체(1단계 pipelines·webhooks + 2·3단계). */
450
+ type PlatformResourcesV2 = PlatformResources & {
451
+ brands: PlatformBrandResource[];
452
+ brandapps: PlatformBrandappResource[];
453
+ oauthClients: PlatformOAuthClientResource[];
454
+ eav: PlatformEavBrandappResources[];
455
+ };
456
+ declare const platformResourcesV2Schema: z.ZodType<PlatformResourcesV2>;
457
+ //#endregion
458
+ //#region src/workspace/client.d.ts
459
+ /**
460
+ * 플랫폼 API(RFC-0029) 클라이언트 — **서버 전용**.
461
+ *
462
+ * `client_credentials`로 `platform.reopt.ai` audience 토큰을 받아(캐시·만료 60초 전 재발급·401 시 1회
463
+ * 재발급) `/v1/*`를 부른다. 브라우저에서 만들면 던진다 — clientSecret이 곧 워크스페이스 쓰기 권한이다.
464
+ *
465
+ * 기본 origin은 환경에서 파생하고(`isProduction` 또는 `REOPT_PLATFORM_URL`/`REOPT_ID_BASE_URL` env),
466
+ * 자체서명 dev 인증서는 `fetch` 주입(undici Agent 등)으로 요청 단위로 푼다 — 프로세스 전역
467
+ * `NODE_TLS_REJECT_UNAUTHORIZED`는 쓰지 않는다.
468
+ */
469
+ declare const REOPT_PLATFORM_URLS: {
470
+ readonly production: "https://platform.reopt.ai";
471
+ readonly development: "https://platform.reopt.de:3443";
472
+ };
473
+ declare const REOPT_PLATFORM_ID_URLS: {
474
+ readonly production: "https://id.reopt.ai";
475
+ readonly development: "https://id.reopt.de:3443";
476
+ };
477
+ declare const DEFAULT_PLATFORM_SCOPES: readonly ["works:read", "works:write"];
478
+ type PlatformClientConfig = {
479
+ clientId: string;
480
+ clientSecret: string;
481
+ /** 플랫폼 API origin. 생략 시 `REOPT_PLATFORM_URL` env → `isProduction` 기본값 */
482
+ platformUrl?: string;
483
+ /** 토큰 발급(id 서버) origin. 생략 시 `REOPT_ID_BASE_URL` env → `isProduction` 기본값 */
484
+ idBaseUrl?: string;
485
+ /** 기본 `["works:read", "works:write"]` — 클라이언트의 clientCredentialsScopes 안이어야 한다 */
486
+ scopes?: readonly string[];
487
+ /** true: production 호스트 / false: dev 호스트 / 생략: `NODE_ENV === "production"` */
488
+ isProduction?: boolean;
489
+ /** 요청 타임아웃(ms). 기본 10_000 */
490
+ timeoutMs?: number;
491
+ /** fetch 주입 — 테스트·자체서명 인증서(undici dispatcher) 용 */
492
+ fetch?: typeof fetch;
493
+ /** 서버 로그 상관관계용 — 요청마다 `X-Request-Id`로 실린다(생략 시 UUID) */
494
+ requestId?: () => string;
495
+ };
496
+ type PlatformWriteResult<T> = {
497
+ data: T;
498
+ meta: PlatformWriteMeta;
499
+ };
500
+ declare class PlatformApiError extends Error {
501
+ readonly status: number;
502
+ readonly code: string;
503
+ readonly retryable: boolean;
504
+ readonly fields?: Array<{
505
+ field: string;
506
+ message: string;
507
+ }>;
508
+ readonly requestId?: string;
509
+ constructor(input: {
510
+ status: number;
511
+ code: string;
512
+ message: string;
513
+ retryable: boolean;
514
+ fields?: Array<{
515
+ field: string;
516
+ message: string;
517
+ }>;
518
+ requestId?: string;
519
+ });
520
+ }
521
+ type PlatformUrls = {
522
+ platformUrl: string;
523
+ idBaseUrl: string;
524
+ };
525
+ declare function resolvePlatformUrls(config: Pick<PlatformClientConfig, "platformUrl" | "idBaseUrl" | "isProduction">): PlatformUrls;
526
+ type PlatformClient = {
527
+ /** 진단 — 이 자격이 어느 워크스페이스·source에 묶였는가 */
528
+ me: () => Promise<PlatformMe>;
529
+ works: {
530
+ listPipelines: () => Promise<PlatformPipeline[]>;
531
+ upsertTask: (externalId: string, input: PlatformTaskUpsertInput) => Promise<PlatformWriteResult<PlatformTask>>;
532
+ getTask: (externalId: string) => Promise<PlatformTask>;
533
+ setTaskStage: (externalId: string, input: PlatformTaskStageInput) => Promise<PlatformWriteResult<PlatformTask>>;
534
+ /** RFC-0030 — 선언 키 기준 파이프라인 upsert(단계는 key로 조정, 빠진 단계는 삭제). scope `workspace:admin` */
535
+ upsertPipeline: (key: string, input: PlatformPipelineUpsertInput) => Promise<PlatformWriteResult<PlatformPipelineResource>>;
536
+ /** RFC-0030 — 업무가 남아 있으면 `allowDestructive` 없이는 409 DESTRUCTIVE_BLOCKED. 기본 파이프라인은 422 */
537
+ deletePipeline: (key: string, options?: {
538
+ allowDestructive?: boolean;
539
+ }) => Promise<{
540
+ id: string;
541
+ deleted: boolean;
542
+ }>;
543
+ /** RFC-0030 — UI로 만든 기존 파이프라인에 선언 키·`managedBy: "code"`를 결속 */
544
+ importPipeline: (key: string, input: PlatformPipelineImportInput) => Promise<PlatformPipelineResource>;
545
+ };
546
+ /** RFC-0030 — plan이 한 왕복으로 읽는 워크스페이스 자원 전부(파이프라인·웹훅·브랜드·브랜드앱·OAuth·EAV). scope `workspace:admin` */
547
+ resources: {
548
+ list: () => Promise<PlatformResourcesV2>;
549
+ };
550
+ /** RFC-0030 3단계 — 브랜드(+primary 도메인). 삭제 라우트는 없다(unsupported — superadmin에서 사람이). */
551
+ brands: {
552
+ upsert: (key: string, input: PlatformBrandUpsertInput) => Promise<PlatformWriteResult<PlatformBrandResource>>;
553
+ import: (key: string, input: PlatformBrandImportInput) => Promise<PlatformBrandResource>;
554
+ };
555
+ /** RFC-0030 3단계 — 브랜드앱(slug = 키). 삭제 라우트 없음. import는 slug가 정체성이라 본문이 없다. */
556
+ brandapps: {
557
+ upsert: (slug: string, input: PlatformBrandappUpsertInput) => Promise<PlatformWriteResult<PlatformBrandappResource>>;
558
+ import: (slug: string) => Promise<PlatformBrandappResource>;
559
+ };
560
+ /**
561
+ * RFC-0030 3단계 — OAuth 클라이언트. 🔴 생성·회전 응답의 `data.clientSecret`은 이때 한 번만 보인다.
562
+ * 삭제는 발급 토큰을 무효화한다(destructive — CLI가 `--allow-destructive`를 요구).
563
+ */
564
+ oauthClients: {
565
+ upsert: (key: string, input: PlatformOAuthClientUpsertInput) => Promise<PlatformWriteResult<PlatformOAuthClientResource>>;
566
+ rotateSecret: (key: string) => Promise<PlatformOAuthClientResource>;
567
+ delete: (key: string, options?: {
568
+ allowDestructive?: boolean;
569
+ }) => Promise<{
570
+ id: string;
571
+ deleted: boolean;
572
+ }>;
573
+ import: (key: string, input: PlatformOAuthClientImportInput) => Promise<PlatformOAuthClientResource>;
574
+ };
575
+ /** RFC-0030 2단계 — EAV 스키마 연산을 한 트랜잭션으로. 레코드가 남은 삭제는 allowDestructive 없이 409. */
576
+ eav: {
577
+ applySchema: (input: PlatformEavSchemaApplyInput) => Promise<PlatformEavSchemaApplyResult>;
578
+ };
579
+ /**
580
+ * RFC-0030 — 워크스페이스 apply 락(Redis, TTL 30분, fail-closed). 잡혀 있으면 `PlatformApiError`
581
+ * code `LOCK_HELD`(409), Redis 불가면 `LOCK_UNAVAILABLE`(503). EAV 마이그레이션 러너와 같은 락이다.
582
+ */
583
+ lock: {
584
+ acquire: (holderId: string) => Promise<PlatformLockAcquired>;
585
+ release: (holderId: string) => Promise<PlatformLockReleased>;
586
+ };
587
+ webhooks: {
588
+ list: () => Promise<PlatformWebhook[]>;
589
+ upsert: (input: PlatformWebhookUpsertInput) => Promise<PlatformWriteResult<PlatformWebhook>>;
590
+ delete: (id: string) => Promise<{
591
+ id: string;
592
+ deleted: boolean;
593
+ }>;
594
+ };
595
+ /** 테스트·진단용 — 캐시된 토큰을 버린다 */
596
+ invalidateToken: () => void;
597
+ urls: PlatformUrls;
598
+ };
599
+ declare function createPlatformClient(config: PlatformClientConfig): PlatformClient;
600
+ //#endregion
601
+ export { DEFAULT_PLATFORM_SCOPES, PLATFORM_ADMIN_SCOPE, PLATFORM_BRANDAPP_STATUSES, PLATFORM_DOMAIN_STATUSES, PLATFORM_MANAGED_BY_VALUES, PLATFORM_OAUTH_APPLICATION_TYPES, 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 PlatformDomainStatus, type PlatformEavBrandappResources, type PlatformEavEntityResource, type PlatformEavSchemaApplyInput, type PlatformEavSchemaApplyResult, type PlatformEavSchemaOperation, type PlatformErrorBody, type PlatformLockAcquired, type PlatformLockReleased, type PlatformManagedBy, type PlatformMe, type PlatformOAuthClientImportInput, type PlatformOAuthClientResource, type PlatformOAuthClientUpsertInput, type PlatformPipeline, type PlatformPipelineImportInput, type PlatformPipelineResource, type PlatformPipelineStageInput, type PlatformPipelineUpsertInput, 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, createPlatformClient, platformBrandImportInputSchema, platformBrandResourceSchema, platformBrandUpsertInputSchema, platformBrandappResourceSchema, platformBrandappUpsertInputSchema, platformEavBrandappResourcesSchema, platformEavEntityResourceSchema, platformEavSchemaApplyInputSchema, platformEavSchemaApplyResultSchema, platformEavSchemaOperationSchema, platformErrorSchema, platformExternalIdSchema, platformLockAcquiredSchema, platformLockReleasedSchema, platformMeSchema, platformOAuthClientImportInputSchema, platformOAuthClientResourceSchema, platformOAuthClientUpsertInputSchema, platformPipelineImportInputSchema, platformPipelineResourceSchema, platformPipelineSchema, platformPipelineStageInputSchema, platformPipelineUpsertInputSchema, platformResourceKeySchema, platformResourcesSchema, platformResourcesV2Schema, platformTaskSchema, platformTaskStageInputSchema, platformTaskStageSchema, platformTaskUpsertInputSchema, platformWebhookResourceSchema, platformWebhookSchema, platformWebhookUpsertInputSchema, platformWorkTaskStageChangedEventSchema, platformWriteMetaSchema, resolvePlatformUrls };
602
+ //# sourceMappingURL=index.d.ts.map