@event-driven-io/emmett-postgresql 0.13.0 → 0.14.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.
Files changed (43) hide show
  1. package/dist/chunk-2452BJTJ.js +1 -0
  2. package/dist/chunk-45ODDXOQ.mjs +1 -0
  3. package/dist/{chunk-UMUX2OL5.mjs → chunk-7PVUE3OV.mjs} +2 -2
  4. package/dist/chunk-BBOP347O.mjs +2 -0
  5. package/dist/chunk-BBOP347O.mjs.map +1 -0
  6. package/dist/{chunk-WHT7LTAU.js → chunk-ICKSIW7K.js} +2 -2
  7. package/dist/chunk-S6NGBYJW.js +2 -0
  8. package/dist/chunk-S6NGBYJW.js.map +1 -0
  9. package/dist/eventStore/index.d.mts +1 -1
  10. package/dist/eventStore/index.d.ts +1 -1
  11. package/dist/eventStore/index.js +1 -1
  12. package/dist/eventStore/index.mjs +1 -1
  13. package/dist/eventStore/postgreSQLEventStore.d.mts +1 -1
  14. package/dist/eventStore/postgreSQLEventStore.d.ts +1 -1
  15. package/dist/eventStore/postgreSQLEventStore.js +1 -1
  16. package/dist/eventStore/postgreSQLEventStore.mjs +1 -1
  17. package/dist/eventStore/projections/index.d.mts +1 -1
  18. package/dist/eventStore/projections/index.d.ts +1 -1
  19. package/dist/eventStore/projections/index.js +1 -1
  20. package/dist/eventStore/projections/index.mjs +1 -1
  21. package/dist/eventStore/projections/pongo.d.mts +1 -1
  22. package/dist/eventStore/projections/pongo.d.ts +1 -1
  23. package/dist/eventStore/projections/pongo.js +1 -1
  24. package/dist/eventStore/projections/pongo.js.map +1 -1
  25. package/dist/eventStore/projections/pongo.mjs +1 -1
  26. package/dist/eventStore/projections/pongo.mjs.map +1 -1
  27. package/dist/index.d.mts +1 -1
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/index.mjs +1 -1
  31. package/dist/{postgreSQLEventStore-Dz2eALUF.d.mts → postgreSQLEventStore-B7GlXfis.d.mts} +8 -2
  32. package/dist/{postgreSQLEventStore-Dz2eALUF.d.ts → postgreSQLEventStore-B7GlXfis.d.ts} +8 -2
  33. package/package.json +2 -2
  34. package/dist/chunk-HIATDE4Q.mjs +0 -1
  35. package/dist/chunk-KA3LTDXJ.mjs +0 -2
  36. package/dist/chunk-KA3LTDXJ.mjs.map +0 -1
  37. package/dist/chunk-MERDQHBQ.js +0 -1
  38. package/dist/chunk-MI5QKIUY.js +0 -2
  39. package/dist/chunk-MI5QKIUY.js.map +0 -1
  40. /package/dist/{chunk-MERDQHBQ.js.map → chunk-2452BJTJ.js.map} +0 -0
  41. /package/dist/{chunk-HIATDE4Q.mjs.map → chunk-45ODDXOQ.mjs.map} +0 -0
  42. /package/dist/{chunk-UMUX2OL5.mjs.map → chunk-7PVUE3OV.mjs.map} +0 -0
  43. /package/dist/{chunk-WHT7LTAU.js.map → chunk-ICKSIW7K.js.map} +0 -0
@@ -0,0 +1 @@
1
+ "use strict";//# sourceMappingURL=chunk-2452BJTJ.js.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-45ODDXOQ.mjs.map
@@ -1,2 +1,2 @@
1
- import{a as y,b as f}from"./chunk-KA3LTDXJ.mjs";import{b as R}from"./chunk-QHCLGPQG.mjs";import{b as T}from"./chunk-COTRMVOL.mjs";import{a as P}from"./chunk-D5T7G7UL.mjs";import{c as v,d as g,e as S,f as c}from"./chunk-E56AUXA3.mjs";import{endPool as x,getPool as O}from"@event-driven-io/dumbo";var D=(e,t=y)=>{let m=O(e),d=R(m),{projections:V}=t;return{async aggregateStream(n,r){await d;let{evolve:s,initialState:i,read:E}=r,l=E?.expectedStreamVersion,o=i(),a=await this.readStream(n,r.read);if(a===null)return null;let p=a.currentStreamVersion;w(p,l);for(let u of a.events)u&&(o=s(o,u));return{currentStreamVersion:p,state:o}},readStream:async(n,r)=>(await d,P(m,n,r)),appendToStream:async(n,r,s)=>{await d;let[i,...E]=n.split("-"),l=i&&E.length>0?i:"emt:unknown",o=await T(m,n,l,r,{...s,preCommitHook:(a,p)=>f(V,e,a,p)});if(!o.success)throw new c(-1n,s?.expectedStreamVersion??S);return{nextExpectedStreamVersion:o.nextStreamPosition}},close:()=>x({connectionString:e})}},h=(e,t)=>t===S?!0:t==g?e===void 0:t==v?e!==void 0:e===t,w=(e,t)=>{if(t??=S,!h(e,t))throw new c(e,t)};export{D as a};
2
- //# sourceMappingURL=chunk-UMUX2OL5.mjs.map
1
+ import{a as y,b as f}from"./chunk-BBOP347O.mjs";import{b as R}from"./chunk-QHCLGPQG.mjs";import{b as T}from"./chunk-COTRMVOL.mjs";import{a as P}from"./chunk-D5T7G7UL.mjs";import{c as v,d as g,e as S,f as c}from"./chunk-E56AUXA3.mjs";import{endPool as x,getPool as O}from"@event-driven-io/dumbo";var D=(e,t=y)=>{let m=O(e),d=R(m),{projections:V}=t;return{async aggregateStream(n,r){await d;let{evolve:s,initialState:i,read:E}=r,l=E?.expectedStreamVersion,o=i(),a=await this.readStream(n,r.read);if(a===null)return null;let p=a.currentStreamVersion;w(p,l);for(let u of a.events)u&&(o=s(o,u));return{currentStreamVersion:p,state:o}},readStream:async(n,r)=>(await d,P(m,n,r)),appendToStream:async(n,r,s)=>{await d;let[i,...E]=n.split("-"),l=i&&E.length>0?i:"emt:unknown",o=await T(m,n,l,r,{...s,preCommitHook:(a,p)=>f(V,e,a,p)});if(!o.success)throw new c(-1n,s?.expectedStreamVersion??S);return{nextExpectedStreamVersion:o.nextStreamPosition}},close:()=>x({connectionString:e})}},h=(e,t)=>t===S?!0:t==g?e===void 0:t==v?e!==void 0:e===t,w=(e,t)=>{if(t??=S,!h(e,t))throw new c(e,t)};export{D as a};
2
+ //# sourceMappingURL=chunk-7PVUE3OV.mjs.map
@@ -0,0 +1,2 @@
1
+ import"pg";var a={projections:[]},d=async(e,o,i,n)=>{let r=n.map(t=>t.type),p=e.filter(t=>t.canHandle.some(s=>r.includes(s)));for(let t of p)await t.handle(n,{connectionString:o,client:i})},c=e=>e,P=e=>c({type:"inline",...e});export{a,d as b,c,P as d};
2
+ //# sourceMappingURL=chunk-BBOP347O.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/eventStore/projections/index.ts"],"sourcesContent":["import {\n type Event,\n type EventTypeOf,\n type ReadEvent,\n} from '@event-driven-io/emmett';\nimport pg from 'pg';\nimport type { PostgresEventStoreOptions } from '../postgreSQLEventStore';\n\nexport type ProjectionHandlerContext = {\n connectionString: string;\n client: pg.PoolClient;\n};\n\nexport type PostgresProjectionHandler<EventType extends Event = Event> = (\n events: ReadEvent<EventType>[],\n context: ProjectionHandlerContext,\n) => Promise<void> | void;\n\nexport type ProjectionDefintion<EventType extends Event = Event> = {\n type: 'inline';\n name?: string;\n canHandle: EventTypeOf<EventType>[];\n handle: PostgresProjectionHandler<EventType>;\n};\n\nexport const defaultProjectionOptions: PostgresEventStoreOptions = {\n projections: [],\n};\n\nexport const handleProjections = async <EventType extends Event = Event>(\n allProjections: ProjectionDefintion<EventType>[],\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n): Promise<void> => {\n const eventTypes = events.map((e) => e.type);\n\n const projections = allProjections.filter((p) =>\n p.canHandle.some((type) => eventTypes.includes(type)),\n );\n\n for (const projection of projections) {\n await projection.handle(events, { connectionString, client });\n }\n};\n\nexport const projection = <EventType extends Event>(\n definition: ProjectionDefintion<EventType>,\n): ProjectionDefintion => definition as unknown as ProjectionDefintion;\n\nexport const inlineProjection = <EventType extends Event>(\n definition: Omit<ProjectionDefintion<EventType>, 'type'>,\n): ProjectionDefintion => projection({ type: 'inline', ...definition });\n"],"mappings":"AAKA,MAAe,KAoBR,IAAMA,EAAsD,CACjE,YAAa,CAAC,CAChB,EAEaC,EAAoB,MAC/BC,EACAC,EACAC,EACAC,IACkB,CAClB,IAAMC,EAAaD,EAAO,IAAKE,GAAMA,EAAE,IAAI,EAErCC,EAAcN,EAAe,OAAQO,GACzCA,EAAE,UAAU,KAAMC,GAASJ,EAAW,SAASI,CAAI,CAAC,CACtD,EAEA,QAAWC,KAAcH,EACvB,MAAMG,EAAW,OAAON,EAAQ,CAAE,iBAAAF,EAAkB,OAAAC,CAAO,CAAC,CAEhE,EAEaO,EACXC,GACwBA,EAEbC,EACXD,GACwBD,EAAW,CAAE,KAAM,SAAU,GAAGC,CAAW,CAAC","names":["defaultProjectionOptions","handleProjections","allProjections","connectionString","client","events","eventTypes","e","projections","p","type","projection","definition","inlineProjection"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkMI5QKIUYjs = require('./chunk-MI5QKIUY.js');var _chunkEMFXYVCKjs = require('./chunk-EMFXYVCK.js');var _chunkKADY7IHMjs = require('./chunk-KADY7IHM.js');var _chunkP36ZOB2Ejs = require('./chunk-P36ZOB2E.js');var _chunkXQZVOI6Wjs = require('./chunk-XQZVOI6W.js');var _dumbo = require('@event-driven-io/dumbo');var D=(e,t=_chunkMI5QKIUYjs.a)=>{let m=_dumbo.getPool.call(void 0, e),d=_chunkEMFXYVCKjs.b.call(void 0, m),{projections:V}=t;return{async aggregateStream(n,r){await d;let{evolve:s,initialState:i,read:E}=r,l=_optionalChain([E, 'optionalAccess', _ => _.expectedStreamVersion]),o=i(),a=await this.readStream(n,r.read);if(a===null)return null;let p=a.currentStreamVersion;w(p,l);for(let u of a.events)u&&(o=s(o,u));return{currentStreamVersion:p,state:o}},readStream:async(n,r)=>(await d,_chunkP36ZOB2Ejs.a.call(void 0, m,n,r)),appendToStream:async(n,r,s)=>{await d;let[i,...E]=n.split("-"),l=i&&E.length>0?i:"emt:unknown",o=await _chunkKADY7IHMjs.b.call(void 0, m,n,l,r,{...s,preCommitHook:(a,p)=>_chunkMI5QKIUYjs.b.call(void 0, V,e,a,p)});if(!o.success)throw new (0, _chunkXQZVOI6Wjs.f)(-1n,_nullishCoalesce(_optionalChain([s, 'optionalAccess', _2 => _2.expectedStreamVersion]), () => (_chunkXQZVOI6Wjs.e)));return{nextExpectedStreamVersion:o.nextStreamPosition}},close:()=>_dumbo.endPool.call(void 0, {connectionString:e})}},h=(e,t)=>t===_chunkXQZVOI6Wjs.e?!0:t==_chunkXQZVOI6Wjs.d?e===void 0:t==_chunkXQZVOI6Wjs.c?e!==void 0:e===t,w=(e,t)=>{if(t??=_chunkXQZVOI6Wjs.e,!h(e,t))throw new (0, _chunkXQZVOI6Wjs.f)(e,t)};exports.a = D;
2
- //# sourceMappingURL=chunk-WHT7LTAU.js.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkS6NGBYJWjs = require('./chunk-S6NGBYJW.js');var _chunkEMFXYVCKjs = require('./chunk-EMFXYVCK.js');var _chunkKADY7IHMjs = require('./chunk-KADY7IHM.js');var _chunkP36ZOB2Ejs = require('./chunk-P36ZOB2E.js');var _chunkXQZVOI6Wjs = require('./chunk-XQZVOI6W.js');var _dumbo = require('@event-driven-io/dumbo');var D=(e,t=_chunkS6NGBYJWjs.a)=>{let m=_dumbo.getPool.call(void 0, e),d=_chunkEMFXYVCKjs.b.call(void 0, m),{projections:V}=t;return{async aggregateStream(n,r){await d;let{evolve:s,initialState:i,read:E}=r,l=_optionalChain([E, 'optionalAccess', _ => _.expectedStreamVersion]),o=i(),a=await this.readStream(n,r.read);if(a===null)return null;let p=a.currentStreamVersion;w(p,l);for(let u of a.events)u&&(o=s(o,u));return{currentStreamVersion:p,state:o}},readStream:async(n,r)=>(await d,_chunkP36ZOB2Ejs.a.call(void 0, m,n,r)),appendToStream:async(n,r,s)=>{await d;let[i,...E]=n.split("-"),l=i&&E.length>0?i:"emt:unknown",o=await _chunkKADY7IHMjs.b.call(void 0, m,n,l,r,{...s,preCommitHook:(a,p)=>_chunkS6NGBYJWjs.b.call(void 0, V,e,a,p)});if(!o.success)throw new (0, _chunkXQZVOI6Wjs.f)(-1n,_nullishCoalesce(_optionalChain([s, 'optionalAccess', _2 => _2.expectedStreamVersion]), () => (_chunkXQZVOI6Wjs.e)));return{nextExpectedStreamVersion:o.nextStreamPosition}},close:()=>_dumbo.endPool.call(void 0, {connectionString:e})}},h=(e,t)=>t===_chunkXQZVOI6Wjs.e?!0:t==_chunkXQZVOI6Wjs.d?e===void 0:t==_chunkXQZVOI6Wjs.c?e!==void 0:e===t,w=(e,t)=>{if(t??=_chunkXQZVOI6Wjs.e,!h(e,t))throw new (0, _chunkXQZVOI6Wjs.f)(e,t)};exports.a = D;
2
+ //# sourceMappingURL=chunk-ICKSIW7K.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('pg');var a={projections:[]},d= exports.b =async(e,o,i,n)=>{let r=n.map(t=>t.type),p=e.filter(t=>t.canHandle.some(s=>r.includes(s)));for(let t of p)await t.handle(n,{connectionString:o,client:i})},c= exports.c =e=>e,P= exports.d =e=>c({type:"inline",...e});exports.a = a; exports.b = d; exports.c = c; exports.d = P;
2
+ //# sourceMappingURL=chunk-S6NGBYJW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/eventStore/projections/index.ts"],"names":["defaultProjectionOptions","handleProjections","allProjections","connectionString","client","events","eventTypes","e","projections","p","type","projection","definition","inlineProjection"],"mappings":"AAKA,MAAe,KAoBR,IAAMA,EAAsD,CACjE,YAAa,CAAC,CAChB,EAEaC,EAAoB,MAC/BC,EACAC,EACAC,EACAC,IACkB,CAClB,IAAMC,EAAaD,EAAO,IAAKE,GAAMA,EAAE,IAAI,EAErCC,EAAcN,EAAe,OAAQO,GACzCA,EAAE,UAAU,KAAMC,GAASJ,EAAW,SAASI,CAAI,CAAC,CACtD,EAEA,QAAWC,KAAcH,EACvB,MAAMG,EAAW,OAAON,EAAQ,CAAE,iBAAAF,EAAkB,OAAAC,CAAO,CAAC,CAEhE,EAEaO,EACXC,GACwBA,EAEbC,EACXD,GACwBD,EAAW,CAAE,KAAM,SAAU,GAAGC,CAAW,CAAC","sourcesContent":["import {\n type Event,\n type EventTypeOf,\n type ReadEvent,\n} from '@event-driven-io/emmett';\nimport pg from 'pg';\nimport type { PostgresEventStoreOptions } from '../postgreSQLEventStore';\n\nexport type ProjectionHandlerContext = {\n connectionString: string;\n client: pg.PoolClient;\n};\n\nexport type PostgresProjectionHandler<EventType extends Event = Event> = (\n events: ReadEvent<EventType>[],\n context: ProjectionHandlerContext,\n) => Promise<void> | void;\n\nexport type ProjectionDefintion<EventType extends Event = Event> = {\n type: 'inline';\n name?: string;\n canHandle: EventTypeOf<EventType>[];\n handle: PostgresProjectionHandler<EventType>;\n};\n\nexport const defaultProjectionOptions: PostgresEventStoreOptions = {\n projections: [],\n};\n\nexport const handleProjections = async <EventType extends Event = Event>(\n allProjections: ProjectionDefintion<EventType>[],\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n): Promise<void> => {\n const eventTypes = events.map((e) => e.type);\n\n const projections = allProjections.filter((p) =>\n p.canHandle.some((type) => eventTypes.includes(type)),\n );\n\n for (const projection of projections) {\n await projection.handle(events, { connectionString, client });\n }\n};\n\nexport const projection = <EventType extends Event>(\n definition: ProjectionDefintion<EventType>,\n): ProjectionDefintion => definition as unknown as ProjectionDefintion;\n\nexport const inlineProjection = <EventType extends Event>(\n definition: Omit<ProjectionDefintion<EventType>, 'type'>,\n): ProjectionDefintion => projection({ type: 'inline', ...definition });\n"]}
@@ -1,4 +1,4 @@
1
- export { P as PostgresEventStore, a as PostgresEventStoreOptions, g as getPostgreSQLEventStore } from '../postgreSQLEventStore-Dz2eALUF.mjs';
1
+ export { P as PostgresEventStore, a as PostgresEventStoreOptions, c as PostgresProjectionHandler, d as ProjectionDefintion, b as ProjectionHandlerContext, e as defaultProjectionOptions, g as getPostgreSQLEventStore, h as handleProjections, i as inlineProjection, p as projection } from '../postgreSQLEventStore-B7GlXfis.mjs';
2
2
  export { createEventStoreSchema, schemaSQL } from './schema/index.mjs';
3
3
  export { appendEventsSQL, appendToStream } from './schema/appendToStream.mjs';
4
4
  export { readStream } from './schema/readStream.mjs';
@@ -1,4 +1,4 @@
1
- export { P as PostgresEventStore, a as PostgresEventStoreOptions, g as getPostgreSQLEventStore } from '../postgreSQLEventStore-Dz2eALUF.js';
1
+ export { P as PostgresEventStore, a as PostgresEventStoreOptions, c as PostgresProjectionHandler, d as ProjectionDefintion, b as ProjectionHandlerContext, e as defaultProjectionOptions, g as getPostgreSQLEventStore, h as handleProjections, i as inlineProjection, p as projection } from '../postgreSQLEventStore-B7GlXfis.js';
2
2
  export { createEventStoreSchema, schemaSQL } from './schema/index.js';
3
3
  export { appendEventsSQL, appendToStream } from './schema/appendToStream.js';
4
4
  export { readStream } from './schema/readStream.js';
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-MERDQHBQ.js');var _chunkWHT7LTAUjs = require('../chunk-WHT7LTAU.js');require('../chunk-MI5QKIUY.js');var _chunkEMFXYVCKjs = require('../chunk-EMFXYVCK.js');var _chunkEEYVFO3Gjs = require('../chunk-EEYVFO3G.js');var _chunkKADY7IHMjs = require('../chunk-KADY7IHM.js');var _chunkP36ZOB2Ejs = require('../chunk-P36ZOB2E.js');var _chunkSS2LQM3Bjs = require('../chunk-SS2LQM3B.js');require('../chunk-XQZVOI6W.js');exports.addDefaultPartition = _chunkEEYVFO3Gjs.k; exports.addEventsPartitions = _chunkEEYVFO3Gjs.f; exports.addModuleForAllTenantsSQL = _chunkEEYVFO3Gjs.i; exports.addModuleSQL = _chunkEEYVFO3Gjs.g; exports.addTablePartitions = _chunkEEYVFO3Gjs.e; exports.addTenantForAllModulesSQL = _chunkEEYVFO3Gjs.j; exports.addTenantSQL = _chunkEEYVFO3Gjs.h; exports.appendEventsSQL = _chunkKADY7IHMjs.a; exports.appendToStream = _chunkKADY7IHMjs.b; exports.createEventStoreSchema = _chunkEMFXYVCKjs.b; exports.defaultTag = _chunkSS2LQM3Bjs.c; exports.emmettPrefix = _chunkSS2LQM3Bjs.a; exports.eventsTable = _chunkSS2LQM3Bjs.f; exports.eventsTableSQL = _chunkEEYVFO3Gjs.b; exports.getPostgreSQLEventStore = _chunkWHT7LTAUjs.a; exports.globalNames = _chunkSS2LQM3Bjs.d; exports.globalTag = _chunkSS2LQM3Bjs.b; exports.readStream = _chunkP36ZOB2Ejs.a; exports.sanitizeNameSQL = _chunkEEYVFO3Gjs.d; exports.schemaSQL = _chunkEMFXYVCKjs.a; exports.streamsTable = _chunkSS2LQM3Bjs.e; exports.streamsTableSQL = _chunkEEYVFO3Gjs.a; exports.subscriptionsTableSQL = _chunkEEYVFO3Gjs.c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-2452BJTJ.js');var _chunkICKSIW7Kjs = require('../chunk-ICKSIW7K.js');var _chunkS6NGBYJWjs = require('../chunk-S6NGBYJW.js');var _chunkEMFXYVCKjs = require('../chunk-EMFXYVCK.js');var _chunkEEYVFO3Gjs = require('../chunk-EEYVFO3G.js');var _chunkKADY7IHMjs = require('../chunk-KADY7IHM.js');var _chunkP36ZOB2Ejs = require('../chunk-P36ZOB2E.js');var _chunkSS2LQM3Bjs = require('../chunk-SS2LQM3B.js');require('../chunk-XQZVOI6W.js');exports.addDefaultPartition = _chunkEEYVFO3Gjs.k; exports.addEventsPartitions = _chunkEEYVFO3Gjs.f; exports.addModuleForAllTenantsSQL = _chunkEEYVFO3Gjs.i; exports.addModuleSQL = _chunkEEYVFO3Gjs.g; exports.addTablePartitions = _chunkEEYVFO3Gjs.e; exports.addTenantForAllModulesSQL = _chunkEEYVFO3Gjs.j; exports.addTenantSQL = _chunkEEYVFO3Gjs.h; exports.appendEventsSQL = _chunkKADY7IHMjs.a; exports.appendToStream = _chunkKADY7IHMjs.b; exports.createEventStoreSchema = _chunkEMFXYVCKjs.b; exports.defaultProjectionOptions = _chunkS6NGBYJWjs.a; exports.defaultTag = _chunkSS2LQM3Bjs.c; exports.emmettPrefix = _chunkSS2LQM3Bjs.a; exports.eventsTable = _chunkSS2LQM3Bjs.f; exports.eventsTableSQL = _chunkEEYVFO3Gjs.b; exports.getPostgreSQLEventStore = _chunkICKSIW7Kjs.a; exports.globalNames = _chunkSS2LQM3Bjs.d; exports.globalTag = _chunkSS2LQM3Bjs.b; exports.handleProjections = _chunkS6NGBYJWjs.b; exports.inlineProjection = _chunkS6NGBYJWjs.d; exports.projection = _chunkS6NGBYJWjs.c; exports.readStream = _chunkP36ZOB2Ejs.a; exports.sanitizeNameSQL = _chunkEEYVFO3Gjs.d; exports.schemaSQL = _chunkEMFXYVCKjs.a; exports.streamsTable = _chunkSS2LQM3Bjs.e; exports.streamsTableSQL = _chunkEEYVFO3Gjs.a; exports.subscriptionsTableSQL = _chunkEEYVFO3Gjs.c;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import"../chunk-HIATDE4Q.mjs";import{a as w}from"../chunk-UMUX2OL5.mjs";import"../chunk-KA3LTDXJ.mjs";import{a as u,b as v}from"../chunk-QHCLGPQG.mjs";import{a as i,b as j,c as k,d as l,e as m,f as n,g as o,h as p,i as q,j as r,k as s}from"../chunk-UWD6GOZC.mjs";import{a as g,b as h}from"../chunk-COTRMVOL.mjs";import{a as t}from"../chunk-D5T7G7UL.mjs";import{a,b,c,d,e,f}from"../chunk-ABNBEUC6.mjs";import"../chunk-E56AUXA3.mjs";export{s as addDefaultPartition,n as addEventsPartitions,q as addModuleForAllTenantsSQL,o as addModuleSQL,m as addTablePartitions,r as addTenantForAllModulesSQL,p as addTenantSQL,g as appendEventsSQL,h as appendToStream,v as createEventStoreSchema,c as defaultTag,a as emmettPrefix,f as eventsTable,j as eventsTableSQL,w as getPostgreSQLEventStore,d as globalNames,b as globalTag,t as readStream,l as sanitizeNameSQL,u as schemaSQL,e as streamsTable,i as streamsTableSQL,k as subscriptionsTableSQL};
1
+ import"../chunk-45ODDXOQ.mjs";import{a as A}from"../chunk-7PVUE3OV.mjs";import{a,b,c,d}from"../chunk-BBOP347O.mjs";import{a as y,b as z}from"../chunk-QHCLGPQG.mjs";import{a as m,b as n,c as o,d as p,e as q,f as r,g as s,h as t,i as u,j as v,k as w}from"../chunk-UWD6GOZC.mjs";import{a as k,b as l}from"../chunk-COTRMVOL.mjs";import{a as x}from"../chunk-D5T7G7UL.mjs";import{a as e,b as f,c as g,d as h,e as i,f as j}from"../chunk-ABNBEUC6.mjs";import"../chunk-E56AUXA3.mjs";export{w as addDefaultPartition,r as addEventsPartitions,u as addModuleForAllTenantsSQL,s as addModuleSQL,q as addTablePartitions,v as addTenantForAllModulesSQL,t as addTenantSQL,k as appendEventsSQL,l as appendToStream,z as createEventStoreSchema,a as defaultProjectionOptions,g as defaultTag,e as emmettPrefix,j as eventsTable,n as eventsTableSQL,A as getPostgreSQLEventStore,h as globalNames,f as globalTag,b as handleProjections,d as inlineProjection,c as projection,x as readStream,p as sanitizeNameSQL,y as schemaSQL,i as streamsTable,m as streamsTableSQL,o as subscriptionsTableSQL};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,3 +1,3 @@
1
1
  import '@event-driven-io/emmett';
2
- export { P as PostgresEventStore, a as PostgresEventStoreOptions, g as getPostgreSQLEventStore } from '../postgreSQLEventStore-Dz2eALUF.mjs';
2
+ export { P as PostgresEventStore, a as PostgresEventStoreOptions, g as getPostgreSQLEventStore } from '../postgreSQLEventStore-B7GlXfis.mjs';
3
3
  import 'pg';
@@ -1,3 +1,3 @@
1
1
  import '@event-driven-io/emmett';
2
- export { P as PostgresEventStore, a as PostgresEventStoreOptions, g as getPostgreSQLEventStore } from '../postgreSQLEventStore-Dz2eALUF.js';
2
+ export { P as PostgresEventStore, a as PostgresEventStoreOptions, g as getPostgreSQLEventStore } from '../postgreSQLEventStore-B7GlXfis.js';
3
3
  import 'pg';
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWHT7LTAUjs = require('../chunk-WHT7LTAU.js');require('../chunk-MI5QKIUY.js');require('../chunk-EMFXYVCK.js');require('../chunk-EEYVFO3G.js');require('../chunk-KADY7IHM.js');require('../chunk-P36ZOB2E.js');require('../chunk-SS2LQM3B.js');require('../chunk-XQZVOI6W.js');exports.getPostgreSQLEventStore = _chunkWHT7LTAUjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkICKSIW7Kjs = require('../chunk-ICKSIW7K.js');require('../chunk-S6NGBYJW.js');require('../chunk-EMFXYVCK.js');require('../chunk-EEYVFO3G.js');require('../chunk-KADY7IHM.js');require('../chunk-P36ZOB2E.js');require('../chunk-SS2LQM3B.js');require('../chunk-XQZVOI6W.js');exports.getPostgreSQLEventStore = _chunkICKSIW7Kjs.a;
2
2
  //# sourceMappingURL=postgreSQLEventStore.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-UMUX2OL5.mjs";import"../chunk-KA3LTDXJ.mjs";import"../chunk-QHCLGPQG.mjs";import"../chunk-UWD6GOZC.mjs";import"../chunk-COTRMVOL.mjs";import"../chunk-D5T7G7UL.mjs";import"../chunk-ABNBEUC6.mjs";import"../chunk-E56AUXA3.mjs";export{a as getPostgreSQLEventStore};
1
+ import{a}from"../chunk-7PVUE3OV.mjs";import"../chunk-BBOP347O.mjs";import"../chunk-QHCLGPQG.mjs";import"../chunk-UWD6GOZC.mjs";import"../chunk-COTRMVOL.mjs";import"../chunk-D5T7G7UL.mjs";import"../chunk-ABNBEUC6.mjs";import"../chunk-E56AUXA3.mjs";export{a as getPostgreSQLEventStore};
2
2
  //# sourceMappingURL=postgreSQLEventStore.mjs.map
@@ -1,3 +1,3 @@
1
1
  import '@event-driven-io/emmett';
2
2
  import 'pg';
3
- export { c as PostgresProjectionHandler, b as ProjectionDefintion, d as defaultProjectionOptions, h as handleProjections } from '../../postgreSQLEventStore-Dz2eALUF.mjs';
3
+ export { c as PostgresProjectionHandler, d as ProjectionDefintion, b as ProjectionHandlerContext, e as defaultProjectionOptions, h as handleProjections, i as inlineProjection, p as projection } from '../../postgreSQLEventStore-B7GlXfis.mjs';
@@ -1,3 +1,3 @@
1
1
  import '@event-driven-io/emmett';
2
2
  import 'pg';
3
- export { c as PostgresProjectionHandler, b as ProjectionDefintion, d as defaultProjectionOptions, h as handleProjections } from '../../postgreSQLEventStore-Dz2eALUF.js';
3
+ export { c as PostgresProjectionHandler, d as ProjectionDefintion, b as ProjectionHandlerContext, e as defaultProjectionOptions, h as handleProjections, i as inlineProjection, p as projection } from '../../postgreSQLEventStore-B7GlXfis.js';
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMI5QKIUYjs = require('../../chunk-MI5QKIUY.js');require('../../chunk-XQZVOI6W.js');exports.defaultProjectionOptions = _chunkMI5QKIUYjs.a; exports.handleProjections = _chunkMI5QKIUYjs.b;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkS6NGBYJWjs = require('../../chunk-S6NGBYJW.js');require('../../chunk-XQZVOI6W.js');exports.defaultProjectionOptions = _chunkS6NGBYJWjs.a; exports.handleProjections = _chunkS6NGBYJWjs.b; exports.inlineProjection = _chunkS6NGBYJWjs.d; exports.projection = _chunkS6NGBYJWjs.c;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{a,b}from"../../chunk-KA3LTDXJ.mjs";import"../../chunk-E56AUXA3.mjs";export{a as defaultProjectionOptions,b as handleProjections};
1
+ import{a,b,c,d}from"../../chunk-BBOP347O.mjs";import"../../chunk-E56AUXA3.mjs";export{a as defaultProjectionOptions,b as handleProjections,d as inlineProjection,c as projection};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  import { Event, ReadEvent, EventTypeOf } from '@event-driven-io/emmett';
2
2
  import { PongoDocument, PongoClient } from '@event-driven-io/pongo';
3
3
  import pg from 'pg';
4
- import { b as ProjectionDefintion } from '../../postgreSQLEventStore-Dz2eALUF.mjs';
4
+ import { d as ProjectionDefintion } from '../../postgreSQLEventStore-B7GlXfis.mjs';
5
5
 
6
6
  type PongoProjectionOptions<EventType extends Event> = {
7
7
  documentId: (event: ReadEvent<EventType>) => string;
@@ -1,7 +1,7 @@
1
1
  import { Event, ReadEvent, EventTypeOf } from '@event-driven-io/emmett';
2
2
  import { PongoDocument, PongoClient } from '@event-driven-io/pongo';
3
3
  import pg from 'pg';
4
- import { b as ProjectionDefintion } from '../../postgreSQLEventStore-Dz2eALUF.js';
4
+ import { d as ProjectionDefintion } from '../../postgreSQLEventStore-B7GlXfis.js';
5
5
 
6
6
  type PongoProjectionOptions<EventType extends Event> = {
7
7
  documentId: (event: ReadEvent<EventType>) => string;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../chunk-MI5QKIUY.js');require('../../chunk-XQZVOI6W.js');var _pongo = require('@event-driven-io/pongo');require('pg');var y=(e,...n)=>({type:"inline",canHandle:n,handle:async(t,o,v)=>{let p=_pongo.pongoClient.call(void 0, t,{client:o});await e(p,v)}}),m= exports.pongoMultiStreamProjection =(e,n,t,...o)=>y(async(v,p)=>{let c=v.db().collection(e);for(let i of p)await c.handle(n(i),async E=>await t(E,i))},...o),u= exports.pongoSingleProjection =(e,n,...t)=>m(e,o=>o.metadata.streamName,n,...t);exports.pongoMultiStreamProjection = m; exports.pongoProjection = y; exports.pongoSingleProjection = u;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkS6NGBYJWjs = require('../../chunk-S6NGBYJW.js');require('../../chunk-XQZVOI6W.js');var _pongo = require('@event-driven-io/pongo');require('pg');var m=(e,...n)=>_chunkS6NGBYJWjs.d.call(void 0, {canHandle:n,handle:async(t,o)=>{let{connectionString:v,client:i}=o,p=_pongo.pongoClient.call(void 0, v,{client:i});await e(p,t)}}),d= exports.pongoMultiStreamProjection =(e,n,t,...o)=>m(async(v,i)=>{let p=v.db().collection(e);for(let c of i)await p.handle(n(c),async r=>await t(r,c))},...o),P= exports.pongoSingleProjection =(e,n,...t)=>d(e,o=>o.metadata.streamName,n,...t);exports.pongoMultiStreamProjection = d; exports.pongoProjection = m; exports.pongoSingleProjection = P;
2
2
  //# sourceMappingURL=pongo.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/eventStore/projections/pongo.ts"],"names":["pongoClient","pongoProjection","handle","canHandle","connectionString","client","events","pongo","pongoMultiStreamProjection","collectionName","getDocumentId","evolve","collection","event","document","pongoSingleProjection"],"mappings":"gEAKA,OACE,eAAAA,MAGK,yBACP,MAAe,KA6BR,IAAMC,EAAkB,CAC7BC,KACGC,KAEF,CACC,KAAM,SACN,UAAAA,EACA,OAAQ,MACNC,EACAC,EACAC,IACG,CACH,IAAMC,EAAQP,EAAYI,EAAkB,CAAE,OAAAC,CAAO,CAAC,EACtD,MAAMH,EAAOK,EAAOD,CAAM,CAC5B,CACF,GAEWE,EAA6B,CAIxCC,EACAC,EACAC,KACGR,IAEHF,EACE,MAAOM,EAAOD,IAAW,CACvB,IAAMM,EAAaL,EAAM,GAAG,EAAE,WAAqBE,CAAc,EAEjE,QAAWI,KAASP,EAClB,MAAMM,EAAW,OAAOF,EAAcG,CAAK,EAAG,MAAOC,GAC5C,MAAMH,EAAOG,EAAUD,CAAK,CACpC,CAEL,EACA,GAAGV,CACL,EAEWY,EAAwB,CAInCN,EACAE,KACGR,IAEHK,EACEC,EACCI,GAAUA,EAAM,SAAS,WAC1BF,EACA,GAAGR,CACL","sourcesContent":["import {\n type Event,\n type EventTypeOf,\n type ReadEvent,\n} from '@event-driven-io/emmett';\nimport {\n pongoClient,\n type PongoClient,\n type PongoDocument,\n} from '@event-driven-io/pongo';\nimport pg from 'pg';\nimport { type ProjectionDefintion } from './';\n\nexport type PongoProjectionOptions<EventType extends Event> = {\n documentId: (event: ReadEvent<EventType>) => string;\n eventHandler: PongoProjectionHandler<EventType>;\n eventTypes: EventTypeOf<EventType>[];\n};\n\nexport type PongoProjectionHandler<EventType extends Event = Event> = (\n documentId: (event: ReadEvent<EventType>) => string,\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n) => Promise<void> | void;\n\nexport type PongoDocumentEvolve<\n Document extends PongoDocument,\n EventType extends Event,\n> =\n | ((\n document: Document | null,\n event: ReadEvent<EventType>,\n ) => Document | null)\n | ((\n document: Document | null,\n event: ReadEvent<EventType>,\n ) => Promise<Document | null>);\n\nexport const pongoProjection = <EventType extends Event>(\n handle: (pongo: PongoClient, events: ReadEvent<EventType>[]) => Promise<void>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n ({\n type: 'inline',\n canHandle,\n handle: async (\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n ) => {\n const pongo = pongoClient(connectionString, { client });\n await handle(pongo, events);\n },\n }) as unknown as ProjectionDefintion;\n\nexport const pongoMultiStreamProjection = <\n Document extends PongoDocument,\n EventType extends Event,\n>(\n collectionName: string,\n getDocumentId: (event: ReadEvent<EventType>) => string,\n evolve: PongoDocumentEvolve<Document, EventType>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n pongoProjection(\n async (pongo, events) => {\n const collection = pongo.db().collection<Document>(collectionName);\n\n for (const event of events) {\n await collection.handle(getDocumentId(event), async (document) => {\n return await evolve(document, event);\n });\n }\n },\n ...canHandle,\n );\n\nexport const pongoSingleProjection = <\n Document extends PongoDocument,\n EventType extends Event,\n>(\n collectionName: string,\n evolve: PongoDocumentEvolve<Document, EventType>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n pongoMultiStreamProjection(\n collectionName,\n (event) => event.metadata.streamName,\n evolve,\n ...canHandle,\n );\n"]}
1
+ {"version":3,"sources":["../../../src/eventStore/projections/pongo.ts"],"names":["pongoClient","pongoProjection","handle","canHandle","inlineProjection","events","context","connectionString","client","pongo","pongoMultiStreamProjection","collectionName","getDocumentId","evolve","collection","event","document","pongoSingleProjection"],"mappings":"4EAKA,OACE,eAAAA,MAGK,yBACP,MAAe,KA6BR,IAAMC,EAAkB,CAC7BC,KACGC,IAEHC,EAA4B,CAC1B,UAAAD,EACA,OAAQ,MAAOE,EAAQC,IAAY,CACjC,GAAM,CAAE,iBAAAC,EAAkB,OAAAC,CAAO,EAAIF,EAC/BG,EAAQT,EAAYO,EAAkB,CAAE,OAAAC,CAAO,CAAC,EACtD,MAAMN,EAAOO,EAAOJ,CAAM,CAC5B,CACF,CAAC,EAEUK,EAA6B,CAIxCC,EACAC,EACAC,KACGV,IAEHF,EACE,MAAOQ,EAAOJ,IAAW,CACvB,IAAMS,EAAaL,EAAM,GAAG,EAAE,WAAqBE,CAAc,EAEjE,QAAWI,KAASV,EAClB,MAAMS,EAAW,OAAOF,EAAcG,CAAK,EAAG,MAAOC,GAC5C,MAAMH,EAAOG,EAAUD,CAAK,CACpC,CAEL,EACA,GAAGZ,CACL,EAEWc,EAAwB,CAInCN,EACAE,KACGV,IAEHO,EACEC,EACCI,GAAUA,EAAM,SAAS,WAC1BF,EACA,GAAGV,CACL","sourcesContent":["import {\n type Event,\n type EventTypeOf,\n type ReadEvent,\n} from '@event-driven-io/emmett';\nimport {\n pongoClient,\n type PongoClient,\n type PongoDocument,\n} from '@event-driven-io/pongo';\nimport pg from 'pg';\nimport { inlineProjection, type ProjectionDefintion } from './';\n\nexport type PongoProjectionOptions<EventType extends Event> = {\n documentId: (event: ReadEvent<EventType>) => string;\n eventHandler: PongoProjectionHandler<EventType>;\n eventTypes: EventTypeOf<EventType>[];\n};\n\nexport type PongoProjectionHandler<EventType extends Event = Event> = (\n documentId: (event: ReadEvent<EventType>) => string,\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n) => Promise<void> | void;\n\nexport type PongoDocumentEvolve<\n Document extends PongoDocument,\n EventType extends Event,\n> =\n | ((\n document: Document | null,\n event: ReadEvent<EventType>,\n ) => Document | null)\n | ((\n document: Document | null,\n event: ReadEvent<EventType>,\n ) => Promise<Document | null>);\n\nexport const pongoProjection = <EventType extends Event>(\n handle: (pongo: PongoClient, events: ReadEvent<EventType>[]) => Promise<void>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n inlineProjection<EventType>({\n canHandle,\n handle: async (events, context) => {\n const { connectionString, client } = context;\n const pongo = pongoClient(connectionString, { client });\n await handle(pongo, events);\n },\n });\n\nexport const pongoMultiStreamProjection = <\n Document extends PongoDocument,\n EventType extends Event,\n>(\n collectionName: string,\n getDocumentId: (event: ReadEvent<EventType>) => string,\n evolve: PongoDocumentEvolve<Document, EventType>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n pongoProjection(\n async (pongo, events) => {\n const collection = pongo.db().collection<Document>(collectionName);\n\n for (const event of events) {\n await collection.handle(getDocumentId(event), async (document) => {\n return await evolve(document, event);\n });\n }\n },\n ...canHandle,\n );\n\nexport const pongoSingleProjection = <\n Document extends PongoDocument,\n EventType extends Event,\n>(\n collectionName: string,\n evolve: PongoDocumentEvolve<Document, EventType>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n pongoMultiStreamProjection(\n collectionName,\n (event) => event.metadata.streamName,\n evolve,\n ...canHandle,\n );\n"]}
@@ -1,2 +1,2 @@
1
- import"../../chunk-KA3LTDXJ.mjs";import"../../chunk-E56AUXA3.mjs";import{pongoClient as r}from"@event-driven-io/pongo";import"pg";var y=(e,...n)=>({type:"inline",canHandle:n,handle:async(t,o,v)=>{let p=r(t,{client:o});await e(p,v)}}),m=(e,n,t,...o)=>y(async(v,p)=>{let c=v.db().collection(e);for(let i of p)await c.handle(n(i),async E=>await t(E,i))},...o),u=(e,n,...t)=>m(e,o=>o.metadata.streamName,n,...t);export{m as pongoMultiStreamProjection,y as pongoProjection,u as pongoSingleProjection};
1
+ import{d as E}from"../../chunk-BBOP347O.mjs";import"../../chunk-E56AUXA3.mjs";import{pongoClient as y}from"@event-driven-io/pongo";import"pg";var m=(e,...n)=>E({canHandle:n,handle:async(t,o)=>{let{connectionString:v,client:i}=o,p=y(v,{client:i});await e(p,t)}}),d=(e,n,t,...o)=>m(async(v,i)=>{let p=v.db().collection(e);for(let c of i)await p.handle(n(c),async r=>await t(r,c))},...o),P=(e,n,...t)=>d(e,o=>o.metadata.streamName,n,...t);export{d as pongoMultiStreamProjection,m as pongoProjection,P as pongoSingleProjection};
2
2
  //# sourceMappingURL=pongo.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/eventStore/projections/pongo.ts"],"sourcesContent":["import {\n type Event,\n type EventTypeOf,\n type ReadEvent,\n} from '@event-driven-io/emmett';\nimport {\n pongoClient,\n type PongoClient,\n type PongoDocument,\n} from '@event-driven-io/pongo';\nimport pg from 'pg';\nimport { type ProjectionDefintion } from './';\n\nexport type PongoProjectionOptions<EventType extends Event> = {\n documentId: (event: ReadEvent<EventType>) => string;\n eventHandler: PongoProjectionHandler<EventType>;\n eventTypes: EventTypeOf<EventType>[];\n};\n\nexport type PongoProjectionHandler<EventType extends Event = Event> = (\n documentId: (event: ReadEvent<EventType>) => string,\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n) => Promise<void> | void;\n\nexport type PongoDocumentEvolve<\n Document extends PongoDocument,\n EventType extends Event,\n> =\n | ((\n document: Document | null,\n event: ReadEvent<EventType>,\n ) => Document | null)\n | ((\n document: Document | null,\n event: ReadEvent<EventType>,\n ) => Promise<Document | null>);\n\nexport const pongoProjection = <EventType extends Event>(\n handle: (pongo: PongoClient, events: ReadEvent<EventType>[]) => Promise<void>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n ({\n type: 'inline',\n canHandle,\n handle: async (\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n ) => {\n const pongo = pongoClient(connectionString, { client });\n await handle(pongo, events);\n },\n }) as unknown as ProjectionDefintion;\n\nexport const pongoMultiStreamProjection = <\n Document extends PongoDocument,\n EventType extends Event,\n>(\n collectionName: string,\n getDocumentId: (event: ReadEvent<EventType>) => string,\n evolve: PongoDocumentEvolve<Document, EventType>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n pongoProjection(\n async (pongo, events) => {\n const collection = pongo.db().collection<Document>(collectionName);\n\n for (const event of events) {\n await collection.handle(getDocumentId(event), async (document) => {\n return await evolve(document, event);\n });\n }\n },\n ...canHandle,\n );\n\nexport const pongoSingleProjection = <\n Document extends PongoDocument,\n EventType extends Event,\n>(\n collectionName: string,\n evolve: PongoDocumentEvolve<Document, EventType>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n pongoMultiStreamProjection(\n collectionName,\n (event) => event.metadata.streamName,\n evolve,\n ...canHandle,\n );\n"],"mappings":"kEAKA,OACE,eAAAA,MAGK,yBACP,MAAe,KA6BR,IAAMC,EAAkB,CAC7BC,KACGC,KAEF,CACC,KAAM,SACN,UAAAA,EACA,OAAQ,MACNC,EACAC,EACAC,IACG,CACH,IAAMC,EAAQC,EAAYJ,EAAkB,CAAE,OAAAC,CAAO,CAAC,EACtD,MAAMH,EAAOK,EAAOD,CAAM,CAC5B,CACF,GAEWG,EAA6B,CAIxCC,EACAC,EACAC,KACGT,IAEHF,EACE,MAAOM,EAAOD,IAAW,CACvB,IAAMO,EAAaN,EAAM,GAAG,EAAE,WAAqBG,CAAc,EAEjE,QAAWI,KAASR,EAClB,MAAMO,EAAW,OAAOF,EAAcG,CAAK,EAAG,MAAOC,GAC5C,MAAMH,EAAOG,EAAUD,CAAK,CACpC,CAEL,EACA,GAAGX,CACL,EAEWa,EAAwB,CAInCN,EACAE,KACGT,IAEHM,EACEC,EACCI,GAAUA,EAAM,SAAS,WAC1BF,EACA,GAAGT,CACL","names":["pongoClient","pongoProjection","handle","canHandle","connectionString","client","events","pongo","pongoClient","pongoMultiStreamProjection","collectionName","getDocumentId","evolve","collection","event","document","pongoSingleProjection"]}
1
+ {"version":3,"sources":["../../../src/eventStore/projections/pongo.ts"],"sourcesContent":["import {\n type Event,\n type EventTypeOf,\n type ReadEvent,\n} from '@event-driven-io/emmett';\nimport {\n pongoClient,\n type PongoClient,\n type PongoDocument,\n} from '@event-driven-io/pongo';\nimport pg from 'pg';\nimport { inlineProjection, type ProjectionDefintion } from './';\n\nexport type PongoProjectionOptions<EventType extends Event> = {\n documentId: (event: ReadEvent<EventType>) => string;\n eventHandler: PongoProjectionHandler<EventType>;\n eventTypes: EventTypeOf<EventType>[];\n};\n\nexport type PongoProjectionHandler<EventType extends Event = Event> = (\n documentId: (event: ReadEvent<EventType>) => string,\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n) => Promise<void> | void;\n\nexport type PongoDocumentEvolve<\n Document extends PongoDocument,\n EventType extends Event,\n> =\n | ((\n document: Document | null,\n event: ReadEvent<EventType>,\n ) => Document | null)\n | ((\n document: Document | null,\n event: ReadEvent<EventType>,\n ) => Promise<Document | null>);\n\nexport const pongoProjection = <EventType extends Event>(\n handle: (pongo: PongoClient, events: ReadEvent<EventType>[]) => Promise<void>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n inlineProjection<EventType>({\n canHandle,\n handle: async (events, context) => {\n const { connectionString, client } = context;\n const pongo = pongoClient(connectionString, { client });\n await handle(pongo, events);\n },\n });\n\nexport const pongoMultiStreamProjection = <\n Document extends PongoDocument,\n EventType extends Event,\n>(\n collectionName: string,\n getDocumentId: (event: ReadEvent<EventType>) => string,\n evolve: PongoDocumentEvolve<Document, EventType>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n pongoProjection(\n async (pongo, events) => {\n const collection = pongo.db().collection<Document>(collectionName);\n\n for (const event of events) {\n await collection.handle(getDocumentId(event), async (document) => {\n return await evolve(document, event);\n });\n }\n },\n ...canHandle,\n );\n\nexport const pongoSingleProjection = <\n Document extends PongoDocument,\n EventType extends Event,\n>(\n collectionName: string,\n evolve: PongoDocumentEvolve<Document, EventType>,\n ...canHandle: EventTypeOf<EventType>[]\n): ProjectionDefintion =>\n pongoMultiStreamProjection(\n collectionName,\n (event) => event.metadata.streamName,\n evolve,\n ...canHandle,\n );\n"],"mappings":"8EAKA,OACE,eAAAA,MAGK,yBACP,MAAe,KA6BR,IAAMC,EAAkB,CAC7BC,KACGC,IAEHC,EAA4B,CAC1B,UAAAD,EACA,OAAQ,MAAOE,EAAQC,IAAY,CACjC,GAAM,CAAE,iBAAAC,EAAkB,OAAAC,CAAO,EAAIF,EAC/BG,EAAQC,EAAYH,EAAkB,CAAE,OAAAC,CAAO,CAAC,EACtD,MAAMN,EAAOO,EAAOJ,CAAM,CAC5B,CACF,CAAC,EAEUM,EAA6B,CAIxCC,EACAC,EACAC,KACGX,IAEHF,EACE,MAAOQ,EAAOJ,IAAW,CACvB,IAAMU,EAAaN,EAAM,GAAG,EAAE,WAAqBG,CAAc,EAEjE,QAAWI,KAASX,EAClB,MAAMU,EAAW,OAAOF,EAAcG,CAAK,EAAG,MAAOC,GAC5C,MAAMH,EAAOG,EAAUD,CAAK,CACpC,CAEL,EACA,GAAGb,CACL,EAEWe,EAAwB,CAInCN,EACAE,KACGX,IAEHQ,EACEC,EACCI,GAAUA,EAAM,SAAS,WAC1BF,EACA,GAAGX,CACL","names":["pongoClient","pongoProjection","handle","canHandle","inlineProjection","events","context","connectionString","client","pongo","pongoClient","pongoMultiStreamProjection","collectionName","getDocumentId","evolve","collection","event","document","pongoSingleProjection"]}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { P as PostgresEventStore, a as PostgresEventStoreOptions, g as getPostgreSQLEventStore } from './postgreSQLEventStore-Dz2eALUF.mjs';
1
+ export { P as PostgresEventStore, a as PostgresEventStoreOptions, c as PostgresProjectionHandler, d as ProjectionDefintion, b as ProjectionHandlerContext, e as defaultProjectionOptions, g as getPostgreSQLEventStore, h as handleProjections, i as inlineProjection, p as projection } from './postgreSQLEventStore-B7GlXfis.mjs';
2
2
  export { createEventStoreSchema, schemaSQL } from './eventStore/schema/index.mjs';
3
3
  export { appendEventsSQL, appendToStream } from './eventStore/schema/appendToStream.mjs';
4
4
  export { readStream } from './eventStore/schema/readStream.mjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { P as PostgresEventStore, a as PostgresEventStoreOptions, g as getPostgreSQLEventStore } from './postgreSQLEventStore-Dz2eALUF.js';
1
+ export { P as PostgresEventStore, a as PostgresEventStoreOptions, c as PostgresProjectionHandler, d as ProjectionDefintion, b as ProjectionHandlerContext, e as defaultProjectionOptions, g as getPostgreSQLEventStore, h as handleProjections, i as inlineProjection, p as projection } from './postgreSQLEventStore-B7GlXfis.js';
2
2
  export { createEventStoreSchema, schemaSQL } from './eventStore/schema/index.js';
3
3
  export { appendEventsSQL, appendToStream } from './eventStore/schema/appendToStream.js';
4
4
  export { readStream } from './eventStore/schema/readStream.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-MERDQHBQ.js');var _chunkWHT7LTAUjs = require('./chunk-WHT7LTAU.js');require('./chunk-MI5QKIUY.js');var _chunkEMFXYVCKjs = require('./chunk-EMFXYVCK.js');var _chunkEEYVFO3Gjs = require('./chunk-EEYVFO3G.js');var _chunkKADY7IHMjs = require('./chunk-KADY7IHM.js');var _chunkP36ZOB2Ejs = require('./chunk-P36ZOB2E.js');var _chunkSS2LQM3Bjs = require('./chunk-SS2LQM3B.js');require('./chunk-XQZVOI6W.js');exports.addDefaultPartition = _chunkEEYVFO3Gjs.k; exports.addEventsPartitions = _chunkEEYVFO3Gjs.f; exports.addModuleForAllTenantsSQL = _chunkEEYVFO3Gjs.i; exports.addModuleSQL = _chunkEEYVFO3Gjs.g; exports.addTablePartitions = _chunkEEYVFO3Gjs.e; exports.addTenantForAllModulesSQL = _chunkEEYVFO3Gjs.j; exports.addTenantSQL = _chunkEEYVFO3Gjs.h; exports.appendEventsSQL = _chunkKADY7IHMjs.a; exports.appendToStream = _chunkKADY7IHMjs.b; exports.createEventStoreSchema = _chunkEMFXYVCKjs.b; exports.defaultTag = _chunkSS2LQM3Bjs.c; exports.emmettPrefix = _chunkSS2LQM3Bjs.a; exports.eventsTable = _chunkSS2LQM3Bjs.f; exports.eventsTableSQL = _chunkEEYVFO3Gjs.b; exports.getPostgreSQLEventStore = _chunkWHT7LTAUjs.a; exports.globalNames = _chunkSS2LQM3Bjs.d; exports.globalTag = _chunkSS2LQM3Bjs.b; exports.readStream = _chunkP36ZOB2Ejs.a; exports.sanitizeNameSQL = _chunkEEYVFO3Gjs.d; exports.schemaSQL = _chunkEMFXYVCKjs.a; exports.streamsTable = _chunkSS2LQM3Bjs.e; exports.streamsTableSQL = _chunkEEYVFO3Gjs.a; exports.subscriptionsTableSQL = _chunkEEYVFO3Gjs.c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-2452BJTJ.js');var _chunkICKSIW7Kjs = require('./chunk-ICKSIW7K.js');var _chunkS6NGBYJWjs = require('./chunk-S6NGBYJW.js');var _chunkEMFXYVCKjs = require('./chunk-EMFXYVCK.js');var _chunkEEYVFO3Gjs = require('./chunk-EEYVFO3G.js');var _chunkKADY7IHMjs = require('./chunk-KADY7IHM.js');var _chunkP36ZOB2Ejs = require('./chunk-P36ZOB2E.js');var _chunkSS2LQM3Bjs = require('./chunk-SS2LQM3B.js');require('./chunk-XQZVOI6W.js');exports.addDefaultPartition = _chunkEEYVFO3Gjs.k; exports.addEventsPartitions = _chunkEEYVFO3Gjs.f; exports.addModuleForAllTenantsSQL = _chunkEEYVFO3Gjs.i; exports.addModuleSQL = _chunkEEYVFO3Gjs.g; exports.addTablePartitions = _chunkEEYVFO3Gjs.e; exports.addTenantForAllModulesSQL = _chunkEEYVFO3Gjs.j; exports.addTenantSQL = _chunkEEYVFO3Gjs.h; exports.appendEventsSQL = _chunkKADY7IHMjs.a; exports.appendToStream = _chunkKADY7IHMjs.b; exports.createEventStoreSchema = _chunkEMFXYVCKjs.b; exports.defaultProjectionOptions = _chunkS6NGBYJWjs.a; exports.defaultTag = _chunkSS2LQM3Bjs.c; exports.emmettPrefix = _chunkSS2LQM3Bjs.a; exports.eventsTable = _chunkSS2LQM3Bjs.f; exports.eventsTableSQL = _chunkEEYVFO3Gjs.b; exports.getPostgreSQLEventStore = _chunkICKSIW7Kjs.a; exports.globalNames = _chunkSS2LQM3Bjs.d; exports.globalTag = _chunkSS2LQM3Bjs.b; exports.handleProjections = _chunkS6NGBYJWjs.b; exports.inlineProjection = _chunkS6NGBYJWjs.d; exports.projection = _chunkS6NGBYJWjs.c; exports.readStream = _chunkP36ZOB2Ejs.a; exports.sanitizeNameSQL = _chunkEEYVFO3Gjs.d; exports.schemaSQL = _chunkEMFXYVCKjs.a; exports.streamsTable = _chunkSS2LQM3Bjs.e; exports.streamsTableSQL = _chunkEEYVFO3Gjs.a; exports.subscriptionsTableSQL = _chunkEEYVFO3Gjs.c;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import"./chunk-HIATDE4Q.mjs";import{a as v}from"./chunk-UMUX2OL5.mjs";import"./chunk-KA3LTDXJ.mjs";import{a as s,b as u}from"./chunk-QHCLGPQG.mjs";import{a,b,c,d,e as g,f as h,g as i,h as j,i as k,j as l,k as n}from"./chunk-UWD6GOZC.mjs";import{a as t,b as x}from"./chunk-COTRMVOL.mjs";import{a as q}from"./chunk-D5T7G7UL.mjs";import{a as o,b as r,c as e,d as f,e as m,f as p}from"./chunk-ABNBEUC6.mjs";import"./chunk-E56AUXA3.mjs";export{n as addDefaultPartition,h as addEventsPartitions,k as addModuleForAllTenantsSQL,i as addModuleSQL,g as addTablePartitions,l as addTenantForAllModulesSQL,j as addTenantSQL,t as appendEventsSQL,x as appendToStream,u as createEventStoreSchema,e as defaultTag,o as emmettPrefix,p as eventsTable,b as eventsTableSQL,v as getPostgreSQLEventStore,f as globalNames,r as globalTag,q as readStream,d as sanitizeNameSQL,s as schemaSQL,m as streamsTable,a as streamsTableSQL,c as subscriptionsTableSQL};
1
+ import"./chunk-45ODDXOQ.mjs";import{a as A}from"./chunk-7PVUE3OV.mjs";import{a as o,b as r,c as e,d as f}from"./chunk-BBOP347O.mjs";import{a as y,b as z}from"./chunk-QHCLGPQG.mjs";import{a as g,b as h,c as i,d as j,e as k,f as l,g as n,h as q,i as s,j as u,k as v}from"./chunk-UWD6GOZC.mjs";import{a as c,b as d}from"./chunk-COTRMVOL.mjs";import{a as w}from"./chunk-D5T7G7UL.mjs";import{a as m,b as p,c as t,d as x,e as a,f as b}from"./chunk-ABNBEUC6.mjs";import"./chunk-E56AUXA3.mjs";export{v as addDefaultPartition,l as addEventsPartitions,s as addModuleForAllTenantsSQL,n as addModuleSQL,k as addTablePartitions,u as addTenantForAllModulesSQL,q as addTenantSQL,c as appendEventsSQL,d as appendToStream,z as createEventStoreSchema,o as defaultProjectionOptions,t as defaultTag,m as emmettPrefix,b as eventsTable,h as eventsTableSQL,A as getPostgreSQLEventStore,x as globalNames,p as globalTag,r as handleProjections,f as inlineProjection,e as projection,w as readStream,j as sanitizeNameSQL,y as schemaSQL,a as streamsTable,g as streamsTableSQL,i as subscriptionsTableSQL};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,11 @@
1
1
  import { Event, ReadEvent, EventTypeOf, EventStore, DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition } from '@event-driven-io/emmett';
2
2
  import pg from 'pg';
3
3
 
4
- type PostgresProjectionHandler<EventType extends Event = Event> = (connectionString: string, client: pg.PoolClient, events: ReadEvent<EventType>[]) => Promise<void> | void;
4
+ type ProjectionHandlerContext = {
5
+ connectionString: string;
6
+ client: pg.PoolClient;
7
+ };
8
+ type PostgresProjectionHandler<EventType extends Event = Event> = (events: ReadEvent<EventType>[], context: ProjectionHandlerContext) => Promise<void> | void;
5
9
  type ProjectionDefintion<EventType extends Event = Event> = {
6
10
  type: 'inline';
7
11
  name?: string;
@@ -10,6 +14,8 @@ type ProjectionDefintion<EventType extends Event = Event> = {
10
14
  };
11
15
  declare const defaultProjectionOptions: PostgresEventStoreOptions;
12
16
  declare const handleProjections: <EventType extends Event = Event>(allProjections: ProjectionDefintion<EventType>[], connectionString: string, client: pg.PoolClient, events: ReadEvent<EventType>[]) => Promise<void>;
17
+ declare const projection: <EventType extends Event>(definition: ProjectionDefintion<EventType>) => ProjectionDefintion;
18
+ declare const inlineProjection: <EventType extends Event>(definition: Omit<ProjectionDefintion<EventType>, 'type'>) => ProjectionDefintion;
13
19
 
14
20
  interface PostgresEventStore extends EventStore<DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition> {
15
21
  close(): Promise<void>;
@@ -19,4 +25,4 @@ type PostgresEventStoreOptions = {
19
25
  };
20
26
  declare const getPostgreSQLEventStore: (connectionString: string, options?: PostgresEventStoreOptions) => PostgresEventStore;
21
27
 
22
- export { type PostgresEventStore as P, type PostgresEventStoreOptions as a, type ProjectionDefintion as b, type PostgresProjectionHandler as c, defaultProjectionOptions as d, getPostgreSQLEventStore as g, handleProjections as h };
28
+ export { type PostgresEventStore as P, type PostgresEventStoreOptions as a, type ProjectionHandlerContext as b, type PostgresProjectionHandler as c, type ProjectionDefintion as d, defaultProjectionOptions as e, getPostgreSQLEventStore as g, handleProjections as h, inlineProjection as i, projection as p };
@@ -1,7 +1,11 @@
1
1
  import { Event, ReadEvent, EventTypeOf, EventStore, DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition } from '@event-driven-io/emmett';
2
2
  import pg from 'pg';
3
3
 
4
- type PostgresProjectionHandler<EventType extends Event = Event> = (connectionString: string, client: pg.PoolClient, events: ReadEvent<EventType>[]) => Promise<void> | void;
4
+ type ProjectionHandlerContext = {
5
+ connectionString: string;
6
+ client: pg.PoolClient;
7
+ };
8
+ type PostgresProjectionHandler<EventType extends Event = Event> = (events: ReadEvent<EventType>[], context: ProjectionHandlerContext) => Promise<void> | void;
5
9
  type ProjectionDefintion<EventType extends Event = Event> = {
6
10
  type: 'inline';
7
11
  name?: string;
@@ -10,6 +14,8 @@ type ProjectionDefintion<EventType extends Event = Event> = {
10
14
  };
11
15
  declare const defaultProjectionOptions: PostgresEventStoreOptions;
12
16
  declare const handleProjections: <EventType extends Event = Event>(allProjections: ProjectionDefintion<EventType>[], connectionString: string, client: pg.PoolClient, events: ReadEvent<EventType>[]) => Promise<void>;
17
+ declare const projection: <EventType extends Event>(definition: ProjectionDefintion<EventType>) => ProjectionDefintion;
18
+ declare const inlineProjection: <EventType extends Event>(definition: Omit<ProjectionDefintion<EventType>, 'type'>) => ProjectionDefintion;
13
19
 
14
20
  interface PostgresEventStore extends EventStore<DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition> {
15
21
  close(): Promise<void>;
@@ -19,4 +25,4 @@ type PostgresEventStoreOptions = {
19
25
  };
20
26
  declare const getPostgreSQLEventStore: (connectionString: string, options?: PostgresEventStoreOptions) => PostgresEventStore;
21
27
 
22
- export { type PostgresEventStore as P, type PostgresEventStoreOptions as a, type ProjectionDefintion as b, type PostgresProjectionHandler as c, defaultProjectionOptions as d, getPostgreSQLEventStore as g, handleProjections as h };
28
+ export { type PostgresEventStore as P, type PostgresEventStoreOptions as a, type ProjectionHandlerContext as b, type PostgresProjectionHandler as c, type ProjectionDefintion as d, defaultProjectionOptions as e, getPostgreSQLEventStore as g, handleProjections as h, inlineProjection as i, projection as p };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-driven-io/emmett-postgresql",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Emmett - PostgreSQL - Event Sourcing development made simple",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -52,7 +52,7 @@
52
52
  "@event-driven-io/emmett-testcontainers": "^0.5.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@event-driven-io/emmett": "0.13.0",
55
+ "@event-driven-io/emmett": "0.14.0",
56
56
  "@types/pg": "^8.11.6",
57
57
  "@types/pg-format": "^1.0.5",
58
58
  "pg": "^8.12.0",
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-HIATDE4Q.mjs.map
@@ -1,2 +0,0 @@
1
- import"pg";var y={projections:[]},a=async(n,o,i,t)=>{let p=t.map(e=>e.type),r=n.filter(e=>e.canHandle.some(s=>p.includes(s)));for(let e of r)await e.handle(o,i,t)};export{y as a,a as b};
2
- //# sourceMappingURL=chunk-KA3LTDXJ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/eventStore/projections/index.ts"],"sourcesContent":["import {\n type Event,\n type EventTypeOf,\n type ReadEvent,\n} from '@event-driven-io/emmett';\nimport pg from 'pg';\nimport type { PostgresEventStoreOptions } from '../postgreSQLEventStore';\n\nexport type PostgresProjectionHandler<EventType extends Event = Event> = (\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n) => Promise<void> | void;\n\nexport type ProjectionDefintion<EventType extends Event = Event> = {\n type: 'inline';\n name?: string;\n canHandle: EventTypeOf<EventType>[];\n handle: PostgresProjectionHandler<EventType>;\n};\n\nexport const defaultProjectionOptions: PostgresEventStoreOptions = {\n projections: [],\n};\n\nexport const handleProjections = async <EventType extends Event = Event>(\n allProjections: ProjectionDefintion<EventType>[],\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n): Promise<void> => {\n const eventTypes = events.map((e) => e.type);\n\n const projections = allProjections.filter((p) =>\n p.canHandle.some((type) => eventTypes.includes(type)),\n );\n\n for (const projection of projections) {\n await projection.handle(connectionString, client, events);\n }\n};\n"],"mappings":"AAKA,MAAe,KAgBR,IAAMA,EAAsD,CACjE,YAAa,CAAC,CAChB,EAEaC,EAAoB,MAC/BC,EACAC,EACAC,EACAC,IACkB,CAClB,IAAMC,EAAaD,EAAO,IAAK,GAAM,EAAE,IAAI,EAErCE,EAAcL,EAAe,OAAQM,GACzCA,EAAE,UAAU,KAAMC,GAASH,EAAW,SAASG,CAAI,CAAC,CACtD,EAEA,QAAWC,KAAcH,EACvB,MAAMG,EAAW,OAAOP,EAAkBC,EAAQC,CAAM,CAE5D","names":["defaultProjectionOptions","handleProjections","allProjections","connectionString","client","events","eventTypes","projections","p","type","projection"]}
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-MERDQHBQ.js.map
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('pg');var y={projections:[]},a= exports.b =async(n,o,i,t)=>{let p=t.map(e=>e.type),r=n.filter(e=>e.canHandle.some(s=>p.includes(s)));for(let e of r)await e.handle(o,i,t)};exports.a = y; exports.b = a;
2
- //# sourceMappingURL=chunk-MI5QKIUY.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/eventStore/projections/index.ts"],"names":["defaultProjectionOptions","handleProjections","allProjections","connectionString","client","events","eventTypes","projections","p","type","projection"],"mappings":"AAKA,MAAe,KAgBR,IAAMA,EAAsD,CACjE,YAAa,CAAC,CAChB,EAEaC,EAAoB,MAC/BC,EACAC,EACAC,EACAC,IACkB,CAClB,IAAMC,EAAaD,EAAO,IAAK,GAAM,EAAE,IAAI,EAErCE,EAAcL,EAAe,OAAQM,GACzCA,EAAE,UAAU,KAAMC,GAASH,EAAW,SAASG,CAAI,CAAC,CACtD,EAEA,QAAWC,KAAcH,EACvB,MAAMG,EAAW,OAAOP,EAAkBC,EAAQC,CAAM,CAE5D","sourcesContent":["import {\n type Event,\n type EventTypeOf,\n type ReadEvent,\n} from '@event-driven-io/emmett';\nimport pg from 'pg';\nimport type { PostgresEventStoreOptions } from '../postgreSQLEventStore';\n\nexport type PostgresProjectionHandler<EventType extends Event = Event> = (\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n) => Promise<void> | void;\n\nexport type ProjectionDefintion<EventType extends Event = Event> = {\n type: 'inline';\n name?: string;\n canHandle: EventTypeOf<EventType>[];\n handle: PostgresProjectionHandler<EventType>;\n};\n\nexport const defaultProjectionOptions: PostgresEventStoreOptions = {\n projections: [],\n};\n\nexport const handleProjections = async <EventType extends Event = Event>(\n allProjections: ProjectionDefintion<EventType>[],\n connectionString: string,\n client: pg.PoolClient,\n events: ReadEvent<EventType>[],\n): Promise<void> => {\n const eventTypes = events.map((e) => e.type);\n\n const projections = allProjections.filter((p) =>\n p.canHandle.some((type) => eventTypes.includes(type)),\n );\n\n for (const projection of projections) {\n await projection.handle(connectionString, client, events);\n }\n};\n"]}