@h3ravel/foundation 0.1.0-alpha.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 h3ravel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ <div align="center">
2
+ <a href="https://h3ravel.toneflix.net" target="_blank">
3
+ <img src="https://raw.githubusercontent.com/h3ravel/assets/refs/heads/main/logo-full.svg" width="200" alt="H3ravel Logo">
4
+ </a>
5
+ <h1 align="center"><a href="https://github.com/h3ravel/framework/tree/main/packages/shared">H3ravel Foundation</a></h1>
6
+
7
+ [![Framework][ix]][lx]
8
+ [![Foundation Package Version][i1]][l1]
9
+ [![Downloads][d1]][d1]
10
+ [![Tests][tei]][tel]
11
+ [![License][lini]][linl]
12
+
13
+ </div>
14
+
15
+ # About H3ravel/foundation
16
+
17
+ We just needed somewhere to dump stuff that we couldn't dump on [@h3ravel/shared](/packages/shared).
18
+
19
+ ## Contributing
20
+
21
+ Thank you for considering contributing to the H3ravel framework! The [Contribution Guide](https://h3ravel.toneflix.net/contributing) can be found in the H3ravel documentation and will provide you with all the information you need to get started.
22
+
23
+ ## Code of Conduct
24
+
25
+ In order to ensure that the H3ravel community is welcoming to all, please review and abide by the [Code of Conduct](#).
26
+
27
+ ## Security Vulnerabilities
28
+
29
+ If you discover a security vulnerability within H3ravel, please send an e-mail to Legacy via hamzas.legacy@toneflix.ng. All security vulnerabilities will be promptly addressed.
30
+
31
+ ## License
32
+
33
+ The H3ravel framework is open-sourced software licensed under the [MIT license](LICENSE).
34
+
35
+ [ix]: https://img.shields.io/npm/v/%40h3ravel%2Fcore?style=flat-square&label=Framework&color=%230970ce
36
+ [lx]: https://www.npmjs.com/package/@h3ravel/core
37
+ [i1]: https://img.shields.io/npm/v/%40h3ravel%2Ffoundation?style=flat-square&label=@h3ravel/foundation&color=%230970ce
38
+ [l1]: https://www.npmjs.com/package/@h3ravel/foundation
39
+ [d1]: https://img.shields.io/npm/dt/%40h3ravel%2Ffoundation?style=flat-square&label=Downloads&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40h3ravel%2Ffoundation
40
+ [linl]: https://github.com/h3ravel/framework/blob/main/LICENSE
41
+ [lini]: https://img.shields.io/github/license/h3ravel/framework
42
+ [tel]: https://github.com/h3ravel/framework/actions/workflows/test.yml
43
+ [tei]: https://github.com/h3ravel/framework/actions/workflows/test.yml/badge.svg
@@ -0,0 +1,190 @@
1
+ import { Bindings, GenericObject, IApplication, IRequest, IResponsable, IResponse, ISessionManager, IUrlGenerator, UseKey } from '@h3ravel/contracts'
2
+
3
+ export { }
4
+
5
+ declare global {
6
+ /**
7
+ * Get the available Application instance.
8
+ */
9
+ function app (): IApplication
10
+ /**
11
+ * Get the available Application instance.
12
+ *
13
+ * @param key
14
+ */
15
+ function app<T extends UseKey> (key: T): Bindings[T];
16
+ /**
17
+ * Get the available Application instance.
18
+ *
19
+ * @param key
20
+ */
21
+ function app<C extends abstract new (...args: any[]) => any> (key: C): InstanceType<C>;
22
+ /**
23
+ * Get the available Application instance.
24
+ *
25
+ * @param key
26
+ */
27
+ function app<F extends (...args: any[]) => any> (key: F): ReturnType<F>;
28
+
29
+ /**
30
+ * Dump something and kill the process for quick debugging. Based on Laravel's dd()
31
+ *
32
+ * @param args
33
+ */
34
+ function dd (...args: any[]): never
35
+
36
+ /**
37
+ * Dump something but keep the process for quick debugging. Based on Laravel's dump()
38
+ *
39
+ * @param args
40
+ */
41
+ function dump (...args: any[]): void
42
+
43
+ /**
44
+ * Global env variable
45
+ */
46
+ function env (): NodeJS.ProcessEnv;
47
+ /**
48
+ * Global env variable
49
+ *
50
+ * @param key
51
+ * @param defaultValue
52
+ */
53
+ function env<T extends string> (key: T, defaultValue?: any): any;
54
+
55
+ /**
56
+ * Load config options
57
+ */
58
+ function config<X extends Record<string, any>> (): X;
59
+ /**
60
+ * Load config option
61
+ *
62
+ * @param key
63
+ * @param defaultValue
64
+ */
65
+ function config<X extends Record<string, any>, T extends Extract<keyof X, string>> (key: T, defaultValue?: any): X[T];
66
+ /**
67
+ * Load config option
68
+ *
69
+ * @param key
70
+ */
71
+ function config<T extends Record<string, any>> (key: T): void;
72
+
73
+ /**
74
+ * Generate a URL instance.
75
+ */
76
+ function url (): IUrlGenerator;
77
+ /**
78
+ * Generate a URL for the current application instance.
79
+ *
80
+ * @param path
81
+ * @param parameters
82
+ * @param secure
83
+ */
84
+ function url (path?: string, parameters: (string | number)[] = [], secure?: boolean): string;
85
+
86
+ /**
87
+ * Get the URL to a named route.
88
+ *
89
+ * @param name
90
+ * @param parameters
91
+ * @param absolute
92
+ * @returns
93
+ */
94
+ function route (name: string, parameters: GenericObject = {}, absolute?: boolean): string
95
+
96
+ /**
97
+ * Get the evaluated view contents for the given view.
98
+ *
99
+ * @param viewPath
100
+ * @param params
101
+ */
102
+ function view (viewPath: string, params?: Record<string, any> | undefined): Promise<IResponsable>
103
+
104
+ /**
105
+ * Get static asset
106
+ *
107
+ * @param asset Name of the asset to serve
108
+ * @param defaultValue Default asset to serve if asset does not exist
109
+ */
110
+ function asset (asset: string, defaultValue?: string): string
111
+
112
+ /**
113
+ * Get an instance of the Request class
114
+ *
115
+ * @returns a global instance of the Request class.
116
+ */
117
+ function request (): IRequest
118
+
119
+ /**
120
+ * Get an instance of the Response class
121
+ *
122
+ * @returns a global instance of the Response class.
123
+ */
124
+ function response (): IResponse
125
+
126
+ /**
127
+ * Get the flashed input from previous request
128
+ *
129
+ * @param key
130
+ * @param defaultValue
131
+ * @returns
132
+ */
133
+ function old (): Promise<Record<string, any>>
134
+ function old (key: string, defaultValue?: any): Promise<any>
135
+
136
+ /**
137
+ * Get an instance of the current session manager
138
+ *
139
+ * @param key
140
+ * @param defaultValue
141
+ * @returns a global instance of the current session manager.
142
+ */
143
+ function session<K extends string | Record<string, any> | undefined = undefined> (key?: K, defaultValue?: any): K extends undefined
144
+ ? ISessionManager
145
+ : K extends string
146
+ ? any : void | Promise<void>
147
+
148
+ /**
149
+ * Get app path
150
+ *
151
+ * @param path
152
+ */
153
+ function app_path (path?: string): string
154
+
155
+ /**
156
+ * Get base path
157
+ *
158
+ * @param path
159
+ */
160
+ function base_path (path?: string): string
161
+
162
+ /**
163
+ * Get public path
164
+ *
165
+ * @param path
166
+ */
167
+ function public_path (path?: string): string
168
+
169
+ /**
170
+ * Get storage path
171
+ *
172
+ * @param path
173
+ */
174
+ function storage_path (path?: string): string
175
+
176
+ /**
177
+ * Get the database path
178
+ *
179
+ * @param path
180
+ */
181
+ function database_path (path?: string): string
182
+
183
+ /**
184
+ * Hash the given value against the bcrypt algorithm.
185
+ *
186
+ * @param value
187
+ * @param options
188
+ */
189
+ function bcrypt (value: string, options?: HashOptions): Promise<string>
190
+ }
@@ -0,0 +1,33 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region rolldown:runtime
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
11
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) {
17
+ __defProp(to, key, {
18
+ get: ((k) => from[k]).bind(null, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ }
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
27
+ value: mod,
28
+ enumerable: true
29
+ }) : target, mod));
30
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
+
32
+ //#endregion
33
+ export { __toESM as i, __esmMin as n, __require as r, __commonJSMin as t };
@@ -0,0 +1,48 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
9
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) {
15
+ __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ }
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
28
+
29
+ //#endregion
30
+
31
+ Object.defineProperty(exports, '__commonJSMin', {
32
+ enumerable: true,
33
+ get: function () {
34
+ return __commonJSMin;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, '__esmMin', {
38
+ enumerable: true,
39
+ get: function () {
40
+ return __esmMin;
41
+ }
42
+ });
43
+ Object.defineProperty(exports, '__toESM', {
44
+ enumerable: true,
45
+ get: function () {
46
+ return __toESM;
47
+ }
48
+ });
@@ -0,0 +1,35 @@
1
+ const require_chunk = require('./chunk-xvyjDJxY.cjs');
2
+ let node_fs = require("node:fs");
3
+ node_fs = require_chunk.__toESM(node_fs);
4
+ let node_url = require("node:url");
5
+ let node_process = require("node:process");
6
+ node_process = require_chunk.__toESM(node_process);
7
+ let node_path = require("node:path");
8
+ node_path = require_chunk.__toESM(node_path);
9
+ let node_fs_promises = require("node:fs/promises");
10
+ node_fs_promises = require_chunk.__toESM(node_fs_promises);
11
+
12
+ //#region ../../node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
13
+ async function findUp(name, { cwd = node_process.default.cwd(), type = "file", stopAt } = {}) {
14
+ let directory = node_path.default.resolve(toPath(cwd) ?? "");
15
+ const { root } = node_path.default.parse(directory);
16
+ stopAt = node_path.default.resolve(directory, toPath(stopAt ?? root));
17
+ const isAbsoluteName = node_path.default.isAbsolute(name);
18
+ while (directory) {
19
+ const filePath = isAbsoluteName ? name : node_path.default.join(directory, name);
20
+ try {
21
+ const stats = await node_fs_promises.default.stat(filePath);
22
+ if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
23
+ } catch {}
24
+ if (directory === stopAt || directory === root) break;
25
+ directory = node_path.default.dirname(directory);
26
+ }
27
+ }
28
+ var toPath;
29
+ var init_find_up_simple = require_chunk.__esmMin((() => {
30
+ toPath = (urlOrPath) => urlOrPath instanceof URL ? (0, node_url.fileURLToPath)(urlOrPath) : urlOrPath;
31
+ }));
32
+
33
+ //#endregion
34
+ init_find_up_simple();
35
+ exports.findUp = findUp;
@@ -0,0 +1,31 @@
1
+ import { n as __esmMin } from "./chunk-Zh1HL_PD.js";
2
+ import "node:fs";
3
+ import { fileURLToPath } from "node:url";
4
+ import process from "node:process";
5
+ import path from "node:path";
6
+ import fsPromises from "node:fs/promises";
7
+
8
+ //#region ../../node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
9
+ async function findUp(name, { cwd = process.cwd(), type = "file", stopAt } = {}) {
10
+ let directory = path.resolve(toPath(cwd) ?? "");
11
+ const { root } = path.parse(directory);
12
+ stopAt = path.resolve(directory, toPath(stopAt ?? root));
13
+ const isAbsoluteName = path.isAbsolute(name);
14
+ while (directory) {
15
+ const filePath = isAbsoluteName ? name : path.join(directory, name);
16
+ try {
17
+ const stats = await fsPromises.stat(filePath);
18
+ if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
19
+ } catch {}
20
+ if (directory === stopAt || directory === root) break;
21
+ directory = path.dirname(directory);
22
+ }
23
+ }
24
+ var toPath;
25
+ var init_find_up_simple = __esmMin((() => {
26
+ toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
27
+ }));
28
+
29
+ //#endregion
30
+ init_find_up_simple();
31
+ export { findUp };