@caitlyn-ai/sdk-core 0.0.1 → 0.1.0

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,12 +1,3169 @@
1
- export { CaitlynRestJsonProtocol, type WithRaw } from './protocol.js';
2
- export { getCaitlynSdkPlugin, NotSupportedByServer, CAITLYN_SDK_USER_AGENT_PREFIX } from './plugin.js';
3
- export { CaitlynRetryStrategy, NO_RETRY } from './retry.js';
4
- export { caitlynEndpointProvider } from './endpoint.js';
5
- export { getCaitlynTelemetryPlugin } from './telemetry.js';
6
- export { SseStream, type SseSpec } from './stream.js';
7
- export { parseSse, type SseMessage } from './sse.js';
8
- export { uploadFile, type UploadMeta, type UploadSlot } from './upload.js';
9
- export { clientConfig, createAuth, workspaceEndpoint, type CaitlynOptions, type CallOptions, type CaitlynErrorFields, type CaitlynFieldError } from './client.js';
10
- export { AuthSession, CaitlynAuthError, workspaceAudience, workspaceHost, getCaitlynAuthPlugin, tokenIdentityProvider, type AuthOptions, type OAuthTokens, type TokenStore } from './auth.js';
11
- export { signV4, getWebIdentityToken, defaultAwsCredentials, type AwsCredentials, type AwsCredentialSource } from './aws.js';
12
- export { waitUntil, WaiterError, type WaiterOptions, type WaiterState } from './waiter.js';
1
+ /** Stand-in for node:http's Agent, so these types need no @types/node. */
2
+ interface Agent {}
3
+ /** Stand-in for node:http's AgentOptions, so these types need no @types/node. */
4
+ interface AgentOptions {}
5
+ /** Stand-in for node:https's Agent, so these types need no @types/node. */
6
+ interface Agent$1 {}
7
+ /** Stand-in for node:https's AgentOptions, so these types need no @types/node. */
8
+ interface AgentOptions$1 {}
9
+ import * as _opentelemetry_api from '@opentelemetry/api';
10
+ import { TracerProvider, Tracer } from '@opentelemetry/api';
11
+
12
+ /**
13
+ * @public
14
+ */
15
+ interface AbortHandler {
16
+ (this: AbortSignal | AbortSignal$1, ev: any): any;
17
+ }
18
+
19
+ /**
20
+ * Holders of an AbortSignal object may query if the associated operation has
21
+ * been aborted and register an onabort handler.
22
+ *
23
+ * @public
24
+ * @deprecated use platform (global) type for AbortSignal.
25
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
26
+ */
27
+ interface AbortSignal$1 {
28
+ /**
29
+ * Whether the action represented by this signal has been cancelled.
30
+ */
31
+ readonly aborted: boolean;
32
+ /**
33
+ * A function to be invoked when the action represented by this signal has
34
+ * been cancelled.
35
+ */
36
+ onabort: AbortHandler | Function | null;
37
+ }
38
+
39
+ /**
40
+ * Authentication schemes represent a way that the service will authenticate the customer’s identity.
41
+ *
42
+ * @internal
43
+ */
44
+ interface AuthScheme {
45
+ /**
46
+ * @example "sigv4a" or "sigv4"
47
+ */
48
+ name: "sigv4" | "sigv4a" | string;
49
+ /**
50
+ * @example "s3"
51
+ */
52
+ signingName: string;
53
+ /**
54
+ * @example "us-east-1"
55
+ */
56
+ signingRegion: string;
57
+ /**
58
+ * @example ["*"]
59
+ * @example ["us-west-2", "us-east-1"]
60
+ */
61
+ signingRegionSet?: string[];
62
+ /**
63
+ * @deprecated this field was renamed to signingRegion.
64
+ */
65
+ signingScope?: never;
66
+ properties: Record<string, unknown>;
67
+ }
68
+ /**
69
+ * @deprecated
70
+ *
71
+ * @internal
72
+ */
73
+ interface HttpAuthDefinition {
74
+ /**
75
+ * Defines the location of where the Auth is serialized.
76
+ */
77
+ in: HttpAuthLocation;
78
+ /**
79
+ * Defines the name of the HTTP header or query string parameter
80
+ * that contains the Auth.
81
+ */
82
+ name: string;
83
+ /**
84
+ * Defines the security scheme to use on the `Authorization` header value.
85
+ * This can only be set if the "in" property is set to {@link HttpAuthLocation.HEADER}.
86
+ */
87
+ scheme?: string;
88
+ }
89
+ /**
90
+ * @deprecated
91
+ *
92
+ * @internal
93
+ */
94
+ declare enum HttpAuthLocation {
95
+ HEADER = "header",
96
+ QUERY = "query"
97
+ }
98
+
99
+ /**
100
+ * @public
101
+ */
102
+ interface Identity {
103
+ /**
104
+ * A `Date` when the identity or credential will no longer be accepted.
105
+ */
106
+ readonly expiration?: Date;
107
+ }
108
+
109
+ /**
110
+ * @public
111
+ */
112
+ interface ResponseMetadata {
113
+ /**
114
+ * The status code of the last HTTP response received for this operation.
115
+ */
116
+ httpStatusCode?: number;
117
+ /**
118
+ * A unique identifier for the last request sent for this operation. Often
119
+ * requested by AWS service teams to aid in debugging.
120
+ */
121
+ requestId?: string;
122
+ /**
123
+ * A secondary identifier for the last request sent. Used for debugging.
124
+ */
125
+ extendedRequestId?: string;
126
+ /**
127
+ * A tertiary identifier for the last request sent. Used for debugging.
128
+ */
129
+ cfId?: string;
130
+ /**
131
+ * The number of times this operation was attempted.
132
+ */
133
+ attempts?: number;
134
+ /**
135
+ * The total amount of time (in milliseconds) that was spent waiting between
136
+ * retry attempts.
137
+ */
138
+ totalRetryDelay?: number;
139
+ }
140
+ /**
141
+ * @public
142
+ */
143
+ interface MetadataBearer {
144
+ /**
145
+ * Metadata pertaining to this request.
146
+ */
147
+ $metadata: ResponseMetadata;
148
+ }
149
+
150
+ /**
151
+ * @public
152
+ */
153
+ interface Command<ClientInput extends object, InputType extends ClientInput, ClientOutput extends MetadataBearer, OutputType extends ClientOutput, ResolvedConfiguration> extends CommandIO<InputType, OutputType> {
154
+ readonly input: InputType;
155
+ readonly middlewareStack: MiddlewareStack<InputType, OutputType>;
156
+ /**
157
+ * This should be OperationSchema from @smithy/types, but would
158
+ * create problems with the client transform type adaptors.
159
+ */
160
+ readonly schema?: any;
161
+ resolveMiddleware(stack: MiddlewareStack<ClientInput, ClientOutput>, configuration: ResolvedConfiguration, options: any): Handler<InputType, OutputType>;
162
+ }
163
+ /**
164
+ * This is a subset of the Command type used only to detect the i/o types.
165
+ *
166
+ * @internal
167
+ */
168
+ interface CommandIO<InputType extends object, OutputType extends MetadataBearer> {
169
+ readonly input: InputType;
170
+ resolveMiddleware(stack: any, configuration: any, options: any): Handler<InputType, OutputType>;
171
+ }
172
+
173
+ /**
174
+ * @public
175
+ */
176
+ type EndpointObjectProperty = string | boolean | {
177
+ [key: string]: EndpointObjectProperty;
178
+ } | EndpointObjectProperty[];
179
+ /**
180
+ * @public
181
+ */
182
+ interface EndpointV2 {
183
+ url: URL;
184
+ properties?: {
185
+ authSchemes?: AuthScheme[];
186
+ } & Record<string, EndpointObjectProperty>;
187
+ headers?: Record<string, string[]>;
188
+ }
189
+
190
+ /**
191
+ * @internal
192
+ */
193
+ type SmithyFeatures = Partial<{
194
+ RESOURCE_MODEL: "A";
195
+ WAITER: "B";
196
+ PAGINATOR: "C";
197
+ RETRY_MODE_LEGACY: "D";
198
+ RETRY_MODE_STANDARD: "E";
199
+ RETRY_MODE_ADAPTIVE: "F";
200
+ GZIP_REQUEST_COMPRESSION: "L";
201
+ PROTOCOL_RPC_V2_CBOR: "M";
202
+ ENDPOINT_OVERRIDE: "N";
203
+ SIGV4A_SIGNING: "S";
204
+ CREDENTIALS_CODE: "e";
205
+ }>;
206
+
207
+ /**
208
+ * Represents a logger object that is available in HandlerExecutionContext
209
+ * throughout the middleware stack.
210
+ *
211
+ * @public
212
+ */
213
+ interface Logger {
214
+ trace?: (...content: any[]) => void;
215
+ debug: (...content: any[]) => void;
216
+ info: (...content: any[]) => void;
217
+ warn: (...content: any[]) => void;
218
+ error: (...content: any[]) => void;
219
+ }
220
+
221
+ /**
222
+ * Outcome of a request, recorded by the framework via {@link MetricsRecorder.recordRequestOutcome}.
223
+ *
224
+ * @public
225
+ */
226
+ type RequestOutcome = "Success" | "Fault";
227
+ /**
228
+ * Unit attached to a recorded metric value. The vocabulary follows the
229
+ * CloudWatch unit names so backends that emit to CloudWatch can pass it
230
+ * through, but it carries no backend-specific semantics — a recorder is free
231
+ * to map or ignore it.
232
+ *
233
+ * @public
234
+ */
235
+ type MetricUnit = "Seconds" | "Microseconds" | "Milliseconds" | "Bytes" | "Kilobytes" | "Megabytes" | "Gigabytes" | "Terabytes" | "Bits" | "Kilobits" | "Megabits" | "Gigabits" | "Terabits" | "Percent" | "Count" | "None" | "Bytes/Second" | "Kilobytes/Second" | "Megabytes/Second" | "Gigabytes/Second" | "Terabytes/Second" | "Bits/Second" | "Kilobits/Second" | "Megabits/Second" | "Gigabits/Second" | "Terabits/Second" | "Count/Second";
236
+ /**
237
+ * Backend-agnostic recorder for per-request metrics. The framework drives the
238
+ * lifecycle of recorders obtained from a factory and records request-level
239
+ * metrics through this interface; user handlers record their own business
240
+ * metrics through the same methods. Concrete recorders (e.g. an EMF recorder,
241
+ * or a future OpenTelemetry recorder) translate these abstract calls into their
242
+ * own primitives.
243
+ *
244
+ * @typeParam Native - the concrete backend handle returned by
245
+ * {@link MetricsRecorder.getMetrics}, e.g. an OpenTelemetry `Meter`. The
246
+ * parameter is required so that native access is always typed rather than
247
+ * erased to `unknown`.
248
+ *
249
+ * @public
250
+ */
251
+ interface MetricsRecorder<Native> {
252
+ /**
253
+ * Open the recorder for the current request. Called by the framework once at
254
+ * the start of request handling when it owns the recorder.
255
+ */
256
+ begin(): void;
257
+ /**
258
+ * Close the recorder for the current request. Called by the framework once at
259
+ * the end of request handling when it owns the recorder; this is where an
260
+ * implementation typically flushes its event.
261
+ */
262
+ end(): void;
263
+ /**
264
+ * Records the outcome and duration of a request. The concrete backend decides
265
+ * how to express this.
266
+ */
267
+ recordRequestOutcome(outcome: RequestOutcome, durationMs: number): void;
268
+ /**
269
+ * Records a count. Values should be non-negative for cross-backend portability.
270
+ */
271
+ addCount(name: string, value: number): void;
272
+ /**
273
+ * Records a duration in milliseconds.
274
+ */
275
+ addTime(name: string, value: number): void;
276
+ /**
277
+ * Records a level — a sampled value that should average meaningfully across
278
+ * calls (e.g. queue depth, batch size).
279
+ */
280
+ addLevel(name: string, value: number, unit?: MetricUnit): void;
281
+ /**
282
+ * Records a discrete data point where percentiles matter (e.g. per-call
283
+ * latency, item size).
284
+ */
285
+ addMetric(name: string, value: number, unit?: MetricUnit): void;
286
+ /**
287
+ * Records a unitless ratio (e.g. cache hit rate, throttle rate).
288
+ */
289
+ addRatio(name: string, value: number): void;
290
+ /**
291
+ * Attaches a property to the request's metrics. A nullish or empty value
292
+ * removes the property.
293
+ */
294
+ setProperty(name: string, value: string | null | undefined): void;
295
+ /**
296
+ * Returns the recorder's native backend handle, so callers can reach
297
+ * library-specific features the abstract methods do not expose (e.g. an
298
+ * OpenTelemetry `Meter`).
299
+ */
300
+ getMetrics(): Native;
301
+ }
302
+
303
+ /**
304
+ * Represents the components parts of a Uniform Resource Identifier used to
305
+ * construct the target location of a Request.
306
+ *
307
+ * @internal
308
+ */
309
+ type URI = {
310
+ protocol: string;
311
+ hostname: string;
312
+ port?: number;
313
+ path: string;
314
+ query?: QueryParameterBag;
315
+ username?: string;
316
+ password?: string;
317
+ fragment?: string;
318
+ };
319
+
320
+ /**
321
+ * @public
322
+ *
323
+ * @deprecated use {@link EndpointV2} from `@smithy/types`.
324
+ */
325
+ interface Endpoint {
326
+ protocol: string;
327
+ hostname: string;
328
+ port?: number;
329
+ path: string;
330
+ query?: QueryParameterBag;
331
+ headers?: HeaderBag;
332
+ }
333
+ /**
334
+ * Interface an HTTP request class. Contains
335
+ * addressing information in addition to standard message properties.
336
+ *
337
+ * @public
338
+ */
339
+ interface HttpRequest$1 extends HttpMessage, URI {
340
+ method: string;
341
+ }
342
+ /**
343
+ * Represents an HTTP message as received in reply to a request. Contains a
344
+ * numeric status code in addition to standard message properties.
345
+ *
346
+ * @public
347
+ */
348
+ interface HttpResponse$1 extends HttpMessage {
349
+ statusCode: number;
350
+ reason?: string;
351
+ }
352
+ /**
353
+ * A mapping of query parameter names to strings or arrays of strings, with the
354
+ * second being used when a parameter contains a list of values. Value can be set
355
+ * to null when query is not in key-value pairs shape
356
+ *
357
+ * @public
358
+ */
359
+ type QueryParameterBag = Record<string, string | Array<string> | null>;
360
+ /**
361
+ * A mapping of header names to string values. Multiple values for the same
362
+ * header should be represented as a single string with values separated by
363
+ * `, `.
364
+ * Keys should be considered case insensitive, even if this is not enforced by a
365
+ * particular implementation. For example, given the following HeaderBag, where
366
+ * keys differ only in case:
367
+ * ```json
368
+ * {
369
+ * 'x-request-date': '2000-01-01T00:00:00Z',
370
+ * 'X-Request-Date': '2001-01-01T00:00:00Z'
371
+ * }
372
+ * ```
373
+ * The SDK may at any point during processing remove one of the object
374
+ * properties in favor of the other. The headers may or may not be combined, and
375
+ * the SDK will not deterministically select which header candidate to use.
376
+ *
377
+ * @public
378
+ */
379
+ type HeaderBag = Record<string, string>;
380
+ /**
381
+ * Represents an HTTP message with headers and an optional static or streaming
382
+ * body. body: ArrayBuffer | ArrayBufferView | string | Uint8Array | Readable | ReadableStream;
383
+ *
384
+ * @public
385
+ */
386
+ interface HttpMessage {
387
+ headers: HeaderBag;
388
+ body?: any;
389
+ }
390
+ /**
391
+ * Represents an HTTP message with headers and an optional static or streaming
392
+ * body. bode: ArrayBuffer | ArrayBufferView | string | Uint8Array | Readable | ReadableStream;
393
+ *
394
+ * @public
395
+ */
396
+ interface HttpMessage {
397
+ headers: HeaderBag;
398
+ body?: any;
399
+ }
400
+ /**
401
+ * Represents the options that may be passed to an Http Handler.
402
+ *
403
+ * @public
404
+ */
405
+ interface HttpHandlerOptions {
406
+ abortSignal?: AbortSignal | AbortSignal$1;
407
+ /**
408
+ * The maximum time in milliseconds that the connection phase of a request
409
+ * may take before the connection attempt is abandoned.
410
+ */
411
+ requestTimeout?: number;
412
+ }
413
+
414
+ /**
415
+ * A function that, given a Uint8Array of bytes, can produce a string
416
+ * representation thereof. The function may optionally attempt to
417
+ * convert other input types to Uint8Array before encoding.
418
+ *
419
+ * @example An encoder function that converts bytes to hexadecimal
420
+ * representation would return `'hello'` when given
421
+ * `new Uint8Array([104, 101, 108, 108, 111])`.
422
+ *
423
+ * @public
424
+ */
425
+ interface Encoder {
426
+ /**
427
+ * Caution: the `any` type on the input is for backwards compatibility.
428
+ * Runtime support is limited to Uint8Array and string by default.
429
+ *
430
+ * You may choose to support more encoder input types if overriding the default
431
+ * implementations.
432
+ */
433
+ (input: Uint8Array | string | any): string;
434
+ }
435
+ /**
436
+ * A function that, given a string, can derive the bytes represented by that
437
+ * string.
438
+ *
439
+ * @example A decoder function that converts bytes to hexadecimal
440
+ * representation would return `new Uint8Array([104, 101, 108, 108, 111])` when
441
+ * given the string `'hello'`.
442
+ *
443
+ * @public
444
+ */
445
+ interface Decoder {
446
+ (input: string): Uint8Array;
447
+ }
448
+ /**
449
+ * A function that, when invoked, returns a promise that will be fulfilled with
450
+ * a value of type T.
451
+ *
452
+ * @example A function that reads credentials from shared SDK configuration
453
+ * files, assuming roles and collecting MFA tokens as necessary.
454
+ *
455
+ * @public
456
+ */
457
+ interface Provider<T> {
458
+ (): Promise<T>;
459
+ }
460
+ /**
461
+ * A tuple that represents an API name and optional version
462
+ * of a library built using the AWS SDK.
463
+ *
464
+ * @public
465
+ */
466
+ type UserAgentPair = [name: string, version?: string];
467
+ /**
468
+ * User agent data that to be put into the request's user
469
+ * agent.
470
+ *
471
+ * @public
472
+ */
473
+ type UserAgent = UserAgentPair[];
474
+
475
+ /**
476
+ * @public
477
+ */
478
+ interface InitializeHandlerArguments<Input extends object> {
479
+ /**
480
+ * User input to a command. Reflects the userland representation of the
481
+ * union of data types the command can effectively handle.
482
+ */
483
+ input: Input;
484
+ }
485
+ /**
486
+ * @public
487
+ */
488
+ interface InitializeHandlerOutput<Output extends object> extends DeserializeHandlerOutput<Output> {
489
+ output: Output;
490
+ }
491
+ /**
492
+ * @public
493
+ */
494
+ interface SerializeHandlerArguments<Input extends object> extends InitializeHandlerArguments<Input> {
495
+ /**
496
+ * The user input serialized as a request object. The request object is unknown,
497
+ * so you cannot modify it directly. When work with request, you need to guard its
498
+ * type to e.g. HttpRequest with 'instanceof' operand
499
+ *
500
+ * During the build phase of the execution of a middleware stack, a built
501
+ * request may or may not be available.
502
+ */
503
+ request?: unknown;
504
+ }
505
+ /**
506
+ * @public
507
+ */
508
+ interface SerializeHandlerOutput<Output extends object> extends InitializeHandlerOutput<Output> {
509
+ }
510
+ /**
511
+ * @public
512
+ */
513
+ interface BuildHandlerArguments<Input extends object> extends FinalizeHandlerArguments<Input> {
514
+ }
515
+ /**
516
+ * @public
517
+ */
518
+ interface BuildHandlerOutput<Output extends object> extends InitializeHandlerOutput<Output> {
519
+ }
520
+ /**
521
+ * @public
522
+ */
523
+ interface FinalizeHandlerArguments<Input extends object> extends SerializeHandlerArguments<Input> {
524
+ /**
525
+ * The user input serialized as a request.
526
+ */
527
+ request: unknown;
528
+ }
529
+ /**
530
+ * @public
531
+ */
532
+ interface FinalizeHandlerOutput<Output extends object> extends InitializeHandlerOutput<Output> {
533
+ }
534
+ /**
535
+ * @public
536
+ */
537
+ interface DeserializeHandlerArguments<Input extends object> extends FinalizeHandlerArguments<Input> {
538
+ }
539
+ /**
540
+ * @public
541
+ */
542
+ interface DeserializeHandlerOutput<Output extends object> {
543
+ /**
544
+ * The raw response object from runtime is deserialized to structured output object.
545
+ * The response object is unknown so you cannot modify it directly. When work with
546
+ * response, you need to guard its type to e.g. HttpResponse with 'instanceof' operand.
547
+ *
548
+ * During the deserialize phase of the execution of a middleware stack, a deserialized
549
+ * response may or may not be available
550
+ */
551
+ response: unknown;
552
+ output?: Output;
553
+ }
554
+ /**
555
+ * @public
556
+ */
557
+ interface InitializeHandler<Input extends object, Output extends object> {
558
+ /**
559
+ * Asynchronously converts an input object into an output object.
560
+ *
561
+ * @param args - An object containing a input to the command as well as any
562
+ * associated or previously generated execution artifacts.
563
+ */
564
+ (args: InitializeHandlerArguments<Input>): Promise<InitializeHandlerOutput<Output>>;
565
+ }
566
+ /**
567
+ * @public
568
+ */
569
+ type Handler<Input extends object, Output extends object> = InitializeHandler<Input, Output>;
570
+ /**
571
+ * @public
572
+ */
573
+ interface SerializeHandler<Input extends object, Output extends object> {
574
+ /**
575
+ * Asynchronously converts an input object into an output object.
576
+ *
577
+ * @param args - An object containing a input to the command as well as any
578
+ * associated or previously generated execution artifacts.
579
+ */
580
+ (args: SerializeHandlerArguments<Input>): Promise<SerializeHandlerOutput<Output>>;
581
+ }
582
+ /**
583
+ * @public
584
+ */
585
+ interface FinalizeHandler<Input extends object, Output extends object> {
586
+ /**
587
+ * Asynchronously converts an input object into an output object.
588
+ *
589
+ * @param args - An object containing a input to the command as well as any
590
+ * associated or previously generated execution artifacts.
591
+ */
592
+ (args: FinalizeHandlerArguments<Input>): Promise<FinalizeHandlerOutput<Output>>;
593
+ }
594
+ /**
595
+ * @public
596
+ */
597
+ interface BuildHandler<Input extends object, Output extends object> {
598
+ (args: BuildHandlerArguments<Input>): Promise<BuildHandlerOutput<Output>>;
599
+ }
600
+ /**
601
+ * @public
602
+ */
603
+ interface DeserializeHandler<Input extends object, Output extends object> {
604
+ (args: DeserializeHandlerArguments<Input>): Promise<DeserializeHandlerOutput<Output>>;
605
+ }
606
+ /**
607
+ * A factory function that creates functions implementing the `Handler`
608
+ * interface.
609
+ *
610
+ * @public
611
+ */
612
+ interface InitializeMiddleware<Input extends object, Output extends object> {
613
+ /**
614
+ * @param next - The handler to invoke after this middleware has operated on
615
+ * the user input and before this middleware operates on the output.
616
+ *
617
+ * @param context - Invariant data and functions for use by the handler.
618
+ */
619
+ (next: InitializeHandler<Input, Output>, context: HandlerExecutionContext): InitializeHandler<Input, Output>;
620
+ }
621
+ /**
622
+ * A factory function that creates functions implementing the `BuildHandler`
623
+ * interface.
624
+ *
625
+ * @public
626
+ */
627
+ interface SerializeMiddleware<Input extends object, Output extends object> {
628
+ /**
629
+ * @param next - The handler to invoke after this middleware has operated on
630
+ * the user input and before this middleware operates on the output.
631
+ *
632
+ * @param context - Invariant data and functions for use by the handler.
633
+ */
634
+ (next: SerializeHandler<Input, Output>, context: HandlerExecutionContext): SerializeHandler<Input, Output>;
635
+ }
636
+ /**
637
+ * A factory function that creates functions implementing the `FinalizeHandler`
638
+ * interface.
639
+ *
640
+ * @public
641
+ */
642
+ interface FinalizeRequestMiddleware<Input extends object, Output extends object> {
643
+ /**
644
+ * @param next - The handler to invoke after this middleware has operated on
645
+ * the user input and before this middleware operates on the output.
646
+ *
647
+ * @param context - Invariant data and functions for use by the handler.
648
+ */
649
+ (next: FinalizeHandler<Input, Output>, context: HandlerExecutionContext): FinalizeHandler<Input, Output>;
650
+ }
651
+ /**
652
+ * @public
653
+ */
654
+ interface BuildMiddleware<Input extends object, Output extends object> {
655
+ (next: BuildHandler<Input, Output>, context: HandlerExecutionContext): BuildHandler<Input, Output>;
656
+ }
657
+ /**
658
+ * @public
659
+ */
660
+ interface DeserializeMiddleware<Input extends object, Output extends object> {
661
+ (next: DeserializeHandler<Input, Output>, context: HandlerExecutionContext): DeserializeHandler<Input, Output>;
662
+ }
663
+ /**
664
+ * @public
665
+ */
666
+ type MiddlewareType<Input extends object, Output extends object> = InitializeMiddleware<Input, Output> | SerializeMiddleware<Input, Output> | BuildMiddleware<Input, Output> | FinalizeRequestMiddleware<Input, Output> | DeserializeMiddleware<Input, Output>;
667
+ /**
668
+ * @public
669
+ */
670
+ type Step = "initialize" | "serialize" | "build" | "finalizeRequest" | "deserialize";
671
+ /**
672
+ * @public
673
+ */
674
+ type Priority = "high" | "normal" | "low";
675
+ /**
676
+ * @public
677
+ */
678
+ interface HandlerOptions {
679
+ /**
680
+ * Handlers are ordered using a "step" that describes the stage of command
681
+ * execution at which the handler will be executed. The available steps are:
682
+ *
683
+ * - initialize: The input is being prepared. Examples of typical
684
+ * initialization tasks include injecting default options computing
685
+ * derived parameters.
686
+ * - serialize: The input is complete and ready to be serialized. Examples
687
+ * of typical serialization tasks include input validation and building
688
+ * an HTTP request from user input.
689
+ * - build: The input has been serialized into an HTTP request, but that
690
+ * request may require further modification. Any request alterations
691
+ * will be applied to all retries. Examples of typical build tasks
692
+ * include injecting HTTP headers that describe a stable aspect of the
693
+ * request, such as `Content-Length` or a body checksum.
694
+ * - finalizeRequest: The request is being prepared to be sent over the wire. The
695
+ * request in this stage should already be semantically complete and
696
+ * should therefore only be altered as match the recipient's
697
+ * expectations. Examples of typical finalization tasks include request
698
+ * signing and injecting hop-by-hop headers.
699
+ * - deserialize: The response has arrived, the middleware here will deserialize
700
+ * the raw response object to structured response
701
+ *
702
+ * Unlike initialization and build handlers, which are executed once
703
+ * per operation execution, finalization and deserialize handlers will be
704
+ * executed foreach HTTP request sent.
705
+ *
706
+ * @defaultValue 'initialize'
707
+ */
708
+ step?: Step;
709
+ /**
710
+ * A list of strings to any that identify the general purpose or important
711
+ * characteristics of a given handler.
712
+ */
713
+ tags?: Array<string>;
714
+ /**
715
+ * A unique name to refer to a middleware
716
+ */
717
+ name?: string;
718
+ /**
719
+ * Aliases allows for middleware to be found by multiple names besides {@link HandlerOptions.name}.
720
+ * This allows for references to replaced middleware to continue working, e.g. replacing
721
+ * multiple auth-specific middleware with a single generic auth middleware.
722
+ *
723
+ * @internal
724
+ */
725
+ aliases?: Array<string>;
726
+ /**
727
+ * A flag to override the existing middleware with the same name. Without
728
+ * setting it, adding middleware with duplicated name will throw an exception.
729
+ * @internal
730
+ */
731
+ override?: boolean;
732
+ }
733
+ /**
734
+ * @public
735
+ */
736
+ interface AbsoluteLocation {
737
+ /**
738
+ * By default middleware will be added to individual step in un-guaranteed order.
739
+ * In the case that
740
+ *
741
+ * @defaultValue 'normal'
742
+ */
743
+ priority?: Priority;
744
+ }
745
+ /**
746
+ * @public
747
+ */
748
+ type Relation = "before" | "after";
749
+ /**
750
+ * @public
751
+ */
752
+ interface RelativeLocation {
753
+ /**
754
+ * Specify the relation to be before or after a know middleware.
755
+ */
756
+ relation: Relation;
757
+ /**
758
+ * A known middleware name to indicate inserting middleware's location.
759
+ */
760
+ toMiddleware: string;
761
+ }
762
+ /**
763
+ * @public
764
+ */
765
+ type RelativeMiddlewareOptions = RelativeLocation & Omit<HandlerOptions, "step">;
766
+ /**
767
+ * @public
768
+ */
769
+ interface InitializeHandlerOptions extends HandlerOptions {
770
+ step?: "initialize";
771
+ }
772
+ /**
773
+ * @public
774
+ */
775
+ interface SerializeHandlerOptions extends HandlerOptions {
776
+ step: "serialize";
777
+ }
778
+ /**
779
+ * @public
780
+ */
781
+ interface BuildHandlerOptions extends HandlerOptions {
782
+ step: "build";
783
+ }
784
+ /**
785
+ * @public
786
+ */
787
+ interface FinalizeRequestHandlerOptions extends HandlerOptions {
788
+ step: "finalizeRequest";
789
+ }
790
+ /**
791
+ * @public
792
+ */
793
+ interface DeserializeHandlerOptions extends HandlerOptions {
794
+ step: "deserialize";
795
+ }
796
+ /**
797
+ * A stack storing middleware. It can be resolved into a handler. It supports 2
798
+ * approaches for adding middleware:
799
+ * 1. Adding middleware to specific step with `add()`. The order of middleware
800
+ * added into same step is determined by order of adding them. If one middleware
801
+ * needs to be executed at the front of the step or at the end of step, set
802
+ * `priority` options to `high` or `low`.
803
+ * 2. Adding middleware to location relative to known middleware with `addRelativeTo()`.
804
+ * This is useful when given middleware must be executed before or after specific
805
+ * middleware(`toMiddleware`). You can add a middleware relatively to another
806
+ * middleware which also added relatively. But eventually, this relative middleware
807
+ * chain **must** be 'anchored' by a middleware that added using `add()` API
808
+ * with absolute `step` and `priority`. This mothod will throw if specified
809
+ * `toMiddleware` is not found.
810
+ *
811
+ * @public
812
+ */
813
+ interface MiddlewareStack<Input extends object, Output extends object> extends Pluggable<Input, Output> {
814
+ /**
815
+ * Add middleware to the stack to be executed during the "initialize" step,
816
+ * optionally specifying a priority, tags and name
817
+ */
818
+ add(middleware: InitializeMiddleware<Input, Output>, options?: InitializeHandlerOptions & AbsoluteLocation): void;
819
+ /**
820
+ * Add middleware to the stack to be executed during the "serialize" step,
821
+ * optionally specifying a priority, tags and name
822
+ */
823
+ add(middleware: SerializeMiddleware<Input, Output>, options: SerializeHandlerOptions & AbsoluteLocation): void;
824
+ /**
825
+ * Add middleware to the stack to be executed during the "build" step,
826
+ * optionally specifying a priority, tags and name
827
+ */
828
+ add(middleware: BuildMiddleware<Input, Output>, options: BuildHandlerOptions & AbsoluteLocation): void;
829
+ /**
830
+ * Add middleware to the stack to be executed during the "finalizeRequest" step,
831
+ * optionally specifying a priority, tags and name
832
+ */
833
+ add(middleware: FinalizeRequestMiddleware<Input, Output>, options: FinalizeRequestHandlerOptions & AbsoluteLocation): void;
834
+ /**
835
+ * Add middleware to the stack to be executed during the "deserialize" step,
836
+ * optionally specifying a priority, tags and name
837
+ */
838
+ add(middleware: DeserializeMiddleware<Input, Output>, options: DeserializeHandlerOptions & AbsoluteLocation): void;
839
+ /**
840
+ * Add middleware to a stack position before or after a known middleware,optionally
841
+ * specifying name and tags.
842
+ */
843
+ addRelativeTo(middleware: MiddlewareType<Input, Output>, options: RelativeMiddlewareOptions): void;
844
+ /**
845
+ * Apply a customization function to mutate the middleware stack, often
846
+ * used for customizations that requires mutating multiple middleware.
847
+ */
848
+ use(pluggable: Pluggable<Input, Output>): void;
849
+ /**
850
+ * Create a shallow clone of this stack. Step bindings and handler priorities
851
+ * and tags are preserved in the copy.
852
+ */
853
+ clone(): MiddlewareStack<Input, Output>;
854
+ /**
855
+ * Removes middleware from the stack.
856
+ *
857
+ * If a string is provided, it will be treated as middleware name. If a middleware
858
+ * is inserted with the given name, it will be removed.
859
+ *
860
+ * If a middleware class is provided, all usages thereof will be removed.
861
+ */
862
+ remove(toRemove: MiddlewareType<Input, Output> | string): boolean;
863
+ /**
864
+ * Removes middleware that contains given tag
865
+ *
866
+ * Multiple middleware will potentially be removed
867
+ */
868
+ removeByTag(toRemove: string): boolean;
869
+ /**
870
+ * Create a stack containing the middlewares in this stack as well as the
871
+ * middlewares in the `from` stack. Neither source is modified, and step
872
+ * bindings and handler priorities and tags are preserved in the copy.
873
+ */
874
+ concat<InputType extends Input, OutputType extends Output>(from: MiddlewareStack<InputType, OutputType>): MiddlewareStack<InputType, OutputType>;
875
+ /**
876
+ * Returns a list of the current order of middleware in the stack.
877
+ * This does not execute the middleware functions, nor does it
878
+ * provide a reference to the stack itself.
879
+ */
880
+ identify(): string[];
881
+ /**
882
+ * When an operation is called using this stack,
883
+ * it will log its list of middleware to the console using
884
+ * the identify function.
885
+ * If no argument given, returns the current value.
886
+ *
887
+ * @internal
888
+ * @param toggle - set whether to log on resolve.
889
+ */
890
+ identifyOnResolve(toggle?: boolean): boolean;
891
+ /**
892
+ * Builds a single handler function from zero or more middleware classes and
893
+ * a core handler. The core handler is meant to send command objects to AWS
894
+ * services and return promises that will resolve with the operation result
895
+ * or be rejected with an error.
896
+ *
897
+ * When a composed handler is invoked, the arguments will pass through all
898
+ * middleware in a defined order, and the return from the innermost handler
899
+ * will pass through all middleware in the reverse of that order.
900
+ */
901
+ resolve<InputType extends Input, OutputType extends Output>(handler: DeserializeHandler<InputType, OutputType>, context: HandlerExecutionContext): InitializeHandler<InputType, OutputType>;
902
+ }
903
+ /**
904
+ * @internal
905
+ */
906
+ declare const SMITHY_CONTEXT_KEY = "__smithy_context";
907
+ /**
908
+ * Data and helper objects that are not expected to change from one execution of
909
+ * a composed handler to another.
910
+ *
911
+ * @public
912
+ */
913
+ interface HandlerExecutionContext {
914
+ /**
915
+ * A logger that may be invoked by any handler during execution of an
916
+ * operation.
917
+ */
918
+ logger?: Logger;
919
+ /**
920
+ * Name of the service the operation is being sent to.
921
+ */
922
+ clientName?: string;
923
+ /**
924
+ * Name of the operation being executed.
925
+ */
926
+ commandName?: string;
927
+ /**
928
+ * Additional user agent that inferred by middleware. It can be used to save
929
+ * the internal user agent sections without overriding the `customUserAgent`
930
+ * config in clients.
931
+ */
932
+ userAgent?: UserAgent;
933
+ /**
934
+ * Resolved by the endpointMiddleware function of `@smithy/middleware-endpoint`
935
+ * in the serialization stage.
936
+ */
937
+ endpointV2?: EndpointV2;
938
+ /**
939
+ * Set at the same time as endpointV2.
940
+ */
941
+ authSchemes?: AuthScheme[];
942
+ /**
943
+ * The current auth configuration that has been set by any auth middleware and
944
+ * that will prevent from being set more than once.
945
+ */
946
+ currentAuthConfig?: HttpAuthDefinition;
947
+ /**
948
+ * @deprecated do not extend this field, it is a carryover from AWS SDKs.
949
+ * Used by DynamoDbDocumentClient.
950
+ */
951
+ dynamoDbDocumentClientOptions?: Partial<{
952
+ overrideInputFilterSensitiveLog(...args: any[]): string | void;
953
+ overrideOutputFilterSensitiveLog(...args: any[]): string | void;
954
+ }>;
955
+ /**
956
+ * Context for Smithy properties.
957
+ *
958
+ * @internal
959
+ */
960
+ [SMITHY_CONTEXT_KEY]?: {
961
+ service?: string;
962
+ operation?: string;
963
+ commandInstance?: Command<any, any, any, any, any>;
964
+ selectedHttpAuthScheme?: SelectedHttpAuthScheme;
965
+ features?: SmithyFeatures;
966
+ /**
967
+ * Transferred from request options to the Smithy context.
968
+ */
969
+ metricsRecorder?: MetricsRecorder<unknown>;
970
+ /**
971
+ * Transferred from request options to allow middleware to cancel
972
+ * asynchronous work outside of the request handler.
973
+ */
974
+ abortSignal?: AbortSignal | AbortSignal$1;
975
+ /**
976
+ * @deprecated
977
+ * Do not assign arbitrary members to the Smithy Context,
978
+ * fields should be explicitly declared here to avoid collisions.
979
+ */
980
+ [key: string]: unknown;
981
+ };
982
+ /**
983
+ * Set by some operations which instructs the retry behavior to backoff
984
+ * after a failed request even when no further retry (of the same request) is expected.
985
+ * @internal
986
+ */
987
+ __retryLongPoll?: boolean;
988
+ /**
989
+ * @deprecated
990
+ * Do not assign arbitrary members to the context, since
991
+ * they can interfere with existing functionality.
992
+ *
993
+ * Additional members should instead be declared on the SMITHY_CONTEXT_KEY
994
+ * or other reserved keys.
995
+ */
996
+ [key: string]: any;
997
+ }
998
+ /**
999
+ * @public
1000
+ */
1001
+ interface Pluggable<Input extends object, Output extends object> {
1002
+ /**
1003
+ * A function that mutate the passed in middleware stack. Functions implementing
1004
+ * this interface can add, remove, modify existing middleware stack from clients
1005
+ * or commands
1006
+ */
1007
+ applyToStack: (stack: MiddlewareStack<Input, Output>) => void;
1008
+ }
1009
+
1010
+ /**
1011
+ * @internal
1012
+ */
1013
+ interface ErrorHandler {
1014
+ (signingProperties: Record<string, unknown>): <E extends Error>(error: E) => never;
1015
+ }
1016
+ /**
1017
+ * @internal
1018
+ */
1019
+ interface SuccessHandler {
1020
+ (httpResponse: HttpResponse$1 | unknown, signingProperties: Record<string, unknown>): void;
1021
+ }
1022
+ /**
1023
+ * Interface to sign identity and signing properties.
1024
+ * @internal
1025
+ */
1026
+ interface HttpSigner {
1027
+ /**
1028
+ * Signs an HttpRequest with an identity and signing properties.
1029
+ * @param httpRequest request to sign
1030
+ * @param identity identity to sing the request with
1031
+ * @param signingProperties property bag for signing
1032
+ * @returns signed request in a promise
1033
+ */
1034
+ sign(httpRequest: HttpRequest$1, identity: Identity, signingProperties: Record<string, unknown>): Promise<HttpRequest$1>;
1035
+ /**
1036
+ * Handler that executes after the {@link HttpSigner.sign} invocation and corresponding
1037
+ * middleware throws an error.
1038
+ * The error handler is expected to throw the error it receives, so the return type of the error handler is `never`.
1039
+ * @internal
1040
+ */
1041
+ errorHandler?: ErrorHandler;
1042
+ /**
1043
+ * Handler that executes after the {@link HttpSigner.sign} invocation and corresponding
1044
+ * middleware succeeds.
1045
+ * @internal
1046
+ */
1047
+ successHandler?: SuccessHandler;
1048
+ }
1049
+
1050
+ /**
1051
+ * ID for {@link HttpAuthScheme}
1052
+ * @internal
1053
+ */
1054
+ type HttpAuthSchemeId = string;
1055
+ /**
1056
+ * Interface that defines the identity and signing properties when selecting
1057
+ * an HttpAuthScheme.
1058
+ * @internal
1059
+ */
1060
+ interface HttpAuthOption {
1061
+ schemeId: HttpAuthSchemeId;
1062
+ identityProperties?: Record<string, unknown>;
1063
+ signingProperties?: Record<string, unknown>;
1064
+ propertiesExtractor?: <TConfig extends object, TContext extends HandlerExecutionContext>(config: TConfig, context: TContext) => {
1065
+ identityProperties?: Record<string, unknown>;
1066
+ signingProperties?: Record<string, unknown>;
1067
+ };
1068
+ }
1069
+ /**
1070
+ * @internal
1071
+ */
1072
+ interface SelectedHttpAuthScheme {
1073
+ httpAuthOption: HttpAuthOption;
1074
+ identity: Identity;
1075
+ signer: HttpSigner;
1076
+ }
1077
+
1078
+ /**
1079
+ * @public
1080
+ */
1081
+ type RequestHandlerOutput<ResponseType> = {
1082
+ response: ResponseType;
1083
+ };
1084
+ /**
1085
+ * @public
1086
+ */
1087
+ interface RequestHandler<RequestType, ResponseType, HandlerOptions = {}> {
1088
+ /**
1089
+ * metadata contains information of a handler. For example
1090
+ * 'h2' refers this handler is for handling HTTP/2 requests,
1091
+ * whereas 'h1' refers handling HTTP1 requests
1092
+ */
1093
+ metadata?: RequestHandlerMetadata;
1094
+ destroy?: () => void;
1095
+ handle: (request: RequestType, handlerOptions?: HandlerOptions) => Promise<RequestHandlerOutput<ResponseType>>;
1096
+ }
1097
+ /**
1098
+ * @public
1099
+ */
1100
+ interface RequestHandlerMetadata {
1101
+ handlerProtocol: RequestHandlerProtocol | string;
1102
+ }
1103
+ /**
1104
+ * Values from ALPN Protocol IDs.
1105
+ *
1106
+ * @public
1107
+ * @see https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids
1108
+ */
1109
+ declare enum RequestHandlerProtocol {
1110
+ HTTP_0_9 = "http/0.9",
1111
+ HTTP_1_0 = "http/1.0",
1112
+ TDS_8_0 = "tds/8.0"
1113
+ }
1114
+
1115
+ /**
1116
+ * An event stream message. The headers and body properties will always be
1117
+ * defined, with empty headers represented as an object with no keys and an
1118
+ * empty body represented as a zero-length Uint8Array.
1119
+ *
1120
+ * @public
1121
+ */
1122
+ interface Message {
1123
+ headers: MessageHeaders;
1124
+ body: Uint8Array;
1125
+ }
1126
+ /**
1127
+ * @public
1128
+ */
1129
+ type MessageHeaders = Record<string, MessageHeaderValue>;
1130
+ /**
1131
+ * @public
1132
+ */
1133
+ type HeaderValue<K extends string, V> = {
1134
+ type: K;
1135
+ value: V;
1136
+ };
1137
+ /**
1138
+ * @public
1139
+ */
1140
+ type BooleanHeaderValue = HeaderValue<"boolean", boolean>;
1141
+ /**
1142
+ * @public
1143
+ */
1144
+ type ByteHeaderValue = HeaderValue<"byte", number>;
1145
+ /**
1146
+ * @public
1147
+ */
1148
+ type ShortHeaderValue = HeaderValue<"short", number>;
1149
+ /**
1150
+ * @public
1151
+ */
1152
+ type IntegerHeaderValue = HeaderValue<"integer", number>;
1153
+ /**
1154
+ * @public
1155
+ */
1156
+ type LongHeaderValue = HeaderValue<"long", Int64>;
1157
+ /**
1158
+ * @public
1159
+ */
1160
+ type BinaryHeaderValue = HeaderValue<"binary", Uint8Array>;
1161
+ /**
1162
+ * @public
1163
+ */
1164
+ type StringHeaderValue = HeaderValue<"string", string>;
1165
+ /**
1166
+ * @public
1167
+ */
1168
+ type TimestampHeaderValue = HeaderValue<"timestamp", Date>;
1169
+ /**
1170
+ * @public
1171
+ */
1172
+ type UuidHeaderValue = HeaderValue<"uuid", string>;
1173
+ /**
1174
+ * @public
1175
+ */
1176
+ type MessageHeaderValue = BooleanHeaderValue | ByteHeaderValue | ShortHeaderValue | IntegerHeaderValue | LongHeaderValue | BinaryHeaderValue | StringHeaderValue | TimestampHeaderValue | UuidHeaderValue;
1177
+ /**
1178
+ * @public
1179
+ */
1180
+ interface Int64 {
1181
+ readonly bytes: Uint8Array;
1182
+ valueOf: () => number;
1183
+ toString: () => string;
1184
+ }
1185
+ /**
1186
+ * A function which deserializes binary event stream message into modeled shape.
1187
+ *
1188
+ * @public
1189
+ */
1190
+ interface EventStreamMarshallerDeserFn<StreamType> {
1191
+ <T>(body: StreamType, deserializer: (input: Record<string, Message>) => Promise<T>): AsyncIterable<T>;
1192
+ }
1193
+ /**
1194
+ * A function that serializes modeled shape into binary stream message.
1195
+ *
1196
+ * @public
1197
+ */
1198
+ interface EventStreamMarshallerSerFn<StreamType> {
1199
+ <T>(input: AsyncIterable<T>, serializer: (event: T) => Message): StreamType;
1200
+ }
1201
+ /**
1202
+ * An interface which provides functions for serializing and deserializing binary event stream
1203
+ * to/from corresponsing modeled shape.
1204
+ *
1205
+ * @public
1206
+ */
1207
+ interface EventStreamMarshaller<StreamType = any> {
1208
+ deserialize: EventStreamMarshallerDeserFn<StreamType>;
1209
+ serialize: EventStreamMarshallerSerFn<StreamType>;
1210
+ }
1211
+
1212
+ /**
1213
+ * A structure shape with the error trait.
1214
+ * https://smithy.io/2.0/spec/behavior-traits.html#smithy-api-retryable-trait
1215
+ *
1216
+ * @public
1217
+ */
1218
+ interface RetryableTrait {
1219
+ /**
1220
+ * Indicates that the error is a retryable throttling error.
1221
+ */
1222
+ readonly throttling?: boolean;
1223
+ }
1224
+ /**
1225
+ * Type that is implemented by all Smithy shapes marked with the
1226
+ * error trait.
1227
+ *
1228
+ * @public
1229
+ * @deprecated
1230
+ */
1231
+ interface SmithyException {
1232
+ /**
1233
+ * The shape ID name of the exception.
1234
+ */
1235
+ readonly name: string;
1236
+ /**
1237
+ * Whether the client or server are at fault.
1238
+ */
1239
+ readonly $fault: "client" | "server";
1240
+ /**
1241
+ * The service that encountered the exception.
1242
+ */
1243
+ readonly $service?: string;
1244
+ /**
1245
+ * Indicates that an error MAY be retried by the client.
1246
+ */
1247
+ readonly $retryable?: RetryableTrait;
1248
+ /**
1249
+ * Reference to low-level HTTP response object.
1250
+ */
1251
+ readonly $response?: HttpResponse$1;
1252
+ }
1253
+ /**
1254
+ * This type should not be used in your application.
1255
+ * Users of the AWS SDK for JavaScript v3 service clients should prefer to
1256
+ * use the specific Exception classes corresponding to each operation.
1257
+ * These can be found as code in the deserializer for the operation's Command class,
1258
+ * or as declarations in the service model file in codegen/sdk-codegen/aws-models.
1259
+ * If no exceptions are enumerated by a particular Command operation,
1260
+ * the base exception for the service should be used. Each client exports
1261
+ * a base ServiceException prefixed with the service name.
1262
+ *
1263
+ * @public
1264
+ * @deprecated See {@link https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/}
1265
+ */
1266
+ type SdkError = Error & Partial<SmithyException> & Partial<MetadataBearer> & {
1267
+ $metadata?: Partial<MetadataBearer>["$metadata"] & {
1268
+ /**
1269
+ * If present, will have value of true and indicates that the error resulted in a
1270
+ * correction of the clock skew, a.k.a. config.systemClockOffset.
1271
+ * This is specific to AWS SDK and sigv4.
1272
+ */
1273
+ readonly clockSkewCorrected?: true;
1274
+ };
1275
+ cause?: Error;
1276
+ };
1277
+
1278
+ /**
1279
+ * @public
1280
+ */
1281
+ type RetryErrorType =
1282
+ /**
1283
+ * This is a connection level error such as a socket timeout, socket connect
1284
+ * error, tls negotiation timeout etc...
1285
+ * Typically these should never be applied for non-idempotent request types
1286
+ * since in this scenario, it's impossible to know whether the operation had
1287
+ * a side effect on the server.
1288
+ */
1289
+ "TRANSIENT"
1290
+ /**
1291
+ * This is an error where the server explicitly told the client to back off,
1292
+ * such as a 429 or 503 Http error.
1293
+ */
1294
+ | "THROTTLING"
1295
+ /**
1296
+ * This is a server error that isn't explicitly throttling but is considered
1297
+ * by the client to be something that should be retried.
1298
+ */
1299
+ | "SERVER_ERROR"
1300
+ /**
1301
+ * Doesn't count against any budgets. This could be something like a 401
1302
+ * challenge in Http.
1303
+ */
1304
+ | "CLIENT_ERROR";
1305
+ /**
1306
+ * @public
1307
+ */
1308
+ interface RetryErrorInfo {
1309
+ /**
1310
+ * The error thrown during the initial request, if available.
1311
+ */
1312
+ error?: SdkError;
1313
+ errorType: RetryErrorType;
1314
+ /**
1315
+ * Protocol hint. This could come from Http's 'retry-after' header or
1316
+ * something from MQTT or any other protocol that has the ability to convey
1317
+ * retry info from a peer.
1318
+ *
1319
+ * The Date after which a retry should be attempted.
1320
+ */
1321
+ retryAfterHint?: Date;
1322
+ }
1323
+ /**
1324
+ * @public
1325
+ */
1326
+ interface RetryToken {
1327
+ /**
1328
+ * Starts at 0 for the initial request, which is not a "retry" by definition.
1329
+ * 1 indicates the first retry.
1330
+ *
1331
+ * @returns the current count of retry.
1332
+ */
1333
+ getRetryCount(): number;
1334
+ /**
1335
+ * RetryStrategies implemented by `@smithy/core` will return tokens with a
1336
+ * delay of zero.
1337
+ *
1338
+ * This is because the RetryStrategy token acquisition methods took over the
1339
+ * task of idling for the delay period. If a user-implemented retry token
1340
+ * contains a delay, the default Smithy retry middleware will still honor it.
1341
+ *
1342
+ * That is to say, you may either sleep within the RetryStrategy methods for acquiring
1343
+ * the token, OR return a token with a retry delay that will cause the retry middleware
1344
+ * to sleep.
1345
+ *
1346
+ * @returns the number of milliseconds to wait before retrying an action.
1347
+ */
1348
+ getRetryDelay(): number;
1349
+ /**
1350
+ * @returns whether the operation which generated this token is long polling.
1351
+ */
1352
+ isLongPoll?(): boolean;
1353
+ /**
1354
+ * Delays that have already been executed by the time the token
1355
+ * is accessible. This is needed for the token handler to understand what has happened.
1356
+ * @internal
1357
+ */
1358
+ $retryLog?: {
1359
+ acquisitionDelay?: number;
1360
+ };
1361
+ }
1362
+ /**
1363
+ * @public
1364
+ */
1365
+ interface RetryStrategyV2 {
1366
+ /**
1367
+ * Called before any retries (for the first call to the operation). It either
1368
+ * returns a retry token or an error upon the failure to acquire a token prior.
1369
+ *
1370
+ * tokenScope is arbitrary and out of scope for this component. However,
1371
+ * adding it here offers us a lot of future flexibility for outage detection.
1372
+ * For example, it could be "us-east-1" on a shared retry strategy, or
1373
+ * "us-west-2-c:dynamodb".
1374
+ */
1375
+ acquireInitialRetryToken(retryTokenScope: string): Promise<RetryToken>;
1376
+ /**
1377
+ * After a failed operation call, this function is invoked to refresh the
1378
+ * retryToken returned by acquireInitialRetryToken(). This function can
1379
+ * either choose to allow another retry and send a new or updated token,
1380
+ * or reject the retry attempt and report the error either in an exception
1381
+ * or returning an error.
1382
+ *
1383
+ * This method should either delay internally and return a token with 0 delay, OR
1384
+ * do not sleep and return a token with the desired delay duration.
1385
+ */
1386
+ refreshRetryTokenForRetry(tokenToRenew: RetryToken, errorInfo: RetryErrorInfo): Promise<RetryToken>;
1387
+ /**
1388
+ * Upon successful completion of the operation, this function is called
1389
+ * to record that the operation was successful.
1390
+ */
1391
+ recordSuccess(token: RetryToken): void;
1392
+ }
1393
+
1394
+ /**
1395
+ * Represents the http options that can be passed to a node http client.
1396
+ * @public
1397
+ */
1398
+ interface NodeHttpHandlerOptions {
1399
+ /**
1400
+ * The maximum time in milliseconds that the connection phase of a request
1401
+ * may take before the connection attempt is abandoned.
1402
+ * Defaults to 0, which disables the timeout.
1403
+ */
1404
+ connectionTimeout?: number;
1405
+ /**
1406
+ * The maximum number of milliseconds request & response should take.
1407
+ * Defaults to 0, which disables the timeout.
1408
+ *
1409
+ * If exceeded, a warning will be emitted unless throwOnRequestTimeout=true,
1410
+ * in which case a TimeoutError will be thrown.
1411
+ */
1412
+ requestTimeout?: number;
1413
+ /**
1414
+ * Because requestTimeout was for a long time incorrectly being set as a socket idle timeout,
1415
+ * users must also opt-in for request timeout thrown errors.
1416
+ * Without this setting, a breach of the request timeout will be logged as a warning.
1417
+ */
1418
+ throwOnRequestTimeout?: boolean;
1419
+ /**
1420
+ * The maximum time in milliseconds that a socket may remain idle before it
1421
+ * is closed. Defaults to 0, which means no maximum.
1422
+ *
1423
+ * This does not affect the server, which may still close the connection due to an idle socket.
1424
+ */
1425
+ socketTimeout?: number;
1426
+ /**
1427
+ * Delay before the NodeHttpHandler checks for socket exhaustion,
1428
+ * and emits a warning if the active sockets and enqueued request count is greater than
1429
+ * 2x the maxSockets count.
1430
+ *
1431
+ * Defaults to connectionTimeout + requestTimeout or 3000ms if those are not set.
1432
+ */
1433
+ socketAcquisitionWarningTimeout?: number;
1434
+ /**
1435
+ * You can pass http.Agent or its constructor options.
1436
+ */
1437
+ httpAgent?: Agent | AgentOptions;
1438
+ /**
1439
+ * You can pass https.Agent or its constructor options.
1440
+ */
1441
+ httpsAgent?: Agent$1 | AgentOptions$1;
1442
+ /**
1443
+ * Optional logger.
1444
+ */
1445
+ logger?: Logger;
1446
+ }
1447
+ /**
1448
+ * Represents the http options that can be passed to a browser http client.
1449
+ * @public
1450
+ */
1451
+ interface FetchHttpHandlerOptions {
1452
+ /**
1453
+ * The number of milliseconds a request can take before being automatically
1454
+ * terminated.
1455
+ */
1456
+ requestTimeout?: number;
1457
+ /**
1458
+ * Whether to allow the request to outlive the page. Default value is false.
1459
+ *
1460
+ * There may be limitations to the payload size, number of concurrent requests,
1461
+ * request duration etc. when using keepalive in browsers.
1462
+ *
1463
+ * These may change over time, so look for up to date information about
1464
+ * these limitations before enabling keepalive.
1465
+ */
1466
+ keepAlive?: boolean;
1467
+ /**
1468
+ * A string indicating whether credentials will be sent with the request always, never, or
1469
+ * only when sent to a same-origin URL.
1470
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials
1471
+ */
1472
+ credentials?: "include" | "omit" | "same-origin" | undefined | string;
1473
+ /**
1474
+ * Cache settings for fetch.
1475
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Request/cache
1476
+ */
1477
+ cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
1478
+ /**
1479
+ * An optional function that produces additional RequestInit
1480
+ * parameters for each httpRequest.
1481
+ *
1482
+ * This is applied last via merging with Object.assign() and overwrites other values
1483
+ * set from other sources.
1484
+ *
1485
+ * @example
1486
+ * ```js
1487
+ * new Client({
1488
+ * requestHandler: {
1489
+ * requestInit(httpRequest) {
1490
+ * return { cache: "no-store" };
1491
+ * }
1492
+ * }
1493
+ * });
1494
+ * ```
1495
+ */
1496
+ requestInit?: (httpRequest: HttpRequest$1) => RequestInit;
1497
+ /**
1498
+ * An optional custom fetch implementation to use in place of the
1499
+ * global fetch function.
1500
+ *
1501
+ * @example
1502
+ * ```js
1503
+ * new Client({
1504
+ * requestHandler: {
1505
+ * customFetch: (request) => myFetchImplementation(request)
1506
+ * }
1507
+ * });
1508
+ * ```
1509
+ */
1510
+ customFetch?: typeof fetch;
1511
+ }
1512
+ declare global {
1513
+ /**
1514
+ * interface merging stub.
1515
+ */
1516
+ interface RequestInit {
1517
+ }
1518
+ }
1519
+
1520
+ /**
1521
+ * @internal
1522
+ */
1523
+ interface TokenIdentity extends Identity {
1524
+ /**
1525
+ * The literal token string
1526
+ */
1527
+ readonly token: string;
1528
+ }
1529
+
1530
+ /**
1531
+ * Interface for object requires an Endpoint set.
1532
+ *
1533
+ * @public
1534
+ */
1535
+ interface EndpointBearer {
1536
+ endpoint: Provider<Endpoint>;
1537
+ }
1538
+ /**
1539
+ * @public
1540
+ */
1541
+ interface StreamCollector {
1542
+ /**
1543
+ * A function that converts a stream into an array of bytes.
1544
+ *
1545
+ * @param stream - The low-level native stream from browser or Nodejs runtime
1546
+ */
1547
+ (stream: any): Promise<Uint8Array>;
1548
+ }
1549
+ /**
1550
+ * Serde functions from the client config.
1551
+ *
1552
+ * @public
1553
+ */
1554
+ interface SerdeFunctions {
1555
+ base64Encoder: Encoder;
1556
+ base64Decoder: Decoder;
1557
+ utf8Encoder: Encoder;
1558
+ utf8Decoder: Decoder;
1559
+ streamCollector: StreamCollector;
1560
+ }
1561
+
1562
+ /**
1563
+ * The blob Smithy type, in JS as Uint8Array and other representations
1564
+ * such as Buffer, string, or Readable(Stream) depending on circumstances.
1565
+ * @public
1566
+ */
1567
+ type BlobSchema = 0b0001_0101;
1568
+ /**
1569
+ * @public
1570
+ */
1571
+ type StreamingBlobSchema = 0b0010_1010;
1572
+ /**
1573
+ * @public
1574
+ */
1575
+ type BooleanSchema = 0b0000_0010;
1576
+ /**
1577
+ * Includes string and enum Smithy types.
1578
+ * @public
1579
+ */
1580
+ type StringSchema = 0b0000_0000;
1581
+ /**
1582
+ * Includes all numeric Smithy types except bigInteger and bigDecimal.
1583
+ * byte, short, integer, long, float, double, intEnum.
1584
+ *
1585
+ * @public
1586
+ */
1587
+ type NumericSchema = 0b0000_0001;
1588
+ /**
1589
+ * @public
1590
+ */
1591
+ type BigIntegerSchema = 0b0001_0001;
1592
+ /**
1593
+ * @public
1594
+ */
1595
+ type BigDecimalSchema = 0b0001_0011;
1596
+ /**
1597
+ * @public
1598
+ */
1599
+ type DocumentSchema = 0b0000_1111;
1600
+ /**
1601
+ * Smithy type timestamp, in JS as native Date object.
1602
+ * @public
1603
+ */
1604
+ type TimestampDefaultSchema = 0b0000_0100;
1605
+ /**
1606
+ * @public
1607
+ */
1608
+ type TimestampDateTimeSchema = 0b0000_0101;
1609
+ /**
1610
+ * @public
1611
+ */
1612
+ type TimestampHttpDateSchema = 0b0000_0110;
1613
+ /**
1614
+ * @public
1615
+ */
1616
+ type TimestampEpochSecondsSchema = 0b0000_0111;
1617
+
1618
+ /**
1619
+ * @public
1620
+ */
1621
+ type StaticSchemaIdSimple = 0;
1622
+ /**
1623
+ * @public
1624
+ */
1625
+ type StaticSchemaIdList = 1;
1626
+ /**
1627
+ * @public
1628
+ */
1629
+ type StaticSchemaIdMap = 2;
1630
+ /**
1631
+ * @public
1632
+ */
1633
+ type StaticSchemaIdStruct = 3;
1634
+ /**
1635
+ * @public
1636
+ */
1637
+ type StaticSchemaIdUnion = 4;
1638
+ /**
1639
+ * @public
1640
+ */
1641
+ type StaticSchemaIdError = -3;
1642
+ /**
1643
+ * @public
1644
+ */
1645
+ type StaticSchemaIdOperation = 9;
1646
+ /**
1647
+ * @public
1648
+ */
1649
+ type StaticSchema = StaticSimpleSchema | StaticListSchema | StaticMapSchema | StaticStructureSchema | StaticUnionSchema | StaticErrorSchema | StaticOperationSchema;
1650
+ /**
1651
+ * @public
1652
+ */
1653
+ type ShapeName = string;
1654
+ /**
1655
+ * @public
1656
+ */
1657
+ type ShapeNamespace = string;
1658
+ /**
1659
+ * @public
1660
+ */
1661
+ type StaticSimpleSchema = [StaticSchemaIdSimple, ShapeNamespace, ShapeName, SchemaTraits, $SchemaRef];
1662
+ /**
1663
+ * @public
1664
+ */
1665
+ type StaticListSchema = [StaticSchemaIdList, ShapeNamespace, ShapeName, SchemaTraits, $SchemaRef];
1666
+ /**
1667
+ * @public
1668
+ */
1669
+ type StaticMapSchema = [StaticSchemaIdMap, ShapeNamespace, ShapeName, SchemaTraits, $SchemaRef, $SchemaRef];
1670
+ /**
1671
+ * @public
1672
+ */
1673
+ type StaticStructureSchema = [
1674
+ StaticSchemaIdStruct,
1675
+ ShapeNamespace,
1676
+ ShapeName,
1677
+ SchemaTraits,
1678
+ string[],
1679
+ $SchemaRef[],
1680
+ number?
1681
+ ];
1682
+ /**
1683
+ * @public
1684
+ */
1685
+ type StaticUnionSchema = [
1686
+ StaticSchemaIdUnion,
1687
+ ShapeNamespace,
1688
+ ShapeName,
1689
+ SchemaTraits,
1690
+ string[],
1691
+ $SchemaRef[]
1692
+ ];
1693
+ /**
1694
+ * @public
1695
+ */
1696
+ type StaticErrorSchema = [
1697
+ StaticSchemaIdError,
1698
+ ShapeNamespace,
1699
+ ShapeName,
1700
+ SchemaTraits,
1701
+ string[],
1702
+ $SchemaRef[],
1703
+ number?
1704
+ ];
1705
+ /**
1706
+ * @public
1707
+ */
1708
+ type StaticOperationSchema = [
1709
+ StaticSchemaIdOperation,
1710
+ ShapeNamespace,
1711
+ ShapeName,
1712
+ SchemaTraits,
1713
+ $SchemaRef,
1714
+ $SchemaRef
1715
+ ];
1716
+
1717
+ /**
1718
+ * A bitvector representing a traits object.
1719
+ *
1720
+ * Vector index to trait:
1721
+ * 0 - httpLabel
1722
+ * 1 - idempotent
1723
+ * 2 - idempotencyToken
1724
+ * 3 - sensitive
1725
+ * 4 - httpPayload
1726
+ * 5 - httpResponseCode
1727
+ * 6 - httpQueryParams
1728
+ *
1729
+ * The singular trait values are enumerated for quick identification, but
1730
+ * combination values are left to the `number` union type.
1731
+ *
1732
+ * @public
1733
+ */
1734
+ type TraitBitVector = HttpLabelBitMask | IdempotentBitMask | IdempotencyTokenBitMask | SensitiveBitMask | HttpPayloadBitMask | HttpResponseCodeBitMask | HttpQueryParamsBitMask | number;
1735
+ /**
1736
+ * @public
1737
+ */
1738
+ type HttpLabelBitMask = 1;
1739
+ /**
1740
+ * @public
1741
+ */
1742
+ type IdempotentBitMask = 2;
1743
+ /**
1744
+ * @public
1745
+ */
1746
+ type IdempotencyTokenBitMask = 4;
1747
+ /**
1748
+ * @public
1749
+ */
1750
+ type SensitiveBitMask = 8;
1751
+ /**
1752
+ * @public
1753
+ */
1754
+ type HttpPayloadBitMask = 16;
1755
+ /**
1756
+ * @public
1757
+ */
1758
+ type HttpResponseCodeBitMask = 32;
1759
+ /**
1760
+ * @public
1761
+ */
1762
+ type HttpQueryParamsBitMask = 64;
1763
+
1764
+ /**
1765
+ * A schema is an object or value that describes how to serialize/deserialize data.
1766
+ * @public
1767
+ */
1768
+ type $Schema = UnitSchema | SimpleSchema | $MemberSchema | StaticSchema | NormalizedSchema$1;
1769
+ /**
1770
+ * Traits attached to schema objects.
1771
+ *
1772
+ * When this is a number, it refers to a pre-allocated
1773
+ * trait combination that is equivalent to one of the
1774
+ * object type's variations.
1775
+ *
1776
+ * @public
1777
+ */
1778
+ type SchemaTraits = TraitBitVector | SchemaTraitsObject;
1779
+ /**
1780
+ * Simple schemas are those corresponding to simple Smithy types.
1781
+ * @see https://smithy.io/2.0/spec/simple-types.html
1782
+ * @public
1783
+ */
1784
+ type SimpleSchema = BlobSchemas | StringSchema | BooleanSchema | NumericSchema | BigIntegerSchema | BigDecimalSchema | DocumentSchema | TimestampSchemas | number;
1785
+ /**
1786
+ * Sentinel value for Timestamp schema.
1787
+ * "Default" means unspecified and to use the protocol serializer's default format.
1788
+ *
1789
+ * @public
1790
+ */
1791
+ type TimestampSchemas = TimestampDefaultSchema | TimestampDateTimeSchema | TimestampHttpDateSchema | TimestampEpochSecondsSchema;
1792
+ /**
1793
+ * Sentinel values for Blob schema.
1794
+ * @public
1795
+ */
1796
+ type BlobSchemas = BlobSchema | StreamingBlobSchema;
1797
+ /**
1798
+ * Signal value for the Smithy void value. Typically used for
1799
+ * operation input and outputs.
1800
+ *
1801
+ * @public
1802
+ */
1803
+ type UnitSchema = "unit";
1804
+ /**
1805
+ * See https://smithy.io/2.0/trait-index.html for individual definitions.
1806
+ *
1807
+ * @public
1808
+ */
1809
+ type SchemaTraitsObject = {
1810
+ idempotent?: 1;
1811
+ idempotencyToken?: 1;
1812
+ sensitive?: 1;
1813
+ sparse?: 1;
1814
+ /**
1815
+ * timestampFormat is expressed by the schema sentinel values of 4, 5, 6, and 7,
1816
+ * and not contained in trait objects.
1817
+ * @deprecated use schema value.
1818
+ */
1819
+ timestampFormat?: never;
1820
+ httpLabel?: 1;
1821
+ httpHeader?: string;
1822
+ httpQuery?: string;
1823
+ httpPrefixHeaders?: string;
1824
+ httpQueryParams?: 1;
1825
+ httpPayload?: 1;
1826
+ /**
1827
+ * [method, path, statusCode]
1828
+ */
1829
+ http?: [string, string, number];
1830
+ httpResponseCode?: 1;
1831
+ /**
1832
+ * [hostPrefix]
1833
+ */
1834
+ endpoint?: [string];
1835
+ xmlAttribute?: 1;
1836
+ xmlName?: string;
1837
+ /**
1838
+ * [prefix, uri]
1839
+ */
1840
+ xmlNamespace?: [string, string];
1841
+ xmlFlattened?: 1;
1842
+ jsonName?: string;
1843
+ mediaType?: string;
1844
+ error?: "client" | "server";
1845
+ streaming?: 1;
1846
+ eventHeader?: 1;
1847
+ eventPayload?: 1;
1848
+ [traitName: string]: unknown;
1849
+ };
1850
+ /**
1851
+ * Indicates the schema is a member of a parent Structure schema.
1852
+ * It may also have a set of member traits distinct from its target shape's traits.
1853
+ * @public
1854
+ */
1855
+ type $MemberSchema = [$SchemaRef, SchemaTraits];
1856
+ /**
1857
+ * Normalization wrapper for various schema data objects.
1858
+ * @public
1859
+ */
1860
+ interface NormalizedSchema$1 {
1861
+ getSchema(): $Schema;
1862
+ getName(): string | undefined;
1863
+ isMemberSchema(): boolean;
1864
+ isListSchema(): boolean;
1865
+ isMapSchema(): boolean;
1866
+ isStructSchema(): boolean;
1867
+ isBlobSchema(): boolean;
1868
+ isTimestampSchema(): boolean;
1869
+ isStringSchema(): boolean;
1870
+ isBooleanSchema(): boolean;
1871
+ isNumericSchema(): boolean;
1872
+ isBigIntegerSchema(): boolean;
1873
+ isBigDecimalSchema(): boolean;
1874
+ isStreaming(): boolean;
1875
+ getMergedTraits(): SchemaTraitsObject;
1876
+ getMemberTraits(): SchemaTraitsObject;
1877
+ getOwnTraits(): SchemaTraitsObject;
1878
+ /**
1879
+ * For list/set/map.
1880
+ */
1881
+ getValueSchema(): NormalizedSchema$1;
1882
+ /**
1883
+ * For struct/union.
1884
+ */
1885
+ getMemberSchema(member: string): NormalizedSchema$1 | undefined;
1886
+ structIterator(): Generator<[string, NormalizedSchema$1], undefined, undefined>;
1887
+ }
1888
+ /**
1889
+ * A schema "reference" is either a schema or a function that
1890
+ * provides a schema. This is useful for lazy loading, and to allow
1891
+ * code generation to define schema out of dependency order.
1892
+ * @public
1893
+ */
1894
+ type $SchemaRef = $Schema | (() => $Schema);
1895
+ /**
1896
+ * A codec creates serializers and deserializers for some format such as JSON, XML, or CBOR.
1897
+ *
1898
+ * @public
1899
+ */
1900
+ interface $Codec<S, D> extends ConfigurableSerdeContext {
1901
+ createSerializer(): $ShapeSerializer<S>;
1902
+ createDeserializer(): $ShapeDeserializer<D>;
1903
+ }
1904
+ /**
1905
+ * Configuration for codecs. Different protocols may share codecs, but require different behaviors from them.
1906
+ *
1907
+ * @public
1908
+ */
1909
+ type CodecSettings = {
1910
+ timestampFormat: {
1911
+ /**
1912
+ * Whether to use member timestamp format traits.
1913
+ */
1914
+ useTrait: boolean;
1915
+ /**
1916
+ * Default timestamp format.
1917
+ */
1918
+ default: TimestampDateTimeSchema | TimestampHttpDateSchema | TimestampEpochSecondsSchema;
1919
+ };
1920
+ /**
1921
+ * Whether to use HTTP binding traits.
1922
+ */
1923
+ httpBindings?: boolean;
1924
+ };
1925
+ /**
1926
+ * Turns a serialization into a data object.
1927
+ * @public
1928
+ */
1929
+ interface $ShapeDeserializer<SerializationType = Uint8Array> extends ConfigurableSerdeContext {
1930
+ /**
1931
+ * Optionally async.
1932
+ */
1933
+ read(schema: $Schema, data: SerializationType): any | Promise<any>;
1934
+ }
1935
+ /**
1936
+ * Turns a data object into a serialization.
1937
+ * @public
1938
+ */
1939
+ interface $ShapeSerializer<SerializationType = Uint8Array> extends ConfigurableSerdeContext {
1940
+ write(schema: $Schema, value: unknown): void;
1941
+ flush(): SerializationType;
1942
+ }
1943
+ /**
1944
+ * Allows a protocol, codec, or serde utility to accept the serdeContext
1945
+ * from a client configuration or request/response handlerExecutionContext.
1946
+ *
1947
+ * @public
1948
+ */
1949
+ interface ConfigurableSerdeContext {
1950
+ setSerdeContext(serdeContext: SerdeFunctions): void;
1951
+ }
1952
+
1953
+ /**
1954
+ * A schema is an object or value that describes how to serialize/deserialize data.
1955
+ * @internal
1956
+ * @deprecated use $Schema
1957
+ */
1958
+ type Schema$1 = UnitSchema | TraitsSchema | SimpleSchema | ListSchema | MapSchema | StructureSchema$1 | MemberSchema | OperationSchema | StaticSchema | NormalizedSchema$1;
1959
+ /**
1960
+ * A schema "reference" is either a schema or a function that
1961
+ * provides a schema. This is useful for lazy loading, and to allow
1962
+ * code generation to define schema out of dependency order.
1963
+ * @internal
1964
+ * @deprecated use $SchemaRef
1965
+ */
1966
+ type SchemaRef = Schema$1 | (() => Schema$1);
1967
+ /**
1968
+ * A schema that has traits.
1969
+ *
1970
+ * @internal
1971
+ * @deprecated use static schema.
1972
+ */
1973
+ interface TraitsSchema {
1974
+ namespace: string;
1975
+ name: string;
1976
+ traits: SchemaTraits;
1977
+ }
1978
+ /**
1979
+ * Indicates the schema is a member of a parent Structure schema.
1980
+ * It may also have a set of member traits distinct from its target shape's traits.
1981
+ * @internal
1982
+ * @deprecated use $MemberSchema
1983
+ */
1984
+ type MemberSchema = [SchemaRef, SchemaTraits];
1985
+ /**
1986
+ * Schema for the structure aggregate type.
1987
+ * @internal
1988
+ * @deprecated use static schema.
1989
+ */
1990
+ interface StructureSchema$1 extends TraitsSchema {
1991
+ memberNames: string[];
1992
+ memberList: SchemaRef[];
1993
+ /**
1994
+ * @deprecated structure member iteration will be linear on the memberNames and memberList arrays.
1995
+ * It can be collected into a hashmap form on an ad-hoc basis, but will not initialize as such.
1996
+ */
1997
+ members?: Record<string, [SchemaRef, SchemaTraits]> | undefined;
1998
+ }
1999
+ /**
2000
+ * Schema for the list aggregate type.
2001
+ * @internal
2002
+ * @deprecated use static schema.
2003
+ */
2004
+ interface ListSchema extends TraitsSchema {
2005
+ valueSchema: SchemaRef;
2006
+ }
2007
+ /**
2008
+ * Schema for the map aggregate type.
2009
+ * @internal
2010
+ * @deprecated use static schema.
2011
+ */
2012
+ interface MapSchema extends TraitsSchema {
2013
+ keySchema: SchemaRef;
2014
+ valueSchema: SchemaRef;
2015
+ }
2016
+ /**
2017
+ * Schema for an operation.
2018
+ * @internal
2019
+ * @deprecated use StaticOperationSchema or $OperationSchema
2020
+ */
2021
+ interface OperationSchema {
2022
+ namespace: string;
2023
+ name: string;
2024
+ traits: SchemaTraits;
2025
+ input: SchemaRef;
2026
+ output: SchemaRef;
2027
+ }
2028
+ /**
2029
+ * Turns a serialization into a data object.
2030
+ * @internal
2031
+ * @deprecated use $ShapeDeserializer
2032
+ */
2033
+ interface ShapeDeserializer<SerializationType = Uint8Array> extends ConfigurableSerdeContext {
2034
+ /**
2035
+ * Optionally async.
2036
+ */
2037
+ read(schema: Schema$1, data: SerializationType): any | Promise<any>;
2038
+ }
2039
+ /**
2040
+ * Turns a data object into a serialization.
2041
+ * @internal
2042
+ * @deprecated use $ShapeSerializer
2043
+ */
2044
+ interface ShapeSerializer<SerializationType = Uint8Array> extends ConfigurableSerdeContext {
2045
+ write(schema: Schema$1, value: unknown): void;
2046
+ flush(): SerializationType;
2047
+ }
2048
+ /**
2049
+ * A codec creates serializers and deserializers for some format such as JSON, XML, or CBOR.
2050
+ *
2051
+ * @internal
2052
+ * @deprecated use $Codec
2053
+ */
2054
+ interface Codec<S, D> extends ConfigurableSerdeContext {
2055
+ createSerializer(): ShapeSerializer<S>;
2056
+ createDeserializer(): ShapeDeserializer<D>;
2057
+ }
2058
+ /**
2059
+ * A client protocol defines how to convert a message (e.g. HTTP request/response) to and from a data object.
2060
+ * @internal
2061
+ * @deprecated use $ClientProtocol
2062
+ */
2063
+ interface ClientProtocol<Request, Response> extends ConfigurableSerdeContext {
2064
+ /**
2065
+ * @returns the Smithy qualified shape id.
2066
+ */
2067
+ getShapeId(): string;
2068
+ getRequestType(): {
2069
+ new (...args: any[]): Request;
2070
+ };
2071
+ getResponseType(): {
2072
+ new (...args: any[]): Response;
2073
+ };
2074
+ /**
2075
+ * @returns the payload codec if the requests/responses have a symmetric format.
2076
+ * It otherwise may return null.
2077
+ */
2078
+ getPayloadCodec(): Codec<any, any>;
2079
+ serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<Request>;
2080
+ updateServiceEndpoint(request: Request, endpoint: EndpointV2): Request;
2081
+ deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: Response): Promise<Output>;
2082
+ }
2083
+
2084
+ type HttpRequestOptions = Partial<HttpMessage> & Partial<URI> & {
2085
+ method?: string;
2086
+ };
2087
+
2088
+ /**
2089
+ * Use the distinct IHttpRequest interface from \@smithy/types instead.
2090
+ * This should not be used due to
2091
+ * overlapping with the concrete class' name.
2092
+ *
2093
+ * This is not marked deprecated since that would mark the concrete class
2094
+ * deprecated as well.
2095
+ *
2096
+ * @internal
2097
+ */
2098
+ interface HttpRequest extends HttpRequest$1 {
2099
+ }
2100
+ /**
2101
+ * @public
2102
+ */
2103
+ declare class HttpRequest implements HttpMessage, URI {
2104
+ method: string;
2105
+ protocol: string;
2106
+ hostname: string;
2107
+ port?: number;
2108
+ path: string;
2109
+ query: QueryParameterBag;
2110
+ headers: HeaderBag;
2111
+ username?: string;
2112
+ password?: string;
2113
+ fragment?: string;
2114
+ body?: any;
2115
+ constructor(options: HttpRequestOptions);
2116
+ /**
2117
+ * Note: this does not deep-clone the body.
2118
+ */
2119
+ static clone(request: HttpRequest$1): HttpRequest;
2120
+ /**
2121
+ * This method only actually asserts that request is the interface {@link IHttpRequest},
2122
+ * and not necessarily this concrete class. Left in place for API stability.
2123
+ *
2124
+ * Do not call instance methods on the input of this function, and
2125
+ * do not assume it has the HttpRequest prototype.
2126
+ */
2127
+ static isInstance(request: unknown): request is HttpRequest;
2128
+ /**
2129
+ * @deprecated use static HttpRequest.clone(request) instead. It's not safe to call
2130
+ * this method because {@link HttpRequest.isInstance} incorrectly
2131
+ * asserts that IHttpRequest (interface) objects are of type HttpRequest (class).
2132
+ */
2133
+ clone(): HttpRequest;
2134
+ }
2135
+
2136
+ type HttpResponseOptions = Partial<HttpMessage> & {
2137
+ statusCode: number;
2138
+ reason?: string;
2139
+ };
2140
+ /**
2141
+ * Use the distinct IHttpResponse interface from \@smithy/types instead.
2142
+ * This should not be used due to
2143
+ * overlapping with the concrete class' name.
2144
+ *
2145
+ * This is not marked deprecated since that would mark the concrete class
2146
+ * deprecated as well.
2147
+ *
2148
+ * @internal
2149
+ */
2150
+ interface HttpResponse extends HttpResponse$1 {
2151
+ }
2152
+ /**
2153
+ * @public
2154
+ */
2155
+ declare class HttpResponse {
2156
+ statusCode: number;
2157
+ reason?: string;
2158
+ headers: HeaderBag;
2159
+ body?: any;
2160
+ constructor(options: HttpResponseOptions);
2161
+ static isInstance(response: unknown): response is HttpResponse;
2162
+ }
2163
+
2164
+ /**
2165
+ * Abstract base for class-based Schema except NormalizedSchema.
2166
+ *
2167
+ * @internal
2168
+ * @deprecated use StaticSchema
2169
+ */
2170
+ declare abstract class Schema implements TraitsSchema {
2171
+ name: string;
2172
+ namespace: string;
2173
+ traits: SchemaTraits;
2174
+ protected abstract readonly symbol: symbol;
2175
+ static assign<T extends Schema>(instance: T, values: Omit<T, "getName" | "symbol">): T;
2176
+ static [Symbol.hasInstance](lhs: unknown): boolean;
2177
+ getName(): string;
2178
+ }
2179
+
2180
+ /**
2181
+ * A structure schema has a known list of members. This is also used for unions.
2182
+ *
2183
+ * @internal
2184
+ * @deprecated use StaticSchema
2185
+ */
2186
+ declare class StructureSchema extends Schema implements StructureSchema$1 {
2187
+ static symbol: symbol;
2188
+ name: string;
2189
+ traits: SchemaTraits;
2190
+ memberNames: string[];
2191
+ memberList: SchemaRef[];
2192
+ protected readonly symbol: symbol;
2193
+ }
2194
+
2195
+ /**
2196
+ * A schema for a structure shape having the error trait. These represent enumerated operation errors.
2197
+ * Because Smithy-TS SDKs use classes for exceptions, whereas plain objects are used for all other data,
2198
+ * and have an existing notion of a XYZServiceBaseException, the ErrorSchema differs from a StructureSchema
2199
+ * by additionally holding the class reference for the corresponding ServiceException class.
2200
+ *
2201
+ * @internal
2202
+ * @deprecated use StaticSchema
2203
+ */
2204
+ declare class ErrorSchema extends StructureSchema {
2205
+ static readonly symbol: unique symbol;
2206
+ /**
2207
+ * @deprecated - field unused.
2208
+ */
2209
+ ctor: any;
2210
+ protected readonly symbol: symbol;
2211
+ }
2212
+
2213
+ /**
2214
+ * Wraps both class instances, numeric sentinel values, and member schema pairs.
2215
+ * Presents a consistent interface for interacting with polymorphic schema representations.
2216
+ *
2217
+ * @public
2218
+ */
2219
+ declare class NormalizedSchema implements NormalizedSchema$1 {
2220
+ readonly ref: $SchemaRef;
2221
+ private readonly memberName?;
2222
+ static readonly symbol: unique symbol;
2223
+ protected readonly symbol: symbol;
2224
+ private readonly name;
2225
+ private readonly schema;
2226
+ private readonly _isMemberSchema;
2227
+ private readonly traits;
2228
+ private readonly memberTraits;
2229
+ private normalizedTraits?;
2230
+ /**
2231
+ * @param ref - a polymorphic SchemaRef to be dereferenced/normalized.
2232
+ * @param memberName - optional memberName if this NormalizedSchema should be considered a member schema.
2233
+ */
2234
+ private constructor();
2235
+ static [Symbol.hasInstance](lhs: unknown): lhs is NormalizedSchema;
2236
+ /**
2237
+ * Static constructor that attempts to avoid wrapping a NormalizedSchema within another.
2238
+ */
2239
+ static of(ref: SchemaRef | $SchemaRef): NormalizedSchema;
2240
+ /**
2241
+ * @returns the underlying non-normalized schema.
2242
+ */
2243
+ getSchema(): Exclude<$Schema, $MemberSchema | NormalizedSchema$1>;
2244
+ /**
2245
+ * @param withNamespace - qualifies the name.
2246
+ * @returns e.g. `MyShape` or `com.namespace#MyShape`.
2247
+ */
2248
+ getName(withNamespace?: boolean): string | undefined;
2249
+ /**
2250
+ * @returns the member name if the schema is a member schema.
2251
+ */
2252
+ getMemberName(): string;
2253
+ isMemberSchema(): boolean;
2254
+ /**
2255
+ * boolean methods on this class help control flow in shape serialization and deserialization.
2256
+ */
2257
+ isListSchema(): boolean;
2258
+ isMapSchema(): boolean;
2259
+ /**
2260
+ * To simplify serialization logic, static union schemas are considered a specialization
2261
+ * of structs in the TypeScript typings and JS runtime, as well as static error schemas
2262
+ * which have a different identifier.
2263
+ */
2264
+ isStructSchema(): boolean;
2265
+ isUnionSchema(): boolean;
2266
+ isBlobSchema(): boolean;
2267
+ isTimestampSchema(): boolean;
2268
+ isUnitSchema(): boolean;
2269
+ isDocumentSchema(): boolean;
2270
+ isStringSchema(): boolean;
2271
+ isBooleanSchema(): boolean;
2272
+ isNumericSchema(): boolean;
2273
+ isBigIntegerSchema(): boolean;
2274
+ isBigDecimalSchema(): boolean;
2275
+ isStreaming(): boolean;
2276
+ /**
2277
+ * @returns whether the schema has the idempotencyToken trait.
2278
+ */
2279
+ isIdempotencyToken(): boolean;
2280
+ /**
2281
+ * @returns own traits merged with member traits, where member traits of the same trait key take priority.
2282
+ * This method is cached.
2283
+ */
2284
+ getMergedTraits(): SchemaTraitsObject;
2285
+ /**
2286
+ * @returns only the member traits. If the schema is not a member, this returns empty.
2287
+ */
2288
+ getMemberTraits(): SchemaTraitsObject;
2289
+ /**
2290
+ * @returns only the traits inherent to the shape or member target shape if this schema is a member.
2291
+ * If there are any member traits they are excluded.
2292
+ */
2293
+ getOwnTraits(): SchemaTraitsObject;
2294
+ /**
2295
+ * @returns the map's key's schema. Returns a dummy Document schema if this schema is a Document.
2296
+ *
2297
+ * @throws Error if the schema is not a Map or Document.
2298
+ */
2299
+ getKeySchema(): NormalizedSchema;
2300
+ /**
2301
+ * @returns the schema of the map's value or list's member.
2302
+ * Returns a dummy Document schema if this schema is a Document.
2303
+ *
2304
+ * @throws Error if the schema is not a Map, List, nor Document.
2305
+ */
2306
+ getValueSchema(): NormalizedSchema;
2307
+ /**
2308
+ * @returns the NormalizedSchema for the given member name. The returned instance will return true for `isMemberSchema()`
2309
+ * and will have the member name given.
2310
+ * @param memberName - which member to retrieve and wrap.
2311
+ *
2312
+ * @throws Error if member does not exist or the schema is neither a document nor structure.
2313
+ * Note that errors are assumed to be structures and unions are considered structures for these purposes.
2314
+ */
2315
+ getMemberSchema(memberName: string): NormalizedSchema;
2316
+ /**
2317
+ * This can be used for checking the members as a hashmap.
2318
+ * Prefer the structIterator method for iteration.
2319
+ *
2320
+ * This does NOT return list and map members, it is only for structures.
2321
+ *
2322
+ * @deprecated use (checked) structIterator instead.
2323
+ *
2324
+ * @returns a map of member names to member schemas (normalized).
2325
+ */
2326
+ getMemberSchemas(): Record<string, NormalizedSchema>;
2327
+ /**
2328
+ * @returns member name of event stream or empty string indicating none exists or this
2329
+ * isn't a structure schema.
2330
+ */
2331
+ getEventStreamMember(): string;
2332
+ /**
2333
+ * Allows iteration over members of a structure schema.
2334
+ * Each yield is a pair of the member name and member schema.
2335
+ *
2336
+ * This avoids the overhead of calling Object.entries(ns.getMemberSchemas()).
2337
+ */
2338
+ structIterator(): Generator<[string, NormalizedSchema], undefined, undefined>;
2339
+ }
2340
+
2341
+ /**
2342
+ * A way to look up schema by their ShapeId values.
2343
+ *
2344
+ * @public
2345
+ */
2346
+ declare class TypeRegistry {
2347
+ readonly namespace: string;
2348
+ private schemas;
2349
+ private exceptions;
2350
+ static readonly registries: Map<string, TypeRegistry>;
2351
+ constructor(namespace: string, schemas?: Map<string, Schema$1>, exceptions?: Map<StaticErrorSchema, any>);
2352
+ /**
2353
+ * @param namespace - specifier.
2354
+ * @returns the TypeRegistry for that namespace, creating it if necessary.
2355
+ */
2356
+ static for(namespace: string): TypeRegistry;
2357
+ /**
2358
+ * Copies entries from another instance without changing the namespace of self.
2359
+ * The composition is additive but non-destructive and will not overwrite existing entries.
2360
+ *
2361
+ * @param other - another TypeRegistry.
2362
+ */
2363
+ copyFrom(other: TypeRegistry): void;
2364
+ /**
2365
+ * Adds the given schema to a type registry with the same namespace, and this registry.
2366
+ *
2367
+ * @param shapeId - to be registered.
2368
+ * @param schema - to be registered.
2369
+ */
2370
+ register(shapeId: string, schema: Schema$1): void;
2371
+ /**
2372
+ * @param shapeId - query.
2373
+ * @returns the schema.
2374
+ */
2375
+ getSchema(shapeId: string): Schema$1;
2376
+ /**
2377
+ * Associates an error schema with its constructor.
2378
+ */
2379
+ registerError(es: ErrorSchema | StaticErrorSchema, ctor: any): void;
2380
+ /**
2381
+ * @param es - query.
2382
+ * @returns Error constructor that extends the service's base exception.
2383
+ */
2384
+ getErrorCtor(es: ErrorSchema | StaticErrorSchema): any;
2385
+ /**
2386
+ * The smithy-typescript code generator generates a synthetic (i.e. unmodeled) base exception,
2387
+ * because generated SDKs before the introduction of schemas have the notion of a ServiceBaseException, which
2388
+ * is unique per service/model.
2389
+ *
2390
+ * This is generated under a unique prefix that is combined with the service namespace, and this
2391
+ * method is used to retrieve it.
2392
+ *
2393
+ * The base exception synthetic schema is used when an error is returned by a service, but we cannot
2394
+ * determine what existing schema to use to deserialize it.
2395
+ *
2396
+ * @returns the synthetic base exception of the service namespace associated with this registry instance.
2397
+ */
2398
+ getBaseException(): StaticErrorSchema | undefined;
2399
+ /**
2400
+ * @param predicate - criterion.
2401
+ * @returns a schema in this registry matching the predicate.
2402
+ */
2403
+ find(predicate: (schema: Schema$1) => boolean): number | "unit" | MemberSchema | NormalizedSchema$1 | StaticErrorSchema | StaticListSchema | StaticMapSchema | StaticOperationSchema | StaticSimpleSchema | StaticStructureSchema | StaticUnionSchema | TraitsSchema | undefined;
2404
+ /**
2405
+ * Unloads the current TypeRegistry.
2406
+ */
2407
+ clear(): void;
2408
+ private normalizeShapeId;
2409
+ }
2410
+
2411
+ /**
2412
+ * Separated module for async mixin of EventStream serde capability.
2413
+ * This is used by the HttpProtocol base class from \@smithy/core/protocols.
2414
+ *
2415
+ * @public
2416
+ */
2417
+ declare class EventStreamSerde {
2418
+ private readonly marshaller;
2419
+ private readonly serializer;
2420
+ private readonly deserializer;
2421
+ private readonly serdeContext?;
2422
+ private readonly defaultContentType;
2423
+ private readonly compositeErrorRegistry?;
2424
+ /**
2425
+ * Properties are injected by the HttpProtocol.
2426
+ */
2427
+ constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, compositeErrorRegistry, }: {
2428
+ marshaller: EventStreamMarshaller;
2429
+ serializer: ShapeSerializer<string | Uint8Array>;
2430
+ deserializer: ShapeDeserializer<string | Uint8Array>;
2431
+ serdeContext?: SerdeFunctions;
2432
+ defaultContentType: string;
2433
+ compositeErrorRegistry?: TypeRegistry;
2434
+ });
2435
+ /**
2436
+ * @param eventStream - the iterable provided by the caller.
2437
+ * @param requestSchema - the schema of the event stream container (struct).
2438
+ * @param [initialRequest] - only provided if the initial-request is part of the event stream (RPC).
2439
+ *
2440
+ * @returns a stream suitable for the HTTP body of a request.
2441
+ */
2442
+ serializeEventStream({ eventStream, requestSchema, initialRequest, initialMessageType, }: {
2443
+ eventStream: AsyncIterable<any>;
2444
+ requestSchema: NormalizedSchema;
2445
+ initialRequest?: any;
2446
+ /**
2447
+ * The :event-type header value for the initial message.
2448
+ * Defaults to "initial-request" (client→server).
2449
+ * Server→client should pass "initial-response".
2450
+ */
2451
+ initialMessageType?: string;
2452
+ }): Promise<HttpRequest$1["body"] | Uint8Array>;
2453
+ /**
2454
+ * @param response - http response from which to read the event stream.
2455
+ * @param unionSchema - schema of the event stream container (struct).
2456
+ * @param [initialResponseContainer] - provided and written to only if the initial response is part of the event stream (RPC).
2457
+ *
2458
+ * @returns the asyncIterable of the event stream for the end-user.
2459
+ */
2460
+ deserializeEventStream({ response, responseSchema, initialResponseContainer, initialMessageType, }: {
2461
+ response: HttpResponse$1;
2462
+ responseSchema: NormalizedSchema;
2463
+ initialResponseContainer?: any;
2464
+ /**
2465
+ * The :event-type header value to match as the initial message.
2466
+ * Defaults to "initial-response" (server→client).
2467
+ * Server-side deserialization of client requests should pass "initial-request".
2468
+ */
2469
+ initialMessageType?: string;
2470
+ }): Promise<AsyncIterable<{
2471
+ [key: string]: any;
2472
+ $unknown?: unknown;
2473
+ }>>;
2474
+ /**
2475
+ * Reads and returns an event member. For error schemas, resolves the registered
2476
+ * error constructor from the TypeRegistry and wraps the deserialized value
2477
+ * so that it can be thrown as a typed exception instance by the caller.
2478
+ */
2479
+ private readEventMember;
2480
+ /**
2481
+ * @param unionMember - member name within the structure that contains an event stream union.
2482
+ * @param unionSchema - schema of the union.
2483
+ * @param event
2484
+ *
2485
+ * @returns the event body (bytes) and event type (string).
2486
+ */
2487
+ private writeEventBody;
2488
+ }
2489
+
2490
+ /**
2491
+ * This in practice should be the client config object.
2492
+ * @internal
2493
+ */
2494
+ type SerdeContextType = SerdeFunctions & {
2495
+ disableHostPrefix?: boolean;
2496
+ };
2497
+ /**
2498
+ * @internal
2499
+ */
2500
+ declare abstract class SerdeContext implements ConfigurableSerdeContext {
2501
+ protected serdeContext?: SerdeContextType;
2502
+ setSerdeContext(serdeContext: SerdeContextType): void;
2503
+ }
2504
+
2505
+ /**
2506
+ * Abstract base for HTTP-based client protocols.
2507
+ *
2508
+ * @public
2509
+ */
2510
+ declare abstract class HttpProtocol extends SerdeContext implements ClientProtocol<HttpRequest$1, HttpResponse$1> {
2511
+ readonly options: {
2512
+ defaultNamespace: string;
2513
+ errorTypeRegistries?: TypeRegistry[];
2514
+ };
2515
+ /**
2516
+ * An error registry having the namespace of the modeled service,
2517
+ * but combining all error schemas found within the service closure.
2518
+ *
2519
+ * Used to look up error schema during deserialization.
2520
+ */
2521
+ protected compositeErrorRegistry: TypeRegistry;
2522
+ protected abstract serializer: ShapeSerializer<string | Uint8Array>;
2523
+ protected abstract deserializer: ShapeDeserializer<string | Uint8Array>;
2524
+ /**
2525
+ * @param options.defaultNamespace - used by various implementing classes.
2526
+ * @param options.errorTypeRegistries - registry instances that contribute to error deserialization.
2527
+ */
2528
+ protected constructor(options: {
2529
+ defaultNamespace: string;
2530
+ errorTypeRegistries?: TypeRegistry[];
2531
+ });
2532
+ abstract getShapeId(): string;
2533
+ abstract getPayloadCodec(): Codec<any, any>;
2534
+ getRequestType(): new (...args: any[]) => HttpRequest$1;
2535
+ getResponseType(): new (...args: any[]) => HttpResponse$1;
2536
+ /**
2537
+ * @override
2538
+ */
2539
+ setSerdeContext(serdeContext: SerdeFunctions): void;
2540
+ abstract serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<HttpRequest$1>;
2541
+ updateServiceEndpoint(request: HttpRequest$1, endpoint: EndpointV2 | Endpoint): HttpRequest$1;
2542
+ abstract deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse$1): Promise<Output>;
2543
+ protected setHostPrefix<Input extends object>(request: HttpRequest$1, operationSchema: OperationSchema, input: Input): void;
2544
+ protected abstract handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse$1, dataObject: any, metadata: ResponseMetadata): Promise<never>;
2545
+ protected deserializeMetadata(output: HttpResponse$1): ResponseMetadata;
2546
+ /**
2547
+ * For a given error short name, a list of preferred namespaces, and a list of preferred registries,
2548
+ * find the error's schema and class.
2549
+ *
2550
+ * @param name - short error shape id.
2551
+ * @param namespaces - must contain '*' to allow matching against an undeclared namespace.
2552
+ * @param registries - in which to look.
2553
+ * @returns matched error schema and constructor, with worst case being the least-descriptive DocumentSchema and native Error.
2554
+ */
2555
+ protected resolveError(name: string, namespaces: string[], registries: TypeRegistry[]): [StaticErrorSchema, any, "modeled" | "synthetic" | "native"];
2556
+ /**
2557
+ * @param eventStream - the iterable provided by the caller.
2558
+ * @param requestSchema - the schema of the event stream container (struct).
2559
+ * @param [initialRequest] - only provided if the initial-request is part of the event stream (RPC).
2560
+ *
2561
+ * @returns a stream suitable for the HTTP body of a request.
2562
+ */
2563
+ protected serializeEventStream({ eventStream, requestSchema, initialRequest, }: {
2564
+ eventStream: AsyncIterable<any>;
2565
+ requestSchema: NormalizedSchema;
2566
+ initialRequest?: any;
2567
+ }): Promise<HttpRequest$1["body"]>;
2568
+ /**
2569
+ * @param response - http response from which to read the event stream.
2570
+ * @param unionSchema - schema of the event stream container (struct).
2571
+ * @param [initialResponseContainer] - provided and written to only if the initial response is part of the event stream (RPC).
2572
+ *
2573
+ * @returns the asyncIterable of the event stream.
2574
+ */
2575
+ protected deserializeEventStream({ response, responseSchema, initialResponseContainer, }: {
2576
+ response: HttpResponse$1;
2577
+ responseSchema: NormalizedSchema;
2578
+ initialResponseContainer?: any;
2579
+ }): Promise<AsyncIterable<{
2580
+ [key: string]: any;
2581
+ $unknown?: unknown;
2582
+ }>>;
2583
+ /**
2584
+ * Loads eventStream capability async (for chunking).
2585
+ */
2586
+ protected loadEventStreamCapability(): Promise<EventStreamSerde>;
2587
+ /**
2588
+ * @returns content-type default header value for event stream events and other documents.
2589
+ */
2590
+ protected getDefaultContentType(): string;
2591
+ /**
2592
+ * For HTTP binding protocols, this method is overridden in {@link HttpBindingProtocol}.
2593
+ *
2594
+ * @deprecated only use this for HTTP binding protocols.
2595
+ */
2596
+ protected deserializeHttpMessage(schema: Schema$1, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse$1, headerBindings: Set<string>, dataObject: any): Promise<string[]>;
2597
+ protected deserializeHttpMessage(schema: Schema$1, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse$1, dataObject: any): Promise<string[]>;
2598
+ protected getEventStreamMarshaller(): EventStreamMarshaller;
2599
+ /**
2600
+ * Returns a platform-specific EventStreamMarshaller.
2601
+ * Prefers user-injected marshaller from serdeContext (via client config),
2602
+ * falls back to the dynamically imported provider.
2603
+ */
2604
+ private resolveEventStreamMarshaller;
2605
+ }
2606
+
2607
+ /**
2608
+ * Base for HTTP-binding protocols. Downstream examples
2609
+ * include AWS REST JSON and AWS REST XML.
2610
+ *
2611
+ * @public
2612
+ */
2613
+ declare abstract class HttpBindingProtocol extends HttpProtocol {
2614
+ /**
2615
+ * @override
2616
+ */
2617
+ protected compositeErrorRegistry: TypeRegistry;
2618
+ serializeRequest<Input extends object>(operationSchema: OperationSchema, _input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<HttpRequest$1>;
2619
+ protected serializeQuery(ns: NormalizedSchema, data: any, query: HttpRequest["query"]): void;
2620
+ deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse$1): Promise<Output>;
2621
+ /**
2622
+ * The base method ignores HTTP bindings.
2623
+ *
2624
+ * @deprecated (only this signature) use signature without headerBindings.
2625
+ * @override
2626
+ */
2627
+ protected deserializeHttpMessage(schema: Schema$1, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse$1, headerBindings: Set<string>, dataObject: any): Promise<string[] & {
2628
+ discardResponseBody?: boolean;
2629
+ }>;
2630
+ protected deserializeHttpMessage(schema: Schema$1, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse$1, dataObject: any): Promise<string[] & {
2631
+ discardResponseBody?: boolean;
2632
+ }>;
2633
+ }
2634
+
2635
+ /**
2636
+ * This deserializer is a dispatcher that decides whether to use a string deserializer
2637
+ * or a codec deserializer based on HTTP traits.
2638
+ *
2639
+ * For example, in a JSON HTTP message, the deserialization of a field will differ depending on whether
2640
+ * it is bound to the HTTP header (string) or body (JSON).
2641
+ *
2642
+ * @public
2643
+ */
2644
+ declare class HttpInterceptingShapeDeserializer<CodecShapeDeserializer extends ShapeDeserializer<any>> extends SerdeContext implements ShapeDeserializer<string | Uint8Array> {
2645
+ private codecDeserializer;
2646
+ private stringDeserializer;
2647
+ constructor(codecDeserializer: CodecShapeDeserializer, codecSettings: CodecSettings);
2648
+ /**
2649
+ * @override
2650
+ */
2651
+ setSerdeContext(serdeContext: SerdeFunctions): void;
2652
+ read(schema: Schema$1, data: string | Uint8Array): any | Promise<any>;
2653
+ }
2654
+
2655
+ /**
2656
+ * Serializes a shape to string.
2657
+ *
2658
+ * @public
2659
+ */
2660
+ declare class ToStringShapeSerializer extends SerdeContext implements ShapeSerializer<string> {
2661
+ private settings;
2662
+ private stringBuffer;
2663
+ constructor(settings: CodecSettings);
2664
+ write(schema: Schema$1, value: unknown): void;
2665
+ flush(): string;
2666
+ }
2667
+
2668
+ /**
2669
+ * This serializer decides whether to dispatch to a string serializer or a codec serializer
2670
+ * depending on HTTP binding traits within the given schema.
2671
+ *
2672
+ * For example, a JavaScript array is serialized differently when being written
2673
+ * to a REST JSON HTTP header (comma-delimited string) and a REST JSON HTTP body (JSON array).
2674
+ *
2675
+ * @public
2676
+ */
2677
+ declare class HttpInterceptingShapeSerializer<CodecShapeSerializer extends ShapeSerializer<string | Uint8Array>> implements ShapeSerializer<string | Uint8Array>, ConfigurableSerdeContext {
2678
+ private codecSerializer;
2679
+ private stringSerializer;
2680
+ private buffer;
2681
+ constructor(codecSerializer: CodecShapeSerializer, codecSettings: CodecSettings, stringSerializer?: ToStringShapeSerializer);
2682
+ /**
2683
+ * @override
2684
+ */
2685
+ setSerdeContext(serdeContext: SerdeFunctions): void;
2686
+ write(schema: Schema$1, value: unknown): void;
2687
+ flush(): string | Uint8Array;
2688
+ }
2689
+
2690
+ /**
2691
+ * @internal
2692
+ */
2693
+ type HttpHandler<HttpHandlerConfig extends object = {}> = RequestHandler<HttpRequest, HttpResponse, HttpHandlerOptions> & {
2694
+ /**
2695
+ * @internal
2696
+ */
2697
+ updateHttpClientConfig(key: keyof HttpHandlerConfig, value: HttpHandlerConfig[typeof key]): void;
2698
+ /**
2699
+ * @internal
2700
+ */
2701
+ httpHandlerConfigs(): HttpHandlerConfig;
2702
+ };
2703
+ /**
2704
+ * A type representing the accepted user inputs for the `requestHandler` field
2705
+ * of a client's constructor object.
2706
+ * You may provide an instance of an HttpHandler, or alternatively
2707
+ * provide the constructor arguments as an object which will be passed
2708
+ * to the constructor of the default request handler.
2709
+ * The default class constructor to which your arguments will be passed
2710
+ * varies. The Node.js default is the NodeHttpHandler and the browser/react-native
2711
+ * default is the FetchHttpHandler. In rarer cases specific clients may be
2712
+ * configured to use other default implementations such as Websocket or HTTP2.
2713
+ * The fallback type Record<string, unknown> is part of the union to allow
2714
+ * passing constructor params to an unknown requestHandler type.
2715
+ *
2716
+ * @public
2717
+ */
2718
+ type HttpHandlerUserInput = HttpHandler | NodeHttpHandlerOptions | FetchHttpHandlerOptions | Record<string, unknown>;
2719
+
2720
+ /**
2721
+ * @internal
2722
+ */
2723
+ declare class SerdeContextConfig implements ConfigurableSerdeContext {
2724
+ protected serdeContext?: SerdeFunctions;
2725
+ setSerdeContext(serdeContext: SerdeFunctions): void;
2726
+ }
2727
+
2728
+ /**
2729
+ * @public
2730
+ */
2731
+ type JsonSettings = CodecSettings & {
2732
+ jsonName: boolean;
2733
+ /**
2734
+ * When true, bigInteger and bigDecimal values are serialized as JSON strings
2735
+ * to preserve arbitrary precision (Smithy RPCv2 JSON behavior). When false or
2736
+ * unset, they are serialized as unquoted JSON numbers (AWS JSON 1.0/1.1 behavior).
2737
+ */
2738
+ bigNumberAsString?: boolean;
2739
+ };
2740
+
2741
+ /**
2742
+ * Codec grouping the v2 serializer and deserializer.
2743
+ * @public
2744
+ */
2745
+ declare class JsonCodec2 extends SerdeContextConfig implements $Codec<Uint8Array, string> {
2746
+ readonly settings: JsonSettings;
2747
+ constructor(settings: JsonSettings);
2748
+ createSerializer(): $ShapeSerializer<Uint8Array>;
2749
+ createDeserializer(): $ShapeDeserializer<string>;
2750
+ }
2751
+
2752
+ /** An output with the parsed response body, including fields this SDK version does not model. */
2753
+ type WithRaw<T> = T & {
2754
+ readonly raw?: Record<string, unknown>;
2755
+ };
2756
+ declare class CaitlynRestJsonProtocol extends HttpBindingProtocol {
2757
+ protected serializer: HttpInterceptingShapeSerializer<$ShapeSerializer<Uint8Array<ArrayBufferLike>>>;
2758
+ protected deserializer: HttpInterceptingShapeDeserializer<$ShapeDeserializer<string>>;
2759
+ private readonly codec;
2760
+ constructor({ defaultNamespace, errorTypeRegistries }: {
2761
+ defaultNamespace: string;
2762
+ errorTypeRegistries?: TypeRegistry[];
2763
+ });
2764
+ getShapeId(): string;
2765
+ getDefaultContentType(): string;
2766
+ getPayloadCodec(): JsonCodec2;
2767
+ setSerdeContext(serdeContext: SerdeFunctions): void;
2768
+ serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: Parameters<HttpBindingProtocol['serializeRequest']>[2]): Promise<HttpRequest$1>;
2769
+ deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse$1): Promise<Output>;
2770
+ protected deserializeMetadata(response: HttpResponse$1): ResponseMetadata;
2771
+ protected handleError(_operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse$1, dataObject: Record<string, unknown>, metadata: ResponseMetadata): Promise<never>;
2772
+ }
2773
+
2774
+ declare const CAITLYN_SDK_USER_AGENT_PREFIX = "caitlyn-sdk-ts";
2775
+ /**
2776
+ * Connection errors (PROTOCOL.md 6.5): a call that got no HTTP response, or whose connection failed while the
2777
+ * body was read, fails with `toError(operation, cause)`, the generated `CaitlynConnectionError`, once the retries
2778
+ * are spent. Token requests are not marked: their failures stay sign-in errors.
2779
+ */
2780
+ declare function getCaitlynConnectionErrorPlugin(toError: (operation: string, cause: unknown) => Error): Pluggable<any, any>;
2781
+ declare class NotSupportedByServer extends Error {
2782
+ readonly operation: string;
2783
+ readonly requires: string;
2784
+ readonly server: string;
2785
+ constructor(operation: string, requires: string, server: string);
2786
+ }
2787
+ /**
2788
+ * @param options.sdkModel the highest @since in the model: the server release this SDK was generated against
2789
+ * @param options.retrySafeOperations operations that are @readonly, @idempotent or have an @idempotencyToken member
2790
+ * @param options.since `Operation=5.120.0` and `Operation.member=5.124.0` entries from the model's @since traits
2791
+ */
2792
+ declare function getCaitlynSdkPlugin(config: {
2793
+ caitlynSdkVersion?: string;
2794
+ customUserAgent?: string;
2795
+ }, options: {
2796
+ sdkModel: string;
2797
+ retrySafeOperations: string[];
2798
+ since?: string[];
2799
+ }): Pluggable<any, any>;
2800
+
2801
+ declare const NO_RETRY: unique symbol;
2802
+ declare class CaitlynRetryStrategy implements RetryStrategyV2 {
2803
+ private readonly maxRetryDelayMs;
2804
+ readonly mode = "standard";
2805
+ private readonly maxAttempts;
2806
+ constructor(maxAttempts?: number | Provider<number>, maxRetryDelayMs?: number);
2807
+ acquireInitialRetryToken(): Promise<RetryToken>;
2808
+ refreshRetryTokenForRetry(token: RetryToken, info: RetryErrorInfo): Promise<RetryToken>;
2809
+ recordSuccess(): void;
2810
+ }
2811
+
2812
+ declare const caitlynEndpointProvider: (params: {
2813
+ endpoint?: string;
2814
+ }) => EndpointV2;
2815
+
2816
+ /** The tracer every Caitlyn span comes from. */
2817
+ declare function caitlynTracer(provider?: TracerProvider): Tracer;
2818
+ declare function getCaitlynTelemetryPlugin(provider?: TracerProvider): Pluggable<any, any>;
2819
+
2820
+ interface SseSpec {
2821
+ /** SSE `event:` names this SDK knows (the union members' jsonNames). Others are skipped. */
2822
+ readonly known: ReadonlySet<string>;
2823
+ /** The event that ends the stream successfully, and the member finalMessage() returns. */
2824
+ readonly final?: {
2825
+ event: string;
2826
+ member: string;
2827
+ };
2828
+ /** The event carrying RFC 9457 problem details; it ends the stream with a thrown error. */
2829
+ readonly errorEvent?: string;
2830
+ /** Builds the typed error for an error event. */
2831
+ readonly toError: (problem: Record<string, unknown>) => Error;
2832
+ }
2833
+ /** What opening (or resuming) a stream returns: the command output, with its event body and response metadata. */
2834
+ interface SseOpened {
2835
+ readonly events: unknown;
2836
+ readonly $metadata?: {
2837
+ readonly requestId?: string;
2838
+ };
2839
+ }
2840
+ declare class SseStream<E extends {
2841
+ type: string;
2842
+ }, F = never> implements AsyncIterable<E> {
2843
+ private readonly spec;
2844
+ private readonly open;
2845
+ private readonly resume;
2846
+ private readonly signal?;
2847
+ private readonly maxReconnects;
2848
+ private finalValue?;
2849
+ private consumed;
2850
+ private readonly seen;
2851
+ lastEventId?: string;
2852
+ reconnects: number;
2853
+ /** The Caitlyn-Request-Id of the response that opened the stream; set once iteration has started. */
2854
+ requestId?: string;
2855
+ constructor(spec: SseSpec, open: () => Promise<SseOpened>, resume: ((lastEventId: string | undefined) => Promise<SseOpened>) | undefined, signal?: AbortSignal | undefined, maxReconnects?: number);
2856
+ private aborted;
2857
+ [Symbol.asyncIterator](): AsyncGenerator<E>;
2858
+ /** Drains the stream if needed and returns the final event's member. */
2859
+ finalMessage(): Promise<F>;
2860
+ }
2861
+
2862
+ interface SseMessage {
2863
+ id?: string;
2864
+ event: string;
2865
+ data: string;
2866
+ }
2867
+ declare function parseSse(body: AsyncIterable<Uint8Array | string>): AsyncGenerator<SseMessage>;
2868
+
2869
+ interface UploadSlot {
2870
+ uploadUrl: string;
2871
+ uploadMethod: string;
2872
+ requiredHeaders: Record<string, string>;
2873
+ }
2874
+ interface UploadMeta {
2875
+ fileName: string;
2876
+ contentType: string;
2877
+ byteSize: number;
2878
+ sha256: string;
2879
+ }
2880
+ declare function uploadFile<S extends UploadSlot>(file: Blob, fileName: string, reserve: (meta: UploadMeta) => Promise<S>, toError: (problem: Record<string, unknown>) => Error, signal?: AbortSignal, tracer?: Tracer): Promise<S>;
2881
+
2882
+ interface AwsCredentials {
2883
+ accessKeyId: string;
2884
+ secretAccessKey: string;
2885
+ sessionToken?: string;
2886
+ /** When the credentials stop working; the SDK fetches new ones a minute before. */
2887
+ expiration?: Date;
2888
+ }
2889
+ type AwsCredentialSource = AwsCredentials | (() => Promise<AwsCredentials> | AwsCredentials);
2890
+ interface SignableRequest {
2891
+ method: string;
2892
+ url: URL;
2893
+ headers: Record<string, string>;
2894
+ body: string;
2895
+ }
2896
+ /**
2897
+ * Signs a request with AWS Signature Version 4 (header form) and returns the headers to send, including
2898
+ * `authorization`, `x-amz-date`, `x-amz-content-sha256` and, for temporary credentials, `x-amz-security-token`.
2899
+ */
2900
+ declare function signV4(req: SignableRequest, creds: AwsCredentials, region: string, service: string, now?: Date): Promise<Record<string, string>>;
2901
+ /**
2902
+ * The default credential source: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (with AWS_SESSION_TOKEN), as AWS
2903
+ * Lambda and CI runners set them; otherwise the container credentials endpoint
2904
+ * (AWS_CONTAINER_CREDENTIALS_FULL_URI or _RELATIVE_URI), as ECS, Fargate and AgentCore runtimes set it.
2905
+ */
2906
+ declare function defaultAwsCredentials(fetchFn?: typeof fetch): Promise<AwsCredentials>;
2907
+ interface WebIdentityTokenRequest {
2908
+ region: string;
2909
+ audience: string;
2910
+ credentials: AwsCredentials;
2911
+ signingAlgorithm?: 'ES384' | 'RS256';
2912
+ durationSeconds?: number;
2913
+ /** Overrides https://sts.{region}.amazonaws.com/ (tests, FIPS or VPC endpoints). */
2914
+ stsEndpoint?: string;
2915
+ fetch?: typeof fetch;
2916
+ signal?: AbortSignal;
2917
+ }
2918
+ /** Calls STS GetWebIdentityToken (outbound identity federation) on a regional endpoint and returns the JWT. */
2919
+ declare function getWebIdentityToken(r: WebIdentityTokenRequest): Promise<{
2920
+ token: string;
2921
+ expiration?: Date;
2922
+ }>;
2923
+
2924
+ /** Tokens the `oauth` mode keeps. `expiresAt` is milliseconds since the epoch. */
2925
+ interface OAuthTokens {
2926
+ accessToken: string;
2927
+ refreshToken?: string;
2928
+ expiresAt?: number;
2929
+ scope?: string;
2930
+ }
2931
+ /** Where the `oauth` mode keeps tokens between processes, for example encrypted on a server. */
2932
+ interface TokenStore {
2933
+ load(): Promise<OAuthTokens | undefined> | OAuthTokens | undefined;
2934
+ save(tokens: OAuthTokens): Promise<void> | void;
2935
+ clear(): Promise<void> | void;
2936
+ }
2937
+ type AuthOptions = {
2938
+ mode: 'token';
2939
+ token: string;
2940
+ /** In a browser, silences the warning that a long-lived token there is exposed (for local testing). */
2941
+ allowBrowserToken?: boolean;
2942
+ } | {
2943
+ mode: 'clientCredentials';
2944
+ clientId: string;
2945
+ clientSecret: string;
2946
+ scopes?: string[];
2947
+ resource?: string;
2948
+ } | {
2949
+ mode: 'oauth';
2950
+ clientId: string;
2951
+ /** For a confidential client on a server; omit in a browser. */
2952
+ clientSecret?: string;
2953
+ redirectUri?: string;
2954
+ scopes?: string[];
2955
+ resource?: string;
2956
+ /** Default: kept in memory for the life of the client. */
2957
+ tokenStore?: TokenStore;
2958
+ } | {
2959
+ mode: 'awsIam';
2960
+ /** The regional STS endpoint to use. Default: AWS_REGION, then AWS_DEFAULT_REGION. */
2961
+ region?: string;
2962
+ /** Default: environment variables, then the container credentials endpoint. Accepts any @aws-sdk provider. */
2963
+ credentials?: AwsCredentialSource;
2964
+ signingAlgorithm?: 'ES384' | 'RS256';
2965
+ /** Lifetime of the AWS-signed token, at most 300 (the default). */
2966
+ durationSeconds?: number;
2967
+ /** The audience the AWS token is minted for. Default: the workspace resource URL. */
2968
+ audience?: string;
2969
+ stsEndpoint?: string;
2970
+ } | {
2971
+ mode: 'workloadIdentity';
2972
+ /** Returns the workload's current identity token, for example a GitLab CI id_tokens variable. */
2973
+ token: () => string | Promise<string>;
2974
+ resource?: string;
2975
+ } | {
2976
+ mode: 'session';
2977
+ /** A session cookie, for server-side use. In a browser leave it out: the browser sends its own. */
2978
+ cookie?: string;
2979
+ /** Sent as Origin on every write. Default: the workspace URL. */
2980
+ origin?: string;
2981
+ };
2982
+ /** A sign-in failure: the token endpoint's OAuth error, or a failure to get the identity it exchanges. */
2983
+ declare class CaitlynAuthError extends Error {
2984
+ /** The OAuth error code (`invalid_client`, `invalid_grant`…), or `sign_in_required`. */
2985
+ readonly code: string;
2986
+ readonly status?: number | undefined;
2987
+ readonly requestId?: string | undefined;
2988
+ readonly name = "CaitlynAuthError";
2989
+ constructor(message: string,
2990
+ /** The OAuth error code (`invalid_client`, `invalid_grant`…), or `sign_in_required`. */
2991
+ code: string, status?: number | undefined, requestId?: string | undefined);
2992
+ }
2993
+ /** The audience of a workspace's tokens: its resource URL, https://<workspace>/api. */
2994
+ declare const workspaceAudience: (workspace: string) => string;
2995
+ /** A workspace given as a hostname or a URL, as its bare hostname. */
2996
+ declare const workspaceHost: (workspace: string) => string;
2997
+ /** What `client.auth` offers: the current token, and the `oauth` mode's sign-in steps. */
2998
+ declare class AuthSession {
2999
+ readonly options: AuthOptions;
3000
+ /** Where the token endpoint is: the client's endpoint, which an override may move (a proxy, a local app). */
3001
+ readonly endpoint: string;
3002
+ /** The workspace hostname. Like an AWS region, it decides the endpoint and the token audience. */
3003
+ readonly workspace: string;
3004
+ private readonly fetchFn;
3005
+ private cached?;
3006
+ /** The token the server last refused with a 401, so `oauth` never reloads it from the store. */
3007
+ private refused?;
3008
+ private inflight?;
3009
+ private memoryTokens?;
3010
+ readonly tokenEndpoint: string;
3011
+ readonly authorizationEndpoint: string;
3012
+ /** The workspace's resource URL, https://<workspace>/api: the audience every token is bound to. */
3013
+ readonly resource: string;
3014
+ /** https://<workspace>: the default Origin for session writes. */
3015
+ readonly workspaceUrl: string;
3016
+ constructor(options: AuthOptions,
3017
+ /** Where the token endpoint is: the client's endpoint, which an override may move (a proxy, a local app). */
3018
+ endpoint: string,
3019
+ /** The workspace hostname. Like an AWS region, it decides the endpoint and the token audience. */
3020
+ workspace: string, fetchFn?: typeof fetch);
3021
+ get mode(): "token" | "clientCredentials" | "oauth" | "awsIam" | "workloadIdentity" | "session";
3022
+ /** The bearer token for the next request: cached, or fetched once however many calls ask at the same time. */
3023
+ token(): Promise<string>;
3024
+ /** Forgets the cached token, so the next call signs in again (done once after a 401). */
3025
+ invalidate(): void;
3026
+ /** Whether a 401 is worth one more try with a new token. */
3027
+ get canRefresh(): boolean;
3028
+ /** Starts sign-in (`oauth` mode): the URL to send the person to, and the state and PKCE verifier to keep. */
3029
+ authorizationUrl(opts?: {
3030
+ state?: string;
3031
+ scopes?: string[];
3032
+ redirectUri?: string;
3033
+ }): Promise<{
3034
+ url: string;
3035
+ state: string;
3036
+ codeVerifier: string;
3037
+ }>;
3038
+ /** Finishes sign-in (`oauth` mode): checks state, exchanges the code and saves the tokens. */
3039
+ handleCallback(p: {
3040
+ code: string;
3041
+ state?: string;
3042
+ expectedState?: string;
3043
+ codeVerifier: string;
3044
+ redirectUri?: string;
3045
+ }): Promise<OAuthTokens>;
3046
+ /** Signs out (`oauth` mode): revokes the refresh token where possible and clears the store. */
3047
+ signOut(): Promise<void>;
3048
+ private oauth;
3049
+ private clientParams;
3050
+ private loadTokens;
3051
+ private saveTokens;
3052
+ private fetchToken;
3053
+ private exchange;
3054
+ private requestToken;
3055
+ }
3056
+ /**
3057
+ * The generated client's `token` identity provider. It reports the token as already near expiry, so Smithy's
3058
+ * memoisation asks again on every request and AuthSession's own cache (which knows the real expiry, and can
3059
+ * be invalidated after a 401) decides.
3060
+ */
3061
+ declare const tokenIdentityProvider: (auth: AuthSession) => () => Promise<TokenIdentity>;
3062
+ /** Session headers, and one retry with a new token after a 401. */
3063
+ declare function getCaitlynAuthPlugin(auth: AuthSession): Pluggable<any, any>;
3064
+
3065
+ interface CaitlynOptions {
3066
+ /**
3067
+ * The workspace hostname, for example "your-company.getcaitlyn.ai". Like an AWS region, it decides where
3068
+ * requests go (https://<workspace>/api) and the audience every token is bound to (https://<workspace>/api).
3069
+ */
3070
+ workspace: string;
3071
+ /** How the client signs in: token, clientCredentials, oauth, awsIam, workloadIdentity or session. */
3072
+ auth: AuthOptions;
3073
+ /** The fetch the sign-in requests use (token endpoint, STS, container credentials). Default: global fetch. */
3074
+ fetch?: typeof fetch;
3075
+ /**
3076
+ * Overrides the base URL the operation paths (/v3/…) and the token endpoint (/oauth/token) are appended to,
3077
+ * for a proxy or a local app. Default: https://{workspace}/api. It never changes the token audience.
3078
+ */
3079
+ endpoint?: string;
3080
+ /**
3081
+ * The HTTP handler API calls go through, for this client only: a `NodeHttpHandler` with your own `https.Agent`
3082
+ * (a private certificate authority, a proxy, keep-alive settings), a `FetchHttpHandler`, any object with
3083
+ * `handle(request)`, or the default handler's options (`{ httpsAgent }` on Node). Default: a handler of the
3084
+ * client's own. Sign-in requests go through `fetch`.
3085
+ */
3086
+ requestHandler?: HttpHandlerUserInput;
3087
+ maxAttempts?: number;
3088
+ /** Longest Retry-After the SDK waits for (default 60 000 ms); above it the call fails at once. */
3089
+ maxRetryDelayMs?: number;
3090
+ telemetry?: {
3091
+ tracerProvider?: TracerProvider;
3092
+ enabled?: boolean;
3093
+ };
3094
+ }
3095
+ interface CallOptions {
3096
+ signal?: AbortSignal;
3097
+ }
3098
+ /** The base URL of a workspace's API: its hostname, over HTTPS, with the /api prefix every Caitlyn route has. */
3099
+ declare function workspaceEndpoint(workspace: string): string;
3100
+ /** The sign-in session for a set of options: what `client.auth` is. */
3101
+ declare function createAuth(opts: CaitlynOptions): AuthSession;
3102
+ /** The generated client's configuration for a set of options. */
3103
+ declare function clientConfig(opts: CaitlynOptions, auth?: AuthSession): {
3104
+ retryStrategy?: CaitlynRetryStrategy | undefined;
3105
+ maxAttempts?: number | undefined;
3106
+ requestHandler?: HttpHandlerUserInput | undefined;
3107
+ /** The workspace this client is for; readable as client.config.workspace. */
3108
+ workspace: string;
3109
+ endpoint: string;
3110
+ token: () => Promise<TokenIdentity>;
3111
+ /** The tracer upload helpers record the byte transfer with (PROTOCOL.md 13); absent with telemetry off. */
3112
+ caitlynTracer: _opentelemetry_api.Tracer | undefined;
3113
+ };
3114
+ /** One problem with one request member or query parameter, on a 400 VALIDATION_FAILED. */
3115
+ interface CaitlynFieldError {
3116
+ pointer?: string;
3117
+ parameter?: string;
3118
+ code: string;
3119
+ detail?: string;
3120
+ }
3121
+ /** The RFC 9457 fields every Caitlyn error carries (PROTOCOL.md 6.3). */
3122
+ interface CaitlynErrorFields {
3123
+ status?: number;
3124
+ code?: string;
3125
+ type?: string;
3126
+ title?: string;
3127
+ detail?: string;
3128
+ requestId?: string;
3129
+ retryAfterSeconds?: number;
3130
+ errors?: CaitlynFieldError[];
3131
+ /** The response body as received, as text, at most its first 8 KiB: the only view of a body that is not problem details (PROTOCOL.md 6.3). */
3132
+ rawBody?: string;
3133
+ /** True when the body was longer than 8 KiB and `rawBody` holds only its first 8 KiB. */
3134
+ rawBodyTruncated?: boolean;
3135
+ }
3136
+
3137
+ type WaiterState = 'success' | 'failure' | 'retry';
3138
+ interface WaiterOptions {
3139
+ /** Stops waiting and throws the signal's reason (use AbortSignal.timeout() for a deadline). */
3140
+ signal?: AbortSignal;
3141
+ /** The longest the waiter waits in total, in milliseconds. Default: no limit beyond the signal. */
3142
+ maxWaitMs?: number;
3143
+ /** Default 2 000 ms (Smithy's default minDelay). */
3144
+ minDelayMs?: number;
3145
+ /** Default 120 000 ms (Smithy's default maxDelay). */
3146
+ maxDelayMs?: number;
3147
+ }
3148
+ /** A waiter ended in a failure state, or ran out of time. `last` is the last output or error it saw. */
3149
+ declare class WaiterError extends Error {
3150
+ readonly reason: 'failure' | 'timeout';
3151
+ readonly last: unknown;
3152
+ readonly attempts: number;
3153
+ readonly name = "WaiterError";
3154
+ constructor(message: string, reason: 'failure' | 'timeout', last: unknown, attempts: number);
3155
+ }
3156
+ /**
3157
+ * Calls `read` until `accept` says success (returns the output) or failure (throws WaiterError).
3158
+ * `accept` sees either `{output}` or `{error}`; returning undefined for an error rethrows it.
3159
+ */
3160
+ declare function waitUntil<T>(name: string, read: (signal?: AbortSignal) => Promise<T>, accept: (r: {
3161
+ output: T;
3162
+ error?: undefined;
3163
+ } | {
3164
+ output?: undefined;
3165
+ error: unknown;
3166
+ }) => WaiterState | undefined, opts?: WaiterOptions): Promise<T>;
3167
+
3168
+ export { AuthSession, CAITLYN_SDK_USER_AGENT_PREFIX, CaitlynAuthError, CaitlynRestJsonProtocol, CaitlynRetryStrategy, NO_RETRY, NotSupportedByServer, SseStream, WaiterError, caitlynEndpointProvider, caitlynTracer, clientConfig, createAuth, defaultAwsCredentials, getCaitlynAuthPlugin, getCaitlynConnectionErrorPlugin, getCaitlynSdkPlugin, getCaitlynTelemetryPlugin, getWebIdentityToken, parseSse, signV4, tokenIdentityProvider, uploadFile, waitUntil, workspaceAudience, workspaceEndpoint, workspaceHost };
3169
+ export type { AuthOptions, AwsCredentialSource, AwsCredentials, CaitlynErrorFields, CaitlynFieldError, CaitlynOptions, CallOptions, OAuthTokens, SseMessage, SseOpened, SseSpec, TokenStore, UploadMeta, UploadSlot, WaiterOptions, WaiterState, WithRaw };