@routr/common 2.12.0 → 2.13.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.
@@ -1,5 +1,4 @@
1
1
  import * as grpc from "@grpc/grpc-js";
2
- import { JsonObject } from "pb-util/build";
3
2
  import { AccessControlList, Agent, Credentials, Domain, INumber, Kind, Peer, Trunk } from "../types";
4
3
  export interface DataAPIOptions {
5
4
  apiAddr: string;
@@ -37,7 +36,7 @@ export type APIClient = {
37
36
  numbers: ServiceAPI<INumber>;
38
37
  };
39
38
  export type ServiceAPI<R extends {
40
- extended?: JsonObject;
39
+ extended?: Record<string, unknown>;
41
40
  }> = {
42
41
  create: (request: unknown) => Promise<R>;
43
42
  update: (request: unknown) => Promise<R>;
@@ -11,7 +11,7 @@ export declare const hasValidACLRulesOrThrow: (acl: {
11
11
  deny: string[];
12
12
  allow: string[];
13
13
  }) => void;
14
- export declare const hasRefenceOrThrow: (ref: string) => void;
14
+ export declare const hasReferenceOrThrow: (ref: string) => void;
15
15
  export declare const hasNameOrThrow: (name: string) => void;
16
16
  export declare const isValidNameOrThrow: (name: string) => void;
17
17
  export declare const hasUsernameOrThrow: (username: string) => void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasValidOutboundUrisOrThrow = exports.isValidE164OrThrow = exports.isValidContactAddressOrThrow = exports.isValidAORLinkOrThrow = exports.hasAORLinkOrThrow = exports.isValidAOROrThrow = exports.hasAOROrThrow = exports.isValidInboundUriOrThrow = exports.hasInboundUriOrThrow = exports.hasCountryIsoCodeOrThrow = exports.hasCountryOrThrow = exports.hasCityOrThrow = exports.isValidSessionAffinityHeaderOrThrow = exports.isValidTelUrlOrThrow = exports.hasTelUrlOrThrow = exports.isValidDomainUriOrThrow = exports.hasDomainUriOrThrow = exports.hasPasswordOrThrow = exports.isValidUsernameOrThrow = exports.hasUsernameOrThrow = exports.isValidNameOrThrow = exports.hasNameOrThrow = exports.hasRefenceOrThrow = exports.hasValidACLRulesOrThrow = exports.hasACLRulesOrThrow = exports.hasValidHeadersOrThrow = void 0;
3
+ exports.hasValidOutboundUrisOrThrow = exports.isValidE164OrThrow = exports.isValidContactAddressOrThrow = exports.isValidAORLinkOrThrow = exports.hasAORLinkOrThrow = exports.isValidAOROrThrow = exports.hasAOROrThrow = exports.isValidInboundUriOrThrow = exports.hasInboundUriOrThrow = exports.hasCountryIsoCodeOrThrow = exports.hasCountryOrThrow = exports.hasCityOrThrow = exports.isValidSessionAffinityHeaderOrThrow = exports.isValidTelUrlOrThrow = exports.hasTelUrlOrThrow = exports.isValidDomainUriOrThrow = exports.hasDomainUriOrThrow = exports.hasPasswordOrThrow = exports.isValidUsernameOrThrow = exports.hasUsernameOrThrow = exports.isValidNameOrThrow = exports.hasNameOrThrow = exports.hasReferenceOrThrow = exports.hasValidACLRulesOrThrow = exports.hasACLRulesOrThrow = exports.hasValidHeadersOrThrow = void 0;
4
4
  /*
5
5
  * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/routr
@@ -38,8 +38,8 @@ const hasACLRulesOrThrow = (acl) => validOrThrow(validations_1.hasACLRules, acl)
38
38
  exports.hasACLRulesOrThrow = hasACLRulesOrThrow;
39
39
  const hasValidACLRulesOrThrow = (acl) => validOrThrow(validations_1.hasValidACLRules, acl);
40
40
  exports.hasValidACLRulesOrThrow = hasValidACLRulesOrThrow;
41
- const hasRefenceOrThrow = (ref) => validOrThrow(validations_1.hasReference, ref);
42
- exports.hasRefenceOrThrow = hasRefenceOrThrow;
41
+ const hasReferenceOrThrow = (ref) => validOrThrow(validations_1.hasReference, ref);
42
+ exports.hasReferenceOrThrow = hasReferenceOrThrow;
43
43
  const hasNameOrThrow = (name) => validOrThrow(validations_1.hasName, name);
44
44
  exports.hasNameOrThrow = hasNameOrThrow;
45
45
  const isValidNameOrThrow = (name) => validOrThrow(validations_1.isValidName, name);
@@ -51,7 +51,7 @@ const protoOptions = {
51
51
  keepCase: false,
52
52
  longs: String,
53
53
  enums: String,
54
- defaults: true,
54
+ defaults: false,
55
55
  oneofs: true
56
56
  };
57
57
  function getProtoPath(kind) {
@@ -1,7 +1,7 @@
1
1
  import { LoadBalancingAlgorithm, Privacy, Transport } from "../types";
2
- import { Kind } from "./types";
2
+ import { APIVersion, Kind } from "./types";
3
3
  export interface ConfigBase {
4
- apiVersion: string;
4
+ apiVersion: APIVersion;
5
5
  ref: string;
6
6
  metadata: {
7
7
  name: string;
@@ -13,7 +13,9 @@ function mapToACL(config) {
13
13
  ref: config.ref,
14
14
  name: config.metadata.name,
15
15
  allow: (_b = (_a = config.spec.accessControlList) === null || _a === void 0 ? void 0 : _a.allow) !== null && _b !== void 0 ? _b : [],
16
- deny: (_d = (_c = config.spec.accessControlList) === null || _c === void 0 ? void 0 : _c.deny) !== null && _d !== void 0 ? _d : []
16
+ deny: (_d = (_c = config.spec.accessControlList) === null || _c === void 0 ? void 0 : _c.deny) !== null && _d !== void 0 ? _d : [],
17
+ createdAt: new Date().getTime(),
18
+ updatedAt: new Date().getTime()
17
19
  };
18
20
  }
19
21
  exports.mapToACL = mapToACL;
@@ -38,7 +38,9 @@ function mapToAgent(config) {
38
38
  domainRef: config.spec.domainRef,
39
39
  credentialsRef: config.spec.credentialsRef,
40
40
  maxContacts: config.spec.maxContacts,
41
- expires: config.spec.expires
41
+ expires: config.spec.expires,
42
+ createdAt: new Date().getTime(),
43
+ updatedAt: new Date().getTime()
42
44
  };
43
45
  }
44
46
  exports.mapToAgent = mapToAgent;
@@ -12,7 +12,9 @@ function mapToCredentials(config) {
12
12
  ref: config.ref,
13
13
  name: config.metadata.name,
14
14
  username: config.spec.credentials.username,
15
- password: config.spec.credentials.password
15
+ password: config.spec.credentials.password,
16
+ createdAt: new Date().getTime(),
17
+ updatedAt: new Date().getTime()
16
18
  };
17
19
  }
18
20
  exports.mapToCredentials = mapToCredentials;
@@ -13,7 +13,9 @@ function mapToDomain(config) {
13
13
  name: config.metadata.name,
14
14
  domainUri: config.spec.context.domainUri,
15
15
  accessControlListRef: config.spec.accessControlListRef,
16
- egressPolicies: config.spec.context.egressPolicies
16
+ egressPolicies: config.spec.context.egressPolicies,
17
+ createdAt: new Date().getTime(),
18
+ updatedAt: new Date().getTime()
17
19
  };
18
20
  }
19
21
  exports.mapToDomain = mapToDomain;
@@ -20,7 +20,9 @@ function mapToNumber(config) {
20
20
  aorLink: location.aorLink,
21
21
  sessionAffinityHeader: location.sessionAffinityHeader,
22
22
  extraHeaders: location.extraHeaders,
23
- trunkRef: config.spec.trunkRef
23
+ trunkRef: config.spec.trunkRef,
24
+ createdAt: new Date().getTime(),
25
+ updatedAt: new Date().getTime()
24
26
  };
25
27
  }
26
28
  exports.mapToNumber = mapToNumber;
@@ -21,7 +21,9 @@ function mapToPeer(config) {
21
21
  balancingAlgorithm: normalizeAlgorithm((_a = config.spec.loadBalancing) === null || _a === void 0 ? void 0 : _a.algorithm),
22
22
  withSessionAffinity: (_b = config.spec.loadBalancing) === null || _b === void 0 ? void 0 : _b.withSessionAffinity,
23
23
  maxContacts: config.spec.maxContacts,
24
- expires: config.spec.expires
24
+ expires: config.spec.expires,
25
+ createdAt: new Date().getTime(),
26
+ updatedAt: new Date().getTime()
25
27
  };
26
28
  }
27
29
  exports.mapToPeer = mapToPeer;
@@ -28,7 +28,9 @@ function mapToTrunk(config) {
28
28
  weight: entry.weight,
29
29
  priority: entry.priority
30
30
  };
31
- })
31
+ }),
32
+ createdAt: new Date().getTime(),
33
+ updatedAt: new Date().getTime()
32
34
  };
33
35
  }
34
36
  exports.mapToTrunk = mapToTrunk;
@@ -1,4 +1,3 @@
1
- import { JsonObject } from "pb-util/build";
2
1
  import { LoadBalancingAlgorithm, Privacy, Transport } from "../types";
3
2
  export declare enum Kind {
4
3
  AGENT = "agent",
@@ -12,16 +11,16 @@ export declare enum Kind {
12
11
  }
13
12
  export type KindWithoutUnknown = Exclude<Kind, Kind.UNKNOWN>;
14
13
  export declare enum APIVersion {
15
- v2beta1 = "v2beta1",
14
+ V2BETA1 = "v2beta1",
16
15
  V2 = "v2"
17
16
  }
18
17
  export interface BaseConnectModel {
19
- apiVersion: string;
18
+ apiVersion: APIVersion;
20
19
  ref: string;
21
20
  name: string;
22
- createdAt?: number;
23
- updatedAt?: number;
24
- extended?: JsonObject;
21
+ createdAt: number;
22
+ updatedAt: number;
23
+ extended?: Record<string, unknown>;
25
24
  }
26
25
  export interface AccessControlList extends BaseConnectModel {
27
26
  allow: string[];
@@ -59,8 +58,8 @@ export interface INumber extends BaseConnectModel {
59
58
  city: string;
60
59
  country: string;
61
60
  countryIsoCode: string;
62
- sessionAffinityHeader: string;
63
- extraHeaders: {
61
+ sessionAffinityHeader?: string;
62
+ extraHeaders?: {
64
63
  name: string;
65
64
  value: string;
66
65
  }[];
@@ -14,6 +14,6 @@ var Kind;
14
14
  })(Kind = exports.Kind || (exports.Kind = {}));
15
15
  var APIVersion;
16
16
  (function (APIVersion) {
17
- APIVersion["v2beta1"] = "v2beta1";
17
+ APIVersion["V2BETA1"] = "v2beta1";
18
18
  APIVersion["V2"] = "v2";
19
19
  })(APIVersion = exports.APIVersion || (exports.APIVersion = {}));
@@ -11,7 +11,7 @@ export declare const hasTelUrl: (telUrl: string) => true | BadRequestError;
11
11
  export declare const isValidTelUrl: (telUrl: string) => true | BadRequestError;
12
12
  export declare const isValidSessionAffinityHeader: (sessionAffinityHeader: string) => true | BadRequestError;
13
13
  export declare const isValidHeader: (header: string) => true | BadRequestError;
14
- export declare const hasValidHeaders: (headers: {
14
+ export declare const hasValidHeaders: (headers?: {
15
15
  name: string;
16
16
  value: string;
17
17
  }[]) => true | BadRequestError;
@@ -26,7 +26,7 @@ export declare const hasACLRules: (acl: {
26
26
  deny: string[];
27
27
  allow: string[];
28
28
  }) => true | BadRequestError;
29
- export declare const isValidACLRule: (rules: string[]) => true | BadRequestError;
29
+ export declare const isValidACLRule: (rules?: string[]) => true | BadRequestError;
30
30
  export declare const hasValidACLRules: (acl: {
31
31
  deny: string[];
32
32
  allow: string[];
@@ -108,7 +108,7 @@ const isValidHeader = (header) => {
108
108
  : true;
109
109
  };
110
110
  exports.isValidHeader = isValidHeader;
111
- const hasValidHeaders = (headers) => {
111
+ const hasValidHeaders = (headers = []) => {
112
112
  // eslint-disable-next-line no-loops/no-loops
113
113
  for (const header of headers) {
114
114
  const E = (0, exports.isValidHeader)(header.name);
@@ -161,7 +161,7 @@ const hasACLRules = (acl) => {
161
161
  return true;
162
162
  };
163
163
  exports.hasACLRules = hasACLRules;
164
- const isValidACLRule = (rules) => {
164
+ const isValidACLRule = (rules = []) => {
165
165
  // eslint-disable-next-line no-loops/no-loops
166
166
  for (const cidr of rules) {
167
167
  if (!Validator.default.isIPRange(cidr, 4) &&
@@ -48,7 +48,7 @@ const packageDefinition = protoLoader.loadSync(__dirname + "/../protos/requester
48
48
  keepCase: false,
49
49
  longs: String,
50
50
  enums: String,
51
- defaults: true,
51
+ defaults: false,
52
52
  oneofs: true
53
53
  });
54
54
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
package/dist/service.js CHANGED
@@ -53,7 +53,7 @@ const loadOptions = {
53
53
  keepCase: false,
54
54
  longs: String,
55
55
  enums: String,
56
- defaults: true,
56
+ defaults: false,
57
57
  oneofs: true
58
58
  };
59
59
  // TODO: Get version from the proto or package
@@ -48,7 +48,7 @@ const packageDefinition = protoLoader.loadSync(__dirname + "/../protos/verifier.
48
48
  keepCase: false,
49
49
  longs: String,
50
50
  enums: String,
51
- defaults: true,
51
+ defaults: false,
52
52
  oneofs: true
53
53
  });
54
54
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/common",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "description": "Common package",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -13,6 +13,7 @@
13
13
  "postbuild": "cp -a src/protos dist/protos && cp -a src/connect/protos dist/connect/protos"
14
14
  },
15
15
  "dependencies": {
16
+ "@fonoster/common": "0.6.0",
16
17
  "@fonoster/logger": "0.6.0",
17
18
  "@grpc/grpc-js": "~1.10.1",
18
19
  "@grpc/proto-loader": "~0.7.10",
@@ -54,5 +55,5 @@
54
55
  "devDependencies": {
55
56
  "@types/js-yaml": "^4.0.5"
56
57
  },
57
- "gitHead": "83c134c9ad3f414bdd8c30222ac5be7cdfd13420"
58
+ "gitHead": "6272ef833472f0df1204073739c48eeb37ce705f"
58
59
  }