-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.interface.ts
More file actions
153 lines (140 loc) · 4.05 KB
/
api.interface.ts
File metadata and controls
153 lines (140 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Copyright The Linux Foundation and each contributor to LFX.
// SPDX-License-Identifier: MIT
/**
* Configuration options for API client initialization
* @description Settings for HTTP client behavior and retry logic
*/
export interface ApiClientConfig {
/** Request timeout in milliseconds */
timeout?: number;
/** Number of retry attempts for failed requests */
retryAttempts?: number;
/** Delay between retry attempts in milliseconds */
retryDelay?: number;
}
/**
* Standardized API response wrapper
* @description Generic response structure for all API endpoints
*/
export interface ApiResponse<T = unknown> {
/** Response payload data */
data: T;
/** HTTP status code */
status: number;
/** HTTP status text */
statusText: string;
/** Response headers as key-value pairs */
headers: Record<string, string>;
}
/**
* Microservice URL configuration
* @description Service endpoint URLs for different environments
*/
export interface MicroserviceUrls {
/** LFX V2 service base URL */
LFX_V2_SERVICE: string;
}
/**
* Individual item in query service responses
* @description Standardized structure for resource items
*/
export interface QueryServiceItem<T = unknown> {
/** Resource type identifier */
type: string;
/** Unique resource identifier */
id: string;
/** Resource data payload */
data: T;
}
/**
* Query service response wrapper
* @description Container for multiple resource items
*/
export interface QueryServiceResponse<T = unknown> {
/** Array of resource items */
resources: QueryServiceItem<T>[];
/** Page token for pagination (optional - not present on first/last page) */
page_token?: string;
}
/**
* Query service count endpoint response wrapper
* @description Container for query service count endpoint response
*/
export interface QueryServiceCountResponse {
/** The count of resources */
count: number;
/** Whether there are more resources to fetch - if set to true, the
* query scope needs to be narrowed down */
has_more: boolean;
}
/**
* ETag-enabled API response
* @description Response with cache control information
*/
export interface ETagResult<T> {
/** Response data */
data: T;
/** ETag header value for caching */
etag: string;
/** All response headers */
headers: Record<string, string>;
}
/**
* ETag-specific error information
* @description Errors related to cache control and optimistic concurrency
*/
export interface ETagError {
/** Specific error code for ETag operations */
code: 'NOT_FOUND' | 'ETAG_MISSING' | 'NETWORK_ERROR' | 'PRECONDITION_FAILED';
/** Human-readable error message */
message: string;
/** HTTP status code */
statusCode: number;
/** Optional response headers */
headers?: Record<string, string>;
}
export interface ValidationError {
field: string;
message: string;
code: string;
}
export interface PaginationInfo {
page: number;
limit: number;
total: number;
pages: number;
hasNext: boolean;
hasPrev: boolean;
}
/**
* Paginated response wrapper for offset-based pagination
* @description Generic response structure for API endpoints that use total/pageSize/offset pagination
*/
export interface OffsetPaginatedResponse<T> {
/** Array of response items */
data: T[];
/** Total number of records matching the query */
total: number;
/** Number of records per page */
pageSize: number;
/** Number of records skipped */
offset: number;
}
/**
* Paginated response wrapper for cursor-based pagination
* @description Generic response structure for API endpoints that support page_token pagination
*/
export interface PaginatedResponse<T> {
/** Array of response items */
data: T[];
/** Cursor token for fetching the next page (undefined when no more pages) */
page_token?: string;
}
/**
* Internal page result used for accumulating paginated data in reactive streams
* @description Extends PaginatedResponse with a reset flag for scan-based accumulation
*/
export interface PageResult<T> extends PaginatedResponse<T> {
/** When true, replaces accumulated data; when false, appends to it */
reset: boolean;
}