@macro-inc/sdk 0.4.0 → 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 (193) hide show
  1. package/CALLS.md +82 -0
  2. package/README.md +176 -7
  3. package/dist/chunk-2IVGAIGQ.js +80 -0
  4. package/dist/{chunk-PTX2RV2N.js → chunk-3SW6QVDV.js} +33 -0
  5. package/dist/{chunk-XFA7NCJ5.js → chunk-GT5EUYOR.js} +13 -15
  6. package/dist/{chunk-ZLBDES7U.js → chunk-HIW6KU2I.js} +490 -4
  7. package/dist/{chunk-AZJUIUIV.js → chunk-J2VK3NOR.js} +56 -0
  8. package/dist/{chunk-PZPTJI6F.js → chunk-UVJLWLSJ.js} +41 -2
  9. package/dist/generated/agent-fold/index.d.ts +8 -6
  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 +17 -1
  13. package/dist/generated/agent-harness/types.gen.d.ts +188 -3
  14. package/dist/generated/auth/index.js +1 -1
  15. package/dist/generated/auth/sdk.gen.d.ts +13 -15
  16. package/dist/generated/auth/types.gen.d.ts +36 -17
  17. package/dist/generated/cognition/index.d.ts +1 -1
  18. package/dist/generated/cognition/index.js +1 -1
  19. package/dist/generated/cognition/sdk.gen.d.ts +38 -1
  20. package/dist/generated/cognition/types.gen.d.ts +473 -4
  21. package/dist/generated/connection/types.gen.d.ts +1 -1
  22. package/dist/generated/notification/index.d.ts +1 -1
  23. package/dist/generated/notification/types.gen.d.ts +36 -1
  24. package/dist/generated/scheduled-action/index.d.ts +1 -1
  25. package/dist/generated/scheduled-action/index.js +1 -1
  26. package/dist/generated/scheduled-action/sdk.gen.d.ts +17 -2
  27. package/dist/generated/scheduled-action/types.gen.d.ts +642 -104
  28. package/dist/generated/storage/index.d.ts +1 -1
  29. package/dist/generated/storage/index.js +1 -1
  30. package/dist/generated/storage/sdk.gen.d.ts +204 -5
  31. package/dist/generated/storage/types.gen.d.ts +3969 -374
  32. package/dist/src/calls/browser.d.ts +14 -0
  33. package/dist/src/calls/browser.js +102 -0
  34. package/dist/src/calls/common.d.ts +18 -0
  35. package/dist/src/calls/node.d.ts +24 -0
  36. package/dist/src/calls/node.js +145 -0
  37. package/dist/src/calls/telemetry.d.ts +5 -0
  38. package/dist/src/entities/account-managers/grant.d.ts +28 -5
  39. package/dist/src/entities/account-managers/namespace.d.ts +15 -3
  40. package/dist/src/entities/activity/entity.d.ts +7 -0
  41. package/dist/src/entities/activity/namespace.d.ts +58 -0
  42. package/dist/src/entities/activity/namespace.test.d.ts +1 -0
  43. package/dist/src/entities/agent-sessions/activity.d.ts +10 -2
  44. package/dist/src/entities/agent-sessions/agent-session.d.ts +193 -18
  45. package/dist/src/entities/agent-sessions/code-execution.d.ts +15 -3
  46. package/dist/src/entities/agent-sessions/conversation.d.ts +46 -9
  47. package/dist/src/entities/agent-sessions/namespace.d.ts +71 -16
  48. package/dist/src/entities/agent-sessions/origin.d.ts +1 -1
  49. package/dist/src/entities/agent-sessions/queued-action.d.ts +17 -3
  50. package/dist/src/entities/agent-sessions/review.d.ts +55 -4
  51. package/dist/src/entities/agent-sessions/tool-approval.d.ts +5 -1
  52. package/dist/src/entities/agents/agent.d.ts +98 -3
  53. package/dist/src/entities/agents/namespace.d.ts +52 -8
  54. package/dist/src/entities/ai/namespace.d.ts +9 -1
  55. package/dist/src/entities/api-keys/api-key.d.ts +6 -1
  56. package/dist/src/entities/api-keys/namespace.d.ts +15 -3
  57. package/dist/src/entities/bots/bot.d.ts +38 -6
  58. package/dist/src/entities/bots/namespace.d.ts +13 -1
  59. package/dist/src/entities/bots/token.d.ts +6 -1
  60. package/dist/src/entities/calendar/booking-link.d.ts +7 -1
  61. package/dist/src/entities/calendar/booking-namespace.d.ts +13 -0
  62. package/dist/src/entities/calendar/booking.d.ts +15 -0
  63. package/dist/src/entities/calendar/calendar.d.ts +7 -1
  64. package/dist/src/entities/calendar/event.d.ts +59 -9
  65. package/dist/src/entities/calendar/namespace.d.ts +88 -10
  66. package/dist/src/entities/calendar/replacement.d.ts +19 -3
  67. package/dist/src/entities/calls/call-record.d.ts +90 -14
  68. package/dist/src/entities/calls/connection.d.ts +7 -1
  69. package/dist/src/entities/calls/message.d.ts +27 -5
  70. package/dist/src/entities/calls/namespace.d.ts +15 -3
  71. package/dist/src/entities/canvases/canvas.d.ts +324 -0
  72. package/dist/src/entities/channels/access-request.d.ts +10 -2
  73. package/dist/src/entities/channels/activity.d.ts +20 -4
  74. package/dist/src/entities/channels/channel.d.ts +130 -23
  75. package/dist/src/entities/channels/labels.d.ts +41 -7
  76. package/dist/src/entities/channels/message.d.ts +41 -7
  77. package/dist/src/entities/channels/namespace.d.ts +28 -3
  78. package/dist/src/entities/channels/post.test.d.ts +1 -0
  79. package/dist/src/entities/channels/thread.d.ts +19 -3
  80. package/dist/src/entities/chats/chat.d.ts +56 -6
  81. package/dist/src/entities/chats/generation.d.ts +11 -2
  82. package/dist/src/entities/chats/namespace.d.ts +10 -2
  83. package/dist/src/entities/connected-apps/connected-app.d.ts +14 -1
  84. package/dist/src/entities/connected-apps/connector.d.ts +3 -0
  85. package/dist/src/entities/connected-apps/namespace.d.ts +16 -0
  86. package/dist/src/entities/crm/company.d.ts +63 -15
  87. package/dist/src/entities/crm/contact.d.ts +60 -13
  88. package/dist/src/entities/crm/namespace.d.ts +85 -11
  89. package/dist/src/entities/crm/pipeline-entry.d.ts +102 -0
  90. package/dist/src/entities/crm/pipeline.d.ts +271 -27
  91. package/dist/src/entities/crm/pipelines.d.ts +39 -2
  92. package/dist/src/entities/databases/column.d.ts +54 -7
  93. package/dist/src/entities/databases/database.d.ts +126 -12
  94. package/dist/src/entities/databases/namespace.d.ts +16 -4
  95. package/dist/src/entities/databases/row.d.ts +2 -0
  96. package/dist/src/entities/databases/saved-query.d.ts +145 -0
  97. package/dist/src/entities/databases/table.d.ts +64 -10
  98. package/dist/src/entities/databases/view.d.ts +27 -5
  99. package/dist/src/entities/databases/webhook.d.ts +8 -1
  100. package/dist/src/entities/documents/ai-edit.d.ts +2 -0
  101. package/dist/src/entities/documents/anchor.d.ts +12 -2
  102. package/dist/src/entities/documents/comment.d.ts +29 -5
  103. package/dist/src/entities/documents/document.d.ts +243 -20
  104. package/dist/src/entities/documents/markdown.d.ts +25 -0
  105. package/dist/src/entities/documents/namespace.d.ts +132 -13
  106. package/dist/src/entities/documents/skills.test.d.ts +1 -0
  107. package/dist/src/entities/documents/system-skill.d.ts +21 -1
  108. package/dist/src/entities/documents/text-comment.d.ts +41 -0
  109. package/dist/src/entities/documents/text-comment.test.d.ts +1 -0
  110. package/dist/src/entities/documents/version.d.ts +5 -1
  111. package/dist/src/entities/email/attachment.d.ts +3 -0
  112. package/dist/src/entities/email/draft.d.ts +61 -9
  113. package/dist/src/entities/email/filter.d.ts +12 -2
  114. package/dist/src/entities/email/label.d.ts +7 -1
  115. package/dist/src/entities/email/link.d.ts +5 -1
  116. package/dist/src/entities/email/message.d.ts +55 -8
  117. package/dist/src/entities/email/namespace.d.ts +127 -21
  118. package/dist/src/entities/email/thread.d.ts +99 -16
  119. package/dist/src/entities/entity-mentions/mention.d.ts +6 -1
  120. package/dist/src/entities/entity-mentions/namespace.d.ts +5 -1
  121. package/dist/src/entities/entity.d.ts +56 -6
  122. package/dist/src/entities/external-chat/chat.d.ts +62 -11
  123. package/dist/src/entities/external-chat/message.d.ts +1 -1
  124. package/dist/src/entities/external-chat/namespace.d.ts +5 -1
  125. package/dist/src/entities/external-chat/send.d.ts +10 -2
  126. package/dist/src/entities/favorites/namespace.d.ts +20 -3
  127. package/dist/src/entities/foreign/foreign-entity.d.ts +5 -1
  128. package/dist/src/entities/foreign/namespace.d.ts +4 -0
  129. package/dist/src/entities/forms/form.d.ts +71 -13
  130. package/dist/src/entities/forms/namespace.d.ts +10 -2
  131. package/dist/src/entities/forms/question.d.ts +35 -7
  132. package/dist/src/entities/forms/response.d.ts +25 -5
  133. package/dist/src/entities/forms/section.d.ts +15 -3
  134. package/dist/src/entities/github-pull-requests/namespace.d.ts +5 -1
  135. package/dist/src/entities/github-pull-requests/pull-request.d.ts +15 -3
  136. package/dist/src/entities/harnesses/harness.d.ts +51 -3
  137. package/dist/src/entities/harnesses/namespace.d.ts +53 -7
  138. package/dist/src/entities/harnesses/pairing.d.ts +12 -2
  139. package/dist/src/entities/images/image.d.ts +16 -5
  140. package/dist/src/entities/images/namespace.d.ts +8 -1
  141. package/dist/src/entities/initiatives/initiative.d.ts +117 -3
  142. package/dist/src/entities/initiatives/initiative.test.d.ts +1 -0
  143. package/dist/src/entities/initiatives/namespace.d.ts +69 -7
  144. package/dist/src/entities/me/namespace.d.ts +27 -2
  145. package/dist/src/entities/meetings/meeting.d.ts +45 -8
  146. package/dist/src/entities/meetings/namespace.d.ts +20 -4
  147. package/dist/src/entities/memory/namespace.d.ts +49 -0
  148. package/dist/src/entities/memory/namespace.test.d.ts +1 -0
  149. package/dist/src/entities/messages/discussion.d.ts +84 -0
  150. package/dist/src/entities/messages/thread.d.ts +19 -5
  151. package/dist/src/entities/notifications/namespace.d.ts +40 -7
  152. package/dist/src/entities/notifications/notification.d.ts +29 -5
  153. package/dist/src/entities/pins/namespace.d.ts +23 -4
  154. package/dist/src/entities/projects/namespace.d.ts +29 -0
  155. package/dist/src/entities/projects/project.d.ts +47 -6
  156. package/dist/src/entities/properties/namespace.d.ts +67 -11
  157. package/dist/src/entities/properties/namespace.test.d.ts +1 -0
  158. package/dist/src/entities/properties/property-definition.d.ts +30 -5
  159. package/dist/src/entities/properties/property-option.d.ts +14 -2
  160. package/dist/src/entities/referrals/namespace.d.ts +8 -1
  161. package/dist/src/entities/routines/namespace.d.ts +128 -7
  162. package/dist/src/entities/routines/routine.d.ts +111 -25
  163. package/dist/src/entities/saved-views/namespace.d.ts +57 -0
  164. package/dist/src/entities/saved-views/saved-view.d.ts +78 -0
  165. package/dist/src/entities/search/namespace.d.ts +5 -1
  166. package/dist/src/entities/sharing/access.d.ts +50 -9
  167. package/dist/src/entities/spreadsheets/spreadsheet.d.ts +201 -0
  168. package/dist/src/entities/tasks/namespace.d.ts +13 -1
  169. package/dist/src/entities/tasks/task.d.ts +7 -1
  170. package/dist/src/entities/teams/invite.d.ts +3 -0
  171. package/dist/src/entities/teams/namespace.d.ts +10 -2
  172. package/dist/src/entities/teams/team.d.ts +7 -0
  173. package/dist/src/entities/unfurls/namespace.d.ts +12 -2
  174. package/dist/src/entities/users/namespace.d.ts +19 -1
  175. package/dist/src/entities/users/profile-picture.d.ts +29 -0
  176. package/dist/src/entities/users/profile-picture.test.d.ts +1 -0
  177. package/dist/src/entities/users/user.d.ts +52 -1
  178. package/dist/src/entities/web/namespace.d.ts +6 -0
  179. package/dist/src/entities/webhooks/namespace.d.ts +5 -0
  180. package/dist/src/entities/webhooks/webhook.d.ts +47 -7
  181. package/dist/src/entities/whatsapp/account.d.ts +5 -1
  182. package/dist/src/entities/whatsapp/chat.d.ts +9 -1
  183. package/dist/src/entities/whatsapp/namespace.d.ts +7 -1
  184. package/dist/src/entities/workspace/namespace.d.ts +7 -1
  185. package/dist/src/entities/workspace/query.d.ts +5 -1
  186. package/dist/src/events/hydrate/user.d.ts +14 -0
  187. package/dist/src/events/receiver.d.ts +2 -0
  188. package/dist/src/events/types.d.ts +2 -1
  189. package/dist/src/macro.d.ts +33 -5
  190. package/dist/src/macro.js +15635 -10132
  191. package/dist/src/utils/lazy.d.ts +7 -1
  192. package/package.json +32 -5
  193. package/dist/src/entities/crm/comment.d.ts +0 -64
@@ -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;
@@ -1,10 +1,14 @@
1
- import type { AccessiblePipeline, CardPosition, ColumnDetail, CreatePipeline, DatabaseOp, DatabaseView as DatabaseViewRecord, StorageRow, StorageRowsQuery, TableDetail } from '../../../generated/storage/types.gen';
1
+ import type { AccessiblePipeline, CardPosition, ColumnDetail, CreatePipeline, DatabaseOp, DatabaseView as DatabaseViewRecord, EditPipelineRequest, StorageRow, StorageRowsQuery, TableDetail } from '../../../generated/storage/types.gen';
2
2
  import type { MacroClient } from '../../utils/client';
3
+ import { Document } from '../documents/document';
3
4
  import { MacroEntity } from '../entity';
4
5
  import { PropertyOption } from '../properties/property-option';
5
6
  import { type SharePermissionOptions } from '../sharing/permissions';
6
7
  import { Team } from '../teams/team';
7
8
  import { User } from '../users/user';
9
+ import { Company } from './company';
10
+ import { Contact } from './contact';
11
+ import { PipelineEntry, type PipelineField, type PipelineFieldChange, type PipelineFieldInputs, type PipelineFieldTotal, type PipelineImport, type PipelineOptionCounts, type PipelineRecordInput } from './pipeline-entry';
8
12
  /** Required fields for one option of a pipeline stage column. */
9
13
  export type PipelineStageRequirement = {
10
14
  stageColumn: PipelineColumn;
@@ -31,35 +35,221 @@ export declare class CrmPipeline extends MacroEntity<AccessiblePipeline> {
31
35
  readonly owner: () => Promise<User>;
32
36
  /** Owning team. */
33
37
  readonly team: () => Promise<Team>;
34
- /** Rename this pipeline. */
38
+ /**
39
+ * Rename this pipeline.
40
+ *
41
+ * @write
42
+ * @idempotent
43
+ */
35
44
  rename(name: string): Promise<void>;
36
- /** Change its sharing scope. */
45
+ /**
46
+ * Change its sharing scope.
47
+ *
48
+ * @write
49
+ * @idempotent
50
+ */
37
51
  setSharing(sharing: CreatePipeline['sharing']): Promise<void>;
38
- /** Trash or restore the pipeline. */
52
+ /**
53
+ * Trash or restore the pipeline.
54
+ *
55
+ * @destructive
56
+ * @idempotent
57
+ */
39
58
  setTrashed(trashed: boolean): Promise<void>;
40
- /** Read sharing grants. */
59
+ /**
60
+ * Read sharing grants.
61
+ *
62
+ * @readonly
63
+ */
41
64
  sharePermissions(): Promise<import("../../../generated/storage").SharePermissionV2>;
42
- /** Update sharing grants. */
65
+ /**
66
+ * Update sharing grants.
67
+ *
68
+ * @write
69
+ * @idempotent
70
+ */
43
71
  updateSharePermissions(options: SharePermissionOptions): Promise<import("../../../generated/storage").SharePermissionV2>;
44
- /** Read stage rules with column and option handles that survive renames. */
72
+ /**
73
+ * Read stage rules with column and option handles that survive renames.
74
+ *
75
+ * @readonly
76
+ */
45
77
  stageRequirements(): Promise<PipelineStageRequirement[]>;
46
- /** Require fields when entering a stage; an empty list removes that stage's rule. */
78
+ /**
79
+ * Require fields when entering a stage; an empty list removes that stage's rule.
80
+ *
81
+ * @write
82
+ * @idempotent
83
+ * @mcp-exclude Takes a handle built from a listing record, which an MCP call can't reference.
84
+ */
47
85
  setStageRequirements(stageColumn: PipelineColumn, stage: PropertyOption, requiredFields: PipelineColumn[]): Promise<void>;
48
- /** Read the backing table through the pipeline's authorization boundary. */
86
+ /**
87
+ * Read the backing table through the pipeline's authorization boundary.
88
+ *
89
+ * @readonly
90
+ */
49
91
  table(): Promise<PipelineTable>;
50
- /** Saved card order through this pipeline's authorization boundary. */
92
+ /**
93
+ * Saved card order through this pipeline's authorization boundary.
94
+ *
95
+ * @readonly
96
+ * @mcp-exclude Takes a handle built from a listing record, which an MCP call can't reference.
97
+ */
51
98
  viewPositions(view: PipelineView): Promise<CardPosition[]>;
52
- /** @internal Cached table snapshot shared by all pipeline table handles. */
99
+ /**
100
+ * @internal Cached table snapshot shared by all pipeline table handles.
101
+ *
102
+ * @readonly
103
+ * @mcp-exclude Internal cache accessor shared by pipeline handles.
104
+ */
53
105
  tableRecord(): Promise<TableDetail>;
54
- /** Rows in pipeline order, automatically paginated. */
106
+ /**
107
+ * Rows in pipeline order, automatically paginated.
108
+ *
109
+ * @readonly
110
+ */
55
111
  rows(): AsyncGenerator<PipelineRow>;
56
- /** Query pipeline rows, optionally restricting the query to typed row handles. */
112
+ /**
113
+ * Query pipeline rows, optionally restricting the query to typed row handles.
114
+ *
115
+ * @readonly
116
+ */
57
117
  queryRows(options?: {
58
118
  query?: StorageRowsQuery['query'];
59
119
  rows?: PipelineRow[];
60
120
  }): AsyncGenerator<PipelineRow>;
121
+ /**
122
+ * Add companies or contacts as entries (deals), filling fields by name: a
123
+ * stage by its label, a person as `'me'` or an email. A generic pipeline's
124
+ * entries name no record, only fields. A record already in the pipeline is
125
+ * not added again unless `allowDuplicates` (a separate second deal); its
126
+ * entry comes back in `alreadyPresent`.
127
+ *
128
+ * @write
129
+ */
130
+ addRecords(entries: {
131
+ record?: PipelineRecordInput;
132
+ set?: PipelineFieldInputs;
133
+ }[], options?: {
134
+ allowDuplicates?: boolean;
135
+ }): Promise<{
136
+ added: PipelineEntry[];
137
+ alreadyPresent: PipelineEntry[];
138
+ version: number | undefined;
139
+ }>;
140
+ /**
141
+ * Set fields of entries by name, all or nothing: a stage by its label, a
142
+ * person as `'me'` or an email, `null` to empty. Name an entry, or a company
143
+ * or contact with exactly one entry here. Pass `baseVersion` (from
144
+ * {@link CrmPipeline.find}) to refuse the change if the pipeline changed
145
+ * since. Each returned entry carries the fields the update set.
146
+ *
147
+ * @destructive
148
+ * @mcp-exclude Takes a pipeline entry built from a listing record, which an MCP call cannot reference.
149
+ */
150
+ updateEntries(updates: {
151
+ entry: PipelineEntry | Company | Contact;
152
+ set: PipelineFieldInputs;
153
+ }[], options?: {
154
+ baseVersion?: number;
155
+ }): Promise<{
156
+ updated: {
157
+ entry: PipelineEntry;
158
+ changes: PipelineFieldChange[];
159
+ }[];
160
+ version: number | undefined;
161
+ }>;
162
+ /**
163
+ * Delete entries: each entry given, and every entry of each company or
164
+ * contact given. The companies and contacts stay in the CRM. Returns the
165
+ * deleted entries as they were.
166
+ *
167
+ * @destructive
168
+ * @mcp-exclude Takes a pipeline entry built from a listing record, which an MCP call cannot reference.
169
+ */
170
+ removeRecords(targets: (PipelineEntry | Company | Contact)[]): Promise<{
171
+ removed: PipelineEntry[];
172
+ version: number | undefined;
173
+ }>;
174
+ /**
175
+ * Read entries by field name and label: `where` filters (`{ Stage: 'Demo' }`,
176
+ * a list for any of several, `null` for empty), only some companies or
177
+ * contacts, or a search of their names, domains and emails; sorted by a
178
+ * field. Also answers per-stage counts and number totals (such as Revenue)
179
+ * over every match, and the pipeline's fields and version.
180
+ *
181
+ * @param query.limit Most entries to return, 1 to 5000 (default 50); counts and totals cover every match.
182
+ *
183
+ * @readonly
184
+ */
185
+ find(query?: {
186
+ where?: PipelineFieldInputs;
187
+ records?: (Company | Contact)[];
188
+ search?: string;
189
+ sortBy?: string;
190
+ descending?: boolean;
191
+ limit?: number;
192
+ }): Promise<{
193
+ entries: PipelineEntry[];
194
+ matched: number;
195
+ complete: boolean;
196
+ counts: PipelineOptionCounts[];
197
+ totals: PipelineFieldTotal[];
198
+ fields: PipelineField[];
199
+ version: number;
200
+ }>;
201
+ /**
202
+ * Rename or share the pipeline and change its fields and options by name,
203
+ * in one change: add fields (text, number, checkbox, date, link, select,
204
+ * multi_select, person or people), rename or delete fields, and add,
205
+ * relabel or delete options (new Stage options become the last stages).
206
+ * Returns the fields and version afterwards.
207
+ *
208
+ * @destructive
209
+ */
210
+ edit(changes: EditPipelineRequest): Promise<{
211
+ fields: PipelineField[];
212
+ version: number;
213
+ }>;
214
+ /**
215
+ * Add a CSV's rows as entries: CSV text, or a CSV document. Columns match
216
+ * fields by name; Company and Domain (or Contact and Email) name each row's
217
+ * record, created when the team lacks it. Records already here are not
218
+ * added again, and select options the CSV needs are added.
219
+ *
220
+ * @write
221
+ */
222
+ importCsv(source: string | Document): Promise<PipelineImport>;
223
+ /**
224
+ * Every entry as CSV text: Company and Domain (or Contact and Email), then
225
+ * one column per field, people as emails; {@link CrmPipeline.importCsv}
226
+ * reads the same layout. `complete` is false past 5000 entries.
227
+ *
228
+ * @readonly
229
+ */
230
+ exportCsv(): Promise<{
231
+ csv: string;
232
+ name: string;
233
+ rows: number;
234
+ complete: boolean;
235
+ }>;
236
+ /** Save every entry as a CSV file in the caller's Macro files, laid out as {@link CrmPipeline.exportCsv} returns it.
237
+ *
238
+ * @write
239
+ */
240
+ exportCsvFile(): Promise<{
241
+ document: Document;
242
+ rows: number;
243
+ complete: boolean;
244
+ }>;
245
+ /** @internal Whether entries track companies or contacts; `undefined` for a generic pipeline. */
246
+ private trackedRecordType;
61
247
  /** Apply an atomic generated database operation batch through this pipeline.
62
- * As with Database.applyOps, batch-local UUIDs may name resources minted earlier in the batch. */
248
+ * As with Database.applyOps, batch-local UUIDs may name resources minted earlier in the batch.
249
+ *
250
+ * @destructive
251
+ * @mcp-exclude Takes a handle built from a listing record, which an MCP call can't reference.
252
+ */
63
253
  applyOps(ops: DatabaseOp[], options?: {
64
254
  baseVersions?: {
65
255
  table: PipelineTable;
@@ -67,7 +257,11 @@ export declare class CrmPipeline extends MacroEntity<AccessiblePipeline> {
67
257
  }[];
68
258
  }): Promise<import("../../../generated/storage").AppliedOps>;
69
259
  }
70
- /** Backing table of a CRM pipeline. */
260
+ /**
261
+ * Backing table of a CRM pipeline.
262
+ *
263
+ * @mcp-exclude Built from a listing record; no id-only reference an MCP call can pass.
264
+ */
71
265
  export declare class PipelineTable extends MacroEntity<TableDetail> {
72
266
  /** Parent pipeline. */
73
267
  readonly pipeline: CrmPipeline;
@@ -81,18 +275,42 @@ export declare class PipelineTable extends MacroEntity<TableDetail> {
81
275
  /** Seed a table from a pipeline table response. */
82
276
  static from(client: MacroClient, pipeline: CrmPipeline, record: TableDetail): PipelineTable;
83
277
  protected fetch(): Promise<TableDetail>;
84
- /** Columns in this table. */
278
+ /**
279
+ * Columns in this table.
280
+ *
281
+ * @readonly
282
+ */
85
283
  columns(): Promise<PipelineColumn[]>;
86
- /** Stored views in display order. */
284
+ /**
285
+ * Stored views in display order.
286
+ *
287
+ * @readonly
288
+ */
87
289
  views(): Promise<PipelineView[]>;
88
- /** Table version for optimistic operation batches. */
290
+ /**
291
+ * Table version for optimistic operation batches.
292
+ *
293
+ * @readonly
294
+ */
89
295
  version(): Promise<number>;
90
- /** A scoped row handle. */
296
+ /**
297
+ * A scoped row handle.
298
+ *
299
+ * @readonly
300
+ */
91
301
  rowById(id: string): PipelineRow;
92
- /** Rows from the authorized pipeline surface. */
302
+ /**
303
+ * Rows from the authorized pipeline surface.
304
+ *
305
+ * @readonly
306
+ */
93
307
  rows(): AsyncGenerator<PipelineRow>;
94
308
  }
95
- /** A view owned and authorized by its CRM pipeline. */
309
+ /**
310
+ * A view owned and authorized by its CRM pipeline.
311
+ *
312
+ * @mcp-exclude Its table is built from a listing record; no id-only reference an MCP call can pass.
313
+ */
96
314
  export declare class PipelineView {
97
315
  /** The pipeline table this view shows. */
98
316
  readonly table: PipelineTable;
@@ -101,12 +319,18 @@ export declare class PipelineView {
101
319
  private constructor();
102
320
  /** A handle to a stored view within a pipeline table. */
103
321
  static byId(table: PipelineTable, id: string): PipelineView;
104
- /** The current view definition from the pipeline's shared schema cache. */
322
+ /**
323
+ * The current view definition from the pipeline's shared schema cache.
324
+ *
325
+ * @readonly
326
+ */
105
327
  detail(): Promise<DatabaseViewRecord>;
106
328
  /**
107
329
  * Read only cards with saved positions; unplaced cards are omitted.
108
330
  * A saved lane may be stale after a row's grouping value changes outside a
109
331
  * card move. Compare each lane with the row's current grouping before using it.
332
+ *
333
+ * @readonly
110
334
  */
111
335
  positions(): Promise<CardPosition[]>;
112
336
  /** Serialize identity without an authenticated client. */
@@ -136,10 +360,18 @@ export declare class PipelineRow extends MacroEntity<StorageRow> {
136
360
  readonly cells: () => Promise<{
137
361
  [key: string]: import("../../../generated/storage").PropertyValue;
138
362
  }>;
139
- /** Reload this row after an operation batch. */
363
+ /**
364
+ * Reload this row after an operation batch.
365
+ *
366
+ * @readonly
367
+ */
140
368
  refresh(): Promise<void>;
141
369
  }
142
- /** A column belonging to a pipeline table. */
370
+ /**
371
+ * A column belonging to a pipeline table.
372
+ *
373
+ * @mcp-exclude Built from a listing record; no id-only reference an MCP call can pass.
374
+ */
143
375
  export declare class PipelineColumn extends MacroEntity<ColumnDetail> {
144
376
  /** Parent table. */
145
377
  readonly table: PipelineTable;
@@ -154,10 +386,22 @@ export declare class PipelineColumn extends MacroEntity<ColumnDetail> {
154
386
  /** Seed a column handle. */
155
387
  static from(client: MacroClient, table: PipelineTable, record: ColumnDetail): PipelineColumn;
156
388
  protected fetch(): Promise<ColumnDetail>;
157
- /** Selectable options, including stable stage identities for requirement rules. */
389
+ /**
390
+ * Selectable options, including stable stage identities for requirement rules.
391
+ *
392
+ * @readonly
393
+ */
158
394
  options(): Promise<PropertyOption[]>;
159
- /** Whether the caller can write this column. */
395
+ /**
396
+ * Whether the caller can write this column.
397
+ *
398
+ * @readonly
399
+ */
160
400
  writable(): Promise<boolean>;
161
- /** Current column label. */
401
+ /**
402
+ * Current column label.
403
+ *
404
+ * @readonly
405
+ */
162
406
  name(): Promise<string>;
163
407
  }