@mailpier/inbox 0.0.0-stage → 0.1.1
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/CHANGELOG.md +24 -0
- package/LICENSE +21 -0
- package/README.md +159 -2
- package/dist/chunk-2NMZ2IWD.js +524 -0
- package/dist/cli.cjs +751 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +244 -0
- package/dist/client-DD8Tr4-3.d.cts +415 -0
- package/dist/client-DD8Tr4-3.d.ts +415 -0
- package/dist/cypress/commands.cjs +94 -0
- package/dist/cypress/commands.d.cts +58 -0
- package/dist/cypress/commands.d.ts +58 -0
- package/dist/cypress/commands.js +68 -0
- package/dist/cypress/index.cjs +575 -0
- package/dist/cypress/index.d.cts +47 -0
- package/dist/cypress/index.d.ts +47 -0
- package/dist/cypress/index.js +40 -0
- package/dist/index.cjs +557 -0
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +22 -0
- package/dist/playwright.cjs +639 -0
- package/dist/playwright.d.cts +65 -0
- package/dist/playwright.d.ts +65 -0
- package/dist/playwright.js +104 -0
- package/dist/testing/index.cjs +683 -0
- package/dist/testing/index.d.cts +106 -0
- package/dist/testing/index.d.ts +106 -0
- package/dist/testing/index.js +654 -0
- package/package.json +112 -4
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
interface FakeAttachment {
|
|
2
|
+
fileName: string;
|
|
3
|
+
contentType?: string;
|
|
4
|
+
content: string | Uint8Array;
|
|
5
|
+
}
|
|
6
|
+
interface FakeMail {
|
|
7
|
+
/** Envelope recipient(s). */
|
|
8
|
+
to: string | string[];
|
|
9
|
+
from?: string;
|
|
10
|
+
fromName?: string;
|
|
11
|
+
subject?: string;
|
|
12
|
+
text?: string;
|
|
13
|
+
html?: string;
|
|
14
|
+
/** Defaults to the links found in html (href) and text (http/https URLs). */
|
|
15
|
+
links?: {
|
|
16
|
+
href: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
}[];
|
|
19
|
+
/** Defaults to 4-8 digit numbers found in the subject and text. */
|
|
20
|
+
codes?: string[];
|
|
21
|
+
attachments?: FakeAttachment[];
|
|
22
|
+
/** Defaults to now. */
|
|
23
|
+
receivedUtc?: Date;
|
|
24
|
+
}
|
|
25
|
+
interface FakeMailPierOptions {
|
|
26
|
+
/** The only key the fake accepts. Default "mpi_test_key". */
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
account?: string;
|
|
29
|
+
environment?: string;
|
|
30
|
+
/** Base domains; the first is the default for new addresses. Default ["mailpier.io"]. */
|
|
31
|
+
domains?: string[];
|
|
32
|
+
/** Port to listen on (127.0.0.1); 0 = any free port. */
|
|
33
|
+
port?: number;
|
|
34
|
+
/** The Webhook inspector is on (default true); false = every /v1/hooks call answers 404 like the service while it is off. */
|
|
35
|
+
webhooks?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** A request as if the environment's catch URL had received it (FakeMailPier.catchWebhook). */
|
|
38
|
+
interface FakeWebhook {
|
|
39
|
+
/** Default "POST". */
|
|
40
|
+
method?: string;
|
|
41
|
+
/** The path after the token. Default "/". */
|
|
42
|
+
path?: string;
|
|
43
|
+
/** The query string, without "?". */
|
|
44
|
+
query?: string;
|
|
45
|
+
headers?: Record<string, string> | [string, string][];
|
|
46
|
+
/** Text (UTF-8), bytes, or an object/array (sent as JSON). */
|
|
47
|
+
body?: string | Uint8Array | Record<string, unknown> | unknown[];
|
|
48
|
+
/** Default application/json for an object body, text/plain for a text body, none without a body. */
|
|
49
|
+
contentType?: string;
|
|
50
|
+
/** Defaults to now. */
|
|
51
|
+
receivedUtc?: Date;
|
|
52
|
+
/** Default 203.0.113.10. */
|
|
53
|
+
sourceIp?: string;
|
|
54
|
+
}
|
|
55
|
+
interface FailNext {
|
|
56
|
+
status: number;
|
|
57
|
+
/** Retry-After seconds (sent on 429). */
|
|
58
|
+
retryAfter?: number;
|
|
59
|
+
error?: string;
|
|
60
|
+
/** How many requests in a row get this answer. Default 1. */
|
|
61
|
+
times?: number;
|
|
62
|
+
}
|
|
63
|
+
interface FakeMailPier {
|
|
64
|
+
/** e.g. http://127.0.0.1:53211 (use as baseUrl). */
|
|
65
|
+
readonly url: string;
|
|
66
|
+
readonly apiKey: string;
|
|
67
|
+
/** The default zone, e.g. qa.demo.mailpier.io: any `<anything>@<zone>` belongs to the environment. */
|
|
68
|
+
readonly zone: string;
|
|
69
|
+
/** Every request seen (method, path with query, Authorization header), oldest first. */
|
|
70
|
+
readonly requests: {
|
|
71
|
+
method: string;
|
|
72
|
+
url: string;
|
|
73
|
+
authorization?: string;
|
|
74
|
+
}[];
|
|
75
|
+
/** Stores a mail as if MailPier had received it; wakes waiting long-polls. Returns its id. */
|
|
76
|
+
deliver(mail: FakeMail): string;
|
|
77
|
+
/** The next API request(s) get this error instead of their answer (after the key check). */
|
|
78
|
+
failNext(f: FailNext): void;
|
|
79
|
+
/** Number of stored mails (all addresses). */
|
|
80
|
+
count(): number;
|
|
81
|
+
/** The environment's catch URL on this fake: any request to it, or to any path below it, is caught. */
|
|
82
|
+
readonly webhookUrl: string;
|
|
83
|
+
/** Stores a request as if the catch URL had received it (custom responses decide its status); wakes waits. Returns its id. */
|
|
84
|
+
catchWebhook(request?: FakeWebhook): number;
|
|
85
|
+
/** Number of stored webhook requests. */
|
|
86
|
+
webhookCount(): number;
|
|
87
|
+
/** Every replay the API was asked for, oldest first (the fake never sends anything). */
|
|
88
|
+
readonly replays: {
|
|
89
|
+
id: number;
|
|
90
|
+
url: string;
|
|
91
|
+
}[];
|
|
92
|
+
reset(): void;
|
|
93
|
+
close(): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
/** Starts the fake on 127.0.0.1. Always close() it (afterAll). */
|
|
96
|
+
declare function startFakeMailPier(options?: FakeMailPierOptions): Promise<FakeMailPier>;
|
|
97
|
+
/** Links like MailPier reports them: <a href> in the HTML (with its text), else http(s) URLs in the text. */
|
|
98
|
+
declare function findLinks(html?: string, text?: string): {
|
|
99
|
+
href: string;
|
|
100
|
+
text?: string;
|
|
101
|
+
}[];
|
|
102
|
+
/** One-time codes: 4-8 digit numbers in the subject and text, in order, without duplicates. */
|
|
103
|
+
declare function findCodes(subject?: string, text?: string): string[];
|
|
104
|
+
|
|
105
|
+
export { findCodes, findLinks, startFakeMailPier };
|
|
106
|
+
export type { FailNext, FakeAttachment, FakeMail, FakeMailPier, FakeMailPierOptions, FakeWebhook };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
interface FakeAttachment {
|
|
2
|
+
fileName: string;
|
|
3
|
+
contentType?: string;
|
|
4
|
+
content: string | Uint8Array;
|
|
5
|
+
}
|
|
6
|
+
interface FakeMail {
|
|
7
|
+
/** Envelope recipient(s). */
|
|
8
|
+
to: string | string[];
|
|
9
|
+
from?: string;
|
|
10
|
+
fromName?: string;
|
|
11
|
+
subject?: string;
|
|
12
|
+
text?: string;
|
|
13
|
+
html?: string;
|
|
14
|
+
/** Defaults to the links found in html (href) and text (http/https URLs). */
|
|
15
|
+
links?: {
|
|
16
|
+
href: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
}[];
|
|
19
|
+
/** Defaults to 4-8 digit numbers found in the subject and text. */
|
|
20
|
+
codes?: string[];
|
|
21
|
+
attachments?: FakeAttachment[];
|
|
22
|
+
/** Defaults to now. */
|
|
23
|
+
receivedUtc?: Date;
|
|
24
|
+
}
|
|
25
|
+
interface FakeMailPierOptions {
|
|
26
|
+
/** The only key the fake accepts. Default "mpi_test_key". */
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
account?: string;
|
|
29
|
+
environment?: string;
|
|
30
|
+
/** Base domains; the first is the default for new addresses. Default ["mailpier.io"]. */
|
|
31
|
+
domains?: string[];
|
|
32
|
+
/** Port to listen on (127.0.0.1); 0 = any free port. */
|
|
33
|
+
port?: number;
|
|
34
|
+
/** The Webhook inspector is on (default true); false = every /v1/hooks call answers 404 like the service while it is off. */
|
|
35
|
+
webhooks?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** A request as if the environment's catch URL had received it (FakeMailPier.catchWebhook). */
|
|
38
|
+
interface FakeWebhook {
|
|
39
|
+
/** Default "POST". */
|
|
40
|
+
method?: string;
|
|
41
|
+
/** The path after the token. Default "/". */
|
|
42
|
+
path?: string;
|
|
43
|
+
/** The query string, without "?". */
|
|
44
|
+
query?: string;
|
|
45
|
+
headers?: Record<string, string> | [string, string][];
|
|
46
|
+
/** Text (UTF-8), bytes, or an object/array (sent as JSON). */
|
|
47
|
+
body?: string | Uint8Array | Record<string, unknown> | unknown[];
|
|
48
|
+
/** Default application/json for an object body, text/plain for a text body, none without a body. */
|
|
49
|
+
contentType?: string;
|
|
50
|
+
/** Defaults to now. */
|
|
51
|
+
receivedUtc?: Date;
|
|
52
|
+
/** Default 203.0.113.10. */
|
|
53
|
+
sourceIp?: string;
|
|
54
|
+
}
|
|
55
|
+
interface FailNext {
|
|
56
|
+
status: number;
|
|
57
|
+
/** Retry-After seconds (sent on 429). */
|
|
58
|
+
retryAfter?: number;
|
|
59
|
+
error?: string;
|
|
60
|
+
/** How many requests in a row get this answer. Default 1. */
|
|
61
|
+
times?: number;
|
|
62
|
+
}
|
|
63
|
+
interface FakeMailPier {
|
|
64
|
+
/** e.g. http://127.0.0.1:53211 (use as baseUrl). */
|
|
65
|
+
readonly url: string;
|
|
66
|
+
readonly apiKey: string;
|
|
67
|
+
/** The default zone, e.g. qa.demo.mailpier.io: any `<anything>@<zone>` belongs to the environment. */
|
|
68
|
+
readonly zone: string;
|
|
69
|
+
/** Every request seen (method, path with query, Authorization header), oldest first. */
|
|
70
|
+
readonly requests: {
|
|
71
|
+
method: string;
|
|
72
|
+
url: string;
|
|
73
|
+
authorization?: string;
|
|
74
|
+
}[];
|
|
75
|
+
/** Stores a mail as if MailPier had received it; wakes waiting long-polls. Returns its id. */
|
|
76
|
+
deliver(mail: FakeMail): string;
|
|
77
|
+
/** The next API request(s) get this error instead of their answer (after the key check). */
|
|
78
|
+
failNext(f: FailNext): void;
|
|
79
|
+
/** Number of stored mails (all addresses). */
|
|
80
|
+
count(): number;
|
|
81
|
+
/** The environment's catch URL on this fake: any request to it, or to any path below it, is caught. */
|
|
82
|
+
readonly webhookUrl: string;
|
|
83
|
+
/** Stores a request as if the catch URL had received it (custom responses decide its status); wakes waits. Returns its id. */
|
|
84
|
+
catchWebhook(request?: FakeWebhook): number;
|
|
85
|
+
/** Number of stored webhook requests. */
|
|
86
|
+
webhookCount(): number;
|
|
87
|
+
/** Every replay the API was asked for, oldest first (the fake never sends anything). */
|
|
88
|
+
readonly replays: {
|
|
89
|
+
id: number;
|
|
90
|
+
url: string;
|
|
91
|
+
}[];
|
|
92
|
+
reset(): void;
|
|
93
|
+
close(): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
/** Starts the fake on 127.0.0.1. Always close() it (afterAll). */
|
|
96
|
+
declare function startFakeMailPier(options?: FakeMailPierOptions): Promise<FakeMailPier>;
|
|
97
|
+
/** Links like MailPier reports them: <a href> in the HTML (with its text), else http(s) URLs in the text. */
|
|
98
|
+
declare function findLinks(html?: string, text?: string): {
|
|
99
|
+
href: string;
|
|
100
|
+
text?: string;
|
|
101
|
+
}[];
|
|
102
|
+
/** One-time codes: 4-8 digit numbers in the subject and text, in order, without duplicates. */
|
|
103
|
+
declare function findCodes(subject?: string, text?: string): string[];
|
|
104
|
+
|
|
105
|
+
export { findCodes, findLinks, startFakeMailPier };
|
|
106
|
+
export type { FailNext, FakeAttachment, FakeMail, FakeMailPier, FakeMailPierOptions, FakeWebhook };
|