@rest-vir/implement-service 1.2.5 → 1.3.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ErrorHttpStatusCategories, type ExtractKeysWithMatchingValues, type HttpMethod, type HttpStatusByCategory, type MaybePromise, type SuccessHttpStatusCategories } from '@augment-vir/common';
|
|
2
|
-
import { type BaseSearchParams, type BaseServiceEndpointsInit, type EndpointDefinition, type EndpointInit, type EndpointPathBase, type
|
|
2
|
+
import { type BaseSearchParams, type BaseServiceEndpointsInit, type ConstructPathParams, type EndpointDefinition, type EndpointInit, type EndpointPathBase, type GenericPathParams, type MinimalService, type NoParam, type ServiceDefinition, type WithFinalEndpointProps } from '@rest-vir/define-service';
|
|
3
3
|
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';
|
|
@@ -52,8 +52,7 @@ export type EndpointImplementationOutput<ResponseDataType = unknown> = EndpointI
|
|
|
52
52
|
* @category Package : @rest-vir/implement-service
|
|
53
53
|
* @package [`@rest-vir/implement-service`](https://www.npmjs.com/package/@rest-vir/implement-service)
|
|
54
54
|
*/
|
|
55
|
-
export type EndpointImplementationParams<Context = any, SpecificEndpoint extends EndpointDefinition | NoParam = NoParam, ServiceName extends string = any> = {
|
|
56
|
-
pathParams: SpecificEndpoint extends NoParam ? Readonly<Record<string, string>> : PathParams<Exclude<SpecificEndpoint, NoParam>['path']> extends string ? Readonly<Record<PathParams<Exclude<SpecificEndpoint, NoParam>['path']>, string>> : Readonly<Record<string, string>>;
|
|
55
|
+
export type EndpointImplementationParams<Context = any, SpecificEndpoint extends EndpointDefinition | NoParam = NoParam, ServiceName extends string = any> = (SpecificEndpoint extends NoParam ? GenericPathParams : ConstructPathParams<Exclude<SpecificEndpoint, NoParam>['path']>) & {
|
|
57
56
|
context: NoInfer<Context>;
|
|
58
57
|
method: IsEqual<Extract<SpecificEndpoint, NoParam>, NoParam> extends true ? HttpMethod : ExtractKeysWithMatchingValues<Exclude<SpecificEndpoint, NoParam>['methods'], true> extends infer AvailableMethod ? IsNever<AvailableMethod> extends true ? HttpMethod : AvailableMethod : never;
|
|
59
58
|
endpoint: IsEqual<Extract<SpecificEndpoint, NoParam>, NoParam> extends true ? EndpointDefinition : SpecificEndpoint;
|
|
@@ -92,14 +91,13 @@ export type GenericEndpointImplementationParams = {
|
|
|
92
91
|
service: MinimalService<any>;
|
|
93
92
|
requestHeaders: IncomingHttpHeaders;
|
|
94
93
|
searchParams: BaseSearchParams;
|
|
95
|
-
pathParams: Readonly<Record<string, string>>;
|
|
96
94
|
requestData: any;
|
|
97
95
|
request: ServerRequest;
|
|
98
96
|
response: ServerResponse;
|
|
99
97
|
log: Readonly<ServiceLogger>;
|
|
100
98
|
/** The actual running server info. */
|
|
101
99
|
server: RunningServerInfo;
|
|
102
|
-
};
|
|
100
|
+
} & GenericPathParams;
|
|
103
101
|
/**
|
|
104
102
|
* A full, type-safe endpoint implementation type.
|
|
105
103
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HttpMethod, type MaybePromise, type Values } from '@augment-vir/common';
|
|
2
|
-
import { type BaseSearchParams, type BaseServiceEndpointsInit, type BaseServiceWebSocketsInit, type EndpointDefinition, type EndpointPathBase, type MinimalService, type NoParam, type
|
|
2
|
+
import { type BaseSearchParams, type BaseServiceEndpointsInit, type BaseServiceWebSocketsInit, type ConstructPathParams, type EndpointDefinition, type EndpointPathBase, type MinimalService, type NoParam, type WebSocketDefinition, type WithFinalEndpointProps, type WithFinalWebSocketProps } from '@rest-vir/define-service';
|
|
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';
|
|
@@ -36,8 +36,7 @@ export type ContextInit<Context, ServiceName extends string, EndpointsInit exten
|
|
|
36
36
|
* @category Package : @rest-vir/implement-service
|
|
37
37
|
* @package [`@rest-vir/implement-service`](https://www.npmjs.com/package/@rest-vir/implement-service)
|
|
38
38
|
*/
|
|
39
|
-
export type ContextInitParams<ServiceName extends string = any, EndpointsInit extends BaseServiceEndpointsInit | NoParam = NoParam, WebSocketsInit extends BaseServiceWebSocketsInit | NoParam = NoParam> = {
|
|
40
|
-
pathParams: EndpointsInit extends NoParam ? Readonly<Record<string, string>> : PathParams<WithFinalWebSocketProps<Values<WebSocketsInit>, any>['path']> extends string ? Readonly<Record<PathParams<WithFinalWebSocketProps<Values<WebSocketsInit>, any>['path']>, string>> : Readonly<Record<string, string>>;
|
|
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']> & {
|
|
41
40
|
searchParams: ReplaceUndefinedWithEmptyObject<(WebSocketsInit extends NoParam ? BaseSearchParams | undefined : WithFinalWebSocketProps<Values<WebSocketsInit>, any>['SearchParamsType']) | (EndpointsInit extends NoParam ? BaseSearchParams | undefined : WithFinalEndpointProps<Values<EndpointsInit>, any>['SearchParamsType'])>;
|
|
42
41
|
service: MinimalService<ServiceName>;
|
|
43
42
|
requestHeaders: IncomingHttpHeaders;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rest-vir/implement-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.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.48.0",
|
|
43
|
+
"@augment-vir/common": "^31.48.0",
|
|
44
|
+
"@rest-vir/define-service": "^1.3.0",
|
|
45
45
|
"@types/ws": "^8.18.1",
|
|
46
46
|
"fastify": "^5.6.1",
|
|
47
47
|
"path-to-regexp": "^8.3.0",
|
|
48
|
-
"type-fest": "^5.
|
|
48
|
+
"type-fest": "^5.2.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@augment-vir/test": "^31.
|
|
52
|
-
"@types/node": "^24.
|
|
51
|
+
"@augment-vir/test": "^31.48.0",
|
|
52
|
+
"@types/node": "^24.10.0",
|
|
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.9.
|
|
56
|
+
"object-shape-tester": "^6.9.3"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"object-shape-tester": ">=5"
|