@event-driven-io/emmett-testcontainers 0.43.0-beta.14 → 0.43.0-beta.15
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/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["GenericContainer","Wait","AbstractStartedContainer","EventStoreDBClient","EventStoreDBClient","MongoDBContainer","PostgreSqlContainer"],"sources":["../src/eventStore/eventStoreDBContainer.ts","../src/eventStore/index.ts","../src/mongodb/mongoDBContainer.ts","../src/postgresql/postgreSQLContainer.ts"],"sourcesContent":["import { InProcessLock } from '@event-driven-io/emmett';\nimport { EventStoreDBClient } from '@eventstore/db-client';\nimport {\n AbstractStartedContainer,\n GenericContainer,\n Wait,\n type StartedTestContainer,\n} from 'testcontainers';\nimport type { Environment } from 'testcontainers/build/types';\n\nexport const EVENTSTOREDB_PORT = 2113;\nexport const EVENTSTOREDB_IMAGE_NAME = 'eventstore/eventstore';\nexport const EVENTSTOREDB_IMAGE_TAG = '24.10.0-bookworm-slim';\nexport const EVENTSTOREDB_ARM64_IMAGE_TAG = '24.10.0-alpha-arm64v8';\n\nexport const EVENTSTOREDB_DEFAULT_IMAGE = `${EVENTSTOREDB_IMAGE_NAME}:${process.arch !== 'arm64' ? EVENTSTOREDB_IMAGE_TAG : EVENTSTOREDB_ARM64_IMAGE_TAG}`;\n\nexport type EventStoreDBContainerOptions = {\n disableProjections?: boolean;\n isSecure?: boolean;\n useFileStorage?: boolean;\n withReuse?: boolean;\n};\n\nexport const defaultEventStoreDBContainerOptions: EventStoreDBContainerOptions =\n {\n disableProjections: false,\n isSecure: false,\n useFileStorage: false,\n withReuse: false,\n };\n\nexport class EventStoreDBContainer extends GenericContainer {\n constructor(\n image = EVENTSTOREDB_DEFAULT_IMAGE,\n options: EventStoreDBContainerOptions = defaultEventStoreDBContainerOptions,\n ) {\n super(image);\n\n const environment: Environment = {\n ...(!options.disableProjections\n ? {\n EVENTSTORE_RUN_PROJECTIONS: 'ALL',\n }\n : {}),\n ...(!options.isSecure\n ? {\n EVENTSTORE_INSECURE: 'true',\n }\n : {}),\n ...(options.useFileStorage\n ? {\n EVENTSTORE_MEM_DB: 'false',\n EVENTSTORE_DB: '/data/integration-tests',\n }\n : {}),\n EVENTSTORE_CLUSTER_SIZE: '1',\n EVENTSTORE_START_STANDARD_PROJECTIONS: 'true',\n EVENTSTORE_NODE_PORT: `${EVENTSTOREDB_PORT}`,\n EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: 'true',\n };\n\n this.withEnvironment(environment).withExposedPorts(EVENTSTOREDB_PORT);\n\n if (options.withReuse) this.withReuse();\n\n this.withWaitStrategy(\n Wait.forAll([Wait.forHealthCheck(), Wait.forListeningPorts()]),\n );\n }\n\n async start(): Promise<StartedEventStoreDBContainer> {\n return new StartedEventStoreDBContainer(await super.start());\n }\n}\n\nexport class StartedEventStoreDBContainer extends AbstractStartedContainer {\n constructor(container: StartedTestContainer) {\n super(container);\n }\n\n getConnectionString(): string {\n return `esdb://${this.getHost()}:${this.getMappedPort(2113)}?tls=false`;\n }\n\n getClient(): EventStoreDBClient {\n return EventStoreDBClient.connectionString(this.getConnectionString());\n }\n}\n\nlet container: EventStoreDBContainer | null = null;\nlet startedContainer: StartedEventStoreDBContainer | null = null;\nlet startedCount = 0;\nconst lock = InProcessLock();\n\nexport const getSharedEventStoreDBTestContainer = () =>\n lock.withAcquire(\n async () => {\n if (startedContainer) return startedContainer;\n\n if (!container)\n container = new EventStoreDBContainer(EVENTSTOREDB_DEFAULT_IMAGE);\n\n startedContainer = await container.start();\n startedCount++;\n\n container.withLogConsumer((stream) =>\n stream\n .on('data', (line) => console.log(line))\n .on('err', (line) => console.error(line))\n .on('end', () => console.log('Stream closed')),\n );\n\n return startedContainer;\n },\n { lockId: 'SharedEventStoreDBTestContainer' },\n );\n\nexport const getSharedTestEventStoreDBClient = async () => {\n return (await getSharedEventStoreDBTestContainer()).getClient();\n};\n\nexport const releaseSharedEventStoreDBTestContainer = () =>\n lock.withAcquire(\n async () => {\n const containerToStop = startedContainer;\n if (containerToStop && --startedCount === 0) {\n try {\n startedContainer = null;\n container = null;\n await containerToStop.stop();\n } catch {\n /* do nothing */\n }\n }\n },\n { lockId: 'SharedEventStoreDBTestContainer' },\n );\n","import { EventStoreDBClient } from '@eventstore/db-client';\nimport type { StartedEventStoreDBContainer } from './eventStoreDBContainer';\nimport { EventStoreDBContainer } from './eventStoreDBContainer';\n\nexport * from './eventStoreDBContainer';\n\nlet esdbContainer: StartedEventStoreDBContainer;\n\nexport const getEventStoreDBTestClient = async (\n useTestContainers = false,\n): Promise<EventStoreDBClient> => {\n let connectionString;\n\n if (useTestContainers) {\n if (!esdbContainer)\n esdbContainer = await new EventStoreDBContainer().start();\n\n connectionString = esdbContainer.getConnectionString();\n } else {\n // await compose.upAll();\n connectionString = 'esdb://localhost:2113?tls=false';\n }\n\n // That's how EventStoreDB client is setup\n // We're taking the connection string from container\n return EventStoreDBClient.connectionString(connectionString);\n};\n","import { MongoDBContainer } from '@testcontainers/mongodb';\n\nexport const getMongoDBContainer = (\n options: { version: string } = { version: '6.0.1' },\n) => {\n return new MongoDBContainer(`mongo:${options.version}`);\n};\n\nexport const getMongoDBStartedContainer = async (\n options: { version: string } = { version: '6.0.1' },\n) => {\n const container = getMongoDBContainer(options);\n return container.start();\n};\n","import { PostgreSqlContainer } from '@testcontainers/postgresql';\n\nexport const getPostgreSQLContainer = (\n options: { version: string } = { version: '18.1' },\n) => {\n return new PostgreSqlContainer(`postgres:${options.version}`);\n};\n\nexport const getPostgreSQLStartedContainer = async (\n options: { version: string } = { version: '18.1' },\n) => {\n const container = getPostgreSQLContainer(options);\n return container.start();\n};\n"],"mappings":";;;;;;;;AAUA,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,yBAAyB;AACtC,MAAa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AU,OAAO;AAC1C;AAEA,WAAU,iBAAiB,WACzB,OACG,GAAG,SAAS,SAAS,QAAQ,IAAI,KAAK,CAAC,CACvC,GAAG,QAAQ,SAAS,QAAQ,MAAM,KAAK,CAAC,CACxC,GAAG,aAAa,QAAQ,IAAI,gBAAgB,CAAC,CACjD;AAED,QAAO;GAET,EAAE,QAAQ,mCAAmC,CAC9C;AAEH,MAAa,kCAAkC,YAAY;AACzD,SAAQ,MAAM,oCAAoC,EAAE,WAAW;;AAGjE,MAAa,+CACX,KAAK,YACH,YAAY;CACV,MAAM,kBAAkB;AACxB,KAAI,mBAAmB,EAAE,iBAAiB,EACxC,KAAI;AACF,qBAAmB;AACnB,cAAY;AACZ,QAAM,gBAAgB,MAAM;SACtB;GAKZ,EAAE,QAAQ,mCAAmC,CAC9C;;;;ACnIH,IAAI;AAEJ,MAAa,4BAA4B,OACvC,oBAAoB,UACY;CAChC,IAAI;AAEJ,KAAI,mBAAmB;AACrB,MAAI,CAAC,cACH,iBAAgB,MAAM,IAAI,uBAAuB,CAAC,OAAO;AAE3D,qBAAmB,cAAc,qBAAqB;OAGtD,oBAAmB;AAKrB,QAAOC,yCAAmB,iBAAiB,iBAAiB;;;;;ACvB9D,MAAa,uBACX,UAA+B,EAAE,SAAS,SAAS,KAChD;AACH,QAAO,IAAIC,yCAAiB,SAAS,QAAQ,UAAU;;AAGzD,MAAa,6BAA6B,OACxC,UAA+B,EAAE,SAAS,SAAS,KAChD;AAEH,QADkB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["GenericContainer","Wait","AbstractStartedContainer","EventStoreDBClient","EventStoreDBClient","MongoDBContainer","PostgreSqlContainer"],"sources":["../src/eventStore/eventStoreDBContainer.ts","../src/eventStore/index.ts","../src/mongodb/mongoDBContainer.ts","../src/postgresql/postgreSQLContainer.ts"],"sourcesContent":["import { InProcessLock } from '@event-driven-io/emmett';\nimport { EventStoreDBClient } from '@eventstore/db-client';\nimport {\n AbstractStartedContainer,\n GenericContainer,\n Wait,\n type StartedTestContainer,\n} from 'testcontainers';\nimport type { Environment } from 'testcontainers/build/types';\n\nexport const EVENTSTOREDB_PORT = 2113;\nexport const EVENTSTOREDB_IMAGE_NAME = 'eventstore/eventstore';\nexport const EVENTSTOREDB_IMAGE_TAG = '24.10.0-bookworm-slim';\nexport const EVENTSTOREDB_ARM64_IMAGE_TAG = '24.10.0-alpha-arm64v8';\n\nexport const EVENTSTOREDB_DEFAULT_IMAGE = `${EVENTSTOREDB_IMAGE_NAME}:${process.arch !== 'arm64' ? EVENTSTOREDB_IMAGE_TAG : EVENTSTOREDB_ARM64_IMAGE_TAG}`;\n\nexport type EventStoreDBContainerOptions = {\n disableProjections?: boolean;\n isSecure?: boolean;\n useFileStorage?: boolean;\n withReuse?: boolean;\n};\n\nexport const defaultEventStoreDBContainerOptions: EventStoreDBContainerOptions =\n {\n disableProjections: false,\n isSecure: false,\n useFileStorage: false,\n withReuse: false,\n };\n\nexport class EventStoreDBContainer extends GenericContainer {\n constructor(\n image = EVENTSTOREDB_DEFAULT_IMAGE,\n options: EventStoreDBContainerOptions = defaultEventStoreDBContainerOptions,\n ) {\n super(image);\n\n const environment: Environment = {\n ...(!options.disableProjections\n ? {\n EVENTSTORE_RUN_PROJECTIONS: 'ALL',\n }\n : {}),\n ...(!options.isSecure\n ? {\n EVENTSTORE_INSECURE: 'true',\n }\n : {}),\n ...(options.useFileStorage\n ? {\n EVENTSTORE_MEM_DB: 'false',\n EVENTSTORE_DB: '/data/integration-tests',\n }\n : {}),\n EVENTSTORE_CLUSTER_SIZE: '1',\n EVENTSTORE_START_STANDARD_PROJECTIONS: 'true',\n EVENTSTORE_NODE_PORT: `${EVENTSTOREDB_PORT}`,\n EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: 'true',\n };\n\n this.withEnvironment(environment).withExposedPorts(EVENTSTOREDB_PORT);\n\n if (options.withReuse) this.withReuse();\n\n this.withWaitStrategy(\n Wait.forAll([Wait.forHealthCheck(), Wait.forListeningPorts()]),\n );\n }\n\n async start(): Promise<StartedEventStoreDBContainer> {\n return new StartedEventStoreDBContainer(await super.start());\n }\n}\n\nexport class StartedEventStoreDBContainer extends AbstractStartedContainer {\n constructor(container: StartedTestContainer) {\n super(container);\n }\n\n getConnectionString(): string {\n return `esdb://${this.getHost()}:${this.getMappedPort(2113)}?tls=false`;\n }\n\n getClient(): EventStoreDBClient {\n return EventStoreDBClient.connectionString(this.getConnectionString());\n }\n}\n\nlet container: EventStoreDBContainer | null = null;\nlet startedContainer: StartedEventStoreDBContainer | null = null;\nlet startedCount = 0;\nconst lock = InProcessLock();\n\nexport const getSharedEventStoreDBTestContainer = () =>\n lock.withAcquire(\n async () => {\n if (startedContainer) return startedContainer;\n\n if (!container)\n container = new EventStoreDBContainer(EVENTSTOREDB_DEFAULT_IMAGE);\n\n startedContainer = await container.start();\n startedCount++;\n\n container.withLogConsumer((stream) =>\n stream\n .on('data', (line) => console.log(line))\n .on('err', (line) => console.error(line))\n .on('end', () => console.log('Stream closed')),\n );\n\n return startedContainer;\n },\n { lockId: 'SharedEventStoreDBTestContainer' },\n );\n\nexport const getSharedTestEventStoreDBClient = async () => {\n return (await getSharedEventStoreDBTestContainer()).getClient();\n};\n\nexport const releaseSharedEventStoreDBTestContainer = () =>\n lock.withAcquire(\n async () => {\n const containerToStop = startedContainer;\n if (containerToStop && --startedCount === 0) {\n try {\n startedContainer = null;\n container = null;\n await containerToStop.stop();\n } catch {\n /* do nothing */\n }\n }\n },\n { lockId: 'SharedEventStoreDBTestContainer' },\n );\n","import { EventStoreDBClient } from '@eventstore/db-client';\nimport type { StartedEventStoreDBContainer } from './eventStoreDBContainer';\nimport { EventStoreDBContainer } from './eventStoreDBContainer';\n\nexport * from './eventStoreDBContainer';\n\nlet esdbContainer: StartedEventStoreDBContainer;\n\nexport const getEventStoreDBTestClient = async (\n useTestContainers = false,\n): Promise<EventStoreDBClient> => {\n let connectionString;\n\n if (useTestContainers) {\n if (!esdbContainer)\n esdbContainer = await new EventStoreDBContainer().start();\n\n connectionString = esdbContainer.getConnectionString();\n } else {\n // await compose.upAll();\n connectionString = 'esdb://localhost:2113?tls=false';\n }\n\n // That's how EventStoreDB client is setup\n // We're taking the connection string from container\n return EventStoreDBClient.connectionString(connectionString);\n};\n","import { MongoDBContainer } from '@testcontainers/mongodb';\n\nexport const getMongoDBContainer = (\n options: { version: string } = { version: '6.0.1' },\n) => {\n return new MongoDBContainer(`mongo:${options.version}`);\n};\n\nexport const getMongoDBStartedContainer = async (\n options: { version: string } = { version: '6.0.1' },\n) => {\n const container = getMongoDBContainer(options);\n return container.start();\n};\n","import { PostgreSqlContainer } from '@testcontainers/postgresql';\n\nexport const getPostgreSQLContainer = (\n options: { version: string } = { version: '18.1' },\n) => {\n return new PostgreSqlContainer(`postgres:${options.version}`);\n};\n\nexport const getPostgreSQLStartedContainer = async (\n options: { version: string } = { version: '18.1' },\n) => {\n const container = getPostgreSQLContainer(options);\n return container.start();\n};\n"],"mappings":";;;;;;;;AAUA,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,yBAAyB;AACtC,MAAa,+BAA+B;AAE5C,MAAa,6BAA6B,GAAG,wBAAwB,GAAG,QAAQ,SAAS,UAAU,yBAAyB;AAS5H,MAAa,sCACX;CACE,oBAAoB;CACpB,UAAU;CACV,gBAAgB;CAChB,WAAW;CACZ;AAEH,IAAa,wBAAb,cAA2CA,gCAAiB;CAC1D,YACE,QAAQ,4BACR,UAAwC,qCACxC;AACA,QAAM,MAAM;EAEZ,MAAM,cAA2B;GAC/B,GAAI,CAAC,QAAQ,qBACT,EACE,4BAA4B,OAC7B,GACD,EAAE;GACN,GAAI,CAAC,QAAQ,WACT,EACE,qBAAqB,QACtB,GACD,EAAE;GACN,GAAI,QAAQ,iBACR;IACE,mBAAmB;IACnB,eAAe;IAChB,GACD,EAAE;GACN,yBAAyB;GACzB,uCAAuC;GACvC,sBAAsB,GAAG;GACzB,sCAAsC;GACvC;AAED,OAAK,gB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,OACvC,oBAAoB,UACY;CAChC,IAAI;AAEJ,KAAI,mBAAmB;AACrB,MAAI,CAAC,cACH,iBAAgB,MAAM,IAAI,uBAAuB,CAAC,OAAO;AAE3D,qBAAmB,cAAc,qBAAqB;OAGtD,oBAAmB;AAKrB,QAAOC,yCAAmB,iBAAiB,iBAAiB;;;;;ACvB9D,MAAa,uBACX,UAA+B,EAAE,SAAS,SAAS,KAChD;AACH,QAAO,IAAIC,yCAAiB,SAAS,QAAQ,UAAU;;AAGzD,MAAa,6BAA6B,OACxC,UAA+B,EAAE,SAAS,SAAS,KAChD;AAEH,QADkB,oBAAoB,QACtB,CAAC,OAAO;;;;;ACV1B,MAAa,0BACX,UAA+B,EAAE,SAAS,QAAQ,KAC/C;AACH,QAAO,IAAIC,+CAAoB,YAAY,QAAQ,UAAU;;AAG/D,MAAa,gCAAgC,OAC3C,UAA+B,EAAE,SAAS,QAAQ,KAC/C;AAEH,QADkB,uBAAuB,QACzB,CAAC,OAAO"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/eventStore/eventStoreDBContainer.ts","../src/eventStore/index.ts","../src/mongodb/mongoDBContainer.ts","../src/postgresql/postgreSQLContainer.ts"],"sourcesContent":["import { InProcessLock } from '@event-driven-io/emmett';\nimport { EventStoreDBClient } from '@eventstore/db-client';\nimport {\n AbstractStartedContainer,\n GenericContainer,\n Wait,\n type StartedTestContainer,\n} from 'testcontainers';\nimport type { Environment } from 'testcontainers/build/types';\n\nexport const EVENTSTOREDB_PORT = 2113;\nexport const EVENTSTOREDB_IMAGE_NAME = 'eventstore/eventstore';\nexport const EVENTSTOREDB_IMAGE_TAG = '24.10.0-bookworm-slim';\nexport const EVENTSTOREDB_ARM64_IMAGE_TAG = '24.10.0-alpha-arm64v8';\n\nexport const EVENTSTOREDB_DEFAULT_IMAGE = `${EVENTSTOREDB_IMAGE_NAME}:${process.arch !== 'arm64' ? EVENTSTOREDB_IMAGE_TAG : EVENTSTOREDB_ARM64_IMAGE_TAG}`;\n\nexport type EventStoreDBContainerOptions = {\n disableProjections?: boolean;\n isSecure?: boolean;\n useFileStorage?: boolean;\n withReuse?: boolean;\n};\n\nexport const defaultEventStoreDBContainerOptions: EventStoreDBContainerOptions =\n {\n disableProjections: false,\n isSecure: false,\n useFileStorage: false,\n withReuse: false,\n };\n\nexport class EventStoreDBContainer extends GenericContainer {\n constructor(\n image = EVENTSTOREDB_DEFAULT_IMAGE,\n options: EventStoreDBContainerOptions = defaultEventStoreDBContainerOptions,\n ) {\n super(image);\n\n const environment: Environment = {\n ...(!options.disableProjections\n ? {\n EVENTSTORE_RUN_PROJECTIONS: 'ALL',\n }\n : {}),\n ...(!options.isSecure\n ? {\n EVENTSTORE_INSECURE: 'true',\n }\n : {}),\n ...(options.useFileStorage\n ? {\n EVENTSTORE_MEM_DB: 'false',\n EVENTSTORE_DB: '/data/integration-tests',\n }\n : {}),\n EVENTSTORE_CLUSTER_SIZE: '1',\n EVENTSTORE_START_STANDARD_PROJECTIONS: 'true',\n EVENTSTORE_NODE_PORT: `${EVENTSTOREDB_PORT}`,\n EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: 'true',\n };\n\n this.withEnvironment(environment).withExposedPorts(EVENTSTOREDB_PORT);\n\n if (options.withReuse) this.withReuse();\n\n this.withWaitStrategy(\n Wait.forAll([Wait.forHealthCheck(), Wait.forListeningPorts()]),\n );\n }\n\n async start(): Promise<StartedEventStoreDBContainer> {\n return new StartedEventStoreDBContainer(await super.start());\n }\n}\n\nexport class StartedEventStoreDBContainer extends AbstractStartedContainer {\n constructor(container: StartedTestContainer) {\n super(container);\n }\n\n getConnectionString(): string {\n return `esdb://${this.getHost()}:${this.getMappedPort(2113)}?tls=false`;\n }\n\n getClient(): EventStoreDBClient {\n return EventStoreDBClient.connectionString(this.getConnectionString());\n }\n}\n\nlet container: EventStoreDBContainer | null = null;\nlet startedContainer: StartedEventStoreDBContainer | null = null;\nlet startedCount = 0;\nconst lock = InProcessLock();\n\nexport const getSharedEventStoreDBTestContainer = () =>\n lock.withAcquire(\n async () => {\n if (startedContainer) return startedContainer;\n\n if (!container)\n container = new EventStoreDBContainer(EVENTSTOREDB_DEFAULT_IMAGE);\n\n startedContainer = await container.start();\n startedCount++;\n\n container.withLogConsumer((stream) =>\n stream\n .on('data', (line) => console.log(line))\n .on('err', (line) => console.error(line))\n .on('end', () => console.log('Stream closed')),\n );\n\n return startedContainer;\n },\n { lockId: 'SharedEventStoreDBTestContainer' },\n );\n\nexport const getSharedTestEventStoreDBClient = async () => {\n return (await getSharedEventStoreDBTestContainer()).getClient();\n};\n\nexport const releaseSharedEventStoreDBTestContainer = () =>\n lock.withAcquire(\n async () => {\n const containerToStop = startedContainer;\n if (containerToStop && --startedCount === 0) {\n try {\n startedContainer = null;\n container = null;\n await containerToStop.stop();\n } catch {\n /* do nothing */\n }\n }\n },\n { lockId: 'SharedEventStoreDBTestContainer' },\n );\n","import { EventStoreDBClient } from '@eventstore/db-client';\nimport type { StartedEventStoreDBContainer } from './eventStoreDBContainer';\nimport { EventStoreDBContainer } from './eventStoreDBContainer';\n\nexport * from './eventStoreDBContainer';\n\nlet esdbContainer: StartedEventStoreDBContainer;\n\nexport const getEventStoreDBTestClient = async (\n useTestContainers = false,\n): Promise<EventStoreDBClient> => {\n let connectionString;\n\n if (useTestContainers) {\n if (!esdbContainer)\n esdbContainer = await new EventStoreDBContainer().start();\n\n connectionString = esdbContainer.getConnectionString();\n } else {\n // await compose.upAll();\n connectionString = 'esdb://localhost:2113?tls=false';\n }\n\n // That's how EventStoreDB client is setup\n // We're taking the connection string from container\n return EventStoreDBClient.connectionString(connectionString);\n};\n","import { MongoDBContainer } from '@testcontainers/mongodb';\n\nexport const getMongoDBContainer = (\n options: { version: string } = { version: '6.0.1' },\n) => {\n return new MongoDBContainer(`mongo:${options.version}`);\n};\n\nexport const getMongoDBStartedContainer = async (\n options: { version: string } = { version: '6.0.1' },\n) => {\n const container = getMongoDBContainer(options);\n return container.start();\n};\n","import { PostgreSqlContainer } from '@testcontainers/postgresql';\n\nexport const getPostgreSQLContainer = (\n options: { version: string } = { version: '18.1' },\n) => {\n return new PostgreSqlContainer(`postgres:${options.version}`);\n};\n\nexport const getPostgreSQLStartedContainer = async (\n options: { version: string } = { version: '18.1' },\n) => {\n const container = getPostgreSQLContainer(options);\n return container.start();\n};\n"],"mappings":";;;;;;;AAUA,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,yBAAyB;AACtC,MAAa,+BAA+B;AAE5C,MAAa,6BAA6B,GAAG,wBAAwB,GAAG,QAAQ,SAAS,UAAU,yBAAyB;AAS5H,MAAa,sCACX;CACE,oBAAoB;CACpB,UAAU;CACV,gBAAgB;CAChB,WAAW;CACZ;AAEH,IAAa,wBAAb,cAA2C,iBAAiB;CAC1D,YACE,QAAQ,4BACR,UAAwC,qCACxC;AACA,QAAM,MAAM;EAEZ,MAAM,cAA2B;GAC/B,GAAI,CAAC,QAAQ,qBACT,EACE,4BAA4B,OAC7B,GACD,EAAE;GACN,GAAI,CAAC,QAAQ,WACT,EACE,qBAAqB,QACtB,GACD,EAAE;GACN,GAAI,QAAQ,iBACR;IACE,mBAAmB;IACnB,eAAe;IAChB,GACD,EAAE;GACN,yBAAyB;GACzB,uCAAuC;GACvC,sBAAsB,GAAG;GACzB,sCAAsC;GACvC;AAED,OAAK,gBAAgB,YAAY,CAAC,iBAAiB,kBAAkB;AAErE,MAAI,QAAQ,UAAW,MAAK,WAAW;AAEvC,OAAK,iBACH,KAAK,OAAO,CAAC,KAAK,gBAAgB,EAAE,KAAK,mBAAmB,CAAC,CAAC,CAC/D;;CAGH,MAAM,QAA+C;AACnD,SAAO,IAAI,6BAA6B,MAAM,MAAM,OAAO,CAAC;;;AAIhE,IAAa,+BAAb,cAAkD,yBAAyB;CACzE,YAAY,WAAiC;AAC3C,QAAM,UAAU;;CAGlB,sBAA8B;AAC5B,SAAO,UAAU,KAA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,KAChD;AAEH,QADkB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/eventStore/eventStoreDBContainer.ts","../src/eventStore/index.ts","../src/mongodb/mongoDBContainer.ts","../src/postgresql/postgreSQLContainer.ts"],"sourcesContent":["import { InProcessLock } from '@event-driven-io/emmett';\nimport { EventStoreDBClient } from '@eventstore/db-client';\nimport {\n AbstractStartedContainer,\n GenericContainer,\n Wait,\n type StartedTestContainer,\n} from 'testcontainers';\nimport type { Environment } from 'testcontainers/build/types';\n\nexport const EVENTSTOREDB_PORT = 2113;\nexport const EVENTSTOREDB_IMAGE_NAME = 'eventstore/eventstore';\nexport const EVENTSTOREDB_IMAGE_TAG = '24.10.0-bookworm-slim';\nexport const EVENTSTOREDB_ARM64_IMAGE_TAG = '24.10.0-alpha-arm64v8';\n\nexport const EVENTSTOREDB_DEFAULT_IMAGE = `${EVENTSTOREDB_IMAGE_NAME}:${process.arch !== 'arm64' ? EVENTSTOREDB_IMAGE_TAG : EVENTSTOREDB_ARM64_IMAGE_TAG}`;\n\nexport type EventStoreDBContainerOptions = {\n disableProjections?: boolean;\n isSecure?: boolean;\n useFileStorage?: boolean;\n withReuse?: boolean;\n};\n\nexport const defaultEventStoreDBContainerOptions: EventStoreDBContainerOptions =\n {\n disableProjections: false,\n isSecure: false,\n useFileStorage: false,\n withReuse: false,\n };\n\nexport class EventStoreDBContainer extends GenericContainer {\n constructor(\n image = EVENTSTOREDB_DEFAULT_IMAGE,\n options: EventStoreDBContainerOptions = defaultEventStoreDBContainerOptions,\n ) {\n super(image);\n\n const environment: Environment = {\n ...(!options.disableProjections\n ? {\n EVENTSTORE_RUN_PROJECTIONS: 'ALL',\n }\n : {}),\n ...(!options.isSecure\n ? {\n EVENTSTORE_INSECURE: 'true',\n }\n : {}),\n ...(options.useFileStorage\n ? {\n EVENTSTORE_MEM_DB: 'false',\n EVENTSTORE_DB: '/data/integration-tests',\n }\n : {}),\n EVENTSTORE_CLUSTER_SIZE: '1',\n EVENTSTORE_START_STANDARD_PROJECTIONS: 'true',\n EVENTSTORE_NODE_PORT: `${EVENTSTOREDB_PORT}`,\n EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: 'true',\n };\n\n this.withEnvironment(environment).withExposedPorts(EVENTSTOREDB_PORT);\n\n if (options.withReuse) this.withReuse();\n\n this.withWaitStrategy(\n Wait.forAll([Wait.forHealthCheck(), Wait.forListeningPorts()]),\n );\n }\n\n async start(): Promise<StartedEventStoreDBContainer> {\n return new StartedEventStoreDBContainer(await super.start());\n }\n}\n\nexport class StartedEventStoreDBContainer extends AbstractStartedContainer {\n constructor(container: StartedTestContainer) {\n super(container);\n }\n\n getConnectionString(): string {\n return `esdb://${this.getHost()}:${this.getMappedPort(2113)}?tls=false`;\n }\n\n getClient(): EventStoreDBClient {\n return EventStoreDBClient.connectionString(this.getConnectionString());\n }\n}\n\nlet container: EventStoreDBContainer | null = null;\nlet startedContainer: StartedEventStoreDBContainer | null = null;\nlet startedCount = 0;\nconst lock = InProcessLock();\n\nexport const getSharedEventStoreDBTestContainer = () =>\n lock.withAcquire(\n async () => {\n if (startedContainer) return startedContainer;\n\n if (!container)\n container = new EventStoreDBContainer(EVENTSTOREDB_DEFAULT_IMAGE);\n\n startedContainer = await container.start();\n startedCount++;\n\n container.withLogConsumer((stream) =>\n stream\n .on('data', (line) => console.log(line))\n .on('err', (line) => console.error(line))\n .on('end', () => console.log('Stream closed')),\n );\n\n return startedContainer;\n },\n { lockId: 'SharedEventStoreDBTestContainer' },\n );\n\nexport const getSharedTestEventStoreDBClient = async () => {\n return (await getSharedEventStoreDBTestContainer()).getClient();\n};\n\nexport const releaseSharedEventStoreDBTestContainer = () =>\n lock.withAcquire(\n async () => {\n const containerToStop = startedContainer;\n if (containerToStop && --startedCount === 0) {\n try {\n startedContainer = null;\n container = null;\n await containerToStop.stop();\n } catch {\n /* do nothing */\n }\n }\n },\n { lockId: 'SharedEventStoreDBTestContainer' },\n );\n","import { EventStoreDBClient } from '@eventstore/db-client';\nimport type { StartedEventStoreDBContainer } from './eventStoreDBContainer';\nimport { EventStoreDBContainer } from './eventStoreDBContainer';\n\nexport * from './eventStoreDBContainer';\n\nlet esdbContainer: StartedEventStoreDBContainer;\n\nexport const getEventStoreDBTestClient = async (\n useTestContainers = false,\n): Promise<EventStoreDBClient> => {\n let connectionString;\n\n if (useTestContainers) {\n if (!esdbContainer)\n esdbContainer = await new EventStoreDBContainer().start();\n\n connectionString = esdbContainer.getConnectionString();\n } else {\n // await compose.upAll();\n connectionString = 'esdb://localhost:2113?tls=false';\n }\n\n // That's how EventStoreDB client is setup\n // We're taking the connection string from container\n return EventStoreDBClient.connectionString(connectionString);\n};\n","import { MongoDBContainer } from '@testcontainers/mongodb';\n\nexport const getMongoDBContainer = (\n options: { version: string } = { version: '6.0.1' },\n) => {\n return new MongoDBContainer(`mongo:${options.version}`);\n};\n\nexport const getMongoDBStartedContainer = async (\n options: { version: string } = { version: '6.0.1' },\n) => {\n const container = getMongoDBContainer(options);\n return container.start();\n};\n","import { PostgreSqlContainer } from '@testcontainers/postgresql';\n\nexport const getPostgreSQLContainer = (\n options: { version: string } = { version: '18.1' },\n) => {\n return new PostgreSqlContainer(`postgres:${options.version}`);\n};\n\nexport const getPostgreSQLStartedContainer = async (\n options: { version: string } = { version: '18.1' },\n) => {\n const container = getPostgreSQLContainer(options);\n return container.start();\n};\n"],"mappings":";;;;;;;AAUA,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,yBAAyB;AACtC,MAAa,+BAA+B;AAE5C,MAAa,6BAA6B,GAAG,wBAAwB,GAAG,QAAQ,SAAS,UAAU,yBAAyB;AAS5H,MAAa,sCACX;CACE,oBAAoB;CACpB,UAAU;CACV,gBAAgB;CAChB,WAAW;CACZ;AAEH,IAAa,wBAAb,cAA2C,iBAAiB;CAC1D,YACE,QAAQ,4BACR,UAAwC,qCACxC;AACA,QAAM,MAAM;EAEZ,MAAM,cAA2B;GAC/B,GAAI,CA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oC,EAAE,WAAW;;AAGjE,MAAa,+CACX,KAAK,YACH,YAAY;CACV,MAAM,kBAAkB;AACxB,KAAI,mBAAmB,EAAE,iBAAiB,EACxC,KAAI;AACF,qBAAmB;AACnB,cAAY;AACZ,QAAM,gBAAgB,MAAM;SACtB;GAKZ,EAAE,QAAQ,mCAAmC,CAC9C;;;;ACnIH,IAAI;AAEJ,MAAa,4BAA4B,OACvC,oBAAoB,UACY;CAChC,IAAI;AAEJ,KAAI,mBAAmB;AACrB,MAAI,CAAC,cACH,iBAAgB,MAAM,IAAI,uBAAuB,CAAC,OAAO;AAE3D,qBAAmB,cAAc,qBAAqB;OAGtD,oBAAmB;AAKrB,QAAO,mBAAmB,iBAAiB,iBAAiB;;;;;ACvB9D,MAAa,uBACX,UAA+B,EAAE,SAAS,SAAS,KAChD;AACH,QAAO,IAAI,iBAAiB,SAAS,QAAQ,UAAU;;AAGzD,MAAa,6BAA6B,OACxC,UAA+B,EAAE,SAAS,SAAS,KAChD;AAEH,QADkB,oBAAoB,QACtB,CAAC,OAAO;;;;;ACV1B,MAAa,0BACX,UAA+B,EAAE,SAAS,QAAQ,KAC/C;AACH,QAAO,IAAI,oBAAoB,YAAY,QAAQ,UAAU;;AAG/D,MAAa,gCAAgC,OAC3C,UAA+B,EAAE,SAAS,QAAQ,KAC/C;AAEH,QADkB,uBAAuB,QACzB,CAAC,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@event-driven-io/emmett-testcontainers",
|
|
3
|
-
"version": "0.43.0-beta.
|
|
3
|
+
"version": "0.43.0-beta.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Emmett - TestContainers - Event Sourcing development made simple",
|
|
6
6
|
"scripts": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dist"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@event-driven-io/emmett": "0.43.0-beta.
|
|
50
|
+
"@event-driven-io/emmett": "0.43.0-beta.15",
|
|
51
51
|
"@testcontainers/mongodb": "^11.14.0",
|
|
52
52
|
"@testcontainers/postgresql": "^11.14.0",
|
|
53
53
|
"testcontainers": "^11.14.0"
|