@studiometa/forge-core 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/executors/daemons/get-log.d.ts +7 -0
- package/dist/executors/daemons/get-log.d.ts.map +1 -0
- package/dist/executors/daemons/index.d.ts +2 -1
- package/dist/executors/daemons/index.d.ts.map +1 -1
- package/dist/executors/daemons/types.d.ts +7 -0
- package/dist/executors/daemons/types.d.ts.map +1 -1
- package/dist/executors/php/config.d.ts +11 -0
- package/dist/executors/php/config.d.ts.map +1 -0
- package/dist/executors/php/index.d.ts +7 -0
- package/dist/executors/php/index.d.ts.map +1 -0
- package/dist/executors/php/limits.d.ts +19 -0
- package/dist/executors/php/limits.d.ts.map +1 -0
- package/dist/executors/php/opcache.d.ts +15 -0
- package/dist/executors/php/opcache.d.ts.map +1 -0
- package/dist/executors/php/types.d.ts +57 -0
- package/dist/executors/php/types.d.ts.map +1 -0
- package/dist/executors/php/versions.d.ts +24 -0
- package/dist/executors/php/versions.d.ts.map +1 -0
- package/dist/executors/servers/list.d.ts +1 -1
- package/dist/executors/servers/list.d.ts.map +1 -1
- package/dist/executors/services/index.d.ts +5 -0
- package/dist/executors/services/index.d.ts.map +1 -0
- package/dist/executors/services/list.d.ts +17 -0
- package/dist/executors/services/list.d.ts.map +1 -0
- package/dist/executors/services/restart.d.ts +11 -0
- package/dist/executors/services/restart.d.ts.map +1 -0
- package/dist/executors/services/types.d.ts +39 -0
- package/dist/executors/services/types.d.ts.map +1 -0
- package/dist/executors/ssh-keys/list.d.ts +1 -1
- package/dist/executors/ssh-keys/list.d.ts.map +1 -1
- package/dist/executors/ssh-keys/types.d.ts +2 -0
- package/dist/executors/ssh-keys/types.d.ts.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +332 -6
- package/dist/index.js.map +1 -1
- package/dist/routes.d.ts +52 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/utils/list-all-pages.d.ts +11 -0
- package/dist/utils/list-all-pages.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createWriteStream, mkdirSync } from "node:fs";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import pino from "pino";
|
|
5
|
-
import { BackgroundProcessAttributesSchema, BackupConfigAttributesSchema, CertificateAttributesSchema, CommandAttributesSchema, DatabaseAttributesSchema, DatabaseUserAttributesSchema, DeploymentAttributesSchema, DeploymentOutputAttributesSchema, DeploymentScriptAttributesSchema, EnvironmentAttributesSchema, FirewallRuleAttributesSchema, MonitorAttributesSchema, NginxTemplateAttributesSchema, RecipeAttributesSchema, RedirectRuleAttributesSchema, ScheduledJobAttributesSchema, SecurityRuleAttributesSchema, ServerAttributesSchema, SiteAttributesSchema, SshKeyAttributesSchema, UserAttributesSchema, jsonApiDocumentSchema, jsonApiListDocumentSchema, unwrapDocument, unwrapListDocument } from "@studiometa/forge-api";
|
|
5
|
+
import { BackgroundProcessAttributesSchema, BackgroundProcessLogAttributesSchema, BackupConfigAttributesSchema, CertificateAttributesSchema, CommandAttributesSchema, DatabaseAttributesSchema, DatabaseUserAttributesSchema, DeploymentAttributesSchema, DeploymentOutputAttributesSchema, DeploymentScriptAttributesSchema, EnvironmentAttributesSchema, FirewallRuleAttributesSchema, MonitorAttributesSchema, NginxTemplateAttributesSchema, PhpConfigAttributesSchema, PhpMaxExecutionTimeAttributesSchema, PhpMaxUploadSizeAttributesSchema, PhpOpcacheAttributesSchema, PhpVersionAttributesSchema, RecipeAttributesSchema, RedirectRuleAttributesSchema, ScheduledJobAttributesSchema, SecurityRuleAttributesSchema, ServerAttributesSchema, SiteAttributesSchema, SshKeyAttributesSchema, UserAttributesSchema, jsonApiDocumentSchema, jsonApiListDocumentSchema, unwrapDocument, unwrapListDocument } from "@studiometa/forge-api";
|
|
6
6
|
//#region src/constants.ts
|
|
7
7
|
/**
|
|
8
8
|
* All supported resources.
|
|
@@ -28,6 +28,8 @@ var RESOURCES = [
|
|
|
28
28
|
"backups",
|
|
29
29
|
"commands",
|
|
30
30
|
"scheduled-jobs",
|
|
31
|
+
"services",
|
|
32
|
+
"php",
|
|
31
33
|
"user",
|
|
32
34
|
"batch"
|
|
33
35
|
];
|
|
@@ -643,6 +645,56 @@ var ROUTES = {
|
|
|
643
645
|
path: "/orgs/:org/servers/:server_id/sites/:site_id/scheduled-jobs/:id/output"
|
|
644
646
|
}
|
|
645
647
|
},
|
|
648
|
+
services: { action: {
|
|
649
|
+
method: "POST",
|
|
650
|
+
path: "/orgs/:org/servers/:server_id/services/:service/actions"
|
|
651
|
+
} },
|
|
652
|
+
php: {
|
|
653
|
+
listVersions: {
|
|
654
|
+
method: "GET",
|
|
655
|
+
path: "/orgs/:org/servers/:server_id/php/versions"
|
|
656
|
+
},
|
|
657
|
+
getVersion: {
|
|
658
|
+
method: "GET",
|
|
659
|
+
path: "/orgs/:org/servers/:server_id/php/versions/:version_id"
|
|
660
|
+
},
|
|
661
|
+
getConfig: {
|
|
662
|
+
method: "GET",
|
|
663
|
+
path: "/orgs/:org/servers/:server_id/php/versions/:version_id/configs/:type"
|
|
664
|
+
},
|
|
665
|
+
updateConfig: {
|
|
666
|
+
method: "PUT",
|
|
667
|
+
path: "/orgs/:org/servers/:server_id/php/versions/:version_id/configs/:type"
|
|
668
|
+
},
|
|
669
|
+
getMaxUploadSize: {
|
|
670
|
+
method: "GET",
|
|
671
|
+
path: "/orgs/:org/servers/:server_id/php/max-upload-size"
|
|
672
|
+
},
|
|
673
|
+
updateMaxUploadSize: {
|
|
674
|
+
method: "PUT",
|
|
675
|
+
path: "/orgs/:org/servers/:server_id/php/max-upload-size"
|
|
676
|
+
},
|
|
677
|
+
getMaxExecutionTime: {
|
|
678
|
+
method: "GET",
|
|
679
|
+
path: "/orgs/:org/servers/:server_id/php/max-execution-time"
|
|
680
|
+
},
|
|
681
|
+
updateMaxExecutionTime: {
|
|
682
|
+
method: "PUT",
|
|
683
|
+
path: "/orgs/:org/servers/:server_id/php/max-execution-time"
|
|
684
|
+
},
|
|
685
|
+
getOpcache: {
|
|
686
|
+
method: "GET",
|
|
687
|
+
path: "/orgs/:org/servers/:server_id/php/opcache"
|
|
688
|
+
},
|
|
689
|
+
enableOpcache: {
|
|
690
|
+
method: "POST",
|
|
691
|
+
path: "/orgs/:org/servers/:server_id/php/opcache"
|
|
692
|
+
},
|
|
693
|
+
disableOpcache: {
|
|
694
|
+
method: "DELETE",
|
|
695
|
+
path: "/orgs/:org/servers/:server_id/php/opcache"
|
|
696
|
+
}
|
|
697
|
+
},
|
|
646
698
|
user: { get: {
|
|
647
699
|
method: "GET",
|
|
648
700
|
path: "/user"
|
|
@@ -729,12 +781,35 @@ async function getServer(options, ctx) {
|
|
|
729
781
|
return { data: unwrapDocument(await request(ROUTES.servers.get, ctx, { server_id: options.server_id }, { schema: jsonApiDocumentSchema(ServerAttributesSchema) })) };
|
|
730
782
|
}
|
|
731
783
|
//#endregion
|
|
784
|
+
//#region src/utils/list-all-pages.ts
|
|
785
|
+
/**
|
|
786
|
+
* GET every page of a cursor-paginated list route and return all its resources.
|
|
787
|
+
* Follows `meta.next_cursor` until the API returns no cursor.
|
|
788
|
+
*/
|
|
789
|
+
async function listAllPages(route, ctx, params, attributes, query = {}) {
|
|
790
|
+
const schema = jsonApiListDocumentSchema(attributes);
|
|
791
|
+
const items = [];
|
|
792
|
+
let cursor;
|
|
793
|
+
do {
|
|
794
|
+
const response = await request(route, ctx, params, {
|
|
795
|
+
schema,
|
|
796
|
+
query: cursor ? {
|
|
797
|
+
...query,
|
|
798
|
+
"page[cursor]": cursor
|
|
799
|
+
} : query
|
|
800
|
+
});
|
|
801
|
+
items.push(...unwrapListDocument(response));
|
|
802
|
+
cursor = response.meta.next_cursor;
|
|
803
|
+
} while (cursor);
|
|
804
|
+
return items;
|
|
805
|
+
}
|
|
806
|
+
//#endregion
|
|
732
807
|
//#region src/executors/servers/list.ts
|
|
733
808
|
/**
|
|
734
|
-
* List all servers.
|
|
809
|
+
* List all servers, from every page.
|
|
735
810
|
*/
|
|
736
811
|
async function listServers(_options, ctx) {
|
|
737
|
-
return { data:
|
|
812
|
+
return { data: await listAllPages(ROUTES.servers.list, ctx, {}, ServerAttributesSchema) };
|
|
738
813
|
}
|
|
739
814
|
//#endregion
|
|
740
815
|
//#region src/executors/servers/reboot.ts
|
|
@@ -1187,6 +1262,17 @@ async function getDaemon(options, ctx) {
|
|
|
1187
1262
|
}, { schema: jsonApiDocumentSchema(BackgroundProcessAttributesSchema) })) };
|
|
1188
1263
|
}
|
|
1189
1264
|
//#endregion
|
|
1265
|
+
//#region src/executors/daemons/get-log.ts
|
|
1266
|
+
/**
|
|
1267
|
+
* Get the log output for a daemon (background process).
|
|
1268
|
+
*/
|
|
1269
|
+
async function getDaemonLog(options, ctx) {
|
|
1270
|
+
return { data: unwrapDocument(await request(ROUTES.daemons.log, ctx, {
|
|
1271
|
+
server_id: options.server_id,
|
|
1272
|
+
id: options.id
|
|
1273
|
+
}, { schema: jsonApiDocumentSchema(BackgroundProcessLogAttributesSchema) })).content };
|
|
1274
|
+
}
|
|
1275
|
+
//#endregion
|
|
1190
1276
|
//#region src/executors/daemons/list.ts
|
|
1191
1277
|
/**
|
|
1192
1278
|
* List daemons on a server.
|
|
@@ -1298,10 +1384,10 @@ async function getSshKey(options, ctx) {
|
|
|
1298
1384
|
//#endregion
|
|
1299
1385
|
//#region src/executors/ssh-keys/list.ts
|
|
1300
1386
|
/**
|
|
1301
|
-
* List SSH keys on a server.
|
|
1387
|
+
* List SSH keys on a server, from every page. Filter by server user with `user`.
|
|
1302
1388
|
*/
|
|
1303
1389
|
async function listSshKeys(options, ctx) {
|
|
1304
|
-
return { data:
|
|
1390
|
+
return { data: await listAllPages(ROUTES.sshKeys.list, ctx, { server_id: options.server_id }, SshKeyAttributesSchema, options.user ? { "filter[user]": options.user } : {}) };
|
|
1305
1391
|
}
|
|
1306
1392
|
//#endregion
|
|
1307
1393
|
//#region src/executors/security-rules/create.ts
|
|
@@ -1768,6 +1854,246 @@ async function listScheduledJobs(options, ctx) {
|
|
|
1768
1854
|
return { data: unwrapListDocument(await request(route, ctx, params, { schema: jsonApiListDocumentSchema(ScheduledJobAttributesSchema) })) };
|
|
1769
1855
|
}
|
|
1770
1856
|
//#endregion
|
|
1857
|
+
//#region src/executors/services/list.ts
|
|
1858
|
+
/**
|
|
1859
|
+
* List services on a server with a derived availability flag.
|
|
1860
|
+
*
|
|
1861
|
+
* The v2 API has no GET endpoint for services, so availability is inferred from
|
|
1862
|
+
* the server object attributes. This `available` flag is a documented heuristic:
|
|
1863
|
+
*
|
|
1864
|
+
* - nginx → always available
|
|
1865
|
+
* - php → available when `php_version` is set (detail = php_version)
|
|
1866
|
+
* - mysql → available when `database_type` starts with "mysql"/"mariadb"
|
|
1867
|
+
* - postgres → available when `database_type` starts with "postgres"
|
|
1868
|
+
* - redis → available when `redis_status` is non-null
|
|
1869
|
+
* - supervisor → always available
|
|
1870
|
+
*/
|
|
1871
|
+
async function listServices(options, ctx) {
|
|
1872
|
+
const { data: server } = await getServer({ server_id: options.server_id }, ctx);
|
|
1873
|
+
const databaseType = server.database_type ?? "";
|
|
1874
|
+
const isMysql = databaseType.startsWith("mysql") || databaseType.startsWith("mariadb");
|
|
1875
|
+
const isPostgres = databaseType.startsWith("postgres");
|
|
1876
|
+
return { data: [
|
|
1877
|
+
{
|
|
1878
|
+
service: "nginx",
|
|
1879
|
+
available: true,
|
|
1880
|
+
detail: null
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
service: "php",
|
|
1884
|
+
available: server.php_version !== null,
|
|
1885
|
+
detail: server.php_version
|
|
1886
|
+
},
|
|
1887
|
+
{
|
|
1888
|
+
service: "mysql",
|
|
1889
|
+
available: isMysql,
|
|
1890
|
+
detail: isMysql ? server.database_type : null
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
service: "postgres",
|
|
1894
|
+
available: isPostgres,
|
|
1895
|
+
detail: isPostgres ? server.database_type : null
|
|
1896
|
+
},
|
|
1897
|
+
{
|
|
1898
|
+
service: "redis",
|
|
1899
|
+
available: server.redis_status !== null,
|
|
1900
|
+
detail: server.redis_status
|
|
1901
|
+
},
|
|
1902
|
+
{
|
|
1903
|
+
service: "supervisor",
|
|
1904
|
+
available: true,
|
|
1905
|
+
detail: null
|
|
1906
|
+
}
|
|
1907
|
+
] };
|
|
1908
|
+
}
|
|
1909
|
+
//#endregion
|
|
1910
|
+
//#region src/executors/services/types.ts
|
|
1911
|
+
/**
|
|
1912
|
+
* Option and result types for service executors.
|
|
1913
|
+
*/
|
|
1914
|
+
/**
|
|
1915
|
+
* The six restartable services exposed by the Forge v2 API.
|
|
1916
|
+
*
|
|
1917
|
+
* There is no GET endpoint for services — availability is inferred from the
|
|
1918
|
+
* server object (see `listServices`).
|
|
1919
|
+
*/
|
|
1920
|
+
var RESTARTABLE_SERVICES = [
|
|
1921
|
+
"nginx",
|
|
1922
|
+
"php",
|
|
1923
|
+
"mysql",
|
|
1924
|
+
"postgres",
|
|
1925
|
+
"redis",
|
|
1926
|
+
"supervisor"
|
|
1927
|
+
];
|
|
1928
|
+
//#endregion
|
|
1929
|
+
//#region src/executors/services/restart.ts
|
|
1930
|
+
/**
|
|
1931
|
+
* Restart a service on a server.
|
|
1932
|
+
*
|
|
1933
|
+
* Maps the user verb "restart" to the API action "reboot". The v2 API restarts
|
|
1934
|
+
* a service via POST /servers/{server}/services/{service}/actions with body
|
|
1935
|
+
* `{ action: "reboot" }`. The php service additionally requires a `version`.
|
|
1936
|
+
*/
|
|
1937
|
+
async function restartService(options, ctx) {
|
|
1938
|
+
if (!RESTARTABLE_SERVICES.includes(options.service)) throw new Error(`Invalid service "${options.service}". Valid services: ${RESTARTABLE_SERVICES.join(", ")}.`);
|
|
1939
|
+
if (options.service === "php" && !options.version) throw new Error("The \"php\" service requires a version (e.g. \"php83\") to restart.");
|
|
1940
|
+
await request(ROUTES.services.action, ctx, {
|
|
1941
|
+
server_id: options.server_id,
|
|
1942
|
+
service: options.service
|
|
1943
|
+
}, { body: {
|
|
1944
|
+
action: "reboot",
|
|
1945
|
+
...options.version ? { version: options.version } : {}
|
|
1946
|
+
} });
|
|
1947
|
+
return { data: void 0 };
|
|
1948
|
+
}
|
|
1949
|
+
//#endregion
|
|
1950
|
+
//#region src/executors/php/types.ts
|
|
1951
|
+
/**
|
|
1952
|
+
* Option types for PHP executors.
|
|
1953
|
+
*/
|
|
1954
|
+
/**
|
|
1955
|
+
* The PHP configuration files that Forge can read and write.
|
|
1956
|
+
*/
|
|
1957
|
+
var PHP_CONFIG_TYPES = [
|
|
1958
|
+
"cli",
|
|
1959
|
+
"fpm",
|
|
1960
|
+
"pool"
|
|
1961
|
+
];
|
|
1962
|
+
//#endregion
|
|
1963
|
+
//#region src/executors/php/versions.ts
|
|
1964
|
+
/**
|
|
1965
|
+
* List the PHP versions installed on a server.
|
|
1966
|
+
*/
|
|
1967
|
+
async function listPhpVersions(options, ctx) {
|
|
1968
|
+
return { data: unwrapListDocument(await request(ROUTES.php.listVersions, ctx, { server_id: options.server_id }, { schema: jsonApiListDocumentSchema(PhpVersionAttributesSchema) })) };
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* Resolve a PHP version to its ID on a server.
|
|
1972
|
+
*
|
|
1973
|
+
* A numeric value is an ID and is returned as is, without an API call.
|
|
1974
|
+
* Any other value is matched against the installed versions: "8.3",
|
|
1975
|
+
* "php8.3" (binary name) and "php83" all match version 8.3.
|
|
1976
|
+
*/
|
|
1977
|
+
async function resolvePhpVersionId(server_id, version, ctx) {
|
|
1978
|
+
if (/^\d+$/.test(version)) return version;
|
|
1979
|
+
const { data: versions } = await listPhpVersions({ server_id }, ctx);
|
|
1980
|
+
const wanted = version.trim().toLowerCase();
|
|
1981
|
+
const match = versions.find((item) => [
|
|
1982
|
+
item.version,
|
|
1983
|
+
item.binary_name,
|
|
1984
|
+
`php${item.version}`,
|
|
1985
|
+
`php${item.version.replace(".", "")}`
|
|
1986
|
+
].map((name) => name.toLowerCase()).includes(wanted));
|
|
1987
|
+
if (!match) {
|
|
1988
|
+
const installed = versions.map((item) => item.version).join(", ") || "none";
|
|
1989
|
+
throw new Error(`PHP version "${version}" is not installed on server ${server_id}. Installed: ${installed}.`);
|
|
1990
|
+
}
|
|
1991
|
+
return String(match.id);
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* Get one installed PHP version.
|
|
1995
|
+
*/
|
|
1996
|
+
async function getPhpVersion(options, ctx) {
|
|
1997
|
+
const version_id = await resolvePhpVersionId(options.server_id, options.version, ctx);
|
|
1998
|
+
return { data: unwrapDocument(await request(ROUTES.php.getVersion, ctx, {
|
|
1999
|
+
server_id: options.server_id,
|
|
2000
|
+
version_id
|
|
2001
|
+
}, { schema: jsonApiDocumentSchema(PhpVersionAttributesSchema) })) };
|
|
2002
|
+
}
|
|
2003
|
+
//#endregion
|
|
2004
|
+
//#region src/executors/php/config.ts
|
|
2005
|
+
/**
|
|
2006
|
+
* Throw when the configuration type is not one of cli, fpm or pool,
|
|
2007
|
+
* or when a user is given for a type other than pool.
|
|
2008
|
+
*/
|
|
2009
|
+
function assertConfigTarget(type, user) {
|
|
2010
|
+
if (!PHP_CONFIG_TYPES.includes(type)) throw new Error(`Invalid PHP config type "${type}". Valid types: ${PHP_CONFIG_TYPES.join(", ")}.`);
|
|
2011
|
+
if (user && type !== "pool") throw new Error(`The user option applies to the pool config only, not "${type}".`);
|
|
2012
|
+
}
|
|
2013
|
+
/**
|
|
2014
|
+
* Get a PHP configuration file (cli, fpm or pool) for an installed version.
|
|
2015
|
+
*/
|
|
2016
|
+
async function getPhpConfig(options, ctx) {
|
|
2017
|
+
assertConfigTarget(options.type, options.user);
|
|
2018
|
+
const version_id = await resolvePhpVersionId(options.server_id, options.version, ctx);
|
|
2019
|
+
return { data: unwrapDocument(await request(ROUTES.php.getConfig, ctx, {
|
|
2020
|
+
server_id: options.server_id,
|
|
2021
|
+
version_id,
|
|
2022
|
+
type: options.type
|
|
2023
|
+
}, {
|
|
2024
|
+
schema: jsonApiDocumentSchema(PhpConfigAttributesSchema),
|
|
2025
|
+
...options.user ? { query: { user: options.user } } : {}
|
|
2026
|
+
})).configuration };
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* Replace a PHP configuration file (cli, fpm or pool) for an installed version.
|
|
2030
|
+
*/
|
|
2031
|
+
async function updatePhpConfig(options, ctx) {
|
|
2032
|
+
assertConfigTarget(options.type, options.user);
|
|
2033
|
+
const version_id = await resolvePhpVersionId(options.server_id, options.version, ctx);
|
|
2034
|
+
await request(ROUTES.php.updateConfig, ctx, {
|
|
2035
|
+
server_id: options.server_id,
|
|
2036
|
+
version_id,
|
|
2037
|
+
type: options.type
|
|
2038
|
+
}, { body: {
|
|
2039
|
+
config: options.content,
|
|
2040
|
+
...options.user ? { user: options.user } : {}
|
|
2041
|
+
} });
|
|
2042
|
+
return { data: void 0 };
|
|
2043
|
+
}
|
|
2044
|
+
//#endregion
|
|
2045
|
+
//#region src/executors/php/limits.ts
|
|
2046
|
+
/**
|
|
2047
|
+
* Get the PHP max upload size of a server, in megabytes.
|
|
2048
|
+
*/
|
|
2049
|
+
async function getPhpMaxUploadSize(options, ctx) {
|
|
2050
|
+
const response = await request(ROUTES.php.getMaxUploadSize, ctx, { server_id: options.server_id }, { schema: jsonApiDocumentSchema(PhpMaxUploadSizeAttributesSchema) });
|
|
2051
|
+
return { data: String(unwrapDocument(response).max_upload_size) };
|
|
2052
|
+
}
|
|
2053
|
+
/**
|
|
2054
|
+
* Set the PHP max upload size of a server, in megabytes.
|
|
2055
|
+
*/
|
|
2056
|
+
async function updatePhpMaxUploadSize(options, ctx) {
|
|
2057
|
+
await request(ROUTES.php.updateMaxUploadSize, ctx, { server_id: options.server_id }, { body: { max_upload_size: options.size } });
|
|
2058
|
+
return { data: void 0 };
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Get the PHP max execution time of a server, in seconds.
|
|
2062
|
+
*/
|
|
2063
|
+
async function getPhpMaxExecutionTime(options, ctx) {
|
|
2064
|
+
const response = await request(ROUTES.php.getMaxExecutionTime, ctx, { server_id: options.server_id }, { schema: jsonApiDocumentSchema(PhpMaxExecutionTimeAttributesSchema) });
|
|
2065
|
+
return { data: String(unwrapDocument(response).max_execution_time) };
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* Set the PHP max execution time of a server, in seconds.
|
|
2069
|
+
*/
|
|
2070
|
+
async function updatePhpMaxExecutionTime(options, ctx) {
|
|
2071
|
+
await request(ROUTES.php.updateMaxExecutionTime, ctx, { server_id: options.server_id }, { body: { max_execution_time: options.seconds } });
|
|
2072
|
+
return { data: void 0 };
|
|
2073
|
+
}
|
|
2074
|
+
//#endregion
|
|
2075
|
+
//#region src/executors/php/opcache.ts
|
|
2076
|
+
/**
|
|
2077
|
+
* Get whether PHP OPcache is enabled on a server.
|
|
2078
|
+
*/
|
|
2079
|
+
async function getPhpOpcache(options, ctx) {
|
|
2080
|
+
return { data: unwrapDocument(await request(ROUTES.php.getOpcache, ctx, { server_id: options.server_id }, { schema: jsonApiDocumentSchema(PhpOpcacheAttributesSchema) })).opcache_enabled };
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* Enable PHP OPcache on a server.
|
|
2084
|
+
*/
|
|
2085
|
+
async function enablePhpOpcache(options, ctx) {
|
|
2086
|
+
await request(ROUTES.php.enableOpcache, ctx, { server_id: options.server_id });
|
|
2087
|
+
return { data: void 0 };
|
|
2088
|
+
}
|
|
2089
|
+
/**
|
|
2090
|
+
* Disable PHP OPcache on a server.
|
|
2091
|
+
*/
|
|
2092
|
+
async function disablePhpOpcache(options, ctx) {
|
|
2093
|
+
await request(ROUTES.php.disableOpcache, ctx, { server_id: options.server_id });
|
|
2094
|
+
return { data: void 0 };
|
|
2095
|
+
}
|
|
2096
|
+
//#endregion
|
|
1771
2097
|
//#region src/executors/user/get.ts
|
|
1772
2098
|
/**
|
|
1773
2099
|
* Get the currently authenticated user.
|
|
@@ -1776,6 +2102,6 @@ async function getUser(_options, ctx) {
|
|
|
1776
2102
|
return { data: unwrapDocument(await request(ROUTES.user.get, ctx, {}, { schema: jsonApiDocumentSchema(UserAttributesSchema) })) };
|
|
1777
2103
|
}
|
|
1778
2104
|
//#endregion
|
|
1779
|
-
export { ACTIONS, RESOURCES, activateCertificate, createAuditLogger, createBackupConfig, createCertificate, createCommand, createDaemon, createDatabase, createDatabaseUser, createFirewallRule, createMonitor, createNginxTemplate, createRecipe, createRedirectRule, createScheduledJob, createSecurityRule, createServer, createSite, createSshKey, createTestExecutorContext, deleteBackupConfig, deleteCertificate, deleteDaemon, deleteDatabase, deleteDatabaseUser, deleteFirewallRule, deleteMonitor, deleteNginxTemplate, deleteRecipe, deleteRedirectRule, deleteScheduledJob, deleteSecurityRule, deleteServer, deleteSite, deleteSshKey, deploySite, deploySiteAndWait, getAuditLogPath, getBackupConfig, getCertificate, getCommand, getDaemon, getDatabase, getDatabaseUser, getDeploymentLog, getDeploymentScript, getEnv, getFirewallRule, getMonitor, getNginxConfig, getNginxTemplate, getRecipe, getRedirectRule, getScheduledJob, getSecurityRule, getServer, getSite, getSshKey, getUser, listBackupConfigs, listCommands, listDaemons, listDatabaseUsers, listDatabases, listDeployments, listFirewallRules, listMonitors, listNginxTemplates, listRecipes, listRedirectRules, listScheduledJobs, listSecurityRules, listServers, listSites, listSshKeys, matchByName, mockDocument, mockListDocument, mockResource, rebootServer, resolveServers, resolveSites, restartDaemon, runRecipe, sanitizeArgs, updateBackupConfig, updateDaemon, updateDatabaseUser, updateDeploymentScript, updateEnv, updateNginxConfig, updateNginxTemplate, updateRecipe, updateSecurityRule, updateSite };
|
|
2105
|
+
export { ACTIONS, PHP_CONFIG_TYPES, RESOURCES, RESTARTABLE_SERVICES, activateCertificate, createAuditLogger, createBackupConfig, createCertificate, createCommand, createDaemon, createDatabase, createDatabaseUser, createFirewallRule, createMonitor, createNginxTemplate, createRecipe, createRedirectRule, createScheduledJob, createSecurityRule, createServer, createSite, createSshKey, createTestExecutorContext, deleteBackupConfig, deleteCertificate, deleteDaemon, deleteDatabase, deleteDatabaseUser, deleteFirewallRule, deleteMonitor, deleteNginxTemplate, deleteRecipe, deleteRedirectRule, deleteScheduledJob, deleteSecurityRule, deleteServer, deleteSite, deleteSshKey, deploySite, deploySiteAndWait, disablePhpOpcache, enablePhpOpcache, getAuditLogPath, getBackupConfig, getCertificate, getCommand, getDaemon, getDaemonLog, getDatabase, getDatabaseUser, getDeploymentLog, getDeploymentScript, getEnv, getFirewallRule, getMonitor, getNginxConfig, getNginxTemplate, getPhpConfig, getPhpMaxExecutionTime, getPhpMaxUploadSize, getPhpOpcache, getPhpVersion, getRecipe, getRedirectRule, getScheduledJob, getSecurityRule, getServer, getSite, getSshKey, getUser, listBackupConfigs, listCommands, listDaemons, listDatabaseUsers, listDatabases, listDeployments, listFirewallRules, listMonitors, listNginxTemplates, listPhpVersions, listRecipes, listRedirectRules, listScheduledJobs, listSecurityRules, listServers, listServices, listSites, listSshKeys, matchByName, mockDocument, mockListDocument, mockResource, rebootServer, resolvePhpVersionId, resolveServers, resolveSites, restartDaemon, restartService, runRecipe, sanitizeArgs, updateBackupConfig, updateDaemon, updateDatabaseUser, updateDeploymentScript, updateEnv, updateNginxConfig, updateNginxTemplate, updatePhpConfig, updatePhpMaxExecutionTime, updatePhpMaxUploadSize, updateRecipe, updateSecurityRule, updateSite };
|
|
1780
2106
|
|
|
1781
2107
|
//# sourceMappingURL=index.js.map
|