@h3ravel/foundation 1.29.0-alpha.16 → 2.0.0
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/dist/index.d.ts +82 -8
- package/dist/index.js +143 -27
- package/package.json +7 -10
- package/dist/index.cjs +0 -3307
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
|
-
import { CKernel, CacheOptions, CallableConstructor, ConcreteConstructor, ExceptionConditionCallback, ExceptionConstructor, IApplication, IBootstraper, IExceptionHandler, IHttpContext, IKernel, IMiddleware, IMiddlewareHandler, IModel, IRequest, IResponse, IRoute, IRouter, MiddlewareList, RateLimiterAdapter, RedirectHandler, RenderExceptionCallback, ReportExceptionCallback, ThrottleExceptionCallback } from "@h3ravel/contracts";
|
|
2
|
+
import { CKernel, CONTAINER_TOKEN, CacheOptions, CallableConstructor, ConcreteConstructor, ExceptionConditionCallback, ExceptionConstructor, IApplication, IBootstraper, IExceptionHandler, IHttpContext, IKernel, IMiddleware, IMiddlewareHandler, IModel, IRequest, IResponse, IRoute, IRouter, MiddlewareList, RateLimiterAdapter, RedirectHandler, RenderExceptionCallback, ReportExceptionCallback, ThrottleExceptionCallback } from "@h3ravel/contracts";
|
|
3
3
|
import { Collection, DateTime, InvalidArgumentException } from "@h3ravel/support";
|
|
4
4
|
import { Command, Kernel as Kernel$1 } from "@h3ravel/musket";
|
|
5
|
+
import { Console } from "@h3ravel/shared";
|
|
6
|
+
import { Application } from "@h3ravel/core";
|
|
7
|
+
import { Method, PRequest } from "parasito";
|
|
5
8
|
import { UserConfig } from "tsdown";
|
|
6
9
|
import { DriverContract, ObjectMetaData, ObjectVisibility, SignedURLOptions, WriteOptions } from "flydrive/types";
|
|
7
10
|
import { FSDriver } from "flydrive/drivers/fs";
|
|
@@ -10,9 +13,7 @@ import { DriveDirectory, DriveFile, DriveManager } from "flydrive";
|
|
|
10
13
|
import { Readable } from "node:stream";
|
|
11
14
|
import { S3Driver } from "flydrive/drivers/s3";
|
|
12
15
|
import { GCSDriverOptions } from "flydrive/drivers/gcs/types";
|
|
13
|
-
import { Application } from "@h3ravel/core";
|
|
14
16
|
import { H3 } from "h3";
|
|
15
|
-
import { Console } from "@h3ravel/shared";
|
|
16
17
|
|
|
17
18
|
//#region src/Helpers.d.ts
|
|
18
19
|
declare class Helpers {
|
|
@@ -645,7 +646,7 @@ declare class ConsoleKernel extends CKernel {
|
|
|
645
646
|
/**
|
|
646
647
|
* Discover the commands that should be automatically loaded.
|
|
647
648
|
*/
|
|
648
|
-
protected discoverCommands(): void
|
|
649
|
+
protected discoverCommands(): Promise<void>;
|
|
649
650
|
/**
|
|
650
651
|
* Set the paths that should have their Musket commands automatically discovered.
|
|
651
652
|
*
|
|
@@ -1026,6 +1027,7 @@ interface FilesystemConfig {
|
|
|
1026
1027
|
//#endregion
|
|
1027
1028
|
//#region src/Filesystem/IFilesystemManager.d.ts
|
|
1028
1029
|
declare abstract class IFilesystemManager<D extends keyof KnownDisks | keyof CustomDiskDriverRegistry = keyof KnownDisks | keyof CustomDiskDriverRegistry> implements DriverContract {
|
|
1030
|
+
static readonly [CONTAINER_TOKEN]: symbol;
|
|
1029
1031
|
abstract driver: DriveManager<any>;
|
|
1030
1032
|
abstract services: Record<string, () => DriverContract>;
|
|
1031
1033
|
abstract diskName: D;
|
|
@@ -1638,7 +1640,79 @@ declare const statusTexts: {
|
|
|
1638
1640
|
};
|
|
1639
1641
|
//#endregion
|
|
1640
1642
|
//#region src/Testing/testApp.d.ts
|
|
1641
|
-
declare
|
|
1643
|
+
declare class TestClient<TBody = any> {
|
|
1644
|
+
private readonly app;
|
|
1645
|
+
constructor(app: H3);
|
|
1646
|
+
/**
|
|
1647
|
+
* Creates a new request builder for an application instance
|
|
1648
|
+
*
|
|
1649
|
+
* @returns
|
|
1650
|
+
*/
|
|
1651
|
+
request<TResponse = TBody>(): PRequest<TResponse>;
|
|
1652
|
+
/**
|
|
1653
|
+
* Sets the request method to GET and updates the target path.
|
|
1654
|
+
*
|
|
1655
|
+
* @param path
|
|
1656
|
+
* @returns
|
|
1657
|
+
*/
|
|
1658
|
+
get<TResponse = TBody>(path: string): PRequest<TResponse>;
|
|
1659
|
+
/**
|
|
1660
|
+
* Sets the request method to POST and updates the target path.
|
|
1661
|
+
*
|
|
1662
|
+
* @param path
|
|
1663
|
+
* @returns
|
|
1664
|
+
*/
|
|
1665
|
+
post<TResponse = TBody>(path: string): PRequest<TResponse>;
|
|
1666
|
+
/**
|
|
1667
|
+
* Sets the request method to PUT and updates the target path.
|
|
1668
|
+
*
|
|
1669
|
+
* @param path
|
|
1670
|
+
* @returns
|
|
1671
|
+
*/
|
|
1672
|
+
put<TResponse = TBody>(path: string): PRequest<TResponse>;
|
|
1673
|
+
/**
|
|
1674
|
+
* Sets the request method to PATCH and updates the target path.
|
|
1675
|
+
*
|
|
1676
|
+
* @param path
|
|
1677
|
+
* @returns
|
|
1678
|
+
*/
|
|
1679
|
+
patch<TResponse = TBody>(path: string): PRequest<TResponse>;
|
|
1680
|
+
/**
|
|
1681
|
+
* Sets the request method to DELETE and updates the target path.
|
|
1682
|
+
*
|
|
1683
|
+
* @param path
|
|
1684
|
+
* @returns
|
|
1685
|
+
*/
|
|
1686
|
+
delete<TResponse = TBody>(path: string): PRequest<TResponse>;
|
|
1687
|
+
/**
|
|
1688
|
+
* Sets the request method to HEAD and updates the target path.
|
|
1689
|
+
*
|
|
1690
|
+
* @param path
|
|
1691
|
+
* @returns
|
|
1692
|
+
*/
|
|
1693
|
+
head<TResponse = TBody>(path: string): PRequest<TResponse>;
|
|
1694
|
+
/**
|
|
1695
|
+
* Sets the request method to OPTIONS and updates the target path.
|
|
1696
|
+
*
|
|
1697
|
+
* @param path
|
|
1698
|
+
* @returns
|
|
1699
|
+
*/
|
|
1700
|
+
options<TResponse = TBody>(path: string): PRequest<TResponse>;
|
|
1701
|
+
/**
|
|
1702
|
+
* Sets the HTTP method and path for the request.
|
|
1703
|
+
*
|
|
1704
|
+
* @param path
|
|
1705
|
+
* @returns
|
|
1706
|
+
*/
|
|
1707
|
+
method<TResponse = TBody>(method: Method, path: string): PRequest<TResponse>;
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Create a new test client
|
|
1711
|
+
*
|
|
1712
|
+
* @param app
|
|
1713
|
+
* @returns
|
|
1714
|
+
*/
|
|
1715
|
+
declare const testApp: <TBody = any>(app?: Application) => Promise<TestClient<TBody>>;
|
|
1642
1716
|
//#endregion
|
|
1643
1717
|
//#region src/Testing/TestApplication.d.ts
|
|
1644
1718
|
declare class TestApplication {
|
|
@@ -1648,7 +1722,7 @@ declare class TestApplication {
|
|
|
1648
1722
|
* @returns
|
|
1649
1723
|
*/
|
|
1650
1724
|
init(cwd?: string): Promise<Application>;
|
|
1651
|
-
configure(app: Application): any;
|
|
1725
|
+
configure(app: Application, basePath?: string): any;
|
|
1652
1726
|
}
|
|
1653
1727
|
//#endregion
|
|
1654
1728
|
//#region src/Console/Commands/BuildCommand.d.ts
|
|
@@ -2224,7 +2298,7 @@ declare class HttpException extends Error {
|
|
|
2224
2298
|
protected headers: Record<string, string>;
|
|
2225
2299
|
code: number;
|
|
2226
2300
|
constructor(statusCode: number, message?: string, previous?: Error | undefined, headers?: Record<string, string>, code?: number);
|
|
2227
|
-
static fromStatusCode(statusCode: number, message?: string, previous?: Error, headers?: Record<string, string>, code?: number): NotAcceptableHttpException |
|
|
2301
|
+
static fromStatusCode(statusCode: number, message?: string, previous?: Error, headers?: Record<string, string>, code?: number): NotAcceptableHttpException | AccessDeniedHttpException | BadRequestHttpException | ConflictHttpException | LengthRequiredHttpException | LockedHttpException | GoneHttpException | ServiceUnavailableHttpException | UnprocessableEntityHttpException | NotFoundHttpException | HttpException | PreconditionFailedHttpException | UnsupportedMediaTypeHttpException | PreconditionRequiredHttpException | TooManyRequestsHttpException;
|
|
2228
2302
|
getStatusCode(): number;
|
|
2229
2303
|
getHeaders(): Record<string, string>;
|
|
2230
2304
|
setHeaders(headers: Record<string, string>): void;
|
|
@@ -2265,4 +2339,4 @@ declare class RequestHandled {
|
|
|
2265
2339
|
constructor(request: IRequest, response?: IResponse);
|
|
2266
2340
|
}
|
|
2267
2341
|
//#endregion
|
|
2268
|
-
export { AccessDeniedHttpException, AppBuilder, BadRequestHttpException, BindingResolutionException, BootProviders, BuildCommand, CommandNotFoundException, ConfigException, ConflictHttpException, ConsoleKernel, CustomDiskConfig, CustomDiskDriverRegistry, DiskConfig, DriverConfig, ExceptionHandler, Exceptions, FileLike, FilesystemConfig, FtpDiskDriverConfig, GcsDiskDriverConfig, GoneHttpException, HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES, Handler, Helpers, HttpException, HttpExceptionFactory, IFilesystemDriver, IFilesystemManager, IFtpDiskDriver, InMemoryRateLimiter, Inject, Injectable, Kernel, KeyGenerateCommand, KnownDisks, LengthRequiredHttpException, LocalDiskDriverConfig, LockedHttpException, LogicException, MakeCommand, Middleware, MiddlewareHandler, ModelNotFoundException, NotAcceptableHttpException, NotFoundHttpException, PostinstallCommand, PreconditionFailedHttpException, PreconditionRequiredHttpException, RecordNotFoundException, RecordsNotFoundException, RegisterFacades, RequestException, RequestHandled, ResponseCodes, RouteNotFoundException, S3DiskDriverConfig, ServiceUnavailableHttpException, Terminating, TestApplication, TooManyRequestsHttpException, TsDownConfig, UnprocessableEntityHttpException, UnsupportedMediaTypeHttpException, UrlGenerationException, altLogo, logo, statusTexts, testApp };
|
|
2342
|
+
export { AccessDeniedHttpException, AppBuilder, BadRequestHttpException, BindingResolutionException, BootProviders, BuildCommand, CommandNotFoundException, ConfigException, ConflictHttpException, ConsoleKernel, CustomDiskConfig, CustomDiskDriverRegistry, DiskConfig, DriverConfig, ExceptionHandler, Exceptions, FileLike, FilesystemConfig, FtpDiskDriverConfig, GcsDiskDriverConfig, GoneHttpException, HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES, Handler, Helpers, HttpException, HttpExceptionFactory, IFilesystemDriver, IFilesystemManager, IFtpDiskDriver, InMemoryRateLimiter, Inject, Injectable, Kernel, KeyGenerateCommand, KnownDisks, LengthRequiredHttpException, LocalDiskDriverConfig, LockedHttpException, LogicException, MakeCommand, Middleware, MiddlewareHandler, ModelNotFoundException, NotAcceptableHttpException, NotFoundHttpException, PostinstallCommand, PreconditionFailedHttpException, PreconditionRequiredHttpException, RecordNotFoundException, RecordsNotFoundException, RegisterFacades, RequestException, RequestHandled, ResponseCodes, RouteNotFoundException, S3DiskDriverConfig, ServiceUnavailableHttpException, Terminating, TestApplication, TestClient, TooManyRequestsHttpException, TsDownConfig, UnprocessableEntityHttpException, UnsupportedMediaTypeHttpException, UrlGenerationException, altLogo, logo, statusTexts, testApp };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CKernel, IApplication, IBootstraper, IExceptionHandler, IKernel, IRouter, IUrlGenerator } from "@h3ravel/contracts";
|
|
1
|
+
import { CKernel, CONTAINER_TOKEN, IApplication, IBootstraper, IExceptionHandler, IKernel, IRouter, IUrlGenerator, createContainerToken } from "@h3ravel/contracts";
|
|
2
2
|
import { Facades, Route } from "@h3ravel/support/facades";
|
|
3
3
|
import { Arr, AssetsServiceProvider, Collection, DateTime, InvalidArgumentException, RouteServiceProvider, Str, isClass } from "@h3ravel/support";
|
|
4
4
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
5
5
|
import { Command, Kernel as Kernel$1 } from "@h3ravel/musket";
|
|
6
|
-
import { Console, FileSystem, Logger, TaskManager, mix, use } from "@h3ravel/shared";
|
|
6
|
+
import { Console, FileSystem, Logger, TaskManager, importFile, mix, use } from "@h3ravel/shared";
|
|
7
7
|
import { execa } from "execa";
|
|
8
8
|
import preferredPM from "preferred-pm";
|
|
9
9
|
import { ContainerResolver, h3ravel } from "@h3ravel/core";
|
|
@@ -12,10 +12,21 @@ import crypto from "crypto";
|
|
|
12
12
|
import dotenv from "dotenv";
|
|
13
13
|
import { mkdir, readFile as readFile$1, rm, writeFile as writeFile$1 } from "node:fs/promises";
|
|
14
14
|
import path from "node:path";
|
|
15
|
-
import { createRequire } from "module";
|
|
16
15
|
import run from "@rollup/plugin-run";
|
|
17
16
|
import { InteractsWithTime } from "@h3ravel/support/traits";
|
|
18
|
-
import
|
|
17
|
+
import request from "parasito";
|
|
18
|
+
//#region \0rolldown/runtime.js
|
|
19
|
+
var __defProp = Object.defineProperty;
|
|
20
|
+
var __exportAll = (all, no_symbols) => {
|
|
21
|
+
let target = {};
|
|
22
|
+
for (var name in all) __defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true
|
|
25
|
+
});
|
|
26
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
19
30
|
//#region src/Helpers.ts
|
|
20
31
|
var Helpers = class {
|
|
21
32
|
static app;
|
|
@@ -898,7 +909,7 @@ var BuildCommand = class BuildCommand extends Command {
|
|
|
898
909
|
"tsdown",
|
|
899
910
|
silent,
|
|
900
911
|
"--config-loader",
|
|
901
|
-
"
|
|
912
|
+
"native",
|
|
902
913
|
"-c",
|
|
903
914
|
"tsdown.default.config.ts"
|
|
904
915
|
].filter((e) => e !== null), {
|
|
@@ -913,7 +924,7 @@ var BuildCommand = class BuildCommand extends Command {
|
|
|
913
924
|
"tsdown",
|
|
914
925
|
silent,
|
|
915
926
|
"--config-loader",
|
|
916
|
-
"
|
|
927
|
+
"native",
|
|
917
928
|
"-c",
|
|
918
929
|
"tsdown.default.config.ts"
|
|
919
930
|
].filter((e) => e !== null), {
|
|
@@ -1347,7 +1358,7 @@ let ConsoleKernel = _ConsoleKernel = class ConsoleKernel extends CKernel {
|
|
|
1347
1358
|
if (!this.app.hasBeenBootstrapped()) await this.app.bootstrapWith(this.bootstrappers());
|
|
1348
1359
|
if (!this.commandsLoaded) {
|
|
1349
1360
|
this.registerCommands();
|
|
1350
|
-
if (this.shouldDiscoverCommands()) this.discoverCommands();
|
|
1361
|
+
if (this.shouldDiscoverCommands()) await this.discoverCommands();
|
|
1351
1362
|
this.commandsLoaded = true;
|
|
1352
1363
|
}
|
|
1353
1364
|
}
|
|
@@ -1364,14 +1375,14 @@ let ConsoleKernel = _ConsoleKernel = class ConsoleKernel extends CKernel {
|
|
|
1364
1375
|
/**
|
|
1365
1376
|
* Discover the commands that should be automatically loaded.
|
|
1366
1377
|
*/
|
|
1367
|
-
discoverCommands() {
|
|
1368
|
-
const require = createRequire(import.meta.url);
|
|
1378
|
+
async discoverCommands() {
|
|
1369
1379
|
this.getConsole().registerDiscoveryPath(Array.from(this.commandPaths));
|
|
1370
1380
|
for (let path of this.commandRoutePaths) {
|
|
1371
|
-
path = path.replace("/src/", this.DIST_DIR);
|
|
1381
|
+
if (process.env.NODE_ENV === "production") path = path.replace("/src/", this.DIST_DIR).replace(/\.(ts|tsx|mts|cts)$/, ".js");
|
|
1372
1382
|
if (existsSync(path)) {
|
|
1383
|
+
const route = await importFile(path);
|
|
1373
1384
|
class RouteCommand extends Command {
|
|
1374
|
-
handle =
|
|
1385
|
+
handle = route.default;
|
|
1375
1386
|
}
|
|
1376
1387
|
this.getConsole().registerCommands([RouteCommand]);
|
|
1377
1388
|
}
|
|
@@ -1384,8 +1395,9 @@ let ConsoleKernel = _ConsoleKernel = class ConsoleKernel extends CKernel {
|
|
|
1384
1395
|
*/
|
|
1385
1396
|
addCommandPaths(paths) {
|
|
1386
1397
|
paths.forEach((e) => {
|
|
1387
|
-
e = e.replace("/src/", this.DIST_DIR);
|
|
1388
|
-
|
|
1398
|
+
if (process.env.NODE_ENV === "production") e = e.replace("/src/", this.DIST_DIR);
|
|
1399
|
+
const extension = process.env.NODE_ENV === "production" ? "*.js" : "*.{ts,js}";
|
|
1400
|
+
this.commandPaths.add(statSync(e, { throwIfNoEntry: false })?.isFile() ? e : e + extension);
|
|
1389
1401
|
});
|
|
1390
1402
|
return this;
|
|
1391
1403
|
}
|
|
@@ -1676,7 +1688,9 @@ var UrlGenerationException = class UrlGenerationException extends Error {
|
|
|
1676
1688
|
var IFilesystemDriver = class {};
|
|
1677
1689
|
//#endregion
|
|
1678
1690
|
//#region src/Filesystem/IFilesystemManager.ts
|
|
1679
|
-
var IFilesystemManager = class {
|
|
1691
|
+
var IFilesystemManager = class {
|
|
1692
|
+
static [CONTAINER_TOKEN] = createContainerToken("Foundation.IFilesystemManager");
|
|
1693
|
+
};
|
|
1680
1694
|
//#endregion
|
|
1681
1695
|
//#region src/Filesystem/IFtpDiskDriver.ts
|
|
1682
1696
|
var IFtpDiskDriver = class {};
|
|
@@ -2313,7 +2327,111 @@ const statusTexts = {
|
|
|
2313
2327
|
511: "Network Authentication Required"
|
|
2314
2328
|
};
|
|
2315
2329
|
//#endregion
|
|
2330
|
+
//#region src/Testing/testApp.ts
|
|
2331
|
+
var TestClient = class {
|
|
2332
|
+
app;
|
|
2333
|
+
constructor(app) {
|
|
2334
|
+
this.app = app;
|
|
2335
|
+
}
|
|
2336
|
+
/**
|
|
2337
|
+
* Creates a new request builder for an application instance
|
|
2338
|
+
*
|
|
2339
|
+
* @returns
|
|
2340
|
+
*/
|
|
2341
|
+
request() {
|
|
2342
|
+
return request(this.app);
|
|
2343
|
+
}
|
|
2344
|
+
/**
|
|
2345
|
+
* Sets the request method to GET and updates the target path.
|
|
2346
|
+
*
|
|
2347
|
+
* @param path
|
|
2348
|
+
* @returns
|
|
2349
|
+
*/
|
|
2350
|
+
get(path) {
|
|
2351
|
+
return this.request().get(path);
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Sets the request method to POST and updates the target path.
|
|
2355
|
+
*
|
|
2356
|
+
* @param path
|
|
2357
|
+
* @returns
|
|
2358
|
+
*/
|
|
2359
|
+
post(path) {
|
|
2360
|
+
return this.request().post(path);
|
|
2361
|
+
}
|
|
2362
|
+
/**
|
|
2363
|
+
* Sets the request method to PUT and updates the target path.
|
|
2364
|
+
*
|
|
2365
|
+
* @param path
|
|
2366
|
+
* @returns
|
|
2367
|
+
*/
|
|
2368
|
+
put(path) {
|
|
2369
|
+
return this.request().put(path);
|
|
2370
|
+
}
|
|
2371
|
+
/**
|
|
2372
|
+
* Sets the request method to PATCH and updates the target path.
|
|
2373
|
+
*
|
|
2374
|
+
* @param path
|
|
2375
|
+
* @returns
|
|
2376
|
+
*/
|
|
2377
|
+
patch(path) {
|
|
2378
|
+
return this.request().patch(path);
|
|
2379
|
+
}
|
|
2380
|
+
/**
|
|
2381
|
+
* Sets the request method to DELETE and updates the target path.
|
|
2382
|
+
*
|
|
2383
|
+
* @param path
|
|
2384
|
+
* @returns
|
|
2385
|
+
*/
|
|
2386
|
+
delete(path) {
|
|
2387
|
+
return this.request().delete(path);
|
|
2388
|
+
}
|
|
2389
|
+
/**
|
|
2390
|
+
* Sets the request method to HEAD and updates the target path.
|
|
2391
|
+
*
|
|
2392
|
+
* @param path
|
|
2393
|
+
* @returns
|
|
2394
|
+
*/
|
|
2395
|
+
head(path) {
|
|
2396
|
+
return this.request().head(path);
|
|
2397
|
+
}
|
|
2398
|
+
/**
|
|
2399
|
+
* Sets the request method to OPTIONS and updates the target path.
|
|
2400
|
+
*
|
|
2401
|
+
* @param path
|
|
2402
|
+
* @returns
|
|
2403
|
+
*/
|
|
2404
|
+
options(path) {
|
|
2405
|
+
return this.request().options(path);
|
|
2406
|
+
}
|
|
2407
|
+
/**
|
|
2408
|
+
* Sets the HTTP method and path for the request.
|
|
2409
|
+
*
|
|
2410
|
+
* @param path
|
|
2411
|
+
* @returns
|
|
2412
|
+
*/
|
|
2413
|
+
method(method, path) {
|
|
2414
|
+
return this.request().method(method, path);
|
|
2415
|
+
}
|
|
2416
|
+
};
|
|
2417
|
+
/**
|
|
2418
|
+
* Create a new test client
|
|
2419
|
+
*
|
|
2420
|
+
* @param app
|
|
2421
|
+
* @returns
|
|
2422
|
+
*/
|
|
2423
|
+
const testApp = async (app) => {
|
|
2424
|
+
if (!app) {
|
|
2425
|
+
const { TestApplication } = await Promise.resolve().then(() => TestApplication_exports);
|
|
2426
|
+
app = await new TestApplication().init();
|
|
2427
|
+
}
|
|
2428
|
+
const h3App = app.getH3App();
|
|
2429
|
+
if (!h3App) throw new Error("Unable to create a test client because the application has no H3 instance.");
|
|
2430
|
+
return new TestClient(h3App);
|
|
2431
|
+
};
|
|
2432
|
+
//#endregion
|
|
2316
2433
|
//#region src/Testing/TestApplication.ts
|
|
2434
|
+
var TestApplication_exports = /* @__PURE__ */ __exportAll({ TestApplication: () => TestApplication });
|
|
2317
2435
|
var TestApplication = class {
|
|
2318
2436
|
/**
|
|
2319
2437
|
* Initialize the app without firing up the dev server
|
|
@@ -2321,29 +2439,27 @@ var TestApplication = class {
|
|
|
2321
2439
|
* @returns
|
|
2322
2440
|
*/
|
|
2323
2441
|
async init(cwd) {
|
|
2324
|
-
const
|
|
2442
|
+
const basePath = cwd ?? process.cwd();
|
|
2443
|
+
const providersModule = await importFile(path.join(basePath, "src/bootstrap/providers.ts"));
|
|
2444
|
+
const providers = providersModule.default ?? providersModule;
|
|
2445
|
+
if (!Array.isArray(providers)) throw new TypeError("The application providers module must export an array as its default export.");
|
|
2446
|
+
const app = await h3ravel(providers, basePath, {
|
|
2325
2447
|
autoload: true,
|
|
2326
2448
|
initialize: false
|
|
2327
2449
|
});
|
|
2328
|
-
this.configure(app);
|
|
2450
|
+
this.configure(app, basePath);
|
|
2329
2451
|
return await app.boot();
|
|
2330
2452
|
}
|
|
2331
|
-
configure(app) {
|
|
2453
|
+
configure(app, basePath = process.cwd()) {
|
|
2332
2454
|
return app.configure().withRouting({
|
|
2333
|
-
web: path.join(
|
|
2334
|
-
api: path.join(
|
|
2455
|
+
web: path.join(basePath, "src/routes/web.ts"),
|
|
2456
|
+
api: path.join(basePath, "src/routes/api.ts")
|
|
2335
2457
|
}).withExceptions((exceptions) => {
|
|
2336
|
-
return exceptions.report((
|
|
2458
|
+
return exceptions.report((error) => {}).dontReport([UnprocessableEntityHttpException]).truncateRequestExceptionsAt(200);
|
|
2337
2459
|
}).withMiddleware(() => {});
|
|
2338
2460
|
}
|
|
2339
2461
|
};
|
|
2340
2462
|
//#endregion
|
|
2341
|
-
//#region src/Testing/testApp.ts
|
|
2342
|
-
const testApp = async (app) => {
|
|
2343
|
-
if (!app) app = await new TestApplication().init();
|
|
2344
|
-
return app?.getH3App() ?? new H3();
|
|
2345
|
-
};
|
|
2346
|
-
//#endregion
|
|
2347
2463
|
//#region src/Database/Exceptions/RecordsNotFoundException.ts
|
|
2348
2464
|
var RecordsNotFoundException = class extends NotFoundHttpException {};
|
|
2349
2465
|
//#endregion
|
|
@@ -3210,4 +3326,4 @@ var LogicException = class extends Error {
|
|
|
3210
3326
|
}
|
|
3211
3327
|
};
|
|
3212
3328
|
//#endregion
|
|
3213
|
-
export { AccessDeniedHttpException, AppBuilder, BadRequestHttpException, BindingResolutionException, BootProviders, BuildCommand, CommandNotFoundException, ConfigException, ConflictHttpException, ConsoleKernel, ExceptionHandler, Exceptions, GoneHttpException, HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES, Handler, Helpers, HttpException, HttpExceptionFactory, IFilesystemDriver, IFilesystemManager, IFtpDiskDriver, InMemoryRateLimiter, Inject, Injectable, Kernel, KeyGenerateCommand, LengthRequiredHttpException, LockedHttpException, LogicException, MakeCommand, Middleware, MiddlewareHandler, ModelNotFoundException, NotAcceptableHttpException, NotFoundHttpException, PostinstallCommand, PreconditionFailedHttpException, PreconditionRequiredHttpException, RecordNotFoundException, RecordsNotFoundException, RegisterFacades, RequestException, RequestHandled, ResponseCodes, RouteNotFoundException, ServiceUnavailableHttpException, Terminating, TestApplication, TooManyRequestsHttpException, TsDownConfig, UnprocessableEntityHttpException, UnsupportedMediaTypeHttpException, UrlGenerationException, altLogo, logo, statusTexts, testApp };
|
|
3329
|
+
export { AccessDeniedHttpException, AppBuilder, BadRequestHttpException, BindingResolutionException, BootProviders, BuildCommand, CommandNotFoundException, ConfigException, ConflictHttpException, ConsoleKernel, ExceptionHandler, Exceptions, GoneHttpException, HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES, Handler, Helpers, HttpException, HttpExceptionFactory, IFilesystemDriver, IFilesystemManager, IFtpDiskDriver, InMemoryRateLimiter, Inject, Injectable, Kernel, KeyGenerateCommand, LengthRequiredHttpException, LockedHttpException, LogicException, MakeCommand, Middleware, MiddlewareHandler, ModelNotFoundException, NotAcceptableHttpException, NotFoundHttpException, PostinstallCommand, PreconditionFailedHttpException, PreconditionRequiredHttpException, RecordNotFoundException, RecordsNotFoundException, RegisterFacades, RequestException, RequestHandled, ResponseCodes, RouteNotFoundException, ServiceUnavailableHttpException, Terminating, TestApplication, TestClient, TooManyRequestsHttpException, TsDownConfig, UnprocessableEntityHttpException, UnsupportedMediaTypeHttpException, UrlGenerationException, altLogo, logo, statusTexts, testApp };
|
package/package.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/foundation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "H3ravel Foundation for shared and reuseable services.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
6
|
"types": "./dist/index.d.ts",
|
|
8
|
-
"module": "./dist/index.js",
|
|
9
7
|
"exports": {
|
|
10
8
|
".": {
|
|
11
9
|
"import": "./dist/index.js",
|
|
@@ -55,19 +53,18 @@
|
|
|
55
53
|
}
|
|
56
54
|
},
|
|
57
55
|
"devDependencies": {
|
|
58
|
-
"@h3ravel/contracts": "^
|
|
59
|
-
"@types/supertest": "^6.0.3",
|
|
60
|
-
"supertest": "^7.1.4"
|
|
56
|
+
"@h3ravel/contracts": "^2.0.0"
|
|
61
57
|
},
|
|
62
58
|
"dependencies": {
|
|
63
59
|
"@h3ravel/musket": "^1.29.0-alpha.15",
|
|
64
|
-
"@h3ravel/shared": "^
|
|
65
|
-
"@h3ravel/support": "^
|
|
66
|
-
"h3": "2.0.1-rc.5"
|
|
60
|
+
"@h3ravel/shared": "^2.0.0",
|
|
61
|
+
"@h3ravel/support": "^2.0.0",
|
|
62
|
+
"h3": "2.0.1-rc.5",
|
|
63
|
+
"parasito": "^0.2.5"
|
|
67
64
|
},
|
|
68
65
|
"scripts": {
|
|
69
66
|
"build": "tsdown --config-loader unrun",
|
|
70
|
-
"dev": "
|
|
67
|
+
"dev": "tsdown --watch --config-loader unrun",
|
|
71
68
|
"start": "node dist/index.js",
|
|
72
69
|
"lint": "eslint . --ext .ts",
|
|
73
70
|
"test": "jest --passWithNoTests",
|