@mailiy/sdk 0.1.0 → 0.3.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/mailiy.d.ts CHANGED
@@ -62,6 +62,14 @@ export interface MailiyForm {
62
62
  group_emails: number;
63
63
  server_requires_key: number;
64
64
  disabled: number;
65
+ /** Submissions are refused before this time (ms since epoch); null: no start. */
66
+ opens_at: number | null;
67
+ /** Submissions are refused from this time on (ms since epoch); null: no end. */
68
+ closes_at: number | null;
69
+ /** Delivered submissions after which the form answers form_full; 0: no limit. */
70
+ max_submissions: number;
71
+ /** Field names, one per line; a submission missing one gets missing_fields. */
72
+ required_fields: string;
65
73
  created_at: number;
66
74
  submissions?: number;
67
75
  delivered?: number;
@@ -187,6 +195,7 @@ export type MailiyFormPatch = Partial<{
187
195
  autoresponder_subject: string;
188
196
  autoresponder_text: string;
189
197
  blocked_ips: string;
198
+ closes_at: number | null;
190
199
  disabled: boolean;
191
200
  /** Placeholders: {fields}, {intro}, {form}, {field:name}. */
192
201
  email_html: string;
@@ -194,10 +203,14 @@ export type MailiyFormPatch = Partial<{
194
203
  from_name: string;
195
204
  group_emails: boolean;
196
205
  intro_text: string;
206
+ max_submissions: number;
197
207
  name: string;
208
+ opens_at: number | null;
198
209
  recipients: string[];
199
210
  redirect_url: string;
200
211
  require_consent: boolean;
212
+ /** Field names, one per line. */
213
+ required_fields: string;
201
214
  retention_days: Retention;
202
215
  captcha: Captcha;
203
216
  captcha_secret: string;
@@ -224,7 +237,9 @@ export declare class MailiyError extends Error {
224
237
  name: string;
225
238
  readonly code: string;
226
239
  readonly status: number;
227
- constructor(code: string, status: number);
240
+ /** With missing_fields: the required fields that were missing or empty. */
241
+ readonly fields: string[] | undefined;
242
+ constructor(code: string, status: number, fields?: string[]);
228
243
  }
229
244
  export declare const DEFAULT_BASE_URL = "https://mailiy.com";
230
245
  export declare const createMailiy: (options?: MailiyOptions) => {
package/dist/mailiy.js CHANGED
@@ -10,10 +10,15 @@ export class MailiyError extends Error {
10
10
  name = "MailiyError";
11
11
  code;
12
12
  status;
13
- constructor(code, status) {
14
- super(`Mailiy API error ${status}: ${code}`);
13
+ /** With missing_fields: the required fields that were missing or empty. */
14
+ fields;
15
+ constructor(code, status, fields) {
16
+ super(fields
17
+ ? `Mailiy API error ${status}: ${code} (${fields.join(", ")})`
18
+ : `Mailiy API error ${status}: ${code}`);
15
19
  this.code = code;
16
20
  this.status = status;
21
+ this.fields = fields;
17
22
  }
18
23
  }
19
24
  const form = (id) => `/forms/${encodeURIComponent(id)}`;
@@ -41,7 +46,7 @@ export const createMailiy = (options = {}) => {
41
46
  });
42
47
  const json = (await res.json().catch(() => ({})));
43
48
  if (!res.ok) {
44
- throw new MailiyError(json.error ?? json.code ?? res.statusText, res.status);
49
+ throw new MailiyError(json.error ?? json.code ?? res.statusText, res.status, json.fields);
45
50
  }
46
51
  return { headers: res.headers, json };
47
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailiy/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Typed, dependency-free client for the Mailiy REST API.",
5
5
  "keywords": [
6
6
  "api-client",