@voltro/plugin-analytics-postgres 0.33.0 → 0.34.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/CHANGELOG.md +1801 -0
- package/dist/index.js +19 -16
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -69,31 +69,33 @@ var l = i("_voltro_events", {
|
|
|
69
69
|
r.has(t) || (yield* e`
|
|
70
70
|
CREATE TABLE IF NOT EXISTS ${e(h(t))} (
|
|
71
71
|
${e("id")} TEXT PRIMARY KEY,
|
|
72
|
-
${e("data")} JSONB NOT NULL
|
|
72
|
+
${e("data")} JSONB NOT NULL,
|
|
73
|
+
${e("version")} BIGINT NOT NULL DEFAULT 0,
|
|
74
|
+
${e("is_deleted")} BOOLEAN NOT NULL DEFAULT false
|
|
73
75
|
)
|
|
74
76
|
`, r.add(t));
|
|
75
77
|
}), a = (e) => s.mapError((t) => new c({
|
|
76
78
|
provider: p,
|
|
77
79
|
operation: e,
|
|
78
80
|
cause: t instanceof Error ? `${t.name}: ${t.message}` : String(t)
|
|
79
|
-
}))
|
|
81
|
+
})), o = (t, n, r, a, o) => s.gen(function* () {
|
|
82
|
+
yield* i(t);
|
|
83
|
+
let s = h(t);
|
|
84
|
+
yield* e`
|
|
85
|
+
INSERT INTO ${e(s)} (${e("id")}, ${e("data")}, ${e("version")}, ${e("is_deleted")})
|
|
86
|
+
VALUES (${n}, ${r}, ${a}, ${o})
|
|
87
|
+
ON CONFLICT (${e("id")}) DO UPDATE SET
|
|
88
|
+
${e("data")} = ${r},
|
|
89
|
+
${e("version")} = ${a},
|
|
90
|
+
${e("is_deleted")} = ${o}
|
|
91
|
+
WHERE ${e(s)}.${e("version")} < ${a}
|
|
92
|
+
`;
|
|
93
|
+
});
|
|
80
94
|
return {
|
|
81
95
|
tables: t,
|
|
82
96
|
primaryKey: n,
|
|
83
|
-
upsert: (t, r) =>
|
|
84
|
-
|
|
85
|
-
let a = h(t), o = String(r[n]), s = JSON.stringify(r);
|
|
86
|
-
yield* e`
|
|
87
|
-
INSERT INTO ${e(a)} (${e("id")}, ${e("data")})
|
|
88
|
-
VALUES (${o}, ${s})
|
|
89
|
-
ON CONFLICT (${e("id")}) DO UPDATE SET ${e("data")} = ${s}
|
|
90
|
-
`;
|
|
91
|
-
}).pipe(a("mirror.upsert")),
|
|
92
|
-
remove: (t, n) => s.gen(function* () {
|
|
93
|
-
yield* i(t);
|
|
94
|
-
let r = h(t), a = String(n);
|
|
95
|
-
yield* e`DELETE FROM ${e(r)} WHERE ${e("id")} = ${a}`;
|
|
96
|
-
}).pipe(a("mirror.remove"))
|
|
97
|
+
upsert: ({ table: e, row: t, version: r }) => o(e, String(t[n]), JSON.stringify(t), r, !1).pipe(a("mirror.upsert")),
|
|
98
|
+
remove: ({ table: e, primaryKeyValue: t, version: n }) => o(e, String(t), "{}", n, !0).pipe(a("mirror.remove"))
|
|
97
99
|
};
|
|
98
100
|
}, x = (e, t = {}) => {
|
|
99
101
|
let n = e, r = t.mirrorTables ?? [], i = r.length > 0 ? b(n, r, t.mirrorPrimaryKey ?? "id") : void 0;
|
|
@@ -161,6 +163,7 @@ var l = i("_voltro_events", {
|
|
|
161
163
|
...i === void 0 ? {} : { mirror: i }
|
|
162
164
|
};
|
|
163
165
|
}, S = (e = {}) => (n({
|
|
166
|
+
source: "plugin",
|
|
164
167
|
table: "_voltro_events",
|
|
165
168
|
timeColumn: "occurredAt",
|
|
166
169
|
ttlMs: r(process.env.VOLTRO_EVENTS_TTL_HOURS, 24 * 365)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/plugin-analytics-postgres",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "First-party AnalyticsSink that stores events in the main DataStore (works on every SQL dialect: postgres / mysql / mariadb / mssql / sqlite). Lite version — ceiling ~10M events/day before queries get slow.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@effect/sql": "^0.52.0",
|
|
37
|
-
"@voltro/database": "0.
|
|
38
|
-
"@voltro/runtime": "0.
|
|
37
|
+
"@voltro/database": "0.34.0",
|
|
38
|
+
"@voltro/runtime": "0.34.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"effect": "^3.22.0"
|