@tstdl/base 0.92.147 → 0.92.148

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,4 +1,5 @@
1
1
  import { HttpClient, type HttpClientOptions } from '../../http/client/index.js';
2
+ import { bustCacheToken } from '../../http/index.js';
2
3
  import { type Resolvable } from '../../injector/interfaces.js';
3
4
  import type { Type } from '../../types/index.js';
4
5
  import { type ApiClientImplementation, type ApiDefinition, type ApiEndpointDefinition } from '../types.js';
@@ -13,6 +14,7 @@ export type ClientOptions = {
13
14
  };
14
15
  export type ApiClientHttpRequestContext = {
15
16
  endpoint: ApiEndpointDefinition;
17
+ [bustCacheToken]?: boolean;
16
18
  };
17
19
  export declare const httpClientSymbol: unique symbol;
18
20
  export declare const apiDefinitionSymbol: unique symbol;
@@ -1,5 +1,5 @@
1
1
  import { HttpClient, HttpClientRequest } from '../../http/client/index.js';
2
- import { normalizeSingleHttpValue } from '../../http/types.js';
2
+ import { bustCacheToken, normalizeSingleHttpValue } from '../../http/index.js';
3
3
  import { inject } from '../../injector/inject.js';
4
4
  import { Injector } from '../../injector/injector.js';
5
5
  import { resolveArgumentType } from '../../injector/interfaces.js';
@@ -74,6 +74,9 @@ export function compileClient(definition, options = defaultOptions) {
74
74
  }
75
75
  return getServerSentEvents(this[httpClientSymbol].options.baseUrl, resource, endpoint, parameters);
76
76
  }
77
+ if (context.endpoint.data?.[bustCacheToken] == true) {
78
+ context[bustCacheToken] = true;
79
+ }
77
80
  const request = new HttpClientRequest({
78
81
  method,
79
82
  url: resource,
package/api/utils.d.ts CHANGED
@@ -5,5 +5,6 @@ type GetApiEndpointUrlData = {
5
5
  defaultPrefix: string | undefined | null;
6
6
  explicitVersion?: number | null;
7
7
  };
8
+ export declare const defaultAccessControlAllowHeaders = "Content-Type, Authorization";
8
9
  export declare function getFullApiEndpointResource({ api, endpoint, defaultPrefix, explicitVersion }: GetApiEndpointUrlData): string;
9
10
  export {};
package/api/utils.js CHANGED
@@ -2,6 +2,7 @@ import { toArray } from '../utils/array/array.js';
2
2
  import { compareByValueDescending } from '../utils/comparison.js';
3
3
  import { sort } from '../utils/iterable-helpers/sort.js';
4
4
  import { isDefined, isNull } from '../utils/type-guards.js';
5
+ export const defaultAccessControlAllowHeaders = 'Content-Type, Authorization';
5
6
  export function getFullApiEndpointResource({ api, endpoint, defaultPrefix, explicitVersion }) {
6
7
  const versionArray = toArray(isDefined(explicitVersion) ? explicitVersion : endpoint.version);
7
8
  const version = sort(versionArray, compareByValueDescending)[0];
@@ -1,3 +1,4 @@
1
+ import { bustCacheToken } from '../../http/tokens.js';
1
2
  import { ServerSentEvents } from '../../sse/server-sent-events.js';
2
3
  import { Document, DocumentCategory, DocumentRequest, DocumentRequestsTemplate, DocumentRequestTemplate, DocumentType } from '../models/index.js';
3
4
  import { DocumentCategoryView, DocumentManagementData, DocumentRequestsTemplateData } from '../service-models/index.js';
@@ -22,6 +23,12 @@ export declare const documentManagementApiDefinition: {
22
23
  }>;
23
24
  result: typeof ServerSentEvents;
24
25
  credentials: true;
26
+ data: {
27
+ [bustCacheToken]: boolean;
28
+ };
29
+ cors: {
30
+ accessControlAllowHeaders: string;
31
+ };
25
32
  };
26
33
  loadDocumentRequestsTemplateData: {
27
34
  resource: string;
@@ -413,6 +420,12 @@ declare const _DocumentManagementApi: import("../../api/client/index.js").ApiCli
413
420
  }>;
414
421
  result: typeof ServerSentEvents;
415
422
  credentials: true;
423
+ data: {
424
+ [bustCacheToken]: boolean;
425
+ };
426
+ cors: {
427
+ accessControlAllowHeaders: string;
428
+ };
416
429
  };
417
430
  loadDocumentRequestsTemplateData: {
418
431
  resource: string;
@@ -6,6 +6,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { compileClient } from '../../api/client/index.js';
8
8
  import { defineApi } from '../../api/index.js';
9
+ import { defaultAccessControlAllowHeaders } from '../../api/utils.js';
10
+ import { bustCacheToken } from '../../http/tokens.js';
9
11
  import { ReplaceClass } from '../../injector/decorators.js';
10
12
  import { array, boolean, literal, number, object, optional, string } from '../../schema/index.js';
11
13
  import { ServerSentEvents } from '../../sse/server-sent-events.js';
@@ -28,6 +30,12 @@ export const documentManagementApiDefinition = defineApi({
28
30
  parameters: loadDataParametersSchema,
29
31
  result: ServerSentEvents,
30
32
  credentials: true,
33
+ data: {
34
+ [bustCacheToken]: true,
35
+ },
36
+ cors: {
37
+ accessControlAllowHeaders: `${defaultAccessControlAllowHeaders}, Cache-Control`,
38
+ },
31
39
  },
32
40
  loadDocumentRequestsTemplateData: {
33
41
  resource: 'views/document-requests-template-data',
@@ -138,7 +138,7 @@ export class HttpClientRequest {
138
138
  body,
139
139
  timeout: this.timeout,
140
140
  throwOnNon200: this.throwOnNon200,
141
- context: this.context
141
+ context: this.context,
142
142
  };
143
143
  }
144
144
  }
package/http/index.d.ts CHANGED
@@ -13,5 +13,6 @@ export * from './http-url-parameters.js';
13
13
  export * from './http-value-map.js';
14
14
  export * from './http.error.js';
15
15
  export * from './server/index.js';
16
+ export * from './tokens.js';
16
17
  export * from './types.js';
17
18
  export * from './utils.js';
package/http/index.js CHANGED
@@ -13,5 +13,6 @@ export * from './http-url-parameters.js';
13
13
  export * from './http-value-map.js';
14
14
  export * from './http.error.js';
15
15
  export * from './server/index.js';
16
+ export * from './tokens.js';
16
17
  export * from './types.js';
17
18
  export * from './utils.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This can be used in the request context to indicate that the request should not be cached.
3
+ * HttpClientAdapters should check for this token and bypass any caching mechanisms if it is present.
4
+ */
5
+ export declare const bustCacheToken: unique symbol;
package/http/tokens.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This can be used in the request context to indicate that the request should not be cached.
3
+ * HttpClientAdapters should check for this token and bypass any caching mechanisms if it is present.
4
+ */
5
+ export const bustCacheToken = Symbol('bustCacheToken');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.147",
3
+ "version": "0.92.148",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"