@macro-inc/sdk 0.4.1 → 0.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 (185) hide show
  1. package/README.md +169 -7
  2. package/dist/{chunk-PTX2RV2N.js → chunk-3SW6QVDV.js} +33 -0
  3. package/dist/{chunk-XFA7NCJ5.js → chunk-GT5EUYOR.js} +13 -15
  4. package/dist/{chunk-ZLBDES7U.js → chunk-HIW6KU2I.js} +490 -4
  5. package/dist/{chunk-AZJUIUIV.js → chunk-J2VK3NOR.js} +56 -0
  6. package/dist/{chunk-PZPTJI6F.js → chunk-UVJLWLSJ.js} +41 -2
  7. package/dist/generated/agent-fold/index.d.ts +8 -6
  8. package/dist/generated/agent-harness/index.d.ts +1 -1
  9. package/dist/generated/agent-harness/index.js +1 -1
  10. package/dist/generated/agent-harness/sdk.gen.d.ts +17 -1
  11. package/dist/generated/agent-harness/types.gen.d.ts +188 -3
  12. package/dist/generated/auth/index.js +1 -1
  13. package/dist/generated/auth/sdk.gen.d.ts +13 -15
  14. package/dist/generated/auth/types.gen.d.ts +36 -17
  15. package/dist/generated/cognition/index.d.ts +1 -1
  16. package/dist/generated/cognition/index.js +1 -1
  17. package/dist/generated/cognition/sdk.gen.d.ts +38 -1
  18. package/dist/generated/cognition/types.gen.d.ts +473 -4
  19. package/dist/generated/connection/types.gen.d.ts +1 -1
  20. package/dist/generated/notification/index.d.ts +1 -1
  21. package/dist/generated/notification/types.gen.d.ts +36 -1
  22. package/dist/generated/scheduled-action/index.d.ts +1 -1
  23. package/dist/generated/scheduled-action/index.js +1 -1
  24. package/dist/generated/scheduled-action/sdk.gen.d.ts +17 -2
  25. package/dist/generated/scheduled-action/types.gen.d.ts +642 -104
  26. package/dist/generated/storage/index.d.ts +1 -1
  27. package/dist/generated/storage/index.js +1 -1
  28. package/dist/generated/storage/sdk.gen.d.ts +204 -5
  29. package/dist/generated/storage/types.gen.d.ts +3969 -374
  30. package/dist/src/entities/account-managers/grant.d.ts +28 -5
  31. package/dist/src/entities/account-managers/namespace.d.ts +15 -3
  32. package/dist/src/entities/activity/entity.d.ts +7 -0
  33. package/dist/src/entities/activity/namespace.d.ts +58 -0
  34. package/dist/src/entities/activity/namespace.test.d.ts +1 -0
  35. package/dist/src/entities/agent-sessions/activity.d.ts +10 -2
  36. package/dist/src/entities/agent-sessions/agent-session.d.ts +193 -18
  37. package/dist/src/entities/agent-sessions/code-execution.d.ts +15 -3
  38. package/dist/src/entities/agent-sessions/conversation.d.ts +46 -9
  39. package/dist/src/entities/agent-sessions/namespace.d.ts +71 -16
  40. package/dist/src/entities/agent-sessions/origin.d.ts +1 -1
  41. package/dist/src/entities/agent-sessions/queued-action.d.ts +17 -3
  42. package/dist/src/entities/agent-sessions/review.d.ts +55 -4
  43. package/dist/src/entities/agent-sessions/tool-approval.d.ts +5 -1
  44. package/dist/src/entities/agents/agent.d.ts +98 -3
  45. package/dist/src/entities/agents/namespace.d.ts +52 -8
  46. package/dist/src/entities/ai/namespace.d.ts +9 -1
  47. package/dist/src/entities/api-keys/api-key.d.ts +6 -1
  48. package/dist/src/entities/api-keys/namespace.d.ts +15 -3
  49. package/dist/src/entities/bots/bot.d.ts +38 -6
  50. package/dist/src/entities/bots/namespace.d.ts +13 -1
  51. package/dist/src/entities/bots/token.d.ts +6 -1
  52. package/dist/src/entities/calendar/booking-link.d.ts +7 -1
  53. package/dist/src/entities/calendar/booking-namespace.d.ts +13 -0
  54. package/dist/src/entities/calendar/booking.d.ts +15 -0
  55. package/dist/src/entities/calendar/calendar.d.ts +7 -1
  56. package/dist/src/entities/calendar/event.d.ts +59 -9
  57. package/dist/src/entities/calendar/namespace.d.ts +88 -10
  58. package/dist/src/entities/calendar/replacement.d.ts +19 -3
  59. package/dist/src/entities/calls/call-record.d.ts +90 -14
  60. package/dist/src/entities/calls/connection.d.ts +7 -1
  61. package/dist/src/entities/calls/message.d.ts +27 -5
  62. package/dist/src/entities/calls/namespace.d.ts +15 -3
  63. package/dist/src/entities/canvases/canvas.d.ts +324 -0
  64. package/dist/src/entities/channels/access-request.d.ts +10 -2
  65. package/dist/src/entities/channels/activity.d.ts +20 -4
  66. package/dist/src/entities/channels/channel.d.ts +130 -23
  67. package/dist/src/entities/channels/labels.d.ts +41 -7
  68. package/dist/src/entities/channels/message.d.ts +41 -7
  69. package/dist/src/entities/channels/namespace.d.ts +28 -3
  70. package/dist/src/entities/channels/post.test.d.ts +1 -0
  71. package/dist/src/entities/channels/thread.d.ts +19 -3
  72. package/dist/src/entities/chats/chat.d.ts +56 -6
  73. package/dist/src/entities/chats/generation.d.ts +11 -2
  74. package/dist/src/entities/chats/namespace.d.ts +10 -2
  75. package/dist/src/entities/connected-apps/connected-app.d.ts +14 -1
  76. package/dist/src/entities/connected-apps/connector.d.ts +3 -0
  77. package/dist/src/entities/connected-apps/namespace.d.ts +16 -0
  78. package/dist/src/entities/crm/company.d.ts +63 -15
  79. package/dist/src/entities/crm/contact.d.ts +60 -13
  80. package/dist/src/entities/crm/namespace.d.ts +85 -11
  81. package/dist/src/entities/crm/pipeline-entry.d.ts +102 -0
  82. package/dist/src/entities/crm/pipeline.d.ts +271 -27
  83. package/dist/src/entities/crm/pipelines.d.ts +39 -2
  84. package/dist/src/entities/databases/column.d.ts +54 -7
  85. package/dist/src/entities/databases/database.d.ts +126 -12
  86. package/dist/src/entities/databases/namespace.d.ts +16 -4
  87. package/dist/src/entities/databases/row.d.ts +2 -0
  88. package/dist/src/entities/databases/saved-query.d.ts +145 -0
  89. package/dist/src/entities/databases/table.d.ts +64 -10
  90. package/dist/src/entities/databases/view.d.ts +27 -5
  91. package/dist/src/entities/databases/webhook.d.ts +8 -1
  92. package/dist/src/entities/documents/ai-edit.d.ts +2 -0
  93. package/dist/src/entities/documents/anchor.d.ts +12 -2
  94. package/dist/src/entities/documents/comment.d.ts +29 -5
  95. package/dist/src/entities/documents/document.d.ts +243 -20
  96. package/dist/src/entities/documents/markdown.d.ts +25 -0
  97. package/dist/src/entities/documents/namespace.d.ts +132 -13
  98. package/dist/src/entities/documents/skills.test.d.ts +1 -0
  99. package/dist/src/entities/documents/system-skill.d.ts +21 -1
  100. package/dist/src/entities/documents/text-comment.d.ts +41 -0
  101. package/dist/src/entities/documents/text-comment.test.d.ts +1 -0
  102. package/dist/src/entities/documents/version.d.ts +5 -1
  103. package/dist/src/entities/email/attachment.d.ts +3 -0
  104. package/dist/src/entities/email/draft.d.ts +61 -9
  105. package/dist/src/entities/email/filter.d.ts +12 -2
  106. package/dist/src/entities/email/label.d.ts +7 -1
  107. package/dist/src/entities/email/link.d.ts +5 -1
  108. package/dist/src/entities/email/message.d.ts +55 -8
  109. package/dist/src/entities/email/namespace.d.ts +127 -21
  110. package/dist/src/entities/email/thread.d.ts +99 -16
  111. package/dist/src/entities/entity-mentions/mention.d.ts +6 -1
  112. package/dist/src/entities/entity-mentions/namespace.d.ts +5 -1
  113. package/dist/src/entities/entity.d.ts +56 -6
  114. package/dist/src/entities/external-chat/chat.d.ts +62 -11
  115. package/dist/src/entities/external-chat/message.d.ts +1 -1
  116. package/dist/src/entities/external-chat/namespace.d.ts +5 -1
  117. package/dist/src/entities/external-chat/send.d.ts +10 -2
  118. package/dist/src/entities/favorites/namespace.d.ts +20 -3
  119. package/dist/src/entities/foreign/foreign-entity.d.ts +5 -1
  120. package/dist/src/entities/foreign/namespace.d.ts +4 -0
  121. package/dist/src/entities/forms/form.d.ts +71 -13
  122. package/dist/src/entities/forms/namespace.d.ts +10 -2
  123. package/dist/src/entities/forms/question.d.ts +35 -7
  124. package/dist/src/entities/forms/response.d.ts +25 -5
  125. package/dist/src/entities/forms/section.d.ts +15 -3
  126. package/dist/src/entities/github-pull-requests/namespace.d.ts +5 -1
  127. package/dist/src/entities/github-pull-requests/pull-request.d.ts +15 -3
  128. package/dist/src/entities/harnesses/harness.d.ts +51 -3
  129. package/dist/src/entities/harnesses/namespace.d.ts +53 -7
  130. package/dist/src/entities/harnesses/pairing.d.ts +12 -2
  131. package/dist/src/entities/images/image.d.ts +16 -5
  132. package/dist/src/entities/images/namespace.d.ts +8 -1
  133. package/dist/src/entities/initiatives/initiative.d.ts +117 -3
  134. package/dist/src/entities/initiatives/initiative.test.d.ts +1 -0
  135. package/dist/src/entities/initiatives/namespace.d.ts +69 -7
  136. package/dist/src/entities/me/namespace.d.ts +27 -2
  137. package/dist/src/entities/meetings/meeting.d.ts +45 -8
  138. package/dist/src/entities/meetings/namespace.d.ts +20 -4
  139. package/dist/src/entities/memory/namespace.d.ts +49 -0
  140. package/dist/src/entities/memory/namespace.test.d.ts +1 -0
  141. package/dist/src/entities/messages/discussion.d.ts +84 -0
  142. package/dist/src/entities/messages/thread.d.ts +19 -5
  143. package/dist/src/entities/notifications/namespace.d.ts +40 -7
  144. package/dist/src/entities/notifications/notification.d.ts +29 -5
  145. package/dist/src/entities/pins/namespace.d.ts +23 -4
  146. package/dist/src/entities/projects/namespace.d.ts +29 -0
  147. package/dist/src/entities/projects/project.d.ts +47 -6
  148. package/dist/src/entities/properties/namespace.d.ts +67 -11
  149. package/dist/src/entities/properties/namespace.test.d.ts +1 -0
  150. package/dist/src/entities/properties/property-definition.d.ts +30 -5
  151. package/dist/src/entities/properties/property-option.d.ts +14 -2
  152. package/dist/src/entities/referrals/namespace.d.ts +8 -1
  153. package/dist/src/entities/routines/namespace.d.ts +128 -7
  154. package/dist/src/entities/routines/routine.d.ts +111 -25
  155. package/dist/src/entities/saved-views/namespace.d.ts +57 -0
  156. package/dist/src/entities/saved-views/saved-view.d.ts +78 -0
  157. package/dist/src/entities/search/namespace.d.ts +5 -1
  158. package/dist/src/entities/sharing/access.d.ts +50 -9
  159. package/dist/src/entities/spreadsheets/spreadsheet.d.ts +201 -0
  160. package/dist/src/entities/tasks/namespace.d.ts +13 -1
  161. package/dist/src/entities/tasks/task.d.ts +7 -1
  162. package/dist/src/entities/teams/invite.d.ts +3 -0
  163. package/dist/src/entities/teams/namespace.d.ts +10 -2
  164. package/dist/src/entities/teams/team.d.ts +7 -0
  165. package/dist/src/entities/unfurls/namespace.d.ts +12 -2
  166. package/dist/src/entities/users/namespace.d.ts +19 -1
  167. package/dist/src/entities/users/profile-picture.d.ts +29 -0
  168. package/dist/src/entities/users/profile-picture.test.d.ts +1 -0
  169. package/dist/src/entities/users/user.d.ts +52 -1
  170. package/dist/src/entities/web/namespace.d.ts +6 -0
  171. package/dist/src/entities/webhooks/namespace.d.ts +5 -0
  172. package/dist/src/entities/webhooks/webhook.d.ts +47 -7
  173. package/dist/src/entities/whatsapp/account.d.ts +5 -1
  174. package/dist/src/entities/whatsapp/chat.d.ts +9 -1
  175. package/dist/src/entities/whatsapp/namespace.d.ts +7 -1
  176. package/dist/src/entities/workspace/namespace.d.ts +7 -1
  177. package/dist/src/entities/workspace/query.d.ts +5 -1
  178. package/dist/src/events/hydrate/user.d.ts +14 -0
  179. package/dist/src/events/receiver.d.ts +2 -0
  180. package/dist/src/events/types.d.ts +2 -1
  181. package/dist/src/macro.d.ts +33 -5
  182. package/dist/src/macro.js +15635 -10132
  183. package/dist/src/utils/lazy.d.ts +7 -1
  184. package/package.json +1 -1
  185. package/dist/src/entities/crm/comment.d.ts +0 -64
@@ -2,16 +2,24 @@ import type { GetContactResponses } from '../../../generated/storage/types.gen';
2
2
  import type { RichMessage } from '../../mentions';
3
3
  import type { MacroClient } from '../../utils/client';
4
4
  import { FavoritableEntity } from '../entity';
5
+ import { DiscussionComment, type DiscussionThread } from '../messages/discussion';
5
6
  import { MessageThread, type TimelineOptions } from '../messages/thread';
6
- import { CrmComment, type CrmCommentThread } from './comment';
7
7
  import { Company } from './company';
8
8
  type ContactDetail = GetContactResponses[200];
9
9
  /** A CRM contact: a person observed interacting with the team. */
10
10
  export declare class Contact extends FavoritableEntity<ContactDetail> {
11
- /** A shared message thread scoped to this resource. */
11
+ /**
12
+ * A shared message thread scoped to this resource.
13
+ *
14
+ * @readonly
15
+ */
12
16
  messageThreadById(id: string): MessageThread;
13
- /** A mixed message and activity timeline page. */
14
- timelinePage(selection?: TimelineOptions<CrmComment>): Promise<{
17
+ /**
18
+ * A mixed message and activity timeline page.
19
+ *
20
+ * @readonly
21
+ */
22
+ timelinePage(selection?: TimelineOptions<DiscussionComment>): Promise<{
15
23
  entries: ({
16
24
  type: "activity";
17
25
  activity: {
@@ -25,7 +33,7 @@ export declare class Contact extends FavoritableEntity<ContactDetail> {
25
33
  message?: undefined;
26
34
  } | {
27
35
  type: "message";
28
- message: CrmComment;
36
+ message: DiscussionComment;
29
37
  activity?: undefined;
30
38
  })[];
31
39
  nextCursor: import("../../../generated/storage").MessageCursor | undefined;
@@ -54,27 +62,66 @@ export declare class Contact extends FavoritableEntity<ContactDetail> {
54
62
  readonly firstInteraction: () => Promise<string>;
55
63
  /** When the team last interacted with this contact. */
56
64
  readonly lastInteraction: () => Promise<string>;
57
- /** Hide the contact from CRM listings. Display-only; reversible with {@link unhide}. */
65
+ /**
66
+ * Hide the contact from CRM listings. Display-only; reversible with {@link unhide}.
67
+ *
68
+ * @write
69
+ * @idempotent
70
+ */
58
71
  hide(): Promise<void>;
59
- /** Un-hide the contact, restoring it to CRM listings. */
72
+ /**
73
+ * Un-hide the contact, restoring it to CRM listings.
74
+ *
75
+ * @write
76
+ * @idempotent
77
+ */
60
78
  unhide(): Promise<void>;
61
79
  private setHidden;
62
- /** Rename the contact for the caller's current team. */
80
+ /**
81
+ * Rename the contact for the caller's current team.
82
+ *
83
+ * @write
84
+ * @idempotent
85
+ */
63
86
  rename(name: string): Promise<void>;
87
+ /**
88
+ * Add an email when absent. Existing addresses cannot be replaced or cleared.
89
+ *
90
+ * @write
91
+ * @idempotent
92
+ */
93
+ setEmail(email: string): Promise<void>;
94
+ /**
95
+ * Link or switch a personal-provider contact's company. Unlinking is not supported.
96
+ *
97
+ * @write
98
+ * @idempotent
99
+ */
100
+ setCompany(company: Company): Promise<void>;
64
101
  /** The CRM record this contact's discussions hang off. */
65
102
  private get commentParent();
66
- /** The comment threads on this contact, newest thread first. */
67
- comments(): Promise<CrmCommentThread[]>;
103
+ /**
104
+ * The comment threads on this contact, newest thread first.
105
+ *
106
+ * @readonly
107
+ */
108
+ comments(): Promise<DiscussionThread[]>;
68
109
  /**
69
110
  * Add a comment. Starts a new thread, or replies to an existing one when
70
111
  * `threadId` (the thread's root comment id) is given.
71
112
  *
72
113
  * @param body - Plain text, or a rich body composed with {@link msg}.
114
+ *
115
+ * @write
73
116
  */
74
117
  comment(body: string | RichMessage, opts?: {
75
118
  threadId?: string;
76
- }): Promise<CrmComment>;
77
- /** A handle to one of this contact's comments by id. */
78
- commentById(id: string): CrmComment;
119
+ }): Promise<DiscussionComment>;
120
+ /**
121
+ * A handle to one of this contact's comments by id.
122
+ *
123
+ * @readonly
124
+ */
125
+ commentById(id: string): DiscussionComment;
79
126
  }
80
127
  export {};
@@ -1,7 +1,10 @@
1
- import type { CreateCrmCompanyRequest, CreateCrmTeamContactRequest, CrmStagesResponse, CrmTeamSettingsResponse, ReplaceCrmStagesRequest, UpdateCrmTeamSettingsRequest } from '../../../generated/storage/types.gen';
1
+ import type { CreateCrmCompanyRequest, CreateCrmTeamContactRequest, CrmStagesResponse, CrmTeamSettingsResponse, PipelineSharing, ReplaceCrmStagesRequest, UpdateCrmTeamSettingsRequest } from '../../../generated/storage/types.gen';
2
2
  import type { MacroClient } from '../../utils/client';
3
+ import type { Document } from '../documents/document';
3
4
  import { Company } from './company';
4
5
  import { Contact } from './contact';
6
+ import { CrmPipeline } from './pipeline';
7
+ import { type CompanyImport } from './pipeline-entry';
5
8
  import { PipelineNamespace } from './pipelines';
6
9
  /**
7
10
  * @routing Use when working with CRM deals, pipelines, stages, companies or contacts; not generic databases, and not a search that merely names a company.
@@ -11,6 +14,8 @@ import { PipelineNamespace } from './pipelines';
11
14
  *
12
15
  * A pipeline is a board of deals. Each entry tracks one CRM company or contact and has its own fields: usually Stage, Owner and Revenue, plus any the team added. "Deal", "opportunity", "lead", "the pipeline", "move Acme to Negotiation" and "who's in Demo" all refer to pipeline entries. A pipeline is not a Macro database: work with it through the CRM pipeline methods, never database queries or SQL.
13
16
  *
17
+ * Work with entries by name through the pipeline's own methods: `find` (filters by field name and stage label, with per-stage counts and number totals such as Revenue), `addRecords`, `updateEntries` (a stage by its label, a person as `'me'`), `removeRecords`, and `edit` for fields and stage options. `importCsv` / `exportCsv` move entries through CSV, and `crm.importCompaniesCsv` loads a companies list. `crm.pipelines.entriesFor` and `searchEntries` find a company's deals across pipelines. Reach for `applyOps` and column ids only for what these cannot express.
18
+ *
14
19
  * A company also has its own Stage, Owner and Revenue properties on its CRM page. They are separate from every pipeline and not kept in sync with it. When the user has pipelines, deal and stage requests mean pipeline entries; change the company's own properties only when the user asks for those properties specifically.
15
20
  */
16
21
  export declare class CrmNamespace {
@@ -18,11 +23,23 @@ export declare class CrmNamespace {
18
23
  /** Pipelines, their records and sharing settings. */
19
24
  readonly pipelines: PipelineNamespace;
20
25
  constructor(client: MacroClient);
21
- /** A handle to a CRM company by id. */
26
+ /**
27
+ * A handle to a CRM company by id.
28
+ *
29
+ * @readonly
30
+ */
22
31
  companyById(id: string): Company;
23
- /** A handle to a CRM contact by id. */
32
+ /**
33
+ * A handle to a CRM contact by id.
34
+ *
35
+ * @readonly
36
+ */
24
37
  contactById(id: string): Contact;
25
- /** Resolve a CRM contact by email in the caller's current team, if present. */
38
+ /**
39
+ * Resolve a CRM contact by email in the caller's current team, if present.
40
+ *
41
+ * @readonly
42
+ */
26
43
  contactByEmail(email: string): Promise<Contact | undefined>;
27
44
  /**
28
45
  * Search the caller's current team's CRM contacts whose email or name
@@ -30,25 +47,40 @@ export declare class CrmNamespace {
30
47
  * An empty query lists the most recent contacts.
31
48
  *
32
49
  * @param opts.limit Maximum contacts to return (1-500, default 20).
50
+ *
51
+ * @readonly
33
52
  */
34
53
  searchContacts(query: string, opts?: {
35
54
  limit?: number;
36
55
  }): Promise<Contact[]>;
37
- /** Create a CRM company for the caller's current team. */
56
+ /**
57
+ * Create a CRM company for the caller's current team.
58
+ *
59
+ * @write
60
+ */
38
61
  createCompany(opts: CreateCrmCompanyRequest): Promise<Company>;
39
62
  /**
40
63
  * Create a contact without a company for the caller's current team. The
41
64
  * email is optional and may be at any domain. To add someone to a company,
42
65
  * use {@link Company.createContact}.
66
+ *
67
+ * @write
43
68
  */
44
69
  createContact(opts: CreateCrmTeamContactRequest): Promise<Contact>;
45
- /** The domains the caller's current team keeps out of email sync. */
70
+ /**
71
+ * The domains the caller's current team keeps out of email sync.
72
+ *
73
+ * @readonly
74
+ */
46
75
  blockedDomains(): Promise<string[]>;
47
76
  /**
48
77
  * Block a domain (like `acme.com`): email sync skips it, and the company
49
78
  * that owns it, that company's contacts, and contacts without a company at
50
79
  * the domain are hidden. A contact attached to another company follows that
51
80
  * company's domains. Requires a team admin or owner.
81
+ *
82
+ * @destructive
83
+ * @idempotent
52
84
  */
53
85
  blockDomain(domain: string): Promise<void>;
54
86
  /**
@@ -57,16 +89,58 @@ export declare class CrmNamespace {
57
89
  * company at this domain are shown again. Its company and attached contacts
58
90
  * stay hidden until the company's last blocked domain is removed, then are
59
91
  * shown even if hidden by hand before blocking. Requires a team admin or owner.
92
+ *
93
+ * @write
94
+ * @idempotent
60
95
  */
61
96
  unblockDomain(domain: string): Promise<void>;
62
- /** The caller's current team's CRM settings. */
97
+ /**
98
+ * The caller's current team's CRM settings.
99
+ *
100
+ * @readonly
101
+ */
63
102
  settings(): Promise<CrmTeamSettingsResponse>;
64
- /** Partially update the caller's current team's CRM settings. */
103
+ /**
104
+ * Partially update the caller's current team's CRM settings.
105
+ *
106
+ * @write
107
+ * @idempotent
108
+ */
65
109
  updateSettings(settings: UpdateCrmTeamSettingsRequest): Promise<CrmTeamSettingsResponse>;
66
- /** Replace the caller's current team's deal stages, in pipeline order. */
110
+ /**
111
+ * Replace the caller's current team's deal stages, in pipeline order.
112
+ *
113
+ * @destructive
114
+ * @idempotent
115
+ */
67
116
  setStages(stages: ReplaceCrmStagesRequest): Promise<CrmStagesResponse>;
68
- /** Reset the caller's current team's deal stages to the defaults. */
117
+ /**
118
+ * Reset the caller's current team's deal stages to the defaults.
119
+ *
120
+ * @destructive
121
+ * @idempotent
122
+ */
69
123
  resetStages(): Promise<void>;
70
- /** Search CRM companies by name/domain, most relevant first, auto-paginated. */
124
+ /**
125
+ * Create the companies a CSV lists (CSV text, or a CSV document), keyed by
126
+ * domain; companies the team already has are counted, not duplicated. When
127
+ * the CSV has Stage, Owner or Revenue columns, those go on entries of
128
+ * `pipeline` (a company pipeline), or of a new pipeline (private unless
129
+ * `newPipeline.sharing` is `team`, named after the file unless named).
130
+ *
131
+ * @write
132
+ */
133
+ importCompaniesCsv(source: string | Document, options?: {
134
+ pipeline?: CrmPipeline;
135
+ newPipeline?: {
136
+ name?: string;
137
+ sharing?: PipelineSharing;
138
+ };
139
+ }): Promise<CompanyImport>;
140
+ /**
141
+ * Search CRM companies by name/domain, most relevant first, auto-paginated.
142
+ *
143
+ * @readonly
144
+ */
71
145
  searchCompanies(query: string): AsyncGenerator<Company>;
72
146
  }
@@ -0,0 +1,102 @@
1
+ import type { CompanyImportResponse, EntryFieldChange, EntryFieldValue, FieldOptionCounts, FieldTotal, FieldValueInput, PipelineEntry as PipelineEntryRecord, PipelineFieldSummary, PipelineImportResponse, SkippedImportRecord } from '../../../generated/storage/types.gen';
2
+ import type { MacroClient } from '../../utils/client';
3
+ import { Company } from './company';
4
+ import { Contact } from './contact';
5
+ import type { CrmPipeline } from './pipeline';
6
+ /**
7
+ * A value to write into a pipeline field, or to match one against: an option
8
+ * label such as a stage (`'Negotiation'`), a person as `'me'`, an email or a
9
+ * `macro|` user id, a number, true/false, a date (`'2026-10-12'`), a list for
10
+ * a field holding several values (in a filter, any of them matches), or
11
+ * `null` to empty the field (in a filter, to match an empty field).
12
+ */
13
+ export type PipelineFieldInput = string | number | boolean | string[] | null;
14
+ /** Pipeline fields by name (case-insensitive), each with what to write or match. */
15
+ export type PipelineFieldInputs = Record<string, PipelineFieldInput>;
16
+ /** A stored pipeline field value, tagged with its kind: `labels` for a stage or other select, `references` for people (`macro|` user ids). */
17
+ export type PipelineFieldValue = EntryFieldValue;
18
+ /** A field of a pipeline as entries and filters name it. */
19
+ export type PipelineField = PipelineFieldSummary;
20
+ /** A field's value before and after an update; `undefined` when empty. */
21
+ export type PipelineFieldChange = {
22
+ field: string;
23
+ before: PipelineFieldValue | undefined;
24
+ after: PipelineFieldValue | undefined;
25
+ };
26
+ /** The company or contact an entry tracks, or a contact's email to add (in a company pipeline, its company). */
27
+ export type PipelineRecordInput = Company | Contact | {
28
+ email: string;
29
+ };
30
+ /** Matched entries per option of a single-select field such as Stage, and how many have it empty. */
31
+ export type PipelineOptionCounts = FieldOptionCounts;
32
+ /** The sum of a number field such as Revenue over the matched entries. */
33
+ export type PipelineFieldTotal = FieldTotal;
34
+ /** A CSV row an import could not add: the company's domain or the contact's email, and why. */
35
+ export type PipelineImportSkip = SkippedImportRecord;
36
+ /** What a CSV import into a pipeline did. */
37
+ export type PipelineImport = Omit<PipelineImportResponse, 'pipelineId' | 'pipelineName'> & {
38
+ /** The pipeline filled. */
39
+ pipeline: CrmPipeline;
40
+ };
41
+ /** What a companies CSV import did. */
42
+ export type CompanyImport = Omit<CompanyImportResponse, 'pipeline'> & {
43
+ /** The entries made from the CSV's Stage, Owner and Revenue, when it had any. */
44
+ pipeline: PipelineImport | undefined;
45
+ };
46
+ /** @internal The wire form of named field values. */
47
+ export declare function fieldInputs(set: PipelineFieldInputs): FieldValueInput[];
48
+ /** @internal A pipeline import with its pipeline as a handle. */
49
+ export declare function pipelineImport(pipeline: CrmPipeline, outcome: PipelineImportResponse): PipelineImport;
50
+ /**
51
+ * One entry of a CRM pipeline (a deal): the company or contact it tracks
52
+ * (none in a generic pipeline of free-form rows) and its fields by name. Change it with {@link PipelineEntry.update} or take it
53
+ * out with {@link PipelineEntry.remove}.
54
+ *
55
+ * @mcp-exclude Built from a pipeline listing; use CrmPipeline.updateEntries and removeRecords.
56
+ */
57
+ export declare class PipelineEntry {
58
+ /** The pipeline holding it. */
59
+ readonly pipeline: CrmPipeline;
60
+ /** Entry identity within the pipeline. */
61
+ readonly id: string;
62
+ /** The company or contact it tracks; `undefined` in a generic pipeline. */
63
+ readonly record: Company | Contact | undefined;
64
+ /** The record's name; `undefined` when the caller cannot see it or there is none. */
65
+ readonly recordName: string | undefined;
66
+ /** A company's domain or a contact's email. */
67
+ readonly recordDetail: string | undefined;
68
+ /** Its fields that hold a value, by name, as the response that returned it carried them. */
69
+ readonly fields: Record<string, PipelineFieldValue>;
70
+ private constructor();
71
+ /** @internal Seed from a workflow response of a pipeline tracking `recordType`, or nothing. */
72
+ static from(client: MacroClient, pipeline: CrmPipeline, recordType: 'company' | 'contact' | null | undefined, entry: Pick<PipelineEntryRecord, 'entryId' | 'record'> & {
73
+ fields?: PipelineEntryRecord['fields'];
74
+ }): PipelineEntry;
75
+ /**
76
+ * Set fields by name: a stage by its label, a person as `'me'` or an email,
77
+ * `null` to empty. Pass `baseVersion` (from {@link CrmPipeline.find}) to
78
+ * refuse the change if the pipeline changed since.
79
+ */
80
+ update(set: PipelineFieldInputs, options?: {
81
+ baseVersion?: number;
82
+ }): Promise<{
83
+ entry: PipelineEntry;
84
+ changes: PipelineFieldChange[];
85
+ version: number | undefined;
86
+ }>;
87
+ /** Delete this entry; its company or contact stays in the CRM. */
88
+ remove(): Promise<void>;
89
+ /** Serialize identity and the values read, without an authenticated client. */
90
+ toJSON(): {
91
+ id: string;
92
+ pipelineId: string;
93
+ record: {
94
+ id: string;
95
+ name: string | undefined;
96
+ detail: string | undefined;
97
+ } | undefined;
98
+ fields: Record<string, EntryFieldValue>;
99
+ };
100
+ }
101
+ /** @internal A field change with absent values as `undefined`. */
102
+ export declare function fieldChange(change: EntryFieldChange): PipelineFieldChange;