@prezly/sdk 25.6.0 → 25.7.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.cjs +4 -2
- package/dist/Client.d.ts +4 -2
- package/dist/Client.js +4 -2
- package/dist/api/constants.cjs +1 -1
- package/dist/api/constants.js +1 -1
- package/dist/endpoints/Billing/types.cjs +6 -6
- package/dist/endpoints/Billing/types.js +6 -6
- package/dist/endpoints/ContactTagGroups/types.cjs +3 -3
- package/dist/endpoints/ContactTagGroups/types.js +3 -3
- package/dist/endpoints/PricingTables/types.cjs +12 -12
- package/dist/endpoints/PricingTables/types.js +12 -12
- package/dist/endpoints/Stories/Client.d.ts +1 -1
- package/dist/endpoints/Subscriptions/types.cjs +3 -3
- package/dist/endpoints/Subscriptions/types.js +3 -3
- package/dist/http/HttpClient.cjs +6 -5
- package/dist/http/HttpClient.d.ts +6 -2
- package/dist/http/HttpClient.js +6 -5
- package/dist/http/createRequest.cjs +4 -2
- package/dist/http/createRequest.d.ts +3 -2
- package/dist/http/createRequest.js +4 -2
- package/dist/http/types.cjs +6 -6
- package/dist/http/types.js +6 -6
- package/dist/types/BillingCycle.cjs +3 -3
- package/dist/types/BillingCycle.js +3 -3
- package/dist/types/Campaign.cjs +18 -18
- package/dist/types/Campaign.js +18 -18
- package/dist/types/Category.cjs +1 -0
- package/dist/types/Category.js +1 -0
- package/dist/types/Contact.cjs +18 -18
- package/dist/types/Contact.js +18 -18
- package/dist/types/ContactDuplicateSuggestion.cjs +3 -3
- package/dist/types/ContactDuplicateSuggestion.js +4 -3
- package/dist/types/ContactTag.cjs +2 -1
- package/dist/types/ContactTag.js +2 -1
- package/dist/types/ContactsExport.cjs +3 -3
- package/dist/types/ContactsExport.js +3 -3
- package/dist/types/ContactsScope.cjs +3 -3
- package/dist/types/ContactsScope.js +3 -3
- package/dist/types/CoverageEntry.cjs +9 -9
- package/dist/types/CoverageEntry.js +9 -9
- package/dist/types/CoverageIntegration.cjs +3 -3
- package/dist/types/CoverageIntegration.js +3 -3
- package/dist/types/CoverageIntegrationRun.cjs +3 -3
- package/dist/types/CoverageIntegrationRun.js +3 -3
- package/dist/types/Culture.cjs +3 -3
- package/dist/types/Culture.js +3 -3
- package/dist/types/Currency.cjs +3 -3
- package/dist/types/Currency.js +3 -3
- package/dist/types/EmailRecipient.cjs +6 -6
- package/dist/types/EmailRecipient.js +6 -6
- package/dist/types/JobState.cjs +3 -3
- package/dist/types/JobState.js +3 -3
- package/dist/types/License.cjs +12 -12
- package/dist/types/License.js +12 -12
- package/dist/types/Newsroom.cjs +12 -12
- package/dist/types/Newsroom.js +12 -12
- package/dist/types/NewsroomDomain.cjs +6 -6
- package/dist/types/NewsroomDomain.js +6 -6
- package/dist/types/NewsroomGallery.cjs +6 -6
- package/dist/types/NewsroomGallery.js +6 -6
- package/dist/types/NewsroomTheme.cjs +8 -7
- package/dist/types/NewsroomTheme.js +8 -7
- package/dist/types/NewsroomWebhook.cjs +3 -3
- package/dist/types/NewsroomWebhook.js +3 -3
- package/dist/types/NotificationSubscription.cjs +3 -3
- package/dist/types/NotificationSubscription.js +3 -3
- package/dist/types/Permissions.cjs +3 -3
- package/dist/types/Permissions.js +3 -3
- package/dist/types/Plan.cjs +10 -10
- package/dist/types/Plan.js +11 -11
- package/dist/types/Price.cjs +6 -6
- package/dist/types/Price.js +6 -6
- package/dist/types/PrivacyRequest.cjs +6 -6
- package/dist/types/PrivacyRequest.js +6 -6
- package/dist/types/SenderAddress.cjs +3 -3
- package/dist/types/SenderAddress.js +3 -3
- package/dist/types/SenderDomain.cjs +3 -3
- package/dist/types/SenderDomain.js +3 -3
- package/dist/types/SortOrder.cjs +3 -3
- package/dist/types/SortOrder.js +3 -3
- package/dist/types/Story.cjs +12 -12
- package/dist/types/Story.js +12 -12
- package/dist/types/User.cjs +6 -6
- package/dist/types/User.js +6 -6
- package/dist/types/common/Notification.cjs +3 -3
- package/dist/types/common/Notification.js +3 -3
- package/dist/types/common/OEmbedInfo.cjs +3 -3
- package/dist/types/common/OEmbedInfo.js +3 -3
- package/dist/types/common/Pagination.cjs +3 -3
- package/dist/types/common/Pagination.js +3 -3
- package/dist/types/common/Query.js +1 -0
- package/package.json +1 -1
package/dist/Client.cjs
CHANGED
|
@@ -12,11 +12,13 @@ function createClient({
|
|
|
12
12
|
accessToken,
|
|
13
13
|
baseUrl = DEFAULT_BASE_URL,
|
|
14
14
|
headers = {},
|
|
15
|
-
fetch
|
|
15
|
+
fetch,
|
|
16
|
+
onError
|
|
16
17
|
}) {
|
|
17
18
|
const api = (0, _index.createDeferredJobsApiClient)((0, _index.createApiClient)((0, _index3.createHttpClient)({
|
|
18
19
|
fetch,
|
|
19
|
-
baseUrl
|
|
20
|
+
baseUrl,
|
|
21
|
+
onError
|
|
20
22
|
}), {
|
|
21
23
|
accessToken,
|
|
22
24
|
headers
|
package/dist/Client.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { DeferredJobsApiClient } from './api';
|
|
2
2
|
import { type Fetch } from './api';
|
|
3
3
|
import { Accounts, Billing, CampaignRecipients, Campaigns, Contacts, ContactsExports, ContactTagGroups, ContactTags, Coverage, CoverageIntegrations, Jobs, Licenses, NewsroomCategories, NewsroomContacts, NewsroomDomains, NewsroomGalleries, NewsroomHub, NewsroomLanguages, NewsroomPrivacyRequests, Newsrooms, NewsroomSubscriptions, NewsroomThemes, NewsroomWebhooks, NotificationSubscriptions, PricingTables, SenderAddresses, Snippets, Stories, Subscriptions, Templates } from './endpoints';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ApiError } from './http';
|
|
5
|
+
import { type HeadersMap } from './http';
|
|
5
6
|
export interface ClientOptions {
|
|
6
7
|
accessToken: string;
|
|
7
8
|
baseUrl?: string;
|
|
8
9
|
headers?: HeadersMap;
|
|
9
10
|
fetch?: Fetch;
|
|
11
|
+
onError?: (error: ApiError) => void;
|
|
10
12
|
}
|
|
11
13
|
export interface Client {
|
|
12
14
|
api: DeferredJobsApiClient;
|
|
@@ -41,4 +43,4 @@ export interface Client {
|
|
|
41
43
|
subscriptions: Subscriptions.Client;
|
|
42
44
|
templates: Templates.Client;
|
|
43
45
|
}
|
|
44
|
-
export declare function createClient({ accessToken, baseUrl, headers, fetch, }: ClientOptions): Client;
|
|
46
|
+
export declare function createClient({ accessToken, baseUrl, headers, fetch, onError, }: ClientOptions): Client;
|
package/dist/Client.js
CHANGED
|
@@ -6,11 +6,13 @@ export function createClient({
|
|
|
6
6
|
accessToken,
|
|
7
7
|
baseUrl = DEFAULT_BASE_URL,
|
|
8
8
|
headers = {},
|
|
9
|
-
fetch
|
|
9
|
+
fetch,
|
|
10
|
+
onError
|
|
10
11
|
}) {
|
|
11
12
|
const api = createDeferredJobsApiClient(createApiClient(createHttpClient({
|
|
12
13
|
fetch,
|
|
13
|
-
baseUrl
|
|
14
|
+
baseUrl,
|
|
15
|
+
onError
|
|
14
16
|
}), {
|
|
15
17
|
accessToken,
|
|
16
18
|
headers
|
package/dist/api/constants.cjs
CHANGED
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DEFAULT_USER_AGENT = void 0;
|
|
7
|
-
const VERSION = "25.
|
|
7
|
+
const VERSION = "25.6.0";
|
|
8
8
|
const URL = 'https://github.com/prezly/javascript-sdk';
|
|
9
9
|
const DEFAULT_USER_AGENT = exports.DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
|
package/dist/api/constants.js
CHANGED
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SignupPlan = exports.SignupCurrency = void 0;
|
|
7
|
-
let SignupPlan = exports.SignupPlan =
|
|
7
|
+
let SignupPlan = exports.SignupPlan = void 0;
|
|
8
|
+
(function (SignupPlan) {
|
|
8
9
|
SignupPlan["ESSENTIAL"] = "essential";
|
|
9
10
|
SignupPlan["STANDARD"] = "standard";
|
|
10
11
|
SignupPlan["AGENCY_ESSENTIAL"] = "agency_essential";
|
|
11
12
|
SignupPlan["AGENCY_STANDARD"] = "agency_standard";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
})(SignupPlan || (exports.SignupPlan = SignupPlan = {}));
|
|
14
|
+
let SignupCurrency = exports.SignupCurrency = void 0;
|
|
15
|
+
(function (SignupCurrency) {
|
|
15
16
|
SignupCurrency["EUR"] = "eur";
|
|
16
17
|
SignupCurrency["USD"] = "usd";
|
|
17
|
-
|
|
18
|
-
}({});
|
|
18
|
+
})(SignupCurrency || (exports.SignupCurrency = SignupCurrency = {}));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export let SignupPlan
|
|
1
|
+
export let SignupPlan;
|
|
2
|
+
(function (SignupPlan) {
|
|
2
3
|
SignupPlan["ESSENTIAL"] = "essential";
|
|
3
4
|
SignupPlan["STANDARD"] = "standard";
|
|
4
5
|
SignupPlan["AGENCY_ESSENTIAL"] = "agency_essential";
|
|
5
6
|
SignupPlan["AGENCY_STANDARD"] = "agency_standard";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
})(SignupPlan || (SignupPlan = {}));
|
|
8
|
+
export let SignupCurrency;
|
|
9
|
+
(function (SignupCurrency) {
|
|
9
10
|
SignupCurrency["EUR"] = "eur";
|
|
10
11
|
SignupCurrency["USD"] = "usd";
|
|
11
|
-
|
|
12
|
-
}({});
|
|
12
|
+
})(SignupCurrency || (SignupCurrency = {}));
|
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Color = void 0;
|
|
7
|
-
let Color = exports.Color =
|
|
7
|
+
let Color = exports.Color = void 0;
|
|
8
|
+
(function (Color) {
|
|
8
9
|
Color["RED"] = "red";
|
|
9
10
|
Color["PINK"] = "pink";
|
|
10
11
|
Color["ORANGE"] = "orange";
|
|
@@ -15,5 +16,4 @@ let Color = exports.Color = /*#__PURE__*/function (Color) {
|
|
|
15
16
|
Color["BLUE"] = "blue";
|
|
16
17
|
Color["INDIGO"] = "indigo";
|
|
17
18
|
Color["PURPLE"] = "purple";
|
|
18
|
-
|
|
19
|
-
}({});
|
|
19
|
+
})(Color || (exports.Color = Color = {}));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export let Color
|
|
1
|
+
export let Color;
|
|
2
|
+
(function (Color) {
|
|
2
3
|
Color["RED"] = "red";
|
|
3
4
|
Color["PINK"] = "pink";
|
|
4
5
|
Color["ORANGE"] = "orange";
|
|
@@ -9,5 +10,4 @@ export let Color = /*#__PURE__*/function (Color) {
|
|
|
9
10
|
Color["BLUE"] = "blue";
|
|
10
11
|
Color["INDIGO"] = "indigo";
|
|
11
12
|
Color["PURPLE"] = "purple";
|
|
12
|
-
|
|
13
|
-
}({});
|
|
13
|
+
})(Color || (Color = {}));
|
|
@@ -4,12 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TableId = exports.OptionId = exports.LimitId = exports.AddOnId = void 0;
|
|
7
|
-
let TableId = exports.TableId =
|
|
7
|
+
let TableId = exports.TableId = void 0;
|
|
8
|
+
(function (TableId) {
|
|
8
9
|
TableId["STANDARD"] = "standard";
|
|
9
10
|
TableId["AGENCY"] = "agency";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
})(TableId || (exports.TableId = TableId = {}));
|
|
12
|
+
let OptionId = exports.OptionId = void 0;
|
|
13
|
+
(function (OptionId) {
|
|
13
14
|
OptionId["STARTER"] = "starter";
|
|
14
15
|
OptionId["CORE"] = "core";
|
|
15
16
|
OptionId["PREMIUM"] = "premium";
|
|
@@ -18,18 +19,17 @@ let OptionId = exports.OptionId = /*#__PURE__*/function (OptionId) {
|
|
|
18
19
|
OptionId["AGENCY_MEDIUM"] = "agency_medium";
|
|
19
20
|
OptionId["AGENCY_LARGE"] = "agency_large";
|
|
20
21
|
OptionId["AGENCY_HUGE"] = "agency_huge";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
})(OptionId || (exports.OptionId = OptionId = {}));
|
|
23
|
+
let LimitId = exports.LimitId = void 0;
|
|
24
|
+
(function (LimitId) {
|
|
24
25
|
LimitId["STORIES"] = "stories";
|
|
25
26
|
LimitId["USERS"] = "users";
|
|
26
27
|
LimitId["SITES"] = "sites";
|
|
27
28
|
LimitId["CONTACTS"] = "contacts";
|
|
28
29
|
LimitId["EMAIL_SENDS"] = "email_sends";
|
|
29
30
|
LimitId["CUSTOM_SENDER_ADDRESSES"] = "custom_sender_addresses";
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
})(LimitId || (exports.LimitId = LimitId = {}));
|
|
32
|
+
let AddOnId = exports.AddOnId = void 0;
|
|
33
|
+
(function (AddOnId) {
|
|
33
34
|
AddOnId["SITE"] = "site";
|
|
34
|
-
|
|
35
|
-
}({});
|
|
35
|
+
})(AddOnId || (exports.AddOnId = AddOnId = {}));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export let TableId
|
|
1
|
+
export let TableId;
|
|
2
|
+
(function (TableId) {
|
|
2
3
|
TableId["STANDARD"] = "standard";
|
|
3
4
|
TableId["AGENCY"] = "agency";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
})(TableId || (TableId = {}));
|
|
6
|
+
export let OptionId;
|
|
7
|
+
(function (OptionId) {
|
|
7
8
|
OptionId["STARTER"] = "starter";
|
|
8
9
|
OptionId["CORE"] = "core";
|
|
9
10
|
OptionId["PREMIUM"] = "premium";
|
|
@@ -12,18 +13,17 @@ export let OptionId = /*#__PURE__*/function (OptionId) {
|
|
|
12
13
|
OptionId["AGENCY_MEDIUM"] = "agency_medium";
|
|
13
14
|
OptionId["AGENCY_LARGE"] = "agency_large";
|
|
14
15
|
OptionId["AGENCY_HUGE"] = "agency_huge";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
})(OptionId || (OptionId = {}));
|
|
17
|
+
export let LimitId;
|
|
18
|
+
(function (LimitId) {
|
|
18
19
|
LimitId["STORIES"] = "stories";
|
|
19
20
|
LimitId["USERS"] = "users";
|
|
20
21
|
LimitId["SITES"] = "sites";
|
|
21
22
|
LimitId["CONTACTS"] = "contacts";
|
|
22
23
|
LimitId["EMAIL_SENDS"] = "email_sends";
|
|
23
24
|
LimitId["CUSTOM_SENDER_ADDRESSES"] = "custom_sender_addresses";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
})(LimitId || (LimitId = {}));
|
|
26
|
+
export let AddOnId;
|
|
27
|
+
(function (AddOnId) {
|
|
27
28
|
AddOnId["SITE"] = "site";
|
|
28
|
-
|
|
29
|
-
}({});
|
|
29
|
+
})(AddOnId || (AddOnId = {}));
|
|
@@ -15,7 +15,7 @@ type Exactly<Concrete, Abstract> = Concrete & Record<Exclude<keyof Concrete, key
|
|
|
15
15
|
type InferExtraFields<T> = T extends Required<IncludeOptions<infer I>> ? Pick<Story.ExtraFields, I> : unknown;
|
|
16
16
|
export type Client = ReturnType<typeof createClient>;
|
|
17
17
|
export declare function createClient(api: DeferredJobsApiClient): {
|
|
18
|
-
list: <Options extends ListOptions<keyof Story.ExtraFields>>(options?: Exactly<Options, ListOptions
|
|
18
|
+
list: <Options extends ListOptions<keyof Story.ExtraFields>>(options?: Exactly<Options, ListOptions<keyof Story.ExtraFields>> | undefined) => Promise<ListResponse<Story & InferExtraFields<Options>>>;
|
|
19
19
|
search: <Options_1 extends SearchOptions<keyof Story.ExtraFields>>(options?: Exactly<Options_1, SearchOptions<keyof Story.ExtraFields>> | undefined) => Promise<ListResponse<Story & InferExtraFields<Options_1>>>;
|
|
20
20
|
get: {
|
|
21
21
|
<Options_2 extends IncludeOptions<keyof Story.ExtraFields> & {
|
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.UnsubscribeReason = void 0;
|
|
7
|
-
let UnsubscribeReason = exports.UnsubscribeReason =
|
|
7
|
+
let UnsubscribeReason = exports.UnsubscribeReason = void 0;
|
|
8
|
+
(function (UnsubscribeReason) {
|
|
8
9
|
UnsubscribeReason["UNKNOWN"] = "unknown";
|
|
9
10
|
UnsubscribeReason["UNWANTED"] = "unwanted";
|
|
10
11
|
UnsubscribeReason["SPAM"] = "spam";
|
|
11
12
|
UnsubscribeReason["NEVER_SIGNED_UP"] = "never_signed_up";
|
|
12
13
|
UnsubscribeReason["OTHER"] = "other";
|
|
13
|
-
|
|
14
|
-
}({});
|
|
14
|
+
})(UnsubscribeReason || (exports.UnsubscribeReason = UnsubscribeReason = {}));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export let UnsubscribeReason
|
|
1
|
+
export let UnsubscribeReason;
|
|
2
|
+
(function (UnsubscribeReason) {
|
|
2
3
|
UnsubscribeReason["UNKNOWN"] = "unknown";
|
|
3
4
|
UnsubscribeReason["UNWANTED"] = "unwanted";
|
|
4
5
|
UnsubscribeReason["SPAM"] = "spam";
|
|
5
6
|
UnsubscribeReason["NEVER_SIGNED_UP"] = "never_signed_up";
|
|
6
7
|
UnsubscribeReason["OTHER"] = "other";
|
|
7
|
-
|
|
8
|
-
}({});
|
|
8
|
+
})(UnsubscribeReason || (UnsubscribeReason = {}));
|
package/dist/http/HttpClient.cjs
CHANGED
|
@@ -9,6 +9,7 @@ var _types = require("./types.cjs");
|
|
|
9
9
|
function createHttpClient(options = {}) {
|
|
10
10
|
const baseUrl = options.baseUrl ?? null;
|
|
11
11
|
const fetchImpl = options.fetch ?? fetch;
|
|
12
|
+
const onError = options.onError;
|
|
12
13
|
function resolveUrl(url) {
|
|
13
14
|
if (baseUrl) {
|
|
14
15
|
return new URL(url, baseUrl).toString();
|
|
@@ -24,7 +25,7 @@ function createHttpClient(options = {}) {
|
|
|
24
25
|
headers,
|
|
25
26
|
method: _types.Method.GET,
|
|
26
27
|
query
|
|
27
|
-
});
|
|
28
|
+
}, onError);
|
|
28
29
|
},
|
|
29
30
|
post(url, {
|
|
30
31
|
headers,
|
|
@@ -36,7 +37,7 @@ function createHttpClient(options = {}) {
|
|
|
36
37
|
method: _types.Method.POST,
|
|
37
38
|
payload,
|
|
38
39
|
query
|
|
39
|
-
});
|
|
40
|
+
}, onError);
|
|
40
41
|
},
|
|
41
42
|
put(url, {
|
|
42
43
|
headers,
|
|
@@ -48,7 +49,7 @@ function createHttpClient(options = {}) {
|
|
|
48
49
|
method: _types.Method.PUT,
|
|
49
50
|
payload,
|
|
50
51
|
query
|
|
51
|
-
});
|
|
52
|
+
}, onError);
|
|
52
53
|
},
|
|
53
54
|
patch(url, {
|
|
54
55
|
headers,
|
|
@@ -60,7 +61,7 @@ function createHttpClient(options = {}) {
|
|
|
60
61
|
method: _types.Method.PATCH,
|
|
61
62
|
payload,
|
|
62
63
|
query
|
|
63
|
-
});
|
|
64
|
+
}, onError);
|
|
64
65
|
},
|
|
65
66
|
delete(url, {
|
|
66
67
|
headers,
|
|
@@ -72,7 +73,7 @@ function createHttpClient(options = {}) {
|
|
|
72
73
|
method: _types.Method.DELETE,
|
|
73
74
|
payload,
|
|
74
75
|
query
|
|
75
|
-
});
|
|
76
|
+
}, onError);
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
79
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Fetch } from '../api';
|
|
2
|
+
import type { ApiError } from './ApiError';
|
|
2
3
|
import type { ApiResponse, Params, ParamsWithPayload } from './types';
|
|
3
4
|
export interface HttpClient {
|
|
4
5
|
get<V = any>(url: string, params?: Params): Promise<ApiResponse<V>>;
|
|
@@ -7,7 +8,10 @@ export interface HttpClient {
|
|
|
7
8
|
patch<V = any>(url: string, params?: ParamsWithPayload): Promise<ApiResponse<V>>;
|
|
8
9
|
delete<V = any>(url: string, params?: ParamsWithPayload): Promise<ApiResponse<V>>;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
interface Options {
|
|
11
12
|
baseUrl?: string;
|
|
12
13
|
fetch?: Fetch;
|
|
13
|
-
|
|
14
|
+
onError?: (error: ApiError) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function createHttpClient(options?: Options): HttpClient;
|
|
17
|
+
export {};
|
package/dist/http/HttpClient.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Method } from "./types.js";
|
|
|
3
3
|
export function createHttpClient(options = {}) {
|
|
4
4
|
const baseUrl = options.baseUrl ?? null;
|
|
5
5
|
const fetchImpl = options.fetch ?? fetch;
|
|
6
|
+
const onError = options.onError;
|
|
6
7
|
function resolveUrl(url) {
|
|
7
8
|
if (baseUrl) {
|
|
8
9
|
return new URL(url, baseUrl).toString();
|
|
@@ -18,7 +19,7 @@ export function createHttpClient(options = {}) {
|
|
|
18
19
|
headers,
|
|
19
20
|
method: Method.GET,
|
|
20
21
|
query
|
|
21
|
-
});
|
|
22
|
+
}, onError);
|
|
22
23
|
},
|
|
23
24
|
post(url, {
|
|
24
25
|
headers,
|
|
@@ -30,7 +31,7 @@ export function createHttpClient(options = {}) {
|
|
|
30
31
|
method: Method.POST,
|
|
31
32
|
payload,
|
|
32
33
|
query
|
|
33
|
-
});
|
|
34
|
+
}, onError);
|
|
34
35
|
},
|
|
35
36
|
put(url, {
|
|
36
37
|
headers,
|
|
@@ -42,7 +43,7 @@ export function createHttpClient(options = {}) {
|
|
|
42
43
|
method: Method.PUT,
|
|
43
44
|
payload,
|
|
44
45
|
query
|
|
45
|
-
});
|
|
46
|
+
}, onError);
|
|
46
47
|
},
|
|
47
48
|
patch(url, {
|
|
48
49
|
headers,
|
|
@@ -54,7 +55,7 @@ export function createHttpClient(options = {}) {
|
|
|
54
55
|
method: Method.PATCH,
|
|
55
56
|
payload,
|
|
56
57
|
query
|
|
57
|
-
});
|
|
58
|
+
}, onError);
|
|
58
59
|
},
|
|
59
60
|
delete(url, {
|
|
60
61
|
headers,
|
|
@@ -66,7 +67,7 @@ export function createHttpClient(options = {}) {
|
|
|
66
67
|
method: Method.DELETE,
|
|
67
68
|
payload,
|
|
68
69
|
query
|
|
69
|
-
});
|
|
70
|
+
}, onError);
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
73
|
}
|
|
@@ -39,7 +39,7 @@ function createFakeErrorPayload({
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
async function createRequest(fetchImpl, url, options) {
|
|
42
|
+
async function createRequest(fetchImpl, url, options, onError) {
|
|
43
43
|
const {
|
|
44
44
|
headers,
|
|
45
45
|
method,
|
|
@@ -75,10 +75,12 @@ async function createRequest(fetchImpl, url, options) {
|
|
|
75
75
|
} catch (error) {
|
|
76
76
|
responsePayload = createFakeErrorPayload(response);
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
const error = new _ApiError.ApiError({
|
|
79
79
|
payload: responsePayload,
|
|
80
80
|
...extractResponse(response)
|
|
81
81
|
});
|
|
82
|
+
onError?.(error);
|
|
83
|
+
throw error;
|
|
82
84
|
}
|
|
83
85
|
const responsePayload = response.status === _types.HttpCodes.NO_CONTENT ? undefined : await response.json();
|
|
84
86
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Fetch } from '../api';
|
|
2
|
-
import
|
|
2
|
+
import { ApiError } from './ApiError';
|
|
3
|
+
import type { ApiResponse, HeadersMap, Method } from './types';
|
|
3
4
|
export declare function createFakeErrorPayload({ status, statusText, }: {
|
|
4
5
|
status?: number;
|
|
5
6
|
statusText?: string;
|
|
@@ -19,4 +20,4 @@ export declare function createRequest<P = any>(fetchImpl: Fetch, url: string, op
|
|
|
19
20
|
method: Method;
|
|
20
21
|
payload?: object;
|
|
21
22
|
query?: object;
|
|
22
|
-
}): Promise<ApiResponse<P>>;
|
|
23
|
+
}, onError?: (error: ApiError) => void): Promise<ApiResponse<P>>;
|
|
@@ -32,7 +32,7 @@ export function createFakeErrorPayload({
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
export async function createRequest(fetchImpl, url, options) {
|
|
35
|
+
export async function createRequest(fetchImpl, url, options, onError) {
|
|
36
36
|
const {
|
|
37
37
|
headers,
|
|
38
38
|
method,
|
|
@@ -68,10 +68,12 @@ export async function createRequest(fetchImpl, url, options) {
|
|
|
68
68
|
} catch (error) {
|
|
69
69
|
responsePayload = createFakeErrorPayload(response);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
const error = new ApiError({
|
|
72
72
|
payload: responsePayload,
|
|
73
73
|
...extractResponse(response)
|
|
74
74
|
});
|
|
75
|
+
onError?.(error);
|
|
76
|
+
throw error;
|
|
75
77
|
}
|
|
76
78
|
const responsePayload = response.status === HttpCodes.NO_CONTENT ? undefined : await response.json();
|
|
77
79
|
return {
|
package/dist/http/types.cjs
CHANGED
|
@@ -4,20 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Method = exports.HttpCodes = void 0;
|
|
7
|
-
let HttpCodes = exports.HttpCodes =
|
|
7
|
+
let HttpCodes = exports.HttpCodes = void 0;
|
|
8
|
+
(function (HttpCodes) {
|
|
8
9
|
HttpCodes[HttpCodes["ACCEPTED"] = 202] = "ACCEPTED";
|
|
9
10
|
HttpCodes[HttpCodes["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
10
11
|
HttpCodes[HttpCodes["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
11
12
|
HttpCodes[HttpCodes["CONFLICT"] = 409] = "CONFLICT";
|
|
12
13
|
HttpCodes[HttpCodes["GONE"] = 410] = "GONE";
|
|
13
14
|
HttpCodes[HttpCodes["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
})(HttpCodes || (exports.HttpCodes = HttpCodes = {}));
|
|
16
|
+
let Method = exports.Method = void 0;
|
|
17
|
+
(function (Method) {
|
|
17
18
|
Method["DELETE"] = "DELETE";
|
|
18
19
|
Method["GET"] = "GET";
|
|
19
20
|
Method["PATCH"] = "PATCH";
|
|
20
21
|
Method["POST"] = "POST";
|
|
21
22
|
Method["PUT"] = "PUT";
|
|
22
|
-
|
|
23
|
-
}({});
|
|
23
|
+
})(Method || (exports.Method = Method = {}));
|
package/dist/http/types.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export let HttpCodes
|
|
1
|
+
export let HttpCodes;
|
|
2
|
+
(function (HttpCodes) {
|
|
2
3
|
HttpCodes[HttpCodes["ACCEPTED"] = 202] = "ACCEPTED";
|
|
3
4
|
HttpCodes[HttpCodes["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
4
5
|
HttpCodes[HttpCodes["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
5
6
|
HttpCodes[HttpCodes["CONFLICT"] = 409] = "CONFLICT";
|
|
6
7
|
HttpCodes[HttpCodes["GONE"] = 410] = "GONE";
|
|
7
8
|
HttpCodes[HttpCodes["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
})(HttpCodes || (HttpCodes = {}));
|
|
10
|
+
export let Method;
|
|
11
|
+
(function (Method) {
|
|
11
12
|
Method["DELETE"] = "DELETE";
|
|
12
13
|
Method["GET"] = "GET";
|
|
13
14
|
Method["PATCH"] = "PATCH";
|
|
14
15
|
Method["POST"] = "POST";
|
|
15
16
|
Method["PUT"] = "PUT";
|
|
16
|
-
|
|
17
|
-
}({});
|
|
17
|
+
})(Method || (Method = {}));
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BillingCycle = void 0;
|
|
7
|
-
let BillingCycle = exports.BillingCycle =
|
|
7
|
+
let BillingCycle = exports.BillingCycle = void 0;
|
|
8
|
+
(function (BillingCycle) {
|
|
8
9
|
BillingCycle["YEAR"] = "year";
|
|
9
10
|
BillingCycle["MONTH"] = "month";
|
|
10
|
-
|
|
11
|
-
}({});
|
|
11
|
+
})(BillingCycle || (exports.BillingCycle = BillingCycle = {}));
|
package/dist/types/Campaign.cjs
CHANGED
|
@@ -8,48 +8,48 @@ var _SenderDomain = require("./SenderDomain.cjs");
|
|
|
8
8
|
let Campaign = exports.Campaign = void 0;
|
|
9
9
|
(function (_Campaign) {
|
|
10
10
|
const SenderDomainVerificationFlow = _Campaign.SenderDomainVerificationFlow = _SenderDomain.SenderDomain.VerificationFlowVersion;
|
|
11
|
-
let LifecycleStatus
|
|
11
|
+
let LifecycleStatus;
|
|
12
|
+
(function (LifecycleStatus) {
|
|
12
13
|
LifecycleStatus["DRAFT"] = "draft";
|
|
13
14
|
LifecycleStatus["SCHEDULED"] = "scheduled";
|
|
14
15
|
LifecycleStatus["PENDING"] = "pending";
|
|
15
16
|
LifecycleStatus["SENT"] = "sent";
|
|
16
|
-
|
|
17
|
-
}({});
|
|
17
|
+
})(LifecycleStatus || (LifecycleStatus = {}));
|
|
18
18
|
_Campaign.LifecycleStatus = LifecycleStatus;
|
|
19
|
-
let StoryAlignment
|
|
19
|
+
let StoryAlignment;
|
|
20
|
+
(function (StoryAlignment) {
|
|
20
21
|
StoryAlignment["CENTER"] = "center";
|
|
21
22
|
StoryAlignment["LEFT"] = "left";
|
|
22
23
|
StoryAlignment["RIGHT"] = "right";
|
|
23
|
-
|
|
24
|
-
}({});
|
|
24
|
+
})(StoryAlignment || (StoryAlignment = {}));
|
|
25
25
|
_Campaign.StoryAlignment = StoryAlignment;
|
|
26
|
-
let StoryAppearance
|
|
26
|
+
let StoryAppearance;
|
|
27
|
+
(function (StoryAppearance) {
|
|
27
28
|
StoryAppearance["INTRO"] = "intro";
|
|
28
29
|
StoryAppearance["FULL"] = "full";
|
|
29
|
-
|
|
30
|
-
}({});
|
|
30
|
+
})(StoryAppearance || (StoryAppearance = {}));
|
|
31
31
|
_Campaign.StoryAppearance = StoryAppearance;
|
|
32
|
-
let StoryHeaderFooter
|
|
32
|
+
let StoryHeaderFooter;
|
|
33
|
+
(function (StoryHeaderFooter) {
|
|
33
34
|
StoryHeaderFooter["NONE"] = "none";
|
|
34
35
|
StoryHeaderFooter["STANDARD"] = "standard";
|
|
35
36
|
StoryHeaderFooter["FULL"] = "full";
|
|
36
|
-
|
|
37
|
-
}({});
|
|
37
|
+
})(StoryHeaderFooter || (StoryHeaderFooter = {}));
|
|
38
38
|
_Campaign.StoryHeaderFooter = StoryHeaderFooter;
|
|
39
|
-
let SenderDomainVerificationStatus
|
|
39
|
+
let SenderDomainVerificationStatus;
|
|
40
|
+
(function (SenderDomainVerificationStatus) {
|
|
40
41
|
SenderDomainVerificationStatus["UNKNOWN"] = "unknown";
|
|
41
42
|
SenderDomainVerificationStatus["VALID"] = "valid";
|
|
42
43
|
SenderDomainVerificationStatus["INVALID"] = "invalid";
|
|
43
44
|
SenderDomainVerificationStatus["NOT_APPLICABLE"] = "not-applicable";
|
|
44
|
-
|
|
45
|
-
}({});
|
|
45
|
+
})(SenderDomainVerificationStatus || (SenderDomainVerificationStatus = {}));
|
|
46
46
|
_Campaign.SenderDomainVerificationStatus = SenderDomainVerificationStatus;
|
|
47
|
-
let ClickTrackingVersion
|
|
47
|
+
let ClickTrackingVersion;
|
|
48
|
+
(function (ClickTrackingVersion) {
|
|
48
49
|
ClickTrackingVersion[ClickTrackingVersion["DEPRECATED"] = 1] = "DEPRECATED";
|
|
49
50
|
ClickTrackingVersion[ClickTrackingVersion["ENHANCED"] = 2] = "ENHANCED";
|
|
50
51
|
ClickTrackingVersion[ClickTrackingVersion["INHOUSE"] = 3] = "INHOUSE";
|
|
51
|
-
|
|
52
|
-
}({});
|
|
52
|
+
})(ClickTrackingVersion || (ClickTrackingVersion = {}));
|
|
53
53
|
_Campaign.ClickTrackingVersion = ClickTrackingVersion;
|
|
54
54
|
function isDraft(arg) {
|
|
55
55
|
if (typeof arg === 'object') {
|