Merge branch '1.6.x' into fix-redirect-validator-v2

This commit is contained in:
Luke B. Silver 2025-01-27 11:00:03 +00:00 committed by GitHub
commit c30689d664
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 168 additions and 75 deletions

View file

@ -1,8 +1,10 @@
<?php <?php
return [ // Accepted inputs files return [
'jpg' => 'image/jpeg', // Accepted inputs files
'jpeg' => 'image/jpeg', "jpg" => "image/jpeg",
'gif' => 'image/gif', "jpeg" => "image/jpeg",
'png' => 'image/png', "gif" => "image/gif",
"png" => "image/png",
"heic" => "image/heic",
]; ];

View file

@ -1,70 +1,71 @@
<?php <?php
return [ return [
'image/jpeg', "image/jpeg",
'image/jpeg', "image/jpeg",
'image/gif', "image/gif",
'image/png', "image/png",
'image/webp', "image/webp",
// 'image/heic', "image/heic",
'image/avif', "image/heic-sequence",
"image/avif",
// Video Files // Video Files
'video/mp4', "video/mp4",
'video/x-flv', "video/x-flv",
'video/webm', "video/webm",
'application/x-mpegURL', "application/x-mpegURL",
'video/MP2T', "video/MP2T",
'video/3gpp', "video/3gpp",
'video/quicktime', "video/quicktime",
'video/x-msvideo', "video/x-msvideo",
'video/x-ms-wmv', "video/x-ms-wmv",
// Audio Files // Audio Files
'audio/basic', // au snd RFC 2046 "audio/basic", // au snd RFC 2046
'auido/L24', // Linear PCM RFC 3190 "auido/L24", // Linear PCM RFC 3190
'audio/mid', // mid rmi "audio/mid", // mid rmi
'audio/mpeg', // mp3 RFC 3003 "audio/mpeg", // mp3 RFC 3003
'audio/mp4', // mp4 audio "audio/mp4", // mp4 audio
'audio/x-aiff', // aif aifc aiff "audio/x-aiff", // aif aifc aiff
'audio/x-mpegurl', // m3u "audio/x-mpegurl", // m3u
'audio/vnd.rn-realaudio', // ra ram "audio/vnd.rn-realaudio", // ra ram
'audio/ogg', // Ogg Vorbis RFC 5334 "audio/ogg", // Ogg Vorbis RFC 5334
'audio/vorbis', // Vorbis RFC 5215 "audio/vorbis", // Vorbis RFC 5215
'audio/vnd.wav', // wav RFC 2361 "audio/vnd.wav", // wav RFC 2361
'audio/x-wav', // php reads .wav as this - https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types "audio/x-wav", // php reads .wav as this - https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
'audio/aac', //AAC audio "audio/aac", //AAC audio
'audio/x-hx-aac-adts', // AAC audio "audio/x-hx-aac-adts", // AAC audio
// Microsoft Word // Microsoft Word
'application/msword', "application/msword",
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
'application/vnd.openxmlformats-officedocument.wordprocessingml.template', "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
'application/vnd.ms-word.document.macroEnabled.12', "application/vnd.ms-word.document.macroEnabled.12",
// Microsoft Excel // Microsoft Excel
'application/vnd.ms-excel', "application/vnd.ms-excel",
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
'application/vnd.openxmlformats-officedocument.spreadsheetml.template', "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
'application/vnd.ms-excel.sheet.macroEnabled.12', "application/vnd.ms-excel.sheet.macroEnabled.12",
'application/vnd.ms-excel.template.macroEnabled.12', "application/vnd.ms-excel.template.macroEnabled.12",
'application/vnd.ms-excel.addin.macroEnabled.12', "application/vnd.ms-excel.addin.macroEnabled.12",
'application/vnd.ms-excel.sheet.binary.macroEnabled.12', "application/vnd.ms-excel.sheet.binary.macroEnabled.12",
// Microsoft Power Point // Microsoft Power Point
'application/vnd.ms-powerpoint', "application/vnd.ms-powerpoint",
'application/vnd.openxmlformats-officedocument.presentationml.presentation', "application/vnd.openxmlformats-officedocument.presentationml.presentation",
'application/vnd.openxmlformats-officedocument.presentationml.template', "application/vnd.openxmlformats-officedocument.presentationml.template",
'application/vnd.openxmlformats-officedocument.presentationml.slideshow', "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
'application/vnd.ms-powerpoint.addin.macroEnabled.12', "application/vnd.ms-powerpoint.addin.macroEnabled.12",
'application/vnd.ms-powerpoint.presentation.macroEnabled.12', "application/vnd.ms-powerpoint.presentation.macroEnabled.12",
'application/vnd.ms-powerpoint.template.macroEnabled.12', "application/vnd.ms-powerpoint.template.macroEnabled.12",
'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', "application/vnd.ms-powerpoint.slideshow.macroEnabled.12",
// Microsoft Access // Microsoft Access
'application/vnd.ms-access', "application/vnd.ms-access",
// Adobe PDF // Adobe PDF
'application/pdf', "application/pdf",
]; ];

View file

@ -1,12 +1,12 @@
<?php <?php
return [ // Accepted outputs files return [
'jpg' => 'image/jpeg', // Accepted outputs files
'jpeg' => 'image/jpeg', "jpg" => "image/jpeg",
'gif' => 'image/gif', "jpeg" => "image/jpeg",
'png' => 'image/png', "gif" => "image/gif",
'webp' => 'image/webp', "png" => "image/png",
// 'heic' => 'image/heic', "webp" => "image/webp",
// 'heics' => 'image/heic', "heic" => "image/heic",
'avif' => 'image/avif' "avif" => "image/avif",
]; ];

View file

@ -4185,7 +4185,9 @@ App::get('/v1/databases/usage')
METRIC_DATABASES, METRIC_DATABASES,
METRIC_COLLECTIONS, METRIC_COLLECTIONS,
METRIC_DOCUMENTS, METRIC_DOCUMENTS,
METRIC_DATABASES_STORAGE METRIC_DATABASES_STORAGE,
METRIC_DATABASES_OPERATIONS_READS,
METRIC_DATABASES_OPERATIONS_WRITES,
]; ];
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
@ -4237,10 +4239,14 @@ App::get('/v1/databases/usage')
'collectionsTotal' => $usage[$metrics[1]]['total'], 'collectionsTotal' => $usage[$metrics[1]]['total'],
'documentsTotal' => $usage[$metrics[2]]['total'], 'documentsTotal' => $usage[$metrics[2]]['total'],
'storageTotal' => $usage[$metrics[3]]['total'], 'storageTotal' => $usage[$metrics[3]]['total'],
'databasesReadsTotal' => $usage[$metrics[4]]['total'],
'databasesWritesTotal' => $usage[$metrics[5]]['total'],
'databases' => $usage[$metrics[0]]['data'], 'databases' => $usage[$metrics[0]]['data'],
'collections' => $usage[$metrics[1]]['data'], 'collections' => $usage[$metrics[1]]['data'],
'documents' => $usage[$metrics[2]]['data'], 'documents' => $usage[$metrics[2]]['data'],
'storage' => $usage[$metrics[3]]['data'], 'storage' => $usage[$metrics[3]]['data'],
'databasesReads' => $usage[$metrics[4]]['data'],
'databasesWrites' => $usage[$metrics[5]]['data'],
]), Response::MODEL_USAGE_DATABASES); ]), Response::MODEL_USAGE_DATABASES);
}); });
@ -4280,7 +4286,9 @@ App::get('/v1/databases/:databaseId/usage')
$metrics = [ $metrics = [
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_COLLECTIONS), str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_COLLECTIONS),
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_DOCUMENTS), str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_DOCUMENTS),
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_STORAGE) str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_STORAGE),
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASES_OPERATIONS_READS),
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASES_OPERATIONS_WRITES)
]; ];
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
@ -4332,9 +4340,13 @@ App::get('/v1/databases/:databaseId/usage')
'collectionsTotal' => $usage[$metrics[0]]['total'], 'collectionsTotal' => $usage[$metrics[0]]['total'],
'documentsTotal' => $usage[$metrics[1]]['total'], 'documentsTotal' => $usage[$metrics[1]]['total'],
'storageTotal' => $usage[$metrics[2]]['total'], 'storageTotal' => $usage[$metrics[2]]['total'],
'databaseReadsTotal' => $usage[$metrics[3]]['total'],
'databaseWritesTotal' => $usage[$metrics[4]]['total'],
'collections' => $usage[$metrics[0]]['data'], 'collections' => $usage[$metrics[0]]['data'],
'documents' => $usage[$metrics[1]]['data'], 'documents' => $usage[$metrics[1]]['data'],
'storage' => $usage[$metrics[2]]['data'], 'storage' => $usage[$metrics[2]]['data'],
'databaseReads' => $usage[$metrics[3]]['data'],
'databaseWrites' => $usage[$metrics[4]]['data'],
]), Response::MODEL_USAGE_DATABASE); ]), Response::MODEL_USAGE_DATABASE);
}); });

View file

@ -60,7 +60,9 @@ App::get('/v1/project/usage')
METRIC_FILES_STORAGE, METRIC_FILES_STORAGE,
METRIC_DATABASES_STORAGE, METRIC_DATABASES_STORAGE,
METRIC_DEPLOYMENTS_STORAGE, METRIC_DEPLOYMENTS_STORAGE,
METRIC_BUILDS_STORAGE METRIC_BUILDS_STORAGE,
METRIC_DATABASES_OPERATIONS_READS,
METRIC_DATABASES_OPERATIONS_WRITES,
], ],
'period' => [ 'period' => [
METRIC_NETWORK_REQUESTS, METRIC_NETWORK_REQUESTS,
@ -70,7 +72,9 @@ App::get('/v1/project/usage')
METRIC_EXECUTIONS, METRIC_EXECUTIONS,
METRIC_DATABASES_STORAGE, METRIC_DATABASES_STORAGE,
METRIC_EXECUTIONS_MB_SECONDS, METRIC_EXECUTIONS_MB_SECONDS,
METRIC_BUILDS_MB_SECONDS METRIC_BUILDS_MB_SECONDS,
METRIC_DATABASES_OPERATIONS_READS,
METRIC_DATABASES_OPERATIONS_WRITES,
] ]
]; ];
@ -346,10 +350,12 @@ App::get('/v1/project/usage')
'functionsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE] + $total[METRIC_BUILDS_STORAGE], 'functionsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE] + $total[METRIC_BUILDS_STORAGE],
'buildsStorageTotal' => $total[METRIC_BUILDS_STORAGE], 'buildsStorageTotal' => $total[METRIC_BUILDS_STORAGE],
'deploymentsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE], 'deploymentsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE],
'databasesReadsTotal' => $total[METRIC_DATABASES_OPERATIONS_READS],
'databasesWritesTotal' => $total[METRIC_DATABASES_OPERATIONS_WRITES],
'executionsBreakdown' => $executionsBreakdown, 'executionsBreakdown' => $executionsBreakdown,
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
'bucketsBreakdown' => $bucketsBreakdown, 'bucketsBreakdown' => $bucketsBreakdown,
'databasesReads' => $usage[METRIC_DATABASES_OPERATIONS_READS],
'databasesWrites' => $usage[METRIC_DATABASES_OPERATIONS_WRITES],
'databasesStorageBreakdown' => $databasesStorageBreakdown, 'databasesStorageBreakdown' => $databasesStorageBreakdown,
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown, 'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown, 'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,

View file

@ -34,6 +34,18 @@ class UsageDatabase extends Model
'default' => 0, 'default' => 0,
'example' => 0, 'example' => 0,
]) ])
->addRule('databaseReadsTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases reads.',
'default' => 0,
'example' => 0,
])
->addRule('databaseWritesTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases writes.',
'default' => 0,
'example' => 0,
])
->addRule('collections', [ ->addRule('collections', [
'type' => Response::MODEL_METRIC, 'type' => Response::MODEL_METRIC,
'description' => 'Aggregated number of collections per period.', 'description' => 'Aggregated number of collections per period.',
@ -55,6 +67,18 @@ class UsageDatabase extends Model
'example' => [], 'example' => [],
'array' => true 'array' => true
]) ])
->addRule('databaseReads', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database reads.',
'default' => 0,
'example' => 0,
])
->addRule('databaseWrites', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database writes.',
'default' => 0,
'example' => 0,
])
; ;
} }

View file

@ -40,6 +40,18 @@ class UsageDatabases extends Model
'default' => 0, 'default' => 0,
'example' => 0, 'example' => 0,
]) ])
->addRule('databasesReadsTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases reads.',
'default' => 0,
'example' => 0,
])
->addRule('databasesWritesTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases writes.',
'default' => 0,
'example' => 0,
])
->addRule('databases', [ ->addRule('databases', [
'type' => Response::MODEL_METRIC, 'type' => Response::MODEL_METRIC,
'description' => 'Aggregated number of databases per period.', 'description' => 'Aggregated number of databases per period.',
@ -68,6 +80,18 @@ class UsageDatabases extends Model
'example' => [], 'example' => [],
'array' => true 'array' => true
]) ])
->addRule('databasesReads', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database reads.',
'default' => 0,
'example' => 0,
])
->addRule('databasesWrites', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database writes.',
'default' => 0,
'example' => 0,
])
; ;
} }

View file

@ -82,6 +82,18 @@ class UsageProject extends Model
'default' => 0, 'default' => 0,
'example' => 0, 'example' => 0,
]) ])
->addRule('databasesReadsTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases reads.',
'default' => 0,
'example' => 0,
])
->addRule('databasesWritesTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases writes.',
'default' => 0,
'example' => 0,
])
->addRule('requests', [ ->addRule('requests', [
'type' => Response::MODEL_METRIC, 'type' => Response::MODEL_METRIC,
'description' => 'Aggregated number of requests per period.', 'description' => 'Aggregated number of requests per period.',
@ -171,6 +183,18 @@ class UsageProject extends Model
'example' => [], 'example' => [],
'array' => true 'array' => true
]) ])
->addRule('databasesReads', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database reads.',
'default' => 0,
'example' => 0,
])
->addRule('databasesWrites', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database writes.',
'default' => 0,
'example' => 0,
])
; ;
} }

View file

@ -143,7 +143,7 @@ class UsageTest extends Scope
); );
$this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(25, count($response['body'])); $this->assertEquals(29, count($response['body']));
$this->validateDates($response['body']['network']); $this->validateDates($response['body']['network']);
$this->validateDates($response['body']['requests']); $this->validateDates($response['body']['requests']);
$this->validateDates($response['body']['users']); $this->validateDates($response['body']['users']);
@ -324,7 +324,7 @@ class UsageTest extends Scope
] ]
); );
$this->assertEquals(25, count($response['body'])); $this->assertEquals(29, count($response['body']));
$this->assertEquals(1, count($response['body']['requests'])); $this->assertEquals(1, count($response['body']['requests']));
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']); $this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
$this->validateDates($response['body']['requests']); $this->validateDates($response['body']['requests']);
@ -545,7 +545,7 @@ class UsageTest extends Scope
] ]
); );
$this->assertEquals(25, count($response['body'])); $this->assertEquals(29, count($response['body']));
$this->assertEquals(1, count($response['body']['requests'])); $this->assertEquals(1, count($response['body']['requests']));
$this->assertEquals(1, count($response['body']['network'])); $this->assertEquals(1, count($response['body']['network']));
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']); $this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);

View file

@ -224,7 +224,7 @@ class DatabasesConsoleClientTest extends Scope
]); ]);
$this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(7, count($response['body'])); $this->assertEquals(11, count($response['body']));
$this->assertEquals('24h', $response['body']['range']); $this->assertEquals('24h', $response['body']['range']);
$this->assertIsNumeric($response['body']['documentsTotal']); $this->assertIsNumeric($response['body']['documentsTotal']);
$this->assertIsNumeric($response['body']['collectionsTotal']); $this->assertIsNumeric($response['body']['collectionsTotal']);