@voltro/plugin-analytics-postgres 0.33.0 → 0.35.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 +1968 -0
- package/dist/index.js +25 -15
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -69,31 +69,40 @@ 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
|
-
|
|
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* () {
|
|
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")),
|
|
99
|
+
maxVersion: ({ table: t, primaryKeyValue: n }) => s.gen(function* () {
|
|
93
100
|
yield* i(t);
|
|
94
|
-
let r = h(t), a =
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
let r = h(t), a = (yield* e`
|
|
102
|
+
SELECT ${e("version")} AS version FROM ${e(r)} WHERE ${e("id")} = ${String(n)}
|
|
103
|
+
`)[0]?.version;
|
|
104
|
+
return a == null ? null : Number(a);
|
|
105
|
+
}).pipe(a("mirror.maxVersion"))
|
|
97
106
|
};
|
|
98
107
|
}, x = (e, t = {}) => {
|
|
99
108
|
let n = e, r = t.mirrorTables ?? [], i = r.length > 0 ? b(n, r, t.mirrorPrimaryKey ?? "id") : void 0;
|
|
@@ -161,6 +170,7 @@ var l = i("_voltro_events", {
|
|
|
161
170
|
...i === void 0 ? {} : { mirror: i }
|
|
162
171
|
};
|
|
163
172
|
}, S = (e = {}) => (n({
|
|
173
|
+
source: "plugin",
|
|
164
174
|
table: "_voltro_events",
|
|
165
175
|
timeColumn: "occurredAt",
|
|
166
176
|
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.35.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.35.0",
|
|
38
|
+
"@voltro/runtime": "0.35.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"effect": "^3.22.0"
|