@entifix/sql 0.17.0 → 0.18.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.
@@ -1,6 +1,6 @@
1
- import { EventBusTag, OutboxMaxAttempts } from '@entifix/transactions';
1
+ import { EventBusTag, OutboxDrainTag, OutboxMaxAttempts } from '@entifix/transactions';
2
2
  import { type OutboxStatsSink, type RelayOutcomeSink } from '@entifix/transactions/engine';
3
- import { Effect } from 'effect';
3
+ import { Effect, Layer } from 'effect';
4
4
  import { SqlClient } from 'effect/sql';
5
5
  /**
6
6
  * Starts the relay over the service's SQL database: the tables are ensured, a
@@ -19,4 +19,11 @@ export declare const startSqlOutboxRelay: (options: {
19
19
  * rather than at the next sweep. A failure is reported and left to the sweep.
20
20
  */
21
21
  export declare const drainSqlOutboxNow: (database: string, onOutcome?: RelayOutcomeSink) => Effect.Effect<void, never, SqlClient.SqlClient | OutboxMaxAttempts | EventBusTag>;
22
+ /**
23
+ * {@link drainSqlOutboxNow} as the {@link OutboxDrainTag} a writer finds, over
24
+ * the client, bus and attempt ceiling this layer is built with — so a flow
25
+ * engine announcing into this outbox puts its event on the bus at once rather
26
+ * than at the next sweep.
27
+ */
28
+ export declare const SqlOutboxDrainLayer: (database: string, onOutcome?: RelayOutcomeSink) => Layer.Layer<OutboxDrainTag, never, SqlClient.SqlClient | OutboxMaxAttempts | EventBusTag>;
22
29
  //# sourceMappingURL=relay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/transactions/relay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAGtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS;IAC3C,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;CACvC,uKAcG,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,MAAM,EAChB,YAAW,gBAAqC,sFAe/C,CAAC"}
1
+ {"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/transactions/relay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAGtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS;IAC3C,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;CACvC,uKAcG,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,MAAM,EAChB,YAAW,gBAAqC,sFAe/C,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,EAChB,YAAW,gBAAqC,8FAgB/C,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { _ as _extends } from "@swc/helpers/_/_extends";
2
- import { EventBusTag, OutboxMaxAttempts } from '@entifix/transactions';
2
+ import { EventBusTag, OutboxDrainTag, OutboxMaxAttempts } from '@entifix/transactions';
3
3
  import { drainOutbox, ignoreRelayOutcome, runRelayDaemon, sweepOutbox } from '@entifix/transactions/engine';
4
- import { Effect } from 'effect';
4
+ import { Effect, Layer } from 'effect';
5
5
  import { SqlClient } from 'effect/sql';
6
6
  import { makeSqlOutbox } from './outbox.js';
7
7
  import { ensureSqlTransactionTables } from './schema.js';
@@ -41,5 +41,18 @@ import { ensureSqlTransactionTables } from './schema.js';
41
41
  database,
42
42
  failure
43
43
  })));
44
+ /**
45
+ * {@link drainSqlOutboxNow} as the {@link OutboxDrainTag} a writer finds, over
46
+ * the client, bus and attempt ceiling this layer is built with — so a flow
47
+ * engine announcing into this outbox puts its event on the bus at once rather
48
+ * than at the next sweep.
49
+ */ export const SqlOutboxDrainLayer = (database, onOutcome = ignoreRelayOutcome)=>Layer.effect(OutboxDrainTag, Effect.gen(function*() {
50
+ const sql = yield* SqlClient.SqlClient;
51
+ const bus = yield* EventBusTag;
52
+ const maxAttempts = yield* OutboxMaxAttempts;
53
+ return {
54
+ now: drainSqlOutboxNow(database, onOutcome).pipe(Effect.provideService(SqlClient.SqlClient, sql), Effect.provideService(EventBusTag, bus), Effect.provideService(OutboxMaxAttempts, maxAttempts))
55
+ };
56
+ }));
44
57
 
45
58
  //# sourceMappingURL=relay.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transactions/relay.ts"],"sourcesContent":["import { EventBusTag, OutboxMaxAttempts } from '@entifix/transactions';\nimport {\n drainOutbox,\n ignoreRelayOutcome,\n type OutboxStatsSink,\n type RelayOutcomeSink,\n runRelayDaemon,\n sweepOutbox,\n} from '@entifix/transactions/engine';\nimport { Effect } from 'effect';\nimport { SqlClient } from 'effect/sql';\n\nimport { makeSqlOutbox } from './outbox.js';\nimport { ensureSqlTransactionTables } from './schema.js';\n\n/**\n * Starts the relay over the service's SQL database: the tables are ensured, a\n * daemon sweeps the outbox, and its last sweep runs in the `flush` phase of a\n * shutdown, after consumers have stopped and while the bus is still open.\n * Several replicas may run it at once — the outbox's claim keeps them apart.\n */\nexport const startSqlOutboxRelay = (options: {\n /** What the outbox's outcomes and gauges are labelled with. */\n readonly database: string;\n readonly onStats?: OutboxStatsSink;\n readonly onOutcome?: RelayOutcomeSink;\n}) =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n const bus = yield* EventBusTag;\n const maxAttempts = yield* OutboxMaxAttempts;\n yield* ensureSqlTransactionTables(sql);\n yield* runRelayDaemon(\n sweepOutbox(makeSqlOutbox(sql), bus, {\n maxAttempts,\n database: options.database,\n ...(options.onStats ? { onStats: options.onStats } : {}),\n ...(options.onOutcome ? { onOutcome: options.onOutcome } : {}),\n }),\n );\n });\n\n/**\n * One drain now, for a write that just committed — the event leaves at once\n * rather than at the next sweep. A failure is reported and left to the sweep.\n */\nexport const drainSqlOutboxNow = (\n database: string,\n onOutcome: RelayOutcomeSink = ignoreRelayOutcome,\n) =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n const bus = yield* EventBusTag;\n const maxAttempts = yield* OutboxMaxAttempts;\n yield* drainOutbox(makeSqlOutbox(sql), bus, {\n maxAttempts,\n database,\n onOutcome,\n });\n }).pipe(\n Effect.catch(failure =>\n onOutcome({ _tag: 'drainFailed', database, failure }),\n ),\n );\n"],"names":["EventBusTag","OutboxMaxAttempts","drainOutbox","ignoreRelayOutcome","runRelayDaemon","sweepOutbox","Effect","SqlClient","makeSqlOutbox","ensureSqlTransactionTables","startSqlOutboxRelay","options","gen","sql","bus","maxAttempts","database","onStats","onOutcome","drainSqlOutboxNow","pipe","catch","failure","_tag"],"mappings":";AAAA,SAASA,WAAW,EAAEC,iBAAiB,QAAQ,wBAAwB;AACvE,SACEC,WAAW,EACXC,kBAAkB,EAGlBC,cAAc,EACdC,WAAW,QACN,+BAA+B;AACtC,SAASC,MAAM,QAAQ,SAAS;AAChC,SAASC,SAAS,QAAQ,aAAa;AAEvC,SAASC,aAAa,QAAQ,cAAc;AAC5C,SAASC,0BAA0B,QAAQ,cAAc;AAEzD;;;;;CAKC,GACD,OAAO,MAAMC,sBAAsB,CAACC,UAMlCL,OAAOM,GAAG,CAAC;QACT,MAAMC,MAAM,OAAON,UAAUA,SAAS;QACtC,MAAMO,MAAM,OAAOd;QACnB,MAAMe,cAAc,OAAOd;QAC3B,OAAOQ,2BAA2BI;QAClC,OAAOT,eACLC,YAAYG,cAAcK,MAAMC,KAAK;YACnCC;YACAC,UAAUL,QAAQK,QAAQ;WACtBL,QAAQM,OAAO,GAAG;YAAEA,SAASN,QAAQM,OAAO;QAAC,IAAI,CAAC,GAClDN,QAAQO,SAAS,GAAG;YAAEA,WAAWP,QAAQO,SAAS;QAAC,IAAI,CAAC;IAGlE,GAAG;AAEL;;;CAGC,GACD,OAAO,MAAMC,oBAAoB,CAC/BH,UACAE,YAA8Bf,kBAAkB,GAEhDG,OAAOM,GAAG,CAAC;QACT,MAAMC,MAAM,OAAON,UAAUA,SAAS;QACtC,MAAMO,MAAM,OAAOd;QACnB,MAAMe,cAAc,OAAOd;QAC3B,OAAOC,YAAYM,cAAcK,MAAMC,KAAK;YAC1CC;YACAC;YACAE;QACF;IACF,GAAGE,IAAI,CACLd,OAAOe,KAAK,CAACC,CAAAA,UACXJ,UAAU;YAAEK,MAAM;YAAeP;YAAUM;QAAQ,KAErD"}
1
+ {"version":3,"sources":["../../src/transactions/relay.ts"],"sourcesContent":["import {\n EventBusTag,\n OutboxDrainTag,\n OutboxMaxAttempts,\n} from '@entifix/transactions';\nimport {\n drainOutbox,\n ignoreRelayOutcome,\n type OutboxStatsSink,\n type RelayOutcomeSink,\n runRelayDaemon,\n sweepOutbox,\n} from '@entifix/transactions/engine';\nimport { Effect, Layer } from 'effect';\nimport { SqlClient } from 'effect/sql';\n\nimport { makeSqlOutbox } from './outbox.js';\nimport { ensureSqlTransactionTables } from './schema.js';\n\n/**\n * Starts the relay over the service's SQL database: the tables are ensured, a\n * daemon sweeps the outbox, and its last sweep runs in the `flush` phase of a\n * shutdown, after consumers have stopped and while the bus is still open.\n * Several replicas may run it at once — the outbox's claim keeps them apart.\n */\nexport const startSqlOutboxRelay = (options: {\n /** What the outbox's outcomes and gauges are labelled with. */\n readonly database: string;\n readonly onStats?: OutboxStatsSink;\n readonly onOutcome?: RelayOutcomeSink;\n}) =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n const bus = yield* EventBusTag;\n const maxAttempts = yield* OutboxMaxAttempts;\n yield* ensureSqlTransactionTables(sql);\n yield* runRelayDaemon(\n sweepOutbox(makeSqlOutbox(sql), bus, {\n maxAttempts,\n database: options.database,\n ...(options.onStats ? { onStats: options.onStats } : {}),\n ...(options.onOutcome ? { onOutcome: options.onOutcome } : {}),\n }),\n );\n });\n\n/**\n * One drain now, for a write that just committed — the event leaves at once\n * rather than at the next sweep. A failure is reported and left to the sweep.\n */\nexport const drainSqlOutboxNow = (\n database: string,\n onOutcome: RelayOutcomeSink = ignoreRelayOutcome,\n) =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n const bus = yield* EventBusTag;\n const maxAttempts = yield* OutboxMaxAttempts;\n yield* drainOutbox(makeSqlOutbox(sql), bus, {\n maxAttempts,\n database,\n onOutcome,\n });\n }).pipe(\n Effect.catch(failure =>\n onOutcome({ _tag: 'drainFailed', database, failure }),\n ),\n );\n\n/**\n * {@link drainSqlOutboxNow} as the {@link OutboxDrainTag} a writer finds, over\n * the client, bus and attempt ceiling this layer is built with — so a flow\n * engine announcing into this outbox puts its event on the bus at once rather\n * than at the next sweep.\n */\nexport const SqlOutboxDrainLayer = (\n database: string,\n onOutcome: RelayOutcomeSink = ignoreRelayOutcome,\n) =>\n Layer.effect(\n OutboxDrainTag,\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n const bus = yield* EventBusTag;\n const maxAttempts = yield* OutboxMaxAttempts;\n return {\n now: drainSqlOutboxNow(database, onOutcome).pipe(\n Effect.provideService(SqlClient.SqlClient, sql),\n Effect.provideService(EventBusTag, bus),\n Effect.provideService(OutboxMaxAttempts, maxAttempts),\n ),\n };\n }),\n );\n"],"names":["EventBusTag","OutboxDrainTag","OutboxMaxAttempts","drainOutbox","ignoreRelayOutcome","runRelayDaemon","sweepOutbox","Effect","Layer","SqlClient","makeSqlOutbox","ensureSqlTransactionTables","startSqlOutboxRelay","options","gen","sql","bus","maxAttempts","database","onStats","onOutcome","drainSqlOutboxNow","pipe","catch","failure","_tag","SqlOutboxDrainLayer","effect","now","provideService"],"mappings":";AAAA,SACEA,WAAW,EACXC,cAAc,EACdC,iBAAiB,QACZ,wBAAwB;AAC/B,SACEC,WAAW,EACXC,kBAAkB,EAGlBC,cAAc,EACdC,WAAW,QACN,+BAA+B;AACtC,SAASC,MAAM,EAAEC,KAAK,QAAQ,SAAS;AACvC,SAASC,SAAS,QAAQ,aAAa;AAEvC,SAASC,aAAa,QAAQ,cAAc;AAC5C,SAASC,0BAA0B,QAAQ,cAAc;AAEzD;;;;;CAKC,GACD,OAAO,MAAMC,sBAAsB,CAACC,UAMlCN,OAAOO,GAAG,CAAC;QACT,MAAMC,MAAM,OAAON,UAAUA,SAAS;QACtC,MAAMO,MAAM,OAAOhB;QACnB,MAAMiB,cAAc,OAAOf;QAC3B,OAAOS,2BAA2BI;QAClC,OAAOV,eACLC,YAAYI,cAAcK,MAAMC,KAAK;YACnCC;YACAC,UAAUL,QAAQK,QAAQ;WACtBL,QAAQM,OAAO,GAAG;YAAEA,SAASN,QAAQM,OAAO;QAAC,IAAI,CAAC,GAClDN,QAAQO,SAAS,GAAG;YAAEA,WAAWP,QAAQO,SAAS;QAAC,IAAI,CAAC;IAGlE,GAAG;AAEL;;;CAGC,GACD,OAAO,MAAMC,oBAAoB,CAC/BH,UACAE,YAA8BhB,kBAAkB,GAEhDG,OAAOO,GAAG,CAAC;QACT,MAAMC,MAAM,OAAON,UAAUA,SAAS;QACtC,MAAMO,MAAM,OAAOhB;QACnB,MAAMiB,cAAc,OAAOf;QAC3B,OAAOC,YAAYO,cAAcK,MAAMC,KAAK;YAC1CC;YACAC;YACAE;QACF;IACF,GAAGE,IAAI,CACLf,OAAOgB,KAAK,CAACC,CAAAA,UACXJ,UAAU;YAAEK,MAAM;YAAeP;YAAUM;QAAQ,KAErD;AAEJ;;;;;CAKC,GACD,OAAO,MAAME,sBAAsB,CACjCR,UACAE,YAA8BhB,kBAAkB,GAEhDI,MAAMmB,MAAM,CACV1B,gBACAM,OAAOO,GAAG,CAAC;QACT,MAAMC,MAAM,OAAON,UAAUA,SAAS;QACtC,MAAMO,MAAM,OAAOhB;QACnB,MAAMiB,cAAc,OAAOf;QAC3B,OAAO;YACL0B,KAAKP,kBAAkBH,UAAUE,WAAWE,IAAI,CAC9Cf,OAAOsB,cAAc,CAACpB,UAAUA,SAAS,EAAEM,MAC3CR,OAAOsB,cAAc,CAAC7B,aAAagB,MACnCT,OAAOsB,cAAc,CAAC3B,mBAAmBe;QAE7C;IACF,IACA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entifix/sql",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "SQL adapter over @effect/sql: an entity repository with RSQL filter and sort translation, and a health probe.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -63,18 +63,18 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@swc/helpers": "0.5.23",
66
- "@entifix/business": "0.17.0",
67
- "@entifix/core": "0.17.0"
66
+ "@entifix/business": "0.18.0",
67
+ "@entifix/core": "0.18.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@effect/sql-pg": "4.0.7",
71
71
  "effect": "4.0.7",
72
- "@entifix/testing-unit": "0.17.0",
73
- "@entifix/transactions": "0.17.0"
72
+ "@entifix/transactions": "0.18.0",
73
+ "@entifix/testing-unit": "0.18.0"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "effect": "^4.0.7",
77
- "@entifix/transactions": "0.17.0"
77
+ "@entifix/transactions": "0.18.0"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "@entifix/transactions": {