@empathyco/x-adapter 8.0.0-alpha.21 → 8.0.0-alpha.23
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.
|
@@ -38,7 +38,7 @@ export interface ExtendableEndpointAdapter<Request, Response> extends EndpointAd
|
|
|
38
38
|
* @returns A brand-new {@link ExtendableEndpointAdapter} instance.
|
|
39
39
|
* @public
|
|
40
40
|
*/
|
|
41
|
-
export
|
|
41
|
+
export type EndpointAdapterFactory = <Request, Response>(options: EndpointAdapterOptions<Request, Response>) => ExtendableEndpointAdapter<Request, Response>;
|
|
42
42
|
/**
|
|
43
43
|
* Options to create an adapter with.
|
|
44
44
|
*
|
|
@@ -7,7 +7,7 @@ import { Dictionary } from '@empathyco/x-utils';
|
|
|
7
7
|
* @returns A promise wrapped object containing the response.
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type HttpClient = <Response = unknown>(endpoint: string, options?: Omit<RequestOptions, 'endpoint'>) => Promise<Readonly<Response>>;
|
|
11
11
|
/**
|
|
12
12
|
* A record of options to make the request with.
|
|
13
13
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @returns A new value created using the data in the `context` or in the `from` parameters.
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type Mapper<From, To> = (from: Readonly<From>, context: MapperContext) => To;
|
|
9
9
|
/**
|
|
10
10
|
* The context is an object that can be used to share information between the invocation of
|
|
11
11
|
* different mappers or the process that they are being executed on.
|
|
@@ -34,7 +34,7 @@ import { MapperContext } from '../mappers/types';
|
|
|
34
34
|
* ```
|
|
35
35
|
* @public
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export type Schema<Source = any, Target = any> = {
|
|
38
38
|
[TargetKey in keyof Target]: SchemaTransformer<Source, Target, TargetKey>;
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
@@ -44,7 +44,7 @@ export declare type Schema<Source = any, Target = any> = {
|
|
|
44
44
|
* @param OriginalSchema - The {@link Schema | schema} that will be mutable.
|
|
45
45
|
* @public
|
|
46
46
|
*/
|
|
47
|
-
export
|
|
47
|
+
export type MutableSchema<Source, Target> = Schema<Source, Target> & {
|
|
48
48
|
/**
|
|
49
49
|
* Replaces all usages of the original {@link Schema | schema} with the given one.
|
|
50
50
|
*
|
|
@@ -86,7 +86,7 @@ export declare type MutableSchema<Source, Target> = Schema<Source, Target> & {
|
|
|
86
86
|
* @param TargetKey - The target key to apply the transformation.
|
|
87
87
|
* @public
|
|
88
88
|
*/
|
|
89
|
-
export
|
|
89
|
+
export type SchemaTransformer<Source, Target, TargetKey extends keyof Target> = PathTransformer<Source, Target[TargetKey]> | FunctionTransformer<Source, Target[TargetKey]> | SubSchemaTransformer<Source, Target[TargetKey]> | Schema<Source, Exclude<Target[TargetKey], AnyFunction | Primitive>>;
|
|
90
90
|
/**
|
|
91
91
|
* A function with the source object and mapper context as parameters that returns the value of a
|
|
92
92
|
* target's property.
|
|
@@ -118,7 +118,7 @@ export declare type SchemaTransformer<Source, Target, TargetKey extends keyof Ta
|
|
|
118
118
|
* ```
|
|
119
119
|
* @public
|
|
120
120
|
*/
|
|
121
|
-
export
|
|
121
|
+
export type PathTransformer<Source, Target> = ExtractPathByType<Source, Target>;
|
|
122
122
|
/**
|
|
123
123
|
* A function with the source object and mapper context as parameters that returns the value of a
|
|
124
124
|
* target's property.
|
|
@@ -146,7 +146,7 @@ export declare type PathTransformer<Source, Target> = ExtractPathByType<Source,
|
|
|
146
146
|
* ```
|
|
147
147
|
* @public
|
|
148
148
|
*/
|
|
149
|
-
export
|
|
149
|
+
export type FunctionTransformer<Source, Target> = (source: Source, context?: MapperContext) => Target;
|
|
150
150
|
/**
|
|
151
151
|
* An object containing a schema narrowing its source object based on the given path.
|
|
152
152
|
*
|
|
@@ -182,7 +182,7 @@ export declare type FunctionTransformer<Source, Target> = (source: Source, conte
|
|
|
182
182
|
* ```
|
|
183
183
|
* @public
|
|
184
184
|
*/
|
|
185
|
-
export
|
|
185
|
+
export type SubSchemaTransformer<Source, Target> = {
|
|
186
186
|
[Path in ExtractPath<Source>]: {
|
|
187
187
|
$context?: MapperContext;
|
|
188
188
|
$path: Path;
|
|
@@ -197,4 +197,4 @@ export declare type SubSchemaTransformer<Source, Target> = {
|
|
|
197
197
|
* @param Path - The path where the schema will be applied.
|
|
198
198
|
* @public
|
|
199
199
|
*/
|
|
200
|
-
export
|
|
200
|
+
export type SubSchema<Source, Target, Path extends ExtractPath<Source>> = ExtractType<Source, Path> extends (infer SourceArrayType)[] ? Target extends (infer TargetArrayType)[] ? Schema<SourceArrayType, TargetArrayType> : never : Target extends [] ? never : Schema<ExtractType<Source, Path>, Target>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-adapter",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.23",
|
|
4
4
|
"description": "A utils library to create a client for any API",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"prepublishOnly": "npm run build"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@empathyco/x-deep-merge": "^1.3.0-alpha.
|
|
39
|
-
"@empathyco/x-utils": "^1.0.0-alpha.
|
|
38
|
+
"@empathyco/x-deep-merge": "^1.3.0-alpha.30",
|
|
39
|
+
"@empathyco/x-utils": "^1.0.0-alpha.15",
|
|
40
40
|
"tslib": "~2.4.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"jest": "~27.3.1",
|
|
46
46
|
"rimraf": "~3.0.2",
|
|
47
47
|
"ts-jest": "~27.0.7",
|
|
48
|
-
"typescript": "~4.
|
|
48
|
+
"typescript": "~4.9.4"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "6fccb9c182fa3bad626901b551006a39a7f47d98"
|
|
54
54
|
}
|