diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 027f1fd2..433d71ae 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -50,6 +50,8 @@ body: label: Версия DLE options: - "20.0" + - "19.x" + - "18.x" - "17.x" - "16.x" validations: diff --git a/.github/workflows/composer-check.yml b/.github/workflows/composer-check.yml index bd4b8a35..b372f18f 100644 --- a/.github/workflows/composer-check.yml +++ b/.github/workflows/composer-check.yml @@ -1,7 +1,7 @@ -<<<<<<< New base: Update README.md name: Composer check on: + workflow_dispatch: pull_request: paths: - 'upload/api/composer.json' @@ -33,52 +33,11 @@ jobs: run: composer validate --no-check-publish --strict - name: Install dependencies - run: composer install --no-dev --no-interaction --prefer-dist --no-progress - - - name: PHP syntax smoke run: | - find . -name '*.php' -not -path './vendor/*' -print0 \ - | xargs -0 -n1 php -l -||||||| -======= -name: Composer check - -on: - pull_request: - paths: - - 'upload/api/composer.json' - - 'upload/api/composer.lock' - - 'upload/api/**/*.php' - - '.github/workflows/composer-check.yml' - push: - paths: - - 'upload/api/composer.json' - - 'upload/api/composer.lock' - -jobs: - composer: - runs-on: ubuntu-latest - defaults: - run: - working-directory: upload/api - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - extensions: json, pdo, simplexml - coverage: none - - - name: Validate composer.json - run: composer validate --no-check-publish --strict - - - name: Install dependencies - run: composer install --no-interaction --prefer-dist --no-progress + rm -rf vendor + composer install --no-dev --no-interaction --prefer-dist --no-progress - name: PHP syntax smoke run: | find . -name '*.php' -not -path './vendor/*' -print0 \ | xargs -0 -n1 php -l ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/.github/workflows/composer-update.yml b/.github/workflows/composer-update.yml index aef37f45..8f8b6e0a 100644 --- a/.github/workflows/composer-update.yml +++ b/.github/workflows/composer-update.yml @@ -31,7 +31,9 @@ jobs: coverage: none - name: Run composer update - run: composer update --no-dev --no-interaction --prefer-dist --no-progress + run: | + rm -rf vendor + composer update --no-dev --no-interaction --prefer-dist --no-progress - name: Open PR if lock file changed uses: peter-evans/create-pull-request@v8 diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 4b773f9e..eea60203 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -1,8 +1,8 @@ -<<<<<<< New base: Update README.md name: Dependabot auto-merge on: pull_request: + workflow_dispatch: permissions: contents: write @@ -27,34 +27,3 @@ jobs: env: PR_URL: ${{ github.event.pull_request.html_url }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} -||||||| -======= -name: Dependabot auto-merge - -on: - pull_request: - -permissions: - contents: write - pull-requests: write - -jobs: - dependabot: - runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'dependabot[bot]' - steps: - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Enable auto-merge for patch and minor - if: | - steps.metadata.outputs.update-type == 'version-update:semver-patch' || - steps.metadata.outputs.update-type == 'version-update:semver-minor' - run: gh pr merge --auto --squash "$PR_URL" - env: - PR_URL: ${{ github.event.pull_request.html_url }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/.github/workflows/openapi.yml b/.github/workflows/openapi.yml index 171991c8..1ba19bd3 100644 --- a/.github/workflows/openapi.yml +++ b/.github/workflows/openapi.yml @@ -32,7 +32,9 @@ jobs: coverage: none - name: Install dependencies - run: composer install --no-dev --no-interaction --prefer-dist --no-progress + run: | + rm -rf vendor + composer install --no-dev --no-interaction --prefer-dist --no-progress - name: Generate openapi.yaml run: composer openapi diff --git a/upload/api/src/Http/V2/Controller/MeController.php b/upload/api/src/Http/V2/Controller/MeController.php index 416f67c8..ba071f2e 100644 --- a/upload/api/src/Http/V2/Controller/MeController.php +++ b/upload/api/src/Http/V2/Controller/MeController.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md payloadBuilder->fromRequest($request)); - } - -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Http/V2/Controller/OauthController.php b/upload/api/src/Http/V2/Controller/OauthController.php index fbe3f241..57949318 100644 --- a/upload/api/src/Http/V2/Controller/OauthController.php +++ b/upload/api/src/Http/V2/Controller/OauthController.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md getQueryParams(), (array) $request->getParsedBody()); - $cred = (string) ($params['credential_type'] ?? ''); - $grant = (string) ($params['grant_type'] ?? ''); - - if($cred !== '') { - $result = match ($cred) { - 'api_key' => $this->tokens->issueByApiKey( - (string) ($params['api_key'] ?? ''), - (string) ($params['scope'] ?? ''), - ), - 'auth' => $this->tokens->issueByAuth( - (string) ($params['username'] ?? ''), - (string) ($params['password'] ?? ''), - (string) ($params['scope'] ?? ''), - ), - 'oauth_client' => $this->tokens->issueByOauthClient( - (string) ($params['client_id'] ?? ''), - (string) ($params['client_secret'] ?? ''), - (string) ($params['scope'] ?? ''), - ), - default => ['error' => 'unsupported_credential_type', 'message' => __('Неподдерживаемый credential_type')], - }; - } else { - $result = match ($grant) { - 'client_credentials' => $this->tokens->issueByOauthClient( - (string) ($params['client_id'] ?? ''), - (string) ($params['client_secret'] ?? ''), - (string) ($params['scope'] ?? ''), - ), - 'authorization_code' => $this->tokens->issueAuthorizationCode( - (string) ($params['client_id'] ?? ''), - (string) ($params['client_secret'] ?? ''), - (string) ($params['code'] ?? ''), - (string) ($params['redirect_uri'] ?? ''), - (string) ($params['code_verifier'] ?? ''), - ), - 'refresh_token' => $this->tokens->refresh((string) ($params['refresh_token'] ?? '')), - 'password' => $this->tokens->issuePassword( - (string) ($params['client_id'] ?? ''), - (string) ($params['client_secret'] ?? ''), - (string) ($params['username'] ?? ''), - (string) ($params['password'] ?? ''), - (string) ($params['scope'] ?? ''), - ), - default => ['error' => 'unsupported_grant_type', 'message' => __('Укажите credential_type или grant_type')], - }; - } - - $status = isset($result['error']) ? 400 : 200; - - return JsonResponder::ok($result, $status); - } - - public function revoke(Request $request, Response $_response): Response { - $body = (array) $request->getParsedBody(); - $this->tokens->revoke((string) ($body['token'] ?? '')); - - return JsonResponder::ok(['revoked' => true]); - } - - public function authorize(Request $request, Response $response): Response { - $q = array_merge($request->getQueryParams(), (array) $request->getParsedBody()); - $clientId = (string) ($q['client_id'] ?? ''); - $redirect = (string) ($q['redirect_uri'] ?? ''); - $state = (string) ($q['state'] ?? ''); - $challenge = (string) ($q['code_challenge'] ?? ''); - $method = (string) ($q['code_challenge_method'] ?? 'S256'); - - global $is_logged, $member_id, $config; - $userId = 0; - if(!empty($is_logged) && is_array($member_id ?? null)) { - $userId = (int) ($member_id['user_id'] ?? 0); - } - - if($clientId === '' || $redirect === '') { - return JsonResponder::error('invalid_request', __('Нужны client_id и redirect_uri'), 400); - } - - $authErr = $this->tokens->validateAuthorizeRequest($clientId, $redirect); - if($authErr !== null) { - return JsonResponder::error($authErr['error'], $authErr['message'], 400); - } - - if($userId < 1) { - $return = (string) $request->getUri(); - if(session_status() === PHP_SESSION_ACTIVE || @session_start()) { - $_SESSION['dleapi_oauth_return'] = $return; - } - $login = rtrim((string) ($config['http_home_url'] ?? '/'), '/') . '/index.php?do=login'; - - return $response->withHeader('Location', $login)->withStatus(302); - } - - $sep = str_contains($redirect, '?') ? '&' : '?'; - if(DleApiConfig::isDemoMode()) { - $loc = $redirect . $sep . http_build_query(array_filter([ - 'error' => 'demo_mode', - 'error_description' => __('Авторизация пройдена, но сброшена в демо-режиме'), - 'authorized' => '1', - 'demo_mode' => '1', - 'state' => $state ?: null, - ])); - - return $response->withHeader('Location', $loc)->withStatus(302); - } - - $code = $this->tokens->createAuthCode($clientId, $userId, $redirect, (string) ($q['scope'] ?? ''), $challenge, $method); - $loc = $redirect . $sep . http_build_query(array_filter(['code' => $code, 'state' => $state ?: null])); - - return $response->withHeader('Location', $loc)->withStatus(302); - } - - public function discovery(Request $_request, Response $_response): Response { - $base = $this->apiBaseUrl(); - - return JsonResponder::ok([ - 'issuer' => $base, - 'authorization_endpoint' => $base . '/oauth/authorize', - 'token_endpoint' => $base . '/oauth/token', - 'revocation_endpoint' => $base . '/oauth/revoke', - 'userinfo_endpoint' => $base . '/oauth/userinfo', - 'response_types_supported' => ['code'], - 'grant_types_supported' => [ - 'authorization_code', - 'refresh_token', - 'client_credentials', - 'password', - ], - 'code_challenge_methods_supported' => ['S256', 'plain'], - 'token_endpoint_auth_methods_supported' => ['client_secret_post', 'client_secret_basic'], - 'credential_types_supported' => ['api_key', 'auth', 'oauth_client'], - ]); - } - - public function userinfo(Request $request, Response $_response): Response { - return (new MeController())->me($request, $_response); - } - - private function apiBaseUrl(): string { - global $config; - $host = rtrim((string) ($config['http_home_url'] ?? ''), '/'); - - return $host . '/api/v2'; - } - -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Http/V2/OAuth/TokenService.php b/upload/api/src/Http/V2/OAuth/TokenService.php index 28f5a6ae..4d66b0c5 100644 --- a/upload/api/src/Http/V2/OAuth/TokenService.php +++ b/upload/api/src/Http/V2/OAuth/TokenService.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md - */ - public function issueByApiKey(string $apiKey, string $scope = ''): array { - /** @var ApiKeyRepository $repo */ - $repo = $this->repo(ApiKey::class); - $key = $repo->findActiveByApi($apiKey); - if($key === null) { - return ['error' => 'invalid_client', 'message' => __('Неверный или неактивный API-ключ')]; - } - if(DleApiConfig::isDemoMode()) { - return DleApiConfig::demoAuthorizedResponse(); - } - - return $this->persistTokensForKey($key, $key->user_id, $scope); - } - - /** - * @return array - */ - public function issueByAuth(string $username, string $password, string $scope = ''): array { - $userId = (new DleUserPasswordVerifier())->verify($username, $password); - if($userId === null) { - return ['error' => 'invalid_grant', 'message' => __('Неверный логин или пароль')]; - } - $key = $this->resolveApiKeyForUser($userId); - if($key === null) { - return ['error' => 'access_denied', 'message' => __('Нет API-ключа пользователя и гостевого ключа')]; - } - if(DleApiConfig::isDemoMode()) { - return DleApiConfig::demoAuthorizedResponse(); - } - - return $this->persistTokensForKey($key, $userId, $scope); - } - - /** - * @return array - */ - public function issueByOauthClient(string $clientId, string $clientSecret, string $scope = ''): array { - $client = $this->findActiveClient($clientId); - if($client === null || !password_verify($clientSecret, $client->client_secret)) { - return ['error' => 'invalid_client', 'message' => __('Неверный client_id или client_secret')]; - } - if(!$this->clientAllowsGrant($client, 'client_credentials')) { - return ['error' => 'unauthorized_client', 'message' => __('Клиент не разрешает grant_type=client_credentials')]; - } - $key = $this->findActiveApiKey($client->api_key_id); - if($key === null) { - return ['error' => 'invalid_client', 'message' => __('API-ключ клиента неактивен')]; - } - if(DleApiConfig::isDemoMode()) { - return DleApiConfig::demoAuthorizedResponse(); - } - - return $this->persistTokens($client, $key, $key->user_id, $scope); - } - - /** - * @return array - */ - public function issueClientCredentials(string $clientId, string $clientSecret, string $scope = ''): array { - return $this->issueByOauthClient($clientId, $clientSecret, $scope); - } - - /** - * @return array - */ - public function issuePassword( - string $clientId, - string $clientSecret, - string $username, - string $password, - string $scope = '', - ): array { - if($clientId === '' && $clientSecret === '') { - return $this->issueByAuth($username, $password, $scope); - } - if($clientId === '' || $clientSecret === '') { - return ['error' => 'invalid_client', 'message' => __('Нужны оба: client_id и client_secret')]; - } - $client = $this->findActiveClient($clientId); - if($client === null || !password_verify($clientSecret, $client->client_secret)) { - return ['error' => 'invalid_client', 'message' => __('Неверный client_id или client_secret')]; - } - if(!$this->clientAllowsGrant($client, 'password')) { - return ['error' => 'unauthorized_client', 'message' => __('Клиент не разрешает grant_type=password')]; - } - $key = $this->findActiveApiKey($client->api_key_id); - if($key === null) { - return ['error' => 'invalid_client', 'message' => __('API-ключ клиента неактивен')]; - } - $userId = (new DleUserPasswordVerifier())->verify($username, $password); - if($userId === null) { - return ['error' => 'invalid_grant', 'message' => __('Неверный логин или пароль')]; - } - if(DleApiConfig::isDemoMode()) { - return DleApiConfig::demoAuthorizedResponse(); - } - - return $this->persistTokens($client, $key, $userId, $scope); - } - - /** - * @return array - */ - public function issueAuthorizationCode( - string $clientId, - string $clientSecret, - string $code, - string $redirectUri, - string $codeVerifier = '', - ): array { - $client = $this->findActiveClient($clientId); - if($client === null || !password_verify($clientSecret, $client->client_secret)) { - return ['error' => 'invalid_client', 'message' => __('Неверный client')]; - } - if(!$this->clientAllowsGrant($client, 'authorization_code')) { - return ['error' => 'unauthorized_client', 'message' => __('Клиент не разрешает grant_type=authorization_code')]; - } - /** @var OauthAuthCodeRepository $codes */ - $codes = $this->repo(OauthAuthCode::class); - $row = $codes->findValidByCode($code); - if($row === null || $row->client_id !== $clientId) { - return ['error' => 'invalid_grant', 'message' => __('Код недействителен')]; - } - if($redirectUri !== '' && (string) ($row->redirect_uri ?? '') !== $redirectUri) { - return ['error' => 'invalid_grant', 'message' => __('redirect_uri не совпадает')]; - } - $challenge = (string) ($row->code_challenge ?? ''); - if($challenge !== '') { - $method = (string) ($row->code_challenge_method ?? 'S256'); - $calc = $method === 'plain' - ? $codeVerifier - : rtrim(strtr(base64_encode(hash('sha256', $codeVerifier, true)), '+/', '-_'), '='); - if(!hash_equals($challenge, $calc)) { - return ['error' => 'invalid_grant', 'message' => __('Ошибка проверки PKCE')]; - } - } - if(DleApiConfig::isDemoMode()) { - return DleApiConfig::demoAuthorizedResponse(); - } - $codes->revokeEntity($row); - $key = $this->findActiveApiKey($client->api_key_id); - if($key === null) { - return ['error' => 'invalid_client', 'message' => __('API-ключ неактивен')]; - } - - return $this->persistTokens($client, $key, $row->user_id, (string) ($row->scopes ?? '')); - } - - /** - * @return array - */ - public function refresh(string $refreshToken): array { - /** @var OauthRefreshTokenRepository $refreshRepo */ - $refreshRepo = $this->repo(OauthRefreshToken::class); - $row = $refreshRepo->findValidByTokenId($refreshToken); - if($row === null) { - return ['error' => 'invalid_grant', 'message' => __('Refresh token недействителен')]; - } - /** @var OauthAccessTokenRepository $accessRepo */ - $accessRepo = $this->repo(OauthAccessToken::class); - $access = $accessRepo->findByTokenId($row->access_token_id); - if($access === null) { - return ['error' => 'invalid_grant', 'message' => __('Связанный access token не найден')]; - } - $client = $this->findActiveClient($access->client_id); - $key = $this->findActiveApiKey($access->api_key_id); - if($client === null || $key === null) { - return ['error' => 'invalid_client', 'message' => __('Клиент или ключ неактивен')]; - } - if(!$this->clientAllowsGrant($client, 'refresh_token')) { - return ['error' => 'unauthorized_client', 'message' => __('Клиент не разрешает grant_type=refresh_token')]; - } - if(DleApiConfig::isDemoMode()) { - return DleApiConfig::demoAuthorizedResponse(); - } - $refreshRepo->revokeEntity($row); - $accessRepo->revokeEntity($access); - - return $this->persistTokens($client, $key, $access->user_id, (string) ($access->scopes ?? '')); - } - - public function revoke(string $token): void { - /** @var OauthAccessTokenRepository $accessRepo */ - $accessRepo = $this->repo(OauthAccessToken::class); - $accessRepo->revokeByAccessOrTokenId($token); - /** @var OauthRefreshTokenRepository $refreshRepo */ - $refreshRepo = $this->repo(OauthRefreshToken::class); - $refreshRepo->revokeByTokenId($token); - } - - /** - * Только AuthToken (не сырой API-ключ). - * - * @return array{auth_via: 'access_token', token: array, key: array}|null - */ - public function validateAccessToken(string $bearer): ?array { - /** @var OauthAccessTokenRepository $accessRepo */ - $accessRepo = $this->repo(OauthAccessToken::class); - $row = $accessRepo->findValidByAccessToken($bearer); - if($row === null) { - return null; - } - $key = $this->findActiveApiKey($row->api_key_id); - if($key === null) { - return null; - } - - return [ - 'auth_via' => 'access_token', - 'token' => [ - 'token_id' => $row->token_id, - 'access_token' => $row->access_token, - 'client_id' => $row->client_id, - 'user_id' => $row->user_id, - 'api_key_id' => $row->api_key_id, - 'scopes' => $row->scopes, - ], - 'key' => ApiKeyRepository::toAuthArray($key), - ]; - } - - public function resolveApiKeyForUser(int $userId): ?ApiKey { - /** @var ApiKeyRepository $repo */ - $repo = $this->repo(ApiKey::class); - $key = $repo->findActiveByUserId($userId); - if($key !== null) { - return $key; - } - - return $repo->findActiveGuest(); - } - - /** - * Проверка client_id / redirect_uri / grant authorization_code до выдачи code. - * - * @return array{error: string, message: string}|null null — OK - */ - public function validateAuthorizeRequest(string $clientId, string $redirectUri): ?array { - $client = $this->findActiveClient($clientId); - if($client === null) { - return ['error' => 'invalid_client', 'message' => __('Неизвестный или неактивный client_id')]; - } - if(!$this->clientAllowsGrant($client, 'authorization_code')) { - return ['error' => 'unauthorized_client', 'message' => __('Клиент не разрешает grant_type=authorization_code')]; - } - $registered = (string) ($client->redirect_uri ?? ''); - if($registered === '') { - return ['error' => 'invalid_request', 'message' => __('У клиента не задан redirect_uri')]; - } - if($registered !== $redirectUri) { - return ['error' => 'invalid_request', 'message' => __('redirect_uri не совпадает с зарегистрированным у клиента')]; - } - - return null; - } - - public function createAuthCode( - string $clientId, - int $userId, - string $redirectUri, - string $scopes = '', - string $codeChallenge = '', - string $codeChallengeMethod = 'S256', - ): string { - $code = bin2hex(random_bytes(32)); - /** @var OauthAuthCodeRepository $codes */ - $codes = $this->repo(OauthAuthCode::class); - $codes->createCode( - $code, - $clientId, - $userId, - $scopes, - $redirectUri, - $codeChallenge, - $codeChallengeMethod, - new \DateTimeImmutable('+' . 600 . ' seconds'), - ); - - return $code; - } - - /** - * @return array{access_token: string, token_type: string, expires_in: int, refresh_token: string} - */ - private function persistTokens(OauthClient $client, ApiKey $key, int $userId, string $scopes): array { - return $this->persistTokensForKey($key, $userId, $scopes, $client->client_id); - } - - /** - * @return array{access_token: string, token_type: string, expires_in: int, refresh_token: string} - */ - private function persistTokensForKey(ApiKey $key, int $userId, string $scopes, string $clientId = ''): array { - $ttl = $this->tokenTtl(); - $tokenId = bin2hex(random_bytes(16)); - $accessToken = bin2hex(random_bytes(32)); - $refreshId = bin2hex(random_bytes(16)); - /** @var OauthAccessTokenRepository $accessRepo */ - $accessRepo = $this->repo(OauthAccessToken::class); - $accessRepo->createToken( - $tokenId, - $accessToken, - $clientId, - $userId, - $key->id(), - $scopes, - new \DateTimeImmutable('+' . $ttl . ' seconds'), - ); - /** @var OauthRefreshTokenRepository $refreshRepo */ - $refreshRepo = $this->repo(OauthRefreshToken::class); - $refreshRepo->createToken( - $refreshId, - $tokenId, - new \DateTimeImmutable('+' . (86400 * 30) . ' seconds'), - ); - - return [ - 'access_token' => $accessToken, - 'token_type' => 'Bearer', - 'expires_in' => $ttl, - 'refresh_token' => $refreshId, - ]; - } - - private function clientAllowsGrant(OauthClient $client, string $grant): bool { - $raw = $client->grant_types; - if($raw === '') { - return false; - } - - return in_array($grant, array_map('trim', explode(',', $raw)), true); - } - - private function findActiveClient(string $clientId): ?OauthClient { - /** @var OauthClientRepository $repo */ - $repo = $this->repo(OauthClient::class); - - return $repo->findActiveByClientId($clientId); - } - - private function findActiveApiKey(int $id): ?ApiKey { - /** @var ApiKeyRepository $repo */ - $repo = $this->repo(ApiKey::class); - - return $repo->findActive($id); - } - - /** - * @template T of object - * @param class-string $entity - * @return object - */ - private function repo(string $entity): object { - return Application::instance()->database()->repository($entity); - } - - private function tokenTtl(): int { - $cfg = DleApiConfig::all(); - if(isset($cfg['token_ttl'])) { - return max(60, (int) $cfg['token_ttl']); - } - - return 3600; - } - -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/OpenApi/Document.php b/upload/api/src/OpenApi/Document.php index 51f1e773..7ef50308 100644 --- a/upload/api/src/OpenApi/Document.php +++ b/upload/api/src/OpenApi/Document.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md . Выдача: POST /oauth/token с credential_type=api_key|auth|oauth_client или grant_type. Discovery: /.well-known/oauth-authorization-server. Identity: GET /me и /oauth/userinfo. Проверка сырого ключа: GET /key/check.', -)] -#[OA\Server( - url: '{apiBase}', - description: 'Базовый URL API (подставьте свой хост, напр. https://example.com/api/v2)', - variables: [ - new OA\ServerVariable( - serverVariable: 'apiBase', - default: '/api/v2', - description: 'Путь или полный URL до /api/v2', - ), - ], -)] -#[OA\Server(url: '/api/v2', description: 'Относительный путь по умолчанию')] -#[OA\SecurityScheme( - securityScheme: 'bearerAuth', - type: 'http', - scheme: 'bearer', - bearerFormat: 'AuthToken', - description: 'Access token из POST /oauth/token (credential_type или grant_type). Сырой API-ключ на ресурсах не принимается.', -)] -#[OA\SecurityScheme( - securityScheme: 'rawApiKeyBearer', - type: 'http', - scheme: 'bearer', - bearerFormat: 'API Key', - description: 'Сырой API-ключ только для GET /key/check. Формат: Authorization: Bearer .', -)] -#[OA\Tag(name: 'OAuth', description: 'Выдача и отзыв токенов, discovery, userinfo')] -#[OA\Tag(name: 'Me', description: 'Субъект AuthToken и проверка сырого API-ключа')] -#[OA\Tag(name: 'Table', description: 'Универсальный CRUD по SchemaRegistry: GET/POST /table/{name}/, GET/PUT/DELETE /table/{name}/{id}')] -#[OA\Tag(name: 'Post', description: 'Новости')] -#[OA\Tag(name: 'User', description: 'Пользователи и группы')] -#[OA\Tag(name: 'Plugin', description: 'Плагины')] -#[OA\Tag(name: 'Upload', description: 'Загрузка файлов')] -#[OA\Tag(name: 'Xfield', description: 'Каталог доп. полей (xfields.json / userxfields.json)')] -#[OA\Tag(name: 'System', description: 'Служебные')] -final class Document { - - #[OA\Post( - path: '/oauth/token', - operationId: 'oauthToken', - summary: 'Выдача AuthToken (credential_type или grant_type)', - description: 'Предпочтительно credential_type=api_key|auth|oauth_client. Альтернатива: grant_type=client_credentials|password|authorization_code|refresh_token. В DEMO_MODE при успехе — authorized без access_token.', - security: [], - tags: ['OAuth'], - )] - #[OA\RequestBody( - required: true, - description: 'Параметры credential_type или OAuth2 grant', - content: new OA\JsonContent( - properties: [ - new OA\Property( - property: 'credential_type', - type: 'string', - enum: ['api_key', 'auth', 'oauth_client'], - description: 'Предпочтительный способ выдачи AuthToken', - ), - new OA\Property( - property: 'grant_type', - type: 'string', - enum: ['client_credentials', 'authorization_code', 'refresh_token', 'password'], - ), - new OA\Property(property: 'api_key', type: 'string', description: 'credential_type=api_key'), - new OA\Property(property: 'client_id', type: 'string'), - new OA\Property(property: 'client_secret', type: 'string'), - new OA\Property(property: 'scope', type: 'string'), - new OA\Property(property: 'code', type: 'string'), - new OA\Property(property: 'redirect_uri', type: 'string'), - new OA\Property(property: 'code_verifier', type: 'string'), - new OA\Property(property: 'refresh_token', type: 'string'), - new OA\Property(property: 'username', type: 'string', description: 'Логин или email (auth / password)'), - new OA\Property(property: 'password', type: 'string'), - ], - example: [ - 'credential_type' => 'api_key', - 'api_key' => 'your_api_key', - ], - ), - )] - #[OA\Response( - response: 200, - description: 'Токен выдан или DEMO_MODE authorized', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'access_token', type: 'string', nullable: true), - new OA\Property(property: 'token_type', type: 'string', example: 'Bearer'), - new OA\Property(property: 'expires_in', type: 'integer'), - new OA\Property(property: 'refresh_token', type: 'string'), - new OA\Property(property: 'demo_mode', type: 'boolean'), - new OA\Property(property: 'authorized', type: 'boolean'), - new OA\Property(property: 'message', type: 'string'), - ], - example: [ - 'access_token' => '…', - 'token_type' => 'Bearer', - 'expires_in' => 3600, - 'refresh_token' => '…', - ], - ), - )] - #[OA\Response( - response: 400, - description: 'Ошибка grant / credential', - content: new OA\JsonContent(ref: ApiError::class), - )] - public function oauthToken(): void {} - - #[OA\Get( - path: '/.well-known/oauth-authorization-server', - operationId: 'oauthDiscovery', - summary: 'OAuth AS discovery (без Bearer)', - security: [], - tags: ['OAuth'], - )] - #[OA\Response( - response: 200, - description: 'Метаданные AS', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'issuer', type: 'string'), - new OA\Property(property: 'authorization_endpoint', type: 'string'), - new OA\Property(property: 'token_endpoint', type: 'string'), - new OA\Property(property: 'revocation_endpoint', type: 'string'), - new OA\Property(property: 'userinfo_endpoint', type: 'string'), - new OA\Property(property: 'response_types_supported', type: 'array', items: new OA\Items(type: 'string')), - new OA\Property(property: 'grant_types_supported', type: 'array', items: new OA\Items(type: 'string')), - new OA\Property(property: 'code_challenge_methods_supported', type: 'array', items: new OA\Items(type: 'string')), - new OA\Property(property: 'token_endpoint_auth_methods_supported', type: 'array', items: new OA\Items(type: 'string')), - new OA\Property(property: 'credential_types_supported', type: 'array', items: new OA\Items(type: 'string')), - ], - ), - )] - public function oauthDiscovery(): void {} - - #[OA\Get( - path: '/me', - operationId: 'me', - summary: 'Субъект AuthToken (identity без CRUD-масок ПДн)', - security: [['bearerAuth' => []]], - tags: ['Me'], - )] - #[OA\Response( - response: 200, - description: 'Identity', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'sub', type: 'string', nullable: true), - new OA\Property(property: 'user_id', type: 'integer'), - new OA\Property(property: 'name', type: 'string', nullable: true), - new OA\Property(property: 'email', type: 'string', nullable: true), - new OA\Property(property: 'user_group', type: 'integer', nullable: true), - new OA\Property(property: 'user', type: 'object', nullable: true, additionalProperties: true), - new OA\Property(property: 'api_key_id', type: 'integer'), - new OA\Property(property: 'access_level', type: 'object', nullable: true, additionalProperties: true), - new OA\Property(property: 'client_id', type: 'string', nullable: true), - new OA\Property(property: 'auth_via', type: 'string', example: 'access_token'), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - public function me(): void {} - - #[OA\Get( - path: '/key/check', - operationId: 'keyCheck', - summary: 'Проверка сырого API-ключа', - description: 'Принимает Authorization: Bearer , возвращает ключ, scopes и payload `me`. `validTo = null` означает бессрочный ключ.', - security: [['rawApiKeyBearer' => []]], - tags: ['Me'], - )] - #[OA\Response( - response: 200, - description: 'Ключ валиден', - content: new OA\JsonContent( - properties: [ - new OA\Property( - property: 'apiKey', - type: 'object', - properties: [ - new OA\Property(property: 'key', type: 'string'), - new OA\Property(property: 'validFrom', type: 'string', format: 'date-time', nullable: true), - new OA\Property(property: 'validTo', type: 'string', format: 'date-time', nullable: true, description: 'null = ключ бессрочный'), - new OA\Property(property: 'accessLevel', type: 'object', nullable: true, additionalProperties: true), - ], - ), - new OA\Property( - property: 'scopes', - type: 'object', - additionalProperties: new OA\AdditionalProperties( - type: 'object', - properties: [ - new OA\Property(property: 'read', type: 'boolean'), - new OA\Property(property: 'write', type: 'boolean'), - new OA\Property(property: 'edit', type: 'boolean'), - new OA\Property(property: 'delete', type: 'boolean'), - ], - ), - ), - new OA\Property(property: 'me', type: 'object', additionalProperties: true), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - public function keyCheck(): void {} - - #[OA\Get( - path: '/oauth/userinfo', - operationId: 'oauthUserinfo', - summary: 'OIDC-совместимый userinfo (тот же payload, что /me)', - security: [['bearerAuth' => []]], - tags: ['OAuth'], - )] - #[OA\Response( - response: 200, - description: 'Identity', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'sub', type: 'string', nullable: true), - new OA\Property(property: 'user_id', type: 'integer'), - new OA\Property(property: 'name', type: 'string', nullable: true), - new OA\Property(property: 'email', type: 'string', nullable: true), - new OA\Property(property: 'user_group', type: 'integer', nullable: true), - new OA\Property(property: 'user', type: 'object', nullable: true, additionalProperties: true), - new OA\Property(property: 'api_key_id', type: 'integer'), - new OA\Property(property: 'access_level', type: 'object', nullable: true, additionalProperties: true), - new OA\Property(property: 'client_id', type: 'string', nullable: true), - new OA\Property(property: 'auth_via', type: 'string'), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - public function oauthUserinfo(): void {} - - #[OA\Post( - path: '/oauth/revoke', - operationId: 'oauthRevoke', - summary: 'Отзыв токена', - security: [], - tags: ['OAuth'], - )] - #[OA\RequestBody( - required: true, - content: new OA\JsonContent( - required: ['token'], - properties: [ - new OA\Property(property: 'token', type: 'string', description: 'Access или refresh token'), - ], - ), - )] - #[OA\Response( - response: 200, - description: 'Отозван', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'revoked', type: 'boolean', example: true), - ], - example: ['revoked' => true], - ), - )] - public function oauthRevoke(): void {} - - #[OA\Get( - path: '/post/', - operationId: 'listPosts', - summary: 'Список новостей (фильтры как у /table/post/ + legacy headers)', - description: 'Query-параметры колонок схемы; xf[name]=value для доп. полей; ! и % префиксы значений. Legacy: HTTP-заголовки с именами колонок (BC). category — virtual FK csv + post_extras_cats.', - security: [['bearerAuth' => []]], - tags: ['Post'], - )] - #[OA\QueryParameter(name: 'limit', schema: new OA\Schema(type: 'integer', default: 20))] - #[OA\QueryParameter(name: 'offset', schema: new OA\Schema(type: 'integer', default: 0))] - #[OA\QueryParameter(name: 'orderby', description: 'Колонка сортировки', schema: new OA\Schema(type: 'string'))] - #[OA\QueryParameter(name: 'sort', schema: new OA\Schema(type: 'string', enum: ['ASC', 'DESC'], default: 'DESC'))] - #[OA\QueryParameter(name: 'category', description: 'Virtual FK csv → category.id (FIND_IN_SET + post_extras_cats). !negate, %LIKE', schema: new OA\Schema(type: 'string'))] - #[OA\QueryParameter(name: 'approve', schema: new OA\Schema(type: 'string'))] - #[OA\QueryParameter( - name: 'xf', - description: 'Доп. поля: xf[field]=value (pad-LIKE по xfields). Пример: xf[title]=foo', - style: 'form', - explode: true, - schema: new OA\Schema(type: 'object', additionalProperties: new OA\AdditionalProperties(type: 'string')), - )] - #[OA\Response( - response: 200, - description: 'OK', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'data', type: 'array', items: new OA\Items(ref: PostSchema::class)), - new OA\Property(property: 'count', type: 'integer'), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - public function listPosts(): void {} - - #[OA\Get( - path: '/post/{id}', - operationId: 'getPost', - summary: 'Новость по id', - security: [['bearerAuth' => []]], - tags: ['Post'], - )] - #[OA\PathParameter(name: 'id', required: true, schema: new OA\Schema(type: 'integer'))] - #[OA\Response( - response: 200, - description: 'OK', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'data', ref: PostSchema::class), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 404, description: 'Не найдено', content: new OA\JsonContent(ref: ApiError::class))] - public function getPost(): void {} - - #[OA\Get( - path: '/table/{name}', - operationId: 'listTableRows', - summary: 'Список записей таблицы с фильтрами', - description: 'Любая таблица SchemaRegistry. Фильтры = query-параметры колонок. Virtual FK (RelationMap): csv→FIND_IN_SET, one→=. Операторы: !negate, %LIKE. Пример: /table/banners/?category=1&approve=1. xf[name] если есть колонка xfields.', - security: [['bearerAuth' => []]], - tags: ['Table'], - )] - #[OA\PathParameter( - name: 'name', - required: true, - description: 'Логическое имя таблицы SchemaRegistry (banners, post, category, …)', - schema: new OA\Schema(type: 'string', description: 'Логическое имя таблицы SchemaRegistry'), - )] - #[OA\QueryParameter(name: 'limit', schema: new OA\Schema(type: 'integer', default: 20))] - #[OA\QueryParameter(name: 'offset', schema: new OA\Schema(type: 'integer', default: 0))] - #[OA\QueryParameter(name: 'orderby', description: 'Колонка сортировки (из схемы)', schema: new OA\Schema(type: 'string'))] - #[OA\QueryParameter(name: 'sort', schema: new OA\Schema(type: 'string', enum: ['ASC', 'DESC'], default: 'DESC'))] - #[OA\QueryParameter( - name: 'xf', - description: 'Доп. поля (если у таблицы есть xfields): xf[field]=value. Пример: xf[title]=foo', - style: 'form', - explode: true, - schema: new OA\Schema(type: 'object', additionalProperties: new OA\AdditionalProperties(type: 'string')), - )] - #[OA\Response( - response: 200, - description: 'OK', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'data', type: 'array', items: new OA\Items(ref: TableRowUnion::class)), - new OA\Property(property: 'count', type: 'integer'), - new OA\Property(property: 'table', type: 'string'), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 404, description: 'Неизвестная таблица', content: new OA\JsonContent(ref: ApiError::class))] - #[OA\Response(response: 422, description: 'Неизвестная колонка / ошибка фильтра', content: new OA\JsonContent(ref: ApiError::class))] - public function listTableRows(): void {} - - #[OA\Get( - path: '/table/{name}/{id}', - operationId: 'getTableRow', - summary: 'Запись по скалярному PK', - security: [['bearerAuth' => []]], - tags: ['Table'], - )] - #[OA\PathParameter( - name: 'name', - required: true, - schema: new OA\Schema(type: 'string', description: 'Логическое имя таблицы SchemaRegistry'), - )] - #[OA\PathParameter(name: 'id', required: true, description: 'Значение первичного ключа', schema: new OA\Schema(type: 'string'))] - #[OA\Response( - response: 200, - description: 'OK', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'data', ref: TableRowUnion::class), - new OA\Property(property: 'table', type: 'string'), - ], - ), - )] - #[OA\Response(response: 400, description: 'Составной PK не поддерживается через /{id}', content: new OA\JsonContent(ref: ApiError::class))] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 404, description: 'Не найдено', content: new OA\JsonContent(ref: ApiError::class))] - public function getTableRow(): void {} - - #[OA\Post( - path: '/table/{name}', - operationId: 'createTableRow', - summary: 'Создание записи (Fluent prepare)', - security: [['bearerAuth' => []]], - tags: ['Table'], - )] - #[OA\PathParameter( - name: 'name', - required: true, - description: 'Логическое имя таблицы SchemaRegistry', - schema: new OA\Schema(type: 'string', description: 'Логическое имя таблицы SchemaRegistry'), - )] - #[OA\RequestBody( - required: true, - description: 'Колонки выбранной таблицы (+ optional nested children). Схема = oneOf TableRow.', - content: [new OA\MediaType( - mediaType: 'application/json', - schema: new OA\Schema(ref: TableRowUnion::class), - )], - )] - #[OA\Response( - response: 201, - description: 'Создано', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'id', type: 'integer'), - new OA\Property(property: 'table', type: 'string'), - ], - example: ['id' => 1, 'table' => 'banners'], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 422, description: 'Ошибка создания', content: new OA\JsonContent(ref: ApiError::class))] - public function createTableRow(): void {} - - #[OA\Put( - path: '/table/{name}/{id}', - operationId: 'updateTableRow', - summary: 'Обновление записи по скалярному PK', - security: [['bearerAuth' => []]], - tags: ['Table'], - )] - #[OA\PathParameter( - name: 'name', - required: true, - schema: new OA\Schema(type: 'string', description: 'Логическое имя таблицы SchemaRegistry'), - )] - #[OA\PathParameter(name: 'id', required: true, schema: new OA\Schema(type: 'string'))] - #[OA\RequestBody( - required: true, - content: [new OA\MediaType( - mediaType: 'application/json', - schema: new OA\Schema(ref: TableRowUnion::class), - )], - )] - #[OA\Response( - response: 200, - description: 'Обновлено', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'id', type: 'string'), - new OA\Property(property: 'table', type: 'string'), - new OA\Property(property: 'updated', type: 'boolean', example: true), - ], - example: ['id' => '1', 'table' => 'banners', 'updated' => true], - ), - )] - #[OA\Response(response: 400, description: 'Составной PK не поддерживается', content: new OA\JsonContent(ref: ApiError::class))] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 404, description: 'Не найдено', content: new OA\JsonContent(ref: ApiError::class))] - #[OA\Response(response: 422, description: 'Ошибка обновления', content: new OA\JsonContent(ref: ApiError::class))] - public function updateTableRow(): void {} - - #[OA\Delete( - path: '/table/{name}/{id}', - operationId: 'deleteTableRow', - summary: 'Удаление записи по скалярному PK', - security: [['bearerAuth' => []]], - tags: ['Table'], - )] - #[OA\PathParameter( - name: 'name', - required: true, - schema: new OA\Schema(type: 'string', description: 'Логическое имя таблицы SchemaRegistry'), - )] - #[OA\PathParameter(name: 'id', required: true, schema: new OA\Schema(type: 'string'))] - #[OA\Response( - response: 200, - description: 'Удалено', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'id', type: 'string'), - new OA\Property(property: 'table', type: 'string'), - new OA\Property(property: 'deleted', type: 'boolean', example: true), - ], - example: ['id' => '1', 'table' => 'banners', 'deleted' => true], - ), - )] - #[OA\Response(response: 400, description: 'Составной PK не поддерживается', content: new OA\JsonContent(ref: ApiError::class))] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 404, description: 'Не найдено', content: new OA\JsonContent(ref: ApiError::class))] - public function deleteTableRow(): void {} - - #[OA\Post( - path: '/post/', - operationId: 'createPost', - summary: 'Создание новости (sugar → prepare post)', - security: [['bearerAuth' => []]], - tags: ['Post'], - )] - #[OA\RequestBody( - description: 'Новость + optional nested children', - required: true, - content: [new OA\MediaType( - mediaType: 'application/json', - schema: new OA\Schema(ref: PostSchema::class), - )], - )] - #[OA\Response( - response: 201, - description: 'Создано', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'id', type: 'integer'), - ], - example: ['id' => 1], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 422, description: 'Ошибка создания', content: new OA\JsonContent(ref: ApiError::class))] - public function createPost(): void {} - - #[OA\Post( - path: '/user/', - operationId: 'createUser', - summary: 'Создание пользователя', - security: [['bearerAuth' => []]], - tags: ['User'], - )] - #[OA\RequestBody( - required: true, - content: new OA\JsonContent(ref: UsersSchema::class), - )] - #[OA\Response( - response: 201, - description: 'Создано', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'id', type: 'integer'), - ], - example: ['id' => 1], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 422, description: 'Ошибка создания', content: new OA\JsonContent(ref: ApiError::class))] - public function createUser(): void {} - - #[OA\Post( - path: '/usergroup/', - operationId: 'createUsergroup', - summary: 'Создание группы пользователей', - security: [['bearerAuth' => []]], - tags: ['User'], - )] - #[OA\RequestBody( - required: true, - content: new OA\JsonContent(ref: UsergroupsSchema::class), - )] - #[OA\Response( - response: 201, - description: 'Создано', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'id', type: 'integer'), - ], - example: ['id' => 1], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 422, description: 'Ошибка создания', content: new OA\JsonContent(ref: ApiError::class))] - public function createUsergroup(): void {} - - #[OA\Post( - path: '/plugin/', - operationId: 'createPlugin', - summary: 'Регистрация плагина', - security: [['bearerAuth' => []]], - tags: ['Plugin'], - )] - #[OA\RequestBody( - required: true, - content: new OA\JsonContent(ref: PluginsSchema::class), - )] - #[OA\Response( - response: 201, - description: 'Создано', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'id', type: 'integer'), - ], - example: ['id' => 1], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 422, description: 'Ошибка создания', content: new OA\JsonContent(ref: ApiError::class))] - public function createPlugin(): void {} - - #[OA\Post( - path: '/upload/', - operationId: 'uploadFile', - summary: 'Загрузка файла (multipart)', - security: [['bearerAuth' => []]], - tags: ['Upload'], - )] - #[OA\RequestBody( - required: true, - content: [new OA\MediaType( - mediaType: 'multipart/form-data', - schema: new OA\Schema( - required: ['file'], - properties: [ - new OA\Property(property: 'file', type: 'string', format: 'binary'), - new OA\Property(property: 'subdir', type: 'string', example: 'files'), - ], - ), - )], - )] - #[OA\Response( - response: 201, - description: 'Загружено', - content: new OA\JsonContent( - type: 'object', - additionalProperties: true, - example: ['url' => '/uploads/files/…', 'name' => 'file.jpg'], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 422, description: 'Ошибка загрузки', content: new OA\JsonContent(ref: ApiError::class))] - public function uploadFile(): void {} - - #[OA\Get( - path: '/conversations/', - operationId: 'listConversations', - summary: 'Список переписок', - security: [['bearerAuth' => []]], - tags: ['System'], - )] - #[OA\Response( - response: 200, - description: 'OK', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'data', type: 'array', items: new OA\Items(ref: ConversationsSchema::class)), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - public function listConversations(): void {} - - #[OA\Get( - path: '/xfields/{scope}/', - operationId: 'listXfields', - summary: 'Каталог доп. полей', - security: [['bearerAuth' => []]], - tags: ['Xfield'], - )] - #[OA\PathParameter(name: 'scope', required: true, schema: new OA\Schema(type: 'string', enum: ['post', 'user']))] - #[OA\Response( - response: 200, - description: 'OK (post → PostXfieldsCatalog, user → UserXfieldsCatalog)', - content: new OA\JsonContent( - properties: [ - new OA\Property( - property: 'data', - oneOf: [ - new OA\Schema(ref: PostXfieldsCatalog::class), - new OA\Schema(ref: UserXfieldsCatalog::class), - ], - ), - new OA\Property(property: 'scope', type: 'string', enum: ['post', 'user']), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - public function listXfields(): void {} - - #[OA\Post( - path: '/xfields/{scope}/encode', - operationId: 'encodeXfields', - summary: 'Сериализация значений в формат post.xfields / users.xfields (аналог forPost)', - description: 'Body: {fields:{name:value}} или {name,value}. Ответ: raw + parsed.', - security: [['bearerAuth' => []]], - tags: ['Xfield'], - )] - #[OA\PathParameter(name: 'scope', required: true, schema: new OA\Schema(type: 'string', enum: ['post', 'user']))] - #[OA\RequestBody(required: true, content: new OA\JsonContent(type: 'object', additionalProperties: true))] - #[OA\Response( - response: 200, - description: 'OK', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'raw', type: 'string'), - new OA\Property(property: 'parsed', type: 'object', additionalProperties: true), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 422, description: 'Неизвестное поле / validation', content: new OA\JsonContent(ref: ApiError::class))] - public function encodeXfields(): void {} - - #[OA\Get( - path: '/xfields/{scope}/{name}', - operationId: 'getXfield', - summary: 'Определение одного поля', - security: [['bearerAuth' => []]], - tags: ['Xfield'], - )] - #[OA\PathParameter(name: 'scope', required: true, schema: new OA\Schema(type: 'string', enum: ['post', 'user']))] - #[OA\PathParameter(name: 'name', required: true, schema: new OA\Schema(type: 'string'))] - #[OA\QueryParameter(name: 'as', description: 'Projection по типу (image, text, …)', schema: new OA\Schema(type: 'string'))] - #[OA\Response( - response: 200, - description: 'OK', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'data', ref: PostXfieldField::class), - new OA\Property(property: 'scope', type: 'string'), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 404, description: 'Не найдено', content: new OA\JsonContent(ref: ApiError::class))] - #[OA\Response(response: 422, description: 'Тип не совпадает с ?as=', content: new OA\JsonContent(ref: ApiError::class))] - public function getXfield(): void {} - - #[OA\Post( - path: '/xfields/{scope}/', - operationId: 'createXfield', - summary: 'Создать определение поля (typed validation)', - security: [['bearerAuth' => []]], - tags: ['Xfield'], - )] - #[OA\PathParameter(name: 'scope', required: true, schema: new OA\Schema(type: 'string', enum: ['post', 'user']))] - #[OA\RequestBody(required: true, content: new OA\JsonContent(ref: PostXfieldField::class))] - #[OA\Response( - response: 201, - description: 'Создано', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'name', type: 'string'), - new OA\Property(property: 'scope', type: 'string'), - new OA\Property(property: 'data', ref: PostXfieldField::class), - ], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 422, description: 'validation + details.fields', content: new OA\JsonContent(ref: ApiError::class))] - public function createXfield(): void {} - - #[OA\Put( - path: '/xfields/{scope}/{name}', - operationId: 'replaceXfield', - summary: 'Заменить определение поля', - security: [['bearerAuth' => []]], - tags: ['Xfield'], - )] - #[OA\PathParameter(name: 'scope', required: true, schema: new OA\Schema(type: 'string', enum: ['post', 'user']))] - #[OA\PathParameter(name: 'name', required: true, schema: new OA\Schema(type: 'string'))] - #[OA\RequestBody(required: true, content: new OA\JsonContent(ref: PostXfieldField::class))] - #[OA\Response( - response: 200, - description: 'Обновлено', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'name', type: 'string'), - new OA\Property(property: 'updated', type: 'boolean', example: true), - new OA\Property(property: 'data', ref: PostXfieldField::class), - ], - example: ['name' => 'myfield', 'updated' => true], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 422, description: 'validation + details.fields', content: new OA\JsonContent(ref: ApiError::class))] - public function replaceXfield(): void {} - - #[OA\Delete( - path: '/xfields/{scope}/{name}', - operationId: 'deleteXfield', - summary: 'Удалить определение поля', - security: [['bearerAuth' => []]], - tags: ['Xfield'], - )] - #[OA\PathParameter(name: 'scope', required: true, schema: new OA\Schema(type: 'string', enum: ['post', 'user']))] - #[OA\PathParameter(name: 'name', required: true, schema: new OA\Schema(type: 'string'))] - #[OA\Response( - response: 200, - description: 'Удалено', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'name', type: 'string', example: 'myfield'), - new OA\Property(property: 'deleted', type: 'boolean', example: true), - ], - example: ['name' => 'myfield', 'deleted' => true], - ), - )] - #[OA\Response(response: 401, ref: UnauthorizedResponse::class)] - #[OA\Response(response: 404, description: 'Поле не найдено', content: new OA\JsonContent(ref: ApiError::class))] - #[OA\Response(response: 422, description: 'Ошибка удаления', content: new OA\JsonContent(ref: ApiError::class))] - public function deleteXfield(): void {} - - #[OA\Get( - path: '/health', - operationId: 'health', - summary: 'Проверка API (без Bearer)', - security: [], - tags: ['System'], - )] - #[OA\Response( - response: 200, - description: 'OK', - content: new OA\JsonContent( - properties: [ - new OA\Property(property: 'version', type: 'string', example: '200.1.0'), - new OA\Property(property: 'api', type: 'string', example: 'v2'), - new OA\Property(property: 'auth', type: 'string', example: 'Bearer'), - ], - example: ['version' => '200.1.0', 'api' => 'v2', 'auth' => 'Bearer'], - ), - )] - public function health(): void {} -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/AdminLogsSchema.php b/upload/api/src/Schema/AdminLogsSchema.php index badf1d0c..f7fd3cbd 100644 --- a/upload/api/src/Schema/AdminLogsSchema.php +++ b/upload/api/src/Schema/AdminLogsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'date' => 0, - 'ip' => '', - 'action' => 0, - 'extras' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/AdminSectionsSchema.php b/upload/api/src/Schema/AdminSectionsSchema.php index 4425f0d2..593ed05b 100644 --- a/upload/api/src/Schema/AdminSectionsSchema.php +++ b/upload/api/src/Schema/AdminSectionsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'title' => '', - 'descr' => '', - 'icon' => '', - 'allow_groups' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/BannedSchema.php b/upload/api/src/Schema/BannedSchema.php index b489528b..5ab41d05 100644 --- a/upload/api/src/Schema/BannedSchema.php +++ b/upload/api/src/Schema/BannedSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'descr' => '', - 'date' => '', - 'days' => 0, - 'ip' => '', - 'banned_from' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/BannersLogsSchema.php b/upload/api/src/Schema/BannersLogsSchema.php index 3fd0182a..11341ab8 100644 --- a/upload/api/src/Schema/BannersLogsSchema.php +++ b/upload/api/src/Schema/BannersLogsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'click' => 0, - 'ip' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/BannersRubricsSchema.php b/upload/api/src/Schema/BannersRubricsSchema.php index 8bf38126..11954dc5 100644 --- a/upload/api/src/Schema/BannersRubricsSchema.php +++ b/upload/api/src/Schema/BannersRubricsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'title' => '', - 'description' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/BannersSchema.php b/upload/api/src/Schema/BannersSchema.php index d2dcecb6..09e319c1 100644 --- a/upload/api/src/Schema/BannersSchema.php +++ b/upload/api/src/Schema/BannersSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 'category.id', 'dle-kind' => 'csv'], - )] - public string $category = ''; - #[OA\Property( - property: 'grouplevel', - type: 'string', - description: 'CSV групп или all (virtual FK csv_or_all → usergroups.id)', - x: ['dle-ref' => 'usergroups.id', 'dle-kind' => 'csv_or_all'], - )] - public string $grouplevel = 'all'; - #[OA\Property( - property: 'rubric', - type: 'integer', - description: 'Virtual FK one → banners_rubrics.id', - x: ['dle-ref' => 'banners_rubrics.id', 'dle-kind' => 'one'], - )] - public int $rubric = 0; - #[OA\Property( - property: 'start', - type: 'string', - description: 'Колонка banners.start', - )] - public string $start = ''; - #[OA\Property( - property: 'end', - type: 'string', - description: 'Колонка banners.end', - )] - public string $end = ''; - #[OA\Property( - property: 'fpage', - type: 'integer', - description: 'Колонка banners.fpage', - )] - public int $fpage = 0; - #[OA\Property( - property: 'innews', - type: 'integer', - description: 'Колонка banners.innews', - )] - public int $innews = 0; - #[OA\Property( - property: 'devicelevel', - type: 'string', - description: 'Колонка banners.devicelevel', - )] - public string $devicelevel = ''; - #[OA\Property( - property: 'allow_views', - type: 'integer', - description: 'Колонка banners.allow_views', - )] - public int $allow_views = 0; - #[OA\Property( - property: 'max_views', - type: 'integer', - description: 'Колонка banners.max_views', - )] - public int $max_views = 0; - #[OA\Property( - property: 'allow_counts', - type: 'integer', - description: 'Колонка banners.allow_counts', - )] - public int $allow_counts = 0; - #[OA\Property( - property: 'max_counts', - type: 'integer', - description: 'Колонка banners.max_counts', - )] - public int $max_counts = 0; - #[OA\Property( - property: 'views', - type: 'integer', - description: 'Колонка banners.views', - )] - public int $views = 0; - #[OA\Property( - property: 'clicks', - type: 'integer', - description: 'Колонка banners.clicks', - )] - public int $clicks = 0; - #[OA\Property( - property: 'comments_place', - type: 'integer', - description: 'Колонка banners.comments_place', - )] - public int $comments_place = 0; - #[OA\Property( - property: 'allowed_country', - type: 'string', - description: 'Колонка banners.allowed_country', - )] - public string $allowed_country = ''; - #[OA\Property( - property: 'not_allowed_country', - type: 'string', - description: 'Колонка banners.not_allowed_country', - )] - public string $not_allowed_country = ''; - - public function table(): string { - return 'banners'; - } - - protected function columnList(): array { - return [ - 'id', - 'banner_tag', - 'descr', - 'code', - 'approve', - 'short_place', - 'bstick', - 'main', - 'category', - 'grouplevel', - 'start', - 'end', - 'fpage', - 'innews', - 'devicelevel', - 'allow_views', - 'max_views', - 'allow_counts', - 'max_counts', - 'views', - 'clicks', - 'rubric', - 'comments_place', - 'allowed_country', - 'not_allowed_country', - ]; - } - - protected function defaultMap(): array { - return [ - 'banner_tag' => '', - 'descr' => '', - 'code' => '', - 'approve' => 0, - 'short_place' => 0, - 'bstick' => 0, - 'main' => 0, - 'category' => '', - 'grouplevel' => 'all', - 'start' => '', - 'end' => '', - 'fpage' => 0, - 'innews' => 0, - 'devicelevel' => '', - 'allow_views' => 0, - 'max_views' => 0, - 'allow_counts' => 0, - 'max_counts' => 0, - 'views' => 0, - 'clicks' => 0, - 'rubric' => 0, - 'comments_place' => 0, - 'allowed_country' => '', - 'not_allowed_country' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/CategorySchema.php b/upload/api/src/Schema/CategorySchema.php index f43efea9..c6bfbeb4 100644 --- a/upload/api/src/Schema/CategorySchema.php +++ b/upload/api/src/Schema/CategorySchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'posi' => 1, - 'name' => '', - 'alt_name' => '', - 'icon' => '', - 'skin' => '', - 'descr' => '', - 'keywords' => '', - 'news_sort' => '', - 'news_msort' => '', - 'news_number' => 0, - 'short_tpl' => '', - 'full_tpl' => '', - 'metatitle' => '', - 'show_sub' => 0, - 'allow_rss' => 1, - 'fulldescr' => '', - 'disable_search' => 0, - 'disable_main' => 0, - 'disable_rating' => 0, - 'disable_comments' => 0, - 'enable_dzen' => 1, - 'active' => 1, - 'rating_type' => -1, - 'schema_org' => 1, - 'disable_index' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/CommentRatingLogSchema.php b/upload/api/src/Schema/CommentRatingLogSchema.php index f4554bac..f64918f8 100644 --- a/upload/api/src/Schema/CommentRatingLogSchema.php +++ b/upload/api/src/Schema/CommentRatingLogSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'member' => '', - 'ip' => '', - 'rating' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/CommentsFilesSchema.php b/upload/api/src/Schema/CommentsFilesSchema.php index 7681bbfd..ce0ac4a7 100644 --- a/upload/api/src/Schema/CommentsFilesSchema.php +++ b/upload/api/src/Schema/CommentsFilesSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'author' => '', - 'date' => '', - 'name' => '', - 'driver' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/CommentsSchema.php b/upload/api/src/Schema/CommentsSchema.php index c3aec28f..cf6895b4 100644 --- a/upload/api/src/Schema/CommentsSchema.php +++ b/upload/api/src/Schema/CommentsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md attachChildEntity('comment_rating_log', $entity); } } -||||||| -======= - 0, - 'user_id' => 0, - 'date' => '2000-01-01 00:00:00', - 'autor' => '', - 'email' => '', - 'text' => '', - 'ip' => '', - 'is_register' => 0, - 'approve' => 1, - 'rating' => 0, - 'vote_num' => 0, - 'parent' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } - - public function withPostId(int $postId): static { - return $this->with('post_id', $postId); - } - - public function withUserId(int $userId): static { - return $this->with('user_id', $userId); - } - - public function withAutor(string $autor): static { - return $this->with('autor', $autor); - } - - public function withText(string $text): static { - return $this->with('text', $text); - } - - public function withParent(int $parentId): static { - return $this->with('parent', $parentId); - } - - public function withFilesEntity(CommentsFilesSchema $entity): static { - return $this->attachChildEntity('comments_files', $entity); - } - - public function withRatingEntity(CommentRatingLogSchema $entity): static { - return $this->attachChildEntity('comment_rating_log', $entity); - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/ComplaintSchema.php b/upload/api/src/Schema/ComplaintSchema.php index b49f6d56..dec618fe 100644 --- a/upload/api/src/Schema/ComplaintSchema.php +++ b/upload/api/src/Schema/ComplaintSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'c_id' => 0, - 'n_id' => 0, - 'text' => '', - 'from' => '', - 'to' => '', - 'date' => 0, - 'email' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/ConversationReadsSchema.php b/upload/api/src/Schema/ConversationReadsSchema.php index 3b5e21dd..42b2a2fc 100644 --- a/upload/api/src/Schema/ConversationReadsSchema.php +++ b/upload/api/src/Schema/ConversationReadsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - ]; - } - - public function primaryKey(): string|array { - return ['user_id', 'conversation_id']; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/ConversationUsersSchema.php b/upload/api/src/Schema/ConversationUsersSchema.php index 1dcd531d..ad777a5c 100644 --- a/upload/api/src/Schema/ConversationUsersSchema.php +++ b/upload/api/src/Schema/ConversationUsersSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md >>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/ConversationsMessagesSchema.php b/upload/api/src/Schema/ConversationsMessagesSchema.php index a6d6fbde..d69780b1 100644 --- a/upload/api/src/Schema/ConversationsMessagesSchema.php +++ b/upload/api/src/Schema/ConversationsMessagesSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'sender_id' => 0, - 'content' => '', - 'created_at' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/ConversationsSchema.php b/upload/api/src/Schema/ConversationsSchema.php index 2ec4a5ec..6eb98dbc 100644 --- a/upload/api/src/Schema/ConversationsSchema.php +++ b/upload/api/src/Schema/ConversationsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md attachChildEntity('conversation_reads', $entity); } } -||||||| -======= - '', - 'created_at' => 0, - 'updated_at' => 0, - 'sender_id' => 0, - 'recipient_id' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } - - public function withSenderId(int $senderId): static { - return $this->with('sender_id', $senderId); - } - - public function withRecipientId(int $recipientId): static { - return $this->with('recipient_id', $recipientId); - } - - public function withMessageEntity(ConversationsMessagesSchema $entity): static { - return $this->attachChildEntity('conversations_messages', $entity); - } - - public function withUsersEntity(ConversationUsersSchema $entity): static { - return $this->attachChildEntity('conversation_users', $entity); - } - - public function withReadsEntity(ConversationReadsSchema $entity): static { - return $this->attachChildEntity('conversation_reads', $entity); - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/DownloadsLogSchema.php b/upload/api/src/Schema/DownloadsLogSchema.php index 3b530f9f..5c70ee32 100644 --- a/upload/api/src/Schema/DownloadsLogSchema.php +++ b/upload/api/src/Schema/DownloadsLogSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'ip' => '', - 'file_id' => 0, - 'date' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/EmailSchema.php b/upload/api/src/Schema/EmailSchema.php index 0ab51fb2..b3a88e11 100644 --- a/upload/api/src/Schema/EmailSchema.php +++ b/upload/api/src/Schema/EmailSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'template' => '', - 'use_html' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/FilesSchema.php b/upload/api/src/Schema/FilesSchema.php index 6dbec704..5d1e106e 100644 --- a/upload/api/src/Schema/FilesSchema.php +++ b/upload/api/src/Schema/FilesSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md with('driver', $driver); } } -||||||| -======= - 0, - 'name' => '', - 'onserver' => '', - 'author' => '', - 'date' => '', - 'dcount' => 0, - 'size' => 0, - 'checksum' => '', - 'driver' => 0, - 'is_public' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } - - public function withName(string $name): static { - return $this->with('name', $name); - } - - public function withOnserver(string $onserver): static { - return $this->with('onserver', $onserver); - } - - public function withNewsId(int $newsId): static { - return $this->with('news_id', $newsId); - } - - public function withAuthor(string $author): static { - return $this->with('author', $author); - } - - public function withDriver(int $driver): static { - return $this->with('driver', $driver); - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/FloodSchema.php b/upload/api/src/Schema/FloodSchema.php index 24244158..7b6c6fa0 100644 --- a/upload/api/src/Schema/FloodSchema.php +++ b/upload/api/src/Schema/FloodSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'id' => '', - 'flag' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'f_id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/IgnoreListSchema.php b/upload/api/src/Schema/IgnoreListSchema.php index c8a6d59a..073217ff 100644 --- a/upload/api/src/Schema/IgnoreListSchema.php +++ b/upload/api/src/Schema/IgnoreListSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'user_from' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/ImagesSchema.php b/upload/api/src/Schema/ImagesSchema.php index cc27ac83..f751a946 100644 --- a/upload/api/src/Schema/ImagesSchema.php +++ b/upload/api/src/Schema/ImagesSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md with('date', $date); } } -||||||| -======= - '', - 'news_id' => 0, - 'author' => '', - 'date' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } - - public function withImages(string $images): static { - return $this->with('images', $images); - } - - public function withNewsId(int $newsId): static { - return $this->with('news_id', $newsId); - } - - public function withAuthor(string $author): static { - return $this->with('author', $author); - } - - public function withDate(string $date): static { - return $this->with('date', $date); - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/LinksSchema.php b/upload/api/src/Schema/LinksSchema.php index 427d15e8..65b269a7 100644 --- a/upload/api/src/Schema/LinksSchema.php +++ b/upload/api/src/Schema/LinksSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'link' => '', - 'only_one' => 0, - 'replacearea' => 1, - 'rcount' => 0, - 'targetblank' => 0, - 'title' => '', - 'enabled' => 1, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/LoginLogSchema.php b/upload/api/src/Schema/LoginLogSchema.php index ee3b2cd1..89537f6a 100644 --- a/upload/api/src/Schema/LoginLogSchema.php +++ b/upload/api/src/Schema/LoginLogSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'count' => 0, - 'date' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/LogsSchema.php b/upload/api/src/Schema/LogsSchema.php index 7b93b499..fa0d447e 100644 --- a/upload/api/src/Schema/LogsSchema.php +++ b/upload/api/src/Schema/LogsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'member' => '', - 'ip' => '', - 'rating' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/LostdbSchema.php b/upload/api/src/Schema/LostdbSchema.php index 30631f5f..dd3d4a43 100644 --- a/upload/api/src/Schema/LostdbSchema.php +++ b/upload/api/src/Schema/LostdbSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'lostid' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/MailLogSchema.php b/upload/api/src/Schema/MailLogSchema.php index 107c8525..854d2ad5 100644 --- a/upload/api/src/Schema/MailLogSchema.php +++ b/upload/api/src/Schema/MailLogSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'mail' => '', - 'hash' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/MetatagsSchema.php b/upload/api/src/Schema/MetatagsSchema.php index 22b6bce9..c6893376 100644 --- a/upload/api/src/Schema/MetatagsSchema.php +++ b/upload/api/src/Schema/MetatagsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'title' => '', - 'description' => '', - 'keywords' => '', - 'page_title' => '', - 'page_description' => '', - 'robots' => '', - 'enabled' => 1, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/NewsletterTemplateCategoriesSchema.php b/upload/api/src/Schema/NewsletterTemplateCategoriesSchema.php index bb9b85aa..b8855041 100644 --- a/upload/api/src/Schema/NewsletterTemplateCategoriesSchema.php +++ b/upload/api/src/Schema/NewsletterTemplateCategoriesSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'locked' => 0, - 'sort_order' => 0, - 'created_at' => 0, - 'created_by' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/NewsletterTemplateItemsSchema.php b/upload/api/src/Schema/NewsletterTemplateItemsSchema.php index 0ac16124..06683179 100644 --- a/upload/api/src/Schema/NewsletterTemplateItemsSchema.php +++ b/upload/api/src/Schema/NewsletterTemplateItemsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md null, - 'title' => '', - 'content' => '', - 'locked' => 0, - 'sort_order' => 0, - 'created_at' => 0, - 'created_by' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/NoticeSchema.php b/upload/api/src/Schema/NoticeSchema.php index 368e2f6c..aa5a82d4 100644 --- a/upload/api/src/Schema/NoticeSchema.php +++ b/upload/api/src/Schema/NoticeSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'notice' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/PluginsFilesSchema.php b/upload/api/src/Schema/PluginsFilesSchema.php index c9159d5f..b94a1df2 100644 --- a/upload/api/src/Schema/PluginsFilesSchema.php +++ b/upload/api/src/Schema/PluginsFilesSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'file' => '', - 'action' => '', - 'searchcode' => '', - 'replacecode' => '', - 'active' => 0, - 'searchcount' => 0, - 'replacecount' => 0, - 'filedisable' => 1, - 'filedleversion' => '', - 'fileversioncompare' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/PluginsLogsSchema.php b/upload/api/src/Schema/PluginsLogsSchema.php index d4d77105..9a99b00e 100644 --- a/upload/api/src/Schema/PluginsLogsSchema.php +++ b/upload/api/src/Schema/PluginsLogsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'area' => '', - 'error' => '', - 'type' => '', - 'action_id' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/PluginsSchema.php b/upload/api/src/Schema/PluginsSchema.php index e66e291f..c5f71d34 100644 --- a/upload/api/src/Schema/PluginsSchema.php +++ b/upload/api/src/Schema/PluginsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md attachChildEntity('plugins_files', $entity); } } -||||||| -======= - '', - 'description' => '', - 'icon' => '', - 'version' => '', - 'dleversion' => '', - 'versioncompare' => '', - 'active' => 0, - 'mysqlinstall' => '', - 'mysqlupgrade' => '', - 'mysqlenable' => '', - 'mysqldisable' => '', - 'mysqldelete' => '', - 'filedelete' => 0, - 'filelist' => '', - 'upgradeurl' => '', - 'needplugin' => '', - 'phpinstall' => '', - 'phpupgrade' => '', - 'phpenable' => '', - 'phpdisable' => '', - 'phpdelete' => '', - 'notice' => '', - 'mnotice' => 0, - 'posi' => 1, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } - - public function withName(string $name): static { - return $this->with('name', $name); - } - - public function withDescription(string $description): static { - return $this->with('description', $description); - } - - public function withVersion(string $version): static { - return $this->with('version', $version); - } - - public function withFilesEntity(PluginsFilesSchema $entity): static { - return $this->attachChildEntity('plugins_files', $entity); - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/PollLogSchema.php b/upload/api/src/Schema/PollLogSchema.php index 7ba097d6..e49cdc97 100644 --- a/upload/api/src/Schema/PollLogSchema.php +++ b/upload/api/src/Schema/PollLogSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'member' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/PollSchema.php b/upload/api/src/Schema/PollSchema.php index 19b16c32..81d2e0e5 100644 --- a/upload/api/src/Schema/PollSchema.php +++ b/upload/api/src/Schema/PollSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'title' => '', - 'frage' => '', - 'body' => '', - 'votes' => 0, - 'multiple' => 0, - 'answer' => '', - 'closed' => 0, - 'date_closed' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/PostExtrasCatsSchema.php b/upload/api/src/Schema/PostExtrasCatsSchema.php index 6dde150f..5b60778f 100644 --- a/upload/api/src/Schema/PostExtrasCatsSchema.php +++ b/upload/api/src/Schema/PostExtrasCatsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'cat_id' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/PostExtrasSchema.php b/upload/api/src/Schema/PostExtrasSchema.php index 2e3943d0..994c427a 100644 --- a/upload/api/src/Schema/PostExtrasSchema.php +++ b/upload/api/src/Schema/PostExtrasSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'news_read' => 0, - 'allow_rate' => 1, - 'rating' => 0, - 'vote_num' => 0, - 'votes' => 0, - 'view_edit' => 0, - 'disable_index' => 0, - 'related_ids' => '', - 'access' => '', - 'editdate' => 0, - 'editor' => '', - 'reason' => '', - 'user_id' => 0, - 'disable_search' => 0, - 'need_pass' => 0, - 'allow_rss' => 1, - 'allow_rss_dzen' => 1, - 'edited_now' => '', - 'allowed_country' => '', - 'not_allowed_country' => '', - ]; - } - - public function primaryKey(): string|array { - return 'eid'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/PostLogSchema.php b/upload/api/src/Schema/PostLogSchema.php index 7292ad97..02978776 100644 --- a/upload/api/src/Schema/PostLogSchema.php +++ b/upload/api/src/Schema/PostLogSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'expires' => '', - 'action' => 0, - 'move_cat' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/PostPassSchema.php b/upload/api/src/Schema/PostPassSchema.php index 7d7bbb03..05669657 100644 --- a/upload/api/src/Schema/PostPassSchema.php +++ b/upload/api/src/Schema/PostPassSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'password' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/PostSchema.php b/upload/api/src/Schema/PostSchema.php index d380a365..b1fb2dac 100644 --- a/upload/api/src/Schema/PostSchema.php +++ b/upload/api/src/Schema/PostSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 'category.id', 'dle-kind' => 'csv'], - )] - public string $category = ''; - #[OA\Property( - property: 'alt_name', - type: 'string', - description: 'ЧПУ-имя (post.alt_name)', - )] - public string $alt_name = ''; - #[OA\Property( - property: 'comm_num', - type: 'integer', - description: 'Колонка post.comm_num', - )] - public int $comm_num = 0; - #[OA\Property( - property: 'allow_comm', - type: 'integer', - description: 'Колонка post.allow_comm', - )] - public int $allow_comm = 1; - #[OA\Property( - property: 'allow_main', - type: 'integer', - description: 'Колонка post.allow_main', - )] - public int $allow_main = 1; - #[OA\Property( - property: 'approve', - type: 'integer', - description: 'Одобрено (0/1) (post.approve)', - )] - public int $approve = 0; - #[OA\Property( - property: 'fixed', - type: 'integer', - description: 'Колонка post.fixed', - )] - public int $fixed = 0; - #[OA\Property( - property: 'allow_br', - type: 'integer', - description: 'Колонка post.allow_br', - )] - public int $allow_br = 1; - #[OA\Property( - property: 'symbol', - type: 'string', - description: 'Колонка post.symbol', - )] - public string $symbol = ''; - #[OA\Property( - property: 'tags', - type: 'string', - description: 'Колонка post.tags', - )] - public string $tags = ''; - #[OA\Property( - property: 'metatitle', - type: 'string', - description: 'Колонка post.metatitle', - )] - public string $metatitle = ''; - - public function table(): string { - return 'post'; - } - - protected function columnList(): array { - return [ - 'id', - 'autor', - 'date', - 'short_story', - 'full_story', - 'xfields', - 'title', - 'descr', - 'keywords', - 'category', - 'alt_name', - 'comm_num', - 'allow_comm', - 'allow_main', - 'approve', - 'fixed', - 'allow_br', - 'symbol', - 'tags', - 'metatitle', - ]; - } - - protected function defaultMap(): array { - return [ - 'autor' => '', - 'date' => '2000-01-01 00:00:00', - 'short_story' => '', - 'full_story' => '', - 'xfields' => '', - 'title' => '', - 'descr' => '', - 'keywords' => '', - 'category' => '', - 'alt_name' => '', - 'comm_num' => 0, - 'allow_comm' => 1, - 'allow_main' => 1, - 'approve' => 0, - 'fixed' => 0, - 'allow_br' => 1, - 'symbol' => '', - 'tags' => '', - 'metatitle' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } - - /** @var array */ - private array $xfieldMap = []; - - public function withTitle(string $title): static { - return $this->with('title', $title); - } - - public function withShortStory(string $text): static { - return $this->with('short_story', $text); - } - - public function withFullStory(string $text): static { - return $this->with('full_story', $text); - } - - public function withAutor(string $autor): static { - return $this->with('autor', $autor); - } - - /** - * @param int|string|list $category - */ - public function withCategory(int|string|array $category): static { - [$csv, $ids] = self::normalizeCategoryIds($category); - $this->with('category', $csv); - $this->replaceExtrasCats($ids); - - return $this; - } - - /** - * @param int|string|list $category - */ - public function withExtrasCats(int|string|array $category): static { - return $this->withCategory($category); - } - - public function withExtras( - #[\JetBrains\PhpStorm\ExpectedValues(values: [ - 'news_read', 'allow_rate', 'rating', 'vote_num', 'votes', 'view_edit', 'disable_index', - 'related_ids', 'access', 'editdate', 'editor', 'reason', 'user_id', 'disable_search', - 'need_pass', 'allow_rss', 'allow_rss_dzen', 'edited_now', 'allowed_country', 'not_allowed_country', - ])] - string $attrName, - mixed $value, - ): static { - $this->extrasEntity()->with($attrName, $value); - - return $this; - } - - public function withExtrasEntity(PostExtrasSchema $entity): static { - $this->childEntities['post_extras'] = [$entity]; - - return $this; - } - - public function withPass( - #[\JetBrains\PhpStorm\ExpectedValues(values: ['password'])] - string $attrName, - mixed $value, - ): static { - $this->passEntity()->with($attrName, $value); - - return $this; - } - - public function withPassEntity(PostPassSchema $entity): static { - $this->childEntities['post_pass'] = [$entity]; - - return $this; - } - - public function withXfield(string $fieldName, mixed $value): static { - $this->xfieldMap[$fieldName] = $value; - - return $this; - } - - /** - * @param array $fields - */ - public function withXfields(array $fields): static { - $this->xfieldMap = array_merge($this->xfieldMap, $fields); - - return $this; - } - - public function withImagesEntity(ImagesSchema $entity): static { - return $this->attachChildEntity('images', $entity); - } - - public function withFilesEntity(FilesSchema $entity): static { - return $this->attachChildEntity('files', $entity); - } - - public function withCommentsEntity(CommentsSchema $entity): static { - return $this->attachChildEntity('comments', $entity); - } - - public function withPollEntity(PollSchema $entity): static { - return $this->attachChildEntity('poll', $entity); - } - - public function create(): static { - $this->flushXfields(); - - return parent::create(); - } - - public function save(): static { - $this->flushXfields(); - - return parent::save(); - } - - private function flushXfields(): void { - if($this->xfieldMap === []) { - return; - } - $this->with('xfields', \DleApi\Xfield\XfieldValueEncoder::encode($this->xfieldMap)); - } - - private function extrasEntity(): PostExtrasSchema { - if(!isset($this->childEntities['post_extras'][0]) || !$this->childEntities['post_extras'][0] instanceof PostExtrasSchema) { - $this->childEntities['post_extras'] = [new PostExtrasSchema()]; - } - - return $this->childEntities['post_extras'][0]; - } - - private function passEntity(): PostPassSchema { - if(!isset($this->childEntities['post_pass'][0]) || !$this->childEntities['post_pass'][0] instanceof PostPassSchema) { - $this->childEntities['post_pass'] = [new PostPassSchema()]; - } - - return $this->childEntities['post_pass'][0]; - } - - /** - * @param list $ids - */ - private function replaceExtrasCats(array $ids): void { - $this->childEntities['post_extras_cats'] = []; - foreach($ids as $id) { - if($id < 1) { - continue; - } - $cat = new PostExtrasCatsSchema(); - $cat->with('cat_id', $id); - $this->attachChildEntity('post_extras_cats', $cat); - } - } - - /** - * @param int|string|list $category - * @return array{0: string, 1: list} - */ - private static function normalizeCategoryIds(int|string|array $category): array { - if(is_array($category)) { - $ids = array_values(array_filter(array_map(static fn($v) => (int) $v, $category), static fn(int $v) => $v > 0)); - - return [implode(',', $ids), $ids]; - } - $csv = (string) $category; - $ids = array_values(array_filter(array_map(static fn($v) => (int) $v, explode(',', $csv)), static fn(int $v) => $v > 0)); - - return [$csv, $ids]; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/QuestionSchema.php b/upload/api/src/Schema/QuestionSchema.php index 374b679b..94bc824a 100644 --- a/upload/api/src/Schema/QuestionSchema.php +++ b/upload/api/src/Schema/QuestionSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'answer' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/ReadLogSchema.php b/upload/api/src/Schema/ReadLogSchema.php index 3b105711..4f2a9def 100644 --- a/upload/api/src/Schema/ReadLogSchema.php +++ b/upload/api/src/Schema/ReadLogSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'ip' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/RedirectsSchema.php b/upload/api/src/Schema/RedirectsSchema.php index a7b0a63a..56d166e3 100644 --- a/upload/api/src/Schema/RedirectsSchema.php +++ b/upload/api/src/Schema/RedirectsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'to' => '', - 'enabled' => 1, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/RssSchema.php b/upload/api/src/Schema/RssSchema.php index 120599dd..78c55fd4 100644 --- a/upload/api/src/Schema/RssSchema.php +++ b/upload/api/src/Schema/RssSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'description' => '', - 'allow_main' => 0, - 'allow_rating' => 0, - 'allow_comm' => 0, - 'text_type' => 0, - 'date' => 0, - 'search' => '', - 'max_news' => 0, - 'cookie' => '', - 'category' => '', - 'lastdate' => 0, - 'allow_source' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/RssinformSchema.php b/upload/api/src/Schema/RssinformSchema.php index a244a72d..37de0cc3 100644 --- a/upload/api/src/Schema/RssinformSchema.php +++ b/upload/api/src/Schema/RssinformSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'descr' => '', - 'category' => '', - 'url' => '', - 'template' => '', - 'news_max' => 0, - 'tmax' => 0, - 'dmax' => 0, - 'approve' => 1, - 'rss_date_format' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/SendlogSchema.php b/upload/api/src/Schema/SendlogSchema.php index a79481d5..0acbbb73 100644 --- a/upload/api/src/Schema/SendlogSchema.php +++ b/upload/api/src/Schema/SendlogSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'date' => 0, - 'flag' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/SocialLoginSchema.php b/upload/api/src/Schema/SocialLoginSchema.php index ae9a4039..739601af 100644 --- a/upload/api/src/Schema/SocialLoginSchema.php +++ b/upload/api/src/Schema/SocialLoginSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'uid' => 0, - 'password' => '', - 'provider' => '', - 'wait' => 0, - 'waitlogin' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/SpamLogSchema.php b/upload/api/src/Schema/SpamLogSchema.php index d893db18..43ad3198 100644 --- a/upload/api/src/Schema/SpamLogSchema.php +++ b/upload/api/src/Schema/SpamLogSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'is_spammer' => 0, - 'email' => '', - 'date' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/StaticFilesSchema.php b/upload/api/src/Schema/StaticFilesSchema.php index fe598a38..dc939429 100644 --- a/upload/api/src/Schema/StaticFilesSchema.php +++ b/upload/api/src/Schema/StaticFilesSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'author' => '', - 'date' => '', - 'name' => '', - 'onserver' => '', - 'dcount' => 0, - 'size' => 0, - 'checksum' => '', - 'driver' => 0, - 'is_public' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/StaticSchema.php b/upload/api/src/Schema/StaticSchema.php index dfcdd4d0..a642c330 100644 --- a/upload/api/src/Schema/StaticSchema.php +++ b/upload/api/src/Schema/StaticSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md with('metatitle', $metatitle); } } -||||||| -======= - '', - 'descr' => '', - 'template' => '', - 'allow_br' => 0, - 'allow_template' => 0, - 'grouplevel' => 'all', - 'tpl' => '', - 'metadescr' => '', - 'metakeys' => '', - 'views' => 0, - 'template_folder' => '', - 'date' => 0, - 'metatitle' => '', - 'allow_count' => 1, - 'sitemap' => 1, - 'disable_index' => 0, - 'disable_search' => 0, - 'password' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } - - public function withName(string $name): static { - return $this->with('name', $name); - } - - public function withDescr(string $descr): static { - return $this->with('descr', $descr); - } - - public function withTemplate(string $template): static { - return $this->with('template', $template); - } - - public function withPassword(string $password): static { - return $this->with('password', $password); - } - - public function withMetatitle(string $metatitle): static { - return $this->with('metatitle', $metatitle); - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/StorageSchema.php b/upload/api/src/Schema/StorageSchema.php index e4bf406b..8d89a3b3 100644 --- a/upload/api/src/Schema/StorageSchema.php +++ b/upload/api/src/Schema/StorageSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'type' => 0, - 'accesstype' => '', - 'connect_url' => '', - 'connect_port' => 0, - 'username' => '', - 'password' => '', - 'path' => '', - 'http_url' => '', - 'client_key' => '', - 'secret_key' => '', - 'bucket' => '', - 'region' => '', - 'default_storage' => 0, - 'enabled' => 1, - 'posi' => 1, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/SubscribeSchema.php b/upload/api/src/Schema/SubscribeSchema.php index a972a3eb..dcbae8db 100644 --- a/upload/api/src/Schema/SubscribeSchema.php +++ b/upload/api/src/Schema/SubscribeSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'name' => '', - 'email' => '', - 'news_id' => 0, - 'hash' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/TagsSchema.php b/upload/api/src/Schema/TagsSchema.php index 9e617a3b..15ac30b7 100644 --- a/upload/api/src/Schema/TagsSchema.php +++ b/upload/api/src/Schema/TagsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'tag' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/TwofactorSchema.php b/upload/api/src/Schema/TwofactorSchema.php index ceafaaac..365ca836 100644 --- a/upload/api/src/Schema/TwofactorSchema.php +++ b/upload/api/src/Schema/TwofactorSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'pin' => '', - 'attempt' => 0, - 'date' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/UsergroupsSchema.php b/upload/api/src/Schema/UsergroupsSchema.php index fe47f98b..061808dc 100644 --- a/upload/api/src/Schema/UsergroupsSchema.php +++ b/upload/api/src/Schema/UsergroupsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'allow_cats' => '', - 'allow_adds' => 1, - 'cat_add' => '', - 'allow_admin' => 0, - 'allow_addc' => 0, - 'allow_editc' => 0, - 'allow_delc' => 0, - 'edit_allc' => 0, - 'del_allc' => 0, - 'moderation' => 0, - 'allow_all_edit' => 0, - 'allow_edit' => 0, - 'allow_pm' => 0, - 'max_pm' => 0, - 'max_foto' => '', - 'allow_files' => 0, - 'allow_hide' => 1, - 'allow_short' => 0, - 'time_limit' => 0, - 'rid' => 0, - 'allow_fixed' => 0, - 'allow_feed' => 1, - 'allow_search' => 1, - 'allow_poll' => 1, - 'allow_main' => 1, - 'captcha' => 0, - 'icon' => '', - 'allow_modc' => 0, - 'allow_rating' => 1, - 'allow_offline' => 0, - 'allow_image_upload' => 0, - 'allow_file_upload' => 0, - 'allow_signature' => 0, - 'allow_url' => 1, - 'news_sec_code' => 1, - 'allow_image' => 0, - 'max_signature' => 0, - 'max_info' => 0, - 'admin_addnews' => 0, - 'admin_editnews' => 0, - 'admin_comments' => 0, - 'admin_categories' => 0, - 'admin_editusers' => 0, - 'admin_wordfilter' => 0, - 'admin_xfields' => 0, - 'admin_userfields' => 0, - 'admin_static' => 0, - 'admin_editvote' => 0, - 'admin_newsletter' => 0, - 'admin_blockip' => 0, - 'admin_banners' => 0, - 'admin_rss' => 0, - 'admin_iptools' => 0, - 'admin_rssinform' => 0, - 'admin_googlemap' => 0, - 'allow_html' => 1, - 'group_prefix' => '', - 'group_suffix' => '', - 'allow_subscribe' => 0, - 'allow_image_size' => 0, - 'cat_allow_addnews' => '', - 'flood_news' => 0, - 'max_day_news' => 0, - 'force_leech' => 0, - 'edit_limit' => 0, - 'captcha_pm' => 0, - 'max_pm_day' => 0, - 'max_mail_day' => 0, - 'admin_tagscloud' => 0, - 'allow_vote' => 0, - 'admin_complaint' => 0, - 'news_question' => 0, - 'comments_question' => 0, - 'max_comment_day' => 0, - 'max_images' => 0, - 'max_files' => 0, - 'disable_news_captcha' => 0, - 'disable_comments_captcha' => 0, - 'pm_question' => 0, - 'captcha_feedback' => 1, - 'feedback_question' => 0, - 'files_type' => '', - 'max_file_size' => 0, - 'files_max_speed' => 0, - 'spamfilter' => 2, - 'allow_comments_rating' => 1, - 'max_edit_days' => 0, - 'spampmfilter' => 0, - 'force_reg' => 0, - 'force_reg_days' => 0, - 'force_reg_group' => 4, - 'force_news' => 0, - 'force_news_count' => 0, - 'force_news_group' => 4, - 'force_comments' => 0, - 'force_comments_count' => 0, - 'force_comments_group' => 4, - 'force_rating' => 0, - 'force_rating_count' => 0, - 'force_rating_group' => 4, - 'not_allow_cats' => '', - 'allow_up_image' => 0, - 'allow_up_watermark' => 0, - 'allow_up_thumb' => 0, - 'up_count_image' => 0, - 'up_image_side' => '', - 'up_image_size' => 0, - 'up_thumb_size' => '', - 'allow_mail_files' => 0, - 'max_mail_files' => 0, - 'max_mail_allfiles' => 0, - 'mail_files_type' => '', - 'video_comments' => 0, - 'media_comments' => 0, - 'min_image_side' => '', - 'allow_public_file_upload' => 0, - 'force_comments_rating' => 0, - 'force_comments_rating_count' => 0, - 'force_comments_rating_group' => 0, - 'max_downloads' => 0, - 'admin_links' => 0, - 'admin_meta' => 0, - 'admin_redirects' => 0, - 'allow_change_storage' => 0, - 'self_delete' => 2, - 'allow_complaint_news' => 1, - 'allow_complaint_comments' => 1, - 'allow_complaint_orfo' => 1, - 'flood_time' => 0, - 'max_c_negative' => 0, - 'max_n_negative' => 0, - 'rating_n_day' => 0, - 'rating_c_day' => 0, - 'allow_rating_change' => 1, - 'allow_crating_change' => 1, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/UsersDeleteSchema.php b/upload/api/src/Schema/UsersDeleteSchema.php index 8d3b6cd7..7f254ec4 100644 --- a/upload/api/src/Schema/UsersDeleteSchema.php +++ b/upload/api/src/Schema/UsersDeleteSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/UsersSchema.php b/upload/api/src/Schema/UsersSchema.php index 44fd1b17..eefe6c49 100644 --- a/upload/api/src/Schema/UsersSchema.php +++ b/upload/api/src/Schema/UsersSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md with('user_group', $userGroup); } } -||||||| -======= - '', - 'password' => '', - 'name' => '', - 'news_num' => 0, - 'comm_num' => 0, - 'user_group' => 4, - 'lastdate' => '', - 'reg_date' => '', - 'banned' => '', - 'allow_mail' => 1, - 'info' => '', - 'signature' => '', - 'foto' => '', - 'fullname' => '', - 'land' => '', - 'favorites' => '', - 'pm_all' => 0, - 'pm_unread' => 0, - 'time_limit' => '', - 'xfields' => '', - 'allowed_ip' => '', - 'hash' => '', - 'logged_ip' => '', - 'restricted' => 0, - 'restricted_days' => 0, - 'restricted_date' => '', - 'timezone' => '', - 'news_subscribe' => 0, - 'comments_reply_subscribe' => 0, - 'twofactor_auth' => 0, - 'cat_add' => '', - 'cat_allow_addnews' => '', - 'twofactor_secret' => '', - ]; - } - - public function primaryKey(): string|array { - return 'user_id'; - } - - public function withName(string $name): static { - return $this->with('name', $name); - } - - public function withEmail(string $email): static { - return $this->with('email', $email); - } - - public function withPassword(string $password): static { - return $this->with('password', $password); - } - - public function withUsergroup(int $userGroup): static { - return $this->with('user_group', $userGroup); - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/ViewsSchema.php b/upload/api/src/Schema/ViewsSchema.php index 0ffdbeff..e6126875 100644 --- a/upload/api/src/Schema/ViewsSchema.php +++ b/upload/api/src/Schema/ViewsSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/VoteResultSchema.php b/upload/api/src/Schema/VoteResultSchema.php index 3fac14a8..70a4fb20 100644 --- a/upload/api/src/Schema/VoteResultSchema.php +++ b/upload/api/src/Schema/VoteResultSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'name' => '', - 'vote_id' => 0, - 'answer' => 0, - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/VoteSchema.php b/upload/api/src/Schema/VoteSchema.php index af12a09e..368103fd 100644 --- a/upload/api/src/Schema/VoteSchema.php +++ b/upload/api/src/Schema/VoteSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md '', - 'vote_num' => 0, - 'date' => 0, - 'title' => '', - 'body' => '', - 'approve' => 1, - 'start' => '', - 'end' => '', - 'grouplevel' => 'all', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Schema/XfsearchSchema.php b/upload/api/src/Schema/XfsearchSchema.php index 63c96783..e95f39e5 100644 --- a/upload/api/src/Schema/XfsearchSchema.php +++ b/upload/api/src/Schema/XfsearchSchema.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md 0, - 'tagname' => '', - 'tagvalue' => '', - ]; - } - - public function primaryKey(): string|array { - return 'id'; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/src/Sdk/Presenter/TablePresenter.php b/upload/api/src/Sdk/Presenter/TablePresenter.php index b155b45b..0810895a 100644 --- a/upload/api/src/Sdk/Presenter/TablePresenter.php +++ b/upload/api/src/Sdk/Presenter/TablePresenter.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md tableName; } } -||||||| -======= -tableName; - } -} ->>>>>>> Current commit: Начало обновления до api v2 diff --git a/upload/api/v2/routes.php b/upload/api/v2/routes.php index 389bddc2..413d240d 100644 --- a/upload/api/v2/routes.php +++ b/upload/api/v2/routes.php @@ -1,4 +1,3 @@ -<<<<<<< New base: Update README.md patch('/xfields/{scope}/{name}[/]', [$xf, 'patch']); $group->delete('/xfields/{scope}/{name}[/]', [$xf, 'delete']); })->add(new BearerAuthMiddleware()); -||||||| -======= -group('', function (RouteCollectorProxy $group) { - $oauth = new OauthController(); - $group->post('/oauth/token[/]', [$oauth, 'token']); - $group->post('/oauth/revoke[/]', [$oauth, 'revoke']); - $group->map(['GET', 'POST'], '/oauth/authorize[/]', [$oauth, 'authorize']); - $group->get('/.well-known/oauth-authorization-server[/]', [$oauth, 'discovery']); - $group->get('/health[/]', [new ResourceController(), 'health']); -}); - -$app->group('', function (RouteCollectorProxy $group) { - $group->get('/key/check[/]', [new ApiKeyCheckController(), 'check']); -})->add(new ApiKeyAuthMiddleware()); - -$app->group('', function (RouteCollectorProxy $group) { - $table = new TableCrudController(); - $resource = new ResourceController(); - $xf = new XfieldController(); - $up = new UploadController(); - $me = new MeController(); - $oauth = new OauthController(); - - $group->get('/me[/]', [$me, 'me']); - $group->get('/oauth/userinfo[/]', [$oauth, 'userinfo']); - - $group->get('/post[/]', [$resource, 'listPosts']); - $group->get('/post/{id}[/]', [$resource, 'getPost']); - $group->post('/post[/]', [$resource, 'createPost']); - $group->post('/user[/]', [$resource, 'createUser']); - $group->post('/usergroup[/]', [$resource, 'createUsergroup']); - $group->post('/plugin[/]', [$resource, 'createPlugin']); - $group->get('/conversations[/]', [$resource, 'conversations']); - - $group->get('/table/{name}[/]', [$table, 'list']); - $group->get('/table/{name}/{id}[/]', [$table, 'get']); - $group->post('/table/{name}[/]', [$table, 'create']); - $group->put('/table/{name}/{id}[/]', [$table, 'update']); - $group->delete('/table/{name}/{id}[/]', [$table, 'delete']); - - $group->post('/upload[/]', [$up, 'upload']); - - $group->get('/xfields/{scope}[/]', [$xf, 'list']); - $group->post('/xfields/{scope}/encode[/]', [$xf, 'encode']); - $group->get('/xfields/{scope}/{name}[/]', [$xf, 'get']); - $group->post('/xfields/{scope}[/]', [$xf, 'create']); - $group->put('/xfields/{scope}/{name}[/]', [$xf, 'put']); - $group->patch('/xfields/{scope}/{name}[/]', [$xf, 'patch']); - $group->delete('/xfields/{scope}/{name}[/]', [$xf, 'delete']); -})->add(new BearerAuthMiddleware()); ->>>>>>> Current commit: Начало обновления до api v2