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/README.md
CHANGED
|
@@ -141,6 +141,7 @@ await shipmail.mailboxes.resume("mbx_...");
|
|
|
141
141
|
await shipmail.mailboxes.resetPassword("mbx_...", { password: "NewPassword1" });
|
|
142
142
|
const forwarding = await shipmail.mailboxes.createForwarding("mbx_...", {
|
|
143
143
|
destination: "owner@example.net",
|
|
144
|
+
recipient: "support@example.com",
|
|
144
145
|
});
|
|
145
146
|
const forwardingList = await shipmail.mailboxes.listForwarding("mbx_...");
|
|
146
147
|
await shipmail.mailboxes.deleteForwarding("mbx_...", forwarding.id);
|
package/dist/index.cjs
CHANGED
|
@@ -82,6 +82,12 @@ function apiKeyScopesGrant(grantedScopes, requiredScope) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
// src/errors.ts
|
|
85
|
+
var ERROR_RECOVERY_REASONS = [
|
|
86
|
+
"owner_confirmation_required",
|
|
87
|
+
"subscription_required",
|
|
88
|
+
"trial_capacity",
|
|
89
|
+
"purchased_capacity"
|
|
90
|
+
];
|
|
85
91
|
var ShipmailError = class extends Error {
|
|
86
92
|
constructor(message, options) {
|
|
87
93
|
super(message);
|
|
@@ -90,6 +96,8 @@ var ShipmailError = class extends Error {
|
|
|
90
96
|
this.type = options?.type;
|
|
91
97
|
this.requestId = options?.requestId;
|
|
92
98
|
this.retryable = options?.retryable ?? false;
|
|
99
|
+
this.reason = options?.reason;
|
|
100
|
+
this.actionUrl = options?.actionUrl;
|
|
93
101
|
}
|
|
94
102
|
};
|
|
95
103
|
var AuthenticationError = class extends ShipmailError {
|
|
@@ -99,8 +107,14 @@ var AuthenticationError = class extends ShipmailError {
|
|
|
99
107
|
}
|
|
100
108
|
};
|
|
101
109
|
var AuthorizationError = class extends ShipmailError {
|
|
102
|
-
constructor(message, requestId) {
|
|
103
|
-
super(message, {
|
|
110
|
+
constructor(message, requestId, recovery) {
|
|
111
|
+
super(message, {
|
|
112
|
+
status: 403,
|
|
113
|
+
type: "authorization_error",
|
|
114
|
+
requestId,
|
|
115
|
+
retryable: false,
|
|
116
|
+
...recovery
|
|
117
|
+
});
|
|
104
118
|
this.name = "AuthorizationError";
|
|
105
119
|
}
|
|
106
120
|
};
|
|
@@ -110,15 +124,23 @@ var ValidationError = class extends ShipmailError {
|
|
|
110
124
|
status: 422,
|
|
111
125
|
type: "validation_error",
|
|
112
126
|
requestId: options?.requestId,
|
|
113
|
-
retryable: false
|
|
127
|
+
retryable: false,
|
|
128
|
+
reason: options?.reason,
|
|
129
|
+
actionUrl: options?.actionUrl
|
|
114
130
|
});
|
|
115
131
|
this.name = "ValidationError";
|
|
116
132
|
this.details = options?.details;
|
|
117
133
|
}
|
|
118
134
|
};
|
|
119
135
|
var QuotaExceededError = class extends ShipmailError {
|
|
120
|
-
constructor(message, requestId) {
|
|
121
|
-
super(message, {
|
|
136
|
+
constructor(message, requestId, recovery) {
|
|
137
|
+
super(message, {
|
|
138
|
+
status: 403,
|
|
139
|
+
type: "quota_exceeded",
|
|
140
|
+
requestId,
|
|
141
|
+
retryable: false,
|
|
142
|
+
...recovery
|
|
143
|
+
});
|
|
122
144
|
this.name = "QuotaExceededError";
|
|
123
145
|
}
|
|
124
146
|
};
|
|
@@ -179,15 +201,23 @@ var WebhookVerificationError = class extends ShipmailError {
|
|
|
179
201
|
function mapErrorFromResponse(status, body, requestId) {
|
|
180
202
|
const error = body.error;
|
|
181
203
|
const rid = error.request_id;
|
|
204
|
+
const recovery = {
|
|
205
|
+
reason: typeof error.reason === "string" ? error.reason : void 0,
|
|
206
|
+
actionUrl: typeof error.action_url === "string" ? error.action_url : void 0
|
|
207
|
+
};
|
|
182
208
|
switch (error.type) {
|
|
183
209
|
case "authentication_error":
|
|
184
210
|
return new AuthenticationError(error.message, rid);
|
|
185
211
|
case "authorization_error":
|
|
186
|
-
return new AuthorizationError(error.message, rid);
|
|
212
|
+
return new AuthorizationError(error.message, rid, recovery);
|
|
187
213
|
case "quota_exceeded":
|
|
188
|
-
return new QuotaExceededError(error.message, rid);
|
|
214
|
+
return new QuotaExceededError(error.message, rid, recovery);
|
|
189
215
|
case "validation_error":
|
|
190
|
-
return new ValidationError(error.message, {
|
|
216
|
+
return new ValidationError(error.message, {
|
|
217
|
+
requestId: rid,
|
|
218
|
+
details: error.details,
|
|
219
|
+
...recovery
|
|
220
|
+
});
|
|
191
221
|
case "not_found":
|
|
192
222
|
return new NotFoundError(error.message, rid);
|
|
193
223
|
case "rate_limit_error":
|
|
@@ -203,7 +233,8 @@ function mapErrorFromResponse(status, body, requestId) {
|
|
|
203
233
|
status,
|
|
204
234
|
type: error.type,
|
|
205
235
|
requestId: rid,
|
|
206
|
-
retryable: status >= 500
|
|
236
|
+
retryable: status >= 500,
|
|
237
|
+
...recovery
|
|
207
238
|
});
|
|
208
239
|
}
|
|
209
240
|
}
|
|
@@ -1370,6 +1401,22 @@ var Newsletters = class extends ApiResource {
|
|
|
1370
1401
|
}
|
|
1371
1402
|
};
|
|
1372
1403
|
|
|
1404
|
+
// src/resources/organization.ts
|
|
1405
|
+
var Organization = class extends ApiResource {
|
|
1406
|
+
/**
|
|
1407
|
+
* Whether the credential's organization can create mailboxes now, with its plan, trial and
|
|
1408
|
+
* mailbox capacity. Poll it after the owner pays: access appears once Shipmail has recorded the
|
|
1409
|
+
* payment.
|
|
1410
|
+
*/
|
|
1411
|
+
access(options) {
|
|
1412
|
+
return this.client.request({
|
|
1413
|
+
method: "GET",
|
|
1414
|
+
path: "/organization/access",
|
|
1415
|
+
methodOptions: options
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1373
1420
|
// src/resources/reply-scans.ts
|
|
1374
1421
|
var ReplyScans = class extends ApiResource {
|
|
1375
1422
|
create(params, options) {
|
|
@@ -1618,7 +1665,7 @@ var Webhooks = class extends ApiResource {
|
|
|
1618
1665
|
};
|
|
1619
1666
|
|
|
1620
1667
|
// src/version.ts
|
|
1621
|
-
var VERSION = "0.6.
|
|
1668
|
+
var VERSION = "0.6.3";
|
|
1622
1669
|
|
|
1623
1670
|
// src/client.ts
|
|
1624
1671
|
var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
|
|
@@ -1691,6 +1738,7 @@ var ShipmailClient = class {
|
|
|
1691
1738
|
this.members = new Members(this);
|
|
1692
1739
|
this.messages = new Messages(this);
|
|
1693
1740
|
this.newsletters = new Newsletters(this);
|
|
1741
|
+
this.organization = new Organization(this);
|
|
1694
1742
|
this.replyScans = new ReplyScans(this);
|
|
1695
1743
|
this.scheduledMessages = new ScheduledMessages(this);
|
|
1696
1744
|
this.suppressions = new Suppressions(this);
|
|
@@ -1909,6 +1957,7 @@ exports.CONFERENCING_PROVIDER_IDS = CONFERENCING_PROVIDER_IDS;
|
|
|
1909
1957
|
exports.ConflictError = ConflictError;
|
|
1910
1958
|
exports.ConnectionError = ConnectionError;
|
|
1911
1959
|
exports.DOMAIN_STATUSES = DOMAIN_STATUSES;
|
|
1960
|
+
exports.ERROR_RECOVERY_REASONS = ERROR_RECOVERY_REASONS;
|
|
1912
1961
|
exports.InternalServerError = InternalServerError;
|
|
1913
1962
|
exports.MESSAGE_SOURCES = MESSAGE_SOURCES;
|
|
1914
1963
|
exports.MESSAGE_STATUSES = MESSAGE_STATUSES;
|