@routr/pgdata 2.12.1 → 2.13.1

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.
@@ -43,14 +43,14 @@ function update(operation, kind) {
43
43
  const Manager = (0, utils_1.getManager)(kind);
44
44
  const manager = new Manager(request);
45
45
  manager.validOrThrowUpdate();
46
- if (kind === common_1.CommonConnect.Kind.DOMAIN) {
46
+ if (kind === common_1.CommonConnect.Kind.DOMAIN && request.egressPolicy) {
47
47
  yield db_1.prisma.egressPolicy.deleteMany({
48
48
  where: {
49
49
  domainRef: request.ref
50
50
  }
51
51
  });
52
52
  }
53
- if (kind === common_1.CommonConnect.Kind.TRUNK) {
53
+ if (kind === common_1.CommonConnect.Kind.TRUNK && request.uris) {
54
54
  yield db_1.prisma.trunkURI.deleteMany({
55
55
  where: {
56
56
  trunkRef: request.ref
@@ -1,11 +1,10 @@
1
1
  import { AccessControlList as ACLPrismaModel } from "@prisma/client";
2
2
  import { CommonConnect as CC } from "@routr/common";
3
- import { JsonObject } from "pb-util/build";
4
3
  import { EntityManager } from "./manager";
5
4
  export declare class ACLManager extends EntityManager {
6
5
  private acl;
7
6
  constructor(acl: CC.AccessControlList);
8
- static includeFields(): JsonObject;
7
+ static includeFields(): Record<string, unknown>;
9
8
  validOrThrowCreate(): void;
10
9
  validOrThrowUpdate(): void;
11
10
  mapToPrisma(): ACLPrismaModel;
@@ -18,30 +18,16 @@ class ACLManager extends manager_1.EntityManager {
18
18
  common_1.CommonConnect.hasValidACLRulesOrThrow(this.acl);
19
19
  }
20
20
  validOrThrowUpdate() {
21
- common_1.CommonConnect.hasRefenceOrThrow(this.acl.ref);
21
+ common_1.CommonConnect.hasReferenceOrThrow(this.acl.ref);
22
22
  common_1.CommonConnect.isValidNameOrThrow(this.acl.name);
23
23
  common_1.CommonConnect.hasValidACLRulesOrThrow(this.acl);
24
24
  }
25
25
  mapToPrisma() {
26
- return {
27
- // TODO: Create a default value for apiVersion
28
- apiVersion: "v2",
29
- ref: this.acl.ref,
30
- name: this.acl.name,
31
- allow: this.acl.allow,
32
- deny: this.acl.deny,
33
- createdAt: this.acl.createdAt
34
- ? new Date(this.acl.createdAt * 1000)
35
- : undefined,
36
- updatedAt: this.acl.updatedAt
37
- ? new Date(this.acl.updatedAt * 1000)
38
- : undefined,
39
- extended: this.acl.extended || {}
40
- };
26
+ return Object.assign(Object.assign({}, this.acl), { apiVersion: "v2", createdAt: undefined, updatedAt: undefined, extended: this.acl.extended });
41
27
  }
42
28
  static mapToDto(acl) {
43
29
  return acl
44
- ? Object.assign(Object.assign({}, acl), { createdAt: acl.createdAt.getTime() / 1000, updatedAt: acl.updatedAt.getTime() / 1000, extended: acl.extended }) : undefined;
30
+ ? Object.assign(Object.assign({}, acl), { apiVersion: acl.apiVersion, createdAt: acl.createdAt.getTime() / 1000, updatedAt: acl.updatedAt.getTime() / 1000, extended: acl.extended }) : undefined;
45
31
  }
46
32
  }
47
33
  exports.ACLManager = ACLManager;
@@ -1,6 +1,5 @@
1
1
  import { Agent as AgentPrismaModel, Prisma } from "@prisma/client";
2
2
  import { CommonConnect as CC } from "@routr/common";
3
- import { JsonObject } from "pb-util/build";
4
3
  import { EntityManager } from "./manager";
5
4
  type AgentWithDomainAndCredentials = Prisma.AgentGetPayload<{
6
5
  include: {
@@ -20,7 +19,7 @@ type AgentWithDomainAndCredentials = Prisma.AgentGetPayload<{
20
19
  export declare class AgentManager extends EntityManager {
21
20
  private agent;
22
21
  constructor(agent: CC.Agent);
23
- static includeFields(): JsonObject;
22
+ static includeFields(): Record<string, unknown>;
24
23
  validOrThrowCreate(): void;
25
24
  validOrThrowUpdate(): void;
26
25
  mapToPrisma(): AgentPrismaModel;
@@ -48,52 +48,16 @@ class AgentManager extends manager_1.EntityManager {
48
48
  common_1.CommonConnect.isValidUsernameOrThrow(this.agent.username);
49
49
  }
50
50
  validOrThrowUpdate() {
51
- common_1.CommonConnect.hasRefenceOrThrow(this.agent.ref);
51
+ common_1.CommonConnect.hasReferenceOrThrow(this.agent.ref);
52
52
  common_1.CommonConnect.isValidNameOrThrow(this.agent.name);
53
53
  }
54
54
  mapToPrisma() {
55
55
  var _a;
56
- return {
57
- // TODO: Set a default value for apiVersion
58
- apiVersion: "v2",
59
- ref: this.agent.ref,
60
- name: this.agent.name,
61
- username: this.agent.username,
62
- privacy: (_a = this.agent.privacy) !== null && _a !== void 0 ? _a : client_1.Privacy.NONE,
63
- enabled: this.agent.enabled,
64
- domainRef: this.agent.domainRef || null,
65
- credentialsRef: this.agent.credentialsRef || null,
66
- createdAt: this.agent.createdAt
67
- ? new Date(this.agent.createdAt * 1000)
68
- : undefined,
69
- updatedAt: this.agent.updatedAt
70
- ? new Date(this.agent.updatedAt * 1000)
71
- : undefined,
72
- maxContacts: this.agent.maxContacts,
73
- expires: this.agent.expires,
74
- extended: this.agent.extended || {}
75
- };
56
+ 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 });
76
57
  }
77
58
  static mapToDto(agent) {
78
59
  return agent
79
- ? {
80
- apiVersion: agent.apiVersion,
81
- ref: agent.ref,
82
- name: agent.name,
83
- username: agent.username,
84
- privacy: agent.privacy,
85
- enabled: agent.enabled,
86
- domainRef: agent.domainRef,
87
- credentialsRef: agent.credentialsRef,
88
- domain: domain_1.DomainManager.mapToDto(agent.domain),
89
- credentials: credentials_1.CredentialsManager.mapToDto(agent.credentials),
90
- maxContacts: agent.maxContacts,
91
- expires: agent.expires,
92
- extended: (agent.extended || {}),
93
- createdAt: agent.createdAt.getTime() / 1000,
94
- updatedAt: agent.updatedAt.getTime() / 1000
95
- }
96
- : undefined;
60
+ ? 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;
97
61
  }
98
62
  }
99
63
  exports.AgentManager = AgentManager;
@@ -1,11 +1,10 @@
1
1
  import { Credentials as CredentialsPrismaModel } from "@prisma/client";
2
2
  import { CommonConnect as CC } from "@routr/common";
3
- import { JsonObject } from "pb-util/build";
4
3
  import { EntityManager } from "./manager";
5
4
  export declare class CredentialsManager extends EntityManager {
6
5
  private credentials;
7
6
  constructor(credentials: CC.Credentials);
8
- static includeFields(): JsonObject;
7
+ static includeFields(): Record<string, unknown>;
9
8
  validOrThrowCreate(): void;
10
9
  validOrThrowUpdate(): void;
11
10
  mapToPrisma(): CredentialsPrismaModel;
@@ -20,40 +20,16 @@ class CredentialsManager extends manager_1.EntityManager {
20
20
  common_1.CommonConnect.hasPasswordOrThrow(this.credentials.password);
21
21
  }
22
22
  validOrThrowUpdate() {
23
- common_1.CommonConnect.hasRefenceOrThrow(this.credentials.ref);
23
+ common_1.CommonConnect.hasReferenceOrThrow(this.credentials.ref);
24
24
  common_1.CommonConnect.isValidNameOrThrow(this.credentials.name);
25
25
  common_1.CommonConnect.isValidUsernameOrThrow(this.credentials.username);
26
26
  }
27
27
  mapToPrisma() {
28
- return {
29
- // TODO: Set a default value for apiVersion
30
- apiVersion: "v2",
31
- ref: this.credentials.ref,
32
- name: this.credentials.name,
33
- username: this.credentials.username,
34
- password: this.credentials.password || undefined,
35
- createdAt: this.credentials.createdAt
36
- ? new Date(this.credentials.createdAt * 1000)
37
- : undefined,
38
- updatedAt: this.credentials.updatedAt
39
- ? new Date(this.credentials.updatedAt * 1000)
40
- : undefined,
41
- extended: this.credentials.extended || {}
42
- };
28
+ return Object.assign(Object.assign({}, this.credentials), { apiVersion: "v2", createdAt: undefined, updatedAt: undefined, extended: this.credentials.extended });
43
29
  }
44
30
  static mapToDto(credentials) {
45
31
  return credentials
46
- ? {
47
- apiVersion: credentials.apiVersion,
48
- ref: credentials.ref,
49
- name: credentials.name,
50
- username: credentials.username,
51
- password: credentials.password,
52
- createdAt: credentials.createdAt.getTime() / 1000,
53
- updatedAt: credentials.updatedAt.getTime() / 1000,
54
- extended: credentials.extended
55
- }
56
- : undefined;
32
+ ? Object.assign(Object.assign({}, credentials), { apiVersion: credentials.apiVersion, createdAt: credentials.createdAt.getTime() / 1000, updatedAt: credentials.updatedAt.getTime() / 1000, extended: credentials.extended }) : undefined;
57
33
  }
58
34
  }
59
35
  exports.CredentialsManager = CredentialsManager;
@@ -1,6 +1,5 @@
1
1
  import { Domain as DomainPrismaModel, Prisma, EgressPolicy } from "@prisma/client";
2
2
  import { CommonConnect as CC } from "@routr/common";
3
- import { JsonObject } from "pb-util/build";
4
3
  import { EntityManager } from "./manager";
5
4
  type DomainWithACL = Prisma.DomainGetPayload<{
6
5
  include: {
@@ -15,7 +14,7 @@ type DomainWithACL = Prisma.DomainGetPayload<{
15
14
  export declare class DomainManager extends EntityManager {
16
15
  private domain;
17
16
  constructor(domain: CC.Domain);
18
- static includeFields(): JsonObject;
17
+ static includeFields(): Record<string, unknown>;
19
18
  validOrThrowCreate(): void;
20
19
  validOrThrowUpdate(): void;
21
20
  mapToPrisma(): DomainPrismaModel & {
@@ -27,41 +27,26 @@ class DomainManager extends manager_1.EntityManager {
27
27
  common_1.CommonConnect.isValidDomainUriOrThrow(this.domain.domainUri);
28
28
  }
29
29
  validOrThrowUpdate() {
30
- common_1.CommonConnect.hasRefenceOrThrow(this.domain.ref);
30
+ common_1.CommonConnect.hasReferenceOrThrow(this.domain.ref);
31
31
  common_1.CommonConnect.isValidNameOrThrow(this.domain.name);
32
32
  }
33
33
  mapToPrisma() {
34
34
  var _a;
35
- return {
36
- // TODO: Set a default value for apiVersion
37
- apiVersion: "v2",
38
- ref: this.domain.ref,
39
- name: this.domain.name,
40
- accessControlListRef: this.domain.accessControlListRef || null,
41
- domainUri: this.domain.domainUri,
42
- extended: this.domain.extended || {},
43
- createdAt: this.domain.createdAt
44
- ? new Date(this.domain.createdAt * 1000)
45
- : undefined,
46
- updatedAt: this.domain.updatedAt
47
- ? new Date(this.domain.updatedAt * 1000)
48
- : undefined,
49
- egressPolicies: {
35
+ return Object.assign(Object.assign({}, this.domain), { apiVersion: "v2", accessControlListRef: this.domain.accessControlListRef || null, extended: this.domain.extended, egressPolicies: {
50
36
  create: (_a = this.domain.egressPolicies) === null || _a === void 0 ? void 0 : _a.map((policy) => ({
51
37
  rule: policy.rule,
52
38
  numberRef: policy.numberRef
53
39
  }))
54
- }
55
- };
40
+ }, createdAt: undefined, updatedAt: undefined });
56
41
  }
57
42
  static mapToDto(domain) {
58
43
  var _a, _b;
59
44
  return domain
60
- ? Object.assign(Object.assign({}, domain), { 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) => ({
45
+ ? 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) => ({
61
46
  rule: policy.rule,
62
47
  numberRef: policy.numberRef,
63
48
  number: number_1.NumberManager.mapToDtoWithoutTrunk(policy.number)
64
- })), extended: domain.extended, createdAt: domain.createdAt.getTime() / 1000, updatedAt: domain.updatedAt.getTime() / 1000 }) : undefined;
49
+ })), createdAt: domain.createdAt.getTime() / 1000, updatedAt: domain.updatedAt.getTime() / 1000, extended: domain.extended }) : undefined;
65
50
  }
66
51
  }
67
52
  exports.DomainManager = DomainManager;
@@ -1,6 +1,5 @@
1
- import { JsonObject } from "pb-util/build";
2
1
  export declare abstract class EntityManager {
3
- static readonly includeFields: () => JsonObject;
2
+ static readonly includeFields: () => Record<string, unknown>;
4
3
  abstract validOrThrowCreate(): void;
5
4
  abstract validOrThrowUpdate(): void;
6
5
  }
@@ -1,6 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EntityManager = void 0;
4
+ /*
5
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
6
+ * http://github.com/fonoster/routr
7
+ *
8
+ * This file is part of Routr.
9
+ *
10
+ * Licensed under the MIT License (the "License");
11
+ * you may not use this file except in compliance with
12
+ * the License. You may obtain a copy of the License at
13
+ *
14
+ * https://opensource.org/licenses/MIT
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ /* eslint-disable require-jsdoc */
4
23
  class EntityManager {
5
24
  }
6
25
  exports.EntityManager = EntityManager;
@@ -1,6 +1,5 @@
1
1
  import { Number as NumberPrismaModel, Prisma } from "@prisma/client";
2
2
  import { CommonConnect as CC } from "@routr/common";
3
- import { JsonObject } from "pb-util/build";
4
3
  import { EntityManager } from "./manager";
5
4
  type NumberWithTrunk = Prisma.NumberGetPayload<{
6
5
  include: {
@@ -17,7 +16,7 @@ type NumberWithTrunk = Prisma.NumberGetPayload<{
17
16
  export declare class NumberManager extends EntityManager {
18
17
  private number;
19
18
  constructor(number: CC.INumber);
20
- static includeFields(): JsonObject;
19
+ static includeFields(): Record<string, unknown>;
21
20
  validOrThrowCreate(): void;
22
21
  validOrThrowUpdate(): void;
23
22
  mapToPrisma(): NumberPrismaModel;
@@ -4,7 +4,6 @@ exports.NumberManager = void 0;
4
4
  const common_1 = require("@routr/common");
5
5
  const manager_1 = require("./manager");
6
6
  const trunk_1 = require("./trunk");
7
- const common_2 = require("@routr/common");
8
7
  // Needs testing
9
8
  class NumberManager extends manager_1.EntityManager {
10
9
  constructor(number) {
@@ -26,8 +25,8 @@ class NumberManager extends manager_1.EntityManager {
26
25
  validOrThrowCreate() {
27
26
  common_1.CommonConnect.hasTelUrlOrThrow(this.number.telUrl);
28
27
  common_1.CommonConnect.isValidTelUrlOrThrow(this.number.telUrl);
29
- if (common_2.Environment.ENFORCE_E164) {
30
- common_1.CommonConnect.isValidE164OrThrow(this.number.telUrl.split("tel:")[1], this.number.countryIsoCode, common_2.Environment.ENFORCE_E164_WITH_MOBILE_PREFIX);
28
+ if (common_1.Environment.ENFORCE_E164) {
29
+ common_1.CommonConnect.isValidE164OrThrow(this.number.telUrl.split("tel:")[1], this.number.countryIsoCode, common_1.Environment.ENFORCE_E164_WITH_MOBILE_PREFIX);
31
30
  }
32
31
  common_1.CommonConnect.hasNameOrThrow(this.number.name);
33
32
  common_1.CommonConnect.isValidNameOrThrow(this.number.name);
@@ -39,75 +38,22 @@ class NumberManager extends manager_1.EntityManager {
39
38
  common_1.CommonConnect.isValidSessionAffinityHeaderOrThrow(this.number.sessionAffinityHeader);
40
39
  }
41
40
  validOrThrowUpdate() {
42
- common_1.CommonConnect.hasRefenceOrThrow(this.number.ref);
41
+ common_1.CommonConnect.hasReferenceOrThrow(this.number.ref);
43
42
  common_1.CommonConnect.isValidNameOrThrow(this.number.name);
44
43
  common_1.CommonConnect.isValidAORLinkOrThrow(this.number.aorLink);
45
44
  common_1.CommonConnect.hasValidHeadersOrThrow(this.number.extraHeaders);
46
45
  common_1.CommonConnect.isValidSessionAffinityHeaderOrThrow(this.number.sessionAffinityHeader);
47
46
  }
48
47
  mapToPrisma() {
49
- return {
50
- // TODO: Set a default value for apiVersion
51
- apiVersion: "v2",
52
- ref: this.number.ref,
53
- name: this.number.name,
54
- trunkRef: this.number.trunkRef || null,
55
- telUrl: this.number.telUrl,
56
- aorLink: this.number.aorLink || null,
57
- city: this.number.city || undefined,
58
- country: this.number.country,
59
- countryIsoCode: this.number.countryIsoCode,
60
- sessionAffinityHeader: this.number.sessionAffinityHeader || null,
61
- extraHeaders: this.number.extraHeaders || null,
62
- createdAt: this.number.createdAt
63
- ? new Date(this.number.createdAt * 1000)
64
- : undefined,
65
- updatedAt: this.number.updatedAt
66
- ? new Date(this.number.updatedAt * 1000)
67
- : undefined,
68
- extended: this.number.extended || {}
69
- };
48
+ return Object.assign(Object.assign({}, this.number), { apiVersion: "v2", trunkRef: this.number.trunkRef, sessionAffinityHeader: this.number.sessionAffinityHeader, extraHeaders: this.number.extraHeaders, createdAt: undefined, updatedAt: undefined, extended: this.number.extended });
70
49
  }
71
50
  static mapToDto(number) {
72
51
  return number
73
- ? {
74
- apiVersion: number.apiVersion,
75
- ref: number.ref,
76
- name: number.name,
77
- trunkRef: number.trunkRef,
78
- trunk: trunk_1.TrunkManager.mapToDto(number.trunk),
79
- telUrl: number.telUrl,
80
- aorLink: number.aorLink,
81
- city: number.city,
82
- country: number.country,
83
- countryIsoCode: number.countryIsoCode,
84
- sessionAffinityHeader: number.sessionAffinityHeader,
85
- extraHeaders: number.extraHeaders,
86
- extended: number.extended,
87
- createdAt: number.createdAt.getTime() / 1000,
88
- updatedAt: number.updatedAt.getTime() / 1000
89
- }
90
- : undefined;
52
+ ? Object.assign(Object.assign({}, number), { apiVersion: number.apiVersion, trunk: trunk_1.TrunkManager.mapToDto(number.trunk), extraHeaders: number.extraHeaders, createdAt: number.createdAt.getTime() / 1000, updatedAt: number.updatedAt.getTime() / 1000, extended: number.extended }) : undefined;
91
53
  }
92
54
  static mapToDtoWithoutTrunk(number) {
93
55
  return number
94
- ? {
95
- apiVersion: number.apiVersion,
96
- ref: number.ref,
97
- name: number.name,
98
- trunkRef: number.trunkRef,
99
- telUrl: number.telUrl,
100
- aorLink: number.aorLink,
101
- city: number.city,
102
- country: number.country,
103
- countryIsoCode: number.countryIsoCode,
104
- sessionAffinityHeader: number.sessionAffinityHeader,
105
- extraHeaders: number.extraHeaders,
106
- extended: number.extended,
107
- createdAt: number.createdAt.getTime() / 1000,
108
- updatedAt: number.updatedAt.getTime() / 1000
109
- }
110
- : undefined;
56
+ ? Object.assign(Object.assign({}, number), { apiVersion: number.apiVersion, extraHeaders: number.extraHeaders, createdAt: number.createdAt.getTime() / 1000, updatedAt: number.updatedAt.getTime() / 1000, extended: number.extended }) : undefined;
111
57
  }
112
58
  }
113
59
  exports.NumberManager = NumberManager;
@@ -1,6 +1,5 @@
1
1
  import { Peer as PeerPrismaModel, Prisma } from "@prisma/client";
2
2
  import { CommonConnect as CC } from "@routr/common";
3
- import { JsonObject } from "pb-util/build";
4
3
  import { EntityManager } from "./manager";
5
4
  type PeerWithDomainAndCredentials = Prisma.PeerGetPayload<{
6
5
  include: {
@@ -11,7 +10,7 @@ type PeerWithDomainAndCredentials = Prisma.PeerGetPayload<{
11
10
  export declare class PeerManager extends EntityManager {
12
11
  private peer;
13
12
  constructor(peer: CC.Peer);
14
- static includeFields(): JsonObject;
13
+ static includeFields(): Record<string, unknown>;
15
14
  validOrThrowCreate(): void;
16
15
  validOrThrowUpdate(): void;
17
16
  mapToPrisma(): PeerPrismaModel;
@@ -27,7 +27,7 @@ class PeerManager extends manager_1.EntityManager {
27
27
  common_1.CommonConnect.isValidContactAddressOrThrow(this.peer.contactAddr);
28
28
  }
29
29
  validOrThrowUpdate() {
30
- common_1.CommonConnect.hasRefenceOrThrow(this.peer.ref);
30
+ common_1.CommonConnect.hasReferenceOrThrow(this.peer.ref);
31
31
  common_1.CommonConnect.isValidNameOrThrow(this.peer.name);
32
32
  common_1.CommonConnect.isValidUsernameOrThrow(this.peer.username);
33
33
  common_1.CommonConnect.isValidAOROrThrow(this.peer.aor);
@@ -37,53 +37,11 @@ class PeerManager extends manager_1.EntityManager {
37
37
  const normalizeAlgorithm = (algorithm) => algorithm === common_1.CommonTypes.LoadBalancingAlgorithm.UNSPECIFIED
38
38
  ? undefined
39
39
  : algorithm;
40
- return {
41
- // TODO: Set a default value for apiVersion
42
- apiVersion: "v2",
43
- ref: this.peer.ref,
44
- name: this.peer.name,
45
- username: this.peer.username,
46
- aor: this.peer.aor,
47
- contactAddr: this.peer.contactAddr,
48
- balancingAlgorithm: normalizeAlgorithm(this.peer.balancingAlgorithm),
49
- withSessionAffinity: this.peer.withSessionAffinity,
50
- enabled: this.peer.enabled,
51
- credentialsRef: this.peer.credentialsRef || null,
52
- accessControlListRef: this.peer.accessControlListRef || null,
53
- createdAt: this.peer.createdAt
54
- ? new Date(this.peer.createdAt * 1000)
55
- : undefined,
56
- updatedAt: this.peer.updatedAt
57
- ? new Date(this.peer.updatedAt * 1000)
58
- : undefined,
59
- maxContacts: this.peer.maxContacts,
60
- expires: this.peer.expires,
61
- extended: this.peer.extended || {}
62
- };
40
+ 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 });
63
41
  }
64
42
  static mapToDto(peer) {
65
43
  return peer
66
- ? {
67
- apiVersion: peer.apiVersion,
68
- ref: peer.ref,
69
- name: peer.name,
70
- username: peer.username,
71
- aor: peer.aor,
72
- contactAddr: peer.contactAddr,
73
- balancingAlgorithm: peer.balancingAlgorithm,
74
- withSessionAffinity: peer.withSessionAffinity,
75
- enabled: peer.enabled,
76
- credentialsRef: peer.credentialsRef,
77
- credentials: credentials_1.CredentialsManager.mapToDto(peer.credentials),
78
- accessControlListRef: peer.accessControlListRef,
79
- accessControlList: acl_1.ACLManager.mapToDto(peer.accessControlList),
80
- createdAt: peer.createdAt.getTime() / 1000,
81
- updatedAt: peer.updatedAt.getTime() / 1000,
82
- maxContacts: peer.maxContacts,
83
- expires: peer.expires,
84
- extended: peer.extended
85
- }
86
- : undefined;
44
+ ? 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;
87
45
  }
88
46
  }
89
47
  exports.PeerManager = PeerManager;
@@ -1,6 +1,5 @@
1
1
  import { Trunk as TrunkPrismaModel, Prisma, TrunkURI } from "@prisma/client";
2
2
  import { CommonConnect as CC } from "@routr/common";
3
- import { JsonObject } from "pb-util/build";
4
3
  import { EntityManager } from "./manager";
5
4
  type TrunkWithEagerLoading = Prisma.TrunkGetPayload<{
6
5
  include: {
@@ -13,7 +12,7 @@ type TrunkWithEagerLoading = Prisma.TrunkGetPayload<{
13
12
  export declare class TrunkManager extends EntityManager {
14
13
  private trunk;
15
14
  constructor(trunk: CC.Trunk);
16
- static includeFields(): JsonObject;
15
+ static includeFields(): Record<string, unknown>;
17
16
  validOrThrowCreate(): void;
18
17
  validOrThrowUpdate(): void;
19
18
  mapToPrisma(): TrunkPrismaModel & {
@@ -27,77 +27,21 @@ class TrunkManager extends manager_1.EntityManager {
27
27
  common_1.CommonConnect.hasValidOutboundUrisOrThrow(this.trunk.uris);
28
28
  }
29
29
  validOrThrowUpdate() {
30
- common_1.CommonConnect.hasRefenceOrThrow(this.trunk.ref);
30
+ common_1.CommonConnect.hasReferenceOrThrow(this.trunk.ref);
31
31
  common_1.CommonConnect.isValidNameOrThrow(this.trunk.name);
32
32
  common_1.CommonConnect.isValidInboundUriOrThrow(this.trunk.inboundUri);
33
33
  }
34
34
  mapToPrisma() {
35
- var _a;
36
- return {
37
- // TODO: Set a default value for apiVersion
38
- apiVersion: "v2",
39
- ref: this.trunk.ref,
40
- name: this.trunk.name,
41
- accessControlListRef: this.trunk.accessControlListRef || null,
42
- inboundUri: this.trunk.inboundUri,
43
- inboundCredentialsRef: this.trunk.inboundCredentialsRef || null,
44
- outboundCredentialsRef: this.trunk.outboundCredentialsRef || null,
45
- sendRegister: this.trunk.sendRegister,
46
- createdAt: this.trunk.createdAt
47
- ? new Date(this.trunk.createdAt * 1000)
48
- : undefined,
49
- updatedAt: this.trunk.updatedAt
50
- ? new Date(this.trunk.updatedAt * 1000)
51
- : undefined,
52
- extended: this.trunk.extended || {},
53
- uris: {
54
- create: (_a = this.trunk.uris) === null || _a === void 0 ? void 0 : _a.map((uri) => {
55
- return {
56
- host: uri.host,
57
- port: uri.port,
58
- transport: uri.transport,
59
- user: uri.user,
60
- weight: uri.weight,
61
- priority: uri.priority,
62
- enabled: uri.enabled
63
- };
64
- })
65
- }
66
- };
35
+ 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: {
36
+ create: this.trunk.uris
37
+ }, extended: this.trunk.extended, createdAt: undefined, updatedAt: undefined });
67
38
  }
68
39
  static mapToDto(trunk) {
69
40
  var _a, _b, _c;
70
41
  return trunk
71
- ? {
72
- apiVersion: trunk.apiVersion,
73
- ref: trunk.ref,
74
- name: trunk.name,
75
- inboundUri: trunk.inboundUri,
76
- accessControlListRef: (_a = trunk.accessControlList) === null || _a === void 0 ? void 0 : _a.ref,
77
- inboundCredentialsRef: (_b = trunk.inboundCredentials) === null || _b === void 0 ? void 0 : _b.ref,
78
- outboundCredentialsRef: (_c = trunk.outboundCredentials) === null || _c === void 0 ? void 0 : _c.ref,
79
- inboundCredentials: credentials_1.CredentialsManager.mapToDto(trunk.inboundCredentials),
80
- accessControlList: acl_1.ACLManager.mapToDto(trunk.accessControlList),
81
- outboundCredentials: credentials_1.CredentialsManager.mapToDto(trunk.outboundCredentials),
82
- extended: trunk.extended,
83
- sendRegister: trunk.sendRegister,
84
- uris: trunk.uris.map((uri) => {
85
- return {
86
- ref: uri.ref,
87
- trunkRef: uri.trunkRef,
88
- host: uri.host,
89
- port: uri.port,
90
- transport: uri.transport.toUpperCase(),
91
- user: uri.user,
92
- weight: uri.weight,
93
- priority: uri.priority,
94
- enabled: uri.enabled
95
- };
96
- }),
97
- createdAt: trunk.createdAt.getTime() / 1000,
98
- updatedAt: trunk.updatedAt.getTime() / 1000
99
- }
100
- : undefined;
42
+ ? 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) => {
43
+ return Object.assign(Object.assign({}, uri), { transport: uri.transport.toUpperCase() });
44
+ }), createdAt: trunk.createdAt.getTime() / 1000, updatedAt: trunk.updatedAt.getTime() / 1000, extended: trunk.extended }) : undefined;
101
45
  }
102
46
  }
103
47
  exports.TrunkManager = TrunkManager;
package/dist/runner.js CHANGED
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  * limitations under the License.
24
24
  */
25
25
  // eslint-disable-next-line @typescript-eslint/no-var-requires
26
- require("./tracer").init("simpleauth");
26
+ require("./tracer").init("pgdata");
27
27
  const logger_1 = require("@fonoster/logger");
28
28
  const envs_1 = require("./envs");
29
29
  const service_1 = __importDefault(require("./service"));
package/dist/service.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PostgresDataConfig } from "./types";
2
2
  /**
3
- * Starts a new posgres data service.
3
+ * Starts a new postgres data service.
4
4
  *
5
5
  * @param {PostgresDataConfig} config - the configuration of the service
6
6
  */
package/dist/service.js CHANGED
@@ -60,7 +60,7 @@ const common_2 = require("@fonoster/common");
60
60
  const db_1 = require("./db");
61
61
  const logger = (0, logger_1.getLogger)({ service: "pgdata", filePath: __filename });
62
62
  /**
63
- * Starts a new posgres data service.
63
+ * Starts a new postgres data service.
64
64
  *
65
65
  * @param {PostgresDataConfig} config - the configuration of the service
66
66
  */
package/dist/types.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { CommonConnect as CC } from "@routr/common";
2
- import { JsonObject } from "pb-util/build";
3
2
  export interface PostgresDataConfig {
4
3
  bindAddr: string;
5
4
  externalServerBindAddr: string;
@@ -9,13 +8,13 @@ export type PrismaOperation = (request: {
9
8
  where: {
10
9
  ref: string;
11
10
  };
12
- include?: JsonObject;
11
+ include?: Record<string, unknown>;
13
12
  }) => unknown;
14
13
  export type PrismaFindByOperation = (request: {
15
14
  where: {
16
15
  [key: string]: boolean | string | number;
17
16
  };
18
- include?: JsonObject;
17
+ include?: Record<string, unknown>;
19
18
  }) => unknown;
20
19
  export type PrismaListOperation = (request: {
21
20
  take: number;
@@ -23,17 +22,17 @@ export type PrismaListOperation = (request: {
23
22
  cursor: {
24
23
  ref: string;
25
24
  };
26
- orderBy: JsonObject;
27
- include?: JsonObject;
25
+ orderBy: Record<string, unknown>;
26
+ include?: Record<string, unknown>;
28
27
  }) => unknown;
29
28
  export type PrismaCreateOperation = (request: {
30
29
  data: any;
31
- include?: JsonObject;
30
+ include?: Record<string, unknown>;
32
31
  }) => unknown;
33
32
  export type PrismaUpdateOperation = (request: {
34
33
  where: {
35
34
  ref: string;
36
35
  };
37
36
  data: unknown;
38
- include?: JsonObject;
37
+ include?: Record<string, unknown>;
39
38
  }) => unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/pgdata",
3
- "version": "2.12.1",
3
+ "version": "2.13.1",
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",
@@ -31,8 +31,8 @@
31
31
  "@opentelemetry/sdk-trace-node": "^1.0.4",
32
32
  "@opentelemetry/semantic-conventions": "^1.0.4",
33
33
  "@prisma/client": "^5.9.1",
34
- "@routr/common": "^2.12.1",
35
- "@routr/processor": "^2.12.1",
34
+ "@routr/common": "^2.13.1",
35
+ "@routr/processor": "^2.13.1",
36
36
  "google-protobuf": "^3.9.2",
37
37
  "grpc-health-check": "^2.0.2",
38
38
  "pb-util": "^1.0.3",
@@ -58,5 +58,5 @@
58
58
  "@types/validator": "^13.7.10",
59
59
  "prisma": "^5.9.1"
60
60
  },
61
- "gitHead": "cf4c8276173ec4be0a8013e70935b6cffb29cda4"
61
+ "gitHead": "47b285ad57015b0df452eede4e76cbfc9c67cbbb"
62
62
  }