@prezly/sdk 11.3.1 → 11.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.
package/dist/Client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Accounts, Billing, Campaigns, CampaignRecipients, Coverage, Jobs, Licenses, Newsrooms, NewsroomCategories, NewsroomContacts, NewsroomLanguages, NewsroomThemes, NewsroomWebhooks, NewsroomPrivacyRequests, NewsroomDomains, NewsroomGalleries, SenderAddresses, Signup, Stories, Snippets, Subscriptions, NotificationSubscriptions } from './endpoints';
1
+ import { Accounts, Billing, Campaigns, CampaignRecipients, ContactsExports, Coverage, Jobs, Licenses, Newsrooms, NewsroomCategories, NewsroomContacts, NewsroomLanguages, NewsroomThemes, NewsroomWebhooks, NewsroomPrivacyRequests, NewsroomDomains, NewsroomGalleries, SenderAddresses, Signup, Stories, Snippets, Subscriptions, NotificationSubscriptions } from './endpoints';
2
2
  import type { HeadersMap } from './http';
3
3
  export interface ClientOptions {
4
4
  accessToken: string;
@@ -10,6 +10,7 @@ export interface Client {
10
10
  billing: Billing.Client;
11
11
  campaigns: Campaigns.Client;
12
12
  campaignRecipients: CampaignRecipients.Client;
13
+ contactsExports: ContactsExports.Client;
13
14
  coverage: Coverage.Client;
14
15
  jobs: Jobs.Client;
15
16
  licenses: Licenses.Client;
package/dist/Client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ApiClient, DeferredJobsApiClient } from "./api/index.js";
2
- import { Accounts, Billing, Campaigns, CampaignRecipients, Coverage, Jobs, Licenses, Newsrooms, NewsroomCategories, NewsroomContacts, NewsroomLanguages, NewsroomThemes, NewsroomWebhooks, NewsroomPrivacyRequests, NewsroomDomains, NewsroomGalleries, SenderAddresses, Signup, Stories, Snippets, Subscriptions, NotificationSubscriptions } from "./endpoints/index.js";
2
+ import { Accounts, Billing, Campaigns, CampaignRecipients, ContactsExports, Coverage, Jobs, Licenses, Newsrooms, NewsroomCategories, NewsroomContacts, NewsroomLanguages, NewsroomThemes, NewsroomWebhooks, NewsroomPrivacyRequests, NewsroomDomains, NewsroomGalleries, SenderAddresses, Signup, Stories, Snippets, Subscriptions, NotificationSubscriptions } from "./endpoints/index.js";
3
3
  const DEFAULT_BASE_URL = 'https://api.prezly.com';
4
4
  export function createClient({
5
5
  accessToken,
@@ -16,6 +16,7 @@ export function createClient({
16
16
  billing: new Billing.Client(apiClient),
17
17
  campaigns: new Campaigns.Client(apiClient),
18
18
  campaignRecipients: new CampaignRecipients.Client(apiClient),
19
+ contactsExports: new ContactsExports.Client(apiClient),
19
20
  coverage: new Coverage.Client(apiClient),
20
21
  jobs: new Jobs.Client(apiClient),
21
22
  licenses: new Licenses.Client(apiClient),
@@ -1,3 +1,3 @@
1
- const VERSION = "11.3.0";
1
+ const VERSION = "11.4.0";
2
2
  const URL = 'https://github.com/prezly/javascript-sdk';
3
3
  export const DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
@@ -1,8 +1,7 @@
1
1
  import type { DeferredJobsApiClient } from '../../api';
2
- import type { Campaign, Contact, EmailRecipient } from '../../types';
2
+ import type { Campaign, Contact, ContactsScope, EmailRecipient } from '../../types';
3
3
  import { Query } from '../../types';
4
4
  import type { RecipientsOperationResponse } from '../Campaigns';
5
- import type { ContactsScope } from './scopes';
6
5
  import type { ListOptions, ListResponse, SearchOptions } from './types';
7
6
  declare type CampaignId = Campaign['id'];
8
7
  declare type ContactId = Contact['id'];
@@ -1,3 +1,3 @@
1
1
  export * from './Client';
2
- export * from './scopes';
3
2
  export * from './types';
3
+ export { ContactsScope } from '../../types';
@@ -1,3 +1,3 @@
1
1
  export * from "./Client.js";
2
- export * from "./scopes.js";
3
- export * from "./types.js";
2
+ export * from "./types.js";
3
+ export { ContactsScope } from "../../types/index.js"; // convenience shortcut & BC
@@ -0,0 +1,36 @@
1
+ import type { DeferredJobsApiClient } from '../../api';
2
+ import type { ContactsExport } from '../../types';
3
+ import type { ContactsBulkSelector, ListOptions, ListResponse, SearchOptions } from './types';
4
+ export declare class Client {
5
+ private readonly apiClient;
6
+ constructor(apiClient: DeferredJobsApiClient);
7
+ /**
8
+ * List Contacts Exports with sorting, and pagination.
9
+ */
10
+ list(options: ListOptions): Promise<ListResponse>;
11
+ /**
12
+ * List Contacts Exports with sorting, pagination, and filtering.
13
+ */
14
+ search(options: SearchOptions): Promise<ListResponse>;
15
+ /**
16
+ * Fetch Contacts Export object by its uuid.
17
+ */
18
+ get(uuid: ContactsExport['uuid']): Promise<ContactsExport>;
19
+ /**
20
+ * Request export of the given selection of Contacts.
21
+ * If the selection size is small enough, it can be processed right away,
22
+ * returning an export with `status: "done"`.
23
+ *
24
+ * Otherwise, returns an export with `status: "new"`,
25
+ * and will notify the user over email when it's done.
26
+ */
27
+ create(selector: ContactsBulkSelector): Promise<ContactsExport>;
28
+ /**
29
+ * Fetch a download URL to retrieve the given Contacts Export file.
30
+ * Only works for exports with status = "done"
31
+ * Fails with Method Not Allowed (405) error for pending and failed exports.
32
+ */
33
+ download(uuid: ContactsExport['uuid']): Promise<{
34
+ downloadUrl: string;
35
+ }>;
36
+ }
@@ -0,0 +1,91 @@
1
+ import { routing } from "../../routing.js";
2
+ export class Client {
3
+ constructor(apiClient) {
4
+ this.apiClient = apiClient;
5
+ }
6
+
7
+ /**
8
+ * List Contacts Exports with sorting, and pagination.
9
+ */
10
+ async list(options) {
11
+ const {
12
+ limit,
13
+ offset,
14
+ sortOrder
15
+ } = options;
16
+ return this.apiClient.get(routing.contactsExportsUrl, {
17
+ query: {
18
+ limit,
19
+ offset,
20
+ sort: sortOrder
21
+ }
22
+ });
23
+ }
24
+
25
+ /**
26
+ * List Contacts Exports with sorting, pagination, and filtering.
27
+ */
28
+ async search(options) {
29
+ const {
30
+ query,
31
+ limit,
32
+ offset,
33
+ sortOrder
34
+ } = options;
35
+ const url = `${routing.contactsExportsUrl}/search`;
36
+ return this.apiClient.post(url, {
37
+ payload: {
38
+ limit,
39
+ offset,
40
+ query,
41
+ sort: sortOrder
42
+ }
43
+ });
44
+ }
45
+
46
+ /**
47
+ * Fetch Contacts Export object by its uuid.
48
+ */
49
+ async get(uuid) {
50
+ const url = `${routing.contactsExportsUrl}/${uuid}`;
51
+ const response = await this.apiClient.get(url);
52
+ return response.export;
53
+ }
54
+
55
+ /**
56
+ * Request export of the given selection of Contacts.
57
+ * If the selection size is small enough, it can be processed right away,
58
+ * returning an export with `status: "done"`.
59
+ *
60
+ * Otherwise, returns an export with `status: "new"`,
61
+ * and will notify the user over email when it's done.
62
+ */
63
+ async create(selector) {
64
+ const {
65
+ query,
66
+ scope
67
+ } = selector;
68
+ const response = await this.apiClient.post(routing.contactsExportsUrl, {
69
+ payload: {
70
+ contacts: {
71
+ query,
72
+ scope
73
+ }
74
+ }
75
+ });
76
+ return response.export;
77
+ }
78
+
79
+ /**
80
+ * Fetch a download URL to retrieve the given Contacts Export file.
81
+ * Only works for exports with status = "done"
82
+ * Fails with Method Not Allowed (405) error for pending and failed exports.
83
+ */
84
+ async download(uuid) {
85
+ const url = `${routing.contactsExportsUrl}/${uuid}/download`;
86
+ const response = await this.apiClient.post(url);
87
+ return {
88
+ downloadUrl: response.download_url
89
+ };
90
+ }
91
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Client';
2
+ export * from './types';
3
+ export { ContactsScope } from '../../types';
@@ -0,0 +1,3 @@
1
+ export * from "./Client.js";
2
+ export * from "./types.js";
3
+ export { ContactsScope } from "../../types/index.js"; // convenience shortcut
@@ -0,0 +1,18 @@
1
+ import type { ContactsExport, ContactsScope, Pagination, Query } from '../../types';
2
+ export interface ListOptions {
3
+ limit?: number;
4
+ offset?: number;
5
+ sortOrder?: string;
6
+ }
7
+ export interface SearchOptions extends ListOptions {
8
+ query?: Query;
9
+ }
10
+ export interface ListResponse {
11
+ exports: ContactsExport[];
12
+ pagination: Pagination;
13
+ sort: string;
14
+ }
15
+ export interface ContactsBulkSelector {
16
+ scope?: ContactsScope;
17
+ query?: Query;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -2,6 +2,7 @@ export * as Accounts from './Accounts';
2
2
  export * as Billing from './Billing';
3
3
  export * as CampaignRecipients from './CampaignRecipients';
4
4
  export * as Campaigns from './Campaigns';
5
+ export * as ContactsExports from './ContactsExports';
5
6
  export * as Coverage from './Coverage';
6
7
  export * as Jobs from './Jobs';
7
8
  export * as Licenses from './Licenses';
@@ -2,6 +2,7 @@ export * as Accounts from "./Accounts/index.js";
2
2
  export * as Billing from "./Billing/index.js";
3
3
  export * as CampaignRecipients from "./CampaignRecipients/index.js";
4
4
  export * as Campaigns from "./Campaigns/index.js";
5
+ export * as ContactsExports from "./ContactsExports/index.js";
5
6
  export * as Coverage from "./Coverage/index.js";
6
7
  export * as Jobs from "./Jobs/index.js";
7
8
  export * as Licenses from "./Licenses/index.js";
package/dist/routing.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const routing: {
3
3
  billing: string;
4
4
  campaignsUrl: string;
5
5
  campaignRecipientsUrl: string;
6
+ contactsExportsUrl: string;
6
7
  coverageUrl: string;
7
8
  jobsUrl: string;
8
9
  licenseUrl: string;
package/dist/routing.js CHANGED
@@ -3,6 +3,7 @@ export const routing = {
3
3
  billing: 'v2/billing',
4
4
  campaignsUrl: '/v2/campaigns',
5
5
  campaignRecipientsUrl: '/v2/campaigns/:campaign_id/recipients',
6
+ contactsExportsUrl: '/v2/contacts/exports',
6
7
  coverageUrl: '/v2/coverage',
7
8
  jobsUrl: '/v2/jobs',
8
9
  licenseUrl: '/v2/licenses',
@@ -0,0 +1,18 @@
1
+ import type { UserRef } from './User';
2
+ declare type Iso8601DateTime = string;
3
+ export interface ContactsExport {
4
+ uuid: string;
5
+ status: ContactsExport.Status;
6
+ contacts_count: number;
7
+ user: UserRef;
8
+ created_at: Iso8601DateTime;
9
+ updated_at: Iso8601DateTime;
10
+ }
11
+ export declare namespace ContactsExport {
12
+ enum Status {
13
+ NEW = "new",
14
+ DONE = "done",
15
+ FAILED = "failed"
16
+ }
17
+ }
18
+ export {};
@@ -0,0 +1,10 @@
1
+ export let ContactsExport;
2
+ (function (_ContactsExport) {
3
+ let Status;
4
+ (function (Status) {
5
+ Status["NEW"] = "new";
6
+ Status["DONE"] = "done";
7
+ Status["FAILED"] = "failed";
8
+ })(Status || (Status = {}));
9
+ _ContactsExport.Status = Status;
10
+ })(ContactsExport || (ContactsExport = {}));
@@ -0,0 +1,39 @@
1
+ import type { Campaign } from './Campaign';
2
+ import type { SelectionValue } from './common';
3
+ import type { Contact } from './Contact';
4
+ import type { EmailRecipient } from './EmailRecipient';
5
+ export declare type ContactsScope = ContactsScope.AllContactsScope | ContactsScope.ContactOrganisationsScope | ContactsScope.ContactEmployeesScope | ContactsScope.CampaignRecipientsScope | ContactsScope.CampaignReportScope;
6
+ export declare namespace ContactsScope {
7
+ enum Type {
8
+ ALL_CONTACTS = "scope:contacts",
9
+ CONTACT_EMPLOYEES = "scope:contact_employees",
10
+ CONTACT_ORGANISATIONS = "scope:contact_organisations",
11
+ CAMPAIGN_RECIPIENTS = "scope:campaign_recipients",
12
+ CAMPAIGN_REPORT = "scope:campaign_report"
13
+ }
14
+ interface AllContactsScope {
15
+ type: ContactsScope.Type.ALL_CONTACTS;
16
+ selection?: SelectionValue<Contact['id']>;
17
+ }
18
+ interface ContactOrganisationsScope {
19
+ type: ContactsScope.Type.CONTACT_ORGANISATIONS;
20
+ contact_id: Contact['id'];
21
+ selection?: SelectionValue<Contact['id']>;
22
+ }
23
+ interface ContactEmployeesScope {
24
+ type: ContactsScope.Type.CONTACT_EMPLOYEES;
25
+ contact_id: Contact['id'];
26
+ selection?: SelectionValue<Contact['id']>;
27
+ }
28
+ interface CampaignRecipientsScope {
29
+ type: ContactsScope.Type.CAMPAIGN_RECIPIENTS;
30
+ campaign_id: Campaign['id'];
31
+ selection?: SelectionValue<EmailRecipient['id']>;
32
+ }
33
+ interface CampaignReportScope {
34
+ type: ContactsScope.Type.CAMPAIGN_REPORT;
35
+ campaign_id: Campaign['id'];
36
+ report: 'recipients' | 'sent' | 'clicked' | 'opened' | 'unopened' | 'undelivered' | 'unsubscribed';
37
+ selection?: SelectionValue<EmailRecipient['id']>;
38
+ }
39
+ }
@@ -72,6 +72,8 @@ export interface Newsroom extends NewsroomRef {
72
72
  cultures: CultureRef[];
73
73
  campaigns_number: number;
74
74
  stories_number: number;
75
+ pitches_number: number;
76
+ coverage_number: number;
75
77
  public_galleries_number: number;
76
78
  square_logo: UploadedImage | null;
77
79
  newsroom_logo: UploadedImage | null;
@@ -2,6 +2,8 @@ export * from './common';
2
2
  export * from './Campaign';
3
3
  export * from './Category';
4
4
  export * from './Contact';
5
+ export * from './ContactsExport';
6
+ export * from './ContactsScope';
5
7
  export * from './Country';
6
8
  export * from './CoverageEntry';
7
9
  export * from './Culture';
@@ -3,6 +3,8 @@ export * from "./common/index.js"; // Entities
3
3
  export * from "./Campaign.js";
4
4
  export * from "./Category.js";
5
5
  export * from "./Contact.js";
6
+ export * from "./ContactsExport.js";
7
+ export * from "./ContactsScope.js";
6
8
  export * from "./Country.js";
7
9
  export * from "./CoverageEntry.js";
8
10
  export * from "./Culture.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prezly/sdk",
3
- "version": "11.3.1",
3
+ "version": "11.5.0",
4
4
  "description": "Prezly API SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,36 +0,0 @@
1
- import type { Campaign, Contact, EmailRecipient, SelectionValue } from '../../types';
2
- export interface AllContactsScope {
3
- type: ContactsScope.Type.ALL_CONTACTS;
4
- selection?: SelectionValue<Contact['id']>;
5
- }
6
- export interface ContactOrganisationsScope {
7
- type: ContactsScope.Type.CONTACT_ORGANISATIONS;
8
- contact_id: Contact['id'];
9
- selection?: SelectionValue<Contact['id']>;
10
- }
11
- export interface ContactEmployeesScope {
12
- type: ContactsScope.Type.CONTACT_EMPLOYEES;
13
- contact_id: Contact['id'];
14
- selection?: SelectionValue<Contact['id']>;
15
- }
16
- export interface CampaignRecipientsScope {
17
- type: ContactsScope.Type.CAMPAIGN_RECIPIENTS;
18
- campaign_id: Campaign['id'];
19
- selection?: SelectionValue<EmailRecipient['id']>;
20
- }
21
- export interface CampaignReportScope {
22
- type: ContactsScope.Type.CAMPAIGN_REPORT;
23
- campaign_id: Campaign['id'];
24
- report: 'recipients' | 'sent' | 'clicked' | 'opened' | 'unopened' | 'undelivered' | 'unsubscribed';
25
- selection?: SelectionValue<EmailRecipient['id']>;
26
- }
27
- export declare type ContactsScope = AllContactsScope | ContactOrganisationsScope | ContactEmployeesScope | CampaignRecipientsScope | CampaignReportScope;
28
- export declare namespace ContactsScope {
29
- enum Type {
30
- ALL_CONTACTS = "scope:contacts",
31
- CONTACT_EMPLOYEES = "scope:contact_employees",
32
- CONTACT_ORGANISATIONS = "scope:contact_organisations",
33
- CAMPAIGN_RECIPIENTS = "scope:campaign_recipients",
34
- CAMPAIGN_REPORT = "scope:campaign_report"
35
- }
36
- }