proto.io 0.0.208 → 0.0.210
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/dist/adapters/file/aliyun-oss.d.ts +6 -6
- package/dist/adapters/file/aliyun-oss.js +14 -13
- package/dist/adapters/file/aliyun-oss.js.map +1 -1
- package/dist/adapters/file/aliyun-oss.mjs +14 -13
- package/dist/adapters/file/aliyun-oss.mjs.map +1 -1
- package/dist/adapters/file/database.d.ts +3 -3
- package/dist/adapters/file/database.js +2 -2
- package/dist/adapters/file/database.js.map +1 -1
- package/dist/adapters/file/database.mjs +2 -2
- package/dist/adapters/file/database.mjs.map +1 -1
- package/dist/adapters/file/filesystem.d.ts +5 -5
- package/dist/adapters/file/filesystem.js +11 -7
- package/dist/adapters/file/filesystem.js.map +1 -1
- package/dist/adapters/file/filesystem.mjs +11 -7
- package/dist/adapters/file/filesystem.mjs.map +1 -1
- package/dist/adapters/file/google-cloud-storage.d.ts +6 -6
- package/dist/adapters/file/google-cloud-storage.js +23 -13
- package/dist/adapters/file/google-cloud-storage.js.map +1 -1
- package/dist/adapters/file/google-cloud-storage.mjs +23 -13
- package/dist/adapters/file/google-cloud-storage.mjs.map +1 -1
- package/dist/adapters/storage/progres.d.ts +1 -1
- package/dist/adapters/storage/progres.js +22 -28
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +22 -28
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +2 -1
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +3 -2
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +159 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -24
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-wSknxBv7.d.ts → base-C1ndp06_.d.ts} +2 -2
- package/dist/internals/base-C1ndp06_.d.ts.map +1 -0
- package/dist/internals/{base-CfQi0T0I.mjs → base-DYc1_peK.mjs} +3 -3
- package/dist/internals/{base-CfQi0T0I.mjs.map → base-DYc1_peK.mjs.map} +1 -1
- package/dist/internals/{base-BFKQpiws.js → base-NsJYo2MG.js} +3 -3
- package/dist/internals/{base-BFKQpiws.js.map → base-NsJYo2MG.js.map} +1 -1
- package/dist/internals/{chunk-BuMQw4dz.js → chunk-BuKmyceG.js} +5 -3
- package/dist/internals/chunk-BuKmyceG.js.map +1 -0
- package/dist/internals/{chunk-C_BXf1Er.d.ts → chunk-DF4KyvgB.d.ts} +6 -6
- package/dist/internals/chunk-DF4KyvgB.d.ts.map +1 -0
- package/dist/internals/{chunk-DxYhYVky.mjs → chunk-bpt1C6W4.mjs} +5 -3
- package/dist/internals/chunk-bpt1C6W4.mjs.map +1 -0
- package/dist/internals/const-C3I6cfav.js +42 -0
- package/dist/internals/const-C3I6cfav.js.map +1 -0
- package/dist/internals/const-Dkp7Nsv5.mjs +34 -0
- package/dist/internals/const-Dkp7Nsv5.mjs.map +1 -0
- package/dist/internals/index-B8TESzd9.js.map +1 -1
- package/dist/internals/{index-BvwYz4Yp.mjs → index-BgSBzm-K.mjs} +95 -20
- package/dist/internals/index-BgSBzm-K.mjs.map +1 -0
- package/dist/internals/{index-DVUiXLfI.js → index-Clo9hepf.js} +101 -29
- package/dist/internals/index-Clo9hepf.js.map +1 -0
- package/dist/internals/{index-CkAvNaAe.js → index-D8O7SinR.js} +50 -3
- package/dist/internals/index-D8O7SinR.js.map +1 -0
- package/dist/internals/{index-A-hoMfDO.d.ts → index-DIRjiWPh.d.ts} +32 -1
- package/dist/internals/index-DIRjiWPh.d.ts.map +1 -0
- package/dist/internals/{index-DlY33lfO.mjs → index-DPPLcZx8.mjs} +51 -4
- package/dist/internals/index-DPPLcZx8.mjs.map +1 -0
- package/dist/internals/index-al1N-qi7.mjs.map +1 -1
- package/dist/internals/{index-iqOd-Wdg.d.ts → index-l-Mk0lCc.d.ts} +2 -2
- package/dist/internals/index-l-Mk0lCc.d.ts.map +1 -0
- package/dist/internals/{random-B0V0EnjP.js → random-CyU_Y2Ay.js} +2 -2
- package/dist/internals/{random-B0V0EnjP.js.map → random-CyU_Y2Ay.js.map} +1 -1
- package/dist/internals/{random-ZgzzM5v_.mjs → random-ycCeBd0S.mjs} +2 -2
- package/dist/internals/{random-ZgzzM5v_.mjs.map → random-ycCeBd0S.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/internals/base-wSknxBv7.d.ts.map +0 -1
- package/dist/internals/chunk-BuMQw4dz.js.map +0 -1
- package/dist/internals/chunk-C_BXf1Er.d.ts.map +0 -1
- package/dist/internals/chunk-DxYhYVky.mjs.map +0 -1
- package/dist/internals/index-A-hoMfDO.d.ts.map +0 -1
- package/dist/internals/index-BvwYz4Yp.mjs.map +0 -1
- package/dist/internals/index-CkAvNaAe.js.map +0 -1
- package/dist/internals/index-DVUiXLfI.js.map +0 -1
- package/dist/internals/index-DlY33lfO.mjs.map +0 -1
- package/dist/internals/index-iqOd-Wdg.d.ts.map +0 -1
|
@@ -5,9 +5,10 @@ import QueryStream from 'pg-query-stream';
|
|
|
5
5
|
import { asyncStream, IteratorPool } from '@o2ter/utils-js';
|
|
6
6
|
import Decimal from 'decimal.js';
|
|
7
7
|
import { escapeLiteral, escapeIdentifier } from 'pg/lib/utils';
|
|
8
|
-
import { a as QueryCoditionalSelector, b as QueryFieldSelector, c as QueryExpressionSelector, d as QueryDistanceExpression, e as QueryCoditionalExpression, f as QueryComparisonExpression, g as QueryNotExpression, h as QueryArrayExpression, i as QueryValueExpression, j as QueryKeyExpression, Q as QuerySelector, F as FieldSelectorExpression } from '../../internals/index-
|
|
8
|
+
import { a as QueryCoditionalSelector, b as QueryFieldSelector, c as QueryExpressionSelector, d as QueryDistanceExpression, e as QueryCoditionalExpression, f as QueryComparisonExpression, g as QueryNotExpression, h as QueryArrayExpression, i as QueryValueExpression, j as QueryKeyExpression, Q as QuerySelector, F as FieldSelectorExpression } from '../../internals/index-DPPLcZx8.mjs';
|
|
9
9
|
import '@o2ter/crypto-js';
|
|
10
|
-
import { r as resolveColumn, a as resolveDataType$1, g as generateId, Q as QueryValidator } from '../../internals/random-
|
|
10
|
+
import { r as resolveColumn, a as resolveDataType$1, g as generateId, Q as QueryValidator } from '../../internals/random-ycCeBd0S.mjs';
|
|
11
|
+
import { c as PROTO_EVENT } from '../../internals/const-Dkp7Nsv5.mjs';
|
|
11
12
|
import { P as PVK } from '../../internals/private-CNw40LZ7.mjs';
|
|
12
13
|
|
|
13
14
|
//
|
|
@@ -1059,24 +1060,24 @@ class PostgresClientDriver {
|
|
|
1059
1060
|
}
|
|
1060
1061
|
async publish(channel, payload) {
|
|
1061
1062
|
await this.withClient(async (db) => {
|
|
1062
|
-
await db.query(`NOTIFY ${
|
|
1063
|
+
await db.query(`NOTIFY ${PROTO_EVENT}, ${quote(JSON.stringify(_encodeValue({ channel, payload })))}`);
|
|
1063
1064
|
});
|
|
1064
1065
|
}
|
|
1065
1066
|
}
|
|
1066
1067
|
class PostgresPubSub {
|
|
1067
1068
|
client;
|
|
1068
|
-
subscribers =
|
|
1069
|
-
channels = [];
|
|
1069
|
+
subscribers = [];
|
|
1070
1070
|
constructor(client) {
|
|
1071
1071
|
this.client = client;
|
|
1072
1072
|
(async () => {
|
|
1073
1073
|
try {
|
|
1074
|
-
|
|
1075
|
-
|
|
1074
|
+
client = await client;
|
|
1075
|
+
client.on('notification', ({ channel, payload }) => {
|
|
1076
|
+
if (_.toUpper(channel) !== PROTO_EVENT || !payload)
|
|
1076
1077
|
return;
|
|
1077
1078
|
try {
|
|
1078
1079
|
const _payload = _decodeValue(JSON.parse(payload));
|
|
1079
|
-
for (const subscriber of this.subscribers
|
|
1080
|
+
for (const subscriber of this.subscribers) {
|
|
1080
1081
|
subscriber(_payload);
|
|
1081
1082
|
}
|
|
1082
1083
|
}
|
|
@@ -1084,6 +1085,7 @@ class PostgresPubSub {
|
|
|
1084
1085
|
console.error(`Unknown payload: ${e}`);
|
|
1085
1086
|
}
|
|
1086
1087
|
});
|
|
1088
|
+
await client.query(`LISTEN ${PROTO_EVENT}`);
|
|
1087
1089
|
}
|
|
1088
1090
|
catch (e) {
|
|
1089
1091
|
console.error(e);
|
|
@@ -1093,20 +1095,14 @@ class PostgresPubSub {
|
|
|
1093
1095
|
async shutdown() {
|
|
1094
1096
|
(await this.client).release();
|
|
1095
1097
|
}
|
|
1096
|
-
|
|
1097
|
-
this.
|
|
1098
|
-
await (await this.client).query(`LISTEN ${channel}`);
|
|
1099
|
-
}
|
|
1100
|
-
subscribe(channel, callback) {
|
|
1101
|
-
if (_.isNil(this.subscribers[channel]))
|
|
1102
|
-
this.subscribers[channel] = [];
|
|
1103
|
-
this.subscribers[channel].push(callback);
|
|
1098
|
+
subscribe(callback) {
|
|
1099
|
+
this.subscribers.push(callback);
|
|
1104
1100
|
return () => {
|
|
1105
|
-
this.subscribers
|
|
1101
|
+
this.subscribers = this.subscribers.filter(x => x !== callback);
|
|
1106
1102
|
};
|
|
1107
1103
|
}
|
|
1108
1104
|
isEmpty() {
|
|
1109
|
-
return _.
|
|
1105
|
+
return _.isEmpty(this.subscribers);
|
|
1110
1106
|
}
|
|
1111
1107
|
}
|
|
1112
1108
|
class PostgresDriver extends PostgresClientDriver {
|
|
@@ -1125,14 +1121,9 @@ class PostgresDriver extends PostgresClientDriver {
|
|
|
1125
1121
|
await this.database.end();
|
|
1126
1122
|
}
|
|
1127
1123
|
_init_pubsub() {
|
|
1128
|
-
if (this.pubsub)
|
|
1124
|
+
if (this.pubsub || this.database.ending || this.database.ended)
|
|
1129
1125
|
return;
|
|
1130
|
-
|
|
1131
|
-
this.pubsub = new PostgresPubSub(this.database.connect());
|
|
1132
|
-
}
|
|
1133
|
-
catch (e) {
|
|
1134
|
-
console.error(e);
|
|
1135
|
-
}
|
|
1126
|
+
this.pubsub = new PostgresPubSub(this.database.connect());
|
|
1136
1127
|
}
|
|
1137
1128
|
async _release_pubsub() {
|
|
1138
1129
|
const pubsub = this.pubsub;
|
|
@@ -1141,9 +1132,12 @@ class PostgresDriver extends PostgresClientDriver {
|
|
|
1141
1132
|
}
|
|
1142
1133
|
subscribe(channel, callback) {
|
|
1143
1134
|
this._init_pubsub();
|
|
1144
|
-
if (!
|
|
1145
|
-
|
|
1146
|
-
const release = this.pubsub.subscribe(channel,
|
|
1135
|
+
if (!this.pubsub)
|
|
1136
|
+
return () => void 0;
|
|
1137
|
+
const release = this.pubsub.subscribe(({ channel: _channel, payload }) => {
|
|
1138
|
+
if (_channel === channel)
|
|
1139
|
+
callback(payload);
|
|
1140
|
+
});
|
|
1147
1141
|
return () => {
|
|
1148
1142
|
release();
|
|
1149
1143
|
if (this.pubsub?.isEmpty())
|