@hogsend/engine 0.27.0 → 0.28.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.
- package/package.json +7 -7
- package/src/lib/contacts.ts +15 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hogsend/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"svix": "^1.95.1",
|
|
41
41
|
"winston": "^3.19.0",
|
|
42
42
|
"zod": "^4.4.3",
|
|
43
|
-
"@hogsend/core": "^0.
|
|
44
|
-
"@hogsend/db": "^0.
|
|
45
|
-
"@hogsend/email": "^0.
|
|
46
|
-
"@hogsend/plugin-posthog": "^0.
|
|
47
|
-
"@hogsend/plugin-resend": "^0.
|
|
43
|
+
"@hogsend/core": "^0.28.0",
|
|
44
|
+
"@hogsend/db": "^0.28.0",
|
|
45
|
+
"@hogsend/email": "^0.28.0",
|
|
46
|
+
"@hogsend/plugin-posthog": "^0.28.0",
|
|
47
|
+
"@hogsend/plugin-resend": "^0.28.0"
|
|
48
48
|
},
|
|
49
49
|
"optionalDependencies": {
|
|
50
|
-
"@hogsend/plugin-postmark": "^0.
|
|
50
|
+
"@hogsend/plugin-postmark": "^0.28.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "^22.15.3",
|
package/src/lib/contacts.ts
CHANGED
|
@@ -200,7 +200,7 @@ async function findByKey(tx: Tx, key: ResolveKey): Promise<ContactRow | null> {
|
|
|
200
200
|
* additive — siblings stay strictly shallow, preserving the documented contract
|
|
201
201
|
* for everything else. NON-KEY metadata only; never an identity-resolution key.
|
|
202
202
|
*/
|
|
203
|
-
const DEEP_MERGE_KEYS = ["discord"] as const;
|
|
203
|
+
const DEEP_MERGE_KEYS = ["discord", "telegram"] as const;
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
206
|
* Merge `patch` onto the existing jsonb properties (§2.1 contract): additive
|
|
@@ -798,21 +798,23 @@ async function mergeContacts(
|
|
|
798
798
|
}
|
|
799
799
|
|
|
800
800
|
/**
|
|
801
|
-
* journey_states fold. `uq_user_journey_active` is a
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
*
|
|
801
|
+
* journey_states fold. `uq_user_journey_active` is a PARTIAL unique index on
|
|
802
|
+
* `(user_id, journey_id) WHERE status IN ('active','waiting')` — it constrains
|
|
803
|
+
* only LIVE rows, so terminal rows (completed/failed/exited) may legitimately
|
|
804
|
+
* duplicate across the merged identities. A rewrite of a loser's LIVE row onto
|
|
805
|
+
* the survivor key still collides whenever the survivor already holds a live row
|
|
806
|
+
* for that journey.
|
|
807
807
|
*
|
|
808
808
|
* Fix: build the survivor's occupied (journey_id|status) set over ALL statuses.
|
|
809
809
|
* For active/waiting collisions, EXIT the loser's row first (preserve the
|
|
810
|
-
* survivor's live run)
|
|
811
|
-
*
|
|
812
|
-
*
|
|
813
|
-
*
|
|
814
|
-
*
|
|
815
|
-
*
|
|
810
|
+
* survivor's live run) so the rewrite lands an 'exited' (out-of-predicate) row.
|
|
811
|
+
* For any OTHER collision (terminal), DELETE the loser's duplicate — no longer
|
|
812
|
+
* REQUIRED by the constraint (terminal rows are outside the predicate), but kept
|
|
813
|
+
* as hygiene so the survivor doesn't carry two identical terminal rows (which
|
|
814
|
+
* would inflate the count()-based ctx.history.journey.entryCount). Rewrite only
|
|
815
|
+
* the non-colliding remainder onto the survivor key (+ survivor email). Re-check
|
|
816
|
+
* 'exited' occupancy after exiting so a just-exited loser row that would now
|
|
817
|
+
* duplicate a pre-existing survivor 'exited' row is dropped rather than rewritten.
|
|
816
818
|
*/
|
|
817
819
|
async function foldJourneyStates(
|
|
818
820
|
tx: Tx,
|