@h3ravel/shared 0.6.1 → 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/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/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.1"
|
|
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