@h3ravel/contracts 0.28.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/LICENSE +21 -0
- package/README.md +43 -0
- package/dist/index.cjs +348 -0
- package/dist/index.d.ts +4464 -0
- package/dist/index.js +312 -0
- package/package.json +65 -0
- package/tsconfig.json +8 -0
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://h3ravel.toneflix.net/arquebus">H3ravel Contracts</a></h1>
|
|
6
|
+
|
|
7
|
+
[![Framework][ix]][lx]
|
|
8
|
+
[![Contracts Package Version][i1]][l1]
|
|
9
|
+
[![Downloads][d1]][d1]
|
|
10
|
+
[![Tests][tei]][tel]
|
|
11
|
+
[![License][lini]][linl]
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
# About H3ravel/contracts
|
|
16
|
+
|
|
17
|
+
This package provides first class reusable interfaces and contracts for use across the [H3ravel](https://h3ravel.toneflix.net) ecosystem.
|
|
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%2Fcontracts?style=flat-square&label=@h3ravel/contracts&color=%230970ce
|
|
38
|
+
[l1]: https://www.npmjs.com/package/@h3ravel/contracts
|
|
39
|
+
[d1]: https://img.shields.io/npm/dt/%40h3ravel%2Fcontracts?style=flat-square&label=Downloads&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40h3ravel%2Fcontracts
|
|
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
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
let __h3ravel_arquebus = require("@h3ravel/arquebus");
|
|
2
|
+
let h3 = require("h3");
|
|
3
|
+
|
|
4
|
+
//#region src/Configuration/IAppBuilder.ts
|
|
5
|
+
var IAppBuilder = class {};
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/Core/IContainer.ts
|
|
9
|
+
/**
|
|
10
|
+
* Interface for the Container contract, defining methods for dependency injection and service resolution.
|
|
11
|
+
*/
|
|
12
|
+
var IContainer = class {
|
|
13
|
+
static hasAnyDecorator(target) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/Core/IApplication.ts
|
|
20
|
+
var IApplication = class extends IContainer {
|
|
21
|
+
context;
|
|
22
|
+
h3Event;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/Core/IController.ts
|
|
27
|
+
/**
|
|
28
|
+
* Defines the contract for all controllers.
|
|
29
|
+
*/
|
|
30
|
+
var IController = class {
|
|
31
|
+
callAction(method, parameters) {}
|
|
32
|
+
getMiddleware() {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/Core/IRegisterer.ts
|
|
39
|
+
var IRegisterer = class {};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/Core/IServiceProvider.ts
|
|
43
|
+
var IServiceProvider = class {
|
|
44
|
+
/**
|
|
45
|
+
* Unique Identifier for service providers
|
|
46
|
+
*/
|
|
47
|
+
static uid;
|
|
48
|
+
/**
|
|
49
|
+
* Sort order
|
|
50
|
+
*/
|
|
51
|
+
static order;
|
|
52
|
+
/**
|
|
53
|
+
* Sort priority
|
|
54
|
+
*/
|
|
55
|
+
static priority;
|
|
56
|
+
/**
|
|
57
|
+
* Indicate that this service provider only runs in console
|
|
58
|
+
*/
|
|
59
|
+
static runsInConsole;
|
|
60
|
+
/**
|
|
61
|
+
* Indicate that this service provider only runs in console
|
|
62
|
+
*/
|
|
63
|
+
static console;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/Database/IModel.ts
|
|
68
|
+
var IModel = class extends __h3ravel_arquebus.Model {};
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/Events/IDispatcher.ts
|
|
72
|
+
var IDispatcher = class {};
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/Exceptions/IExceptionHandler.ts
|
|
76
|
+
var IExceptionHandler = class {};
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/Foundation/CKernel.ts
|
|
80
|
+
var CKernel = class {};
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/Foundation/IBootstraper.ts
|
|
84
|
+
var IBootstraper = class {};
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/Foundation/IKernel.ts
|
|
88
|
+
var IKernel = class {};
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/Http/IParamBag.ts
|
|
92
|
+
/**
|
|
93
|
+
* ParamBag is a container for key/value pairs
|
|
94
|
+
* for H3ravel App.
|
|
95
|
+
*/
|
|
96
|
+
var IParamBag = class {};
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/Http/IFileBag.ts
|
|
100
|
+
/**
|
|
101
|
+
* FileBag is a container for uploaded files
|
|
102
|
+
* for H3ravel App.
|
|
103
|
+
*/
|
|
104
|
+
var IFileBag = class extends IParamBag {};
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/Http/IHeaderBag.ts
|
|
108
|
+
/**
|
|
109
|
+
* HeaderBag — A container for HTTP headers
|
|
110
|
+
* for H3ravel App.
|
|
111
|
+
*/
|
|
112
|
+
var IHeaderBag = class {};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/Http/IHttpContext.ts
|
|
116
|
+
var IHttpContext = class {
|
|
117
|
+
/**
|
|
118
|
+
* Retrieve an existing HttpContext instance for an event, if any.
|
|
119
|
+
*/
|
|
120
|
+
static get(event) {}
|
|
121
|
+
/**
|
|
122
|
+
* Delete the cached context for a given event (optional cleanup).
|
|
123
|
+
*/
|
|
124
|
+
static forget(event) {}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/Http/IHttpRequest.ts
|
|
129
|
+
var IHttpRequest = class {};
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/Http/IHttpResponse.ts
|
|
133
|
+
/**
|
|
134
|
+
* Interface for the Response contract, defining methods for handling HTTP responses.
|
|
135
|
+
*/
|
|
136
|
+
var IHttpResponse = class {};
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/Http/IInputBag.ts
|
|
140
|
+
/**
|
|
141
|
+
* InputBag is a container for user input values
|
|
142
|
+
* (e.g., query params, body, cookies)
|
|
143
|
+
* for H3ravel App.
|
|
144
|
+
*/
|
|
145
|
+
var InputBag = class extends IParamBag {};
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/Http/IRequest.ts
|
|
149
|
+
/**
|
|
150
|
+
* Interface for the Request contract, defining methods for handling HTTP request data.
|
|
151
|
+
*/
|
|
152
|
+
var IRequest = class extends IHttpRequest {
|
|
153
|
+
/**
|
|
154
|
+
* Factory method to create a Request instance from an H3Event.
|
|
155
|
+
*/
|
|
156
|
+
static create(event, app) {
|
|
157
|
+
return Promise.resolve({});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Enables support for the _method request parameter to determine the intended HTTP method.
|
|
161
|
+
*
|
|
162
|
+
* Be warned that enabling this feature might lead to CSRF issues in your code.
|
|
163
|
+
* Check that you are using CSRF tokens when required.
|
|
164
|
+
* If the HTTP method parameter override is enabled, an html-form with method "POST" can be altered
|
|
165
|
+
* and used to send a "PUT" or "DELETE" request via the _method request parameter.
|
|
166
|
+
* If these methods are not protected against CSRF, this presents a possible vulnerability.
|
|
167
|
+
*
|
|
168
|
+
* The HTTP method can only be overridden when the real HTTP method is POST.
|
|
169
|
+
*/
|
|
170
|
+
static enableHttpMethodParameterOverride() {}
|
|
171
|
+
/**
|
|
172
|
+
* Checks whether support for the _method request parameter is enabled.
|
|
173
|
+
*/
|
|
174
|
+
static getHttpMethodParameterOverride() {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/Http/IResponse.ts
|
|
181
|
+
/**
|
|
182
|
+
* Interface for the Response contract, defining methods for handling HTTP responses.
|
|
183
|
+
*/
|
|
184
|
+
var IResponse = class extends IHttpResponse {};
|
|
185
|
+
var IResponsable = class extends h3.HTTPResponse {};
|
|
186
|
+
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/Http/IServerBag.ts
|
|
189
|
+
/**
|
|
190
|
+
* ServerBag — a simplified version of Symfony's ServerBag
|
|
191
|
+
* for H3ravel App.
|
|
192
|
+
*
|
|
193
|
+
* Responsible for extracting and normalizing HTTP headers
|
|
194
|
+
* from the incoming request.
|
|
195
|
+
*/
|
|
196
|
+
var IServerBag = class extends IParamBag {};
|
|
197
|
+
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/Http/IUploadedFile.ts
|
|
200
|
+
var IUploadedFile = class {};
|
|
201
|
+
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/Queue/IJob.ts
|
|
204
|
+
var IJob = class {};
|
|
205
|
+
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/Routing/ICallableDispatcher.ts
|
|
208
|
+
var ICallableDispatcher = class {};
|
|
209
|
+
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/Routing/IControllerDispatcher.ts
|
|
212
|
+
var IControllerDispatcher = class {};
|
|
213
|
+
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/Routing/IMiddleware.ts
|
|
216
|
+
/**
|
|
217
|
+
* Defines the contract for all middlewares.
|
|
218
|
+
* Any middleware implementing this must define these methods.
|
|
219
|
+
*/
|
|
220
|
+
var IMiddleware = class {
|
|
221
|
+
options = {};
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/Routing/IPendingResourceRegistration.ts
|
|
226
|
+
var IPendingResourceRegistration = class {};
|
|
227
|
+
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/Routing/IPendingSingletonResourceRegistration.ts
|
|
230
|
+
var IPendingSingletonResourceRegistration = class {};
|
|
231
|
+
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/Routing/IRoute.ts
|
|
234
|
+
var IRoute = class {};
|
|
235
|
+
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/Routing/IRouter.ts
|
|
238
|
+
/**
|
|
239
|
+
* Interface for the Router contract, defining methods for HTTP routing.
|
|
240
|
+
*/
|
|
241
|
+
var IRouter = class {
|
|
242
|
+
/**
|
|
243
|
+
* All of the verbs supported by the router.
|
|
244
|
+
*/
|
|
245
|
+
static verbs;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/Routing/IRouteRegistrar.ts
|
|
250
|
+
var IRouteRegistrar = class {};
|
|
251
|
+
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/Routing/Traits/UrlRoutable.ts
|
|
254
|
+
var UrlRoutable = class {};
|
|
255
|
+
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/Url/IRequestAwareUrl.ts
|
|
258
|
+
/**
|
|
259
|
+
* Contract for request-aware URL helpers
|
|
260
|
+
*/
|
|
261
|
+
var IRequestAwareUrl = class {};
|
|
262
|
+
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/Url/IUrl.ts
|
|
265
|
+
var IUrl = class {
|
|
266
|
+
/**
|
|
267
|
+
* Create a URL from a full URL string
|
|
268
|
+
*/
|
|
269
|
+
static of(url, app) {
|
|
270
|
+
return {};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Create a URL from a path relative to the app URL
|
|
274
|
+
*/
|
|
275
|
+
static to(path, app) {
|
|
276
|
+
return {};
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Create a URL from a named route
|
|
280
|
+
*/
|
|
281
|
+
static route(name, params, app) {
|
|
282
|
+
return {};
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Create a signed URL from a named route
|
|
286
|
+
*/
|
|
287
|
+
static signedRoute(name, params, app) {
|
|
288
|
+
return {};
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Create a temporary signed URL from a named route
|
|
292
|
+
*/
|
|
293
|
+
static temporarySignedRoute(name, params, expiration, app) {
|
|
294
|
+
return {};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Create a URL from a controller action
|
|
298
|
+
*/
|
|
299
|
+
static action(controller, params, app) {
|
|
300
|
+
return {};
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/Url/IUrlHelpers.ts
|
|
306
|
+
/**
|
|
307
|
+
* The Url Helper Contract
|
|
308
|
+
*/
|
|
309
|
+
var IUrlHelpers = class {};
|
|
310
|
+
|
|
311
|
+
//#endregion
|
|
312
|
+
exports.CKernel = CKernel;
|
|
313
|
+
exports.IAppBuilder = IAppBuilder;
|
|
314
|
+
exports.IApplication = IApplication;
|
|
315
|
+
exports.IBootstraper = IBootstraper;
|
|
316
|
+
exports.ICallableDispatcher = ICallableDispatcher;
|
|
317
|
+
exports.IContainer = IContainer;
|
|
318
|
+
exports.IController = IController;
|
|
319
|
+
exports.IControllerDispatcher = IControllerDispatcher;
|
|
320
|
+
exports.IDispatcher = IDispatcher;
|
|
321
|
+
exports.IExceptionHandler = IExceptionHandler;
|
|
322
|
+
exports.IFileBag = IFileBag;
|
|
323
|
+
exports.IHeaderBag = IHeaderBag;
|
|
324
|
+
exports.IHttpContext = IHttpContext;
|
|
325
|
+
exports.IHttpRequest = IHttpRequest;
|
|
326
|
+
exports.IHttpResponse = IHttpResponse;
|
|
327
|
+
exports.IJob = IJob;
|
|
328
|
+
exports.IKernel = IKernel;
|
|
329
|
+
exports.IMiddleware = IMiddleware;
|
|
330
|
+
exports.IModel = IModel;
|
|
331
|
+
exports.IParamBag = IParamBag;
|
|
332
|
+
exports.IPendingResourceRegistration = IPendingResourceRegistration;
|
|
333
|
+
exports.IPendingSingletonResourceRegistration = IPendingSingletonResourceRegistration;
|
|
334
|
+
exports.IRegisterer = IRegisterer;
|
|
335
|
+
exports.IRequest = IRequest;
|
|
336
|
+
exports.IRequestAwareUrl = IRequestAwareUrl;
|
|
337
|
+
exports.IResponsable = IResponsable;
|
|
338
|
+
exports.IResponse = IResponse;
|
|
339
|
+
exports.IRoute = IRoute;
|
|
340
|
+
exports.IRouteRegistrar = IRouteRegistrar;
|
|
341
|
+
exports.IRouter = IRouter;
|
|
342
|
+
exports.IServerBag = IServerBag;
|
|
343
|
+
exports.IServiceProvider = IServiceProvider;
|
|
344
|
+
exports.IUploadedFile = IUploadedFile;
|
|
345
|
+
exports.IUrl = IUrl;
|
|
346
|
+
exports.IUrlHelpers = IUrlHelpers;
|
|
347
|
+
exports.InputBag = InputBag;
|
|
348
|
+
exports.UrlRoutable = UrlRoutable;
|