Skip to content

Commit

Permalink
Merge pull request #138 from sinch/v1.2-next
Browse files Browse the repository at this point in the history
Release version 1.2.0
  • Loading branch information
asein-sinch authored Oct 4, 2024
2 parents 2360660 + 9307f0d commit db3c5db
Show file tree
Hide file tree
Showing 283 changed files with 9,816 additions and 1,696 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"ignoreRegExpLiterals": true,
"ignorePattern": "^import.+|test"
}
]
],
"new-cap": "off"
}
}
4 changes: 2 additions & 2 deletions .github/scripts/validate-audit-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ echo '{"vulnerabilities": [' > audit-report.json
awk 'NR > 1 {print ","} {print}' audit-report.txt >> audit-report.json
echo ']}' >> audit-report.json

# Filter JSON array to remove lerna's transitive dependencies as these dependencies are not used at runtime
jq '.vulnerabilities |= map(select(.data.resolution.path | type == "string" and startswith("lerna") | not))' audit-report.json > audit-report-filtered.json
# Filter JSON array to remove jest and lerna's transitive dependencies as these dependencies are not used at runtime
jq '.vulnerabilities |= map(select(.data.resolution.path | type == "string" and (startswith("lerna") or startswith("jest") or startswith("@types/jest") or startswith("babel-jest")) | not))' audit-report.json > audit-report-filtered.json

# Fail the build if filtered JSON array contains audit advisories
if [ "$(jq '.vulnerabilities[] | select(.type == "auditAdvisory") | .type' audit-report-filtered.json | wc -l)" -gt 0 ]; then
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Publish Packages

on:
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'

- name: Authenticate to npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

- name: Install dependencies
run: yarn install

- name: Build packages
run: yarn run build

- name: Run tests
run: yarn run test

- name: Checkout sinch-sdk-mockserver repository
uses: actions/checkout@v3
with:
repository: sinch/sinch-sdk-mockserver
token: ${{ secrets.PAT_CI }}
fetch-depth: 0
path: sinch-sdk-mockserver

- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Start mock servers with Docker Compose
run: |
cd sinch-sdk-mockserver
docker-compose up -d
- name: Create target directories for feature files
run: |
mkdir -p ./packages/fax/tests/e2e/features
mkdir -p ./packages/numbers/tests/e2e/features
mkdir -p ./packages/conversation/tests/e2e/features
mkdir -p ./packages/elastic-sip-trunking/tests/e2e/features
mkdir -p ./packages/sms/tests/e2e/features
mkdir -p ./packages/verification/tests/e2e/features
mkdir -p ./packages/voice/tests/e2e/features
- name: Copy feature files
run: |
cp sinch-sdk-mockserver/features/fax/*.feature ./packages/fax/tests/e2e/features/
cp sinch-sdk-mockserver/features/numbers/*.feature ./packages/numbers/tests/e2e/features/
cp sinch-sdk-mockserver/features/conversation/*.feature ./packages/conversation/tests/e2e/features/
cp sinch-sdk-mockserver/features/elastic-sip-trunking/*.feature ./packages/elastic-sip-trunking/tests/e2e/features/
cp sinch-sdk-mockserver/features/sms/*.feature ./packages/sms/tests/e2e/features/
cp sinch-sdk-mockserver/features/verification/*.feature ./packages/verification/tests/e2e/features/
cp sinch-sdk-mockserver/features/voice/*.feature ./packages/voice/tests/e2e/features/
- name: Run e2e tests
run: yarn run e2e

- name: Publish packages
run: |
cd packages/sdk-client && npm publish
cd ../numbers && npm publish
cd ../sms && npm publish
cd ../verification && npm publish
cd ../voice && npm publish
cd ../conversation && npm publish
cd ../fax && npm publish
cd ../elastic-sip-trunking && npm publish
cd ../sdk-core && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62 changes: 55 additions & 7 deletions .github/workflows/run-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,66 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
- run: npx eslint "packages/**/src/**/*.ts"
- run: npx eslint "packages/**/tests/**/*.ts"
- run: yarn run build
- run: yarn run test

- name: Install dependencies
run: yarn install

- name: Run ESLint
run: npx eslint "packages/**/{src,tests}/**/*.ts"

- name: Build project
run: yarn run build

- name: Run unit tests
run: yarn run test

- name: Checkout sinch-sdk-mockserver repository
uses: actions/checkout@v3
with:
repository: sinch/sinch-sdk-mockserver
token: ${{ secrets.PAT_CI }}
fetch-depth: 0
path: sinch-sdk-mockserver

- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Start mock servers with Docker Compose
run: |
cd sinch-sdk-mockserver
docker-compose up -d
- name: Create target directories for feature files
run: |
mkdir -p ./packages/fax/tests/e2e/features
mkdir -p ./packages/numbers/tests/e2e/features
mkdir -p ./packages/conversation/tests/e2e/features
mkdir -p ./packages/elastic-sip-trunking/tests/e2e/features
mkdir -p ./packages/sms/tests/e2e/features
mkdir -p ./packages/verification/tests/e2e/features
mkdir -p ./packages/voice/tests/e2e/features
- name: Copy feature files
run: |
cp sinch-sdk-mockserver/features/fax/*.feature ./packages/fax/tests/e2e/features/
cp sinch-sdk-mockserver/features/numbers/*.feature ./packages/numbers/tests/e2e/features/
cp sinch-sdk-mockserver/features/conversation/*.feature ./packages/conversation/tests/e2e/features/
cp sinch-sdk-mockserver/features/elastic-sip-trunking/*.feature ./packages/elastic-sip-trunking/tests/e2e/features/
cp sinch-sdk-mockserver/features/sms/*.feature ./packages/sms/tests/e2e/features/
cp sinch-sdk-mockserver/features/verification/*.feature ./packages/verification/tests/e2e/features/
cp sinch-sdk-mockserver/features/voice/*.feature ./packages/voice/tests/e2e/features/
- name: Run e2e tests
run: yarn run e2e

sonarcloud:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ tsconfig.build.tsbuildinfo
tsconfig.tsbuildinfo
packages/**/dist
.env
*.feature
2 changes: 1 addition & 1 deletion examples/integrated-flows-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"verification:app": "yarn compile && node dist/verification/app.js"
},
"dependencies": {
"@sinch/sdk-core": "^1.1.0",
"@sinch/sdk-core": "^1.2.0",
"@types/node": "^20.8.7",
"dotenv": "^16.3.1",
"inquirer": "^9.2.14",
Expand Down
16 changes: 8 additions & 8 deletions examples/integrated-flows-examples/src/numbers/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ dotenv.config();
try {
// Send the HTTP request with the SDK method
availableNumbersResponse
= await sinchClient.numbers.availableNumber.list(listAvailableNumbersRequestData);
= await sinchClient.numbers.searchForAvailableNumbers(listAvailableNumbersRequestData);
} catch (error) {
// Catch error if any, log it and stop the program
console.error(`ERROR: An error occurred when trying to list the available numbers for the type ${type}`);
Expand Down Expand Up @@ -100,7 +100,7 @@ dotenv.config();
let rentNumberResponse;
try {
// Send the HTTP request with the SDK method
rentNumberResponse = await sinchClient.numbers.availableNumber.rent(rentNumberRequestData);
rentNumberResponse = await sinchClient.numbers.rent(rentNumberRequestData);
} catch (error) {
// Catch error if any, log it and stop the program
console.error(`ERROR: Impossible to rent the number ${phoneNumber1}`);
Expand Down Expand Up @@ -129,7 +129,7 @@ dotenv.config();
let rentAnyNumberResponse;
try {
// Send the HTTP request with the SDK method
rentAnyNumberResponse = await sinchClient.numbers.availableNumber.rentAny(rentAnyNumberRequestData);
rentAnyNumberResponse = await sinchClient.numbers.rentAny(rentAnyNumberRequestData);
} catch (error) {
// Catch error if any, log it and stop the program
console.error(`ERROR: Impossible to rent a number in the region ${regionCode} of type ${type}`);
Expand All @@ -152,7 +152,7 @@ dotenv.config();
let getActiveNumberResponse;
try {
// Send the HTTP request with the SDK method
getActiveNumberResponse = await sinchClient.numbers.activeNumber.get(getActiveNumberRequestData);
getActiveNumberResponse = await sinchClient.numbers.get(getActiveNumberRequestData);
} catch (error) {
// Catch error if any, log it and stop the program
console.error(`ERROR: Impossible to get details for the number ${phoneNumber1}`);
Expand All @@ -172,7 +172,7 @@ dotenv.config();

// The ActiveNumbersResponse is paginated. Let's fetch all the pages using the iterator functionality
const activeNumbersList: Numbers.ActiveNumber[] = [];
for await (const activeNumber of sinchClient.numbers.activeNumber.list(listActiveNumbersRequestData)) {
for await (const activeNumber of sinchClient.numbers.list(listActiveNumbersRequestData)) {
activeNumbersList.push(activeNumber);
}

Expand Down Expand Up @@ -201,7 +201,7 @@ dotenv.config();
try {
// Send the HTTP request with the SDK method
updateActiveNumberResponse
= await sinchClient.numbers.activeNumber.update(updateActiveNumberRequestData);
= await sinchClient.numbers.update(updateActiveNumberRequestData);
} catch (error) {
// Catch error if any, log it and stop the program
console.log(`ERROR: Impossible to update the number ${phoneNumber1}`);
Expand All @@ -222,7 +222,7 @@ dotenv.config();
let releaseActiveNumberResponse;
try {
// Send the HTTP request with the SDK method
releaseActiveNumberResponse = await sinchClient.numbers.activeNumber.release(releaseActiveNumberRequestData);
releaseActiveNumberResponse = await sinchClient.numbers.release(releaseActiveNumberRequestData);
} catch (error) {
// Catch error if any, log it and stop the program
console.error(`ERROR: Impossible to release the number ${phoneNumber1}`);
Expand All @@ -241,7 +241,7 @@ dotenv.config();

try {
// Send the HTTP request with the SDK method
releaseActiveNumberResponse = await sinchClient.numbers.activeNumber.release(releaseActiveNumberRequestData);
releaseActiveNumberResponse = await sinchClient.numbers.release(releaseActiveNumberRequestData);
} catch (error) {
// Catch error if any, log it and stop the program
console.error(`ERROR: Impossible to release the number ${phoneNumber2}`);
Expand Down
24 changes: 12 additions & 12 deletions examples/integrated-flows-examples/src/verification/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ dotenv.config();

enum VerificationMethods {
SMS ='sms',
CALLOUT = 'callout',
PHONE_CALL = 'phone call',
FLASH_CALL = 'flash call',
SEAMLESS = 'seamless',
DATA = 'data',
}

inquirer.prompt([
Expand All @@ -41,13 +41,13 @@ dotenv.config();
case VerificationMethods.SMS:
startSmsVerificationFlow(answers.phoneNumber);
break;
case VerificationMethods.CALLOUT:
startCalloutVerificationFlow(answers.phoneNumber);
case VerificationMethods.PHONE_CALL:
startPhoneCallVerificationFlow(answers.phoneNumber);
break;
case VerificationMethods.FLASH_CALL:
startFlashCallVerificationFlow(answers.phoneNumber);
break;
case VerificationMethods.SEAMLESS:
case VerificationMethods.DATA:
startSeamlessVerificationFlow(answers.phoneNumber);
break;
}
Expand All @@ -72,9 +72,9 @@ dotenv.config();

};

const startCalloutVerificationFlow = async (phoneNumber: string) => {
const requestData = Verification.startVerificationHelper.buildCalloutRequest(phoneNumber);
const response = await sinch.verification.verifications.startCallout(requestData);
const startPhoneCallVerificationFlow = async (phoneNumber: string) => {
const requestData = Verification.startVerificationHelper.buildPhoneCallRequest(phoneNumber);
const response = await sinch.verification.verifications.startPhoneCall(requestData);
console.log('Verification request sent! Please answer to the phone call ans listen to the OTP.');
const answers = await inquirer.prompt([
{
Expand All @@ -83,9 +83,9 @@ dotenv.config();
message: 'Enter the verification code:',
},
]);
const reportRequestData = Verification.reportVerificationByIdHelper.buildCalloutRequest(
const reportRequestData = Verification.reportVerificationByIdHelper.buildPhoneCallRequest(
response.id!, answers.code);
const reportResponse = await sinch.verification.verifications.reportCalloutById(reportRequestData);
const reportResponse = await sinch.verification.verifications.reportPhoneCallById(reportRequestData);
console.log(`Verification status: ${reportResponse.status}${reportResponse.status === 'SUCCESSFUL'?'':' - Reason: ' + reportResponse.reason}`);
};

Expand All @@ -109,10 +109,10 @@ dotenv.config();
};

const startSeamlessVerificationFlow = async (phoneNumber: string) => {
const requestData = Verification.startVerificationHelper.buildSeamlessRequest(phoneNumber);
const requestData = Verification.startVerificationHelper.buildDataRequest(phoneNumber);
let response;
try {
response = await sinch.verification.verifications.startSeamless(requestData);
response = await sinch.verification.verifications.startData(requestData);
} catch (error: any) {
console.log(`Impossible to process the seamless verification: ${error.data})`);
return;
Expand Down
3 changes: 2 additions & 1 deletion examples/simple-examples/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
.DS_Store

.env
fax-pdf/
fax-pdf/*
!fax-pdf/you-faxed.pdf
Loading

0 comments on commit db3c5db

Please sign in to comment.