@routr/pgdata 2.17.0 → 2.19.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/dist/mappers/agent.js +4 -3
- package/dist/mappers/domain.js +5 -4
- package/dist/mappers/peer.js +4 -2
- package/dist/mappers/trunk.js +4 -2
- package/dist/mappers/utils.d.ts +20 -0
- package/dist/mappers/utils.js +37 -0
- package/dist/service.js +10 -12
- package/package.json +4 -4
package/dist/mappers/agent.js
CHANGED
|
@@ -26,6 +26,7 @@ const credentials_1 = require("./credentials");
|
|
|
26
26
|
const domain_1 = require("./domain");
|
|
27
27
|
const number_1 = require("./number");
|
|
28
28
|
const manager_1 = require("./manager");
|
|
29
|
+
const utils_1 = require("./utils");
|
|
29
30
|
// Needs testing
|
|
30
31
|
class AgentManager extends manager_1.EntityManager {
|
|
31
32
|
constructor(agent) {
|
|
@@ -62,12 +63,12 @@ class AgentManager extends manager_1.EntityManager {
|
|
|
62
63
|
common_1.CommonConnect.isValidNameOrThrow(this.agent.name);
|
|
63
64
|
}
|
|
64
65
|
mapToPrisma() {
|
|
65
|
-
var _a;
|
|
66
|
-
return Object.assign(Object.assign({}, this.agent), { apiVersion: "v2", privacy: (
|
|
66
|
+
var _a, _b, _c;
|
|
67
|
+
return Object.assign(Object.assign({}, (0, utils_1.withoutTrace)(this.agent)), { traceEnabled: (_b = (_a = this.agent.trace) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false, apiVersion: "v2", privacy: (_c = this.agent.privacy) !== null && _c !== void 0 ? _c : client_1.Privacy.NONE, domainRef: this.agent.domainRef || null, credentialsRef: this.agent.credentialsRef || null, expires: this.agent.expires || 0, createdAt: undefined, updatedAt: undefined, extended: this.agent.extended });
|
|
67
68
|
}
|
|
68
69
|
static mapToDto(agent) {
|
|
69
70
|
return agent
|
|
70
|
-
? Object.assign(Object.assign({}, agent), { apiVersion: agent.apiVersion, privacy: agent.privacy, domain: domain_1.DomainManager.mapToDto(agent.domain), credentials: credentials_1.CredentialsManager.mapToDto(agent.credentials), createdAt: agent.createdAt.getTime() / 1000, updatedAt: agent.updatedAt.getTime() / 1000, extended: agent.extended }) : undefined;
|
|
71
|
+
? Object.assign(Object.assign({}, (0, utils_1.withoutTraceEnabled)(agent)), { trace: { enabled: agent.traceEnabled }, apiVersion: agent.apiVersion, privacy: agent.privacy, domain: domain_1.DomainManager.mapToDto(agent.domain), credentials: credentials_1.CredentialsManager.mapToDto(agent.credentials), createdAt: agent.createdAt.getTime() / 1000, updatedAt: agent.updatedAt.getTime() / 1000, extended: agent.extended }) : undefined;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
exports.AgentManager = AgentManager;
|
package/dist/mappers/domain.js
CHANGED
|
@@ -5,6 +5,7 @@ const common_1 = require("@routr/common");
|
|
|
5
5
|
const acl_1 = require("./acl");
|
|
6
6
|
const manager_1 = require("./manager");
|
|
7
7
|
const number_1 = require("./number");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
8
9
|
// Needs testing
|
|
9
10
|
class DomainManager extends manager_1.EntityManager {
|
|
10
11
|
constructor(domain) {
|
|
@@ -33,9 +34,9 @@ class DomainManager extends manager_1.EntityManager {
|
|
|
33
34
|
common_1.CommonConnect.isValidNameOrThrow(this.domain.name);
|
|
34
35
|
}
|
|
35
36
|
mapToPrisma() {
|
|
36
|
-
var _a;
|
|
37
|
-
return Object.assign(Object.assign({}, this.domain), { apiVersion: "v2", accessControlListRef: this.domain.accessControlListRef || null, extended: this.domain.extended, egressPolicies: {
|
|
38
|
-
create: (
|
|
37
|
+
var _a, _b, _c;
|
|
38
|
+
return Object.assign(Object.assign({}, (0, utils_1.withoutTrace)(this.domain)), { traceEnabled: (_b = (_a = this.domain.trace) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false, apiVersion: "v2", accessControlListRef: this.domain.accessControlListRef || null, extended: this.domain.extended, egressPolicies: {
|
|
39
|
+
create: (_c = this.domain.egressPolicies) === null || _c === void 0 ? void 0 : _c.map((policy) => ({
|
|
39
40
|
rule: policy.rule,
|
|
40
41
|
numberRef: policy.numberRef
|
|
41
42
|
}))
|
|
@@ -44,7 +45,7 @@ class DomainManager extends manager_1.EntityManager {
|
|
|
44
45
|
static mapToDto(domain) {
|
|
45
46
|
var _a, _b;
|
|
46
47
|
return domain
|
|
47
|
-
? Object.assign(Object.assign({}, domain), { apiVersion: domain.apiVersion, accessControlListRef: (_a = domain.accessControlList) === null || _a === void 0 ? void 0 : _a.ref, accessControlList: acl_1.ACLManager.mapToDto(domain.accessControlList), egressPolicies: (_b = domain.egressPolicies) === null || _b === void 0 ? void 0 : _b.map((policy) => ({
|
|
48
|
+
? Object.assign(Object.assign({}, (0, utils_1.withoutTraceEnabled)(domain)), { trace: { enabled: domain.traceEnabled }, apiVersion: domain.apiVersion, accessControlListRef: (_a = domain.accessControlList) === null || _a === void 0 ? void 0 : _a.ref, accessControlList: acl_1.ACLManager.mapToDto(domain.accessControlList), egressPolicies: (_b = domain.egressPolicies) === null || _b === void 0 ? void 0 : _b.map((policy) => ({
|
|
48
49
|
rule: policy.rule,
|
|
49
50
|
numberRef: policy.numberRef,
|
|
50
51
|
number: number_1.NumberManager.mapToDtoWithoutTrunk(policy.number)
|
package/dist/mappers/peer.js
CHANGED
|
@@ -5,6 +5,7 @@ const common_1 = require("@routr/common");
|
|
|
5
5
|
const acl_1 = require("./acl");
|
|
6
6
|
const credentials_1 = require("./credentials");
|
|
7
7
|
const manager_1 = require("./manager");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
8
9
|
// Needs testing
|
|
9
10
|
class PeerManager extends manager_1.EntityManager {
|
|
10
11
|
constructor(peer) {
|
|
@@ -36,14 +37,15 @@ class PeerManager extends manager_1.EntityManager {
|
|
|
36
37
|
common_1.CommonConnect.isValidContactAddressOrThrow(this.peer.contactAddr);
|
|
37
38
|
}
|
|
38
39
|
mapToPrisma() {
|
|
40
|
+
var _a, _b;
|
|
39
41
|
const normalizeAlgorithm = (algorithm) => algorithm === common_1.CommonTypes.LoadBalancingAlgorithm.UNSPECIFIED
|
|
40
42
|
? undefined
|
|
41
43
|
: algorithm;
|
|
42
|
-
return Object.assign(Object.assign({}, this.peer), { apiVersion: "v2", balancingAlgorithm: normalizeAlgorithm(this.peer.balancingAlgorithm), withSessionAffinity: this.peer.withSessionAffinity, credentialsRef: this.peer.credentialsRef || null, accessControlListRef: this.peer.accessControlListRef || null, expires: this.peer.expires || 0, createdAt: undefined, updatedAt: undefined, extended: this.peer.extended });
|
|
44
|
+
return Object.assign(Object.assign({}, (0, utils_1.withoutTrace)(this.peer)), { traceEnabled: (_b = (_a = this.peer.trace) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false, apiVersion: "v2", balancingAlgorithm: normalizeAlgorithm(this.peer.balancingAlgorithm), withSessionAffinity: this.peer.withSessionAffinity, credentialsRef: this.peer.credentialsRef || null, accessControlListRef: this.peer.accessControlListRef || null, expires: this.peer.expires || 0, createdAt: undefined, updatedAt: undefined, extended: this.peer.extended });
|
|
43
45
|
}
|
|
44
46
|
static mapToDto(peer) {
|
|
45
47
|
return peer
|
|
46
|
-
? Object.assign(Object.assign({}, peer), { apiVersion: peer.apiVersion, balancingAlgorithm: peer.balancingAlgorithm, credentials: credentials_1.CredentialsManager.mapToDto(peer.credentials), accessControlList: acl_1.ACLManager.mapToDto(peer.accessControlList), createdAt: peer.createdAt.getTime() / 1000, updatedAt: peer.updatedAt.getTime() / 1000, extended: peer.extended }) : undefined;
|
|
48
|
+
? Object.assign(Object.assign({}, (0, utils_1.withoutTraceEnabled)(peer)), { trace: { enabled: peer.traceEnabled }, apiVersion: peer.apiVersion, balancingAlgorithm: peer.balancingAlgorithm, credentials: credentials_1.CredentialsManager.mapToDto(peer.credentials), accessControlList: acl_1.ACLManager.mapToDto(peer.accessControlList), createdAt: peer.createdAt.getTime() / 1000, updatedAt: peer.updatedAt.getTime() / 1000, extended: peer.extended }) : undefined;
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
exports.PeerManager = PeerManager;
|
package/dist/mappers/trunk.js
CHANGED
|
@@ -5,6 +5,7 @@ const common_1 = require("@routr/common");
|
|
|
5
5
|
const acl_1 = require("./acl");
|
|
6
6
|
const credentials_1 = require("./credentials");
|
|
7
7
|
const manager_1 = require("./manager");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
8
9
|
// Needs testing
|
|
9
10
|
class TrunkManager extends manager_1.EntityManager {
|
|
10
11
|
constructor(trunk) {
|
|
@@ -34,14 +35,15 @@ class TrunkManager extends manager_1.EntityManager {
|
|
|
34
35
|
common_1.CommonConnect.isValidInboundUriOrThrow(this.trunk.inboundUri);
|
|
35
36
|
}
|
|
36
37
|
mapToPrisma() {
|
|
37
|
-
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return Object.assign(Object.assign({}, (0, utils_1.withoutTrace)(this.trunk)), { traceEnabled: (_b = (_a = this.trunk.trace) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false, apiVersion: "v2", accessControlListRef: this.trunk.accessControlListRef || null, inboundCredentialsRef: this.trunk.inboundCredentialsRef || null, outboundCredentialsRef: this.trunk.outboundCredentialsRef || null, uris: {
|
|
38
40
|
create: this.trunk.uris
|
|
39
41
|
}, extended: this.trunk.extended, createdAt: undefined, updatedAt: undefined });
|
|
40
42
|
}
|
|
41
43
|
static mapToDto(trunk) {
|
|
42
44
|
var _a, _b, _c;
|
|
43
45
|
return trunk
|
|
44
|
-
? Object.assign(Object.assign({}, trunk), { apiVersion: trunk.apiVersion, accessControlListRef: (_a = trunk.accessControlList) === null || _a === void 0 ? void 0 : _a.ref, inboundCredentialsRef: (_b = trunk.inboundCredentials) === null || _b === void 0 ? void 0 : _b.ref, outboundCredentialsRef: (_c = trunk.outboundCredentials) === null || _c === void 0 ? void 0 : _c.ref, inboundCredentials: credentials_1.CredentialsManager.mapToDto(trunk.inboundCredentials), accessControlList: acl_1.ACLManager.mapToDto(trunk.accessControlList), outboundCredentials: credentials_1.CredentialsManager.mapToDto(trunk.outboundCredentials), uris: trunk.uris.map((uri) => {
|
|
46
|
+
? Object.assign(Object.assign({}, (0, utils_1.withoutTraceEnabled)(trunk)), { trace: { enabled: trunk.traceEnabled }, apiVersion: trunk.apiVersion, accessControlListRef: (_a = trunk.accessControlList) === null || _a === void 0 ? void 0 : _a.ref, inboundCredentialsRef: (_b = trunk.inboundCredentials) === null || _b === void 0 ? void 0 : _b.ref, outboundCredentialsRef: (_c = trunk.outboundCredentials) === null || _c === void 0 ? void 0 : _c.ref, inboundCredentials: credentials_1.CredentialsManager.mapToDto(trunk.inboundCredentials), accessControlList: acl_1.ACLManager.mapToDto(trunk.accessControlList), outboundCredentials: credentials_1.CredentialsManager.mapToDto(trunk.outboundCredentials), uris: trunk.uris.map((uri) => {
|
|
45
47
|
return Object.assign(Object.assign({}, uri), { transport: uri.transport.toUpperCase() });
|
|
46
48
|
}), createdAt: trunk.createdAt.getTime() / 1000, updatedAt: trunk.updatedAt.getTime() / 1000, extended: trunk.extended }) : undefined;
|
|
47
49
|
}
|
package/dist/mappers/utils.d.ts
CHANGED
|
@@ -7,3 +7,23 @@ import { NumberManager } from "./number";
|
|
|
7
7
|
import { PeerManager } from "./peer";
|
|
8
8
|
import { TrunkManager } from "./trunk";
|
|
9
9
|
export declare function getManager(kind: CC.KindWithoutUnknown): typeof ACLManager | typeof CredentialsManager | typeof TrunkManager | typeof NumberManager | typeof DomainManager | typeof AgentManager | typeof PeerManager;
|
|
10
|
+
/**
|
|
11
|
+
* Drops the API-level `trace` object before handing a resource to Prisma,
|
|
12
|
+
* which stores it as the trace_enabled column.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} resource - A resource with an optional trace object
|
|
15
|
+
* @return {object} The same resource without it
|
|
16
|
+
*/
|
|
17
|
+
export declare function withoutTrace<T extends {
|
|
18
|
+
trace?: unknown;
|
|
19
|
+
}>(resource: T): Omit<T, "trace">;
|
|
20
|
+
/**
|
|
21
|
+
* Drops Prisma's trace_enabled column from a row before it becomes a DTO,
|
|
22
|
+
* where the setting is the `trace` object.
|
|
23
|
+
*
|
|
24
|
+
* @param {object} row - A Prisma row
|
|
25
|
+
* @return {object} The row without traceEnabled
|
|
26
|
+
*/
|
|
27
|
+
export declare function withoutTraceEnabled<T extends {
|
|
28
|
+
traceEnabled?: unknown;
|
|
29
|
+
}>(row: T): Omit<T, "traceEnabled">;
|
package/dist/mappers/utils.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.getManager = getManager;
|
|
15
|
+
exports.withoutTrace = withoutTrace;
|
|
16
|
+
exports.withoutTraceEnabled = withoutTraceEnabled;
|
|
4
17
|
/*
|
|
5
18
|
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
6
19
|
* http://github.com/fonoster/routr
|
|
@@ -46,3 +59,27 @@ function getManager(kind) {
|
|
|
46
59
|
return domain_1.DomainManager;
|
|
47
60
|
}
|
|
48
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Drops the API-level `trace` object before handing a resource to Prisma,
|
|
64
|
+
* which stores it as the trace_enabled column.
|
|
65
|
+
*
|
|
66
|
+
* @param {object} resource - A resource with an optional trace object
|
|
67
|
+
* @return {object} The same resource without it
|
|
68
|
+
*/
|
|
69
|
+
function withoutTrace(resource) {
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
+
const { trace } = resource, rest = __rest(resource, ["trace"]);
|
|
72
|
+
return rest;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Drops Prisma's trace_enabled column from a row before it becomes a DTO,
|
|
76
|
+
* where the setting is the `trace` object.
|
|
77
|
+
*
|
|
78
|
+
* @param {object} row - A Prisma row
|
|
79
|
+
* @return {object} The row without traceEnabled
|
|
80
|
+
*/
|
|
81
|
+
function withoutTraceEnabled(row) {
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
83
|
+
const { traceEnabled } = row, rest = __rest(row, ["traceEnabled"]);
|
|
84
|
+
return rest;
|
|
85
|
+
}
|
package/dist/service.js
CHANGED
|
@@ -109,6 +109,13 @@ function pgDataService(config) {
|
|
|
109
109
|
internalServer.bindAsync(config.bindAddr, credentials, () => {
|
|
110
110
|
logger.info("internal server started", { bindAddr: config.bindAddr });
|
|
111
111
|
});
|
|
112
|
+
// Report SERVING once the external server is up, with or without TLS
|
|
113
|
+
const onExternalServerStarted = () => {
|
|
114
|
+
healthImpl.setStatus("", common_1.GRPC_SERVING_STATUS);
|
|
115
|
+
logger.info("external server started", {
|
|
116
|
+
externalServerBindAddr: config.externalServerBindAddr
|
|
117
|
+
});
|
|
118
|
+
};
|
|
112
119
|
if (envs_1.TLS_ON) {
|
|
113
120
|
const cacert = envs_1.VERIFY_CLIENT_CERT ? fs_1.default.readFileSync(envs_1.CACERT) : null;
|
|
114
121
|
const cert = fs_1.default.readFileSync(envs_1.SERVER_CERT);
|
|
@@ -121,19 +128,10 @@ function pgDataService(config) {
|
|
|
121
128
|
private_key: key
|
|
122
129
|
}
|
|
123
130
|
], envs_1.VERIFY_CLIENT_CERT);
|
|
124
|
-
externalServer.bindAsync(config.externalServerBindAddr, externalCredentials,
|
|
125
|
-
logger.info("external server started", {
|
|
126
|
-
externalServerBindAddr: config.externalServerBindAddr
|
|
127
|
-
});
|
|
128
|
-
});
|
|
131
|
+
externalServer.bindAsync(config.externalServerBindAddr, externalCredentials, onExternalServerStarted);
|
|
129
132
|
}
|
|
130
133
|
else {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
logger.info("secure connection disabled");
|
|
134
|
-
logger.info("external server started", {
|
|
135
|
-
externalServerBindAddr: config.externalServerBindAddr
|
|
136
|
-
});
|
|
137
|
-
});
|
|
134
|
+
logger.info("secure connection disabled");
|
|
135
|
+
externalServer.bindAsync(config.externalServerBindAddr, credentials, onExternalServerStarted);
|
|
138
136
|
}
|
|
139
137
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/pgdata",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"description": "Postgres API Server for Routr Connect",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"@fonoster/logger": "0.6.0",
|
|
25
25
|
"@grpc/grpc-js": "~1.14.6",
|
|
26
26
|
"@prisma/client": "^6.19.1",
|
|
27
|
-
"@routr/common": "^2.
|
|
28
|
-
"@routr/processor": "^2.
|
|
27
|
+
"@routr/common": "^2.19.0",
|
|
28
|
+
"@routr/processor": "^2.19.0",
|
|
29
29
|
"google-protobuf": "^3.21.4",
|
|
30
30
|
"grpc-health-check": "^2.1.0",
|
|
31
31
|
"pb-util": "^1.0.3",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"@types/validator": "^13.15.10",
|
|
52
52
|
"prisma": "^6.19.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "357116800e150d8bbfbd0ad2406689c5793675b1"
|
|
55
55
|
}
|