@abapify/adt-client 0.4.0 → 0.4.3
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/README.md +2 -0
- package/dist/index.d.mts +578 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1553 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -89,6 +89,8 @@ createAdtClient(config: AdtConnectionConfig): AdtClient
|
|
|
89
89
|
- `password` - SAP password
|
|
90
90
|
- `client` - SAP client (optional, e.g., `'100'`)
|
|
91
91
|
- `language` - SAP language (optional, e.g., `'EN'`)
|
|
92
|
+
- `headersTimeoutMs` - response-header timeout for long-running SAP requests
|
|
93
|
+
(optional; otherwise the native HTTP client default applies)
|
|
92
94
|
|
|
93
95
|
### Class Operations
|
|
94
96
|
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
import { exception } from "@abapify/adt-schemas";
|
|
2
|
+
import { AdtClientType, AdtContract, ClassResponse, CrudContract, CrudContractBase, CrudQueryParams, DataElementResponse, DomainResponse, FunctionGroupResponse, FunctionModuleResponse, HttpAdapter, HttpAdapter as HttpAdapter$1, IncludeResponse, IncludesContractSkeleton, InterfaceResponse, LockOptions, ObjectStructureOptions, Package as PackageResponse, ProgramResponse, RestContract, RestEndpointDescriptor, Serializable, SourceOperations, SourcesContract, StructureResponse, TableResponse, TableTypeResponse, TransportResponse as TransportGetResponse, UnlockOptions, adtContract } from "@abapify/adt-contracts";
|
|
3
|
+
import { Logger, Logger as Logger$1 } from "@abapify/logger";
|
|
4
|
+
//#region src/errors.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Parsed ADT exception structure - derived from ExceptionSchema
|
|
7
|
+
*/
|
|
8
|
+
interface AdtExceptionData {
|
|
9
|
+
/** Exception namespace ID (e.g., "com.sap.adt.oo") */
|
|
10
|
+
namespace?: string;
|
|
11
|
+
/** Exception type ID (e.g., "OBJECT_NOT_FOUND") */
|
|
12
|
+
type?: string;
|
|
13
|
+
/** Human-readable error message */
|
|
14
|
+
message?: string;
|
|
15
|
+
/** Localized error message */
|
|
16
|
+
localizedMessage?: string;
|
|
17
|
+
/** Additional properties as key-value pairs */
|
|
18
|
+
properties?: Record<string, string>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Custom error class for ADT exceptions
|
|
22
|
+
*
|
|
23
|
+
* Provides structured access to SAP ADT error details.
|
|
24
|
+
*/
|
|
25
|
+
declare class AdtError extends Error {
|
|
26
|
+
/** HTTP status code */
|
|
27
|
+
readonly status: number;
|
|
28
|
+
/** HTTP status text */
|
|
29
|
+
readonly statusText: string;
|
|
30
|
+
/** Parsed ADT exception data (if available) */
|
|
31
|
+
readonly exception?: AdtExceptionData;
|
|
32
|
+
/** Raw response body */
|
|
33
|
+
readonly rawBody: string;
|
|
34
|
+
/** Request URL */
|
|
35
|
+
readonly url: string;
|
|
36
|
+
/** HTTP method */
|
|
37
|
+
readonly method: string;
|
|
38
|
+
constructor(options: {
|
|
39
|
+
status: number;
|
|
40
|
+
statusText: string;
|
|
41
|
+
url: string;
|
|
42
|
+
method: string;
|
|
43
|
+
rawBody: string;
|
|
44
|
+
exception?: AdtExceptionData;
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Get the most relevant error message
|
|
48
|
+
*/
|
|
49
|
+
get detailMessage(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Check if this is a specific error type
|
|
52
|
+
*/
|
|
53
|
+
isType(type: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Check if this is from a specific namespace
|
|
56
|
+
*/
|
|
57
|
+
isNamespace(namespace: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Get a property value from the exception
|
|
60
|
+
*/
|
|
61
|
+
getProperty(key: string): string | undefined;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/types.d.ts
|
|
65
|
+
interface AdtConnectionConfig {
|
|
66
|
+
baseUrl: string;
|
|
67
|
+
username?: string;
|
|
68
|
+
password?: string;
|
|
69
|
+
cookieHeader?: string;
|
|
70
|
+
authorizationHeader?: string;
|
|
71
|
+
client?: string;
|
|
72
|
+
language?: string;
|
|
73
|
+
logger?: Logger$1;
|
|
74
|
+
/** Override Undici's response-header timeout for long-running SAP requests. */
|
|
75
|
+
headersTimeoutMs?: number;
|
|
76
|
+
}
|
|
77
|
+
interface LockHandle {
|
|
78
|
+
lockHandle: string;
|
|
79
|
+
objectUri: string;
|
|
80
|
+
}
|
|
81
|
+
interface OperationResult {
|
|
82
|
+
success: boolean;
|
|
83
|
+
message?: string;
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/plugins/types.d.ts
|
|
87
|
+
/**
|
|
88
|
+
* Plugin Types - Core interfaces for the response plugin system
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* Response context passed to plugins
|
|
92
|
+
*/
|
|
93
|
+
interface ResponseContext {
|
|
94
|
+
/** Raw response text (XML) */
|
|
95
|
+
rawText: string;
|
|
96
|
+
/** Parsed response object (if schema available) */
|
|
97
|
+
parsedData?: unknown;
|
|
98
|
+
/** Request URL */
|
|
99
|
+
url: string;
|
|
100
|
+
/** Request method */
|
|
101
|
+
method: string;
|
|
102
|
+
/** Response content type */
|
|
103
|
+
contentType: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Response plugin interface
|
|
107
|
+
*/
|
|
108
|
+
interface ResponsePlugin {
|
|
109
|
+
/**
|
|
110
|
+
* Plugin name for identification
|
|
111
|
+
*/
|
|
112
|
+
name: string;
|
|
113
|
+
/**
|
|
114
|
+
* Process response before returning to caller
|
|
115
|
+
* Can store files, transform data, log, etc.
|
|
116
|
+
*
|
|
117
|
+
* @param context - Response context with raw and parsed data
|
|
118
|
+
* @returns Modified data or original data
|
|
119
|
+
*/
|
|
120
|
+
process(context: ResponseContext): Promise<unknown> | unknown;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/adapter.d.ts
|
|
124
|
+
/**
|
|
125
|
+
* Extended ADT connection config with plugins
|
|
126
|
+
*/
|
|
127
|
+
interface AdtAdapterConfig extends AdtConnectionConfig {
|
|
128
|
+
/** Response plugins for intercepting and transforming responses */
|
|
129
|
+
plugins?: ResponsePlugin[];
|
|
130
|
+
/**
|
|
131
|
+
* Callback when session expires (SAML redirect detected)
|
|
132
|
+
* Return new cookie header to retry the request, or throw to abort
|
|
133
|
+
*/
|
|
134
|
+
onSessionExpired?: () => Promise<string>;
|
|
135
|
+
}
|
|
136
|
+
/** Options for an authenticated GET that returns plain text. */
|
|
137
|
+
interface BoundedTextRequestOptions {
|
|
138
|
+
url: string;
|
|
139
|
+
headers?: Record<string, string>;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A response exceeded an explicit byte cap before its body was retained.
|
|
143
|
+
* Deliberately carries size metadata only, never response text.
|
|
144
|
+
*/
|
|
145
|
+
declare class AdtResponseTooLargeError extends Error {
|
|
146
|
+
readonly maxBytes: number;
|
|
147
|
+
readonly receivedBytes?: number | undefined;
|
|
148
|
+
readonly code: "ADT_RESPONSE_TOO_LARGE";
|
|
149
|
+
constructor(maxBytes: number, receivedBytes?: number | undefined);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Create ADT HTTP adapter with Basic or SAML Authentication and plugin support
|
|
153
|
+
*/
|
|
154
|
+
/** Extended adapter with ETag management */
|
|
155
|
+
interface AdtHttpAdapter extends HttpAdapter$1 {
|
|
156
|
+
/** Clear cached ETag for a specific URL, or all ETags if no URL given */
|
|
157
|
+
clearETag(url?: string): void;
|
|
158
|
+
/** Read an authenticated plain-text response without exceeding maxBytes. */
|
|
159
|
+
readTextBounded(options: BoundedTextRequestOptions, maxBytes: number): Promise<string>;
|
|
160
|
+
}
|
|
161
|
+
declare function createAdtAdapter(config: AdtAdapterConfig): AdtHttpAdapter;
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/services/transports.d.ts
|
|
164
|
+
/**
|
|
165
|
+
* Transport data structure (simplified for service consumers)
|
|
166
|
+
*/
|
|
167
|
+
interface Transport {
|
|
168
|
+
number: string;
|
|
169
|
+
desc?: string;
|
|
170
|
+
owner?: string;
|
|
171
|
+
status?: string;
|
|
172
|
+
type?: string;
|
|
173
|
+
target?: string;
|
|
174
|
+
parent?: string;
|
|
175
|
+
lastChangedTimestamp?: string;
|
|
176
|
+
tasks?: TransportTask[];
|
|
177
|
+
}
|
|
178
|
+
interface TransportTask {
|
|
179
|
+
number: string;
|
|
180
|
+
desc?: string;
|
|
181
|
+
owner?: string;
|
|
182
|
+
status?: string;
|
|
183
|
+
type?: string;
|
|
184
|
+
parent?: string;
|
|
185
|
+
lastChangedTimestamp?: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Options for creating a transport
|
|
189
|
+
*/
|
|
190
|
+
interface CreateTransportOptions {
|
|
191
|
+
description: string;
|
|
192
|
+
type?: 'K' | 'W';
|
|
193
|
+
target?: string;
|
|
194
|
+
project?: string;
|
|
195
|
+
owner?: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Options for listing transports
|
|
199
|
+
*/
|
|
200
|
+
interface ListTransportsOptions {
|
|
201
|
+
targets?: string;
|
|
202
|
+
configUri?: string;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Transport Service - orchestrates CTS operations
|
|
206
|
+
*/
|
|
207
|
+
declare class TransportService {
|
|
208
|
+
private readonly adt;
|
|
209
|
+
constructor(adt: AdtClientType);
|
|
210
|
+
/**
|
|
211
|
+
* List transport requests
|
|
212
|
+
*/
|
|
213
|
+
list(options?: ListTransportsOptions): Promise<Transport[]>;
|
|
214
|
+
/**
|
|
215
|
+
* Get a single transport by number
|
|
216
|
+
*/
|
|
217
|
+
get(trkorr: string): Promise<Transport>;
|
|
218
|
+
/**
|
|
219
|
+
* Create a new transport request
|
|
220
|
+
*
|
|
221
|
+
* Note: Full create implementation requires XML body building.
|
|
222
|
+
* For now, this is a placeholder that throws a helpful error.
|
|
223
|
+
* Use ADK's AdkTransportRequest.create() for full functionality.
|
|
224
|
+
*/
|
|
225
|
+
create(_options: CreateTransportOptions): Promise<Transport>;
|
|
226
|
+
/**
|
|
227
|
+
* Delete a transport request
|
|
228
|
+
*/
|
|
229
|
+
delete(trkorr: string): Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Release a transport request
|
|
232
|
+
*
|
|
233
|
+
* Note: Release requires POST with specific action parameter.
|
|
234
|
+
* This is a placeholder for the full implementation.
|
|
235
|
+
*/
|
|
236
|
+
release(_trkorr: string): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Find a request/task unit whose number matches the wanted transport id.
|
|
239
|
+
* Handles both single-object and array shapes from ts-xsd.
|
|
240
|
+
*/
|
|
241
|
+
private findUnit;
|
|
242
|
+
/**
|
|
243
|
+
* Extract requests array from various response formats
|
|
244
|
+
*/
|
|
245
|
+
private extractRequests;
|
|
246
|
+
/**
|
|
247
|
+
* Map raw request data to Transport interface
|
|
248
|
+
*/
|
|
249
|
+
private mapToTransport;
|
|
250
|
+
/**
|
|
251
|
+
* Extract tasks from transport data
|
|
252
|
+
*/
|
|
253
|
+
private extractTasks;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Create transport service instance
|
|
257
|
+
*/
|
|
258
|
+
declare function createTransportService(adt: AdtClientType): TransportService;
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/services/users.d.ts
|
|
261
|
+
/** Normalized user info from Atom feed entries */
|
|
262
|
+
interface UserInfo {
|
|
263
|
+
username: string;
|
|
264
|
+
fullName?: string;
|
|
265
|
+
uri?: string;
|
|
266
|
+
}
|
|
267
|
+
/** Current authenticated user info from systeminformation */
|
|
268
|
+
interface CurrentUserInfo {
|
|
269
|
+
userName: string;
|
|
270
|
+
userFullName?: string;
|
|
271
|
+
systemID: string;
|
|
272
|
+
client: string;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* User Service - orchestrates user lookup operations
|
|
276
|
+
*/
|
|
277
|
+
declare class UserService {
|
|
278
|
+
private readonly adt;
|
|
279
|
+
constructor(adt: AdtClientType);
|
|
280
|
+
/** Get the currently authenticated user via systeminformation */
|
|
281
|
+
getCurrentUser(): Promise<CurrentUserInfo>;
|
|
282
|
+
/** Look up a specific user by exact username */
|
|
283
|
+
getUserByName(username: string): Promise<UserInfo[]>;
|
|
284
|
+
/** Search users by wildcard query */
|
|
285
|
+
searchUsers(query: string, maxcount?: number): Promise<UserInfo[]>;
|
|
286
|
+
}
|
|
287
|
+
declare function createUserService(adt: AdtClientType): UserService;
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/services/source-history.d.ts
|
|
290
|
+
type SourceHistoryProtocolErrorCode = 'SOURCE_HISTORY_URI_UNSAFE' | 'SOURCE_VERSION_FEED_INVALID' | 'SOURCE_VERSION_ID_MISSING' | 'SOURCE_VERSION_CONTENT_LINK_MISSING';
|
|
291
|
+
declare class SourceHistoryProtocolError extends Error {
|
|
292
|
+
readonly code: SourceHistoryProtocolErrorCode;
|
|
293
|
+
readonly ordinal?: number | undefined;
|
|
294
|
+
constructor(code: SourceHistoryProtocolErrorCode, message: string, ordinal?: number | undefined);
|
|
295
|
+
}
|
|
296
|
+
interface SourceVersionRef {
|
|
297
|
+
id: string;
|
|
298
|
+
ordinal: number;
|
|
299
|
+
title?: string;
|
|
300
|
+
sourceUri: string;
|
|
301
|
+
contentType?: string;
|
|
302
|
+
etag?: string;
|
|
303
|
+
updatedAt?: string;
|
|
304
|
+
author?: string;
|
|
305
|
+
transports: string[];
|
|
306
|
+
}
|
|
307
|
+
type SourceVersionReference = SourceVersionRef;
|
|
308
|
+
type BoundedSourceReader = (sourceUri: string, maxBytes: number) => Promise<string>;
|
|
309
|
+
/**
|
|
310
|
+
* An immutable source body crossed its configured byte limit.
|
|
311
|
+
* This error intentionally does not retain the source URI or any source text.
|
|
312
|
+
*/
|
|
313
|
+
declare class SourceVersionTooLargeError extends Error {
|
|
314
|
+
readonly maxBytes: number;
|
|
315
|
+
readonly receivedBytes?: number | undefined;
|
|
316
|
+
readonly code: "SOURCE_VERSION_TOO_LARGE";
|
|
317
|
+
constructor(maxBytes: number, receivedBytes?: number | undefined);
|
|
318
|
+
}
|
|
319
|
+
declare function assertAdtUri(uri: string): string;
|
|
320
|
+
declare function normalizeSourceVersionFeed(payload: unknown, versionsUri: string): SourceVersionRef[];
|
|
321
|
+
declare class SourceHistoryService {
|
|
322
|
+
private readonly adt;
|
|
323
|
+
private readonly boundedSourceReader?;
|
|
324
|
+
constructor(adt: AdtClientType, boundedSourceReader?: BoundedSourceReader | undefined);
|
|
325
|
+
listVersions(versionsUri: string): Promise<SourceVersionRef[]>;
|
|
326
|
+
readVersionSource(sourceUri: string): Promise<string>;
|
|
327
|
+
readVersionSourceBounded(sourceUri: string, maxBytes: number): Promise<string>;
|
|
328
|
+
}
|
|
329
|
+
declare function createSourceHistoryService(adt: AdtClientType, boundedSourceReader?: BoundedSourceReader): SourceHistoryService;
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/client.d.ts
|
|
332
|
+
/**
|
|
333
|
+
* Fetch options for generic HTTP requests
|
|
334
|
+
*/
|
|
335
|
+
interface FetchOptions {
|
|
336
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
337
|
+
headers?: Record<string, string>;
|
|
338
|
+
body?: string;
|
|
339
|
+
}
|
|
340
|
+
/** Options for a bounded authenticated GET that returns plain text. */
|
|
341
|
+
interface BoundedTextFetchOptions {
|
|
342
|
+
headers?: Record<string, string>;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Services layer - business logic orchestration
|
|
346
|
+
*/
|
|
347
|
+
interface AdtServices {
|
|
348
|
+
transports: TransportService;
|
|
349
|
+
sourceHistory: SourceHistoryService;
|
|
350
|
+
}
|
|
351
|
+
interface AdtClientReturn {
|
|
352
|
+
adt: AdtClientType;
|
|
353
|
+
services: AdtServices;
|
|
354
|
+
fetch: (url: string, options?: FetchOptions) => Promise<unknown>;
|
|
355
|
+
readTextBounded: (url: string, maxBytes: number, options?: BoundedTextFetchOptions) => Promise<string>;
|
|
356
|
+
/** Clear cached ETag for a specific URL, or all ETags if no URL given */
|
|
357
|
+
clearETag: (url?: string) => void;
|
|
358
|
+
}
|
|
359
|
+
declare function createAdtClient(config: AdtAdapterConfig): AdtClientReturn;
|
|
360
|
+
type AdtClient = ReturnType<typeof createAdtClient>;
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/cancellation.d.ts
|
|
363
|
+
/**
|
|
364
|
+
* Runs an ADT operation with an execution-scoped abort signal. Async local
|
|
365
|
+
* storage keeps concurrent clients and invocations isolated without mutating
|
|
366
|
+
* shared client state.
|
|
367
|
+
*/
|
|
368
|
+
declare function runWithAdtAbortSignal<T>(signal: AbortSignal, operation: () => Promise<T>): Promise<T>;
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/plugins/logging.d.ts
|
|
371
|
+
type LogFunction = (message: string, data?: any) => void;
|
|
372
|
+
/**
|
|
373
|
+
* Logging plugin - logs requests and responses
|
|
374
|
+
*/
|
|
375
|
+
declare class LoggingPlugin implements ResponsePlugin {
|
|
376
|
+
private readonly logger;
|
|
377
|
+
name: string;
|
|
378
|
+
constructor(logger?: LogFunction);
|
|
379
|
+
process(context: ResponseContext): unknown;
|
|
380
|
+
}
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/plugins/file-logging.d.ts
|
|
383
|
+
interface FileLoggingConfig {
|
|
384
|
+
outputDir: string;
|
|
385
|
+
writeMetadata?: boolean;
|
|
386
|
+
logger?: Logger$1;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Plugin that logs HTTP responses to files
|
|
390
|
+
* Similar to v1's FileLogger functionality
|
|
391
|
+
*/
|
|
392
|
+
declare class FileLoggingPlugin implements ResponsePlugin {
|
|
393
|
+
private readonly config;
|
|
394
|
+
name: string;
|
|
395
|
+
constructor(config: FileLoggingConfig);
|
|
396
|
+
process(context: ResponseContext): unknown;
|
|
397
|
+
/**
|
|
398
|
+
* Generate file path for HTTP response
|
|
399
|
+
* Converts URL to fixture-style path structure
|
|
400
|
+
*/
|
|
401
|
+
private generateFilePath;
|
|
402
|
+
/**
|
|
403
|
+
* Get metadata file path for a response file
|
|
404
|
+
*/
|
|
405
|
+
private getMetadataPath;
|
|
406
|
+
}
|
|
407
|
+
//#endregion
|
|
408
|
+
//#region src/utils/session.d.ts
|
|
409
|
+
/**
|
|
410
|
+
* Fetch function injected into SessionManager so the adapter can route
|
|
411
|
+
* CSRF handshake requests through the same Undici dispatcher (and
|
|
412
|
+
* headersTimeout) used for the final adapter request. Defaults to the
|
|
413
|
+
* global fetch when no dispatcher is configured.
|
|
414
|
+
*/
|
|
415
|
+
type SessionFetchFn = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
416
|
+
/**
|
|
417
|
+
* Cookie Store - Manages HTTP cookies for stateful sessions
|
|
418
|
+
*/
|
|
419
|
+
declare class CookieStore {
|
|
420
|
+
private readonly cookies;
|
|
421
|
+
/**
|
|
422
|
+
* Parse Set-Cookie header and store cookies
|
|
423
|
+
* Handles complex cookie strings with expires dates
|
|
424
|
+
*/
|
|
425
|
+
parseCookies(setCookieHeader: string): void;
|
|
426
|
+
/**
|
|
427
|
+
* Split Set-Cookie header by commas, avoiding splitting on expires dates
|
|
428
|
+
*/
|
|
429
|
+
private splitCookieHeader;
|
|
430
|
+
/**
|
|
431
|
+
* Get Cookie header value for requests
|
|
432
|
+
*/
|
|
433
|
+
getCookieHeader(): string | undefined;
|
|
434
|
+
/**
|
|
435
|
+
* Check if we have any cookies
|
|
436
|
+
*/
|
|
437
|
+
hasCookies(): boolean;
|
|
438
|
+
/**
|
|
439
|
+
* Clear all cookies
|
|
440
|
+
*/
|
|
441
|
+
clear(): void;
|
|
442
|
+
/**
|
|
443
|
+
* Get all cookies as a map (for testing/debugging)
|
|
444
|
+
*/
|
|
445
|
+
getAll(): Map<string, string>;
|
|
446
|
+
/**
|
|
447
|
+
* Inject pre-existing cookies (e.g., from SAML authentication)
|
|
448
|
+
* @param cookieString Cookie string in "name=value; name2=value2" format
|
|
449
|
+
*/
|
|
450
|
+
injectCookie(cookieString: string): void;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* CSRF Token Manager - Handles CSRF token caching and initialization
|
|
454
|
+
*/
|
|
455
|
+
declare class CsrfTokenManager {
|
|
456
|
+
private cachedToken?;
|
|
457
|
+
/**
|
|
458
|
+
* Extract CSRF token from cookies (SAP stores it there)
|
|
459
|
+
*/
|
|
460
|
+
extractFromCookies(cookies: Map<string, string>): string | undefined;
|
|
461
|
+
/**
|
|
462
|
+
* Extract CSRF token from response header
|
|
463
|
+
*/
|
|
464
|
+
extractFromHeader(headerValue: string | null): string | undefined;
|
|
465
|
+
/**
|
|
466
|
+
* Cache a CSRF token
|
|
467
|
+
*/
|
|
468
|
+
cache(token: string): void;
|
|
469
|
+
/**
|
|
470
|
+
* Get cached CSRF token
|
|
471
|
+
*/
|
|
472
|
+
getCached(): string | undefined;
|
|
473
|
+
/**
|
|
474
|
+
* Clear cached CSRF token (e.g., on 403 errors)
|
|
475
|
+
*/
|
|
476
|
+
clear(): void;
|
|
477
|
+
/**
|
|
478
|
+
* Check if we have a cached token
|
|
479
|
+
*/
|
|
480
|
+
hasCached(): boolean;
|
|
481
|
+
/**
|
|
482
|
+
* Alias for hasCached() - for consistency with SessionManager API
|
|
483
|
+
*/
|
|
484
|
+
hasToken(): boolean;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Session Manager - Orchestrates cookies and CSRF tokens
|
|
488
|
+
*/
|
|
489
|
+
declare class SessionManager {
|
|
490
|
+
private readonly logger?;
|
|
491
|
+
private readonly fetchFn;
|
|
492
|
+
private static readonly SESSION_PATH_PREFIX;
|
|
493
|
+
private readonly cookieStore;
|
|
494
|
+
private readonly csrfManager;
|
|
495
|
+
private readonly etagManager;
|
|
496
|
+
private securitySessionActive;
|
|
497
|
+
constructor(logger?: Logger$1 | undefined, fetchFn?: SessionFetchFn);
|
|
498
|
+
/**
|
|
499
|
+
* Process response to update session state
|
|
500
|
+
* Extracts cookies, CSRF tokens, and ETags
|
|
501
|
+
* @param response The HTTP response
|
|
502
|
+
* @param url Optional URL for ETag caching (required for ETag tracking)
|
|
503
|
+
*/
|
|
504
|
+
processResponse(response: Response, url?: string): void;
|
|
505
|
+
/**
|
|
506
|
+
* Get headers for next request
|
|
507
|
+
* @param method HTTP method
|
|
508
|
+
* @param url Optional URL for ETag lookup (for PUT/PATCH with optimistic locking)
|
|
509
|
+
*/
|
|
510
|
+
getRequestHeaders(method: string, url?: string): Record<string, string>;
|
|
511
|
+
/**
|
|
512
|
+
* Get cached ETag for a URL
|
|
513
|
+
*/
|
|
514
|
+
getETag(url: string): string | undefined;
|
|
515
|
+
/**
|
|
516
|
+
* Clear cached ETag for a URL
|
|
517
|
+
*/
|
|
518
|
+
clearETag(url?: string): void;
|
|
519
|
+
/**
|
|
520
|
+
* Reject session paths that could send cleanup requests off-target.
|
|
521
|
+
* Only relative paths under the ADT sessions endpoint (or same-origin
|
|
522
|
+
* absolute URLs with that path) are accepted.
|
|
523
|
+
*/
|
|
524
|
+
private isTrustedSessionPath;
|
|
525
|
+
private extractTrustedSessionPath;
|
|
526
|
+
/**
|
|
527
|
+
* Initialize CSRF token using the Eclipse ADT security session flow:
|
|
528
|
+
*
|
|
529
|
+
* 1. GET /sessions + x-sap-security-session: create → create security session
|
|
530
|
+
* 2. GET /sessions + x-sap-security-session: use + x-csrf-token: Fetch → get CSRF token
|
|
531
|
+
* 3. DELETE /sessions/<id> + x-sap-security-session: use + x-csrf-token → destroy session
|
|
532
|
+
*
|
|
533
|
+
* The CSRF token survives the session deletion and remains valid for
|
|
534
|
+
* all subsequent lock/unlock operations. Deleting the session frees
|
|
535
|
+
* the slot — SAP allows only one security session per user.
|
|
536
|
+
*/
|
|
537
|
+
private resolveInitializeCsrfArgs;
|
|
538
|
+
initializeCsrf(baseUrl: string, authHeader?: string, client?: string, language?: string, signal?: AbortSignal): Promise<boolean>;
|
|
539
|
+
initializeCsrf(baseUrl: string, options?: {
|
|
540
|
+
authHeader?: string;
|
|
541
|
+
client?: string;
|
|
542
|
+
language?: string;
|
|
543
|
+
signal?: AbortSignal;
|
|
544
|
+
}): Promise<boolean>;
|
|
545
|
+
private buildSessionsUrl;
|
|
546
|
+
private buildSessionHeaders;
|
|
547
|
+
private createSecuritySession;
|
|
548
|
+
private acquireCsrfToken;
|
|
549
|
+
private deleteSecuritySession;
|
|
550
|
+
private fetchSecuritySessionCsrfToken;
|
|
551
|
+
private deleteSecuritySessionWithFallback;
|
|
552
|
+
private handleCsrfInitializationError;
|
|
553
|
+
/**
|
|
554
|
+
* Clear all session state (cookies and CSRF)
|
|
555
|
+
*/
|
|
556
|
+
clear(): void;
|
|
557
|
+
/**
|
|
558
|
+
* Check if we have a cached CSRF token
|
|
559
|
+
*/
|
|
560
|
+
hasCsrfToken(): boolean;
|
|
561
|
+
/**
|
|
562
|
+
* Get Cookie header value for requests
|
|
563
|
+
*/
|
|
564
|
+
getCookieHeader(): string | undefined;
|
|
565
|
+
/**
|
|
566
|
+
* Get session type header value
|
|
567
|
+
* SAP ADT requires 'stateful' for operations that need session persistence
|
|
568
|
+
*/
|
|
569
|
+
getSessionTypeHeader(): string;
|
|
570
|
+
/**
|
|
571
|
+
* Inject a pre-existing cookie (e.g., from SAML authentication)
|
|
572
|
+
* @param cookieString Cookie string in "name=value" format
|
|
573
|
+
*/
|
|
574
|
+
injectCookie(cookieString: string): void;
|
|
575
|
+
}
|
|
576
|
+
//#endregion
|
|
577
|
+
export { type AdtAdapterConfig, type AdtClient, type AdtConnectionConfig, type AdtContract, type AdtError, type AdtHttpAdapter, AdtResponseTooLargeError, type BoundedSourceReader, type BoundedTextFetchOptions, type BoundedTextRequestOptions, type ClassResponse, CookieStore, type CreateTransportOptions, type CrudContract, type CrudContractBase, type CrudQueryParams, CsrfTokenManager, type CurrentUserInfo, type DataElementResponse, type DomainResponse, type FileLoggingConfig, FileLoggingPlugin, type FunctionGroupResponse, type FunctionModuleResponse, type HttpAdapter, type IncludeResponse, type IncludesContractSkeleton, type InterfaceResponse, type ListTransportsOptions, type LockHandle, type LockOptions, type LogFunction, type Logger, LoggingPlugin, type ObjectStructureOptions, type OperationResult, type PackageResponse, type ProgramResponse, type ResponseContext, type ResponsePlugin, type RestContract, type RestEndpointDescriptor, type Serializable, SessionManager, SourceHistoryProtocolError, type SourceHistoryProtocolErrorCode, SourceHistoryService, type SourceOperations, type SourceVersionRef, type SourceVersionReference, SourceVersionTooLargeError, type SourcesContract, type StructureResponse, type TableResponse, type TableTypeResponse, type Transport, type TransportGetResponse, TransportService, type TransportTask, type UnlockOptions, type UserInfo, UserService, adtContract, assertAdtUri, createAdtAdapter, createAdtClient, createSourceHistoryService, createTransportService, createUserService, normalizeSourceVersionFeed, runWithAdtAbortSignal };
|
|
578
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/errors.ts","../src/types.ts","../src/plugins/types.ts","../src/adapter.ts","../src/services/transports.ts","../src/services/users.ts","../src/services/source-history.ts","../src/client.ts","../src/cancellation.ts","../src/plugins/logging.ts","../src/plugins/file-logging.ts","../src/utils/session.ts"],"mappings":";;;;;;;UA4BiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA,aAAa;;;;;;;cAWF,iBAAiB;;WAEnB;;WAEA;;WAEA,YAAY;;WAEZ;;WAEA;;WAEA;EAEG,YAAA;IACV;IACA;IACA;IACA;IACA;IACA,YAAY;;;;;MA0BV;;;;EAWJ,OAAO;;;;EAOP,YAAY;;;;EAOZ,YAAY;;;;UChHG;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;EAET;;UAYe;EACf;EACA;;UAI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