@c-rex/core 0.1.21 → 0.1.23
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.
- package/dist/OIDC.js +239 -27
- package/dist/OIDC.js.map +1 -1
- package/dist/OIDC.mjs +239 -27
- package/dist/OIDC.mjs.map +1 -1
- package/dist/logger.js +239 -27
- package/dist/logger.js.map +1 -1
- package/dist/logger.mjs +239 -27
- package/dist/logger.mjs.map +1 -1
- package/dist/requests.d.mts +66 -2
- package/dist/requests.d.ts +66 -2
- package/dist/requests.js +866 -47
- package/dist/requests.js.map +1 -1
- package/dist/requests.mjs +842 -46
- package/dist/requests.mjs.map +1 -1
- package/dist/sdk.js +124 -9
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.mjs +124 -9
- package/dist/sdk.mjs.map +1 -1
- package/package.json +70 -69
package/dist/requests.d.mts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
import { JWTPayload } from 'jose';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* HTTP methods supported by the API client.
|
|
3
6
|
*/
|
|
@@ -6,6 +9,62 @@ type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTION
|
|
|
6
9
|
* Type for query parameter values - supports primitives and arrays.
|
|
7
10
|
*/
|
|
8
11
|
type ParamValue = string | number | boolean | undefined | (string | number | boolean)[];
|
|
12
|
+
/**
|
|
13
|
+
* Cache constants below represent two distinct layers:
|
|
14
|
+
* - internal cache tags (`CREX_*_TAG`) used by Next.js tag-based revalidation
|
|
15
|
+
* - external cache segments (`CREX_CACHE_SEGMENT_*`) used by admin/API invalidation endpoints
|
|
16
|
+
*/
|
|
17
|
+
declare const CREX_API_CACHE_TAG = "crex-api";
|
|
18
|
+
declare const CREX_API_CACHE_VCARD_TAG = "crex-api:vcard";
|
|
19
|
+
declare const CREX_READMODEL_CACHE_TAG = "crex-readmodel";
|
|
20
|
+
declare const CREX_READMODEL_CACHE_VCARD_TAG = "crex-readmodel:vcard";
|
|
21
|
+
declare const CREX_READMODEL_CACHE_METADATA_TAG = "crex-readmodel:metadata";
|
|
22
|
+
declare const CREX_READMODEL_CACHE_ORGANIZATION_TAG = "crex-readmodel:organization";
|
|
23
|
+
declare const CREX_READMODEL_CACHE_INFORMATION_SUBJECTS_TAG = "crex-readmodel:information-subjects";
|
|
24
|
+
declare const CREX_READMODEL_CACHE_DOCUMENT_TYPES_TAG = "crex-readmodel:document-types";
|
|
25
|
+
declare const CREX_READMODEL_CACHE_COMPONENTS_TAG = "crex-readmodel:components";
|
|
26
|
+
declare const CREX_READMODEL_CACHE_PARTIES_TAG = "crex-readmodel:parties";
|
|
27
|
+
declare const CREX_CACHE_SEGMENT_ALL = "all";
|
|
28
|
+
declare const CREX_CACHE_SEGMENT_METADATA = "metadata";
|
|
29
|
+
declare const CREX_CACHE_SEGMENT_VCARD = "vcard";
|
|
30
|
+
declare const CREX_CACHE_SEGMENT_REQUESTS = "requests";
|
|
31
|
+
/**
|
|
32
|
+
* External cache segment names used by admin/API invalidation endpoints.
|
|
33
|
+
* Segments are user-facing buckets; tags are internal cache keys used by Next.js revalidation.
|
|
34
|
+
*/
|
|
35
|
+
type CrexCacheSegment = typeof CREX_CACHE_SEGMENT_ALL | typeof CREX_CACHE_SEGMENT_METADATA | typeof CREX_CACHE_SEGMENT_VCARD | typeof CREX_CACHE_SEGMENT_REQUESTS;
|
|
36
|
+
/**
|
|
37
|
+
* Segment-to-tag mapping for cache invalidation.
|
|
38
|
+
*
|
|
39
|
+
* Why both levels exist:
|
|
40
|
+
* - Segment (`metadata`, `vcard`, ...) is the coarse external API contract.
|
|
41
|
+
* - Tag (`crex-readmodel:metadata`, ...) is the internal revalidation key.
|
|
42
|
+
*/
|
|
43
|
+
declare const CREX_CACHE_SEGMENT_TO_TAGS: Record<CrexCacheSegment, string[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolves effective cache tags for the requested external segments.
|
|
46
|
+
* Unknown segment strings are ignored.
|
|
47
|
+
*/
|
|
48
|
+
declare const resolveCacheTagsForSegments: (segments: string[]) => string[];
|
|
49
|
+
/**
|
|
50
|
+
* Returns the canonical list of supported external cache segments.
|
|
51
|
+
*/
|
|
52
|
+
declare const getSupportedCacheSegments: () => CrexCacheSegment[];
|
|
53
|
+
declare class CacheClearAuthUnauthorizedError extends Error {
|
|
54
|
+
constructor(message: string);
|
|
55
|
+
}
|
|
56
|
+
declare class CacheClearAuthConfigurationError extends Error {
|
|
57
|
+
constructor(message: string);
|
|
58
|
+
}
|
|
59
|
+
declare const verifyCacheClearBearerToken: (token: string) => Promise<JWTPayload>;
|
|
60
|
+
declare const extractScopesFromJwtPayload: (payload: Record<string, unknown> | JWTPayload | null) => string[];
|
|
61
|
+
declare const handleCacheClearPostRequest: (req: NextRequest) => Promise<NextResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* Clears process-local request caches.
|
|
64
|
+
* Used by explicit cache invalidation endpoints so short-lived in-memory caches
|
|
65
|
+
* do not serve stale results right after tag revalidation.
|
|
66
|
+
*/
|
|
67
|
+
declare const clearProcessLocalRequestCaches: () => void;
|
|
9
68
|
/**
|
|
10
69
|
* Interface for API call parameters.
|
|
11
70
|
*/
|
|
@@ -15,6 +74,8 @@ interface CallParams {
|
|
|
15
74
|
body?: any;
|
|
16
75
|
headers?: Record<string, string>;
|
|
17
76
|
params?: Record<string, ParamValue>;
|
|
77
|
+
skipCookieTokenLookup?: boolean;
|
|
78
|
+
authToken?: string;
|
|
18
79
|
}
|
|
19
80
|
/**
|
|
20
81
|
* API client class for the CREX application.
|
|
@@ -24,6 +85,8 @@ declare class CrexApi {
|
|
|
24
85
|
private customerConfig;
|
|
25
86
|
private baseUrl;
|
|
26
87
|
private logger;
|
|
88
|
+
private debugTiming;
|
|
89
|
+
private resolveLogCategory;
|
|
27
90
|
/**
|
|
28
91
|
* Initializes the API client if it hasn't been initialized yet.
|
|
29
92
|
* Loads customer configuration and initializes the logger.
|
|
@@ -41,6 +104,7 @@ declare class CrexApi {
|
|
|
41
104
|
* @returns The full URL with query string
|
|
42
105
|
*/
|
|
43
106
|
private buildUrl;
|
|
107
|
+
private getApiRootUrl;
|
|
44
108
|
/**
|
|
45
109
|
* Executes an API request with caching, authentication, and retry logic.
|
|
46
110
|
*
|
|
@@ -53,7 +117,7 @@ declare class CrexApi {
|
|
|
53
117
|
* @returns The response data
|
|
54
118
|
* @throws Error if the request fails after maximum retries
|
|
55
119
|
*/
|
|
56
|
-
execute<T>({ url, method, params, body, headers, }: CallParams): Promise<T>;
|
|
120
|
+
execute<T>({ url, method, params, body, headers, skipCookieTokenLookup, authToken, }: CallParams): Promise<T>;
|
|
57
121
|
}
|
|
58
122
|
|
|
59
|
-
export { CrexApi };
|
|
123
|
+
export { CREX_API_CACHE_TAG, CREX_API_CACHE_VCARD_TAG, CREX_CACHE_SEGMENT_ALL, CREX_CACHE_SEGMENT_METADATA, CREX_CACHE_SEGMENT_REQUESTS, CREX_CACHE_SEGMENT_TO_TAGS, CREX_CACHE_SEGMENT_VCARD, CREX_READMODEL_CACHE_COMPONENTS_TAG, CREX_READMODEL_CACHE_DOCUMENT_TYPES_TAG, CREX_READMODEL_CACHE_INFORMATION_SUBJECTS_TAG, CREX_READMODEL_CACHE_METADATA_TAG, CREX_READMODEL_CACHE_ORGANIZATION_TAG, CREX_READMODEL_CACHE_PARTIES_TAG, CREX_READMODEL_CACHE_TAG, CREX_READMODEL_CACHE_VCARD_TAG, CacheClearAuthConfigurationError, CacheClearAuthUnauthorizedError, CrexApi, type CrexCacheSegment, clearProcessLocalRequestCaches, extractScopesFromJwtPayload, getSupportedCacheSegments, handleCacheClearPostRequest, resolveCacheTagsForSegments, verifyCacheClearBearerToken };
|
package/dist/requests.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
import { JWTPayload } from 'jose';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* HTTP methods supported by the API client.
|
|
3
6
|
*/
|
|
@@ -6,6 +9,62 @@ type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTION
|
|
|
6
9
|
* Type for query parameter values - supports primitives and arrays.
|
|
7
10
|
*/
|
|
8
11
|
type ParamValue = string | number | boolean | undefined | (string | number | boolean)[];
|
|
12
|
+
/**
|
|
13
|
+
* Cache constants below represent two distinct layers:
|
|
14
|
+
* - internal cache tags (`CREX_*_TAG`) used by Next.js tag-based revalidation
|
|
15
|
+
* - external cache segments (`CREX_CACHE_SEGMENT_*`) used by admin/API invalidation endpoints
|
|
16
|
+
*/
|
|
17
|
+
declare const CREX_API_CACHE_TAG = "crex-api";
|
|
18
|
+
declare const CREX_API_CACHE_VCARD_TAG = "crex-api:vcard";
|
|
19
|
+
declare const CREX_READMODEL_CACHE_TAG = "crex-readmodel";
|
|
20
|
+
declare const CREX_READMODEL_CACHE_VCARD_TAG = "crex-readmodel:vcard";
|
|
21
|
+
declare const CREX_READMODEL_CACHE_METADATA_TAG = "crex-readmodel:metadata";
|
|
22
|
+
declare const CREX_READMODEL_CACHE_ORGANIZATION_TAG = "crex-readmodel:organization";
|
|
23
|
+
declare const CREX_READMODEL_CACHE_INFORMATION_SUBJECTS_TAG = "crex-readmodel:information-subjects";
|
|
24
|
+
declare const CREX_READMODEL_CACHE_DOCUMENT_TYPES_TAG = "crex-readmodel:document-types";
|
|
25
|
+
declare const CREX_READMODEL_CACHE_COMPONENTS_TAG = "crex-readmodel:components";
|
|
26
|
+
declare const CREX_READMODEL_CACHE_PARTIES_TAG = "crex-readmodel:parties";
|
|
27
|
+
declare const CREX_CACHE_SEGMENT_ALL = "all";
|
|
28
|
+
declare const CREX_CACHE_SEGMENT_METADATA = "metadata";
|
|
29
|
+
declare const CREX_CACHE_SEGMENT_VCARD = "vcard";
|
|
30
|
+
declare const CREX_CACHE_SEGMENT_REQUESTS = "requests";
|
|
31
|
+
/**
|
|
32
|
+
* External cache segment names used by admin/API invalidation endpoints.
|
|
33
|
+
* Segments are user-facing buckets; tags are internal cache keys used by Next.js revalidation.
|
|
34
|
+
*/
|
|
35
|
+
type CrexCacheSegment = typeof CREX_CACHE_SEGMENT_ALL | typeof CREX_CACHE_SEGMENT_METADATA | typeof CREX_CACHE_SEGMENT_VCARD | typeof CREX_CACHE_SEGMENT_REQUESTS;
|
|
36
|
+
/**
|
|
37
|
+
* Segment-to-tag mapping for cache invalidation.
|
|
38
|
+
*
|
|
39
|
+
* Why both levels exist:
|
|
40
|
+
* - Segment (`metadata`, `vcard`, ...) is the coarse external API contract.
|
|
41
|
+
* - Tag (`crex-readmodel:metadata`, ...) is the internal revalidation key.
|
|
42
|
+
*/
|
|
43
|
+
declare const CREX_CACHE_SEGMENT_TO_TAGS: Record<CrexCacheSegment, string[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolves effective cache tags for the requested external segments.
|
|
46
|
+
* Unknown segment strings are ignored.
|
|
47
|
+
*/
|
|
48
|
+
declare const resolveCacheTagsForSegments: (segments: string[]) => string[];
|
|
49
|
+
/**
|
|
50
|
+
* Returns the canonical list of supported external cache segments.
|
|
51
|
+
*/
|
|
52
|
+
declare const getSupportedCacheSegments: () => CrexCacheSegment[];
|
|
53
|
+
declare class CacheClearAuthUnauthorizedError extends Error {
|
|
54
|
+
constructor(message: string);
|
|
55
|
+
}
|
|
56
|
+
declare class CacheClearAuthConfigurationError extends Error {
|
|
57
|
+
constructor(message: string);
|
|
58
|
+
}
|
|
59
|
+
declare const verifyCacheClearBearerToken: (token: string) => Promise<JWTPayload>;
|
|
60
|
+
declare const extractScopesFromJwtPayload: (payload: Record<string, unknown> | JWTPayload | null) => string[];
|
|
61
|
+
declare const handleCacheClearPostRequest: (req: NextRequest) => Promise<NextResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* Clears process-local request caches.
|
|
64
|
+
* Used by explicit cache invalidation endpoints so short-lived in-memory caches
|
|
65
|
+
* do not serve stale results right after tag revalidation.
|
|
66
|
+
*/
|
|
67
|
+
declare const clearProcessLocalRequestCaches: () => void;
|
|
9
68
|
/**
|
|
10
69
|
* Interface for API call parameters.
|
|
11
70
|
*/
|
|
@@ -15,6 +74,8 @@ interface CallParams {
|
|
|
15
74
|
body?: any;
|
|
16
75
|
headers?: Record<string, string>;
|
|
17
76
|
params?: Record<string, ParamValue>;
|
|
77
|
+
skipCookieTokenLookup?: boolean;
|
|
78
|
+
authToken?: string;
|
|
18
79
|
}
|
|
19
80
|
/**
|
|
20
81
|
* API client class for the CREX application.
|
|
@@ -24,6 +85,8 @@ declare class CrexApi {
|
|
|
24
85
|
private customerConfig;
|
|
25
86
|
private baseUrl;
|
|
26
87
|
private logger;
|
|
88
|
+
private debugTiming;
|
|
89
|
+
private resolveLogCategory;
|
|
27
90
|
/**
|
|
28
91
|
* Initializes the API client if it hasn't been initialized yet.
|
|
29
92
|
* Loads customer configuration and initializes the logger.
|
|
@@ -41,6 +104,7 @@ declare class CrexApi {
|
|
|
41
104
|
* @returns The full URL with query string
|
|
42
105
|
*/
|
|
43
106
|
private buildUrl;
|
|
107
|
+
private getApiRootUrl;
|
|
44
108
|
/**
|
|
45
109
|
* Executes an API request with caching, authentication, and retry logic.
|
|
46
110
|
*
|
|
@@ -53,7 +117,7 @@ declare class CrexApi {
|
|
|
53
117
|
* @returns The response data
|
|
54
118
|
* @throws Error if the request fails after maximum retries
|
|
55
119
|
*/
|
|
56
|
-
execute<T>({ url, method, params, body, headers, }: CallParams): Promise<T>;
|
|
120
|
+
execute<T>({ url, method, params, body, headers, skipCookieTokenLookup, authToken, }: CallParams): Promise<T>;
|
|
57
121
|
}
|
|
58
122
|
|
|
59
|
-
export { CrexApi };
|
|
123
|
+
export { CREX_API_CACHE_TAG, CREX_API_CACHE_VCARD_TAG, CREX_CACHE_SEGMENT_ALL, CREX_CACHE_SEGMENT_METADATA, CREX_CACHE_SEGMENT_REQUESTS, CREX_CACHE_SEGMENT_TO_TAGS, CREX_CACHE_SEGMENT_VCARD, CREX_READMODEL_CACHE_COMPONENTS_TAG, CREX_READMODEL_CACHE_DOCUMENT_TYPES_TAG, CREX_READMODEL_CACHE_INFORMATION_SUBJECTS_TAG, CREX_READMODEL_CACHE_METADATA_TAG, CREX_READMODEL_CACHE_ORGANIZATION_TAG, CREX_READMODEL_CACHE_PARTIES_TAG, CREX_READMODEL_CACHE_TAG, CREX_READMODEL_CACHE_VCARD_TAG, CacheClearAuthConfigurationError, CacheClearAuthUnauthorizedError, CrexApi, type CrexCacheSegment, clearProcessLocalRequestCaches, extractScopesFromJwtPayload, getSupportedCacheSegments, handleCacheClearPostRequest, resolveCacheTagsForSegments, verifyCacheClearBearerToken };
|