@reopt-ai/workspace-sdk 0.1.0-rc.11 → 0.1.0-rc.13

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 (42) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +7 -2
  3. package/dist/better-auth/index.d.ts +1 -1
  4. package/dist/better-auth/index.js +1 -1
  5. package/dist/{client-XAvKlbbn.js → client-BLaFMBbS.js} +2 -2
  6. package/dist/{client-WEomQekp.js → client-BX4VHJS6.js} +5 -5
  7. package/dist/{client-DlgVNj3w.d.ts → client-DVozA5Ep.d.ts} +2 -2
  8. package/dist/{client-ByIjKnf3.d.ts → client-olMIaJZH.d.ts} +3 -3
  9. package/dist/{connect-BBf9QfQB.d.ts → connect-CTxppAjD.d.ts} +104 -5
  10. package/dist/connect.d.ts +6 -5
  11. package/dist/connect.js +4 -3
  12. package/dist/{errors-DLJlABJL.d.ts → errors-CLUuzCNG.d.ts} +3 -1
  13. package/dist/{errors-C5_fhcqb.js → errors-DKMC4kId.js} +2 -2
  14. package/dist/forms.d.ts +167 -0
  15. package/dist/forms.js +221 -0
  16. package/dist/index.d.ts +7 -6
  17. package/dist/index.js +5 -4
  18. package/dist/installation/index.d.ts +3 -3
  19. package/dist/installation/index.js +3 -3
  20. package/dist/{keys-6gwtNd0g.js → keys--ef_VwZ-.js} +6 -5
  21. package/dist/{keys-B2pA8EkU.d.ts → keys-BXkGh0VM.d.ts} +10 -2
  22. package/dist/machine/index.d.ts +2 -2
  23. package/dist/machine/index.js +2 -2
  24. package/dist/machine/keygen-cli.js +1 -1
  25. package/dist/mentions-BMI2c7O6.d.ts +26 -0
  26. package/dist/mentions.d.ts +2 -0
  27. package/dist/mentions.js +45 -0
  28. package/dist/{page-79Ab4UGQ.d.ts → page-j1OCu4of.d.ts} +8 -4
  29. package/dist/{page-SjWh1rqY.js → page-rc95cliL.js} +72 -7
  30. package/dist/{permissions-COCbNJeQ.d.ts → permissions-DKm_zC_X.d.ts} +2 -2
  31. package/dist/permissions.d.ts +1 -1
  32. package/dist/permissions.js +48 -0
  33. package/dist/social/index.d.ts +2 -2
  34. package/dist/social/index.js +2 -2
  35. package/dist/testing/index.d.ts +27 -3
  36. package/dist/testing/index.js +343 -30
  37. package/dist/{transport-CN64IoHx.js → transport-BEwY_twi.js} +2 -2
  38. package/docs/forms.md +100 -0
  39. package/docs/machine.md +14 -4
  40. package/docs/testing.md +10 -6
  41. package/docs/workspace.md +70 -19
  42. package/package.json +9 -1
@@ -1,5 +1,5 @@
1
- import { n as PlatformApiError } from "./errors-C5_fhcqb.js";
2
- import { t as createTransport } from "./transport-CN64IoHx.js";
1
+ import { n as PlatformApiError } from "./errors-DKMC4kId.js";
2
+ import { t as createTransport } from "./transport-BEwY_twi.js";
3
3
  import { resolvePlatformUrls } from "./urls.js";
4
4
  import { z } from "zod";
5
5
 
@@ -118,6 +118,34 @@ const authorSchema = z.looseObject({
118
118
  name: z.string().nullable(),
119
119
  image: z.string().nullable()
120
120
  }).nullable();
121
+ const feedMember = z.looseObject({
122
+ memberId: z.string(),
123
+ name: z.string(),
124
+ image: z.string().nullable().default(null)
125
+ }).nullable();
126
+ const taskCommentShape = {
127
+ type: z.literal("comment"),
128
+ id: z.string(),
129
+ author: feedMember.default(null),
130
+ content: z.string(),
131
+ isEdited: z.boolean().default(false),
132
+ createdAt: iso
133
+ };
134
+ const connectTaskCommentSchema = z.looseObject({
135
+ ...taskCommentShape,
136
+ taskId: z.string()
137
+ });
138
+ const connectTaskFeedItemSchema = z.union([z.looseObject({
139
+ ...taskCommentShape,
140
+ taskId: z.string().optional()
141
+ }), z.looseObject({
142
+ type: z.literal("activity"),
143
+ id: z.string(),
144
+ actor: feedMember.default(null),
145
+ activityType: z.string(),
146
+ payload: z.record(z.string(), z.unknown()).nullable().default(null),
147
+ createdAt: iso
148
+ })]);
121
149
  const connectPostGroupSchema = z.looseObject({
122
150
  id: z.string(),
123
151
  name: z.string(),
@@ -189,6 +217,20 @@ const signedUrlSchema = z.looseObject({
189
217
  url: z.string(),
190
218
  expiresAt: z.string()
191
219
  });
220
+ const connectNotificationSchema = z.looseObject({
221
+ id: z.string(),
222
+ kind: z.string(),
223
+ subject: z.string().nullable(),
224
+ content: z.string(),
225
+ seenAt: nullableIso,
226
+ createdAt: iso,
227
+ actorName: z.string().nullable(),
228
+ actorImage: z.string().nullable(),
229
+ entity: z.looseObject({
230
+ type: z.string(),
231
+ id: z.string()
232
+ }).nullable()
233
+ });
192
234
  const connectFormSchema = z.looseObject({
193
235
  id: z.string(),
194
236
  name: z.string(),
@@ -299,6 +341,7 @@ const customerTagSchema = z.looseObject({
299
341
  });
300
342
  const customerFieldSchema = z.looseObject({
301
343
  id: z.string(),
344
+ name: z.string().nullable().default(null),
302
345
  label: z.string(),
303
346
  dataType: z.string(),
304
347
  options: z.array(z.string()).default([])
@@ -354,7 +397,8 @@ const DEFAULT_LIMIT = {
354
397
  files: 100,
355
398
  inquiries: 100,
356
399
  records: 100,
357
- customers: 50
400
+ customers: 50,
401
+ notifications: 20
358
402
  };
359
403
  const nextOffsetSchema = z.looseObject({ nextOffset: z.number().nullable().optional() });
360
404
  function totalOf(meta) {
@@ -452,7 +496,11 @@ function createConnectClient(config) {
452
496
  deleteTasks: (ids, options) => one("POST", "/works/tasks/delete", z.looseObject({
453
497
  deleted: z.array(z.string()),
454
498
  notFound: z.array(z.string())
455
- }), options, { ids })
499
+ }), options, { ids }),
500
+ listFeed: (taskId, options) => page(`/works/tasks/${enc(taskId)}/feed`, connectTaskFeedItemSchema, options),
501
+ addComment: (taskId, content, options) => one("POST", `/works/tasks/${enc(taskId)}/comments`, connectTaskCommentSchema, options, { content }),
502
+ updateComment: (commentId, content, options) => one("PATCH", `/works/task-comments/${enc(commentId)}`, connectTaskCommentSchema, options, { content }),
503
+ deleteComment: (commentId, options) => one("DELETE", `/works/task-comments/${enc(commentId)}`, idResult, options)
456
504
  },
457
505
  posts: {
458
506
  listGroups: (options) => page("/post-groups", connectPostGroupSchema, options),
@@ -512,14 +560,31 @@ function createConnectClient(config) {
512
560
  content: (id, options) => transport.raw("GET", `/files/${enc(id)}/content`, options)
513
561
  },
514
562
  forms: { list: (options) => page("/forms", connectFormSchema, options) },
563
+ notifications: {
564
+ list: (query = {}, options) => page(`/notifications${queryString({
565
+ unseen: query.unseen ? "true" : void 0,
566
+ limit: query.limit ?? DEFAULT_LIMIT.notifications,
567
+ offset: query.offset
568
+ })}`, connectNotificationSchema, options),
569
+ unseenCount: async (options) => (await one("GET", "/notifications/unseen-count", z.looseObject({ count: z.number() }), options)).count,
570
+ markSeen: (id, options) => one("POST", `/notifications/${enc(id)}/seen`, z.looseObject({
571
+ id: z.string(),
572
+ seenAt: nullableIso
573
+ }), options),
574
+ markAllSeen: (options) => one("POST", "/notifications/seen", z.looseObject({ count: z.number() }), options)
575
+ },
515
576
  customers: {
516
- list: (query = {}, options) => {
577
+ list: async (query = {}, options) => {
517
578
  const { tags, limit, ...rest } = query;
518
- return page(`/customers${queryString({
579
+ const result = await page(`/customers${queryString({
519
580
  ...rest,
520
581
  tag: tags,
521
582
  limit: limit ?? DEFAULT_LIMIT.customers
522
583
  })}`, connectCustomerSummarySchema, options);
584
+ return {
585
+ ...result,
586
+ total: result.total ?? result.items.length
587
+ };
523
588
  },
524
589
  listTags: (options) => page("/customer-tags", customerTagSchema, options),
525
590
  listFields: (options) => page("/customer-fields", customerFieldSchema, options),
@@ -603,4 +668,4 @@ async function listAll(fetchPage, query, options = {}) {
603
668
 
604
669
  //#endregion
605
670
  export { connectPostSummarySchema as _, connectEavRecordSchema as a, createConnectClient as b, connectFolderSchema as c, connectInquirySchema as d, connectMeSchema as f, connectPostSchema as g, connectPostGroupSchema as h, connectEavEntitySchema as i, connectFormSchema as l, connectPipelineSchema as m, listAll as n, connectFileSchema as o, connectMemberSchema as p, connectBrandSchema as r, connectFileUsageSchema as s, iterate as t, connectInquiryDetailSchema as u, connectPostTagSchema as v, connectTaskSchema as y };
606
- //# sourceMappingURL=page-SjWh1rqY.js.map
671
+ //# sourceMappingURL=page-rc95cliL.js.map
@@ -34,7 +34,7 @@ declare function canAll(source: PermissionSource, keys: readonly WorkspacePermis
34
34
  /** 하나라도 가졌는가 */
35
35
  declare function canAny(source: PermissionSource, keys: readonly WorkspacePermissionKey[]): boolean;
36
36
  /** 위임 클라이언트의 메서드 이름(`createConnectClient`의 경로 그대로) */
37
- declare const CONNECT_OPERATION_NAMES: readonly ["me", "brands", "members", "works.listPipelines", "works.listTasks", "works.getTask", "works.createTask", "works.updateTask", "works.moveTask", "works.deleteTask", "works.deleteTasks", "posts.listGroups", "posts.listTags", "posts.list", "posts.checkSlug", "posts.get", "posts.create", "posts.update", "posts.publish", "posts.unpublish", "posts.delete", "folders.list", "folders.create", "folders.update", "folders.delete", "files.list", "files.usage", "files.signedUrls", "files.upload", "files.get", "files.update", "files.delete", "files.content", "forms.list", "inquiries.list", "inquiries.get", "inquiries.moveStage", "customers.list", "customers.listTags", "customers.listFields", "customers.get", "customers.create", "customers.update", "customers.updateTags", "customers.listNotes", "customers.addNote", "customers.updateNote", "customers.deleteNote", "customers.timeline", "eav.listEntities", "eav.listRecords", "eav.createRecord", "eav.updateRecord", "eav.deleteRecord"];
37
+ declare const CONNECT_OPERATION_NAMES: readonly ["me", "brands", "members", "works.listPipelines", "works.listTasks", "works.getTask", "works.createTask", "works.updateTask", "works.moveTask", "works.deleteTask", "works.deleteTasks", "works.listFeed", "works.addComment", "works.updateComment", "works.deleteComment", "posts.listGroups", "posts.listTags", "posts.list", "posts.checkSlug", "posts.get", "posts.create", "posts.update", "posts.publish", "posts.unpublish", "posts.delete", "folders.list", "folders.create", "folders.update", "folders.delete", "files.list", "files.usage", "files.signedUrls", "files.upload", "files.get", "files.update", "files.delete", "files.content", "forms.list", "inquiries.list", "inquiries.get", "inquiries.moveStage", "customers.list", "customers.listTags", "customers.listFields", "customers.get", "customers.create", "customers.update", "customers.updateTags", "customers.listNotes", "customers.addNote", "customers.updateNote", "customers.deleteNote", "customers.timeline", "notifications.list", "notifications.unseenCount", "notifications.markAllSeen", "notifications.markSeen", "eav.listEntities", "eav.listRecords", "eav.createRecord", "eav.updateRecord", "eav.deleteRecord"];
38
38
  type ConnectOperation = (typeof CONNECT_OPERATION_NAMES)[number];
39
39
  type ConnectOperationRule = {
40
40
  /** 서버 라우트(정책 표의 키) */
@@ -61,4 +61,4 @@ declare function canCall(me: {
61
61
  } | readonly string[] | null | undefined, operation: ConnectOperation): boolean;
62
62
  //#endregion
63
63
  export { ConnectOperationRule as a, WorkspacePermissionKey as c, canAny as d, canCall as f, ConnectOperation as i, can as l, CONNECT_OPERATION_NAMES as n, ConnectScope as o, CONNECT_SCOPES as r, WORKSPACE_PERMISSION_KEYS as s, CONNECT_OPERATIONS as t, canAll as u };
64
- //# sourceMappingURL=permissions-COCbNJeQ.d.ts.map
64
+ //# sourceMappingURL=permissions-DKm_zC_X.d.ts.map
@@ -1,2 +1,2 @@
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-COCbNJeQ.js";
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-DKm_zC_X.js";
2
2
  export { CONNECT_OPERATIONS, CONNECT_OPERATION_NAMES, CONNECT_SCOPES, ConnectOperation, ConnectOperationRule, ConnectScope, WORKSPACE_PERMISSION_KEYS, WorkspacePermissionKey, can, canAll, canAny, canCall };
@@ -125,6 +125,10 @@ const CONNECT_OPERATION_NAMES = [
125
125
  "works.moveTask",
126
126
  "works.deleteTask",
127
127
  "works.deleteTasks",
128
+ "works.listFeed",
129
+ "works.addComment",
130
+ "works.updateComment",
131
+ "works.deleteComment",
128
132
  "posts.listGroups",
129
133
  "posts.listTags",
130
134
  "posts.list",
@@ -163,6 +167,10 @@ const CONNECT_OPERATION_NAMES = [
163
167
  "customers.updateNote",
164
168
  "customers.deleteNote",
165
169
  "customers.timeline",
170
+ "notifications.list",
171
+ "notifications.unseenCount",
172
+ "notifications.markAllSeen",
173
+ "notifications.markSeen",
166
174
  "eav.listEntities",
167
175
  "eav.listRecords",
168
176
  "eav.createRecord",
@@ -243,6 +251,26 @@ const CONNECT_OPERATIONS = {
243
251
  permission: "works:delete",
244
252
  scopes: WRITE
245
253
  },
254
+ "works.listFeed": {
255
+ route: "GET /works/tasks/:id/feed",
256
+ permission: "works:read",
257
+ scopes: READ
258
+ },
259
+ "works.addComment": {
260
+ route: "POST /works/tasks/:id/comments",
261
+ permission: "works:write",
262
+ scopes: WRITE
263
+ },
264
+ "works.updateComment": {
265
+ route: "PATCH /works/task-comments/:commentId",
266
+ permission: "works:write",
267
+ scopes: WRITE
268
+ },
269
+ "works.deleteComment": {
270
+ route: "DELETE /works/task-comments/:commentId",
271
+ permission: "works:write",
272
+ scopes: WRITE
273
+ },
246
274
  "posts.listGroups": {
247
275
  route: "GET /post-groups",
248
276
  permission: "post:read",
@@ -385,6 +413,26 @@ const CONNECT_OPERATIONS = {
385
413
  "customers.updateNote": customerWrite("PATCH /customer-notes/:noteId"),
386
414
  "customers.deleteNote": customerWrite("DELETE /customer-notes/:noteId"),
387
415
  "customers.timeline": customerRead("GET /customers/:id/timeline"),
416
+ "notifications.list": {
417
+ route: "GET /notifications",
418
+ permission: null,
419
+ scopes: READ
420
+ },
421
+ "notifications.unseenCount": {
422
+ route: "GET /notifications/unseen-count",
423
+ permission: null,
424
+ scopes: READ
425
+ },
426
+ "notifications.markAllSeen": {
427
+ route: "POST /notifications/seen",
428
+ permission: null,
429
+ scopes: READ
430
+ },
431
+ "notifications.markSeen": {
432
+ route: "POST /notifications/:id/seen",
433
+ permission: null,
434
+ scopes: READ
435
+ },
388
436
  "eav.listEntities": {
389
437
  route: "GET /eav/entities",
390
438
  permission: "eav:read",
@@ -1,6 +1,6 @@
1
- import { n as PlatformApiError } from "../errors-DLJlABJL.js";
1
+ import { n as PlatformApiError } from "../errors-CLUuzCNG.js";
2
2
  import { a as REOPT_PLATFORM_URLS, c as resolvePlatformUrls, i as REOPT_PLATFORM_ID_URLS, n as PlatformUrls } from "../urls-DiYp_PHg.js";
3
- import { r as PlatformClientConfig } from "../client-ByIjKnf3.js";
3
+ import { r as PlatformClientConfig } from "../client-olMIaJZH.js";
4
4
  import { z } from "zod";
5
5
  //#region src/social/schemas.d.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { n as PlatformApiError } from "../errors-C5_fhcqb.js";
1
+ import { n as PlatformApiError } from "../errors-DKMC4kId.js";
2
2
  import { REOPT_PLATFORM_ID_URLS, REOPT_PLATFORM_URLS, resolvePlatformUrls } from "../urls.js";
3
- import { r as createPlatformRequester } from "../client-WEomQekp.js";
3
+ import { r as createPlatformRequester } from "../client-BX4VHJS6.js";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region src/social/schemas.ts
@@ -1,5 +1,5 @@
1
- import { c as WorkspacePermissionKey } from "../permissions-COCbNJeQ.js";
2
- import { N as ConnectMemberRole, Q as ConnectStageOutcome, U as ConnectPostSpec, Z as ConnectStageColor, n as ConnectAnswerValue, rt as ConnectTaskPriority } from "../connect-BBf9QfQB.js";
1
+ import { c as WorkspacePermissionKey } from "../permissions-DKm_zC_X.js";
2
+ import { $ as ConnectStageColor, G as ConnectPostSpec, N as ConnectMemberRole, et as ConnectStageOutcome, lt as ConnectTaskPriority, n as ConnectAnswerValue } from "../connect-CTxppAjD.js";
3
3
  //#region src/testing/index.d.ts
4
4
  /** 서로는 id가 아니라 `key`로 가리킨다 — id는 에뮬레이터가 만든다(`platform.id("task", key)`로 읽는다). */
5
5
  type DevPlatformSeed = {
@@ -43,6 +43,11 @@ type DevPlatformSeed = {
43
43
  priority?: ConnectTaskPriority;
44
44
  dueDate?: string | null;
45
45
  assignees?: string[];
46
+ /** 댓글 — `author`는 멤버 key(생략하면 첫 멤버) */
47
+ comments?: Array<{
48
+ author?: string;
49
+ content: string;
50
+ }>;
46
51
  }>;
47
52
  postGroups?: Array<{
48
53
  key: string;
@@ -102,6 +107,25 @@ type DevPlatformSeed = {
102
107
  submittedAt?: string;
103
108
  memo?: string;
104
109
  }>;
110
+ /**
111
+ * 로그인한 직원이 받은 알림. 에뮬레이터는 알림을 스스로 만들지 않는다 — 실제 리옵트는 **다른 사람**이 한 일을 알리는데
112
+ * 에뮬레이터에는 사람이 하나뿐이다. 벨 화면은 시드로 채운다.
113
+ */
114
+ notifications?: Array<{
115
+ key?: string;
116
+ /** `task_assigned`·`task_comment`·`task_mention`·`task_stage_changed`·`task_due_soon`·`form_submitted`·`customer_created` */
117
+ kind: string;
118
+ subject?: string;
119
+ content: string;
120
+ /** 이미 읽은 알림 */
121
+ seen?: boolean;
122
+ actorName?: string;
123
+ /** 가리키는 업무의 key */
124
+ task?: string;
125
+ /** 가리키는 폼의 key */
126
+ form?: string;
127
+ createdAt?: string;
128
+ }>;
105
129
  customers?: Array<{
106
130
  key: string;
107
131
  name: string;
@@ -200,7 +224,7 @@ type DevPlatform = {
200
224
  /** 받은 요청 기록(최근 1,000건) — `"GET /files?folderId=all"` */
201
225
  requests: string[];
202
226
  };
203
- type DevIdKind = "member" | "brand" | "pipeline" | "stage" | "task" | "postGroup" | "post" | "folder" | "file" | "form" | "submission" | "customer" | "table";
227
+ type DevIdKind = "member" | "brand" | "pipeline" | "stage" | "task" | "postGroup" | "post" | "folder" | "file" | "form" | "submission" | "customer" | "notification" | "table";
204
228
  declare function createDevPlatform(options?: DevPlatformOptions): DevPlatform;
205
229
  //#endregion
206
230
  export { DevFormField, DevIdKind, DevPlatform, DevPlatformOptions, DevPlatformSeed, createDevPlatform };