1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-06-25 00:46:45 +02:00

Main build (Jenkins)

This commit is contained in:
Vitaly the Alpaca (bot)
2025-01-29 23:01:38 +03:00
parent 8de3153cb8
commit ecbb7f4cf5
23 changed files with 6873 additions and 6389 deletions

View File

@ -1405,9 +1405,51 @@ jobs:
key: logs-TCP key: logs-TCP
path: ./docs/en/results/TCP path: ./docs/en/results/TCP
Testing-Proxy:
runs-on: ubuntu-latest
needs: [Decode, Build]
steps:
- uses: actions/checkout@v2
- uses: otymko/setup-onescript@v1.4
with:
version: 1.9.1
- name: Получить тестовые данные из кэша
uses: actions/cache/restore@v3
with:
key: test-data
path: ./data.json
- name: Установить asserts и 1testrunner
run: |
opm install asserts
opm install 1testrunner
- name: Установить OInt
run: |
TEMP_DEB="$(mktemp)" &&
wget -O "$TEMP_DEB" 'https://api.athenaeum.digital/tc/job/Release/lastSuccessfulBuild/artifact/1.18.0/oint_1.18.0_all_en.deb' &&
sudo dpkg -i "$TEMP_DEB"
rm -f "$TEMP_DEB"
- name: Project setup
if: ${{ cancelled() }} == false
run: oscript /home/runner/.local/share/ovm/current/lib/1testrunner/src/main.os -run ./src/en/OInt/tests/Modules/internal/OPI_TestsCLI.os "CLI_Proxy_ProjectSetup"
- name: Записать логи
if: ${{ cancelled() }} == false
uses: actions/cache/save@v3
with:
key: logs-Proxy
path: ./docs/en/results/Proxy
Encode: Encode:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [Testing-Telegram,Testing-VK,Testing-Viber,Testing-Twitter,Testing-SQLite,Testing-YandexDisk,Testing-GoogleWorkspace,Testing-GoogleCalendar,Testing-GoogleDrive,Testing-GoogleSheets,Testing-Notion,Testing-Slack,Testing-Airtable,Testing-Dropbox,Testing-Bitrix24,Testing-VkTeams,Testing-Ozon,Testing-Neocities,Testing-CDEK,Testing-YandexMetrika,Testing-S3,Testing-TCP] needs: [Testing-Telegram,Testing-VK,Testing-Viber,Testing-Twitter,Testing-SQLite,Testing-YandexDisk,Testing-GoogleWorkspace,Testing-GoogleCalendar,Testing-GoogleDrive,Testing-GoogleSheets,Testing-Notion,Testing-Slack,Testing-Airtable,Testing-Dropbox,Testing-Bitrix24,Testing-VkTeams,Testing-Ozon,Testing-Neocities,Testing-CDEK,Testing-YandexMetrika,Testing-S3,Testing-TCP,Testing-Proxy]
if: ${{ always() }} if: ${{ always() }}
permissions: permissions:
contents: write contents: write
@ -1787,6 +1829,22 @@ jobs:
-H "X-GitHub-Api-Version: 2022-11-28" \ -H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/Bayselonarrend/OpenIntegrations/actions/caches?key=logs-TCP" "https://api.github.com/repos/Bayselonarrend/OpenIntegrations/actions/caches?key=logs-TCP"
- name: Получить логи Proxy
uses: actions/cache/restore@v3
with:
key: logs-Proxy
path: ./docs/en/results/Proxy
- name: Очистка логов Proxy
run: |
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/Bayselonarrend/OpenIntegrations/actions/caches?key=logs-Proxy"
- name: Записать данные - name: Записать данные
uses: stefanzweifel/git-auto-commit-action@v5 uses: stefanzweifel/git-auto-commit-action@v5
@ -1799,7 +1857,7 @@ jobs:
Clear-Cache: Clear-Cache:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [Testing-Telegram, Testing-VK, Testing-Viber, Testing-Twitter, Testing-SQLite, Testing-YandexDisk, Testing-GoogleWorkspace, Testing-GoogleCalendar, Testing-GoogleDrive, Testing-GoogleSheets, Testing-Notion, Testing-Slack, Testing-Airtable, Testing-Dropbox, Testing-Bitrix24, Testing-VkTeams, Testing-Ozon, Testing-Neocities, Testing-CDEK, Testing-YandexMetrika, Testing-S3, Testing-TCP, Encode] needs: [Testing-Telegram, Testing-VK, Testing-Viber, Testing-Twitter, Testing-SQLite, Testing-YandexDisk, Testing-GoogleWorkspace, Testing-GoogleCalendar, Testing-GoogleDrive, Testing-GoogleSheets, Testing-Notion, Testing-Slack, Testing-Airtable, Testing-Dropbox, Testing-Bitrix24, Testing-VkTeams, Testing-Ozon, Testing-Neocities, Testing-CDEK, Testing-YandexMetrika, Testing-S3, Testing-TCP, Testing-Proxy, Encode]
if: ${{ always() }} if: ${{ always() }}
steps: steps:
- name: Очистка основного кэша - name: Очистка основного кэша

11
ci/cli_ostesten vendored
View File

@ -694,6 +694,17 @@ pipeline {
} }
} }
stage('Testing-Proxy') {
steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
powershell encoding: 'UTF-8', script:'1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_TestsCLI.os" "CLI_Proxy_ProjectSetup"'
}
}
}
} }
post{ post{
always{ always{

10
ci/clitesten vendored
View File

@ -1426,7 +1426,15 @@ def test_proxy(){
} }
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
powershell encoding: 'UTF-8', script:'./oint.exe proxy AddRequestsHandler --proj "test" --name "test" --secret "test" --method "test" --debug --test ' powershell encoding: 'UTF-8', script:'./oint.exe proxy AddRequestsHandler --proj "test" --func "test" --method "test" --debug --test '
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
powershell encoding: 'UTF-8', script:'./oint.exe proxy GetRequestHandlersList --proj "test" --debug --test '
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
powershell encoding: 'UTF-8', script:'./oint.exe proxy DeleteRequestHandler --proj "test" --handler "test" --debug --test '
} }
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {

10
ci/clitestru vendored
View File

@ -2864,7 +2864,15 @@ def test_proxy(){
} }
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
powershell encoding: 'UTF-8', script:'./oint.exe proxy ДобавитьОбработчикЗапросов --proj "test" --name "test" --secret "test" --method "test" --debug --test ' powershell encoding: 'UTF-8', script:'./oint.exe proxy ДобавитьОбработчикЗапросов --proj "test" --func "test" --method "test" --debug --test '
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
powershell encoding: 'UTF-8', script:'./oint.exe proxy ПолучитьСписокОбработчиковЗапросов --proj "test" --debug --test '
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
powershell encoding: 'UTF-8', script:'./oint.exe proxy УдалитьОбработчикЗапросов --proj "test" --handler "test" --debug --test '
} }
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {

11
ci/ostesten vendored
View File

@ -694,6 +694,17 @@ pipeline {
} }
} }
stage('Testing-Proxy') {
steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
powershell encoding: 'UTF-8', script:'1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "Proxy_ProjectSetup"'
}
}
}
} }
post{ post{
always{ always{

View File

@ -10,17 +10,16 @@ import TabItem from '@theme/TabItem';
`Function AddRequestsHandler(Val Project, Val Name, Val SecretKey, Val Method = "GET") Export` `Function AddRequestsHandler(Val Project, Val OintFunction, Val Method = "GET") Export`
| Parameter | CLI option | Type | Required | Description | | Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-| |-|-|-|-|-|
| Project | --proj | String | ✔ | Project filepath | | Project | --proj | String | ✔ | Project filepath |
| Name | --name | String | ✔ | Name of the new handler | | OintFunction | --func | String | ✔ | OpenIntegrations function name |
| SecretKey | --secret | String | ✔ | Secret key for URL handler |
| Method | --method | String | ✖ | HTTP method that will process the handler: GET, POST, MULTIPART | | Method | --method | String | ✖ | HTTP method that will process the handler: GET, POST, MULTIPART |
Returns: Structure Of KeyAndValue - result of adding a handler Returns: Structure Of KeyAndValue - Result of handler creation
<br/> <br/>

View File

@ -17,7 +17,7 @@ import TabItem from '@theme/TabItem';
| Path | --path | String | &#x2714; | Project filepath | | Path | --path | String | &#x2714; | Project filepath |
Returns: Structure Of KeyAndValue - creation result Returns: Structure Of KeyAndValue - Creation result
<br/> <br/>

View File

@ -0,0 +1,35 @@
---
sidebar_position: 4
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Delete request handler
Removes the request handler from the project
`Function DeleteRequestHandler(Val Project, Val HandlerKey) Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Project | --proj | String | &#x2714; | Project filepath |
| HandlerKey | --handler | String | &#x2714; | Handler key |
Returns: Structure Of KeyAndValue - Deletion result
<br/>
```bsl title="1C:Enterprise/OneScript code example"
```

View File

@ -0,0 +1,34 @@
---
sidebar_position: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Get the list of request handlers
Gets the list of handlers in the project
`Function GetRequestHandlersList(Val Project) Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Project | --proj | String | &#x2714; | Project filepath |
Returns: Structure Of KeyAndValue - Handlers list
<br/>
```bsl title="1C:Enterprise/OneScript code example"
```

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 3 sidebar_position: 5
--- ---
import Tabs from '@theme/Tabs'; import Tabs from '@theme/Tabs';
@ -18,7 +18,7 @@ import TabItem from '@theme/TabItem';
| Project | --proj | String | &#x2714; | Project filepath | | Project | --proj | String | &#x2714; | Project filepath |
Returns: Structure Of KeyAndValue - server shutdown result Returns: Structure Of KeyAndValue - Result of server shutdown
<br/> <br/>

View File

@ -10,17 +10,16 @@ import TabItem from '@theme/TabItem';
`Функция ДобавитьОбработчикЗапросов(Знач Проект, Знач Имя, Знач СекретныйКлюч, Знач Метод = "GET") Экспорт` `Функция ДобавитьОбработчикЗапросов(Знач Проект, Знач ФункцияОПИ, Знач Метод = "GET") Экспорт`
| Параметр | CLI опция | Тип | Обяз. | Назначение | | Параметр | CLI опция | Тип | Обяз. | Назначение |
|-|-|-|-|-| |-|-|-|-|-|
| Проект | --proj | Строка | &#x2714; | Путь к файлу проекта | | Проект | --proj | Строка | &#x2714; | Путь к файлу проекта |
| Имя | --name | Строка | &#x2714; | Имя нового обработчика | | ФункцияОПИ | --func | Строка | &#x2714; | Имя функции Открытого пакета интеграций |
| СекретныйКлюч | --secret | Строка | &#x2714; | Секретный ключ для URL обработчика |
| Метод | --method | Строка | &#x2716; | HTTP метод, который будет обрабатывать обработчик: GET, POST, MULTIPART | | Метод | --method | Строка | &#x2716; | HTTP метод, который будет обрабатывать обработчик: GET, POST, MULTIPART |
Возвращаемое значение: Структура Из КлючИЗначение - результат добавления обработчика Возвращаемое значение: Структура Из КлючИЗначение - Результат добавления обработчика
<br/> <br/>

View File

@ -17,7 +17,7 @@ import TabItem from '@theme/TabItem';
| Путь | --path | Строка | &#x2714; | Путь к файлу проекта | | Путь | --path | Строка | &#x2714; | Путь к файлу проекта |
Возвращаемое значение: Структура Из КлючИЗначение - результат создания Возвращаемое значение: Структура Из КлючИЗначение - Результат создания
<br/> <br/>

View File

@ -0,0 +1,35 @@
---
sidebar_position: 4
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Удалить обработчик запросов
Удаляет обработчик запросов из проекта
`Функция УдалитьОбработчикЗапросов(Знач Проект, Знач КлючОбработчика) Экспорт`
| Параметр | CLI опция | Тип | Обяз. | Назначение |
|-|-|-|-|-|
| Проект | --proj | Строка | &#x2714; | Путь к файлу проекта |
| КлючОбработчика | --handler | Строка | &#x2714; | Ключ обработчика |
Возвращаемое значение: Структура Из КлючИЗначение - Результат удаления
<br/>
```bsl title="Пример использования для 1С:Предприятие/OneScript"
```

View File

@ -0,0 +1,34 @@
---
sidebar_position: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Получить список обработчиков запросов
Получает список обработчиков в проекте
`Функция ПолучитьСписокОбработчиковЗапросов(Знач Проект) Экспорт`
| Параметр | CLI опция | Тип | Обяз. | Назначение |
|-|-|-|-|-|
| Проект | --proj | Строка | &#x2714; | Путь к файлу проекта |
Возвращаемое значение: Структура Из КлючИЗначение - Список обработчиков
<br/>
```bsl title="Пример использования для 1С:Предприятие/OneScript"
```

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 3 sidebar_position: 5
--- ---
import Tabs from '@theme/Tabs'; import Tabs from '@theme/Tabs';
@ -18,7 +18,7 @@ import TabItem from '@theme/TabItem';
| Проект | --proj | Строка | &#x2714; | Путь к файлу проекта | | Проект | --proj | Строка | &#x2714; | Путь к файлу проекта |
Возвращаемое значение: Структура Из КлючИЗначение - результат остановки сервера Возвращаемое значение: Структура Из КлючИЗначение - Результат остановки сервера
<br/> <br/>

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@
// Path - String - Project filepath - path // Path - String - Project filepath - path
// //
// Returns: // Returns:
// Structure Of KeyAndValue - creation result // Structure Of KeyAndValue - Creation result
Function CreateProject(Val Path) Export Function CreateProject(Val Path) Export
Return NormalizeProject(Path); Return NormalizeProject(Path);
@ -65,16 +65,14 @@ EndFunction
// //
// Parameters: // Parameters:
// Project - String - Project filepath - proj // Project - String - Project filepath - proj
// Name - String - Name of the new handler - name // OintFunction - String - OpenIntegrations function name - func
// SecretKey - String - Secret key for URL handler - secret
// Method - String - HTTP method that will process the handler: GET, POST, MULTIPART - method // Method - String - HTTP method that will process the handler: GET, POST, MULTIPART - method
// //
// Returns: // Returns:
// Structure Of KeyAndValue - result of adding a handler // Structure Of KeyAndValue - Result of handler creation
Function AddRequestsHandler(Val Project, Val Name, Val SecretKey, Val Method = "GET") Export Function AddRequestsHandler(Val Project, Val OintFunction, Val Method = "GET") Export
OPI_TypeConversion.GetLine(Name); OPI_TypeConversion.GetLine(OintFunction);
OPI_TypeConversion.GetLine(SecretKey);
OPI_TypeConversion.GetLine(Method); OPI_TypeConversion.GetLine(Method);
Result = CheckProjectExistence(Project); Result = CheckProjectExistence(Project);
@ -85,11 +83,77 @@ Function AddRequestsHandler(Val Project, Val Name, Val SecretKey, Val Method = "
Project = Result["path"]; Project = Result["path"];
EndIf; EndIf;
DataArray = New Array; SecretKey = GetHandlerUniqueKey(Project);
DataArray.Add(New Structure("name,secret,method", Name, SecretKey, Method));
If TypeOf(SecretKey) = Type("Structure") Then
SecretKey.Insert("message", "Failed to generate a handler UID. Try again");
Return SecretKey;
EndIf;
RecordStructure = New Structure;
RecordStructure.Insert("function", OintFunction);
RecordStructure.Insert("id" , SecretKey);
RecordStructure.Insert("method" , Method);
RecordStructure.Insert("active" , True);
HandlersTableName = ConstantValue("HandlersTable"); HandlersTableName = ConstantValue("HandlersTable");
Result = OPI_SQLite.AddRecords(HandlersTableName, DataArray, , Project); Result = OPI_SQLite.AddRecords(HandlersTableName, RecordStructure, False, Project);
If Result["result"] Then
Result = New Structure;
Result.Insert("result" , True);
Result.Insert("key" , SecretKey);
Result.Insert("url_example", "localhost:port/" + SecretKey);
EndIf;
Return Result;
EndFunction
// Get the list of request handlers
// Gets the list of handlers in the project
//
// Parameters:
// Project - String - Project filepath - proj
//
// Returns:
// Structure Of KeyAndValue - Handlers list
Function GetRequestHandlersList(Val Project) Export
OPI_TypeConversion.GetLine(Project);
Table = ConstantValue("HandlersTable");
Result = OPI_SQLite.GetRecords(Table, , , , , Project);
Return Result;
EndFunction
// Delete request handler
// Removes the request handler from the project
//
// Parameters:
// Project - String - Project filepath - proj
// HandlerKey - String - Handler key - handler
//
// Returns:
// Structure Of KeyAndValue - Deletion result
Function DeleteRequestHandler(Val Project, Val HandlerKey) Export
OPI_TypeConversion.GetLine(HandlerKey);
Table = ConstantValue("HandlersTable");
FilterStructure = New Structure;
FilterStructure.Insert("field", "id");
FilterStructure.Insert("type" , "=");
FilterStructure.Insert("value", HandlerKey);
FilterStructure.Insert("raw" , False);
Result = OPI_SQLite.DeletePosts(Table, FilterStructure, Project);
Return Result; Return Result;
@ -102,7 +166,7 @@ EndFunction
// Port - Number - Servers port - port // Port - Number - Servers port - port
// Project - String - Project filepath - proj // Project - String - Project filepath - proj
// Returns: // Returns:
// Structure Of KeyAndValue - server shutdown result // Structure Of KeyAndValue - Result of server shutdown
Function Start(Val Port, Val Project) Export Function Start(Val Port, Val Project) Export
OPI_TypeConversion.GetNumber(Port); OPI_TypeConversion.GetNumber(Port);
@ -228,6 +292,7 @@ Function CreateNewProject(Path)
If Not Result["result"] Then If Not Result["result"] Then
DeleteFiles(Path); DeleteFiles(Path);
Return Result;
EndIf; EndIf;
Return Result; Return Result;
@ -237,10 +302,10 @@ EndFunction
Function CreateHandlersTable(Path) Function CreateHandlersTable(Path)
TableStructure = New Structure(); TableStructure = New Structure();
TableStructure.Insert("id" , "INTEGER PRIMARY KEY"); TableStructure.Insert("id" , "TEXT PRIMARY KEY NOT NULL UNIQUE");
TableStructure.Insert("name" , "TEXT"); TableStructure.Insert("function", "TEXT");
TableStructure.Insert("secret", "TEXT");
TableStructure.Insert("method" , "TEXT"); TableStructure.Insert("method" , "TEXT");
TableStructure.Insert("active" , "BOOLEAN");
HandlersTableName = ConstantValue("HandlersTable"); HandlersTableName = ConstantValue("HandlersTable");
Result = OPI_SQLite.CreateTable(HandlersTableName, TableStructure, Path); Result = OPI_SQLite.CreateTable(HandlersTableName, TableStructure, Path);
@ -249,6 +314,45 @@ Function CreateHandlersTable(Path)
EndFunction EndFunction
Function GetHandlerUniqueKey(Path)
SecretKey = GetUUID(9);
Table = ConstantValue("HandlersTable");
FilterStructure = New Structure;
FilterStructure.Insert("field", "id");
FilterStructure.Insert("type" , "=");
FilterStructure.Insert("value", SecretKey);
FilterStructure.Insert("raw" , False);
Result = OPI_SQLite.GetRecords(Table, , FilterStructure, , , Path);
If Not Result["result"] Then
Return Result;
EndIf;
While Result["data"].Count() > 0 Do
SecretKey = GetUUID(9);
FilterStructure["value"] = SecretKey;
Result = OPI_SQLite.GetRecords(Table, , FilterStructure, , , Path);
If Not Result["result"] Then
Return Result;
EndIf;
EndDo;
Return SecretKey;
EndFunction
Function GetUUID(Val Length)
Return Left(StrReplace(String(New UUID), "-", ""), Length);
EndFunction
#EndRegion #EndRegion
#Region Handlers #Region Handlers

View File

@ -53,7 +53,7 @@
// Path - String - Project filepath - path // Path - String - Project filepath - path
// //
// Returns: // Returns:
// Structure Of KeyAndValue - creation result // Structure Of KeyAndValue - Creation result
Function CreateProject(Val Path) Export Function CreateProject(Val Path) Export
Return NormalizeProject(Path); Return NormalizeProject(Path);
@ -65,16 +65,14 @@ EndFunction
// //
// Parameters: // Parameters:
// Project - String - Project filepath - proj // Project - String - Project filepath - proj
// Name - String - Name of the new handler - name // OintFunction - String - OpenIntegrations function name - func
// SecretKey - String - Secret key for URL handler - secret
// Method - String - HTTP method that will process the handler: GET, POST, MULTIPART - method // Method - String - HTTP method that will process the handler: GET, POST, MULTIPART - method
// //
// Returns: // Returns:
// Structure Of KeyAndValue - result of adding a handler // Structure Of KeyAndValue - Result of handler creation
Function AddRequestsHandler(Val Project, Val Name, Val SecretKey, Val Method = "GET") Export Function AddRequestsHandler(Val Project, Val OintFunction, Val Method = "GET") Export
OPI_TypeConversion.GetLine(Name); OPI_TypeConversion.GetLine(OintFunction);
OPI_TypeConversion.GetLine(SecretKey);
OPI_TypeConversion.GetLine(Method); OPI_TypeConversion.GetLine(Method);
Result = CheckProjectExistence(Project); Result = CheckProjectExistence(Project);
@ -85,11 +83,77 @@ Function AddRequestsHandler(Val Project, Val Name, Val SecretKey, Val Method = "
Project = Result["path"]; Project = Result["path"];
EndIf; EndIf;
DataArray = New Array; SecretKey = GetHandlerUniqueKey(Project);
DataArray.Add(New Structure("name,secret,method", Name, SecretKey, Method));
If TypeOf(SecretKey) = Type("Structure") Then
SecretKey.Insert("message", "Failed to generate a handler UID. Try again");
Return SecretKey;
EndIf;
RecordStructure = New Structure;
RecordStructure.Insert("function", OintFunction);
RecordStructure.Insert("id" , SecretKey);
RecordStructure.Insert("method" , Method);
RecordStructure.Insert("active" , True);
HandlersTableName = ConstantValue("HandlersTable"); HandlersTableName = ConstantValue("HandlersTable");
Result = OPI_SQLite.AddRecords(HandlersTableName, DataArray, , Project); Result = OPI_SQLite.AddRecords(HandlersTableName, RecordStructure, False, Project);
If Result["result"] Then
Result = New Structure;
Result.Insert("result" , True);
Result.Insert("key" , SecretKey);
Result.Insert("url_example", "localhost:port/" + SecretKey);
EndIf;
Return Result;
EndFunction
// Get the list of request handlers
// Gets the list of handlers in the project
//
// Parameters:
// Project - String - Project filepath - proj
//
// Returns:
// Structure Of KeyAndValue - Handlers list
Function GetRequestHandlersList(Val Project) Export
OPI_TypeConversion.GetLine(Project);
Table = ConstantValue("HandlersTable");
Result = OPI_SQLite.GetRecords(Table, , , , , Project);
Return Result;
EndFunction
// Delete request handler
// Removes the request handler from the project
//
// Parameters:
// Project - String - Project filepath - proj
// HandlerKey - String - Handler key - handler
//
// Returns:
// Structure Of KeyAndValue - Deletion result
Function DeleteRequestHandler(Val Project, Val HandlerKey) Export
OPI_TypeConversion.GetLine(HandlerKey);
Table = ConstantValue("HandlersTable");
FilterStructure = New Structure;
FilterStructure.Insert("field", "id");
FilterStructure.Insert("type" , "=");
FilterStructure.Insert("value", HandlerKey);
FilterStructure.Insert("raw" , False);
Result = OPI_SQLite.DeletePosts(Table, FilterStructure, Project);
Return Result; Return Result;
@ -102,7 +166,7 @@ EndFunction
// Port - Number - Servers port - port // Port - Number - Servers port - port
// Project - String - Project filepath - proj // Project - String - Project filepath - proj
// Returns: // Returns:
// Structure Of KeyAndValue - server shutdown result // Structure Of KeyAndValue - Result of server shutdown
Function Start(Val Port, Val Project) Export Function Start(Val Port, Val Project) Export
OPI_TypeConversion.GetNumber(Port); OPI_TypeConversion.GetNumber(Port);
@ -228,6 +292,7 @@ Function CreateNewProject(Path)
If Not Result["result"] Then If Not Result["result"] Then
DeleteFiles(Path); DeleteFiles(Path);
Return Result;
EndIf; EndIf;
Return Result; Return Result;
@ -237,10 +302,10 @@ EndFunction
Function CreateHandlersTable(Path) Function CreateHandlersTable(Path)
TableStructure = New Structure(); TableStructure = New Structure();
TableStructure.Insert("id" , "INTEGER PRIMARY KEY"); TableStructure.Insert("id" , "TEXT PRIMARY KEY NOT NULL UNIQUE");
TableStructure.Insert("name" , "TEXT"); TableStructure.Insert("function", "TEXT");
TableStructure.Insert("secret", "TEXT");
TableStructure.Insert("method" , "TEXT"); TableStructure.Insert("method" , "TEXT");
TableStructure.Insert("active" , "BOOLEAN");
HandlersTableName = ConstantValue("HandlersTable"); HandlersTableName = ConstantValue("HandlersTable");
Result = OPI_SQLite.CreateTable(HandlersTableName, TableStructure, Path); Result = OPI_SQLite.CreateTable(HandlersTableName, TableStructure, Path);
@ -249,6 +314,45 @@ Function CreateHandlersTable(Path)
EndFunction EndFunction
Function GetHandlerUniqueKey(Path)
SecretKey = GetUUID(9);
Table = ConstantValue("HandlersTable");
FilterStructure = New Structure;
FilterStructure.Insert("field", "id");
FilterStructure.Insert("type" , "=");
FilterStructure.Insert("value", SecretKey);
FilterStructure.Insert("raw" , False);
Result = OPI_SQLite.GetRecords(Table, , FilterStructure, , , Path);
If Not Result["result"] Then
Return Result;
EndIf;
While Result["data"].Count() > 0 Do
SecretKey = GetUUID(9);
FilterStructure["value"] = SecretKey;
Result = OPI_SQLite.GetRecords(Table, , FilterStructure, , , Path);
If Not Result["result"] Then
Return Result;
EndIf;
EndDo;
Return SecretKey;
EndFunction
Function GetUUID(Val Length)
Return Left(StrReplace(String(New UUID), "-", ""), Length);
EndFunction
#EndRegion #EndRegion
#Region Handlers #Region Handlers

View File

@ -37,18 +37,8 @@
NewLine.Модуль = "OPI_IntegrationProxy"; NewLine.Модуль = "OPI_IntegrationProxy";
NewLine.Метод = "AddRequestsHandler"; NewLine.Метод = "AddRequestsHandler";
NewLine.МетодПоиска = "ADDREQUESTSHANDLER"; NewLine.МетодПоиска = "ADDREQUESTSHANDLER";
NewLine.Параметр = "--name"; NewLine.Параметр = "--func";
NewLine.Описание = "Name of the new handler"; NewLine.Описание = "OpenIntegrations function name";
NewLine.Область = "Project setup";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "proxy";
NewLine.Модуль = "OPI_IntegrationProxy";
NewLine.Метод = "AddRequestsHandler";
NewLine.МетодПоиска = "ADDREQUESTSHANDLER";
NewLine.Параметр = "--secret";
NewLine.Описание = "Secret key for URL handler";
NewLine.Область = "Project setup"; NewLine.Область = "Project setup";
@ -62,6 +52,38 @@
NewLine.Область = "Project setup"; NewLine.Область = "Project setup";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "proxy";
NewLine.Модуль = "OPI_IntegrationProxy";
NewLine.Метод = "GetRequestHandlersList";
NewLine.МетодПоиска = "GETREQUESTHANDLERSLIST";
NewLine.Параметр = "--proj";
NewLine.Описание = "Project filepath";
NewLine.Область = "Project setup";
NewLine.ОписаниеМетода = "Gets the list of handlers in the project";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "proxy";
NewLine.Модуль = "OPI_IntegrationProxy";
NewLine.Метод = "DeleteRequestHandler";
NewLine.МетодПоиска = "DELETEREQUESTHANDLER";
NewLine.Параметр = "--proj";
NewLine.Описание = "Project filepath";
NewLine.Область = "Project setup";
NewLine.ОписаниеМетода = "Removes the request handler from the project";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "proxy";
NewLine.Модуль = "OPI_IntegrationProxy";
NewLine.Метод = "DeleteRequestHandler";
NewLine.МетодПоиска = "DELETEREQUESTHANDLER";
NewLine.Параметр = "--handler";
NewLine.Описание = "Handler key";
NewLine.Область = "Project setup";
NewLine = CompositionTable.Add(); NewLine = CompositionTable.Add();
NewLine.Библиотека = "proxy"; NewLine.Библиотека = "proxy";
NewLine.Модуль = "OPI_IntegrationProxy"; NewLine.Модуль = "OPI_IntegrationProxy";

View File

@ -132,7 +132,7 @@
КонецФункции КонецФункции
// Удалить обработчик запросов // Удалить обработчик запросов
// Удаляет обработчик запросов из базы // Удаляет обработчик запросов из проекта
// //
// Параметры: // Параметры:
// Проект - Строка - Путь к файлу проекта - proj // Проект - Строка - Путь к файлу проекта - proj

View File

@ -37,18 +37,8 @@
НоваяСтрока.Модуль = "OPI_ПроксиИнтеграций"; НоваяСтрока.Модуль = "OPI_ПроксиИнтеграций";
НоваяСтрока.Метод = "ДобавитьОбработчикЗапросов"; НоваяСтрока.Метод = "ДобавитьОбработчикЗапросов";
НоваяСтрока.МетодПоиска = "ДОБАВИТЬОБРАБОТЧИКЗАПРОСОВ"; НоваяСтрока.МетодПоиска = "ДОБАВИТЬОБРАБОТЧИКЗАПРОСОВ";
НоваяСтрока.Параметр = "--name"; НоваяСтрока.Параметр = "--func";
НоваяСтрока.Описание = "Имя нового обработчика"; НоваяСтрока.Описание = "Имя функции Открытого пакета интеграций";
НоваяСтрока.Область = "Настройка проектов";
НоваяСтрока = ТаблицаСостава.Добавить();
НоваяСтрока.Библиотека = "proxy";
НоваяСтрока.Модуль = "OPI_ПроксиИнтеграций";
НоваяСтрока.Метод = "ДобавитьОбработчикЗапросов";
НоваяСтрока.МетодПоиска = "ДОБАВИТЬОБРАБОТЧИКЗАПРОСОВ";
НоваяСтрока.Параметр = "--secret";
НоваяСтрока.Описание = "Секретный ключ для URL обработчика";
НоваяСтрока.Область = "Настройка проектов"; НоваяСтрока.Область = "Настройка проектов";
@ -62,6 +52,38 @@
НоваяСтрока.Область = "Настройка проектов"; НоваяСтрока.Область = "Настройка проектов";
НоваяСтрока = ТаблицаСостава.Добавить();
НоваяСтрока.Библиотека = "proxy";
НоваяСтрока.Модуль = "OPI_ПроксиИнтеграций";
НоваяСтрока.Метод = "ПолучитьСписокОбработчиковЗапросов";
НоваяСтрока.МетодПоиска = "ПОЛУЧИТЬСПИСОКОБРАБОТЧИКОВЗАПРОСОВ";
НоваяСтрока.Параметр = "--proj";
НоваяСтрока.Описание = "Путь к файлу проекта";
НоваяСтрока.Область = "Настройка проектов";
НоваяСтрока.ОписаниеМетода = "Получает список обработчиков в проекте";
НоваяСтрока = ТаблицаСостава.Добавить();
НоваяСтрока.Библиотека = "proxy";
НоваяСтрока.Модуль = "OPI_ПроксиИнтеграций";
НоваяСтрока.Метод = "УдалитьОбработчикЗапросов";
НоваяСтрока.МетодПоиска = "УДАЛИТЬОБРАБОТЧИКЗАПРОСОВ";
НоваяСтрока.Параметр = "--proj";
НоваяСтрока.Описание = "Путь к файлу проекта";
НоваяСтрока.Область = "Настройка проектов";
НоваяСтрока.ОписаниеМетода = "Удаляет обработчик запросов из проекта";
НоваяСтрока = ТаблицаСостава.Добавить();
НоваяСтрока.Библиотека = "proxy";
НоваяСтрока.Модуль = "OPI_ПроксиИнтеграций";
НоваяСтрока.Метод = "УдалитьОбработчикЗапросов";
НоваяСтрока.МетодПоиска = "УДАЛИТЬОБРАБОТЧИКЗАПРОСОВ";
НоваяСтрока.Параметр = "--handler";
НоваяСтрока.Описание = "Ключ обработчика";
НоваяСтрока.Область = "Настройка проектов";
НоваяСтрока = ТаблицаСостава.Добавить(); НоваяСтрока = ТаблицаСостава.Добавить();
НоваяСтрока.Библиотека = "proxy"; НоваяСтрока.Библиотека = "proxy";
НоваяСтрока.Модуль = "OPI_ПроксиИнтеграций"; НоваяСтрока.Модуль = "OPI_ПроксиИнтеграций";