@prezly/sdk 15.18.0 → 15.20.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.
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DEFAULT_USER_AGENT = void 0;
7
- const VERSION = "15.17.0";
7
+ const VERSION = "15.19.0";
8
8
  const URL = 'https://github.com/prezly/javascript-sdk';
9
9
  const DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
10
10
  exports.DEFAULT_USER_AGENT = DEFAULT_USER_AGENT;
@@ -1,3 +1,3 @@
1
- const VERSION = "15.17.0";
1
+ const VERSION = "15.19.0";
2
2
  const URL = 'https://github.com/prezly/javascript-sdk';
3
3
  export const DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
@@ -128,22 +128,46 @@ class Client {
128
128
  return contact;
129
129
  }
130
130
  async bulkTag(selector, tags) {
131
+ const {
132
+ scope,
133
+ query
134
+ } = selector;
131
135
  return this.apiClient.patch(_routing.routing.contactsUrl, {
132
136
  payload: {
133
- scope: selector.scope,
134
- query: selector.query,
137
+ query,
138
+ scope,
135
139
  '+tags': tags
136
140
  }
137
141
  });
138
142
  }
139
143
  async bulkUntag(selector, tags) {
144
+ const {
145
+ query,
146
+ scope
147
+ } = selector;
140
148
  return this.apiClient.patch(_routing.routing.contactsUrl, {
141
149
  payload: {
142
- scope: selector.scope,
143
- query: selector.query,
150
+ query,
151
+ scope,
144
152
  '-tags': tags
145
153
  }
146
154
  });
147
155
  }
156
+ async delete(id) {
157
+ const url = `${_routing.routing.contactsUrl}/${id}`;
158
+ await this.apiClient.delete(url);
159
+ }
160
+ async bulkDelete(selector) {
161
+ const {
162
+ query,
163
+ scope
164
+ } = selector;
165
+ return this.apiClient.delete(_routing.routing.contactsUrl, {
166
+ payload: {
167
+ query,
168
+ scope
169
+ }
170
+ });
171
+ }
148
172
  }
149
173
  exports.Client = Client;
@@ -1,8 +1,7 @@
1
1
  import type { ProgressPromise } from '@prezly/progress-promise';
2
2
  import type { DeferredJobsApiClient } from '../../api';
3
3
  import type { Contact } from '../../types';
4
- import type { ContactsBulkSelector } from '../ContactsExports';
5
- import type { CreateRequest, ListOptions, ListResponse, SearchOptions, SearchResponse, UpdateRequest } from './types';
4
+ import type { BulkDeleteResponse, BulkSelector, CreateRequest, ListOptions, ListResponse, SearchOptions, SearchResponse, UpdateRequest } from './types';
6
5
  declare type TagId = number;
7
6
  declare type TagName = string;
8
7
  export declare class Client {
@@ -22,7 +21,9 @@ export declare class Client {
22
21
  update(id: Contact['id'], payload: UpdateRequest): Promise<Contact>;
23
22
  tag(id: Contact['id'], tags: (TagId | TagName)[]): Promise<Contact>;
24
23
  untag(id: Contact['id'], tags: (TagId | TagName)[]): Promise<Contact>;
25
- bulkTag(selector: ContactsBulkSelector, tags: (TagId | TagName)[]): ProgressPromise<undefined>;
26
- bulkUntag(selector: ContactsBulkSelector, tags: (TagId | TagName)[]): ProgressPromise<undefined>;
24
+ bulkTag(selector: BulkSelector, tags: (TagId | TagName)[]): ProgressPromise<undefined>;
25
+ bulkUntag(selector: BulkSelector, tags: (TagId | TagName)[]): ProgressPromise<undefined>;
26
+ delete(id: Contact['id']): Promise<void>;
27
+ bulkDelete(selector: BulkSelector): Promise<BulkDeleteResponse>;
27
28
  }
28
29
  export {};
@@ -122,21 +122,45 @@ export class Client {
122
122
  return contact;
123
123
  }
124
124
  async bulkTag(selector, tags) {
125
+ const {
126
+ scope,
127
+ query
128
+ } = selector;
125
129
  return this.apiClient.patch(routing.contactsUrl, {
126
130
  payload: {
127
- scope: selector.scope,
128
- query: selector.query,
131
+ query,
132
+ scope,
129
133
  '+tags': tags
130
134
  }
131
135
  });
132
136
  }
133
137
  async bulkUntag(selector, tags) {
138
+ const {
139
+ query,
140
+ scope
141
+ } = selector;
134
142
  return this.apiClient.patch(routing.contactsUrl, {
135
143
  payload: {
136
- scope: selector.scope,
137
- query: selector.query,
144
+ query,
145
+ scope,
138
146
  '-tags': tags
139
147
  }
140
148
  });
141
149
  }
150
+ async delete(id) {
151
+ const url = `${routing.contactsUrl}/${id}`;
152
+ await this.apiClient.delete(url);
153
+ }
154
+ async bulkDelete(selector) {
155
+ const {
156
+ query,
157
+ scope
158
+ } = selector;
159
+ return this.apiClient.delete(routing.contactsUrl, {
160
+ payload: {
161
+ query,
162
+ scope
163
+ }
164
+ });
165
+ }
142
166
  }
@@ -1,5 +1,6 @@
1
1
  import type { Contact, Pagination, Query } from '../../types';
2
2
  import type { SortOrder } from '../../types';
3
+ export type { ContactsBulkSelector as BulkSelector, ContactsScope as Scope } from '../../types';
3
4
  export interface ListOptions {
4
5
  limit?: number;
5
6
  offset?: number;
@@ -55,4 +56,6 @@ export interface PersonUpdateRequest extends BaseContactPayload {
55
56
  export interface PersonCreateRequest extends PersonUpdateRequest {
56
57
  contact_type: `${Contact.Type.PERSON}`;
57
58
  }
58
- export {};
59
+ export interface BulkDeleteResponse {
60
+ deleted_contacts_count: number;
61
+ }
@@ -1,4 +1,5 @@
1
- import type { ContactsExport, ContactsScope, Pagination, Query, SortOrder } from '../../types';
1
+ import type { ContactsExport, Pagination, Query, SortOrder } from '../../types';
2
+ export type { ContactsBulkSelector, ContactsScope } from '../../types';
2
3
  export interface ListOptions {
3
4
  limit?: number;
4
5
  offset?: number;
@@ -12,7 +13,3 @@ export interface ListResponse {
12
13
  pagination: Pagination;
13
14
  sort: string;
14
15
  }
15
- export interface ContactsBulkSelector {
16
- scope?: ContactsScope;
17
- query?: Query;
18
- }
@@ -14,6 +14,14 @@ export interface Campaign {
14
14
  */
15
15
  content: string;
16
16
  thumbnail_url: string;
17
+ /**
18
+ * This partially duplicates the `sender` property, but will always stay defined,
19
+ * even if the linked sender gets deleted later.
20
+ */
21
+ from: {
22
+ name: string;
23
+ email_address: string;
24
+ };
17
25
  story: StoryRef | null;
18
26
  newsroom: NewsroomRef | null;
19
27
  story_alignment: Campaign.StoryAlignment;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,6 @@
1
+ import type { Query } from './common';
2
+ import type { ContactsScope } from './ContactsScope';
3
+ export interface ContactsBulkSelector {
4
+ scope?: ContactsScope;
5
+ query?: Query;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -63,6 +63,16 @@ Object.keys(_ContactDuplicateSuggestion).forEach(function (key) {
63
63
  }
64
64
  });
65
65
  });
66
+ var _ContactsBulkSelector = require("./ContactsBulkSelector.cjs");
67
+ Object.keys(_ContactsBulkSelector).forEach(function (key) {
68
+ if (key === "default" || key === "__esModule") return;
69
+ Object.defineProperty(exports, key, {
70
+ enumerable: true,
71
+ get: function () {
72
+ return _ContactsBulkSelector[key];
73
+ }
74
+ });
75
+ });
66
76
  var _ContactsExport = require("./ContactsExport.cjs");
67
77
  Object.keys(_ContactsExport).forEach(function (key) {
68
78
  if (key === "default" || key === "__esModule") return;
@@ -4,6 +4,7 @@ export * from './Campaign';
4
4
  export * from './Category';
5
5
  export * from './Contact';
6
6
  export * from './ContactDuplicateSuggestion';
7
+ export * from './ContactsBulkSelector';
7
8
  export * from './ContactsExport';
8
9
  export * from './ContactsScope';
9
10
  export * from './Country';
@@ -5,6 +5,7 @@ export * from "./Campaign.js";
5
5
  export * from "./Category.js";
6
6
  export * from "./Contact.js";
7
7
  export * from "./ContactDuplicateSuggestion.js";
8
+ export * from "./ContactsBulkSelector.js";
8
9
  export * from "./ContactsExport.js";
9
10
  export * from "./ContactsScope.js";
10
11
  export * from "./Country.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prezly/sdk",
3
- "version": "15.18.0",
3
+ "version": "15.20.0",
4
4
  "description": "Prezly API SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",