@rest-vir/define-service 1.0.0 → 1.1.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.
@@ -5,7 +5,7 @@ import { type CommonWebSocket } from '../web-socket/common-web-socket.js';
5
5
  import { type ClientWebSocket, type GenericConnectWebSocketParams } from '../web-socket/overwrite-web-socket-methods.js';
6
6
  import { type GenericWebSocketDefinition } from '../web-socket/web-socket-definition.js';
7
7
  import { type CollapsedConnectWebSocketParams } from './connect-web-socket.js';
8
- import { type CollapsedFetchEndpointParams, type FetchEndpointOutput, type GenericFetchEndpointParams } from './fetch-endpoint.js';
8
+ import { buildEndpointUrl, type CollapsedFetchEndpointParams, type FetchEndpointOutput, type GenericFetchEndpointParams } from './fetch-endpoint.js';
9
9
  /**
10
10
  * An API generated by {@link generateApi}. This can be easily mocked by wrapping this API in
11
11
  * {@link makeMockApi}.
@@ -23,6 +23,7 @@ export declare class RestVirApi<SpecificService extends ServiceDefinition> {
23
23
  [EndpointPath in keyof SpecificService['endpoints']]: SpecificService['endpoints'][EndpointPath] extends GenericEndpointDefinition ? SpecificService['endpoints'][EndpointPath] & {
24
24
  /** Send a fetch request to this endpoint. */
25
25
  fetch(...params: CollapsedFetchEndpointParams<SpecificService['endpoints'][EndpointPath]>): Promise<FetchEndpointOutput<SpecificService['endpoints'][EndpointPath]>>;
26
+ buildUrl(params: Parameters<typeof buildEndpointUrl<SpecificService['endpoints'][EndpointPath]>>[1]): string;
26
27
  } : never;
27
28
  };
28
29
  /**
@@ -1,6 +1,6 @@
1
1
  import { mapObjectValues, } from '@augment-vir/common';
2
2
  import { connectWebSocket } from './connect-web-socket.js';
3
- import { fetchEndpoint, } from './fetch-endpoint.js';
3
+ import { buildEndpointUrl, fetchEndpoint, } from './fetch-endpoint.js';
4
4
  /**
5
5
  * An API generated by {@link generateApi}. This can be easily mocked by wrapping this API in
6
6
  * {@link makeMockApi}.
@@ -46,6 +46,9 @@ export class RestVirApi {
46
46
  ...params[0],
47
47
  });
48
48
  },
49
+ buildUrl(params) {
50
+ return buildEndpointUrl(endpointDefinition, params);
51
+ },
49
52
  };
50
53
  });
51
54
  this.webSockets = mapObjectValues(service.webSockets, (webSocketPath, webSocketDefinition) => {
@@ -25,7 +25,7 @@ url) {
25
25
  else {
26
26
  return {
27
27
  ...(endpointPath ? { endpointPath } : {}),
28
- ...(webSocketPath ? { webSocketPath: webSocketPath } : {}),
28
+ ...(webSocketPath ? { webSocketPath } : {}),
29
29
  };
30
30
  }
31
31
  }
@@ -43,7 +43,7 @@ export type MockResponseParams = Overwrite<Partial<Pick<Response, 'redirected' |
43
43
  * @category Package : @rest-vir/define-service
44
44
  * @package [`@rest-vir/define-service`](https://www.npmjs.com/package/@rest-vir/define-service)
45
45
  */
46
- export declare class MockResponseBodyStream extends ReadableStream<Uint8Array> {
46
+ export declare class MockResponseBodyStream extends ReadableStream<Uint8Array<ArrayBuffer>> {
47
47
  private getReaderCalled;
48
48
  constructor(body: unknown, getReaderCalled: () => void);
49
49
  getReader(...args: any): any;
@@ -133,6 +133,7 @@ export function overwriteWebSocketMethods(webSocketDefinition, rawWebSocket, web
133
133
  send(message) {
134
134
  originalSend.call(webSocket,
135
135
  /** The extra `String()` wrapper is to convert `undefined` into `'undefined'`. */
136
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion
136
137
  String(JSON.stringify(verifyWebSocketMessage(webSocketDefinition, message, webSocketLocation))));
137
138
  },
138
139
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rest-vir/define-service",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Define an connect to a declarative and type safe REST and WebSocket service.",
5
5
  "keywords": [
6
6
  "rest",
@@ -40,14 +40,14 @@
40
40
  "test:update": "npm test update"
41
41
  },
42
42
  "dependencies": {
43
- "@augment-vir/assert": "^31.28.0",
44
- "@augment-vir/common": "^31.28.0",
43
+ "@augment-vir/assert": "^31.32.2",
44
+ "@augment-vir/common": "^31.32.2",
45
45
  "date-vir": "^7.4.0",
46
46
  "type-fest": "^4.41.0",
47
47
  "url-vir": "^2.1.3"
48
48
  },
49
49
  "devDependencies": {
50
- "@augment-vir/test": "^31.28.0",
50
+ "@augment-vir/test": "^31.32.2",
51
51
  "@web/dev-server-esbuild": "^1.0.4",
52
52
  "@web/test-runner": "^0.20.2",
53
53
  "@web/test-runner-commands": "^0.9.0",
@@ -56,7 +56,7 @@
56
56
  "istanbul-smart-text-reporter": "^1.1.5",
57
57
  "markdown-code-example-inserter": "^3.0.3",
58
58
  "object-shape-tester": "^5.3.0",
59
- "typedoc": "^0.28.8",
59
+ "typedoc": "^0.28.10",
60
60
  "ws": "^8.18.3"
61
61
  },
62
62
  "peerDependencies": {