@myapihq/sdk 2.22.0 → 2.23.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.
- package/dist/crm.d.ts +37 -0
- package/dist/crm.js +35 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/crm.d.ts
CHANGED
|
@@ -116,6 +116,43 @@ export declare function deleteContact(apiKey: string, orgId: string, id: string)
|
|
|
116
116
|
export declare function restoreContact(apiKey: string, orgId: string, id: string): Promise<Contact>;
|
|
117
117
|
export declare function searchContacts(apiKey: string, orgId: string, filter?: ContactSearchFilter): Promise<ContactSearchResult>;
|
|
118
118
|
export declare function promoteContact(apiKey: string, orgId: string, goldfoxPersonId: string): Promise<Contact>;
|
|
119
|
+
/** One page of a bulk promotion: what it did, and where to resume. */
|
|
120
|
+
export interface PromoteAudienceResult {
|
|
121
|
+
audience_id: string;
|
|
122
|
+
created: number;
|
|
123
|
+
matched: number;
|
|
124
|
+
/** Goldfox rows with no address — the usual reason 400 becomes 260. */
|
|
125
|
+
skipped_no_email: number;
|
|
126
|
+
failed: number;
|
|
127
|
+
processed: number;
|
|
128
|
+
offset: number;
|
|
129
|
+
total: number;
|
|
130
|
+
has_more: boolean;
|
|
131
|
+
next_offset: number;
|
|
132
|
+
note: string;
|
|
133
|
+
}
|
|
134
|
+
export declare function promoteAudience(apiKey: string, orgId: string, audienceId: string, opts?: {
|
|
135
|
+
limit?: number;
|
|
136
|
+
offset?: number;
|
|
137
|
+
}): Promise<PromoteAudienceResult>;
|
|
138
|
+
/** A row the import could not use, with the reason and the line it was on. */
|
|
139
|
+
export interface SkippedImportRow {
|
|
140
|
+
line: number;
|
|
141
|
+
email?: string;
|
|
142
|
+
/** e.g. "no email", "not an address", "previously deleted". */
|
|
143
|
+
reason: string;
|
|
144
|
+
}
|
|
145
|
+
export interface ImportContactsResult {
|
|
146
|
+
created: number;
|
|
147
|
+
/** Already in CRM: matched, never overwritten. A soft-deleted address is
|
|
148
|
+
* NOT counted here — it comes back as a skipped row, since nothing was
|
|
149
|
+
* imported and the person is not present. */
|
|
150
|
+
matched: number;
|
|
151
|
+
skipped: number;
|
|
152
|
+
skipped_rows: SkippedImportRow[];
|
|
153
|
+
note: string;
|
|
154
|
+
}
|
|
155
|
+
export declare function importContacts(apiKey: string, orgId: string, csv: Blob | Buffer | string, filename?: string): Promise<ImportContactsResult>;
|
|
119
156
|
export declare function getContactEvents(apiKey: string, orgId: string, id: string, opts?: ListEventsOptions): Promise<EventsResponse>;
|
|
120
157
|
export declare function createCompany(apiKey: string, orgId: string, input: CreateCompanyInput): Promise<Company>;
|
|
121
158
|
export declare function getCompany(apiKey: string, orgId: string, id: string): Promise<Company>;
|
package/dist/crm.js
CHANGED
|
@@ -8,6 +8,8 @@ exports.deleteContact = deleteContact;
|
|
|
8
8
|
exports.restoreContact = restoreContact;
|
|
9
9
|
exports.searchContacts = searchContacts;
|
|
10
10
|
exports.promoteContact = promoteContact;
|
|
11
|
+
exports.promoteAudience = promoteAudience;
|
|
12
|
+
exports.importContacts = importContacts;
|
|
11
13
|
exports.getContactEvents = getContactEvents;
|
|
12
14
|
exports.createCompany = createCompany;
|
|
13
15
|
exports.getCompany = getCompany;
|
|
@@ -21,6 +23,8 @@ const config_1 = require("./config");
|
|
|
21
23
|
exports.EXPOSES = [
|
|
22
24
|
'POST /crm/orgs/{org_id}/contacts',
|
|
23
25
|
'POST /crm/orgs/{org_id}/contacts/promote',
|
|
26
|
+
'POST /crm/orgs/{org_id}/contacts/promote-audience',
|
|
27
|
+
'POST /crm/orgs/{org_id}/contacts/import',
|
|
24
28
|
'POST /crm/orgs/{org_id}/contacts/search',
|
|
25
29
|
'GET /crm/orgs/{org_id}/contacts/{id}',
|
|
26
30
|
'PATCH /crm/orgs/{org_id}/contacts/{id}',
|
|
@@ -61,6 +65,37 @@ async function searchContacts(apiKey, orgId, filter = {}) {
|
|
|
61
65
|
async function promoteContact(apiKey, orgId, goldfoxPersonId) {
|
|
62
66
|
return (0, client_1.request)('POST', `${config_1.CRM_BASE}/crm/orgs/${encodeURIComponent(orgId)}/contacts/promote`, apiKey, { goldfox_person_id: goldfoxPersonId });
|
|
63
67
|
}
|
|
68
|
+
// Promotes ONE page. Idempotent, so resuming or repeating a page costs a
|
|
69
|
+
// match rather than a duplicate of somebody with the same address.
|
|
70
|
+
async function promoteAudience(apiKey, orgId, audienceId, opts) {
|
|
71
|
+
return (0, client_1.request)('POST', `${config_1.CRM_BASE}/crm/orgs/${encodeURIComponent(orgId)}/contacts/promote-audience`, apiKey, {
|
|
72
|
+
audience_id: audienceId, limit: opts?.limit, offset: opts?.offset,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// Multipart, mirroring the container source upload. The server needs a `file`
|
|
76
|
+
// part; a raw CSV body is rejected with FILE_REQUIRED.
|
|
77
|
+
async function importContacts(apiKey, orgId, csv, filename = 'contacts.csv') {
|
|
78
|
+
const formData = new FormData();
|
|
79
|
+
const blob = typeof csv === 'string'
|
|
80
|
+
? new Blob([csv], { type: 'text/csv' })
|
|
81
|
+
: new Blob([csv], { type: 'text/csv' });
|
|
82
|
+
formData.append('file', blob, filename);
|
|
83
|
+
const response = await fetch(`${config_1.CRM_BASE}/crm/orgs/${encodeURIComponent(orgId)}/contacts/import`, { method: 'POST', headers: { Authorization: `Bearer ${apiKey}` }, body: formData });
|
|
84
|
+
let result;
|
|
85
|
+
try {
|
|
86
|
+
result = await response.json();
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
throw new client_1.MyApiError('invalid_json_response', response.status);
|
|
90
|
+
}
|
|
91
|
+
if (!response.ok || !result?.success) {
|
|
92
|
+
const err = result?.error;
|
|
93
|
+
const code = typeof err === 'object' ? (err?.code || 'unknown_error') : (err || 'unknown_error');
|
|
94
|
+
const detail = typeof err === 'object' ? err?.message : undefined;
|
|
95
|
+
throw new client_1.MyApiError(code, response.status, detail, typeof err === 'object' ? err : undefined);
|
|
96
|
+
}
|
|
97
|
+
return result.data;
|
|
98
|
+
}
|
|
64
99
|
async function getContactEvents(apiKey, orgId, id, opts = {}) {
|
|
65
100
|
const qs = new URLSearchParams();
|
|
66
101
|
if (opts.limit != null)
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.
|
|
1
|
+
export declare const SDK_VERSION = "2.23.0";
|
package/dist/version.js
CHANGED
|
@@ -8,4 +8,4 @@ exports.SDK_VERSION = void 0;
|
|
|
8
8
|
// Why a constant and not a package.json read: the SDK runs inside edge
|
|
9
9
|
// functions (Cloudflare Workers), so it must not import node:fs. A literal
|
|
10
10
|
// is the only version source that works in every runtime we ship to.
|
|
11
|
-
exports.SDK_VERSION = '2.
|
|
11
|
+
exports.SDK_VERSION = '2.23.0';
|