shipmail 0.6.1 → 0.6.3
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 +1 -0
- package/dist/index.cjs +59 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -6
- package/dist/index.d.ts +102 -6
- package/dist/index.js +59 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -78,6 +78,12 @@ function apiKeyScopesGrant(grantedScopes, requiredScope) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// src/errors.ts
|
|
81
|
+
var ERROR_RECOVERY_REASONS = [
|
|
82
|
+
"owner_confirmation_required",
|
|
83
|
+
"subscription_required",
|
|
84
|
+
"trial_capacity",
|
|
85
|
+
"purchased_capacity"
|
|
86
|
+
];
|
|
81
87
|
var ShipmailError = class extends Error {
|
|
82
88
|
constructor(message, options) {
|
|
83
89
|
super(message);
|
|
@@ -86,6 +92,8 @@ var ShipmailError = class extends Error {
|
|
|
86
92
|
this.type = options?.type;
|
|
87
93
|
this.requestId = options?.requestId;
|
|
88
94
|
this.retryable = options?.retryable ?? false;
|
|
95
|
+
this.reason = options?.reason;
|
|
96
|
+
this.actionUrl = options?.actionUrl;
|
|
89
97
|
}
|
|
90
98
|
};
|
|
91
99
|
var AuthenticationError = class extends ShipmailError {
|
|
@@ -95,8 +103,14 @@ var AuthenticationError = class extends ShipmailError {
|
|
|
95
103
|
}
|
|
96
104
|
};
|
|
97
105
|
var AuthorizationError = class extends ShipmailError {
|
|
98
|
-
constructor(message, requestId) {
|
|
99
|
-
super(message, {
|
|
106
|
+
constructor(message, requestId, recovery) {
|
|
107
|
+
super(message, {
|
|
108
|
+
status: 403,
|
|
109
|
+
type: "authorization_error",
|
|
110
|
+
requestId,
|
|
111
|
+
retryable: false,
|
|
112
|
+
...recovery
|
|
113
|
+
});
|
|
100
114
|
this.name = "AuthorizationError";
|
|
101
115
|
}
|
|
102
116
|
};
|
|
@@ -106,15 +120,23 @@ var ValidationError = class extends ShipmailError {
|
|
|
106
120
|
status: 422,
|
|
107
121
|
type: "validation_error",
|
|
108
122
|
requestId: options?.requestId,
|
|
109
|
-
retryable: false
|
|
123
|
+
retryable: false,
|
|
124
|
+
reason: options?.reason,
|
|
125
|
+
actionUrl: options?.actionUrl
|
|
110
126
|
});
|
|
111
127
|
this.name = "ValidationError";
|
|
112
128
|
this.details = options?.details;
|
|
113
129
|
}
|
|
114
130
|
};
|
|
115
131
|
var QuotaExceededError = class extends ShipmailError {
|
|
116
|
-
constructor(message, requestId) {
|
|
117
|
-
super(message, {
|
|
132
|
+
constructor(message, requestId, recovery) {
|
|
133
|
+
super(message, {
|
|
134
|
+
status: 403,
|
|
135
|
+
type: "quota_exceeded",
|
|
136
|
+
requestId,
|
|
137
|
+
retryable: false,
|
|
138
|
+
...recovery
|
|
139
|
+
});
|
|
118
140
|
this.name = "QuotaExceededError";
|
|
119
141
|
}
|
|
120
142
|
};
|
|
@@ -175,15 +197,23 @@ var WebhookVerificationError = class extends ShipmailError {
|
|
|
175
197
|
function mapErrorFromResponse(status, body, requestId) {
|
|
176
198
|
const error = body.error;
|
|
177
199
|
const rid = error.request_id;
|
|
200
|
+
const recovery = {
|
|
201
|
+
reason: typeof error.reason === "string" ? error.reason : void 0,
|
|
202
|
+
actionUrl: typeof error.action_url === "string" ? error.action_url : void 0
|
|
203
|
+
};
|
|
178
204
|
switch (error.type) {
|
|
179
205
|
case "authentication_error":
|
|
180
206
|
return new AuthenticationError(error.message, rid);
|
|
181
207
|
case "authorization_error":
|
|
182
|
-
return new AuthorizationError(error.message, rid);
|
|
208
|
+
return new AuthorizationError(error.message, rid, recovery);
|
|
183
209
|
case "quota_exceeded":
|
|
184
|
-
return new QuotaExceededError(error.message, rid);
|
|
210
|
+
return new QuotaExceededError(error.message, rid, recovery);
|
|
185
211
|
case "validation_error":
|
|
186
|
-
return new ValidationError(error.message, {
|
|
212
|
+
return new ValidationError(error.message, {
|
|
213
|
+
requestId: rid,
|
|
214
|
+
details: error.details,
|
|
215
|
+
...recovery
|
|
216
|
+
});
|
|
187
217
|
case "not_found":
|
|
188
218
|
return new NotFoundError(error.message, rid);
|
|
189
219
|
case "rate_limit_error":
|
|
@@ -199,7 +229,8 @@ function mapErrorFromResponse(status, body, requestId) {
|
|
|
199
229
|
status,
|
|
200
230
|
type: error.type,
|
|
201
231
|
requestId: rid,
|
|
202
|
-
retryable: status >= 500
|
|
232
|
+
retryable: status >= 500,
|
|
233
|
+
...recovery
|
|
203
234
|
});
|
|
204
235
|
}
|
|
205
236
|
}
|
|
@@ -1366,6 +1397,22 @@ var Newsletters = class extends ApiResource {
|
|
|
1366
1397
|
}
|
|
1367
1398
|
};
|
|
1368
1399
|
|
|
1400
|
+
// src/resources/organization.ts
|
|
1401
|
+
var Organization = class extends ApiResource {
|
|
1402
|
+
/**
|
|
1403
|
+
* Whether the credential's organization can create mailboxes now, with its plan, trial and
|
|
1404
|
+
* mailbox capacity. Poll it after the owner pays: access appears once Shipmail has recorded the
|
|
1405
|
+
* payment.
|
|
1406
|
+
*/
|
|
1407
|
+
access(options) {
|
|
1408
|
+
return this.client.request({
|
|
1409
|
+
method: "GET",
|
|
1410
|
+
path: "/organization/access",
|
|
1411
|
+
methodOptions: options
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1369
1416
|
// src/resources/reply-scans.ts
|
|
1370
1417
|
var ReplyScans = class extends ApiResource {
|
|
1371
1418
|
create(params, options) {
|
|
@@ -1614,7 +1661,7 @@ var Webhooks = class extends ApiResource {
|
|
|
1614
1661
|
};
|
|
1615
1662
|
|
|
1616
1663
|
// src/version.ts
|
|
1617
|
-
var VERSION = "0.6.
|
|
1664
|
+
var VERSION = "0.6.3";
|
|
1618
1665
|
|
|
1619
1666
|
// src/client.ts
|
|
1620
1667
|
var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
|
|
@@ -1687,6 +1734,7 @@ var ShipmailClient = class {
|
|
|
1687
1734
|
this.members = new Members(this);
|
|
1688
1735
|
this.messages = new Messages(this);
|
|
1689
1736
|
this.newsletters = new Newsletters(this);
|
|
1737
|
+
this.organization = new Organization(this);
|
|
1690
1738
|
this.replyScans = new ReplyScans(this);
|
|
1691
1739
|
this.scheduledMessages = new ScheduledMessages(this);
|
|
1692
1740
|
this.suppressions = new Suppressions(this);
|
|
@@ -1897,6 +1945,6 @@ async function verifyWebhook(body, headers, secret, options) {
|
|
|
1897
1945
|
return parsed;
|
|
1898
1946
|
}
|
|
1899
1947
|
|
|
1900
|
-
export { API_KEY_SCOPES, API_KEY_SCOPE_DESCRIPTIONS, AuthenticationError, AuthorizationError, CONFERENCING_PROVIDER_IDS, ConflictError, ConnectionError, DOMAIN_STATUSES, InternalServerError, MESSAGE_SOURCES, MESSAGE_STATUSES, NotFoundError, Page, QuotaExceededError, RateLimitError, ReconciliationRequiredError, ShipmailClient, ShipmailError, ValidationError, WEBHOOK_DELIVERY_EVENT_TYPES, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_EVENT_TYPES, WebhookVerificationError, apiKeyScopesGrant, ShipmailClient as default, isApiKeyScope, verifyWebhook };
|
|
1948
|
+
export { API_KEY_SCOPES, API_KEY_SCOPE_DESCRIPTIONS, AuthenticationError, AuthorizationError, CONFERENCING_PROVIDER_IDS, ConflictError, ConnectionError, DOMAIN_STATUSES, ERROR_RECOVERY_REASONS, InternalServerError, MESSAGE_SOURCES, MESSAGE_STATUSES, NotFoundError, Page, QuotaExceededError, RateLimitError, ReconciliationRequiredError, ShipmailClient, ShipmailError, ValidationError, WEBHOOK_DELIVERY_EVENT_TYPES, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_EVENT_TYPES, WebhookVerificationError, apiKeyScopesGrant, ShipmailClient as default, isApiKeyScope, verifyWebhook };
|
|
1901
1949
|
//# sourceMappingURL=index.js.map
|
|
1902
1950
|
//# sourceMappingURL=index.js.map
|