sendmock-testcontainers 0.0.0-stage → 0.1.0-beta.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.
@@ -0,0 +1,20 @@
1
+ import { AbstractStartedContainer, GenericContainer } from "testcontainers";
2
+ export declare const defaultSendMockImage = "ghcr.io/shibbirweb/sendmock:0.1.0-beta.3";
3
+ /**
4
+ * SendMock in Docker for a test: SMTP, the HTTP API and UI, and the provider port that
5
+ * answers provider SDKs at their real paths.
6
+ */
7
+ export declare class SendMockContainer extends GenericContainer {
8
+ constructor(imageName?: string);
9
+ start(): Promise<StartedSendMockContainer>;
10
+ }
11
+ export declare class StartedSendMockContainer extends AbstractStartedContainer {
12
+ /** The host the SMTP port is reached on. */
13
+ getSmtpHost(): string;
14
+ /** The SMTP port on the host, for the app's mail settings. */
15
+ getSmtpPort(): number;
16
+ /** The HTTP API and UI, e.g. `http://localhost:32768`. */
17
+ getHttpUrl(): string;
18
+ /** The provider port, the base URL to give a provider SDK instead of the provider's own. */
19
+ getProviderUrl(): string;
20
+ }
@@ -0,0 +1,42 @@
1
+ // src/sendmock-container.ts
2
+ import {
3
+ AbstractStartedContainer,
4
+ GenericContainer,
5
+ Wait
6
+ } from "testcontainers";
7
+ var defaultSendMockImage = "ghcr.io/shibbirweb/sendmock:0.1.0-beta.3";
8
+ var smtpPort = 1025;
9
+ var httpPort = 8025;
10
+ var providerPort = 8026;
11
+
12
+ class SendMockContainer extends GenericContainer {
13
+ constructor(imageName = defaultSendMockImage) {
14
+ super(imageName);
15
+ this.withExposedPorts(smtpPort, httpPort, providerPort).withEnvironment({
16
+ SENDMOCK_PROVIDER_ADDR: `0.0.0.0:${providerPort}`
17
+ }).withWaitStrategy(Wait.forHttp("/api/v1/health", httpPort));
18
+ }
19
+ async start() {
20
+ return new StartedSendMockContainer(await super.start());
21
+ }
22
+ }
23
+
24
+ class StartedSendMockContainer extends AbstractStartedContainer {
25
+ getSmtpHost() {
26
+ return this.getHost();
27
+ }
28
+ getSmtpPort() {
29
+ return this.getMappedPort(smtpPort);
30
+ }
31
+ getHttpUrl() {
32
+ return `http://${this.getHost()}:${this.getMappedPort(httpPort)}`;
33
+ }
34
+ getProviderUrl() {
35
+ return `http://${this.getHost()}:${this.getMappedPort(providerPort)}`;
36
+ }
37
+ }
38
+ export {
39
+ SendMockContainer,
40
+ StartedSendMockContainer,
41
+ defaultSendMockImage
42
+ };
package/package.json CHANGED
@@ -1,6 +1,30 @@
1
1
  {
2
2
  "name": "sendmock-testcontainers",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-beta.3",
4
+ "description": "Starts SendMock in Docker from a test and gives its SMTP, HTTP and provider addresses.",
5
+ "license": "MIT OR Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/shibbirweb/sendmock.git",
9
+ "directory": "testcontainers/node"
10
+ },
11
+ "homepage": "https://shibbirweb.github.io/sendmock/",
12
+ "type": "module",
13
+ "exports": {
14
+ "types": "./dist/sendmock-container.d.ts",
15
+ "default": "./dist/sendmock-container.js"
16
+ },
17
+ "engines": {
18
+ "node": ">=24"
19
+ },
20
+ "scripts": {
21
+ "build": "bun build src/sendmock-container.ts --outdir dist --target node --format esm --packages external && bunx --package typescript@5.9.3 tsc src/sendmock-container.ts --declaration --emitDeclarationOnly --outDir dist --module nodenext --moduleResolution nodenext --target es2022 --skipLibCheck",
22
+ "test": "node --test 'test/*.test.ts'"
23
+ },
24
+ "dependencies": {
25
+ "testcontainers": "12.2.1"
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ]
30
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.