@h3ravel/shared 0.6.0 → 0.7.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/CHANGELOG.md +6 -0
- package/README.md +29 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -2
- package/dist/index.d.ts +30 -2
- package/package.json +12 -3
- package/src/Contracts/IRequest.ts +1 -1
- package/src/Contracts/IResponse.ts +1 -1
- package/src/Contracts/ObjContract.ts +44 -0
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<p align="center"><a href="https://h3ravel.toneflix.net" target="_blank"><img src="https://raw.githubusercontent.com/h3ravel/assets/refs/heads/main/logo-full.svg" width="400" alt="H3ravel Logo"></a></p>
|
|
2
|
+
|
|
3
|
+
[![Framework][ix]][lx]
|
|
4
|
+
[![Shared Package Version][i1]][l1]
|
|
5
|
+
|
|
6
|
+
# About H3ravel/shared
|
|
7
|
+
|
|
8
|
+
This package provides first reusable interfaces and contracts used across the [H3ravel](https://h3ravel.toneflix.net) ecosystem.
|
|
9
|
+
|
|
10
|
+
## Contributing
|
|
11
|
+
|
|
12
|
+
Thank you for considering contributing to the H3ravel framework! The contribution guide can be found in the [H3ravel documentation](#!).
|
|
13
|
+
|
|
14
|
+
## Code of Conduct
|
|
15
|
+
|
|
16
|
+
In order to ensure that the H3ravel community is welcoming to all, please review and abide by the [Code of Conduct](#).
|
|
17
|
+
|
|
18
|
+
## Security Vulnerabilities
|
|
19
|
+
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
## License
|
|
23
|
+
|
|
24
|
+
The H3ravel framework is open-sourced software licensed under the [MIT license](LICENSE).
|
|
25
|
+
|
|
26
|
+
[ix]: https://img.shields.io/npm/v/%40h3ravel%2Fcore?style=flat-square&label=Framework&color=%230970ce
|
|
27
|
+
[lx]: https://www.npmjs.com/package/@h3ravel/core
|
|
28
|
+
[i1]: https://img.shields.io/npm/v/%40h3ravel%2Fshared?style=flat-square&label=@h3ravel/shared&color=%230970ce
|
|
29
|
+
[l1]: https://www.npmjs.com/package/@h3ravel/shared
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './Contracts/IApplication';\nexport * from './Contracts/IHttp';\nexport * from './Contracts/IRequest';\nexport * from './Contracts/IResponse';\nexport * from './Contracts/IServiceProvider';\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './Contracts/IApplication';\nexport * from './Contracts/IHttp';\nexport * from './Contracts/IRequest';\nexport * from './Contracts/IResponse';\nexport * from './Contracts/IServiceProvider';\nexport * from './Contracts/ObjContract';\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { H3Event, Middleware, MiddlewareOptions } from 'h3';
|
|
2
|
-
import { DotNestedKeys, DotNestedValue } from '@h3ravel/support';
|
|
3
2
|
|
|
4
3
|
interface IServiceProvider {
|
|
5
4
|
/**
|
|
@@ -69,6 +68,35 @@ interface IApplication {
|
|
|
69
68
|
getVersion(key: 'app' | 'ts'): string | undefined;
|
|
70
69
|
}
|
|
71
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Adds a dot prefix to nested keys
|
|
73
|
+
*/
|
|
74
|
+
type DotPrefix<T extends string, U extends string> = T extends '' ? U : `${T}.${U}`;
|
|
75
|
+
/**
|
|
76
|
+
* Converts a union of objects into a single merged object
|
|
77
|
+
*/
|
|
78
|
+
type MergeUnion<T> = (T extends any ? (k: T) => void : never) extends (k: infer I) => void ? {
|
|
79
|
+
[K in keyof I]: I[K];
|
|
80
|
+
} : never;
|
|
81
|
+
/**
|
|
82
|
+
* Flattens nested objects into dotted keys
|
|
83
|
+
*/
|
|
84
|
+
type DotFlatten<T, Prefix extends string = ''> = MergeUnion<{
|
|
85
|
+
[K in keyof T & string]: T[K] extends Record<string, any> ? DotFlatten<T[K], DotPrefix<Prefix, K>> : {
|
|
86
|
+
[P in DotPrefix<Prefix, K>]: T[K];
|
|
87
|
+
};
|
|
88
|
+
}[keyof T & string]>;
|
|
89
|
+
/**
|
|
90
|
+
* Builds "nested.key" paths for autocompletion
|
|
91
|
+
*/
|
|
92
|
+
type DotNestedKeys<T> = {
|
|
93
|
+
[K in keyof T & string]: T[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T[K]>}` : `${K}`;
|
|
94
|
+
}[keyof T & string];
|
|
95
|
+
/**
|
|
96
|
+
* Retrieves type at a given dot-path
|
|
97
|
+
*/
|
|
98
|
+
type DotNestedValue<T, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? DotNestedValue<T[Key], Rest> : never : Path extends keyof T ? T[Path] : never;
|
|
99
|
+
|
|
72
100
|
/**
|
|
73
101
|
* Interface for the Request contract, defining methods for handling HTTP request data.
|
|
74
102
|
*/
|
|
@@ -253,4 +281,4 @@ interface IMiddleware {
|
|
|
253
281
|
handle(context: HttpContext, next: () => Promise<any>): Promise<any>;
|
|
254
282
|
}
|
|
255
283
|
|
|
256
|
-
export type { EventHandler, HttpContext, IApplication, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider };
|
|
284
|
+
export type { DotFlatten, DotNestedKeys, DotNestedValue, EventHandler, HttpContext, IApplication, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { H3Event, Middleware, MiddlewareOptions } from 'h3';
|
|
2
|
-
import { DotNestedKeys, DotNestedValue } from '@h3ravel/support';
|
|
3
2
|
|
|
4
3
|
interface IServiceProvider {
|
|
5
4
|
/**
|
|
@@ -69,6 +68,35 @@ interface IApplication {
|
|
|
69
68
|
getVersion(key: 'app' | 'ts'): string | undefined;
|
|
70
69
|
}
|
|
71
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Adds a dot prefix to nested keys
|
|
73
|
+
*/
|
|
74
|
+
type DotPrefix<T extends string, U extends string> = T extends '' ? U : `${T}.${U}`;
|
|
75
|
+
/**
|
|
76
|
+
* Converts a union of objects into a single merged object
|
|
77
|
+
*/
|
|
78
|
+
type MergeUnion<T> = (T extends any ? (k: T) => void : never) extends (k: infer I) => void ? {
|
|
79
|
+
[K in keyof I]: I[K];
|
|
80
|
+
} : never;
|
|
81
|
+
/**
|
|
82
|
+
* Flattens nested objects into dotted keys
|
|
83
|
+
*/
|
|
84
|
+
type DotFlatten<T, Prefix extends string = ''> = MergeUnion<{
|
|
85
|
+
[K in keyof T & string]: T[K] extends Record<string, any> ? DotFlatten<T[K], DotPrefix<Prefix, K>> : {
|
|
86
|
+
[P in DotPrefix<Prefix, K>]: T[K];
|
|
87
|
+
};
|
|
88
|
+
}[keyof T & string]>;
|
|
89
|
+
/**
|
|
90
|
+
* Builds "nested.key" paths for autocompletion
|
|
91
|
+
*/
|
|
92
|
+
type DotNestedKeys<T> = {
|
|
93
|
+
[K in keyof T & string]: T[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T[K]>}` : `${K}`;
|
|
94
|
+
}[keyof T & string];
|
|
95
|
+
/**
|
|
96
|
+
* Retrieves type at a given dot-path
|
|
97
|
+
*/
|
|
98
|
+
type DotNestedValue<T, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? DotNestedValue<T[Key], Rest> : never : Path extends keyof T ? T[Path] : never;
|
|
99
|
+
|
|
72
100
|
/**
|
|
73
101
|
* Interface for the Request contract, defining methods for handling HTTP request data.
|
|
74
102
|
*/
|
|
@@ -253,4 +281,4 @@ interface IMiddleware {
|
|
|
253
281
|
handle(context: HttpContext, next: () => Promise<any>): Promise<any>;
|
|
254
282
|
}
|
|
255
283
|
|
|
256
|
-
export type { EventHandler, HttpContext, IApplication, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider };
|
|
284
|
+
export type { DotFlatten, DotNestedKeys, DotNestedValue, EventHandler, HttpContext, IApplication, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Shared Utilities.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,9 +8,18 @@
|
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"h3ravel",
|
|
13
|
+
"modern",
|
|
14
|
+
"web",
|
|
15
|
+
"H3",
|
|
16
|
+
"framework",
|
|
17
|
+
"nodejs",
|
|
18
|
+
"typescript",
|
|
19
|
+
"laravel"
|
|
20
|
+
],
|
|
11
21
|
"dependencies": {
|
|
12
|
-
"h3": "^2.0.0-beta.1"
|
|
13
|
-
"@h3ravel/support": "0.6.0"
|
|
22
|
+
"h3": "^2.0.0-beta.1"
|
|
14
23
|
},
|
|
15
24
|
"scripts": {
|
|
16
25
|
"build": "tsup",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds a dot prefix to nested keys
|
|
3
|
+
*/
|
|
4
|
+
type DotPrefix<T extends string, U extends string> =
|
|
5
|
+
T extends '' ? U : `${T}.${U}`
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Converts a union of objects into a single merged object
|
|
9
|
+
*/
|
|
10
|
+
type MergeUnion<T> =
|
|
11
|
+
(T extends any ? (k: T) => void : never) extends
|
|
12
|
+
(k: infer I) => void ? { [K in keyof I]: I[K] } : never
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Flattens nested objects into dotted keys
|
|
16
|
+
*/
|
|
17
|
+
export type DotFlatten<T, Prefix extends string = ''> = MergeUnion<{
|
|
18
|
+
[K in keyof T & string]:
|
|
19
|
+
T[K] extends Record<string, any>
|
|
20
|
+
? DotFlatten<T[K], DotPrefix<Prefix, K>>
|
|
21
|
+
: { [P in DotPrefix<Prefix, K>]: T[K] }
|
|
22
|
+
}[keyof T & string]>
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Builds "nested.key" paths for autocompletion
|
|
26
|
+
*/
|
|
27
|
+
export type DotNestedKeys<T> = {
|
|
28
|
+
[K in keyof T & string]:
|
|
29
|
+
T[K] extends object
|
|
30
|
+
? `${K}` | `${K}.${DotNestedKeys<T[K]>}`
|
|
31
|
+
: `${K}`
|
|
32
|
+
}[keyof T & string]
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves type at a given dot-path
|
|
36
|
+
*/
|
|
37
|
+
export type DotNestedValue<T, Path extends string> =
|
|
38
|
+
Path extends `${infer Key}.${infer Rest}`
|
|
39
|
+
? Key extends keyof T
|
|
40
|
+
? DotNestedValue<T[Key], Rest>
|
|
41
|
+
: never
|
|
42
|
+
: Path extends keyof T
|
|
43
|
+
? T[Path]
|
|
44
|
+
: never
|
package/src/index.ts
CHANGED