@macro-inc/sdk 0.4.1 → 0.6.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 (228) hide show
  1. package/README.md +316 -21
  2. package/dist/{chunk-PTX2RV2N.js → chunk-4MI52GWV.js} +93 -1
  3. package/dist/{chunk-XFA7NCJ5.js → chunk-HO75UE4Z.js} +146 -15
  4. package/dist/{chunk-P4DTO6VD.js → chunk-MCSQNZ4E.js} +6 -0
  5. package/dist/{chunk-ZLBDES7U.js → chunk-SJ6S2GAT.js} +1271 -87
  6. package/dist/{chunk-AZJUIUIV.js → chunk-SK5CMXRV.js} +100 -14
  7. package/dist/{chunk-PZPTJI6F.js → chunk-TMTYN2UK.js} +229 -2
  8. package/dist/{chunk-PPR7IWZ7.js → chunk-ZYBAKW25.js} +2 -1
  9. package/dist/generated/agent-fold/index.d.ts +202 -14
  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 +49 -2
  13. package/dist/generated/agent-harness/types.gen.d.ts +527 -9
  14. package/dist/generated/agent-reviews/index.d.ts +11 -9
  15. package/dist/generated/auth/index.d.ts +1 -1
  16. package/dist/generated/auth/index.js +1 -1
  17. package/dist/generated/auth/sdk.gen.d.ts +82 -16
  18. package/dist/generated/auth/types.gen.d.ts +768 -18
  19. package/dist/generated/calendar/types.gen.d.ts +10 -3
  20. package/dist/generated/cognition/index.d.ts +1 -1
  21. package/dist/generated/cognition/index.js +1 -1
  22. package/dist/generated/cognition/sdk.gen.d.ts +60 -6
  23. package/dist/generated/cognition/types.gen.d.ts +663 -106
  24. package/dist/generated/connection/types.gen.d.ts +1 -1
  25. package/dist/generated/contacts/index.d.ts +1 -1
  26. package/dist/generated/contacts/index.js +1 -1
  27. package/dist/generated/contacts/sdk.gen.d.ts +5 -1
  28. package/dist/generated/contacts/types.gen.d.ts +56 -0
  29. package/dist/generated/email/types.gen.d.ts +8 -2
  30. package/dist/generated/notification/index.d.ts +1 -1
  31. package/dist/generated/notification/index.js +1 -1
  32. package/dist/generated/notification/sdk.gen.d.ts +2 -1
  33. package/dist/generated/notification/types.gen.d.ts +174 -1
  34. package/dist/generated/scheduled-action/index.d.ts +1 -1
  35. package/dist/generated/scheduled-action/index.js +1 -1
  36. package/dist/generated/scheduled-action/sdk.gen.d.ts +107 -2
  37. package/dist/generated/scheduled-action/types.gen.d.ts +2451 -479
  38. package/dist/generated/search/index.d.ts +1 -1
  39. package/dist/generated/search/types.gen.d.ts +50 -11
  40. package/dist/generated/storage/index.d.ts +1 -1
  41. package/dist/generated/storage/index.js +1 -1
  42. package/dist/generated/storage/sdk.gen.d.ts +511 -18
  43. package/dist/generated/storage/types.gen.d.ts +18528 -11395
  44. package/dist/src/entities/account-managers/grant.d.ts +28 -5
  45. package/dist/src/entities/account-managers/namespace.d.ts +15 -3
  46. package/dist/src/entities/activity/entity.d.ts +7 -0
  47. package/dist/src/entities/activity/namespace.d.ts +58 -0
  48. package/dist/src/entities/activity/namespace.test.d.ts +1 -0
  49. package/dist/src/entities/agent-sessions/activity.d.ts +12 -3
  50. package/dist/src/entities/agent-sessions/agent-session.d.ts +209 -22
  51. package/dist/src/entities/agent-sessions/code-execution.d.ts +15 -3
  52. package/dist/src/entities/agent-sessions/conversation.d.ts +46 -9
  53. package/dist/src/entities/agent-sessions/namespace.d.ts +72 -16
  54. package/dist/src/entities/agent-sessions/origin.d.ts +1 -1
  55. package/dist/src/entities/agent-sessions/queued-action.d.ts +17 -3
  56. package/dist/src/entities/agent-sessions/review.d.ts +56 -5
  57. package/dist/src/entities/agent-sessions/tool-approval.d.ts +5 -1
  58. package/dist/src/entities/agents/agent.d.ts +98 -3
  59. package/dist/src/entities/agents/namespace.d.ts +52 -8
  60. package/dist/src/entities/ai/namespace.d.ts +10 -2
  61. package/dist/src/entities/api-keys/api-key.d.ts +6 -1
  62. package/dist/src/entities/api-keys/namespace.d.ts +18 -3
  63. package/dist/src/entities/bots/bot.d.ts +44 -9
  64. package/dist/src/entities/bots/namespace.d.ts +13 -1
  65. package/dist/src/entities/bots/token.d.ts +6 -1
  66. package/dist/src/entities/calendar/booking-link.d.ts +7 -1
  67. package/dist/src/entities/calendar/booking-namespace.d.ts +14 -1
  68. package/dist/src/entities/calendar/booking.d.ts +15 -0
  69. package/dist/src/entities/calendar/calendar.d.ts +10 -3
  70. package/dist/src/entities/calendar/event.d.ts +68 -9
  71. package/dist/src/entities/calendar/namespace.d.ts +91 -12
  72. package/dist/src/entities/calendar/replacement.d.ts +19 -3
  73. package/dist/src/entities/calls/call-record.d.ts +107 -17
  74. package/dist/src/entities/calls/connection.d.ts +7 -1
  75. package/dist/src/entities/calls/message.d.ts +27 -5
  76. package/dist/src/entities/calls/namespace.d.ts +15 -3
  77. package/dist/src/entities/canvases/canvas.d.ts +329 -0
  78. package/dist/src/entities/channels/access-request.d.ts +10 -2
  79. package/dist/src/entities/channels/activity.d.ts +20 -4
  80. package/dist/src/entities/channels/channel.d.ts +154 -27
  81. package/dist/src/entities/channels/labels.d.ts +41 -7
  82. package/dist/src/entities/channels/message.d.ts +105 -8
  83. package/dist/src/entities/channels/message.test.d.ts +1 -0
  84. package/dist/src/entities/channels/namespace.d.ts +37 -7
  85. package/dist/src/entities/channels/post.d.ts +13 -7
  86. package/dist/src/entities/channels/post.test.d.ts +1 -0
  87. package/dist/src/entities/channels/share.d.ts +9 -0
  88. package/dist/src/entities/channels/share.test.d.ts +1 -0
  89. package/dist/src/entities/channels/thread.d.ts +24 -4
  90. package/dist/src/entities/chats/chat.d.ts +57 -7
  91. package/dist/src/entities/chats/generation.d.ts +11 -2
  92. package/dist/src/entities/chats/namespace.d.ts +10 -2
  93. package/dist/src/entities/connected-apps/connected-app.d.ts +16 -2
  94. package/dist/src/entities/connected-apps/connector.d.ts +3 -0
  95. package/dist/src/entities/connected-apps/namespace.d.ts +18 -0
  96. package/dist/src/entities/crm/company.d.ts +64 -16
  97. package/dist/src/entities/crm/contact.d.ts +102 -14
  98. package/dist/src/entities/crm/namespace.d.ts +113 -22
  99. package/dist/src/entities/crm/pipeline-entry.d.ts +109 -0
  100. package/dist/src/entities/crm/pipeline.d.ts +292 -29
  101. package/dist/src/entities/crm/pipelines.d.ts +69 -4
  102. package/dist/src/entities/crm-email-privacy/email-privacy.d.ts +238 -0
  103. package/dist/src/entities/crm-email-privacy/email-rule-preview.d.ts +55 -0
  104. package/dist/src/entities/crm-email-privacy/email-rule-revision.d.ts +27 -0
  105. package/dist/src/entities/crm-email-privacy/email-rules.d.ts +32 -0
  106. package/dist/src/entities/databases/column.d.ts +54 -7
  107. package/dist/src/entities/databases/database.d.ts +160 -18
  108. package/dist/src/entities/databases/namespace.d.ts +40 -8
  109. package/dist/src/entities/databases/row.d.ts +2 -0
  110. package/dist/src/entities/databases/saved-query.d.ts +151 -0
  111. package/dist/src/entities/databases/table.d.ts +73 -10
  112. package/dist/src/entities/databases/view.d.ts +37 -5
  113. package/dist/src/entities/databases/webhook.d.ts +8 -1
  114. package/dist/src/entities/documents/ai-edit.d.ts +2 -0
  115. package/dist/src/entities/documents/anchor.d.ts +12 -2
  116. package/dist/src/entities/documents/comment.d.ts +29 -5
  117. package/dist/src/entities/documents/create.test.d.ts +1 -0
  118. package/dist/src/entities/documents/document.d.ts +284 -26
  119. package/dist/src/entities/documents/markdown.d.ts +25 -0
  120. package/dist/src/entities/documents/namespace.d.ts +146 -13
  121. package/dist/src/entities/documents/skills.test.d.ts +1 -0
  122. package/dist/src/entities/documents/system-skill.d.ts +21 -1
  123. package/dist/src/entities/documents/text-comment.d.ts +41 -0
  124. package/dist/src/entities/documents/text-comment.test.d.ts +1 -0
  125. package/dist/src/entities/documents/version.d.ts +5 -1
  126. package/dist/src/entities/email/attachment.d.ts +3 -0
  127. package/dist/src/entities/email/draft.d.ts +61 -9
  128. package/dist/src/entities/email/filter.d.ts +12 -2
  129. package/dist/src/entities/email/label.d.ts +7 -1
  130. package/dist/src/entities/email/link.d.ts +5 -1
  131. package/dist/src/entities/email/message.d.ts +72 -14
  132. package/dist/src/entities/email/namespace.d.ts +134 -24
  133. package/dist/src/entities/email/thread.d.ts +124 -18
  134. package/dist/src/entities/entity-mentions/mention.d.ts +6 -1
  135. package/dist/src/entities/entity-mentions/namespace.d.ts +5 -1
  136. package/dist/src/entities/entity.d.ts +65 -6
  137. package/dist/src/entities/external-chat/chat.d.ts +80 -12
  138. package/dist/src/entities/external-chat/message.d.ts +1 -1
  139. package/dist/src/entities/external-chat/namespace.d.ts +5 -1
  140. package/dist/src/entities/external-chat/send.d.ts +10 -2
  141. package/dist/src/entities/favorites/namespace.d.ts +20 -3
  142. package/dist/src/entities/foreign/foreign-entity.d.ts +5 -1
  143. package/dist/src/entities/foreign/namespace.d.ts +5 -1
  144. package/dist/src/entities/forms/form.d.ts +91 -14
  145. package/dist/src/entities/forms/namespace.d.ts +10 -2
  146. package/dist/src/entities/forms/question.d.ts +35 -7
  147. package/dist/src/entities/forms/response.d.ts +25 -5
  148. package/dist/src/entities/forms/section.d.ts +15 -3
  149. package/dist/src/entities/github-pull-requests/namespace.d.ts +5 -1
  150. package/dist/src/entities/github-pull-requests/pull-request.d.ts +15 -3
  151. package/dist/src/entities/harnesses/harness.d.ts +51 -3
  152. package/dist/src/entities/harnesses/namespace.d.ts +54 -8
  153. package/dist/src/entities/harnesses/pairing.d.ts +13 -2
  154. package/dist/src/entities/images/image.d.ts +16 -5
  155. package/dist/src/entities/images/namespace.d.ts +8 -1
  156. package/dist/src/entities/imports/entry.d.ts +65 -0
  157. package/dist/src/entities/imports/namespace.d.ts +103 -0
  158. package/dist/src/entities/imports/namespace.test.d.ts +1 -0
  159. package/dist/src/entities/initiatives/initiative.d.ts +128 -4
  160. package/dist/src/entities/initiatives/initiative.test.d.ts +1 -0
  161. package/dist/src/entities/initiatives/namespace.d.ts +71 -7
  162. package/dist/src/entities/me/namespace.d.ts +28 -3
  163. package/dist/src/entities/meetings/meeting.d.ts +46 -8
  164. package/dist/src/entities/meetings/namespace.d.ts +20 -4
  165. package/dist/src/entities/memory/namespace.d.ts +49 -0
  166. package/dist/src/entities/memory/namespace.test.d.ts +1 -0
  167. package/dist/src/entities/messages/discussion.d.ts +84 -0
  168. package/dist/src/entities/messages/thread.d.ts +19 -5
  169. package/dist/src/entities/notifications/namespace.d.ts +41 -7
  170. package/dist/src/entities/notifications/notification.d.ts +31 -6
  171. package/dist/src/entities/passwords/item.d.ts +118 -0
  172. package/dist/src/entities/passwords/namespace.d.ts +45 -0
  173. package/dist/src/entities/pins/namespace.d.ts +23 -4
  174. package/dist/src/entities/projects/namespace.d.ts +29 -0
  175. package/dist/src/entities/projects/project.d.ts +58 -7
  176. package/dist/src/entities/properties/namespace.d.ts +67 -11
  177. package/dist/src/entities/properties/namespace.test.d.ts +1 -0
  178. package/dist/src/entities/properties/property-definition.d.ts +30 -5
  179. package/dist/src/entities/properties/property-option.d.ts +14 -2
  180. package/dist/src/entities/referrals/namespace.d.ts +8 -1
  181. package/dist/src/entities/routines/namespace.d.ts +198 -14
  182. package/dist/src/entities/routines/routine.d.ts +174 -27
  183. package/dist/src/entities/routines/suggestion.d.ts +38 -0
  184. package/dist/src/entities/saved-views/namespace.d.ts +58 -0
  185. package/dist/src/entities/saved-views/saved-view.d.ts +78 -0
  186. package/dist/src/entities/search/exclusions.d.ts +6 -0
  187. package/dist/src/entities/search/namespace.d.ts +9 -3
  188. package/dist/src/entities/search/options.d.ts +3 -2
  189. package/dist/src/entities/sharing/access.d.ts +50 -9
  190. package/dist/src/entities/spreadsheets/spreadsheet.d.ts +201 -0
  191. package/dist/src/entities/suggestions/namespace.d.ts +118 -0
  192. package/dist/src/entities/suggestions/suggestion.d.ts +172 -0
  193. package/dist/src/entities/suggestions/suggestion.test.d.ts +1 -0
  194. package/dist/src/entities/tasks/namespace.d.ts +18 -5
  195. package/dist/src/entities/tasks/task.d.ts +21 -3
  196. package/dist/src/entities/teams/invite.d.ts +3 -0
  197. package/dist/src/entities/teams/namespace.d.ts +10 -2
  198. package/dist/src/entities/teams/team.d.ts +22 -2
  199. package/dist/src/entities/ui/app-link.d.ts +24 -0
  200. package/dist/src/entities/ui/namespace.d.ts +75 -0
  201. package/dist/src/entities/unfurls/namespace.d.ts +12 -2
  202. package/dist/src/entities/users/namespace.d.ts +26 -4
  203. package/dist/src/entities/users/profile-picture.d.ts +29 -0
  204. package/dist/src/entities/users/profile-picture.test.d.ts +1 -0
  205. package/dist/src/entities/users/user.d.ts +52 -1
  206. package/dist/src/entities/web/namespace.d.ts +6 -0
  207. package/dist/src/entities/webhooks/namespace.d.ts +5 -0
  208. package/dist/src/entities/webhooks/webhook.d.ts +47 -7
  209. package/dist/src/entities/whatsapp/account.d.ts +5 -1
  210. package/dist/src/entities/whatsapp/chat.d.ts +9 -1
  211. package/dist/src/entities/whatsapp/namespace.d.ts +7 -1
  212. package/dist/src/entities/workspace/namespace.d.ts +12 -4
  213. package/dist/src/entities/workspace/query.d.ts +5 -1
  214. package/dist/src/entities/workspace/query.test.d.ts +1 -0
  215. package/dist/src/events/hydrate/document.d.ts +5 -0
  216. package/dist/src/events/hydrate/user.d.ts +14 -0
  217. package/dist/src/events/receiver.d.ts +2 -0
  218. package/dist/src/events/types.d.ts +2 -1
  219. package/dist/src/macro.d.ts +59 -6
  220. package/dist/src/macro.js +18710 -10355
  221. package/dist/src/utils/activity.d.ts +2 -0
  222. package/dist/src/utils/index.d.ts +1 -1
  223. package/dist/src/utils/lazy.d.ts +20 -1
  224. package/dist/src/utils/options.d.ts +7 -0
  225. package/dist/src/utils/pagination.d.ts +16 -0
  226. package/dist/src/utils/verbs.d.ts +3 -0
  227. package/package.json +1 -1
  228. package/dist/src/entities/crm/comment.d.ts +0 -64
@@ -1,28 +1,60 @@
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 { CrmEmailPrivacyNamespace } from '../crm-email-privacy/email-privacy';
4
+ import type { Document } from '../documents/document';
5
+ import type { SearchOpts } from '../search/options';
6
+ import { Team } from '../teams/team';
3
7
  import { Company } from './company';
4
8
  import { Contact } from './contact';
9
+ import { CrmPipeline } from './pipeline';
10
+ import { type CompanyImport } from './pipeline-entry';
5
11
  import { PipelineNamespace } from './pipelines';
6
12
  /**
7
- * @routing Use when working with CRM deals, pipelines, stages, companies or contacts; not generic databases, and not a search that merely names a company.
13
+ * @routing Use when working with CRM records and pipelines; not generic databases or email contribution.
8
14
  *
9
15
  * @agent
10
16
  * ## How CRM pipelines work
11
17
  *
12
18
  * 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
19
  *
20
+ * Create a pipeline with its stages and fields in one `crm.pipelines.create` call. 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.
21
+ *
14
22
  * 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
23
  */
16
24
  export declare class CrmNamespace {
17
25
  private readonly client;
26
+ /** Your email contribution. */
27
+ readonly emailPrivacy: CrmEmailPrivacyNamespace;
18
28
  /** Pipelines, their records and sharing settings. */
19
29
  readonly pipelines: PipelineNamespace;
20
30
  constructor(client: MacroClient);
21
- /** A handle to a CRM company by id. */
31
+ /**
32
+ * Read the caller's current CRM access, including when access is denied.
33
+ * Existing handles do not bypass the server's current permission checks.
34
+ *
35
+ * @readonly
36
+ */
37
+ access(): Promise<{
38
+ team?: Team;
39
+ allowed: boolean;
40
+ }>;
41
+ /**
42
+ * A handle to a CRM company by id.
43
+ *
44
+ * @readonly
45
+ */
22
46
  companyById(id: string): Company;
23
- /** A handle to a CRM contact by id. */
47
+ /**
48
+ * A handle to a CRM contact by id.
49
+ *
50
+ * @readonly
51
+ */
24
52
  contactById(id: string): Contact;
25
- /** Resolve a CRM contact by email in the caller's current team, if present. */
53
+ /**
54
+ * Resolve a CRM contact by email in the caller's current team, if present.
55
+ *
56
+ * @readonly
57
+ */
26
58
  contactByEmail(email: string): Promise<Contact | undefined>;
27
59
  /**
28
60
  * Search the caller's current team's CRM contacts whose email or name
@@ -30,43 +62,102 @@ export declare class CrmNamespace {
30
62
  * An empty query lists the most recent contacts.
31
63
  *
32
64
  * @param opts.limit Maximum contacts to return (1-500, default 20).
65
+ *
66
+ * @readonly
33
67
  */
34
68
  searchContacts(query: string, opts?: {
35
69
  limit?: number;
36
70
  }): Promise<Contact[]>;
37
- /** Create a CRM company for the caller's current team. */
71
+ /**
72
+ * Create a CRM company for the caller's current team.
73
+ *
74
+ * @write
75
+ */
38
76
  createCompany(opts: CreateCrmCompanyRequest): Promise<Company>;
39
77
  /**
40
78
  * Create a contact without a company for the caller's current team. The
41
79
  * email is optional and may be at any domain. To add someone to a company,
42
80
  * use {@link Company.createContact}.
81
+ *
82
+ * @write
43
83
  */
44
84
  createContact(opts: CreateCrmTeamContactRequest): Promise<Contact>;
45
- /** The domains the caller's current team keeps out of email sync. */
85
+ /**
86
+ * The domains the caller's current team keeps out of email sync.
87
+ *
88
+ * @readonly
89
+ */
46
90
  blockedDomains(): Promise<string[]>;
47
91
  /**
48
- * Block a domain (like `acme.com`): email sync skips it, and the company
49
- * that owns it, that company's contacts, and contacts without a company at
50
- * the domain are hidden. A contact attached to another company follows that
51
- * company's domains. Requires a team admin or owner.
92
+ * Block a domain from email sync without changing existing CRM records.
93
+ *
94
+ * Existing companies, contacts and their hidden states are preserved.
95
+ * Requires a team admin or owner.
96
+ *
97
+ * @destructive
98
+ * @idempotent
99
+ * @throws When the domain equals or covers a member's connected primary
100
+ * mailbox domain. The error preserves the server's explanation.
52
101
  */
53
102
  blockDomain(domain: string): Promise<void>;
54
103
  /**
55
- * Unblock a domain: email sync resumes for addresses the team's
56
- * personal-email and generic-provider filters allow. Contacts without a
57
- * company at this domain are shown again. Its company and attached contacts
58
- * stay hidden until the company's last blocked domain is removed, then are
59
- * shown even if hidden by hand before blocking. Requires a team admin or owner.
104
+ * Resume eligible email sync for a domain without changing existing CRM records.
105
+ *
106
+ * Email sync resumes for addresses the team's personal-email and
107
+ * generic-provider filters allow. Existing companies, contacts and their
108
+ * hidden states are preserved. Requires a team admin or owner.
109
+ *
110
+ * @write
111
+ * @idempotent
60
112
  */
61
113
  unblockDomain(domain: string): Promise<void>;
62
- /** The caller's current team's CRM settings. */
114
+ /**
115
+ * The caller's current team's CRM settings.
116
+ *
117
+ * @readonly
118
+ */
63
119
  settings(): Promise<CrmTeamSettingsResponse>;
64
- /** Partially update the caller's current team's CRM settings. */
120
+ /**
121
+ * Partially update the caller's current team's CRM settings.
122
+ *
123
+ * @write
124
+ * @idempotent
125
+ */
65
126
  updateSettings(settings: UpdateCrmTeamSettingsRequest): Promise<CrmTeamSettingsResponse>;
66
- /** Replace the caller's current team's deal stages, in pipeline order. */
127
+ /**
128
+ * Replace the caller's current team's deal stages, in pipeline order.
129
+ *
130
+ * @destructive
131
+ * @idempotent
132
+ */
67
133
  setStages(stages: ReplaceCrmStagesRequest): Promise<CrmStagesResponse>;
68
- /** Reset the caller's current team's deal stages to the defaults. */
134
+ /**
135
+ * Reset the caller's current team's deal stages to the defaults.
136
+ *
137
+ * @destructive
138
+ * @idempotent
139
+ */
69
140
  resetStages(): Promise<void>;
70
- /** Search CRM companies by name/domain, most relevant first, auto-paginated. */
71
- searchCompanies(query: string): AsyncGenerator<Company>;
141
+ /**
142
+ * Create the companies a CSV lists (CSV text, or a CSV document), keyed by
143
+ * domain; companies the team already has are counted, not duplicated. When
144
+ * the CSV has Stage, Owner or Revenue columns, those go on entries of
145
+ * `pipeline` (a company pipeline), or of a new pipeline (private unless
146
+ * `newPipeline.sharing` is `team`, named after the file unless named).
147
+ *
148
+ * @write
149
+ */
150
+ importCompaniesCsv(source: string | Document, options?: {
151
+ pipeline?: CrmPipeline;
152
+ newPipeline?: {
153
+ name?: string;
154
+ sharing?: PipelineSharing;
155
+ };
156
+ }): Promise<CompanyImport>;
157
+ /**
158
+ * Search CRM companies by name/domain, most relevant first, auto-paginated; `maxItems` caps the total.
159
+ *
160
+ * @readonly
161
+ */
162
+ searchCompanies(query: string, opts?: SearchOpts): AsyncGenerator<Company>;
72
163
  }
@@ -0,0 +1,109 @@
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
+ /**
21
+ * A field's value before and after an update; `undefined` when empty. A
22
+ * monetary field also carries the currency code of each amount.
23
+ */
24
+ export type PipelineFieldChange = {
25
+ field: string;
26
+ before: PipelineFieldValue | undefined;
27
+ after: PipelineFieldValue | undefined;
28
+ beforeCurrency?: string;
29
+ afterCurrency?: string;
30
+ };
31
+ /** The company or contact an entry tracks, or a contact's email to add (in a company pipeline, its company). */
32
+ export type PipelineRecordInput = Company | Contact | {
33
+ email: string;
34
+ };
35
+ /** Matched entries per option of a single-select field such as Stage, and how many have it empty. */
36
+ export type PipelineOptionCounts = FieldOptionCounts;
37
+ /** The sum of a number field such as Revenue over the matched entries. */
38
+ export type PipelineFieldTotal = FieldTotal;
39
+ /** A CSV row an import could not add: the company's domain or the contact's email, and why. */
40
+ export type PipelineImportSkip = SkippedImportRecord;
41
+ /** What a CSV import into a pipeline did. */
42
+ export type PipelineImport = Omit<PipelineImportResponse, 'pipelineId' | 'pipelineName'> & {
43
+ /** The pipeline filled. */
44
+ pipeline: CrmPipeline;
45
+ };
46
+ /** What a companies CSV import did. */
47
+ export type CompanyImport = Omit<CompanyImportResponse, 'pipeline'> & {
48
+ /** The entries made from the CSV's Stage, Owner and Revenue, when it had any. */
49
+ pipeline: PipelineImport | undefined;
50
+ };
51
+ /** @internal The wire form of named field values. */
52
+ export declare function fieldInputs(set: PipelineFieldInputs): FieldValueInput[];
53
+ /** @internal A pipeline import with its pipeline as a handle. */
54
+ export declare function pipelineImport(pipeline: CrmPipeline, outcome: PipelineImportResponse): PipelineImport;
55
+ /**
56
+ * A CRM pipeline entry (a deal), with its fields by name.
57
+ *
58
+ * It tracks a company or contact, or neither in a generic pipeline of
59
+ * free-form rows. Change it with {@link PipelineEntry.update} or take it
60
+ * out with {@link PipelineEntry.remove}.
61
+ *
62
+ * @mcp-exclude Built from a pipeline listing; use CrmPipeline.updateEntries and removeRecords.
63
+ */
64
+ export declare class PipelineEntry {
65
+ /** The pipeline holding it. */
66
+ readonly pipeline: CrmPipeline;
67
+ /** Entry identity within the pipeline. */
68
+ readonly id: string;
69
+ /** The company or contact it tracks; `undefined` in a generic pipeline. */
70
+ readonly record: Company | Contact | undefined;
71
+ /** The record's name; `undefined` when the caller cannot see it or there is none. */
72
+ readonly recordName: string | undefined;
73
+ /** A company's domain or a contact's email. */
74
+ readonly recordDetail: string | undefined;
75
+ /** Its fields that hold a value, by name, as the response that returned it carried them. */
76
+ readonly fields: Record<string, PipelineFieldValue>;
77
+ private constructor();
78
+ /** @internal Seed from a workflow response of a pipeline tracking `recordType`, or nothing. */
79
+ static from(client: MacroClient, pipeline: CrmPipeline, recordType: 'company' | 'contact' | null | undefined, entry: Pick<PipelineEntryRecord, 'entryId' | 'record'> & {
80
+ fields?: PipelineEntryRecord['fields'];
81
+ }): PipelineEntry;
82
+ /**
83
+ * Set fields by name: a stage by its label, a person as `'me'` or an email,
84
+ * `null` to empty. Pass `baseVersion` (from {@link CrmPipeline.find}) to
85
+ * refuse the change if the pipeline changed since.
86
+ */
87
+ update(set: PipelineFieldInputs, options?: {
88
+ baseVersion?: number;
89
+ }): Promise<{
90
+ entry: PipelineEntry;
91
+ changes: PipelineFieldChange[];
92
+ version: number | undefined;
93
+ }>;
94
+ /** Delete this entry; its company or contact stays in the CRM. */
95
+ remove(): Promise<void>;
96
+ /** Serialize identity and the values read, without an authenticated client. */
97
+ toJSON(): {
98
+ id: string;
99
+ pipelineId: string;
100
+ record: {
101
+ id: string;
102
+ name: string | undefined;
103
+ detail: string | undefined;
104
+ } | undefined;
105
+ fields: Record<string, EntryFieldValue>;
106
+ };
107
+ }
108
+ /** @internal A field change with absent values as `undefined`. */
109
+ export declare function fieldChange(change: EntryFieldChange): PipelineFieldChange;