@routr/pgdata 2.18.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.
@@ -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: (_a = this.agent.privacy) !== null && _a !== void 0 ? _a : 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 });
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;
@@ -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: (_a = this.domain.egressPolicies) === null || _a === void 0 ? void 0 : _a.map((policy) => ({
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)
@@ -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;
@@ -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
- return Object.assign(Object.assign({}, this.trunk), { apiVersion: "v2", accessControlListRef: this.trunk.accessControlListRef || null, inboundCredentialsRef: this.trunk.inboundCredentialsRef || null, outboundCredentialsRef: this.trunk.outboundCredentialsRef || null, uris: {
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
  }
@@ -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">;
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/pgdata",
3
- "version": "2.18.0",
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.17.0",
28
- "@routr/processor": "^2.18.0",
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": "53d48803760e0d8d6af1efa63db2414594d79454"
54
+ "gitHead": "357116800e150d8bbfbd0ad2406689c5793675b1"
55
55
  }