@rest-vir/implement-service 1.3.3 → 1.4.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.
|
@@ -4,7 +4,7 @@ import { type IncomingHttpHeaders, type OutgoingHttpHeaders } from 'node:http';
|
|
|
4
4
|
import { type IsEqual, type IsNever } from 'type-fest';
|
|
5
5
|
import { type ServerRequest, type ServerResponse } from '../util/data.js';
|
|
6
6
|
import { type ServiceLogger } from '../util/service-logger.js';
|
|
7
|
-
import { type
|
|
7
|
+
import { type ReplaceUndefined } from '../util/types.js';
|
|
8
8
|
/**
|
|
9
9
|
* The part of {@link EndpointImplementationOutput} allowed for error responses.
|
|
10
10
|
*
|
|
@@ -62,7 +62,7 @@ export type EndpointImplementationParams<Context = any, SpecificEndpoint extends
|
|
|
62
62
|
request: ServerRequest;
|
|
63
63
|
response: ServerResponse;
|
|
64
64
|
log: Readonly<ServiceLogger>;
|
|
65
|
-
searchParams:
|
|
65
|
+
searchParams: ReplaceUndefined<SpecificEndpoint extends NoParam ? BaseSearchParams : Exclude<SpecificEndpoint, NoParam>['SearchParamsType'], BaseSearchParams>;
|
|
66
66
|
/** The actual running server info. */
|
|
67
67
|
server: RunningServerInfo;
|
|
68
68
|
};
|
|
@@ -88,7 +88,7 @@ export type GenericEndpointImplementationParams = {
|
|
|
88
88
|
context: any;
|
|
89
89
|
method: any;
|
|
90
90
|
endpoint: any;
|
|
91
|
-
service: MinimalService
|
|
91
|
+
service: MinimalService;
|
|
92
92
|
requestHeaders: IncomingHttpHeaders;
|
|
93
93
|
searchParams: BaseSearchParams;
|
|
94
94
|
requestData: any;
|
|
@@ -4,6 +4,7 @@ import { type IncomingHttpHeaders } from 'node:http';
|
|
|
4
4
|
import { type IsEqual } from 'type-fest';
|
|
5
5
|
import { type ServerRequest, type ServerWebSocket } from '../util/data.js';
|
|
6
6
|
import { type ServiceLogger } from '../util/service-logger.js';
|
|
7
|
+
import { type ReplaceUndefined } from '../util/types.js';
|
|
7
8
|
import { type RunningServerInfo } from './implement-endpoint.js';
|
|
8
9
|
/**
|
|
9
10
|
* A WebSocket implementation, with callbacks for WebSocket events.
|
|
@@ -59,7 +60,7 @@ export type WebSocketImplementationParams<Context = any, ServiceName extends str
|
|
|
59
60
|
headers: IncomingHttpHeaders;
|
|
60
61
|
request: ServerRequest;
|
|
61
62
|
protocols: SpecificWebSocket extends NoParam ? string[] : Exclude<SpecificWebSocket, NoParam>['ProtocolsType'];
|
|
62
|
-
searchParams: SpecificWebSocket extends NoParam ? BaseSearchParams : Exclude<SpecificWebSocket, NoParam>['SearchParamsType']
|
|
63
|
+
searchParams: SpecificWebSocket extends NoParam ? BaseSearchParams : ReplaceUndefined<Exclude<SpecificWebSocket, NoParam>['SearchParamsType'], BaseSearchParams>;
|
|
63
64
|
/** The actual running server info. */
|
|
64
65
|
server: RunningServerInfo;
|
|
65
66
|
} & (IsEqual<WithMessage, true> extends true ? {
|
|
@@ -3,7 +3,7 @@ import { type BaseSearchParams, type BaseServiceEndpointsInit, type BaseServiceW
|
|
|
3
3
|
import { type IncomingHttpHeaders } from 'node:http';
|
|
4
4
|
import { type RequireExactlyOne } from 'type-fest';
|
|
5
5
|
import { type ServerRequest, type ServerResponse } from '../util/data.js';
|
|
6
|
-
import { type
|
|
6
|
+
import { type ReplaceUndefined } from '../util/types.js';
|
|
7
7
|
import { type EndpointImplementationErrorOutput, type RunningServerInfo } from './implement-endpoint.js';
|
|
8
8
|
/**
|
|
9
9
|
* Output of {@link ContextInit}.
|
|
@@ -37,7 +37,7 @@ export type ContextInit<Context, ServiceName extends string, EndpointsInit exten
|
|
|
37
37
|
* @package [`@rest-vir/implement-service`](https://www.npmjs.com/package/@rest-vir/implement-service)
|
|
38
38
|
*/
|
|
39
39
|
export type ContextInitParams<ServiceName extends string = any, EndpointsInit extends BaseServiceEndpointsInit | NoParam = NoParam, WebSocketsInit extends BaseServiceWebSocketsInit | NoParam = NoParam> = ConstructPathParams<EndpointsInit extends NoParam ? NoParam : WithFinalWebSocketProps<Values<WebSocketsInit>, any>['path']> & {
|
|
40
|
-
searchParams:
|
|
40
|
+
searchParams: ReplaceUndefined<(WebSocketsInit extends NoParam ? BaseSearchParams | undefined : WithFinalWebSocketProps<Values<WebSocketsInit>, any>['SearchParamsType']) | (EndpointsInit extends NoParam ? BaseSearchParams | undefined : WithFinalEndpointProps<Values<EndpointsInit>, any>['SearchParamsType']), BaseSearchParams>;
|
|
41
41
|
service: MinimalService<ServiceName>;
|
|
42
42
|
requestHeaders: IncomingHttpHeaders;
|
|
43
43
|
method: HttpMethod;
|
package/dist/util/types.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { type EmptyObject } from 'type-fest';
|
|
2
1
|
/**
|
|
3
|
-
* Removes `undefined` unions from the given type and replaces it with `
|
|
4
|
-
* specifically for SearchParamsType.
|
|
2
|
+
* Removes `undefined` unions from the given type and replaces it with `Replace`.
|
|
5
3
|
*
|
|
6
4
|
* @category Internal
|
|
7
5
|
* @category Package : @rest-vir/implement-service
|
|
8
6
|
* @package [`@rest-vir/implement-service`](https://www.npmjs.com/package/@rest-vir/implement-service)
|
|
9
7
|
*/
|
|
10
|
-
export type
|
|
8
|
+
export type ReplaceUndefined<T, Replace> = T extends undefined ? Exclude<T, undefined> | Replace : T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rest-vir/implement-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Implement a service defined by @rest-vir/define-service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rest",
|
|
@@ -39,21 +39,21 @@
|
|
|
39
39
|
"test:update": "npm test update"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@augment-vir/assert": "^31.
|
|
43
|
-
"@augment-vir/common": "^31.
|
|
44
|
-
"@rest-vir/define-service": "^1.
|
|
42
|
+
"@augment-vir/assert": "^31.55.0",
|
|
43
|
+
"@augment-vir/common": "^31.55.0",
|
|
44
|
+
"@rest-vir/define-service": "^1.4.0",
|
|
45
45
|
"@types/ws": "^8.18.1",
|
|
46
46
|
"fastify": "^5.6.2",
|
|
47
47
|
"path-to-regexp": "^8.3.0",
|
|
48
|
-
"type-fest": "^5.
|
|
48
|
+
"type-fest": "^5.3.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@augment-vir/test": "^31.
|
|
52
|
-
"@types/node": "^
|
|
51
|
+
"@augment-vir/test": "^31.55.0",
|
|
52
|
+
"@types/node": "^25.0.3",
|
|
53
53
|
"c8": "^10.1.3",
|
|
54
54
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
55
55
|
"markdown-code-example-inserter": "^3.0.3",
|
|
56
|
-
"object-shape-tester": "^6.
|
|
56
|
+
"object-shape-tester": "^6.10.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"object-shape-tester": ">=5"
|