@voltro/plugin-analytics-postgres 0.32.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.
@@ -5,7 +5,7 @@ property of its respective copyright holders and is used under the terms of
5
5
  its license. This file is provided for attribution; it grants no rights in
6
6
  @voltro/plugin-analytics-postgres itself, which is proprietary (see LICENSE).
7
7
 
8
- Generated from the resolved runtime dependency closure (52 packages).
8
+ Generated from the resolved runtime dependency closure (51 packages).
9
9
 
10
10
  ---
11
11
 
@@ -37,34 +37,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
37
  SOFTWARE.
38
38
  ```
39
39
 
40
- ## @effect/opentelemetry@0.64.0
41
-
42
- License: MIT
43
-
44
- ```
45
- MIT License
46
-
47
- Copyright (c) 2020-present The Contributors
48
-
49
- Permission is hereby granted, free of charge, to any person obtaining a copy
50
- of this software and associated documentation files (the "Software"), to deal
51
- in the Software without restriction, including without limitation the rights
52
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
53
- copies of the Software, and to permit persons to whom the Software is
54
- furnished to do so, subject to the following conditions:
55
-
56
- The above copyright notice and this permission notice shall be included in all
57
- copies or substantial portions of the Software.
58
-
59
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
63
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
64
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
65
- SOFTWARE.
66
- ```
67
-
68
40
  ## @effect/platform-node@0.108.0
69
41
 
70
42
  License: MIT
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) => s.gen(function* () {
84
- yield* i(t);
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.32.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",
@@ -22,7 +22,8 @@
22
22
  "types": "./dist/index.d.ts",
23
23
  "import": "./dist/index.js",
24
24
  "default": "./dist/index.js"
25
- }
25
+ },
26
+ "./package.json": "./package.json"
26
27
  },
27
28
  "main": "./dist/index.js",
28
29
  "module": "./dist/index.js",
@@ -33,8 +34,8 @@
33
34
  },
34
35
  "dependencies": {
35
36
  "@effect/sql": "^0.52.0",
36
- "@voltro/database": "0.32.0",
37
- "@voltro/runtime": "0.32.0"
37
+ "@voltro/database": "0.34.0",
38
+ "@voltro/runtime": "0.34.0"
38
39
  },
39
40
  "peerDependencies": {
40
41
  "effect": "^3.22.0"