@oapiex/sdk-kit 0.1.9 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts DELETED
@@ -1,621 +0,0 @@
1
- import { A as CountryCodeRestricted, C as UnifiedResponse, D as ValidationErrorResponse, E as ValidationError, O as XGenericObject, S as SuccessResponse, T as UserUrls, _ as NormalPagination, a as AuthErrorResponse, b as Response, c as BasicAuthConfig, d as CustomAuthConfig, f as DebugLevel, g as InitOptions, h as HttpMethod, i as AuthConfig, j as CurrencyCode, k as CountryCode, l as BearerAuthConfig, m as ErrorResponse, n as AccessValidationResult, o as AuthRequestConfig, p as Environment, r as ApiKeyAuthConfig, s as AuthResponse, t as AccessValidationConfigUpdate, u as CursorPagination, v as OAuth2AuthConfig, w as UserConfig, x as ResponseStatus, y as PageInfoMeta } from "./index-BA7Ul1Pi.cjs";
2
- import * as axios0 from "axios";
3
- import { RawAxiosRequestHeaders } from "axios";
4
-
5
- //#region src/Exceptions/BadRequestException.d.ts
6
- declare class BadRequestException extends Error {
7
- statusCode: number;
8
- type: string;
9
- code: string | number;
10
- data: ValidationErrorResponse;
11
- constructor(data?: ValidationErrorResponse);
12
- }
13
- //#endregion
14
- //#region src/types.d.ts
15
- interface RuntimeSdkParameterManifest {
16
- name: string;
17
- accessor: string;
18
- in: 'query' | 'header' | 'path';
19
- required: boolean;
20
- description?: string;
21
- }
22
- interface RuntimeSdkSecurityRequirementSchemeManifest {
23
- name: string;
24
- scopes: string[];
25
- }
26
- interface RuntimeSdkSecurityRequirementManifest {
27
- schemes: RuntimeSdkSecurityRequirementSchemeManifest[];
28
- }
29
- interface RuntimeSdkSecuritySchemeManifest {
30
- name: string;
31
- helperName: string;
32
- description?: string;
33
- type: 'http' | 'apiKey' | 'oauth2' | 'openIdConnect';
34
- authType: 'bearer' | 'basic' | 'apiKey' | 'oauth2';
35
- scheme?: string;
36
- bearerFormat?: string;
37
- in?: 'header' | 'query' | 'cookie';
38
- parameterName?: string;
39
- openIdConnectUrl?: string;
40
- scopes?: string[];
41
- }
42
- interface RuntimeSdkOperationManifest {
43
- path: string;
44
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
45
- methodName: string;
46
- summary?: string;
47
- description?: string;
48
- requestBodyDescription?: string;
49
- responseDescription?: string;
50
- operationId?: string;
51
- responseType: string;
52
- inputType: string;
53
- queryType: string;
54
- headerType: string;
55
- paramsType: string;
56
- hasBody: boolean;
57
- bodyRequired: boolean;
58
- pathParams: RuntimeSdkParameterManifest[];
59
- queryParams: RuntimeSdkParameterManifest[];
60
- headerParams: RuntimeSdkParameterManifest[];
61
- security?: RuntimeSdkSecurityRequirementManifest[];
62
- }
63
- interface RuntimeSdkGroupManifest {
64
- className: string;
65
- propertyName: string;
66
- operations: RuntimeSdkOperationManifest[];
67
- }
68
- interface RuntimeSdkManifest {
69
- groups: RuntimeSdkGroupManifest[];
70
- securitySchemes: RuntimeSdkSecuritySchemeManifest[];
71
- security?: RuntimeSdkSecurityRequirementManifest[];
72
- }
73
- interface RuntimeSdkBundle<TApi$1 = unknown> {
74
- document: unknown;
75
- manifest: RuntimeSdkManifest;
76
- __api?: TApi$1;
77
- }
78
- type RuntimeSdkMethodMap<TOperations$1> = TOperations$1 extends readonly unknown[] ? UnionToIntersection<RuntimeSdkMethodNamespace<TOperations$1[number]>> : Record<string, never>;
79
- type RuntimeSdkMethodNamespace<TOperation> = TOperation extends {
80
- methodName: infer TMethodName extends string;
81
- } ? { [TKey in TMethodName]: (...args: any[]) => Promise<unknown> } : Record<string, never>;
82
- type RuntimeSdkGroupMap<TGroups$1> = TGroups$1 extends readonly unknown[] ? UnionToIntersection<RuntimeSdkGroupNamespace<TGroups$1[number]>> : Record<string, never>;
83
- type RuntimeSdkGroupNamespace<TGroup> = TGroup extends {
84
- propertyName: infer TPropertyName extends string;
85
- operations: infer TOperations;
86
- } ? { [TKey in TPropertyName]: RuntimeSdkMethodMap<TOperations> } : Record<string, never>;
87
- type InferRuntimeSdkApiFromManifest<TBundle> = TBundle extends {
88
- manifest: {
89
- groups: infer TGroups;
90
- };
91
- } ? RuntimeSdkGroupMap<TGroups> : never;
92
- type UnionToIntersection<TValue> = (TValue extends unknown ? (value: TValue) => void : never) extends ((value: infer TIntersection) => void) ? TIntersection : never;
93
- type InferRuntimeSdkApi<TBundle> = '__api' extends keyof TBundle ? TBundle extends {
94
- __api?: infer TApi;
95
- } ? TApi : InferRuntimeSdkApiFromManifest<TBundle> : InferRuntimeSdkApiFromManifest<TBundle>;
96
- //#endregion
97
- //#region src/Builder.d.ts
98
- declare class Builder {
99
- private static baseUrls;
100
- /**
101
- * API Environment
102
- */
103
- static environment?: Environment;
104
- constructor();
105
- /**
106
- * Sets the environment for the builder
107
- *
108
- * @param env
109
- */
110
- static setEnvironment(env: Environment): void;
111
- /**
112
- * Gets the base url based on environment
113
- *
114
- * @returns
115
- */
116
- static baseUrl(): string;
117
- /**
118
- * Builds a full url based on endpoint provided
119
- *
120
- * @param endpoint
121
- * @returns
122
- */
123
- static buildUrl(...endpoint: string[]): string;
124
- /**
125
- * Builds parameters for query or path
126
- *
127
- * @param params
128
- * @param type
129
- * @returns
130
- */
131
- static buildParams(params: XGenericObject, type?: 'query' | 'path'): string;
132
- /**
133
- * Assigns parameters to url {placeholders} based on type
134
- *
135
- * @param url
136
- * @param params
137
- * @param type
138
- *
139
- * @returns
140
- */
141
- static assignParamsToUrl(url: string, params: XGenericObject, type?: 'query' | 'path'): string;
142
- /**
143
- * Builds the target url by assigning both path and query parameters
144
- *
145
- * @param path
146
- * @param params
147
- * @param queryParams
148
- * @returns
149
- */
150
- static buildTargetUrl(path: string, params?: XGenericObject, queryParams?: XGenericObject): string;
151
- /**
152
- * Encrypts specified keys in the input object and returns a new object with
153
- * encrypted values.
154
- *
155
- * @param input The input object containing the data to be encrypted.
156
- * @param keysToEncrypt The keys in the input object that should be encrypted.
157
- * @param outputMapping A mapping of input keys to output keys for the encrypted values.
158
- * @returns A new object with the specified keys encrypted.
159
- */
160
- static encryptDetails<X extends XGenericObject>(input: Partial<X>, keysToEncrypt?: (keyof X)[], outputMapping?: Partial<Record<keyof X, string>>): Promise<X>;
161
- /**
162
- * Encrypts data using AES-GCM encryption
163
- * @param data
164
- * @param token
165
- * @param nonce
166
- * @returns
167
- */
168
- static encryptAES(data: string, token: string, nonce: string): Promise<string>;
169
- private static normalizeBaseUrl;
170
- private static normalizeEnvironment;
171
- }
172
- //#endregion
173
- //#region src/Core.d.ts
174
- declare class Core {
175
- static apiClass: typeof BaseApi;
176
- debugLevel: DebugLevel;
177
- /**
178
- * Client ID
179
- */
180
- private clientId?;
181
- /**
182
- * Client Secret
183
- */
184
- private clientSecret?;
185
- /**
186
- * API Environment
187
- */
188
- private environment;
189
- private accessValidator?;
190
- /**
191
- * API Instance
192
- */
193
- api: BaseApi;
194
- /**
195
- * Builder Instance
196
- */
197
- builder: typeof Builder;
198
- /**
199
- * Creates an instance of Core.
200
- *
201
- * @param clientId
202
- * @param clientSecret
203
- * @param encryptionKey
204
- */
205
- constructor(clientId?: InitOptions);
206
- constructor(clientId?: string, clientSecret?: string, encryptionKey?: string, env?: Environment, config?: Partial<UserConfig>);
207
- protected createApi(): BaseApi;
208
- /**
209
- * Initializes the Core instance
210
- *
211
- * @param clientId
212
- * @param clientSecret
213
- * @param encryptionKey
214
- * @param accessToken
215
- * @returns
216
- */
217
- init(clientId?: InitOptions): this;
218
- init(clientId?: string, clientSecret?: string, encryptionKey?: string, env?: Environment, config?: Partial<UserConfig>): this;
219
- configure(config: Partial<UserConfig>): this;
220
- /**
221
- * Set the debug level
222
- *
223
- * @param level
224
- * @returns
225
- */
226
- debug(level?: DebugLevel): this;
227
- /**
228
- * Get the current environment
229
- *
230
- * @returns
231
- */
232
- getEnvironment(): Environment;
233
- /**
234
- * Get the configured client identifier.
235
- */
236
- getClientId(): string | undefined;
237
- /**
238
- * Get the configured client secret.
239
- */
240
- getClientSecret(): string | undefined;
241
- /**
242
- * Get the current shared SDK config.
243
- */
244
- getConfig(): UserConfig;
245
- /**
246
- * Replace the active auth strategy.
247
- */
248
- setAuth(auth: AuthConfig | AuthConfig[]): this;
249
- /**
250
- * Clear any configured auth strategy.
251
- */
252
- clearAuth(): this;
253
- /**
254
- * Set access validator function
255
- *
256
- * @param validator Function to validate access
257
- */
258
- setAccessValidator(validator: (core: Core) => AccessValidationResult | Promise<AccessValidationResult>): this;
259
- /**
260
- * Validates access using the provided access validator function
261
- *
262
- * @throws Error if validation fails
263
- */
264
- validateAccess(): Promise<void>;
265
- /**
266
- * Use a manifest bundle to create the API instance
267
- *
268
- * @param bundle
269
- * @returns
270
- */
271
- useDocument<TBundle extends RuntimeSdkBundle>(bundle: TBundle): this & {
272
- api: BaseApi & InferRuntimeSdkApi<TBundle>;
273
- };
274
- /**
275
- * Use a manifest bundle to create the API instance (alias for useDocument).
276
- *
277
- * @param bundle
278
- * @returns
279
- */
280
- useSdk<TBundle extends RuntimeSdkBundle>(bundle: TBundle): this & {
281
- api: BaseApi & InferRuntimeSdkApi<TBundle>;
282
- };
283
- private static normalizeEnvironment;
284
- private static normalizeCredential;
285
- private resolveInitOptionsFromObject;
286
- private resolveInitOptionsFromArgs;
287
- private hasConfiguredAuth;
288
- private isAuthConfigOrArray;
289
- private isAuthConfig;
290
- private isConfigUpdate;
291
- }
292
- //#endregion
293
- //#region src/Exceptions/ForbiddenRequestException.d.ts
294
- declare class ForbiddenRequestException extends Error {
295
- statusCode: number;
296
- type: string;
297
- code: string | number;
298
- data: ErrorResponse;
299
- constructor(data?: ErrorResponse);
300
- }
301
- //#endregion
302
- //#region src/Exceptions/UnauthorizedRequestException.d.ts
303
- declare class UnauthorizedRequestException extends Error {
304
- statusCode: number;
305
- type: string;
306
- code: string | number;
307
- data: ErrorResponse;
308
- constructor(data?: ErrorResponse);
309
- }
310
- //#endregion
311
- //#region src/Exceptions/HttpException.d.ts
312
- declare class HttpException extends Error {
313
- data: UnifiedResponse;
314
- statusCode: number;
315
- parent?: Error;
316
- constructor(data: UnifiedResponse, statusCode?: number, parent?: Error);
317
- /**
318
- * Create an exception from status code
319
- *
320
- * @param code
321
- * @param data
322
- */
323
- static fromCode(code: number, data: Required<UnifiedResponse>, parent?: Error): BadRequestException | ForbiddenRequestException | HttpException | UnauthorizedRequestException;
324
- }
325
- //#endregion
326
- //#region src/Apis/BaseApi.d.ts
327
- declare class BaseApi {
328
- #private;
329
- private lastException?;
330
- /**
331
- * Create a BaseApi instance
332
- *
333
- * @param coreInstance Core instance
334
- */
335
- constructor(coreInstance: Core);
336
- /**
337
- * Get the owning core instance for SDK-specific API bootstrapping.
338
- */
339
- protected get core(): Core;
340
- /**
341
- * Hook for SDK-specific API registration.
342
- */
343
- protected boot(): void;
344
- /**
345
- * Set access validator function
346
- *
347
- * @param validator
348
- */
349
- setAccessValidator(validator: (...args: any[]) => Promise<boolean | string>): void;
350
- /**
351
- * Get the last exception
352
- *
353
- * @returns
354
- */
355
- getLastException(): BadRequestException | ForbiddenRequestException | UnauthorizedRequestException | HttpException | undefined;
356
- /**
357
- * Set the last exception
358
- *
359
- * @param exception
360
- */
361
- setLastException(exception: BadRequestException | ForbiddenRequestException | UnauthorizedRequestException | HttpException): void;
362
- /**
363
- * Initialize BaseApi and its sub-APIs
364
- *
365
- * @param coreInstance Core instance
366
- * @returns
367
- */
368
- static initialize<T extends BaseApi>(this: new (coreInstance: Core) => T, coreInstance: Core): T;
369
- }
370
- //#endregion
371
- //#region src/global.d.ts
372
- declare global {
373
- interface String {
374
- /**
375
- * Convert a string to Kebab Case
376
- *
377
- * @returns
378
- */
379
- toKebabCase(): string;
380
- /**
381
- * Convert a string to camel Case
382
- *
383
- * @returns
384
- */
385
- toCamelCase(): string;
386
- /**
387
- * Convert a string to Pascal Case
388
- *
389
- * @returns
390
- */
391
- toPascalCase(): string;
392
- /**
393
- * Convert a string to Snake Case
394
- *
395
- * @returns
396
- */
397
- toSnakeCase(): string;
398
- /**
399
- * Convert a string to Title Case
400
- *
401
- * @returns
402
- */
403
- toTitleCase(): string;
404
- /**
405
- * Convert a string to Clean Case
406
- * We will format a string by replacing underscores and hyphens with spaces,
407
- * capitalizing the first letter of every word,
408
- * converting camelCase to spaced words,
409
- * and trimming any leading or trailing spaces.
410
- * If a sentence is only two letters long we will make it uppercase.
411
- *
412
- * @returns
413
- */
414
- toCleanCase(): string;
415
- /**
416
- * Convert a string to Slug Case
417
- *
418
- * @returns
419
- */
420
- toSlug(separator?: string): string;
421
- /**
422
- * Truncate a string to n characters
423
- *
424
- * @param n
425
- */
426
- truncate(n: number): string;
427
- }
428
- }
429
- //#endregion
430
- //#region src/Http.d.ts
431
- declare class Http {
432
- private headers;
433
- private body?;
434
- /**
435
- * Bearer token
436
- */
437
- private static bearerToken?;
438
- /**
439
- * Debug level
440
- */
441
- private static debugLevel;
442
- private static apiInstance;
443
- /**
444
- * Creates an instance of Http.
445
- *
446
- * @param method
447
- * @param url
448
- * @param headers
449
- * @param body
450
- */
451
- constructor(headers?: RawAxiosRequestHeaders, body?: any | undefined);
452
- /**
453
- * Set the debug level
454
- *
455
- * @param debug
456
- */
457
- static setDebugLevel(level?: number): void;
458
- /**
459
- * Set the API instance
460
- *
461
- * @param api
462
- */
463
- static setApiInstance(api: BaseApi): void;
464
- /**
465
- * Set the bearer token
466
- *
467
- * @param token
468
- */
469
- static setBearerToken(token: string): void;
470
- static setAuth(auth: AuthConfig | AuthConfig[]): void;
471
- static setBasicAuth(username: string, password: string): void;
472
- static setApiKey(name: string, value: string, location?: 'header' | 'query' | 'cookie', prefix?: string): void;
473
- static clearAuth(): void;
474
- setDefaultHeaders(defaults: Record<string, string>): void;
475
- getHeaders(): RawAxiosRequestHeaders;
476
- getBody(): any;
477
- axiosApi(): axios0.AxiosInstance;
478
- /**
479
- * Makes a GET request
480
- *
481
- * @param url
482
- * @param headers
483
- * @param params
484
- * @returns
485
- */
486
- static get<R = any, M extends XGenericObject = XGenericObject>(url: string, params?: XGenericObject, headers?: RawAxiosRequestHeaders): Promise<UnifiedResponse<R, M>>;
487
- /**
488
- *
489
- *
490
- * @param url
491
- * @param headers
492
- * @param params
493
- * @returns
494
- */
495
- static send<R = any, M extends XGenericObject = XGenericObject>(url: string, method: HttpMethod, body?: any, headers?: RawAxiosRequestHeaders, params?: XGenericObject): Promise<UnifiedResponse<R, M>>;
496
- private static prepareRequest;
497
- private static getConfiguredAuth;
498
- private static applyAuth;
499
- private static setHeaderIfMissing;
500
- private static appendCookie;
501
- /**
502
- * Create an HttpException from status and error
503
- *
504
- * @param status
505
- * @param error
506
- * @returns
507
- */
508
- private static exception;
509
- private static toHeaderRecord;
510
- }
511
- //#endregion
512
- //#region src/RuntimeSdk.d.ts
513
- declare const createRuntimeApi: <TBundle extends {
514
- manifest: RuntimeSdkManifest;
515
- }>(core: Core, bundle: TBundle) => BaseApi & InferRuntimeSdkApi<TBundle>;
516
- declare const createSdk: <TBundle extends RuntimeSdkBundle>(bundle: TBundle, options: InitOptions) => Core & {
517
- api: BaseApi & InferRuntimeSdkApi<TBundle>;
518
- };
519
- //#endregion
520
- //#region src/utilities/AuthCache.d.ts
521
- interface CachedAuthValue {
522
- auth: AuthConfig | AuthConfig[];
523
- expiresAt?: number;
524
- }
525
- interface CachedAccessTokenValue {
526
- token: string;
527
- tokenType?: string;
528
- expiresAt?: number;
529
- expiresInMs?: number;
530
- expiresInSeconds?: number;
531
- }
532
- type AuthCacheLoader = (core: Core) => Promise<CachedAuthValue>;
533
- type AccessTokenCacheLoader = (core: Core) => Promise<CachedAccessTokenValue>;
534
- /**
535
- * Cache any auth payload returned from a loader until it expires.
536
- */
537
- declare const createAuthCache: (loader: AuthCacheLoader) => (core: Core) => Promise<AuthConfig | AuthConfig[]>;
538
- /**
539
- * Cache bearer or oauth-style access tokens returned from a loader until expiry.
540
- */
541
- declare const createAccessTokenCache: (loader: AccessTokenCacheLoader) => (core: Core) => Promise<AuthConfig | AuthConfig[]>;
542
- //#endregion
543
- //#region src/utilities/helpers.d.ts
544
- /**
545
- * Takes a value like the one prodvided in a destructuring assignment where for instance
546
- * a single value might have been provided as opposed to an array of values and
547
- * normalizes it.
548
- *
549
- * Examples:
550
- * Definition:
551
- * (...value: string[]) => normalizeValue(value)
552
- *
553
- * Usage:
554
- * normalizeValue('singleValue') // returns ['singleValue']
555
- * normalizeValue('value1', 'value2') // returns ['value1', 'value2']
556
- * normalizeValue(['value1', 'value2']) // returns ['value1', 'value2']
557
- *
558
- * @param value
559
- * @returns
560
- */
561
- declare const normalizeValue: <T>(value: T | T[]) => T[];
562
- /**
563
- * Builds a full url based on endpoint provided
564
- *
565
- * @param baseUrl
566
- * @param endpoint
567
- *
568
- * @returns
569
- */
570
- declare const buildUrl: (baseUrl: string, ...endpoint: string[]) => string;
571
- //#endregion
572
- //#region src/utilities/Manager.d.ts
573
- declare const defaultConfig: UserConfig;
574
- declare let globalConfig: UserConfig;
575
- declare const loadUserConfig: (rootDir?: string) => Partial<UserConfig> | null;
576
- declare const defineConfig: (config: Partial<UserConfig>) => UserConfig;
577
- declare const getConfig: () => UserConfig;
578
- declare const resetConfig: () => UserConfig;
579
- //#endregion
580
- //#region src/utilities/WebhookValidator.d.ts
581
- declare class WebhookValidator<Options extends XGenericObject = XGenericObject> {
582
- private secretHash?;
583
- algorithm: 'sha256' | 'sha512' | 'sha1';
584
- encoding: 'base64' | 'hex';
585
- /**
586
- * @param secretHash
587
- * @param options
588
- */
589
- constructor(secretHash?: string | undefined, options?: Options);
590
- /**
591
- * Validate webhook signature
592
- * @param rawBody - Raw request body as string
593
- * @param signature - Signature from request header
594
- * @returns {boolean} - True if signature is valid
595
- */
596
- validate(rawBody: string, signature: string): boolean;
597
- /**
598
- * Generate signature for testing/verification
599
- * @param rawBody - Raw request body as string
600
- * @returns {string} - Generated signature
601
- */
602
- generateSignature(rawBody: string): string;
603
- /**
604
- * Async version of validate (for large payloads)
605
- *
606
- * @param rawBody
607
- * @param signature
608
- * @returns {Promise<boolean>}
609
- */
610
- validateAsync(rawBody: string, signature: string): boolean;
611
- /**
612
- * Get current configuration
613
- */
614
- getConfig(): {
615
- algorithm: "sha256" | "sha512" | "sha1";
616
- encoding: "base64" | "hex";
617
- secretHashLength: number | undefined;
618
- };
619
- }
620
- //#endregion
621
- export { AccessTokenCacheLoader, AccessValidationConfigUpdate, AccessValidationResult, ApiKeyAuthConfig, AuthCacheLoader, AuthConfig, AuthErrorResponse, AuthRequestConfig, AuthResponse, BadRequestException, BaseApi, BasicAuthConfig, BearerAuthConfig, Builder, CachedAccessTokenValue, CachedAuthValue, Core, CountryCode, CountryCodeRestricted, CurrencyCode, CursorPagination, CustomAuthConfig, DebugLevel, Environment, ErrorResponse, ForbiddenRequestException, Http, HttpException, HttpMethod, InferRuntimeSdkApi, InitOptions, NormalPagination, OAuth2AuthConfig, PageInfoMeta, Response, ResponseStatus, RuntimeSdkBundle, RuntimeSdkGroupManifest, RuntimeSdkManifest, RuntimeSdkOperationManifest, RuntimeSdkParameterManifest, RuntimeSdkSecurityRequirementManifest, RuntimeSdkSecurityRequirementSchemeManifest, RuntimeSdkSecuritySchemeManifest, SuccessResponse, UnauthorizedRequestException, UnifiedResponse, UserConfig, UserUrls, ValidationError, ValidationErrorResponse, WebhookValidator, XGenericObject, buildUrl, createAccessTokenCache, createAuthCache, createRuntimeApi, createSdk, defaultConfig, defineConfig, getConfig, globalConfig, loadUserConfig, normalizeValue, resetConfig };