@macro-inc/sdk 0.0.1 → 0.2.2

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 (165) hide show
  1. package/README.md +628 -21
  2. package/dist/{chunk-5HAKQN23.js → chunk-7LVVPVNT.js} +70 -57
  3. package/dist/{chunk-JXIQT5TH.js → chunk-7YJ6Y7HJ.js} +234 -16
  4. package/dist/chunk-LMJW65ML.js +836 -0
  5. package/dist/{chunk-SGAHIERJ.js → chunk-OGE7WXJE.js} +16 -0
  6. package/dist/chunk-PRUFPW3B.js +943 -0
  7. package/dist/{chunk-CTKR64MY.js → chunk-QVBNNMQS.js} +242 -367
  8. package/dist/{chunk-QNUS5BC5.js → chunk-SUINKDXF.js} +30 -84
  9. package/dist/{chunk-77EI4LSQ.js → chunk-ZQXOHNDB.js} +1518 -386
  10. package/dist/generated/agent-harness/index.d.ts +1 -1
  11. package/dist/generated/agent-harness/index.js +1 -1
  12. package/dist/generated/agent-harness/sdk.gen.d.ts +174 -4
  13. package/dist/generated/agent-harness/types.gen.d.ts +2511 -189
  14. package/dist/generated/auth/index.d.ts +1 -1
  15. package/dist/generated/auth/index.js +1 -1
  16. package/dist/generated/auth/sdk.gen.d.ts +106 -8
  17. package/dist/generated/auth/types.gen.d.ts +1473 -116
  18. package/dist/generated/calendar/client/client.gen.d.ts +2 -0
  19. package/dist/generated/calendar/client/index.d.ts +10 -0
  20. package/dist/generated/calendar/client/types.gen.d.ts +120 -0
  21. package/dist/generated/calendar/client/utils.gen.d.ts +37 -0
  22. package/dist/generated/calendar/client.gen.d.ts +12 -0
  23. package/dist/generated/calendar/core/auth.gen.d.ts +25 -0
  24. package/dist/generated/calendar/core/bodySerializer.gen.d.ts +25 -0
  25. package/dist/generated/calendar/core/params.gen.d.ts +43 -0
  26. package/dist/generated/calendar/core/pathSerializer.gen.d.ts +33 -0
  27. package/dist/generated/calendar/core/queryKeySerializer.gen.d.ts +18 -0
  28. package/dist/generated/calendar/core/serverSentEvents.gen.d.ts +71 -0
  29. package/dist/generated/calendar/core/types.gen.d.ts +83 -0
  30. package/dist/generated/calendar/core/utils.gen.d.ts +19 -0
  31. package/dist/generated/calendar/index.d.ts +2 -0
  32. package/dist/generated/calendar/index.js +6 -0
  33. package/dist/generated/calendar/sdk.gen.d.ts +95 -0
  34. package/dist/generated/calendar/types.gen.d.ts +1091 -0
  35. package/dist/generated/cognition/index.d.ts +1 -1
  36. package/dist/generated/cognition/index.js +1 -1
  37. package/dist/generated/cognition/sdk.gen.d.ts +6 -1
  38. package/dist/generated/cognition/types.gen.d.ts +304 -36
  39. package/dist/generated/connection/types.gen.d.ts +1 -1
  40. package/dist/generated/email/index.d.ts +1 -1
  41. package/dist/generated/email/index.js +1 -1
  42. package/dist/generated/email/sdk.gen.d.ts +32 -27
  43. package/dist/generated/email/types.gen.d.ts +586 -409
  44. package/dist/generated/notification/index.d.ts +1 -1
  45. package/dist/generated/notification/types.gen.d.ts +384 -19
  46. package/dist/generated/properties/types.gen.d.ts +8 -5
  47. package/dist/generated/scheduled-action/index.d.ts +1 -1
  48. package/dist/generated/scheduled-action/index.js +3 -842
  49. package/dist/generated/scheduled-action/sdk.gen.d.ts +3 -1
  50. package/dist/generated/scheduled-action/types.gen.d.ts +277 -41
  51. package/dist/generated/search/index.d.ts +1 -1
  52. package/dist/generated/search/types.gen.d.ts +262 -43
  53. package/dist/generated/storage/index.d.ts +1 -1
  54. package/dist/generated/storage/index.js +1 -1
  55. package/dist/generated/storage/sdk.gen.d.ts +678 -107
  56. package/dist/generated/storage/types.gen.d.ts +14827 -5995
  57. package/dist/generated/unfurl/index.d.ts +1 -1
  58. package/dist/generated/unfurl/index.js +3 -832
  59. package/dist/generated/unfurl/types.gen.d.ts +20 -0
  60. package/dist/src/config.d.ts +33 -13
  61. package/dist/src/entities/agent-sessions/agent-session.d.ts +150 -6
  62. package/dist/src/entities/agent-sessions/code-execution.d.ts +43 -0
  63. package/dist/src/entities/agent-sessions/conversation.d.ts +54 -0
  64. package/dist/src/entities/agent-sessions/namespace.d.ts +23 -5
  65. package/dist/src/entities/agent-sessions/queued-action.d.ts +46 -0
  66. package/dist/src/entities/agent-sessions/review.d.ts +107 -0
  67. package/dist/src/entities/agent-sessions/tool-approval.d.ts +21 -0
  68. package/dist/src/entities/agents/agent.d.ts +47 -0
  69. package/dist/src/entities/agents/namespace.d.ts +13 -0
  70. package/dist/src/entities/ai/namespace.d.ts +24 -0
  71. package/dist/src/entities/api-keys/api-key.d.ts +17 -0
  72. package/dist/src/entities/api-keys/namespace.d.ts +18 -0
  73. package/dist/src/entities/calendar/calendar.d.ts +35 -0
  74. package/dist/src/entities/calendar/event.d.ts +123 -0
  75. package/dist/src/entities/calendar/event.test.d.ts +1 -0
  76. package/dist/src/entities/calendar/namespace.d.ts +111 -0
  77. package/dist/src/entities/calendar/replacement.d.ts +15 -0
  78. package/dist/src/entities/calls/call-record.d.ts +62 -6
  79. package/dist/src/entities/calls/message.d.ts +33 -0
  80. package/dist/src/entities/channels/activity.d.ts +24 -0
  81. package/dist/src/entities/channels/channel.d.ts +44 -3
  82. package/dist/src/entities/channels/labels.d.ts +39 -0
  83. package/dist/src/entities/channels/message.d.ts +9 -17
  84. package/dist/src/entities/channels/namespace.d.ts +6 -0
  85. package/dist/src/entities/channels/picture.d.ts +11 -0
  86. package/dist/src/entities/channels/post.d.ts +1 -1
  87. package/dist/src/entities/channels/thread.d.ts +5 -0
  88. package/dist/src/entities/chats/chat.d.ts +11 -1
  89. package/dist/src/entities/chats/generation.d.ts +46 -0
  90. package/dist/src/entities/crm/comment.d.ts +55 -34
  91. package/dist/src/entities/crm/company.d.ts +42 -10
  92. package/dist/src/entities/crm/contact.d.ts +42 -10
  93. package/dist/src/entities/crm/namespace.d.ts +18 -1
  94. package/dist/src/entities/crm/pipeline.d.ts +122 -0
  95. package/dist/src/entities/crm/pipelines.d.ts +14 -0
  96. package/dist/src/entities/databases/column.d.ts +75 -0
  97. package/dist/src/entities/databases/database.d.ts +272 -0
  98. package/dist/src/entities/databases/namespace.d.ts +21 -0
  99. package/dist/src/entities/databases/query.d.ts +86 -0
  100. package/dist/src/entities/databases/row.d.ts +27 -0
  101. package/dist/src/entities/databases/table.d.ts +61 -0
  102. package/dist/src/entities/databases/view.d.ts +40 -0
  103. package/dist/src/entities/databases/webhook.d.ts +32 -0
  104. package/dist/src/entities/documents/anchor.d.ts +29 -0
  105. package/dist/src/entities/documents/comment.d.ts +25 -22
  106. package/dist/src/entities/documents/document.d.ts +60 -12
  107. package/dist/src/entities/documents/namespace.d.ts +30 -0
  108. package/dist/src/entities/documents/version.d.ts +22 -0
  109. package/dist/src/entities/email/draft.d.ts +79 -0
  110. package/dist/src/entities/email/filter.d.ts +34 -0
  111. package/dist/src/entities/email/link.d.ts +6 -4
  112. package/dist/src/entities/email/message.d.ts +12 -1
  113. package/dist/src/entities/email/namespace.d.ts +34 -1
  114. package/dist/src/entities/email/thread.d.ts +23 -1
  115. package/dist/src/entities/entity-mentions/mention.d.ts +16 -0
  116. package/dist/src/entities/entity-mentions/namespace.d.ts +12 -0
  117. package/dist/src/entities/entity.d.ts +7 -0
  118. package/dist/src/entities/favorites/namespace.d.ts +14 -2
  119. package/dist/src/entities/foreign/foreign-entity.d.ts +2 -0
  120. package/dist/src/entities/foreign/namespace.d.ts +40 -0
  121. package/dist/src/entities/forms/form.d.ts +227 -0
  122. package/dist/src/entities/forms/namespace.d.ts +18 -0
  123. package/dist/src/entities/forms/question.d.ts +37 -0
  124. package/dist/src/entities/forms/response.d.ts +32 -0
  125. package/dist/src/entities/forms/section.d.ts +19 -0
  126. package/dist/src/entities/github-pull-requests/namespace.d.ts +12 -0
  127. package/dist/src/entities/github-pull-requests/pull-request.d.ts +52 -0
  128. package/dist/src/entities/harnesses/harness.d.ts +19 -0
  129. package/dist/src/entities/harnesses/namespace.d.ts +33 -0
  130. package/dist/src/entities/harnesses/pairing.d.ts +39 -0
  131. package/dist/src/entities/initiatives/initiative.d.ts +50 -0
  132. package/dist/src/entities/initiatives/namespace.d.ts +13 -0
  133. package/dist/src/entities/meetings/meeting.d.ts +38 -0
  134. package/dist/src/entities/meetings/namespace.d.ts +18 -0
  135. package/dist/src/entities/messages/thread.d.ts +101 -0
  136. package/dist/src/entities/notifications/notification.d.ts +6 -3
  137. package/dist/src/entities/notifications/notification.test.d.ts +1 -0
  138. package/dist/src/entities/projects/project.d.ts +7 -0
  139. package/dist/src/entities/reference.d.ts +82 -0
  140. package/dist/src/entities/routines/namespace.d.ts +15 -0
  141. package/dist/src/entities/routines/routine.d.ts +115 -0
  142. package/dist/src/entities/sharing/access.d.ts +65 -0
  143. package/dist/src/entities/sharing/permissions.d.ts +13 -0
  144. package/dist/src/entities/tasks/namespace.d.ts +4 -0
  145. package/dist/src/entities/tasks/task.d.ts +6 -0
  146. package/dist/src/entities/unfurls/namespace.d.ts +10 -0
  147. package/dist/src/entities/webhooks/webhook.d.ts +3 -1
  148. package/dist/src/entities/workspace/items.d.ts +7 -0
  149. package/dist/src/entities/workspace/namespace.d.ts +83 -0
  150. package/dist/src/entities/workspace/query.d.ts +12 -0
  151. package/dist/src/entities/workspace/types.d.ts +96 -0
  152. package/dist/src/events/hydrate/agentSession.d.ts +192 -0
  153. package/dist/src/events/hydrate/channel.d.ts +2 -39
  154. package/dist/src/events/hydrate/message.d.ts +70 -0
  155. package/dist/src/events/receiver.d.ts +57 -19
  156. package/dist/src/events/types.d.ts +3 -1
  157. package/dist/src/macro.d.ts +80 -3
  158. package/dist/src/macro.js +8832 -2784
  159. package/dist/src/utils/activity.d.ts +11 -0
  160. package/dist/src/utils/activity.test.d.ts +1 -0
  161. package/dist/src/utils/client.d.ts +10 -1
  162. package/dist/src/utils/concurrency.d.ts +5 -0
  163. package/dist/src/utils/index.d.ts +1 -0
  164. package/dist/src/utils/pagination.d.ts +9 -4
  165. package/package.json +11 -3
@@ -0,0 +1,39 @@
1
+ import type { ChannelLabel, ChannelLabelRule, SmartTagPreview } from '../../../generated/storage/types.gen';
2
+ import type { MacroClient } from '../../utils/client';
3
+ import type { Channel } from './channel';
4
+ export type { ChannelLabel, ChannelLabelRule, SmartTagPreview };
5
+ /**
6
+ * Shared or private channel labels: named groups of channels shown in the Chat
7
+ * sidebar. Every member of the team sees the same labels in the same order,
8
+ * and any member may create, rename, delete, or move channels between them;
9
+ * each change applies to the whole team. Users without a team have private
10
+ * labels belonging to their account.
11
+ *
12
+ * A label's `channelIds` lists only the channels the authenticated user is a
13
+ * member of. Manual labels count all assignments; smart tags count visible
14
+ * matches. A channel can be in one manual label and any number of matching
15
+ * smart tags per team or account. Direct messages cannot be grouped.
16
+ */
17
+ export declare class ChannelLabelsNamespace {
18
+ private readonly client;
19
+ constructor(client: MacroClient);
20
+ /** Every label in the authenticated user's shared or private scope. */
21
+ list(): Promise<ChannelLabel[]>;
22
+ /**
23
+ * Create a label and atomically move `channels` into it. Names are unique
24
+ * within the team or account, case-insensitively.
25
+ */
26
+ create(name: string, channels?: Channel[]): Promise<ChannelLabel>;
27
+ /** Create a smart tag whose membership follows an attribute rule automatically. */
28
+ createSmartTag(name: string, rule: ChannelLabelRule): Promise<ChannelLabel>;
29
+ /** Preview the first matches and total visible count without creating a tag. */
30
+ previewSmartTag(rule: ChannelLabelRule): Promise<SmartTagPreview>;
31
+ /** Update the name and matching rule of an existing smart tag. */
32
+ updateSmartTag(label: ChannelLabel, name: string, rule: ChannelLabelRule): Promise<ChannelLabel>;
33
+ /** Rename a label for the whole team. */
34
+ rename(label: ChannelLabel, name: string): Promise<ChannelLabel>;
35
+ /** Delete a label for the whole team; its channels return to the plain list. */
36
+ delete(label: ChannelLabel): Promise<void>;
37
+ /** Move a channel into `label`, or out of any label when `label` is `undefined`. */
38
+ setLabel(channel: Channel, label: ChannelLabel | undefined): Promise<void>;
39
+ }
@@ -1,37 +1,30 @@
1
- import type { GetChannelMessagesResponses, GetMessageWithContextResponses, GetThreadRepliesResponses } from '../../../generated/storage/types.gen';
1
+ import type { Message as MessageRecord } from '../../../generated/storage/types.gen';
2
2
  import { type RichMessage, type SimpleMention } from '../../mentions';
3
3
  import type { MacroClient } from '../../utils/client';
4
4
  import { FavoritableEntity } from '../entity';
5
5
  import { User } from '../users/user';
6
6
  import { Channel } from './channel';
7
7
  import { Thread } from './thread';
8
- type ChannelMessage = GetChannelMessagesResponses[200]['items'][number];
9
- type ThreadReply = GetThreadRepliesResponses[200][number];
10
- type ContextMessage = GetMessageWithContextResponses[200]['messages'][number];
11
- /** The API's representation of a channel message, in any of the forms it's returned. */
12
- export type MessageData = ChannelMessage | ThreadReply | ContextMessage;
8
+ /** The API's representation of a message; the same record the document comment API returns. */
9
+ export type MessageData = MessageRecord;
13
10
  /**
14
11
  * A message in a channel. A thin handle: `id` and `channelId` are known up
15
12
  * front, and record-backed fields (`content`, `author`) load lazily on first
16
13
  * access and cache. Actions carry the ids for you.
17
14
  */
18
- export declare class Message extends FavoritableEntity<MessageData> {
15
+ export declare class Message extends FavoritableEntity<MessageRecord> {
19
16
  readonly channelId: string;
20
- /** Entities mentioned in this message. Populated for event-delivered
21
- * messages; empty otherwise, since the REST API doesn't return mentions inline. */
17
+ /** Entities mentioned in this message, when a list, thread, or event supplied them. */
22
18
  readonly mentions: SimpleMention[];
23
19
  /** Favorites identify channel messages as `channel_message`. */
24
20
  readonly entityType = "channel_message";
25
21
  private constructor();
26
- protected fetch(): Promise<MessageData>;
22
+ private get path();
23
+ protected fetch(): Promise<MessageRecord>;
27
24
  /** A handle to a message by id. Fields load on first access. */
28
25
  static byId(client: MacroClient, channelId: string, id: string, mentions?: SimpleMention[]): Message;
29
- /** Build a message from a list-endpoint record (pre-seeded, no fetch). */
30
- static from(client: MacroClient, data: ChannelMessage, mentions?: SimpleMention[]): Message;
31
- /** Build a message from a thread-reply record (pre-seeded, no fetch). */
32
- static fromReply(client: MacroClient, channelId: string, reply: ThreadReply, mentions?: SimpleMention[]): Message;
33
- /** Build a message from a webhook event record (pre-seeded, no fetch). */
34
- static received(client: MacroClient, channelId: string, data: MessageData, mentions?: SimpleMention[]): Message;
26
+ /** Build a root or reply from a message record (pre-seeded, no fetch). */
27
+ static from(client: MacroClient, channelId: string, data: MessageRecord): Message;
35
28
  /** The message body. */
36
29
  readonly content: () => Promise<string>;
37
30
  /** When the message was created. */
@@ -61,4 +54,3 @@ export declare class Message extends FavoritableEntity<MessageData> {
61
54
  /** Post a reply in this message's thread. */
62
55
  reply(body: string | RichMessage): Promise<Message>;
63
56
  }
64
- export {};
@@ -3,9 +3,15 @@ import type { MacroClient } from '../../utils/client';
3
3
  import type { SearchOpts } from '../search';
4
4
  import type { Team } from '../teams/team';
5
5
  import type { User } from '../users/user';
6
+ import { ChannelActivity } from './activity';
6
7
  import { Channel } from './channel';
8
+ import { ChannelLabelsNamespace } from './labels';
7
9
  export declare class ChannelNamespace {
8
10
  private readonly client;
11
+ /** Recent channel activity, with channel and user handles. */
12
+ activity(): Promise<ChannelActivity[]>;
13
+ /** Team-shared labels that group channels in the Chat sidebar. */
14
+ readonly labels: ChannelLabelsNamespace;
9
15
  constructor(client: MacroClient);
10
16
  byId(id: string): Channel;
11
17
  dm(recipient: User): Promise<Channel>;
@@ -0,0 +1,11 @@
1
+ /** An uploaded channel profile picture in static file storage. */
2
+ export declare class ChannelPicture {
3
+ readonly id: string;
4
+ private constructor();
5
+ /** Construct a reference from the upload receipt. */
6
+ static byId(id: string): ChannelPicture;
7
+ /** Serialize the uploaded picture reference. */
8
+ toJSON(): {
9
+ id: string;
10
+ };
11
+ }
@@ -5,7 +5,7 @@ import type { Thread } from './thread';
5
5
  /**
6
6
  * Post a message using the endpoint supported by the caller's credentials.
7
7
  *
8
- * Most credentials use `POST /channels/{id}/message`. User-owned bots without
8
+ * Most credentials use `POST /messages/channel/{id}`. User-owned bots without
9
9
  * an acting user instead use `POST /channels/{id}/webhook`, which authorizes
10
10
  * through channel membership. The bot owner is read from `GET /bots/me` and
11
11
  * cached by the client.
@@ -14,6 +14,11 @@ export declare class Thread {
14
14
  constructor(client: MacroClient, channelId: string,
15
15
  /** The id of the message this thread hangs off. */
16
16
  rootId: string);
17
+ /** Serialize the thread identity without its authenticated client. */
18
+ toJSON(): {
19
+ channelId: string;
20
+ rootId: string;
21
+ };
17
22
  /** The channel this thread is in. */
18
23
  channel(): Channel;
19
24
  /** The message this thread hangs off. */
@@ -1,12 +1,22 @@
1
- import type { GetChatHistoryHandlerResponses, GetChatResponses } from '../../../generated/cognition/types.gen';
1
+ import type { GetChatHistoryHandlerResponses, GetChatResponses, HttpSendChatMessageRequest } from '../../../generated/cognition/types.gen';
2
2
  import { type Mentionable, type MentionPart } from '../../mentions';
3
3
  import type { MacroClient } from '../../utils/client';
4
4
  import { PropertiedEntity } from '../entity';
5
5
  import { Project } from '../projects/project';
6
+ import type { EntityReference } from '../reference';
7
+ import { EntityAccess } from '../sharing/access';
8
+ import { ChatGeneration } from './generation';
6
9
  type ChatDetail = GetChatResponses[200]['chat'];
7
10
  type ChatHistory = GetChatHistoryHandlerResponses[200]['conversation'];
8
11
  /** A Macro AI chat. */
9
12
  export declare class Chat extends PropertiedEntity<ChatDetail> implements Mentionable {
13
+ /** Send a message and start a background generation. Tools may perform writes. */
14
+ send(options: Omit<HttpSendChatMessageRequest, 'chat_id' | 'attachments' | 'additional_instructions'> & {
15
+ attachments?: EntityReference[];
16
+ additionalInstructions?: string;
17
+ }): Promise<ChatGeneration>;
18
+ /** Access requests and direct user grants. */
19
+ readonly access: EntityAccess;
10
20
  /** Favorites identify chats as `chat`. */
11
21
  readonly entityType = "chat";
12
22
  /** The properties service identifies chats as `CHAT`. */
@@ -0,0 +1,46 @@
1
+ import type { ChatMessageWithAttachments } from '../../../generated/cognition/types.gen';
2
+ import type { MacroClient } from '../../utils/client';
3
+ import { MacroEntity } from '../entity';
4
+ import type { Chat } from './chat';
5
+ /** A background chat generation. The stream belongs to exactly one chat. */
6
+ export declare class ChatGeneration {
7
+ private readonly client;
8
+ /** Parent chat. */
9
+ readonly chat: Chat;
10
+ /** Stream identity. */
11
+ readonly id: string;
12
+ /** AI response message for this generation. */
13
+ readonly message: ChatMessage;
14
+ private constructor();
15
+ /** Construct from a send receipt. */
16
+ static byId(client: MacroClient, chat: Chat, id: string, message: ChatMessage): ChatGeneration;
17
+ /** Request cancellation of this generation. */
18
+ stop(): Promise<void>;
19
+ /** Serialize scoped identity. */
20
+ toJSON(): {
21
+ id: string;
22
+ chatId: string;
23
+ messageId: string;
24
+ };
25
+ }
26
+ /** A message scoped to an AI chat. */
27
+ export declare class ChatMessage extends MacroEntity<ChatMessageWithAttachments> {
28
+ /** Parent chat. */
29
+ readonly chat: Chat;
30
+ private constructor();
31
+ /** Construct a chat message handle. */
32
+ static byId(client: MacroClient, chat: Chat, id: string): ChatMessage;
33
+ protected fetch(): Promise<ChatMessageWithAttachments>;
34
+ /** The message's generated content. */
35
+ readonly content: () => Promise<import("../../../generated/cognition").ChatMessageContent>;
36
+ /** Role of the message author. */
37
+ readonly role: () => Promise<import("../../../generated/cognition").Role>;
38
+ /** Reload after a running generation changes or finishes. */
39
+ refresh(): Promise<void>;
40
+ /** Serialize scoped identity and any loaded message. */
41
+ toJSON(): {
42
+ chatId: string;
43
+ id: string;
44
+ detail?: ChatMessageWithAttachments | undefined;
45
+ };
46
+ }
@@ -1,43 +1,64 @@
1
- import type { CrmComment as CrmCommentRecord, CrmThread, DeleteCrmCommentResult } from '../../../generated/storage/types.gen';
1
+ import type { Message as MessageRecord, ThreadState } from '../../../generated/storage/types.gen';
2
+ import { type RichMessage } from '../../mentions';
2
3
  import type { MacroClient } from '../../utils/client';
3
- /** A CRM comment thread with its comments, as returned for a company or contact. */
4
- export interface CrmThreadWithComments {
5
- /** The thread. */
6
- thread: CrmThread;
7
- /** The thread's comments, oldest first. */
4
+ import { MacroEntity } from '../entity';
5
+ import { User } from '../users/user';
6
+ /** The CRM record a discussion hangs off. */
7
+ export interface CrmCommentParent {
8
+ type: 'crm_company' | 'crm_contact';
9
+ id: string;
10
+ }
11
+ /** One of a CRM record's comment threads: its state and its comments. */
12
+ export interface CrmCommentThread {
13
+ /** The thread state: root id, resolved flag, owner, timestamps. */
14
+ thread: ThreadState;
15
+ /** The thread's comments, root first, then replies oldest first. */
8
16
  comments: CrmComment[];
9
17
  }
10
18
  /**
11
- * A comment on a CRM company or contact. Shared by both entity types, since
12
- * the underlying API and record shape are already unified across them.
19
+ * A comment on a CRM company or contact: a message whose parent is the
20
+ * record, addressed by the record and the message UUID. Its record and
21
+ * mutations are the ones document comments and channel messages use.
13
22
  */
14
- export declare class CrmComment {
15
- private readonly client;
16
- readonly id: string;
17
- private record;
23
+ export declare class CrmComment extends MacroEntity<MessageRecord> {
24
+ /** The company or contact this comment belongs to. */
25
+ readonly parent: CrmCommentParent;
18
26
  private constructor();
19
- /** Wrap a record already in hand (e.g. from a list or create response). */
20
- static from(client: MacroClient, record: CrmCommentRecord): CrmComment;
21
- /** The comment body (markdown). */
22
- get text(): string;
23
- /** The id of the thread this comment belongs to. */
24
- get threadId(): string;
25
- /** Macro user id of the comment author. */
26
- get owner(): string;
27
- /** Macro user id of the actual sender, when distinct from {@link owner}. */
28
- get sender(): string | undefined;
29
- /** Explicit ordering within the thread, if set. */
30
- get order(): number | undefined;
31
- /** Arbitrary client metadata attached to the comment. */
32
- get metadata(): unknown;
27
+ private get path();
28
+ protected fetch(): Promise<MessageRecord>;
29
+ /** A handle to a comment by id. Fields load on first access. */
30
+ static byId(client: MacroClient, parent: CrmCommentParent, id: string): CrmComment;
31
+ /** Build a comment from a message record (pre-seeded, no fetch). */
32
+ static from(client: MacroClient, parent: CrmCommentParent, record: MessageRecord): CrmComment;
33
+ /** The comment's text (markdown). */
34
+ readonly text: () => Promise<string>;
33
35
  /** When the comment was created. */
34
- get createdAt(): string;
36
+ readonly createdAt: () => Promise<string>;
35
37
  /** When the comment was last updated. */
36
- get updatedAt(): string;
37
- /** When the comment was soft-deleted, if ever. */
38
- get deletedAt(): string | undefined;
39
- /** Replace this comment's text (markdown). */
40
- edit(text: string): Promise<this>;
41
- /** Soft-delete this comment; the thread goes too when it was the last live one. */
42
- delete(): Promise<DeleteCrmCommentResult>;
38
+ readonly updatedAt: () => Promise<string>;
39
+ /** When the comment was deleted, if it has been. */
40
+ readonly deletedAt: () => Promise<string | undefined>;
41
+ /** The id of the thread this comment belongs to: its root, or itself for a root. */
42
+ threadId(): Promise<string>;
43
+ /** The user who wrote this comment. */
44
+ author(): Promise<User>;
45
+ /** Reply in this comment's thread. */
46
+ reply(body: string | RichMessage): Promise<CrmComment>;
47
+ /**
48
+ * Replace the comment's text. Only its author may.
49
+ *
50
+ * @param body - Plain text, or a rich body composed with {@link msg}.
51
+ */
52
+ edit(body: string | RichMessage): Promise<this>;
53
+ /** Delete this comment. Deleting a thread's root keeps its replies. */
54
+ delete(): Promise<void>;
43
55
  }
56
+ /** A CRM record's live comment threads, each with its comments, newest thread first. */
57
+ export declare function listCrmCommentThreads(client: MacroClient, parent: CrmCommentParent): Promise<CrmCommentThread[]>;
58
+ /**
59
+ * Post a comment on a CRM record: a new thread, or a reply when `threadId`
60
+ * (the thread's root comment id) is given.
61
+ */
62
+ export declare function postCrmComment(client: MacroClient, parent: CrmCommentParent, body: string | RichMessage, opts?: {
63
+ threadId?: string;
64
+ }): Promise<CrmComment>;
@@ -1,12 +1,37 @@
1
- import type { CreateCrmCommentRequest, DeleteCrmCommentResult, GetCompanyResponses } from '../../../generated/storage/types.gen';
1
+ import type { GetCompanyResponses } from '../../../generated/storage/types.gen';
2
+ import type { RichMessage } from '../../mentions';
2
3
  import type { MacroClient } from '../../utils/client';
3
4
  import { PropertiedEntity } from '../entity';
5
+ import { MessageThread, type TimelineOptions } from '../messages/thread';
4
6
  import { Team } from '../teams/team';
5
- import { CrmComment, type CrmThreadWithComments } from './comment';
7
+ import { CrmComment, type CrmCommentThread } from './comment';
6
8
  import { Contact } from './contact';
7
9
  type CompanyDetail = GetCompanyResponses[200];
8
10
  /** A CRM company: an organization the team has interacted with. */
9
11
  export declare class Company extends PropertiedEntity<CompanyDetail> {
12
+ /** A shared message thread scoped to this resource. */
13
+ messageThreadById(id: string): MessageThread;
14
+ /** A mixed message and activity timeline page. */
15
+ timelinePage(selection?: TimelineOptions<CrmComment>): Promise<{
16
+ entries: ({
17
+ type: "activity";
18
+ activity: {
19
+ actor: import("../users/user").User;
20
+ action: string;
21
+ actor_id: string;
22
+ id: string;
23
+ occurred_at: string;
24
+ payload?: unknown;
25
+ };
26
+ message?: undefined;
27
+ } | {
28
+ type: "message";
29
+ message: CrmComment;
30
+ activity?: undefined;
31
+ })[];
32
+ nextCursor: import("../../../generated/storage").MessageCursor | undefined;
33
+ previousCursor: import("../../../generated/storage").MessageCursor | undefined;
34
+ }>;
10
35
  /** Favorites identify CRM companies as `crm_company`. */
11
36
  readonly entityType = "crm_company";
12
37
  /** The properties service identifies CRM companies as `COMPANY`. */
@@ -58,13 +83,20 @@ export declare class Company extends PropertiedEntity<CompanyDetail> {
58
83
  email: string;
59
84
  name: string;
60
85
  }): Promise<Contact>;
61
- /** The comment threads attached to this company, with comments oldest first. */
62
- comments(): Promise<CrmThreadWithComments[]>;
63
- /** Add a comment: starts a new thread unless `body.threadId` targets an existing one. */
64
- comment(body: CreateCrmCommentRequest): Promise<CrmComment>;
65
- /** Replace a comment's text (markdown). */
66
- editComment(comment: CrmComment, text: string): Promise<CrmComment>;
67
- /** Soft-delete a comment; the thread goes too when it was the last live one. */
68
- deleteComment(comment: CrmComment): Promise<DeleteCrmCommentResult>;
86
+ /** The CRM record this company's discussions hang off. */
87
+ private get commentParent();
88
+ /** The comment threads on this company, newest thread first. */
89
+ comments(): Promise<CrmCommentThread[]>;
90
+ /**
91
+ * Add a comment. Starts a new thread, or replies to an existing one when
92
+ * `threadId` (the thread's root comment id) is given.
93
+ *
94
+ * @param body - Plain text, or a rich body composed with {@link msg}.
95
+ */
96
+ comment(body: string | RichMessage, opts?: {
97
+ threadId?: string;
98
+ }): Promise<CrmComment>;
99
+ /** A handle to one of this company's comments by id. */
100
+ commentById(id: string): CrmComment;
69
101
  }
70
102
  export {};
@@ -1,11 +1,36 @@
1
- import type { CreateCrmCommentRequest, DeleteCrmCommentResult, GetContactResponses } from '../../../generated/storage/types.gen';
1
+ import type { GetContactResponses } from '../../../generated/storage/types.gen';
2
+ import type { RichMessage } from '../../mentions';
2
3
  import type { MacroClient } from '../../utils/client';
3
4
  import { FavoritableEntity } from '../entity';
4
- import { CrmComment, type CrmThreadWithComments } from './comment';
5
+ import { MessageThread, type TimelineOptions } from '../messages/thread';
6
+ import { CrmComment, type CrmCommentThread } from './comment';
5
7
  import { Company } from './company';
6
8
  type ContactDetail = GetContactResponses[200];
7
9
  /** A CRM contact: a person observed interacting with the team. */
8
10
  export declare class Contact extends FavoritableEntity<ContactDetail> {
11
+ /** A shared message thread scoped to this resource. */
12
+ messageThreadById(id: string): MessageThread;
13
+ /** A mixed message and activity timeline page. */
14
+ timelinePage(selection?: TimelineOptions<CrmComment>): Promise<{
15
+ entries: ({
16
+ type: "activity";
17
+ activity: {
18
+ actor: import("../users/user").User;
19
+ action: string;
20
+ actor_id: string;
21
+ id: string;
22
+ occurred_at: string;
23
+ payload?: unknown;
24
+ };
25
+ message?: undefined;
26
+ } | {
27
+ type: "message";
28
+ message: CrmComment;
29
+ activity?: undefined;
30
+ })[];
31
+ nextCursor: import("../../../generated/storage").MessageCursor | undefined;
32
+ previousCursor: import("../../../generated/storage").MessageCursor | undefined;
33
+ }>;
9
34
  /** Favorites identify CRM contacts as `crm_contact`. */
10
35
  readonly entityType = "crm_contact";
11
36
  protected fetch(): Promise<ContactDetail>;
@@ -36,13 +61,20 @@ export declare class Contact extends FavoritableEntity<ContactDetail> {
36
61
  private setHidden;
37
62
  /** Rename the contact for the caller's current team. */
38
63
  rename(name: string): Promise<void>;
39
- /** The comment threads attached to this contact, with comments oldest first. */
40
- comments(): Promise<CrmThreadWithComments[]>;
41
- /** Add a comment: starts a new thread unless `body.threadId` targets an existing one. */
42
- comment(body: CreateCrmCommentRequest): Promise<CrmComment>;
43
- /** Replace a comment's text (markdown). */
44
- editComment(comment: CrmComment, text: string): Promise<CrmComment>;
45
- /** Soft-delete a comment; the thread goes too when it was the last live one. */
46
- deleteComment(comment: CrmComment): Promise<DeleteCrmCommentResult>;
64
+ /** The CRM record this contact's discussions hang off. */
65
+ private get commentParent();
66
+ /** The comment threads on this contact, newest thread first. */
67
+ comments(): Promise<CrmCommentThread[]>;
68
+ /**
69
+ * Add a comment. Starts a new thread, or replies to an existing one when
70
+ * `threadId` (the thread's root comment id) is given.
71
+ *
72
+ * @param body - Plain text, or a rich body composed with {@link msg}.
73
+ */
74
+ comment(body: string | RichMessage, opts?: {
75
+ threadId?: string;
76
+ }): Promise<CrmComment>;
77
+ /** A handle to one of this contact's comments by id. */
78
+ commentById(id: string): CrmComment;
47
79
  }
48
80
  export {};
@@ -1,9 +1,12 @@
1
- import type { CreateCrmCompanyRequest, CrmTeamSettingsResponse, UpdateCrmTeamSettingsRequest } from '../../../generated/storage/types.gen';
1
+ import type { CreateCrmCompanyRequest, CrmStagesResponse, CrmTeamSettingsResponse, ReplaceCrmStagesRequest, UpdateCrmTeamSettingsRequest } from '../../../generated/storage/types.gen';
2
2
  import type { MacroClient } from '../../utils/client';
3
3
  import { Company } from './company';
4
4
  import { Contact } from './contact';
5
+ import { PipelineNamespace } from './pipelines';
5
6
  export declare class CrmNamespace {
6
7
  private readonly client;
8
+ /** Pipelines, their records and sharing settings. */
9
+ readonly pipelines: PipelineNamespace;
7
10
  constructor(client: MacroClient);
8
11
  /** A handle to a CRM company by id. */
9
12
  companyById(id: string): Company;
@@ -11,12 +14,26 @@ export declare class CrmNamespace {
11
14
  contactById(id: string): Contact;
12
15
  /** Resolve a CRM contact by email in the caller's current team, if present. */
13
16
  contactByEmail(email: string): Promise<Contact | undefined>;
17
+ /**
18
+ * Search the caller's current team's CRM contacts whose email or name
19
+ * contains `query` (case-insensitive), most recently interacted first.
20
+ * An empty query lists the most recent contacts.
21
+ *
22
+ * @param opts.limit Maximum contacts to return (1-500, default 20).
23
+ */
24
+ searchContacts(query: string, opts?: {
25
+ limit?: number;
26
+ }): Promise<Contact[]>;
14
27
  /** Create a CRM company for the caller's current team. */
15
28
  createCompany(opts: CreateCrmCompanyRequest): Promise<Company>;
16
29
  /** The caller's current team's CRM settings. */
17
30
  settings(): Promise<CrmTeamSettingsResponse>;
18
31
  /** Partially update the caller's current team's CRM settings. */
19
32
  updateSettings(settings: UpdateCrmTeamSettingsRequest): Promise<CrmTeamSettingsResponse>;
33
+ /** Replace the caller's current team's deal stages, in pipeline order. */
34
+ setStages(stages: ReplaceCrmStagesRequest): Promise<CrmStagesResponse>;
35
+ /** Reset the caller's current team's deal stages to the defaults. */
36
+ resetStages(): Promise<void>;
20
37
  /** Search CRM companies by name/domain, most relevant first, auto-paginated. */
21
38
  searchCompanies(query: string): AsyncGenerator<Company>;
22
39
  }
@@ -0,0 +1,122 @@
1
+ import type { AccessiblePipeline, ColumnDetail, CreatePipeline, DatabaseOp, StorageRow, StorageRowsQuery, TableDetail } from '../../../generated/storage/types.gen';
2
+ import type { MacroClient } from '../../utils/client';
3
+ import { MacroEntity } from '../entity';
4
+ import { type SharePermissionOptions } from '../sharing/permissions';
5
+ import { Team } from '../teams/team';
6
+ import { User } from '../users/user';
7
+ /** A CRM pipeline with its own sharing boundary and backing table. */
8
+ export declare class CrmPipeline extends MacroEntity<AccessiblePipeline> {
9
+ private readonly tableDetail;
10
+ /** Construct a lazy pipeline handle. */
11
+ static byId(client: MacroClient, id: string): CrmPipeline;
12
+ /** Seed from a server record. */
13
+ static from(client: MacroClient, record: AccessiblePipeline): CrmPipeline;
14
+ protected fetch(): Promise<AccessiblePipeline>;
15
+ /** Display name. */
16
+ readonly name: () => Promise<string>;
17
+ /** CRM record type. */
18
+ readonly recordType: () => Promise<import("../../../generated/storage").PipelineRecordType>;
19
+ /** Current caller's access level. */
20
+ readonly accessLevel: () => Promise<import("../../../generated/storage").AccessLevel>;
21
+ /** Sharing scope. */
22
+ readonly sharing: () => Promise<import("../../../generated/storage").PipelineSharing>;
23
+ /** Owner. */
24
+ readonly owner: () => Promise<User>;
25
+ /** Owning team. */
26
+ readonly team: () => Promise<Team>;
27
+ /** Rename this pipeline. */
28
+ rename(name: string): Promise<void>;
29
+ /** Change its sharing scope. */
30
+ setSharing(sharing: CreatePipeline['sharing']): Promise<void>;
31
+ /** Trash or restore the pipeline. */
32
+ setTrashed(trashed: boolean): Promise<void>;
33
+ /** Read sharing grants. */
34
+ sharePermissions(): Promise<import("../../../generated/storage").SharePermissionV2>;
35
+ /** Update sharing grants. */
36
+ updateSharePermissions(options: SharePermissionOptions): Promise<import("../../../generated/storage").SharePermissionV2>;
37
+ /** Read the backing table through the pipeline's authorization boundary. */
38
+ table(): Promise<PipelineTable>;
39
+ /** @internal Cached table snapshot shared by all pipeline table handles. */
40
+ tableRecord(): Promise<TableDetail>;
41
+ /** Rows in pipeline order, automatically paginated. */
42
+ rows(): AsyncGenerator<PipelineRow>;
43
+ /** Query pipeline rows, optionally restricting the query to typed row handles. */
44
+ queryRows(options?: {
45
+ query?: StorageRowsQuery['query'];
46
+ rows?: PipelineRow[];
47
+ }): AsyncGenerator<PipelineRow>;
48
+ /** Apply an atomic generated database operation batch through this pipeline.
49
+ * As with Database.applyOps, batch-local UUIDs may name resources minted earlier in the batch. */
50
+ applyOps(ops: DatabaseOp[], options?: {
51
+ baseVersions?: {
52
+ table: PipelineTable;
53
+ version: number;
54
+ }[];
55
+ }): Promise<import("../../../generated/storage").AppliedOps>;
56
+ }
57
+ /** Backing table of a CRM pipeline. */
58
+ export declare class PipelineTable extends MacroEntity<TableDetail> {
59
+ /** Parent pipeline. */
60
+ readonly pipeline: CrmPipeline;
61
+ /** Serialize identity within its pipeline. */
62
+ toJSON(): {
63
+ pipelineId: string;
64
+ id: string;
65
+ detail?: TableDetail | undefined;
66
+ };
67
+ private constructor();
68
+ /** Seed a table from a pipeline table response. */
69
+ static from(client: MacroClient, pipeline: CrmPipeline, record: TableDetail): PipelineTable;
70
+ protected fetch(): Promise<TableDetail>;
71
+ /** Columns in this table. */
72
+ columns(): Promise<PipelineColumn[]>;
73
+ /** Table version for optimistic operation batches. */
74
+ version(): Promise<number>;
75
+ /** A scoped row handle. */
76
+ rowById(id: string): PipelineRow;
77
+ /** Rows from the authorized pipeline surface. */
78
+ rows(): AsyncGenerator<PipelineRow>;
79
+ }
80
+ /** One pipeline row. */
81
+ export declare class PipelineRow extends MacroEntity<StorageRow> {
82
+ /** Parent pipeline. */
83
+ readonly pipeline: CrmPipeline;
84
+ /** Serialize identity within its pipeline. */
85
+ toJSON(): {
86
+ pipelineId: string;
87
+ id: string;
88
+ detail?: StorageRow | undefined;
89
+ };
90
+ private constructor();
91
+ /** Construct a scoped row handle. */
92
+ static byId(client: MacroClient, pipeline: CrmPipeline, id: string): PipelineRow;
93
+ /** Seed a listed row. */
94
+ static from(client: MacroClient, pipeline: CrmPipeline, record: StorageRow): PipelineRow;
95
+ protected fetch(): Promise<StorageRow>;
96
+ /** Values keyed by property definition. */
97
+ readonly cells: () => Promise<{
98
+ [key: string]: import("../../../generated/storage").PropertyValue;
99
+ }>;
100
+ /** Reload this row after an operation batch. */
101
+ refresh(): Promise<void>;
102
+ }
103
+ /** A column belonging to a pipeline table. */
104
+ export declare class PipelineColumn extends MacroEntity<ColumnDetail> {
105
+ /** Parent table. */
106
+ readonly table: PipelineTable;
107
+ /** Serialize identity within its pipeline. */
108
+ toJSON(): {
109
+ pipelineId: string;
110
+ tableId: string;
111
+ id: string;
112
+ detail?: ColumnDetail | undefined;
113
+ };
114
+ private constructor();
115
+ /** Seed a column handle. */
116
+ static from(client: MacroClient, table: PipelineTable, record: ColumnDetail): PipelineColumn;
117
+ protected fetch(): Promise<ColumnDetail>;
118
+ /** Whether the caller can write this column. */
119
+ writable(): Promise<boolean>;
120
+ /** Current column label. */
121
+ name(): Promise<string>;
122
+ }
@@ -0,0 +1,14 @@
1
+ import type { CreatePipeline } from '../../../generated/storage/types.gen';
2
+ import type { MacroClient } from '../../utils/client';
3
+ import { CrmPipeline } from './pipeline';
4
+ /** CRM pipelines in the caller's team. */
5
+ export declare class PipelineNamespace {
6
+ private readonly client;
7
+ constructor(client: MacroClient);
8
+ /** Construct a lazy pipeline handle. */
9
+ byId(id: string): CrmPipeline;
10
+ /** List accessible pipelines. */
11
+ list(): Promise<CrmPipeline[]>;
12
+ /** Create a pipeline and its backing storage. */
13
+ create(options: CreatePipeline): Promise<CrmPipeline>;
14
+ }