@fonoster/common 0.7.22 → 0.7.26
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/envs.d.ts +1 -0
- package/dist/envs.js +31 -0
- package/dist/errors/handleError.js +23 -8
- package/dist/errors/handleZodError.js +4 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -8
- package/dist/messages.d.ts +8 -0
- package/dist/messages.js +29 -0
- package/dist/notifications/createSendEmail.d.ts +3 -0
- package/dist/notifications/{createEmailSender.js → createSendEmail.js} +2 -2
- package/dist/notifications/createSendSmsTwilioImpl.d.ts +3 -0
- package/dist/notifications/createSendSmsTwilioImpl.js +54 -0
- package/dist/notifications/index.d.ts +3 -1
- package/dist/notifications/index.js +3 -1
- package/dist/notifications/types.d.ts +27 -0
- package/dist/notifications/types.js +2 -0
- package/dist/protos/acls.proto +2 -8
- package/dist/protos/identity.proto +35 -12
- package/dist/utils/createService.js +18 -7
- package/dist/utils/getServerCredentials.js +17 -7
- package/dist/validators/calls.d.ts +4 -4
- package/dist/validators/calls.js +18 -12
- package/dist/validators/common.d.ts +4 -1
- package/dist/validators/common.js +22 -3
- package/dist/validators/hostOrHostPortSchema.js +1 -1
- package/dist/validators/identity.d.ts +48 -6
- package/dist/validators/identity.js +55 -21
- package/dist/validators/secrets.js +3 -3
- package/dist/validators/sipnet/acls.d.ts +20 -2
- package/dist/validators/sipnet/acls.js +53 -2
- package/dist/validators/sipnet/agents.d.ts +41 -2
- package/dist/validators/sipnet/agents.js +23 -2
- package/dist/validators/sipnet/credentials.d.ts +20 -2
- package/dist/validators/sipnet/credentials.js +9 -2
- package/dist/validators/sipnet/domains.d.ts +43 -2
- package/dist/validators/sipnet/domains.js +32 -2
- package/dist/validators/sipnet/numbers.d.ts +29 -4
- package/dist/validators/sipnet/numbers.js +6 -0
- package/dist/validators/sipnet/trunks.d.ts +57 -1
- package/dist/validators/sipnet/trunks.js +55 -1
- package/package.json +4 -3
- package/dist/notifications/createEmailSender.d.ts +0 -17
package/dist/envs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ROOT_DOMAIN: string;
|
package/dist/envs.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ROOT_DOMAIN = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster/fonoster
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Fonoster
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the MIT License (the "License");
|
|
14
|
+
* you may not use this file except in compliance with
|
|
15
|
+
* the License. You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* https://opensource.org/licenses/MIT
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const path_1 = require("path");
|
|
26
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
27
|
+
if (process.env.NODE_ENV === "dev") {
|
|
28
|
+
dotenv_1.default.config({ path: (0, path_1.join)(__dirname, "..", "..", "..", ".env") });
|
|
29
|
+
}
|
|
30
|
+
const e = process.env;
|
|
31
|
+
exports.ROOT_DOMAIN = e.ROOT_DOMAIN || "fonoster.local";
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.handleError = handleError;
|
|
27
37
|
/*
|
|
@@ -57,7 +67,12 @@ function handleError(error, callback) {
|
|
|
57
67
|
const { code, message } = error;
|
|
58
68
|
const logAndCallback = (errorCode, errorMessage, logMessage) => {
|
|
59
69
|
logger.error(logMessage, { message: errorMessage });
|
|
60
|
-
|
|
70
|
+
const messageParts = errorMessage.split(":");
|
|
71
|
+
let effectiveErrorMessage = errorMessage;
|
|
72
|
+
if (errorCode === grpc_js_1.status.NOT_FOUND && messageParts.length > 1) {
|
|
73
|
+
effectiveErrorMessage = `Resource not found: ${messageParts[messageParts.length - 1].trim()}`;
|
|
74
|
+
}
|
|
75
|
+
callback({ code: errorCode, message: effectiveErrorMessage });
|
|
61
76
|
};
|
|
62
77
|
switch (code) {
|
|
63
78
|
case PrismaErrorEnum_1.PrismaErrorEnum.RECORD_ALREADY_EXISTS:
|
|
@@ -30,8 +30,10 @@ function handleZodError(error, callback) {
|
|
|
30
30
|
callback({ code: grpc_js_1.status.INVALID_ARGUMENT, message });
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
const validationError = (0, zod_validation_error_1.fromError)(error
|
|
34
|
-
|
|
33
|
+
const validationError = (0, zod_validation_error_1.fromError)(error, {
|
|
34
|
+
prefix: null
|
|
35
|
+
});
|
|
36
|
+
logger.error("Error:", { message: validationError.toString() });
|
|
35
37
|
callback({
|
|
36
38
|
code: grpc_js_1.status.INVALID_ARGUMENT,
|
|
37
39
|
message: validationError.toString()
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,15 +18,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
18
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
20
|
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Validators = void 0;
|
|
39
|
+
exports.Validators = exports.Messages = void 0;
|
|
30
40
|
/*
|
|
31
41
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
32
42
|
* http://github.com/fonoster/fonoster
|
|
@@ -49,6 +59,7 @@ __exportStar(require("./GrpcError"), exports);
|
|
|
49
59
|
__exportStar(require("./constants"), exports);
|
|
50
60
|
__exportStar(require("./errors"), exports);
|
|
51
61
|
__exportStar(require("./grpcStatusMap"), exports);
|
|
62
|
+
exports.Messages = __importStar(require("./messages"));
|
|
52
63
|
__exportStar(require("./notifications"), exports);
|
|
53
64
|
__exportStar(require("./tts"), exports);
|
|
54
65
|
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const MUST_BE_A_SINGLE_CHARACTER = "Must be a single character";
|
|
2
|
+
export declare const MUST_BE_A_STRING = "Must be a string";
|
|
3
|
+
export declare const POSITIVE_INTEGER_MESSAGE = "Must be a positive number";
|
|
4
|
+
export declare const VALID_DATE = "The date must be a valid ISO 8601";
|
|
5
|
+
export declare const VALID_DTMF = "Must be a valid DTMF";
|
|
6
|
+
export declare const VALID_LANGUAGE_CODE = "Must be a valid language code";
|
|
7
|
+
export declare const VALID_URL = "Must be a valid URL";
|
|
8
|
+
export declare const VALID_UUID = "Must be a valid UUID";
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VALID_UUID = exports.VALID_URL = exports.VALID_LANGUAGE_CODE = exports.VALID_DTMF = exports.VALID_DATE = exports.POSITIVE_INTEGER_MESSAGE = exports.MUST_BE_A_STRING = exports.MUST_BE_A_SINGLE_CHARACTER = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
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
|
+
exports.MUST_BE_A_SINGLE_CHARACTER = "Must be a single character";
|
|
23
|
+
exports.MUST_BE_A_STRING = "Must be a string";
|
|
24
|
+
exports.POSITIVE_INTEGER_MESSAGE = "Must be a positive number";
|
|
25
|
+
exports.VALID_DATE = "The date must be a valid ISO 8601";
|
|
26
|
+
exports.VALID_DTMF = "Must be a valid DTMF";
|
|
27
|
+
exports.VALID_LANGUAGE_CODE = "Must be a valid language code";
|
|
28
|
+
exports.VALID_URL = "Must be a valid URL";
|
|
29
|
+
exports.VALID_UUID = "Must be a valid UUID";
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.createSendEmail = createSendEmail;
|
|
13
13
|
/*
|
|
14
14
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
15
|
* http://github.com/fonoster/fonoster
|
|
@@ -31,7 +31,7 @@ exports.createEmailSender = createEmailSender;
|
|
|
31
31
|
const logger_1 = require("@fonoster/logger");
|
|
32
32
|
const nodemailer_1 = require("nodemailer");
|
|
33
33
|
const logger = (0, logger_1.getLogger)({ service: "common", filePath: __filename });
|
|
34
|
-
function
|
|
34
|
+
function createSendEmail(config) {
|
|
35
35
|
const { sender, host, port, secure, auth } = config;
|
|
36
36
|
const transporter = (0, nodemailer_1.createTransport)({
|
|
37
37
|
host,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createSendSmsTwilioImpl = createSendSmsTwilioImpl;
|
|
16
|
+
/*
|
|
17
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
18
|
+
* http://github.com/fonoster/fonoster
|
|
19
|
+
*
|
|
20
|
+
* This file is part of Fonoster
|
|
21
|
+
*
|
|
22
|
+
* Licensed under the MIT License (the "License");
|
|
23
|
+
* you may not use this file except in compliance with
|
|
24
|
+
* the License. You may obtain a copy of the License at
|
|
25
|
+
*
|
|
26
|
+
* https://opensource.org/licenses/MIT
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
+
* See the License for the specific language governing permissions and
|
|
32
|
+
* limitations under the License.
|
|
33
|
+
*/
|
|
34
|
+
const logger_1 = require("@fonoster/logger");
|
|
35
|
+
const twilio_1 = __importDefault(require("twilio"));
|
|
36
|
+
const logger = (0, logger_1.getLogger)({ service: "common", filePath: __filename });
|
|
37
|
+
function createSendSmsTwilioImpl(config) {
|
|
38
|
+
const { sender: from, accountSid, authToken } = config;
|
|
39
|
+
const client = (0, twilio_1.default)(accountSid, authToken);
|
|
40
|
+
return function sendSms(params) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const { to, body } = params;
|
|
43
|
+
const result = yield client.messages.create({
|
|
44
|
+
body,
|
|
45
|
+
from,
|
|
46
|
+
to
|
|
47
|
+
});
|
|
48
|
+
logger.verbose("message sent", {
|
|
49
|
+
status: result.status,
|
|
50
|
+
messageId: result.sid
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -33,4 +33,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
* limitations under the License.
|
|
34
34
|
*/
|
|
35
35
|
__exportStar(require("./compileTemplate"), exports);
|
|
36
|
-
__exportStar(require("./
|
|
36
|
+
__exportStar(require("./createSendEmail"), exports);
|
|
37
|
+
__exportStar(require("./createSendSmsTwilioImpl"), exports);
|
|
38
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type EmailSenderConfig = {
|
|
2
|
+
sender: string;
|
|
3
|
+
host: string;
|
|
4
|
+
port: number;
|
|
5
|
+
secure: boolean;
|
|
6
|
+
auth: {
|
|
7
|
+
user: string;
|
|
8
|
+
pass: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type EmailParams = {
|
|
12
|
+
to: string;
|
|
13
|
+
subject: string;
|
|
14
|
+
html: string;
|
|
15
|
+
};
|
|
16
|
+
type SmsSenderConfig = {
|
|
17
|
+
sender: string;
|
|
18
|
+
};
|
|
19
|
+
type TwilioSmsSenderConfig = SmsSenderConfig & {
|
|
20
|
+
accountSid: string;
|
|
21
|
+
authToken: string;
|
|
22
|
+
};
|
|
23
|
+
type SmsParams = {
|
|
24
|
+
to: string;
|
|
25
|
+
body: string;
|
|
26
|
+
};
|
|
27
|
+
export { EmailParams, EmailSenderConfig, SmsParams, SmsSenderConfig, TwilioSmsSenderConfig };
|
package/dist/protos/acls.proto
CHANGED
|
@@ -42,12 +42,10 @@ message Acl {
|
|
|
42
42
|
string name = 2;
|
|
43
43
|
// The list of allowed IP addresses
|
|
44
44
|
repeated string allow = 3;
|
|
45
|
-
// The list of denied IP addresses
|
|
46
|
-
repeated string deny = 4;
|
|
47
45
|
// The date the Acl was created
|
|
48
|
-
int32 created_at =
|
|
46
|
+
int32 created_at = 4;
|
|
49
47
|
// The date the Acl was last updated
|
|
50
|
-
int32 updated_at =
|
|
48
|
+
int32 updated_at = 5;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
// The request message for the Acl.CreateAcl method
|
|
@@ -56,8 +54,6 @@ message CreateAclRequest {
|
|
|
56
54
|
string name = 1;
|
|
57
55
|
// The list of allowed IP addresses
|
|
58
56
|
repeated string allow = 2;
|
|
59
|
-
// The list of denied IP addresses
|
|
60
|
-
repeated string deny = 3;
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
// The response message for the Acl.CreateAcl method
|
|
@@ -74,8 +70,6 @@ message UpdateAclRequest {
|
|
|
74
70
|
string name = 2;
|
|
75
71
|
// The list of allowed IP addresses
|
|
76
72
|
repeated string allow = 3;
|
|
77
|
-
// The list of denied IP addresses
|
|
78
|
-
repeated string deny = 4;
|
|
79
73
|
}
|
|
80
74
|
|
|
81
75
|
// The response message for the Acl.UpdateAcl method
|
|
@@ -38,7 +38,9 @@ service Identity {
|
|
|
38
38
|
rpc GetUser (GetUserRequest) returns (User) {}
|
|
39
39
|
rpc UpdateUser (UpdateUserRequest) returns (UpdateUserResponse) {}
|
|
40
40
|
rpc DeleteUser (DeleteUserRequest) returns (DeleteUserResponse) {}
|
|
41
|
-
|
|
41
|
+
rpc SendVerificationCode (SendVerificationCodeRequest) returns (google.protobuf.Empty) {}
|
|
42
|
+
rpc VerifyCode (VerifyCodeRequest) returns (google.protobuf.Empty) {}
|
|
43
|
+
|
|
42
44
|
// ApiKey actions
|
|
43
45
|
rpc CreateApiKey (CreateApiKeyRequest) returns (CreateApiKeyResponse) {}
|
|
44
46
|
rpc DeleteApiKey (DeleteApiKeyRequest) returns (DeleteApiKeyResponse) {}
|
|
@@ -48,7 +50,7 @@ service Identity {
|
|
|
48
50
|
// Token exchange actions
|
|
49
51
|
rpc ExchangeCredentials (ExchangeCredentialsRequest) returns (ExchangeCredentialsResponse) {}
|
|
50
52
|
rpc ExchangeApiKey (ExchangeApiKeyRequest) returns (ExchangeApiKeyResponse) {}
|
|
51
|
-
rpc
|
|
53
|
+
rpc ExchangeOauth2Code (ExchangeOauth2CodeRequest) returns (ExchangeOauth2CodeResponse) {}
|
|
52
54
|
rpc ExchangeRefreshToken (ExchangeRefreshTokenRequest) returns (ExchangeRefreshTokenResponse) {}
|
|
53
55
|
rpc RevokeToken (RevokeTokenRequest) returns (RevokeTokenResponse) {}
|
|
54
56
|
|
|
@@ -58,6 +60,14 @@ service Identity {
|
|
|
58
60
|
|
|
59
61
|
// Workspace Resources
|
|
60
62
|
|
|
63
|
+
message Workspace {
|
|
64
|
+
string ref = 1;
|
|
65
|
+
string name = 2;
|
|
66
|
+
string owner_ref = 3;
|
|
67
|
+
int32 created_at = 4;
|
|
68
|
+
int32 updated_at = 5;
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
message CreateWorkspaceRequest {
|
|
62
72
|
string name = 1;
|
|
63
73
|
}
|
|
@@ -124,6 +134,10 @@ message ResendWorkspaceMembershipInvitationResponse {
|
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
// User Resources
|
|
137
|
+
enum ContactType {
|
|
138
|
+
EMAIL = 0;
|
|
139
|
+
PHONE = 1;
|
|
140
|
+
}
|
|
127
141
|
|
|
128
142
|
message CreateUserRequest {
|
|
129
143
|
string email = 1;
|
|
@@ -168,12 +182,16 @@ message DeleteUserResponse {
|
|
|
168
182
|
string ref = 1;
|
|
169
183
|
}
|
|
170
184
|
|
|
171
|
-
message
|
|
172
|
-
|
|
173
|
-
string
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
185
|
+
message SendVerificationCodeRequest {
|
|
186
|
+
ContactType contact_type = 1;
|
|
187
|
+
string value = 2;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
message VerifyCodeRequest {
|
|
191
|
+
string username = 1;
|
|
192
|
+
ContactType contact_type = 2;
|
|
193
|
+
string value = 3;
|
|
194
|
+
string verification_code = 4;
|
|
177
195
|
}
|
|
178
196
|
|
|
179
197
|
// ApiKey Resources
|
|
@@ -232,7 +250,7 @@ message ExchangeCredentialsRequest {
|
|
|
232
250
|
string username = 1;
|
|
233
251
|
string password = 2;
|
|
234
252
|
// Optional code for multi-factor authentication
|
|
235
|
-
string
|
|
253
|
+
string verification_code = 3;
|
|
236
254
|
}
|
|
237
255
|
|
|
238
256
|
message ExchangeCredentialsResponse {
|
|
@@ -252,11 +270,16 @@ message ExchangeApiKeyResponse {
|
|
|
252
270
|
string refresh_token = 3;
|
|
253
271
|
}
|
|
254
272
|
|
|
255
|
-
message
|
|
256
|
-
|
|
273
|
+
message ExchangeOauth2CodeRequest {
|
|
274
|
+
enum Oauth2Provider {
|
|
275
|
+
GITHUB = 0;
|
|
276
|
+
}
|
|
277
|
+
Oauth2Provider provider = 1;
|
|
278
|
+
string username = 2;
|
|
279
|
+
string code = 3;
|
|
257
280
|
}
|
|
258
281
|
|
|
259
|
-
message
|
|
282
|
+
message ExchangeOauth2CodeResponse {
|
|
260
283
|
string id_token = 1;
|
|
261
284
|
string access_token = 2;
|
|
262
285
|
string refresh_token = 3;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.createServiceDefinition = createServiceDefinition;
|
|
27
37
|
/*
|
|
@@ -49,6 +59,7 @@ const loadOptions = {
|
|
|
49
59
|
longs: String,
|
|
50
60
|
enums: String,
|
|
51
61
|
defaults: false,
|
|
62
|
+
arrays: true,
|
|
52
63
|
oneofs: true
|
|
53
64
|
};
|
|
54
65
|
function createServiceDefinition(params) {
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -6,15 +6,15 @@ declare const createCallRequestSchema: z.ZodObject<{
|
|
|
6
6
|
appRef: z.ZodString;
|
|
7
7
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
8
8
|
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
timeout?: number;
|
|
10
|
-
from?: string;
|
|
11
9
|
to?: string;
|
|
10
|
+
from?: string;
|
|
12
11
|
appRef?: string;
|
|
13
|
-
}, {
|
|
14
12
|
timeout?: number;
|
|
15
|
-
|
|
13
|
+
}, {
|
|
16
14
|
to?: string;
|
|
15
|
+
from?: string;
|
|
17
16
|
appRef?: string;
|
|
17
|
+
timeout?: number;
|
|
18
18
|
}>;
|
|
19
19
|
declare const getCallRequestSchema: z.ZodObject<{
|
|
20
20
|
ref: z.ZodString;
|
package/dist/validators/calls.js
CHANGED
|
@@ -21,27 +21,33 @@ exports.listCallsRequestSchema = exports.getCallRequestSchema = exports.createCa
|
|
|
21
21
|
*/
|
|
22
22
|
const types_1 = require("@fonoster/types");
|
|
23
23
|
const zod_1 = require("zod");
|
|
24
|
+
const messages_1 = require("../messages");
|
|
24
25
|
const createCallRequestSchema = zod_1.z.object({
|
|
25
26
|
from: zod_1.z.string(),
|
|
26
27
|
to: zod_1.z.string(),
|
|
27
|
-
appRef: zod_1.z.string().uuid("Invalid call reference"),
|
|
28
|
-
timeout: zod_1.z
|
|
28
|
+
appRef: zod_1.z.string().uuid({ message: "Invalid call reference" }),
|
|
29
|
+
timeout: zod_1.z
|
|
30
|
+
.number()
|
|
31
|
+
.max(120, { message: "Timeout must be less than 120s" })
|
|
32
|
+
.optional()
|
|
29
33
|
});
|
|
30
34
|
exports.createCallRequestSchema = createCallRequestSchema;
|
|
31
35
|
const getCallRequestSchema = zod_1.z.object({
|
|
32
|
-
ref: zod_1.z.string().uuid("Invalid call reference")
|
|
36
|
+
ref: zod_1.z.string().uuid({ message: "Invalid call reference" })
|
|
33
37
|
});
|
|
34
38
|
exports.getCallRequestSchema = getCallRequestSchema;
|
|
35
39
|
const listCallsRequestSchema = zod_1.z.object({
|
|
36
|
-
after: zod_1.z
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
.
|
|
42
|
-
|
|
40
|
+
after: zod_1.z.string().datetime({ offset: true, message: messages_1.VALID_DATE }).optional(),
|
|
41
|
+
before: zod_1.z.string().datetime({ offset: true, message: messages_1.VALID_DATE }).optional(),
|
|
42
|
+
pageSize: zod_1.z
|
|
43
|
+
.number()
|
|
44
|
+
.int({
|
|
45
|
+
message: messages_1.POSITIVE_INTEGER_MESSAGE
|
|
46
|
+
})
|
|
47
|
+
.positive({
|
|
48
|
+
message: messages_1.POSITIVE_INTEGER_MESSAGE
|
|
49
|
+
})
|
|
43
50
|
.optional(),
|
|
44
|
-
pageSize: zod_1.z.number({ message: "Invalid pageSize value" }).optional(),
|
|
45
51
|
type: zod_1.z
|
|
46
52
|
.nativeEnum(types_1.CallType, {
|
|
47
53
|
message: "Invalid call type"
|
|
@@ -50,6 +56,6 @@ const listCallsRequestSchema = zod_1.z.object({
|
|
|
50
56
|
status: zod_1.z
|
|
51
57
|
.nativeEnum(types_1.CallStatus, { message: "Invalid call status" })
|
|
52
58
|
.optional(),
|
|
53
|
-
pageToken: zod_1.z.string(
|
|
59
|
+
pageToken: zod_1.z.string().optional()
|
|
54
60
|
});
|
|
55
61
|
exports.listCallsRequestSchema = listCallsRequestSchema;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
declare const usernameSchema: z.ZodString;
|
|
2
3
|
declare const baseApiObjectSchema: z.ZodObject<{
|
|
3
4
|
ref: z.ZodString;
|
|
4
5
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -6,6 +7,7 @@ declare const baseApiObjectSchema: z.ZodObject<{
|
|
|
6
7
|
}, {
|
|
7
8
|
ref?: string;
|
|
8
9
|
}>;
|
|
10
|
+
declare const emptySchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
9
11
|
declare const listRequestSchema: z.ZodOptional<z.ZodObject<{
|
|
10
12
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
11
13
|
pageToken: z.ZodOptional<z.ZodString>;
|
|
@@ -16,4 +18,5 @@ declare const listRequestSchema: z.ZodOptional<z.ZodObject<{
|
|
|
16
18
|
pageSize?: number;
|
|
17
19
|
pageToken?: string;
|
|
18
20
|
}>>;
|
|
19
|
-
|
|
21
|
+
declare const nameSchema: z.ZodString;
|
|
22
|
+
export { baseApiObjectSchema, emptySchema, listRequestSchema, nameSchema, usernameSchema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listRequestSchema = exports.baseApiObjectSchema = void 0;
|
|
3
|
+
exports.usernameSchema = exports.nameSchema = exports.listRequestSchema = exports.emptySchema = exports.baseApiObjectSchema = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster/fonoster
|
|
@@ -20,14 +20,33 @@ exports.listRequestSchema = exports.baseApiObjectSchema = void 0;
|
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
22
|
const zod_1 = require("zod");
|
|
23
|
+
const messages_1 = require("../messages");
|
|
24
|
+
const usernameSchema = zod_1.z.string().regex(/^[a-z0-9._-]+$/, {
|
|
25
|
+
message: "Must be a lowercase string and with no spaces."
|
|
26
|
+
});
|
|
27
|
+
exports.usernameSchema = usernameSchema;
|
|
23
28
|
const baseApiObjectSchema = zod_1.z.object({
|
|
24
|
-
ref: zod_1.z.string()
|
|
29
|
+
ref: zod_1.z.string().uuid({
|
|
30
|
+
message: messages_1.VALID_UUID
|
|
31
|
+
})
|
|
25
32
|
});
|
|
26
33
|
exports.baseApiObjectSchema = baseApiObjectSchema;
|
|
34
|
+
const emptySchema = zod_1.z.object({});
|
|
35
|
+
exports.emptySchema = emptySchema;
|
|
27
36
|
const listRequestSchema = zod_1.z
|
|
28
37
|
.object({
|
|
29
|
-
pageSize: zod_1.z
|
|
38
|
+
pageSize: zod_1.z
|
|
39
|
+
.number()
|
|
40
|
+
.int({
|
|
41
|
+
message: messages_1.POSITIVE_INTEGER_MESSAGE
|
|
42
|
+
})
|
|
43
|
+
.positive({
|
|
44
|
+
message: messages_1.POSITIVE_INTEGER_MESSAGE
|
|
45
|
+
})
|
|
46
|
+
.optional(),
|
|
30
47
|
pageToken: zod_1.z.string().optional()
|
|
31
48
|
})
|
|
32
49
|
.optional();
|
|
33
50
|
exports.listRequestSchema = listRequestSchema;
|
|
51
|
+
const nameSchema = zod_1.z.string().min(1, { message: "Value required" });
|
|
52
|
+
exports.nameSchema = nameSchema;
|