@bernierllc/nevarmail 0.21.0 → 0.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/README.md +11 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.js +61 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -166,6 +166,12 @@ the two, not both). The slug must exist in exactly one project the key can open:
|
|
|
166
166
|
| `listLists` / `createList` / `getList` | `/api/v1/lists` | `contacts:read` / `contacts:write` |
|
|
167
167
|
| `addListContacts` | `POST /api/v1/lists/{id}/contacts` | `contacts:write` |
|
|
168
168
|
| `listContacts` / `upsertContacts` / `updateContact` / `deleteContact` | `/api/v1/contacts` | `contacts:read` / `contacts:write` |
|
|
169
|
+
| `listBusinesses({ projectId?, page?, perPage? })` / `getBusiness(id, { projectId? })` | `GET /api/v1/businesses`, `GET /api/v1/businesses/{id}` | `contacts:read` |
|
|
170
|
+
| `createBusiness(input)` / `updateBusiness(id, input)` / `deleteBusiness(id, { projectId? })` — update replaces `domains`, merges `attributes`; delete keeps the contacts | `POST /api/v1/businesses`, `PATCH` / `DELETE /api/v1/businesses/{id}` | `contacts:write` |
|
|
171
|
+
| `upsertBusinessByExternalRef(system, ref, input)` — idempotent; returns `{ business, created }` | `PUT /api/v1/businesses/by-ref/{system}/{ref}` | `contacts:write` |
|
|
172
|
+
| `listBusinessMembers(id, { projectId?, page?, perPage? })` | `GET /api/v1/businesses/{id}/members` | `contacts:read` |
|
|
173
|
+
| `addBusinessMembers(id, members, { addedBy?, projectId? })` (max 100) / `removeBusinessMembers(id, { contactIds?, emails?, projectId? })` — memberships only | `POST` / `DELETE /api/v1/businesses/{id}/members` | `contacts:write` |
|
|
174
|
+
| `addBusinessMembersByDomain(id, { projectId? })` — adds contacts at the business's domains | `POST /api/v1/businesses/{id}/members/by-domain` | `contacts:write` |
|
|
169
175
|
| `listSenders` / `createSender(input)` — `input.projectId?` targets a project when the org has more than one | `/api/v1/senders` | `senders:read` / `senders:write` |
|
|
170
176
|
| `getSender` / `updateSender` / `deleteSender` | `/api/v1/senders/{id}` | `senders:read` / `senders:write` |
|
|
171
177
|
| `listUseCases({ projectId?, includeArchived? })` / `createUseCase(input)` — `input.projectId?` as for `createSender` | `/api/v1/use-cases` | `use-cases:read` / `use-cases:write` |
|
|
@@ -185,6 +191,11 @@ Application-level details worth knowing before you hit them:
|
|
|
185
191
|
`{ data, pagination: { page, perPage, total } }` — the envelope's pagination is the point of
|
|
186
192
|
calling a list route, so it is not unwrapped away. Single-resource methods return the payload
|
|
187
193
|
directly, same as the send methods.
|
|
194
|
+
- **Businesses.** `client.businesses` groups the ten business methods: `list`, `get`, `create`,
|
|
195
|
+
`update`, `delete`, `upsertByExternalRef`, `addByDomain` and `members.{list, add, remove}`, each
|
|
196
|
+
delegating to the flat method above. Tenancy: `projectId` goes in the query for `get`, `delete`
|
|
197
|
+
and `addByDomain`, and in the body for `update`, `createBusiness` and the member writes. Omit it
|
|
198
|
+
only when the org has one project.
|
|
188
199
|
- **Updates are `PATCH`, and partial.** Send only the fields you are changing.
|
|
189
200
|
- **Campaign reads take an optional `projectId`.** Omit it only when the org has one project;
|
|
190
201
|
otherwise the server answers 400 `PROJECT_REQUIRED`. A campaign in another project is a 404
|
package/dist/index.d.ts
CHANGED
|
@@ -139,6 +139,55 @@ export interface Paginated<T> {
|
|
|
139
139
|
data: T[];
|
|
140
140
|
pagination: V1Pagination;
|
|
141
141
|
}
|
|
142
|
+
export interface Business {
|
|
143
|
+
id: string;
|
|
144
|
+
name: string;
|
|
145
|
+
attributes: Record<string, unknown>;
|
|
146
|
+
domains: string[];
|
|
147
|
+
externalRefs: {
|
|
148
|
+
system: string;
|
|
149
|
+
ref: string;
|
|
150
|
+
}[];
|
|
151
|
+
defaultGroupId: string;
|
|
152
|
+
peopleCount: number;
|
|
153
|
+
createdAt: string;
|
|
154
|
+
updatedAt: string;
|
|
155
|
+
}
|
|
156
|
+
export interface BusinessMember {
|
|
157
|
+
contactId: string;
|
|
158
|
+
email: string;
|
|
159
|
+
name: string | null;
|
|
160
|
+
firstName: string | null;
|
|
161
|
+
lastName: string | null;
|
|
162
|
+
role: string | null;
|
|
163
|
+
addedBy: "manual" | "domain_rule" | "import" | "sync";
|
|
164
|
+
createdAt: string;
|
|
165
|
+
}
|
|
166
|
+
/** Fields for create/update/upsert. `attributes` merges on update; a null value deletes the key. */
|
|
167
|
+
export interface BusinessInput {
|
|
168
|
+
name: string;
|
|
169
|
+
domains?: string[];
|
|
170
|
+
attributes?: Record<string, unknown>;
|
|
171
|
+
/** Required when the org has more than one project and the key is not project-bound. */
|
|
172
|
+
projectId?: string;
|
|
173
|
+
}
|
|
174
|
+
export type BusinessMemberInput = ({
|
|
175
|
+
contactId: string;
|
|
176
|
+
} | {
|
|
177
|
+
email: string;
|
|
178
|
+
firstName?: string;
|
|
179
|
+
lastName?: string;
|
|
180
|
+
}) & {
|
|
181
|
+
role?: string;
|
|
182
|
+
};
|
|
183
|
+
export interface AddBusinessMembersResult {
|
|
184
|
+
added: number;
|
|
185
|
+
updated: number;
|
|
186
|
+
members: {
|
|
187
|
+
contactId: string;
|
|
188
|
+
email: string;
|
|
189
|
+
}[];
|
|
190
|
+
}
|
|
142
191
|
/** Delivery counters for one campaign, as the provider reports them. */
|
|
143
192
|
export interface CampaignStats {
|
|
144
193
|
sent: number;
|
|
@@ -530,6 +579,11 @@ export interface Suppression {
|
|
|
530
579
|
deactivatedBy: string | null;
|
|
531
580
|
deactivatedByName: string | null;
|
|
532
581
|
deactivationReason: string | null;
|
|
582
|
+
/**
|
|
583
|
+
* Set when this row was written because the same contact unsubscribed at
|
|
584
|
+
* another address (per-contact unsubscribe scope): that unsubscribe's id.
|
|
585
|
+
*/
|
|
586
|
+
fannedOutFromId?: string | null;
|
|
533
587
|
}
|
|
534
588
|
export interface ListSuppressionsOptions extends PageOptions {
|
|
535
589
|
reason?: SuppressionReason;
|
|
@@ -793,6 +847,110 @@ export declare class NevarMail {
|
|
|
793
847
|
email: string;
|
|
794
848
|
localMembershipsRemoved: number;
|
|
795
849
|
}>;
|
|
850
|
+
/** GET /api/v1/businesses — paged, sorted by name. */
|
|
851
|
+
listBusinesses(options?: PageOptions & {
|
|
852
|
+
projectId?: string;
|
|
853
|
+
}): Promise<Paginated<Business>>;
|
|
854
|
+
/** POST /api/v1/businesses — consumer mail domains are refused (400 CONSUMER_DOMAIN). */
|
|
855
|
+
createBusiness(input: BusinessInput & {
|
|
856
|
+
externalRef?: {
|
|
857
|
+
system: string;
|
|
858
|
+
ref: string;
|
|
859
|
+
};
|
|
860
|
+
}): Promise<Business>;
|
|
861
|
+
/** GET /api/v1/businesses/{id} */
|
|
862
|
+
getBusiness(id: string, opts?: {
|
|
863
|
+
projectId?: string;
|
|
864
|
+
}): Promise<Business>;
|
|
865
|
+
/** PATCH /api/v1/businesses/{id} — domains replaces the set. */
|
|
866
|
+
updateBusiness(id: string, input: Partial<BusinessInput>): Promise<Business>;
|
|
867
|
+
/** DELETE /api/v1/businesses/{id} — the contacts stay. */
|
|
868
|
+
deleteBusiness(id: string, opts?: {
|
|
869
|
+
projectId?: string;
|
|
870
|
+
}): Promise<{
|
|
871
|
+
deleted: true;
|
|
872
|
+
id: string;
|
|
873
|
+
}>;
|
|
874
|
+
/** PUT /api/v1/businesses/by-ref/{system}/{ref} — idempotent upsert by your system's id. */
|
|
875
|
+
upsertBusinessByExternalRef(system: string, ref: string, input: BusinessInput): Promise<{
|
|
876
|
+
business: Business;
|
|
877
|
+
created: boolean;
|
|
878
|
+
}>;
|
|
879
|
+
/** GET /api/v1/businesses/{id}/members */
|
|
880
|
+
listBusinessMembers(id: string, options?: PageOptions & {
|
|
881
|
+
projectId?: string;
|
|
882
|
+
}): Promise<Paginated<BusinessMember>>;
|
|
883
|
+
/** POST /api/v1/businesses/{id}/members — max 100; re-adding is a no-op, a given role replaces the role. */
|
|
884
|
+
addBusinessMembers(id: string, members: BusinessMemberInput[], opts?: {
|
|
885
|
+
addedBy?: "manual" | "import" | "sync";
|
|
886
|
+
projectId?: string;
|
|
887
|
+
}): Promise<AddBusinessMembersResult>;
|
|
888
|
+
/** DELETE /api/v1/businesses/{id}/members — memberships only; the contacts stay. */
|
|
889
|
+
removeBusinessMembers(id: string, who: {
|
|
890
|
+
contactIds?: string[];
|
|
891
|
+
emails?: string[];
|
|
892
|
+
projectId?: string;
|
|
893
|
+
}): Promise<{
|
|
894
|
+
removed: number;
|
|
895
|
+
}>;
|
|
896
|
+
/** POST /api/v1/businesses/{id}/members/by-domain — adds contacts at the business's domains. */
|
|
897
|
+
addBusinessMembersByDomain(id: string, opts?: {
|
|
898
|
+
projectId?: string;
|
|
899
|
+
}): Promise<{
|
|
900
|
+
added: number;
|
|
901
|
+
}>;
|
|
902
|
+
/** Grouped view of the business methods; each delegates to a flat method above. */
|
|
903
|
+
get businesses(): {
|
|
904
|
+
list: (o?: PageOptions & {
|
|
905
|
+
projectId?: string;
|
|
906
|
+
}) => Promise<Paginated<Business>>;
|
|
907
|
+
get: (id: string, o?: {
|
|
908
|
+
projectId?: string;
|
|
909
|
+
}) => Promise<Business>;
|
|
910
|
+
create: (input: BusinessInput & {
|
|
911
|
+
externalRef?: {
|
|
912
|
+
system: string;
|
|
913
|
+
ref: string;
|
|
914
|
+
};
|
|
915
|
+
}) => Promise<Business>;
|
|
916
|
+
update: (id: string, input: Partial<BusinessInput>) => Promise<Business>;
|
|
917
|
+
delete: (id: string, o?: {
|
|
918
|
+
projectId?: string;
|
|
919
|
+
}) => Promise<{
|
|
920
|
+
deleted: true;
|
|
921
|
+
id: string;
|
|
922
|
+
}>;
|
|
923
|
+
upsertByExternalRef: (system: string, ref: string, input: BusinessInput) => Promise<{
|
|
924
|
+
business: Business;
|
|
925
|
+
created: boolean;
|
|
926
|
+
}>;
|
|
927
|
+
addByDomain: (id: string, o?: {
|
|
928
|
+
projectId?: string;
|
|
929
|
+
}) => Promise<{
|
|
930
|
+
added: number;
|
|
931
|
+
}>;
|
|
932
|
+
members: {
|
|
933
|
+
list: (id: string, o?: PageOptions & {
|
|
934
|
+
projectId?: string;
|
|
935
|
+
}) => Promise<Paginated<BusinessMember>>;
|
|
936
|
+
add: (id: string, member: string | {
|
|
937
|
+
email: string;
|
|
938
|
+
firstName?: string;
|
|
939
|
+
lastName?: string;
|
|
940
|
+
}, opts?: {
|
|
941
|
+
role?: string;
|
|
942
|
+
addedBy?: "manual" | "import" | "sync";
|
|
943
|
+
projectId?: string;
|
|
944
|
+
}) => Promise<AddBusinessMembersResult>;
|
|
945
|
+
remove: (id: string, member: string | {
|
|
946
|
+
email: string;
|
|
947
|
+
}, opts?: {
|
|
948
|
+
projectId?: string;
|
|
949
|
+
}) => Promise<{
|
|
950
|
+
removed: number;
|
|
951
|
+
}>;
|
|
952
|
+
};
|
|
953
|
+
};
|
|
796
954
|
/** GET /api/v1/senders — paged. */
|
|
797
955
|
listSenders(options?: PageOptions): Promise<Paginated<Sender>>;
|
|
798
956
|
/** POST /api/v1/senders */
|
package/dist/index.js
CHANGED
|
@@ -411,6 +411,67 @@ export class NevarMail {
|
|
|
411
411
|
deleteContact(email) {
|
|
412
412
|
return this.request("DELETE", "/api/v1/contacts", { query: { email } });
|
|
413
413
|
}
|
|
414
|
+
/** GET /api/v1/businesses — paged, sorted by name. */
|
|
415
|
+
listBusinesses(options = {}) {
|
|
416
|
+
return this.requestPaginated("GET", "/api/v1/businesses", { query: { ...options } });
|
|
417
|
+
}
|
|
418
|
+
/** POST /api/v1/businesses — consumer mail domains are refused (400 CONSUMER_DOMAIN). */
|
|
419
|
+
createBusiness(input) {
|
|
420
|
+
return this.request("POST", "/api/v1/businesses", { body: input });
|
|
421
|
+
}
|
|
422
|
+
/** GET /api/v1/businesses/{id} */
|
|
423
|
+
getBusiness(id, opts = {}) {
|
|
424
|
+
return this.request("GET", `/api/v1/businesses/${encodeURIComponent(id)}`, { query: { ...opts } });
|
|
425
|
+
}
|
|
426
|
+
/** PATCH /api/v1/businesses/{id} — domains replaces the set. */
|
|
427
|
+
updateBusiness(id, input) {
|
|
428
|
+
return this.request("PATCH", `/api/v1/businesses/${encodeURIComponent(id)}`, { body: input });
|
|
429
|
+
}
|
|
430
|
+
/** DELETE /api/v1/businesses/{id} — the contacts stay. */
|
|
431
|
+
deleteBusiness(id, opts = {}) {
|
|
432
|
+
return this.request("DELETE", `/api/v1/businesses/${encodeURIComponent(id)}`, { query: { ...opts } });
|
|
433
|
+
}
|
|
434
|
+
/** PUT /api/v1/businesses/by-ref/{system}/{ref} — idempotent upsert by your system's id. */
|
|
435
|
+
upsertBusinessByExternalRef(system, ref, input) {
|
|
436
|
+
return this.request("PUT", `/api/v1/businesses/by-ref/${encodeURIComponent(system)}/${encodeURIComponent(ref)}`, { body: input });
|
|
437
|
+
}
|
|
438
|
+
/** GET /api/v1/businesses/{id}/members */
|
|
439
|
+
listBusinessMembers(id, options = {}) {
|
|
440
|
+
return this.requestPaginated("GET", `/api/v1/businesses/${encodeURIComponent(id)}/members`, { query: { ...options } });
|
|
441
|
+
}
|
|
442
|
+
/** POST /api/v1/businesses/{id}/members — max 100; re-adding is a no-op, a given role replaces the role. */
|
|
443
|
+
addBusinessMembers(id, members, opts = {}) {
|
|
444
|
+
return this.request("POST", `/api/v1/businesses/${encodeURIComponent(id)}/members`, { body: { members, ...opts } });
|
|
445
|
+
}
|
|
446
|
+
/** DELETE /api/v1/businesses/{id}/members — memberships only; the contacts stay. */
|
|
447
|
+
removeBusinessMembers(id, who) {
|
|
448
|
+
return this.request("DELETE", `/api/v1/businesses/${encodeURIComponent(id)}/members`, { body: who });
|
|
449
|
+
}
|
|
450
|
+
/** POST /api/v1/businesses/{id}/members/by-domain — adds contacts at the business's domains. */
|
|
451
|
+
addBusinessMembersByDomain(id, opts = {}) {
|
|
452
|
+
return this.request("POST", `/api/v1/businesses/${encodeURIComponent(id)}/members/by-domain`, { query: { ...opts } });
|
|
453
|
+
}
|
|
454
|
+
/** Grouped view of the business methods; each delegates to a flat method above. */
|
|
455
|
+
get businesses() {
|
|
456
|
+
return {
|
|
457
|
+
list: (o) => this.listBusinesses(o),
|
|
458
|
+
get: (id, o) => this.getBusiness(id, o),
|
|
459
|
+
create: (input) => this.createBusiness(input),
|
|
460
|
+
update: (id, input) => this.updateBusiness(id, input),
|
|
461
|
+
delete: (id, o) => this.deleteBusiness(id, o),
|
|
462
|
+
upsertByExternalRef: (system, ref, input) => this.upsertBusinessByExternalRef(system, ref, input),
|
|
463
|
+
addByDomain: (id, o) => this.addBusinessMembersByDomain(id, o),
|
|
464
|
+
members: {
|
|
465
|
+
list: (id, o) => this.listBusinessMembers(id, o),
|
|
466
|
+
add: (id, member, opts = {}) => {
|
|
467
|
+
const { role, ...rest } = opts;
|
|
468
|
+
const m = typeof member === "string" ? { contactId: member } : member;
|
|
469
|
+
return this.addBusinessMembers(id, [role === undefined ? m : { ...m, role }], rest);
|
|
470
|
+
},
|
|
471
|
+
remove: (id, member, opts = {}) => this.removeBusinessMembers(id, typeof member === "string" ? { contactIds: [member], ...opts } : { emails: [member.email], ...opts }),
|
|
472
|
+
},
|
|
473
|
+
};
|
|
474
|
+
}
|
|
414
475
|
// ── Senders ────────────────────────────────────────────────────────────
|
|
415
476
|
/** GET /api/v1/senders — paged. */
|
|
416
477
|
listSenders(options = {}) {
|
package/package.json
CHANGED