@tstdl/base 0.90.79 → 0.90.81

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.
@@ -8,8 +8,8 @@ export type ClientOptions = {
8
8
  * Url prefix
9
9
  * @default `api/`
10
10
  */
11
- prefix?: string;
12
- defaultHttpClientOptions?: HttpClientOptions;
11
+ prefix?: string | null;
12
+ defaultHttpClientOptions?: HttpClientOptions | null;
13
13
  };
14
14
  export type ApiClientHttpRequestContext = {
15
15
  endpoint: ApiEndpointDefinition;
@@ -47,18 +47,19 @@ export function compileClient(definition, options = defaultOptions) {
47
47
  }[apiName];
48
48
  Injector.registerSingleton(api, {
49
49
  useFactory: (argument, context) => {
50
- const httpClient = (argument instanceof HttpClient) ? argument : context.resolve(HttpClient, argument ?? options.defaultHttpClientOptions);
50
+ const httpClient = (argument instanceof HttpClient) ? argument : context.resolve(HttpClient, argument ?? options.defaultHttpClientOptions ?? undefined);
51
51
  return new api(httpClient);
52
52
  }
53
53
  });
54
54
  const endpointsEntries = normalizedApiDefinitionEndpointsEntries(endpoints);
55
55
  for (const [name, endpoint] of endpointsEntries) {
56
56
  const methods = isArray(endpoint.method) ? endpoint.method : [endpoint.method ?? 'GET'];
57
- const resource = getFullApiEndpointResource({ api: definition, endpoint, defaultPrefix: options.prefix });
57
+ let resource;
58
58
  const hasGet = methods.includes('GET');
59
59
  const fallbackMethod = methods.find((method) => method != 'GET') ?? 'GET';
60
60
  const apiEndpointFunction = {
61
61
  async [name](parameters, requestBody) {
62
+ resource ??= getFullApiEndpointResource({ api: definition, endpoint, defaultPrefix: options.prefix });
62
63
  const context = { endpoint };
63
64
  const method = (hasGet && isUndefined(parameters)) ? 'GET' : fallbackMethod;
64
65
  if (endpoint.result == ServerSentEvents) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.90.79",
3
+ "version": "0.90.81",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"