@fonoster/sipnet 0.6.1-alpha.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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/acls/buildService.d.ts +30 -0
- package/dist/acls/buildService.js +45 -0
- package/dist/acls/client.d.ts +49 -0
- package/dist/acls/client.js +2 -0
- package/dist/acls/index.d.ts +1 -0
- package/dist/acls/index.js +23 -0
- package/dist/acls/operations.d.ts +21 -0
- package/dist/acls/operations.js +29 -0
- package/dist/acls/types.d.ts +14 -0
- package/dist/acls/types.js +2 -0
- package/dist/agents/buildService.d.ts +30 -0
- package/dist/agents/buildService.js +45 -0
- package/dist/agents/client.d.ts +62 -0
- package/dist/agents/client.js +8 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.js +23 -0
- package/dist/agents/operations.d.ts +21 -0
- package/dist/agents/operations.js +29 -0
- package/dist/agents/types.d.ts +14 -0
- package/dist/agents/types.js +2 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +26 -0
- package/dist/credentials/buildService.d.ts +30 -0
- package/dist/credentials/buildService.js +45 -0
- package/dist/credentials/client.d.ts +49 -0
- package/dist/credentials/client.js +2 -0
- package/dist/credentials/index.d.ts +1 -0
- package/dist/credentials/index.js +23 -0
- package/dist/credentials/operations.d.ts +21 -0
- package/dist/credentials/operations.js +29 -0
- package/dist/credentials/types.d.ts +14 -0
- package/dist/credentials/types.js +2 -0
- package/dist/domains/buildService.d.ts +30 -0
- package/dist/domains/buildService.js +45 -0
- package/dist/domains/client.d.ts +57 -0
- package/dist/domains/client.js +2 -0
- package/dist/domains/index.d.ts +1 -0
- package/dist/domains/index.js +23 -0
- package/dist/domains/operations.d.ts +21 -0
- package/dist/domains/operations.js +29 -0
- package/dist/domains/types.d.ts +14 -0
- package/dist/domains/types.js +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +41 -0
- package/dist/numbers/buildService.d.ts +31 -0
- package/dist/numbers/buildService.js +29 -0
- package/dist/numbers/client.d.ts +67 -0
- package/dist/numbers/client.js +2 -0
- package/dist/numbers/convertToRoutrNumber.d.ts +18 -0
- package/dist/numbers/convertToRoutrNumber.js +26 -0
- package/dist/numbers/createNumber.d.ts +7 -0
- package/dist/numbers/createNumber.js +54 -0
- package/dist/numbers/index.d.ts +1 -0
- package/dist/numbers/index.js +23 -0
- package/dist/numbers/operations.d.ts +15 -0
- package/dist/numbers/operations.js +19 -0
- package/dist/numbers/types.d.ts +29 -0
- package/dist/numbers/types.js +2 -0
- package/dist/numbers/updateNumber.d.ts +7 -0
- package/dist/numbers/updateNumber.js +51 -0
- package/dist/numbers/validation.d.ts +39 -0
- package/dist/numbers/validation.js +51 -0
- package/dist/resources/createResource.d.ts +5 -0
- package/dist/resources/createResource.js +51 -0
- package/dist/resources/deleteResource.d.ts +4 -0
- package/dist/resources/deleteResource.js +42 -0
- package/dist/resources/getResource.d.ts +4 -0
- package/dist/resources/getResource.js +41 -0
- package/dist/resources/listResources.d.ts +9 -0
- package/dist/resources/listResources.js +51 -0
- package/dist/resources/updateResource.d.ts +4 -0
- package/dist/resources/updateResource.js +46 -0
- package/dist/trunks/buildService.d.ts +30 -0
- package/dist/trunks/buildService.js +45 -0
- package/dist/trunks/client.d.ts +76 -0
- package/dist/trunks/client.js +11 -0
- package/dist/trunks/index.d.ts +1 -0
- package/dist/trunks/index.js +23 -0
- package/dist/trunks/operations.d.ts +21 -0
- package/dist/trunks/operations.js +29 -0
- package/dist/trunks/types.d.ts +14 -0
- package/dist/trunks/types.js +2 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.js +2 -0
- package/package.json +44 -0
|
@@ -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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createNumber = void 0;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const common_1 = require("@fonoster/common");
|
|
32
|
+
const identity_1 = require("@fonoster/identity");
|
|
33
|
+
const logger_1 = require("@fonoster/logger");
|
|
34
|
+
const convertToRoutrNumber_1 = require("./convertToRoutrNumber");
|
|
35
|
+
const validation_1 = require("./validation");
|
|
36
|
+
const logger = (0, logger_1.getLogger)({ service: "sipnet", filePath: __filename });
|
|
37
|
+
function createNumber(api, checkNumberPreconditions) {
|
|
38
|
+
return (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const { request } = call;
|
|
40
|
+
try {
|
|
41
|
+
validation_1.createNumberRequestSchema.parse(request);
|
|
42
|
+
// Validates that the appRef or agentAor exists in the system
|
|
43
|
+
yield checkNumberPreconditions(request);
|
|
44
|
+
const accessKeyId = (0, identity_1.getAccessKeyIdFromCall)(call);
|
|
45
|
+
logger.verbose("call to createNumber", { request, accessKeyId });
|
|
46
|
+
const response = yield api.createNumber((0, convertToRoutrNumber_1.convertToRoutrNumber)(request, accessKeyId));
|
|
47
|
+
callback(null, response);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
(0, common_1.handleError)(e, callback);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.createNumber = createNumber;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { buildService as buildNumbersService } from "./buildService";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildNumbersService = 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
|
+
var buildService_1 = require("./buildService");
|
|
23
|
+
Object.defineProperty(exports, "buildNumbersService", { enumerable: true, get: function () { return buildService_1.buildService; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GetNumberRequest, NumbersApi } from "./client";
|
|
2
|
+
import { INumber } from "./types";
|
|
3
|
+
declare function getNumber(numbers: NumbersApi): (call: {
|
|
4
|
+
request: GetNumberRequest;
|
|
5
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: INumber) => void) => Promise<void>;
|
|
6
|
+
declare function listNumbers(numbers: NumbersApi): (call: {
|
|
7
|
+
request: import("./client").ListNumbersRequest;
|
|
8
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: {
|
|
9
|
+
nextPageToken?: string;
|
|
10
|
+
items: INumber[];
|
|
11
|
+
}) => void) => Promise<void>;
|
|
12
|
+
declare function deleteNumber(numbers: NumbersApi): (call: {
|
|
13
|
+
request: import("./client").DeleteNumberRequest;
|
|
14
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: INumber) => void) => Promise<void>;
|
|
15
|
+
export { getNumber, listNumbers, deleteNumber };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteNumber = exports.listNumbers = exports.getNumber = void 0;
|
|
4
|
+
const deleteResource_1 = require("../resources/deleteResource");
|
|
5
|
+
const getResource_1 = require("../resources/getResource");
|
|
6
|
+
const listResources_1 = require("../resources/listResources");
|
|
7
|
+
const RESOURCE = "Number";
|
|
8
|
+
function getNumber(numbers) {
|
|
9
|
+
return (0, getResource_1.getResource)(numbers, RESOURCE);
|
|
10
|
+
}
|
|
11
|
+
exports.getNumber = getNumber;
|
|
12
|
+
function listNumbers(numbers) {
|
|
13
|
+
return (0, listResources_1.listResources)(numbers, RESOURCE);
|
|
14
|
+
}
|
|
15
|
+
exports.listNumbers = listNumbers;
|
|
16
|
+
function deleteNumber(numbers) {
|
|
17
|
+
return (0, deleteResource_1.deleteResource)(numbers, RESOURCE);
|
|
18
|
+
}
|
|
19
|
+
exports.deleteNumber = deleteNumber;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as RTypes from "./client";
|
|
2
|
+
type INumber = Omit<RTypes.INumber, "extended">;
|
|
3
|
+
type CreateNumberRequest = Omit<RTypes.CreateNumberRequest, "extended">;
|
|
4
|
+
type CreateNumberResponse = RTypes.CreateNumberResponse;
|
|
5
|
+
type UpdateNumberRequest = RTypes.UpdateNumberRequest;
|
|
6
|
+
type UpdateNumberResponse = RTypes.UpdateNumberResponse;
|
|
7
|
+
type GetNumberRequest = RTypes.GetNumberRequest;
|
|
8
|
+
type ListNumbersRequest = RTypes.ListNumbersRequest;
|
|
9
|
+
type ListNumbersResponse = RTypes.ListNumbersResponse;
|
|
10
|
+
type DeleteNumberRequest = RTypes.DeleteNumberRequest;
|
|
11
|
+
type DeleteNumberResponse = {
|
|
12
|
+
ref: string;
|
|
13
|
+
};
|
|
14
|
+
type FCreateNumberRequest = {
|
|
15
|
+
name: string;
|
|
16
|
+
telUrl: string;
|
|
17
|
+
city: string;
|
|
18
|
+
country: string;
|
|
19
|
+
countryIsoCode: string;
|
|
20
|
+
appRef?: string;
|
|
21
|
+
agentAor?: string;
|
|
22
|
+
};
|
|
23
|
+
type FUpdateNumberRequest = {
|
|
24
|
+
ref: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
appRef?: string;
|
|
27
|
+
agentAor?: string;
|
|
28
|
+
};
|
|
29
|
+
export type { INumber, CreateNumberRequest, CreateNumberResponse, FCreateNumberRequest, FUpdateNumberRequest, UpdateNumberRequest, UpdateNumberResponse, GetNumberRequest, ListNumbersRequest, ListNumbersResponse, DeleteNumberRequest, DeleteNumberResponse };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GrpcErrorMessage, NumberPreconditionsCheck } from "@fonoster/common";
|
|
2
|
+
import { NumbersApi, UpdateNumberResponse } from "./client";
|
|
3
|
+
import { FUpdateNumberRequest } from "./types";
|
|
4
|
+
declare function updateNumber(api: NumbersApi, checkNumberPreconditions: NumberPreconditionsCheck): (call: {
|
|
5
|
+
request: FUpdateNumberRequest;
|
|
6
|
+
}, callback: (error?: GrpcErrorMessage, response?: UpdateNumberResponse) => void) => Promise<void>;
|
|
7
|
+
export { updateNumber };
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.updateNumber = void 0;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const common_1 = require("@fonoster/common");
|
|
32
|
+
const logger_1 = require("@fonoster/logger");
|
|
33
|
+
const validation_1 = require("./validation");
|
|
34
|
+
const logger = (0, logger_1.getLogger)({ service: "sipnet", filePath: __filename });
|
|
35
|
+
function updateNumber(api, checkNumberPreconditions) {
|
|
36
|
+
return (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { request } = call;
|
|
38
|
+
try {
|
|
39
|
+
validation_1.updateNumberRequestSchema.parse(request);
|
|
40
|
+
// Validates that the appRef or agentAor exists in the system
|
|
41
|
+
yield checkNumberPreconditions(request);
|
|
42
|
+
logger.verbose("call to updateNumber", { request });
|
|
43
|
+
const response = yield api.updateNumber(request);
|
|
44
|
+
callback(null, response);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
(0, common_1.handleError)(e, callback);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.updateNumber = updateNumber;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const createNumberRequestSchema: z.ZodEffects<z.ZodObject<{
|
|
3
|
+
agentAor: z.ZodOptional<z.ZodString>;
|
|
4
|
+
appRef: z.ZodOptional<z.ZodString>;
|
|
5
|
+
countryIsoCode: z.ZodEffects<z.ZodString, string, string>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
countryIsoCode?: string;
|
|
8
|
+
agentAor?: string;
|
|
9
|
+
appRef?: string;
|
|
10
|
+
}, {
|
|
11
|
+
countryIsoCode?: string;
|
|
12
|
+
agentAor?: string;
|
|
13
|
+
appRef?: string;
|
|
14
|
+
}>, {
|
|
15
|
+
countryIsoCode?: string;
|
|
16
|
+
agentAor?: string;
|
|
17
|
+
appRef?: string;
|
|
18
|
+
}, {
|
|
19
|
+
countryIsoCode?: string;
|
|
20
|
+
agentAor?: string;
|
|
21
|
+
appRef?: string;
|
|
22
|
+
}>;
|
|
23
|
+
declare const updateNumberRequestSchema: z.ZodEffects<z.ZodObject<{
|
|
24
|
+
agentAor: z.ZodOptional<z.ZodString>;
|
|
25
|
+
appRef: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
agentAor?: string;
|
|
28
|
+
appRef?: string;
|
|
29
|
+
}, {
|
|
30
|
+
agentAor?: string;
|
|
31
|
+
appRef?: string;
|
|
32
|
+
}>, {
|
|
33
|
+
agentAor?: string;
|
|
34
|
+
appRef?: string;
|
|
35
|
+
}, {
|
|
36
|
+
agentAor?: string;
|
|
37
|
+
appRef?: string;
|
|
38
|
+
}>;
|
|
39
|
+
export { createNumberRequestSchema, updateNumberRequestSchema };
|
|
@@ -0,0 +1,51 @@
|
|
|
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.updateNumberRequestSchema = exports.createNumberRequestSchema = 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 isISO31661Alpha2_1 = __importDefault(require("validator/lib/isISO31661Alpha2"));
|
|
26
|
+
const zod_1 = require("zod");
|
|
27
|
+
const sipUriRegex = /^sip:[a-zA-Z0-9_.-]+@[a-zA-Z0-9_.-]+$/;
|
|
28
|
+
const sipUriSchema = zod_1.z.string().regex(sipUriRegex, "Invalid SIP URI");
|
|
29
|
+
const countryIsoCodeSchema = zod_1.z.string().refine((val) => (0, isISO31661Alpha2_1.default)(val), {
|
|
30
|
+
message: "Invalid country ISO code"
|
|
31
|
+
});
|
|
32
|
+
const createNumberRequestSchema = zod_1.z
|
|
33
|
+
.object({
|
|
34
|
+
// TODO: Add validation for telUrl (perhaps using the "phone" package)
|
|
35
|
+
agentAor: sipUriSchema.optional(),
|
|
36
|
+
appRef: zod_1.z.string().optional(),
|
|
37
|
+
countryIsoCode: countryIsoCodeSchema
|
|
38
|
+
})
|
|
39
|
+
.refine(({ agentAor, appRef }) => !(agentAor !== undefined && appRef !== undefined), {
|
|
40
|
+
message: "You can only provide one of the following fields: 'agentAor' or 'appRef'"
|
|
41
|
+
});
|
|
42
|
+
exports.createNumberRequestSchema = createNumberRequestSchema;
|
|
43
|
+
const updateNumberRequestSchema = zod_1.z
|
|
44
|
+
.object({
|
|
45
|
+
agentAor: sipUriSchema.optional(),
|
|
46
|
+
appRef: zod_1.z.string().optional()
|
|
47
|
+
})
|
|
48
|
+
.refine((data) => data.agentAor && data.appRef, {
|
|
49
|
+
message: "You can only provide one of the following fields: 'agentAor' or 'appRef'"
|
|
50
|
+
});
|
|
51
|
+
exports.updateNumberRequestSchema = updateNumberRequestSchema;
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createResource = void 0;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const common_1 = require("@fonoster/common");
|
|
32
|
+
const identity_1 = require("@fonoster/identity");
|
|
33
|
+
const logger_1 = require("@fonoster/logger");
|
|
34
|
+
const logger = (0, logger_1.getLogger)({ service: "sipnet", filePath: __filename });
|
|
35
|
+
function createResource(api, resource) {
|
|
36
|
+
return (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { request } = call;
|
|
38
|
+
const accessKeyId = (0, identity_1.getAccessKeyIdFromCall)(call);
|
|
39
|
+
logger.verbose(`call to create${resource}`, { request, accessKeyId });
|
|
40
|
+
try {
|
|
41
|
+
const response = yield api[`create${resource}`](Object.assign(Object.assign({}, request), { extended: {
|
|
42
|
+
accessKeyId
|
|
43
|
+
} }));
|
|
44
|
+
callback(null, response);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
(0, common_1.handleError)(e, callback);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.createResource = createResource;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.deleteResource = void 0;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const identity_1 = require("@fonoster/identity");
|
|
32
|
+
const logger_1 = require("@fonoster/logger");
|
|
33
|
+
const logger = (0, logger_1.getLogger)({ service: "sipnet", filePath: __filename });
|
|
34
|
+
function deleteResource(api, resource) {
|
|
35
|
+
return (0, identity_1.withAccess)((call) => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const { request } = call;
|
|
37
|
+
logger.verbose(`call to delete${resource}`, { request, resource });
|
|
38
|
+
yield api[`delete${resource}`](request.ref);
|
|
39
|
+
return { ref: request.ref };
|
|
40
|
+
}), (ref) => api[`get${resource}`](ref));
|
|
41
|
+
}
|
|
42
|
+
exports.deleteResource = deleteResource;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getResource = void 0;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const identity_1 = require("@fonoster/identity");
|
|
32
|
+
const logger_1 = require("@fonoster/logger");
|
|
33
|
+
const logger = (0, logger_1.getLogger)({ service: "sipnet", filePath: __filename });
|
|
34
|
+
function getResource(api, resource) {
|
|
35
|
+
return (0, identity_1.withAccess)((call) => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const { request } = call;
|
|
37
|
+
logger.verbose(`call to get${resource}`, { request, resource });
|
|
38
|
+
return yield api[`get${resource}`](request.ref);
|
|
39
|
+
}), (ref) => api[`get${resource}`](ref));
|
|
40
|
+
}
|
|
41
|
+
exports.getResource = getResource;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GrpcErrorMessage } from "@fonoster/common";
|
|
2
|
+
type ListResourcesResponse<T> = {
|
|
3
|
+
nextPageToken?: string;
|
|
4
|
+
items: T[];
|
|
5
|
+
};
|
|
6
|
+
declare function listResources<T, R, U>(api: U, resource: string): (call: {
|
|
7
|
+
request: R;
|
|
8
|
+
}, callback: (error?: GrpcErrorMessage, response?: ListResourcesResponse<T>) => void) => Promise<void>;
|
|
9
|
+
export { listResources };
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.listResources = void 0;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const common_1 = require("@fonoster/common");
|
|
32
|
+
const logger_1 = require("@fonoster/logger");
|
|
33
|
+
const logger = (0, logger_1.getLogger)({ service: "sipnet", filePath: __filename });
|
|
34
|
+
function listResources(api, resource) {
|
|
35
|
+
return (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const { request } = call;
|
|
37
|
+
const res = resource === "Credentials" ? "Credential" : resource;
|
|
38
|
+
logger.verbose(`call to list${res}s`, { request });
|
|
39
|
+
try {
|
|
40
|
+
const response = yield api[`list${res}s`](request);
|
|
41
|
+
callback(null, {
|
|
42
|
+
items: response.items,
|
|
43
|
+
nextPageToken: response.nextPageToken
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
(0, common_1.handleError)(e, callback);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.listResources = listResources;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.updateResource = void 0;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const identity_1 = require("@fonoster/identity");
|
|
32
|
+
const logger_1 = require("@fonoster/logger");
|
|
33
|
+
const logger = (0, logger_1.getLogger)({ service: "sipnet", filePath: __filename });
|
|
34
|
+
function updateResource(api, resource) {
|
|
35
|
+
return (0, identity_1.withAccess)((call) => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const { request } = call;
|
|
37
|
+
const accessKeyId = (0, identity_1.getAccessKeyIdFromCall)(call);
|
|
38
|
+
logger.verbose(`call to update${resource}`, { request });
|
|
39
|
+
return yield api[`update${resource}`](Object.assign(Object.assign({}, request), {
|
|
40
|
+
// FIXME: We should not have to pass the accessKeyId here. Fix upstream!
|
|
41
|
+
extended: {
|
|
42
|
+
accessKeyId
|
|
43
|
+
} }));
|
|
44
|
+
}), (ref) => api[`get${resource}`](ref));
|
|
45
|
+
}
|
|
46
|
+
exports.updateResource = updateResource;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ClientOptions } from "../types";
|
|
2
|
+
declare function buildService(clientOptions: ClientOptions): {
|
|
3
|
+
definition: {
|
|
4
|
+
serviceName: string;
|
|
5
|
+
pckg: string;
|
|
6
|
+
version: string;
|
|
7
|
+
proto: string;
|
|
8
|
+
};
|
|
9
|
+
handlers: {
|
|
10
|
+
createTrunk: (call: {
|
|
11
|
+
request: import("./types").CreateTrunkRequest;
|
|
12
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: import("./types").Trunk) => void) => Promise<void>;
|
|
13
|
+
updateTrunk: (call: {
|
|
14
|
+
request: import("./client").UpdateTrunkRequest;
|
|
15
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: import("./types").Trunk) => void) => Promise<void>;
|
|
16
|
+
getTrunk: (call: {
|
|
17
|
+
request: import("./client").GetTrunkRequest;
|
|
18
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: import("./types").Trunk) => void) => Promise<void>;
|
|
19
|
+
listTrunks: (call: {
|
|
20
|
+
request: import("./client").ListTrunksRequest;
|
|
21
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: {
|
|
22
|
+
nextPageToken?: string;
|
|
23
|
+
items: import("./types").Trunk[];
|
|
24
|
+
}) => void) => Promise<void>;
|
|
25
|
+
deleteTrunk: (call: {
|
|
26
|
+
request: import("./client").DeleteTrunkRequest;
|
|
27
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: import("./types").Trunk) => void) => Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export { buildService };
|
|
@@ -0,0 +1,45 @@
|
|
|
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.buildService = 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 sdk_1 = __importDefault(require("@routr/sdk"));
|
|
26
|
+
const operations_1 = require("./operations");
|
|
27
|
+
function buildService(clientOptions) {
|
|
28
|
+
const client = new sdk_1.default.Trunks(clientOptions);
|
|
29
|
+
return {
|
|
30
|
+
definition: {
|
|
31
|
+
serviceName: "Trunks",
|
|
32
|
+
pckg: "trunks",
|
|
33
|
+
version: "v1beta2",
|
|
34
|
+
proto: "trunks.proto"
|
|
35
|
+
},
|
|
36
|
+
handlers: {
|
|
37
|
+
createTrunk: (0, operations_1.createTrunk)(client),
|
|
38
|
+
updateTrunk: (0, operations_1.updateTrunk)(client),
|
|
39
|
+
getTrunk: (0, operations_1.getTrunk)(client),
|
|
40
|
+
listTrunks: (0, operations_1.listTrunks)(client),
|
|
41
|
+
deleteTrunk: (0, operations_1.deleteTrunk)(client)
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
exports.buildService = buildService;
|