@rest-vir/implement-service 1.3.2 → 1.3.4

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 ReplaceUndefinedWithEmptyObject } from '../util/types.js';
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: ReplaceUndefinedWithEmptyObject<SpecificEndpoint extends NoParam ? BaseSearchParams : Exclude<SpecificEndpoint, NoParam>['SearchParamsType']>;
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
  };
@@ -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 ReplaceUndefinedWithEmptyObject } from '../util/types.js';
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: ReplaceUndefinedWithEmptyObject<(WebSocketsInit extends NoParam ? BaseSearchParams | undefined : WithFinalWebSocketProps<Values<WebSocketsInit>, any>['SearchParamsType']) | (EndpointsInit extends NoParam ? BaseSearchParams | undefined : WithFinalEndpointProps<Values<EndpointsInit>, any>['SearchParamsType'])>;
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;
@@ -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 `EmptyObject`. This is used
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 ReplaceUndefinedWithEmptyObject<T> = T extends undefined ? Exclude<T, undefined> | EmptyObject : T;
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.2",
3
+ "version": "1.3.4",
4
4
  "description": "Implement a service defined by @rest-vir/define-service.",
5
5
  "keywords": [
6
6
  "rest",
@@ -39,17 +39,17 @@
39
39
  "test:update": "npm test update"
40
40
  },
41
41
  "dependencies": {
42
- "@augment-vir/assert": "^31.48.0",
43
- "@augment-vir/common": "^31.48.0",
44
- "@rest-vir/define-service": "^1.3.2",
42
+ "@augment-vir/assert": "^31.51.1",
43
+ "@augment-vir/common": "^31.51.1",
44
+ "@rest-vir/define-service": "^1.3.4",
45
45
  "@types/ws": "^8.18.1",
46
- "fastify": "^5.6.1",
46
+ "fastify": "^5.6.2",
47
47
  "path-to-regexp": "^8.3.0",
48
48
  "type-fest": "^5.2.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@augment-vir/test": "^31.48.0",
52
- "@types/node": "^24.10.0",
51
+ "@augment-vir/test": "^31.51.1",
52
+ "@types/node": "^24.10.1",
53
53
  "c8": "^10.1.3",
54
54
  "istanbul-smart-text-reporter": "^1.1.5",
55
55
  "markdown-code-example-inserter": "^3.0.3",