@powersync/service-module-postgres-storage 0.0.0-dev-20250820110726 → 0.0.0-dev-20250827072023
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 +13 -9
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/storage/PostgresReportStorageFactory.d.ts +2 -2
- package/dist/@types/storage/storage-index.d.ts +0 -1
- package/dist/@types/types/models/SyncRules.d.ts +2 -2
- package/dist/@types/{storage/PostgresTestStorageFactoryGenerator.d.ts → utils/test-utils.d.ts} +4 -4
- package/dist/@types/utils/utils-index.d.ts +1 -0
- package/dist/storage/PostgresReportStorageFactory.js +5 -57
- package/dist/storage/PostgresReportStorageFactory.js.map +1 -1
- package/dist/storage/storage-index.js +0 -1
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/{storage/PostgresTestStorageFactoryGenerator.js → utils/test-utils.js} +7 -7
- package/dist/utils/test-utils.js.map +1 -0
- package/dist/utils/utils-index.js +1 -0
- package/dist/utils/utils-index.js.map +1 -1
- package/package.json +9 -9
- package/src/storage/PostgresReportStorageFactory.ts +10 -60
- package/src/storage/storage-index.ts +0 -1
- package/src/{storage/PostgresTestStorageFactoryGenerator.ts → utils/test-utils.ts} +6 -6
- package/src/utils/utils-index.ts +1 -0
- package/test/src/__snapshots__/connection-report-storage.test.ts.snap +61 -83
- package/test/src/__snapshots__/storage_sync.test.ts.snap +12 -11
- package/test/src/connection-report-storage.test.ts +128 -234
- package/test/src/util.ts +2 -1
- package/dist/storage/PostgresTestStorageFactoryGenerator.js.map +0 -1
|
@@ -16,8 +16,8 @@ export declare class PostgresReportStorageFactory implements storage.ReportStora
|
|
|
16
16
|
private updateTableFilter;
|
|
17
17
|
reportClientConnection(data: event_types.ClientConnectionBucketData): Promise<void>;
|
|
18
18
|
reportClientDisconnection(data: event_types.ClientDisconnectionEventData): Promise<void>;
|
|
19
|
-
getConnectedClients(
|
|
20
|
-
getClientConnectionReports(data: event_types.ClientConnectionReportRequest): Promise<event_types.
|
|
19
|
+
getConnectedClients(): Promise<event_types.ClientConnectionReportResponse>;
|
|
20
|
+
getClientConnectionReports(data: event_types.ClientConnectionReportRequest): Promise<event_types.ClientConnectionReportResponse>;
|
|
21
21
|
deleteOldConnectionData(data: event_types.DeleteOldConnectionData): Promise<void>;
|
|
22
22
|
[Symbol.asyncDispose](): Promise<void>;
|
|
23
23
|
prepareStatements(connection: pg_wire.PgConnection): Promise<void>;
|
|
@@ -33,13 +33,13 @@ export declare const SyncRules: t.ObjectCodec<{
|
|
|
33
33
|
*
|
|
34
34
|
* This may be old if no data is incoming.
|
|
35
35
|
*/
|
|
36
|
-
last_checkpoint_ts: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Date, string, string, t.CodecProps>>;
|
|
36
|
+
last_checkpoint_ts: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Date, string | import("@powersync/service-sync-rules").DateTimeValue, string, t.CodecProps>>;
|
|
37
37
|
/**
|
|
38
38
|
* Last time we persisted a checkpoint or keepalive.
|
|
39
39
|
*
|
|
40
40
|
* This should stay fairly current while replicating.
|
|
41
41
|
*/
|
|
42
|
-
last_keepalive_ts: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Date, string, string, t.CodecProps>>;
|
|
42
|
+
last_keepalive_ts: t.Union<t.Codec<null, null, string, t.CodecProps>, t.Codec<Date, string | import("@powersync/service-sync-rules").DateTimeValue, string, t.CodecProps>>;
|
|
43
43
|
/**
|
|
44
44
|
* If an error is stopping replication, it will be stored here.
|
|
45
45
|
*/
|
package/dist/@types/{storage/PostgresTestStorageFactoryGenerator.d.ts → utils/test-utils.d.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { framework, TestStorageOptions } from '@powersync/service-core';
|
|
2
2
|
import { PostgresMigrationAgent } from '../migrations/PostgresMigrationAgent.js';
|
|
3
3
|
import { PostgresStorageConfigDecoded } from '../types/types.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { PostgresReportStorageFactory } from '../storage/PostgresReportStorageFactory.js';
|
|
5
|
+
import { PostgresBucketStorageFactory } from '../storage/PostgresBucketStorageFactory.js';
|
|
6
6
|
export type PostgresTestStorageOptions = {
|
|
7
7
|
url: string;
|
|
8
8
|
/**
|
|
@@ -11,9 +11,9 @@ export type PostgresTestStorageOptions = {
|
|
|
11
11
|
*/
|
|
12
12
|
migrationAgent?: (config: PostgresStorageConfigDecoded) => PostgresMigrationAgent;
|
|
13
13
|
};
|
|
14
|
-
export declare
|
|
14
|
+
export declare function postgresTestSetup(factoryOptions: PostgresTestStorageOptions): {
|
|
15
15
|
reportFactory: (options?: TestStorageOptions) => Promise<PostgresReportStorageFactory>;
|
|
16
16
|
factory: (options?: TestStorageOptions) => Promise<PostgresBucketStorageFactory>;
|
|
17
17
|
migrate: (direction: framework.migrations.Direction) => Promise<void>;
|
|
18
18
|
};
|
|
19
|
-
export declare
|
|
19
|
+
export declare function postgresTestStorageFactoryGenerator(factoryOptions: PostgresTestStorageOptions): (options?: TestStorageOptions) => Promise<PostgresBucketStorageFactory>;
|
|
@@ -44,57 +44,7 @@ export class PostgresReportStorageFactory {
|
|
|
44
44
|
sdks: result.sdks?.data || []
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
async listConnectionsQuery(
|
|
48
|
-
const { range } = data;
|
|
49
|
-
if (!range) {
|
|
50
|
-
return this.db.sql `
|
|
51
|
-
WITH
|
|
52
|
-
filtered AS (
|
|
53
|
-
SELECT
|
|
54
|
-
*
|
|
55
|
-
FROM
|
|
56
|
-
connection_report_events
|
|
57
|
-
WHERE
|
|
58
|
-
disconnected_at IS NULL
|
|
59
|
-
AND jwt_exp > NOW()
|
|
60
|
-
),
|
|
61
|
-
unique_users AS (
|
|
62
|
-
SELECT
|
|
63
|
-
COUNT(DISTINCT user_id) AS count
|
|
64
|
-
FROM
|
|
65
|
-
filtered
|
|
66
|
-
),
|
|
67
|
-
sdk_versions_array AS (
|
|
68
|
-
SELECT
|
|
69
|
-
sdk,
|
|
70
|
-
COUNT(DISTINCT client_id) AS clients,
|
|
71
|
-
COUNT(DISTINCT user_id) AS users
|
|
72
|
-
FROM
|
|
73
|
-
filtered
|
|
74
|
-
GROUP BY
|
|
75
|
-
sdk
|
|
76
|
-
)
|
|
77
|
-
SELECT
|
|
78
|
-
(
|
|
79
|
-
SELECT
|
|
80
|
-
COALESCE(count, 0)
|
|
81
|
-
FROM
|
|
82
|
-
unique_users
|
|
83
|
-
) AS users,
|
|
84
|
-
(
|
|
85
|
-
SELECT
|
|
86
|
-
JSON_AGG(ROW_TO_JSON(s))
|
|
87
|
-
FROM
|
|
88
|
-
sdk_versions_array s
|
|
89
|
-
) AS sdks;
|
|
90
|
-
`
|
|
91
|
-
.decoded(SdkReporting)
|
|
92
|
-
.first();
|
|
93
|
-
}
|
|
94
|
-
const endDate = data.range?.end ? new Date(data.range.end) : new Date();
|
|
95
|
-
const startDate = new Date(range.start);
|
|
96
|
-
const lt = endDate.toISOString();
|
|
97
|
-
const gt = startDate.toISOString();
|
|
47
|
+
async listConnectionsQuery() {
|
|
98
48
|
return await this.db.sql `
|
|
99
49
|
WITH
|
|
100
50
|
filtered AS (
|
|
@@ -104,9 +54,7 @@ export class PostgresReportStorageFactory {
|
|
|
104
54
|
connection_report_events
|
|
105
55
|
WHERE
|
|
106
56
|
disconnected_at IS NULL
|
|
107
|
-
AND jwt_exp > NOW()
|
|
108
|
-
AND connected_at >= ${{ type: 1184, value: gt }}
|
|
109
|
-
AND connected_at <= ${{ type: 1184, value: lt }}
|
|
57
|
+
AND jwt_exp > NOW() AT TIME ZONE 'UTC'
|
|
110
58
|
),
|
|
111
59
|
unique_users AS (
|
|
112
60
|
SELECT
|
|
@@ -209,8 +157,8 @@ export class PostgresReportStorageFactory {
|
|
|
209
157
|
AND connected_at = ${{ type: 1184, value: connectIsoString }}
|
|
210
158
|
`.execute();
|
|
211
159
|
}
|
|
212
|
-
async getConnectedClients(
|
|
213
|
-
const result = await this.listConnectionsQuery(
|
|
160
|
+
async getConnectedClients() {
|
|
161
|
+
const result = await this.listConnectionsQuery();
|
|
214
162
|
return this.mapListCurrentConnectionsResponse(result);
|
|
215
163
|
}
|
|
216
164
|
async getClientConnectionReports(data) {
|
|
@@ -269,7 +217,7 @@ export class PostgresReportStorageFactory {
|
|
|
269
217
|
AND (
|
|
270
218
|
disconnected_at IS NOT NULL
|
|
271
219
|
OR (
|
|
272
|
-
jwt_exp < NOW()
|
|
220
|
+
jwt_exp < NOW() AT TIME ZONE 'UTC'
|
|
273
221
|
AND disconnected_at IS NULL
|
|
274
222
|
)
|
|
275
223
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresReportStorageFactory.js","sourceRoot":"","sources":["../../src/storage/PostgresReportStorageFactory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAuB,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAMrD,MAAM,OAAO,4BAA4B;IAEjB;IADb,EAAE,CAA8B;IACzC,YAAsB,OAAqC;QAArC,YAAO,GAAP,OAAO,CAA8B;QACzD,IAAI,CAAC,EAAE,GAAG,IAAI,YAAY,CAAC,cAAc,CAAC;YACxC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,mBAAmB;YAC3B,eAAe,EAAE,yBAAyB,EAAE;SAC7C,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC;YACvB,iBAAiB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YAAY,CAAC,EAAE,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,UAAgC;QACtD,+EAA+E;QAC/E,qCAAqC;IACvC,CAAC;CACF"}
|
|
@@ -2,5 +2,4 @@ export * from './PostgresBucketStorageFactory.js';
|
|
|
2
2
|
export * from './PostgresCompactor.js';
|
|
3
3
|
export * from './PostgresStorageProvider.js';
|
|
4
4
|
export * from './PostgresSyncRulesStorage.js';
|
|
5
|
-
export * from './PostgresTestStorageFactoryGenerator.js';
|
|
6
5
|
//# sourceMappingURL=storage-index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-index.js","sourceRoot":"","sources":["../../src/storage/storage-index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC
|
|
1
|
+
{"version":3,"file":"storage-index.js","sourceRoot":"","sources":["../../src/storage/storage-index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC"}
|
|
@@ -53,9 +53,9 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
53
53
|
import { framework } from '@powersync/service-core';
|
|
54
54
|
import { PostgresMigrationAgent } from '../migrations/PostgresMigrationAgent.js';
|
|
55
55
|
import { normalizePostgresStorageConfig } from '../types/types.js';
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
export
|
|
56
|
+
import { PostgresReportStorageFactory } from '../storage/PostgresReportStorageFactory.js';
|
|
57
|
+
import { PostgresBucketStorageFactory } from '../storage/PostgresBucketStorageFactory.js';
|
|
58
|
+
export function postgresTestSetup(factoryOptions) {
|
|
59
59
|
const BASE_CONFIG = {
|
|
60
60
|
type: 'postgresql',
|
|
61
61
|
uri: factoryOptions.url,
|
|
@@ -130,8 +130,8 @@ export const postgresTestSetup = (factoryOptions) => {
|
|
|
130
130
|
},
|
|
131
131
|
migrate
|
|
132
132
|
};
|
|
133
|
-
}
|
|
134
|
-
export
|
|
133
|
+
}
|
|
134
|
+
export function postgresTestStorageFactoryGenerator(factoryOptions) {
|
|
135
135
|
return postgresTestSetup(factoryOptions).factory;
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../src/utils/test-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAiE,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,8BAA8B,EAAgC,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAW1F,MAAM,UAAU,iBAAiB,CAAC,cAA0C;IAC1E,MAAM,WAAW,GAAG;QAClB,IAAI,EAAE,YAAqB;QAC3B,GAAG,EAAE,cAAc,CAAC,GAAG;QACvB,OAAO,EAAE,SAAkB;KAC5B,CAAC;IAEF,MAAM,uBAAuB,GAAG,8BAA8B,CAAC,WAAW,CAAC,CAAC;IAE5E,MAAM,OAAO,GAAG,KAAK,EAAE,SAAyC,EAAE,EAAE;;;YAClE,MAAY,gBAAgB,kCAA8B,IAAI,SAAS,CAAC,gBAAgB,EAAE,OAAA,CAAC;YAC3F,MAAY,cAAc,kCAAG,cAAc,CAAC,cAAc;gBACxD,CAAC,CAAC,cAAc,CAAC,cAAc,CAAC,WAAW,CAAC;gBAC5C,CAAC,CAAC,IAAI,sBAAs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;oBACzB,MAAM,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;gBACnD,CAAC;gBAED,OAAO,IAAI,4BAA4B,CAAC;oBACtC,MAAM,EAAE,uBAAuB;oBAC/B,gBAAgB,EAAE,OAAO;iBAC1B,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,EAAE,EAAE,CAAC;gBACZ,iFAAiF;gBACjF,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;gBAC5B,MAAM,EAAE,CAAC;YACX,CAAC;QACH,CAAC;QACD,OAAO;KACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mCAAmC,CAAC,cAA0C;IAC5F,OAAO,iBAAiB,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC;AACnD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-index.js","sourceRoot":"","sources":["../../src/utils/utils-index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils-index.js","sourceRoot":"","sources":["../../src/utils/utils-index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@powersync/service-module-postgres-storage",
|
|
3
3
|
"repository": "https://github.com/powersync-ja/powersync-service",
|
|
4
4
|
"types": "dist/@types/index.d.ts",
|
|
5
|
-
"version": "0.0.0-dev-
|
|
5
|
+
"version": "0.0.0-dev-20250827072023",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"p-defer": "^4.0.1",
|
|
29
29
|
"ts-codec": "^1.3.0",
|
|
30
30
|
"uuid": "^11.1.0",
|
|
31
|
-
"@powersync/lib-service-postgres": "0.0.0-dev-
|
|
32
|
-
"@powersync/lib-services-framework": "0.0.0-dev-
|
|
33
|
-
"@powersync/service-core": "0.0.0-dev-
|
|
34
|
-
"@powersync/service-types": "0.0.0-dev-
|
|
35
|
-
"@powersync/service-core-tests": "0.0.0-dev-
|
|
36
|
-
"@powersync/service-jpgwire": "0.0.0-dev-
|
|
37
|
-
"@powersync/service-jsonbig": "0.0.0-dev-
|
|
38
|
-
"@powersync/service-sync-rules": "0.0.0-dev-
|
|
31
|
+
"@powersync/lib-service-postgres": "0.0.0-dev-20250827072023",
|
|
32
|
+
"@powersync/lib-services-framework": "0.0.0-dev-20250827072023",
|
|
33
|
+
"@powersync/service-core": "0.0.0-dev-20250827072023",
|
|
34
|
+
"@powersync/service-types": "0.0.0-dev-20250827072023",
|
|
35
|
+
"@powersync/service-core-tests": "0.0.0-dev-20250827072023",
|
|
36
|
+
"@powersync/service-jpgwire": "0.0.0-dev-20250827072023",
|
|
37
|
+
"@powersync/service-jsonbig": "0.0.0-dev-20250827072023",
|
|
38
|
+
"@powersync/service-sync-rules": "0.0.0-dev-20250827072023"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"typescript": "^5.7.3"
|
|
@@ -42,7 +42,9 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
private mapListCurrentConnectionsResponse(
|
|
45
|
+
private mapListCurrentConnectionsResponse(
|
|
46
|
+
result: SdkReportingDecoded | null
|
|
47
|
+
): event_types.ClientConnectionReportResponse {
|
|
46
48
|
if (!result) {
|
|
47
49
|
return {
|
|
48
50
|
users: 0,
|
|
@@ -54,57 +56,7 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
54
56
|
sdks: result.sdks?.data || []
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
|
-
private async listConnectionsQuery(
|
|
58
|
-
const { range } = data;
|
|
59
|
-
if (!range) {
|
|
60
|
-
return this.db.sql`
|
|
61
|
-
WITH
|
|
62
|
-
filtered AS (
|
|
63
|
-
SELECT
|
|
64
|
-
*
|
|
65
|
-
FROM
|
|
66
|
-
connection_report_events
|
|
67
|
-
WHERE
|
|
68
|
-
disconnected_at IS NULL
|
|
69
|
-
AND jwt_exp > NOW()
|
|
70
|
-
),
|
|
71
|
-
unique_users AS (
|
|
72
|
-
SELECT
|
|
73
|
-
COUNT(DISTINCT user_id) AS count
|
|
74
|
-
FROM
|
|
75
|
-
filtered
|
|
76
|
-
),
|
|
77
|
-
sdk_versions_array AS (
|
|
78
|
-
SELECT
|
|
79
|
-
sdk,
|
|
80
|
-
COUNT(DISTINCT client_id) AS clients,
|
|
81
|
-
COUNT(DISTINCT user_id) AS users
|
|
82
|
-
FROM
|
|
83
|
-
filtered
|
|
84
|
-
GROUP BY
|
|
85
|
-
sdk
|
|
86
|
-
)
|
|
87
|
-
SELECT
|
|
88
|
-
(
|
|
89
|
-
SELECT
|
|
90
|
-
COALESCE(count, 0)
|
|
91
|
-
FROM
|
|
92
|
-
unique_users
|
|
93
|
-
) AS users,
|
|
94
|
-
(
|
|
95
|
-
SELECT
|
|
96
|
-
JSON_AGG(ROW_TO_JSON(s))
|
|
97
|
-
FROM
|
|
98
|
-
sdk_versions_array s
|
|
99
|
-
) AS sdks;
|
|
100
|
-
`
|
|
101
|
-
.decoded(SdkReporting)
|
|
102
|
-
.first();
|
|
103
|
-
}
|
|
104
|
-
const endDate = data.range?.end ? new Date(data.range.end) : new Date();
|
|
105
|
-
const startDate = new Date(range.start);
|
|
106
|
-
const lt = endDate.toISOString();
|
|
107
|
-
const gt = startDate.toISOString();
|
|
59
|
+
private async listConnectionsQuery() {
|
|
108
60
|
return await this.db.sql`
|
|
109
61
|
WITH
|
|
110
62
|
filtered AS (
|
|
@@ -114,9 +66,7 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
114
66
|
connection_report_events
|
|
115
67
|
WHERE
|
|
116
68
|
disconnected_at IS NULL
|
|
117
|
-
AND jwt_exp > NOW()
|
|
118
|
-
AND connected_at >= ${{ type: 1184, value: gt }}
|
|
119
|
-
AND connected_at <= ${{ type: 1184, value: lt }}
|
|
69
|
+
AND jwt_exp > NOW() AT TIME ZONE 'UTC'
|
|
120
70
|
),
|
|
121
71
|
unique_users AS (
|
|
122
72
|
SELECT
|
|
@@ -164,7 +114,7 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
164
114
|
async reportClientConnection(data: event_types.ClientConnectionBucketData): Promise<void> {
|
|
165
115
|
const { sdk, connected_at, user_id, user_agent, jwt_exp, client_id } = data;
|
|
166
116
|
const connectIsoString = connected_at.toISOString();
|
|
167
|
-
const jwtExpIsoString = jwt_exp
|
|
117
|
+
const jwtExpIsoString = jwt_exp.toISOString();
|
|
168
118
|
const { gte, lt } = this.updateTableFilter();
|
|
169
119
|
const uuid = v4();
|
|
170
120
|
const result = await this.db.sql`
|
|
@@ -221,14 +171,14 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
221
171
|
AND connected_at = ${{ type: 1184, value: connectIsoString }}
|
|
222
172
|
`.execute();
|
|
223
173
|
}
|
|
224
|
-
async getConnectedClients(
|
|
225
|
-
const result = await this.listConnectionsQuery(
|
|
174
|
+
async getConnectedClients(): Promise<event_types.ClientConnectionReportResponse> {
|
|
175
|
+
const result = await this.listConnectionsQuery();
|
|
226
176
|
return this.mapListCurrentConnectionsResponse(result);
|
|
227
177
|
}
|
|
228
178
|
|
|
229
179
|
async getClientConnectionReports(
|
|
230
180
|
data: event_types.ClientConnectionReportRequest
|
|
231
|
-
): Promise<event_types.
|
|
181
|
+
): Promise<event_types.ClientConnectionReportResponse> {
|
|
232
182
|
const { start, end } = data;
|
|
233
183
|
const result = await this.db.sql`
|
|
234
184
|
WITH
|
|
@@ -284,7 +234,7 @@ export class PostgresReportStorageFactory implements storage.ReportStorage {
|
|
|
284
234
|
AND (
|
|
285
235
|
disconnected_at IS NOT NULL
|
|
286
236
|
OR (
|
|
287
|
-
jwt_exp < NOW()
|
|
237
|
+
jwt_exp < NOW() AT TIME ZONE 'UTC'
|
|
288
238
|
AND disconnected_at IS NULL
|
|
289
239
|
)
|
|
290
240
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { framework, PowerSyncMigrationManager, ServiceContext, TestStorageOptions } from '@powersync/service-core';
|
|
2
2
|
import { PostgresMigrationAgent } from '../migrations/PostgresMigrationAgent.js';
|
|
3
3
|
import { normalizePostgresStorageConfig, PostgresStorageConfigDecoded } from '../types/types.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { PostgresReportStorageFactory } from '../storage/PostgresReportStorageFactory.js';
|
|
5
|
+
import { PostgresBucketStorageFactory } from '../storage/PostgresBucketStorageFactory.js';
|
|
6
6
|
|
|
7
7
|
export type PostgresTestStorageOptions = {
|
|
8
8
|
url: string;
|
|
@@ -13,7 +13,7 @@ export type PostgresTestStorageOptions = {
|
|
|
13
13
|
migrationAgent?: (config: PostgresStorageConfigDecoded) => PostgresMigrationAgent;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export function postgresTestSetup(factoryOptions: PostgresTestStorageOptions) {
|
|
17
17
|
const BASE_CONFIG = {
|
|
18
18
|
type: 'postgresql' as const,
|
|
19
19
|
uri: factoryOptions.url,
|
|
@@ -82,8 +82,8 @@ export const postgresTestSetup = (factoryOptions: PostgresTestStorageOptions) =>
|
|
|
82
82
|
},
|
|
83
83
|
migrate
|
|
84
84
|
};
|
|
85
|
-
}
|
|
85
|
+
}
|
|
86
86
|
|
|
87
|
-
export
|
|
87
|
+
export function postgresTestStorageFactoryGenerator(factoryOptions: PostgresTestStorageOptions) {
|
|
88
88
|
return postgresTestSetup(factoryOptions).factory;
|
|
89
|
-
}
|
|
89
|
+
}
|
package/src/utils/utils-index.ts
CHANGED
|
@@ -17,23 +17,6 @@ exports[`Connection report storage > Should create a connection event if its aft
|
|
|
17
17
|
]
|
|
18
18
|
`;
|
|
19
19
|
|
|
20
|
-
exports[`Connection report storage > Should create a sdk event if its after a day 1`] = `
|
|
21
|
-
[
|
|
22
|
-
{
|
|
23
|
-
"client_id": "client_week",
|
|
24
|
-
"sdk": "powersync-js/1.24.5",
|
|
25
|
-
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
26
|
-
"user_id": "user_week",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"client_id": "client_week",
|
|
30
|
-
"sdk": "powersync-js/1.24.5",
|
|
31
|
-
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
32
|
-
"user_id": "user_week",
|
|
33
|
-
},
|
|
34
|
-
]
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
20
|
exports[`Connection report storage > Should delete rows older than specified range 1`] = `
|
|
38
21
|
{
|
|
39
22
|
"sdks": [
|
|
@@ -62,38 +45,39 @@ exports[`Connection report storage > Should delete rows older than specified ran
|
|
|
62
45
|
"sdk": "powersync-js/1.24.5",
|
|
63
46
|
"users": 1,
|
|
64
47
|
},
|
|
65
|
-
],
|
|
66
|
-
"users": 5,
|
|
67
|
-
}
|
|
68
|
-
`;
|
|
69
|
-
|
|
70
|
-
exports[`Connection report storage > Should show connected users with start range 1`] = `
|
|
71
|
-
{
|
|
72
|
-
"sdks": [
|
|
73
48
|
{
|
|
74
49
|
"clients": 1,
|
|
75
|
-
"sdk": "
|
|
50
|
+
"sdk": "unknown",
|
|
76
51
|
"users": 1,
|
|
77
52
|
},
|
|
78
53
|
],
|
|
79
|
-
"users":
|
|
54
|
+
"users": 5,
|
|
80
55
|
}
|
|
81
56
|
`;
|
|
82
57
|
|
|
83
|
-
exports[`Connection report storage > Should
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"users": 1,
|
|
93
|
-
}
|
|
58
|
+
exports[`Connection report storage > Should update a connection event and make it disconnected 1`] = `
|
|
59
|
+
[
|
|
60
|
+
{
|
|
61
|
+
"client_id": "client_three",
|
|
62
|
+
"sdk": "powersync-js/1.21.2",
|
|
63
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
64
|
+
"user_id": "user_three",
|
|
65
|
+
},
|
|
66
|
+
]
|
|
94
67
|
`;
|
|
95
68
|
|
|
96
|
-
exports[`Connection report storage > Should
|
|
69
|
+
exports[`Connection report storage > Should update a connection event if its within a day 1`] = `
|
|
70
|
+
[
|
|
71
|
+
{
|
|
72
|
+
"client_id": "client_one",
|
|
73
|
+
"sdk": "powersync-dart/1.6.4",
|
|
74
|
+
"user_agent": "powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android",
|
|
75
|
+
"user_id": "user_one",
|
|
76
|
+
},
|
|
77
|
+
]
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
exports[`Report storage tests > Should show connection report data for user over the past day 1`] = `
|
|
97
81
|
{
|
|
98
82
|
"sdks": [
|
|
99
83
|
{
|
|
@@ -111,12 +95,17 @@ exports[`Connection report storage > Should show connection report data for user
|
|
|
111
95
|
"sdk": "powersync-js/1.21.4",
|
|
112
96
|
"users": 1,
|
|
113
97
|
},
|
|
98
|
+
{
|
|
99
|
+
"clients": 1,
|
|
100
|
+
"sdk": "unknown",
|
|
101
|
+
"users": 1,
|
|
102
|
+
},
|
|
114
103
|
],
|
|
115
104
|
"users": 3,
|
|
116
105
|
}
|
|
117
106
|
`;
|
|
118
107
|
|
|
119
|
-
exports[`
|
|
108
|
+
exports[`Report storage tests > Should show connection report data for user over the past month 1`] = `
|
|
120
109
|
{
|
|
121
110
|
"sdks": [
|
|
122
111
|
{
|
|
@@ -154,12 +143,17 @@ exports[`Connection report storage > Should show connection report data for user
|
|
|
154
143
|
"sdk": "powersync-js/1.24.5",
|
|
155
144
|
"users": 1,
|
|
156
145
|
},
|
|
146
|
+
{
|
|
147
|
+
"clients": 1,
|
|
148
|
+
"sdk": "unknown",
|
|
149
|
+
"users": 1,
|
|
150
|
+
},
|
|
157
151
|
],
|
|
158
152
|
"users": 7,
|
|
159
153
|
}
|
|
160
154
|
`;
|
|
161
155
|
|
|
162
|
-
exports[`
|
|
156
|
+
exports[`Report storage tests > Should show connection report data for user over the past week 1`] = `
|
|
163
157
|
{
|
|
164
158
|
"sdks": [
|
|
165
159
|
{
|
|
@@ -187,51 +181,35 @@ exports[`Connection report storage > Should show connection report data for user
|
|
|
187
181
|
"sdk": "powersync-js/1.24.5",
|
|
188
182
|
"users": 1,
|
|
189
183
|
},
|
|
184
|
+
{
|
|
185
|
+
"clients": 1,
|
|
186
|
+
"sdk": "unknown",
|
|
187
|
+
"users": 1,
|
|
188
|
+
},
|
|
190
189
|
],
|
|
191
190
|
"users": 5,
|
|
192
191
|
}
|
|
193
192
|
`;
|
|
194
193
|
|
|
195
|
-
exports[`
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
exports[`Connection report storage > Should update a connection event if its within a day 1`] = `
|
|
218
|
-
[
|
|
219
|
-
{
|
|
220
|
-
"client_id": "client_one",
|
|
221
|
-
"sdk": "powersync-dart/1.6.4",
|
|
222
|
-
"user_agent": "powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android",
|
|
223
|
-
"user_id": "user_one",
|
|
224
|
-
},
|
|
225
|
-
]
|
|
226
|
-
`;
|
|
227
|
-
|
|
228
|
-
exports[`Connection report storage > Should update a sdk event if its within a day 1`] = `
|
|
229
|
-
[
|
|
230
|
-
{
|
|
231
|
-
"client_id": "client_one",
|
|
232
|
-
"sdk": "powersync-dart/1.6.4",
|
|
233
|
-
"user_agent": "powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android",
|
|
234
|
-
"user_id": "user_one",
|
|
235
|
-
},
|
|
236
|
-
]
|
|
194
|
+
exports[`Report storage tests > Should show currently connected users 1`] = `
|
|
195
|
+
{
|
|
196
|
+
"sdks": [
|
|
197
|
+
{
|
|
198
|
+
"clients": 1,
|
|
199
|
+
"sdk": "powersync-dart/1.6.4",
|
|
200
|
+
"users": 1,
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"clients": 1,
|
|
204
|
+
"sdk": "powersync-js/1.21.1",
|
|
205
|
+
"users": 1,
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"clients": 1,
|
|
209
|
+
"sdk": "unknown",
|
|
210
|
+
"users": 1,
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
"users": 2,
|
|
214
|
+
}
|
|
237
215
|
`;
|