@quba/sensitive-data-protection 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @quba/sensitive-data-protection@0.0.1
2
+
3
+ A TypeScript SDK client for the app.quba.ae API.
4
+
5
+ ## Usage
6
+
7
+ First, install the SDK from npm.
8
+
9
+ ```bash
10
+ npm install @quba/sensitive-data-protection --save
11
+ ```
12
+
13
+ Next, try it out.
14
+
15
+
16
+ ```ts
17
+ import {
18
+ Configuration,
19
+ SensitiveDataProtectionApi,
20
+ } from '@quba/sensitive-data-protection';
21
+ import type { HealthCheckRequest } from '@quba/sensitive-data-protection';
22
+
23
+ async function example() {
24
+ console.log("🚀 Testing @quba/sensitive-data-protection SDK...");
25
+ const api = new SensitiveDataProtectionApi();
26
+
27
+ try {
28
+ const data = await api.healthCheck();
29
+ console.log(data);
30
+ } catch (error) {
31
+ console.error(error);
32
+ }
33
+ }
34
+
35
+ // Run the test
36
+ example().catch(console.error);
37
+ ```
38
+
39
+
40
+ ## Documentation
41
+
42
+ ### API Endpoints
43
+
44
+ All URIs are relative to *https://app.quba.ae/api/sdp*
45
+
46
+ | Class | Method | HTTP request | Description
47
+ | ----- | ------ | ------------ | -------------
48
+ *SensitiveDataProtectionApi* | [**healthCheck**](docs/SensitiveDataProtectionApi.md#healthcheck) | **GET** /health | Health
49
+ *SensitiveDataProtectionApi* | [**scanText**](docs/SensitiveDataProtectionApi.md#scantext) | **POST** /scan | Scan Text
50
+
51
+
52
+ ### Models
53
+
54
+ - [HTTPValidationError](docs/HTTPValidationError.md)
55
+ - [ScanRequestBody](docs/ScanRequestBody.md)
56
+ - [ScanResponseBody](docs/ScanResponseBody.md)
57
+ - [ScanResult](docs/ScanResult.md)
58
+ - [ValidationError](docs/ValidationError.md)
59
+ - [ValidationErrorLocInner](docs/ValidationErrorLocInner.md)
60
+
@@ -0,0 +1,429 @@
1
+ //#region src/runtime.d.ts
2
+ /**
3
+ * Sensitive Data Protection API
4
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+ *
6
+ * The version of the OpenAPI document: 0.0.1
7
+ *
8
+ *
9
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10
+ * https://openapi-generator.tech
11
+ * Do not edit the class manually.
12
+ */
13
+ declare const BASE_PATH: string;
14
+ interface ConfigurationParameters {
15
+ basePath?: string;
16
+ fetchApi?: FetchAPI;
17
+ middleware?: Middleware[];
18
+ queryParamsStringify?: (params: HTTPQuery) => string;
19
+ username?: string;
20
+ password?: string;
21
+ apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>);
22
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>);
23
+ headers?: HTTPHeaders;
24
+ credentials?: RequestCredentials;
25
+ }
26
+ declare class Configuration {
27
+ private configuration;
28
+ constructor(configuration?: ConfigurationParameters);
29
+ set config(configuration: Configuration);
30
+ get basePath(): string;
31
+ get fetchApi(): FetchAPI | undefined;
32
+ get middleware(): Middleware[];
33
+ get queryParamsStringify(): (params: HTTPQuery) => string;
34
+ get username(): string | undefined;
35
+ get password(): string | undefined;
36
+ get apiKey(): ((name: string) => string | Promise<string>) | undefined;
37
+ get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined;
38
+ get headers(): HTTPHeaders | undefined;
39
+ get credentials(): RequestCredentials | undefined;
40
+ }
41
+ declare const DefaultConfig: Configuration;
42
+ /**
43
+ * This is the base class for all generated API classes.
44
+ */
45
+ declare class BaseAPI {
46
+ protected configuration: Configuration;
47
+ private static readonly jsonRegex;
48
+ private middleware;
49
+ constructor(configuration?: Configuration);
50
+ withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]): T;
51
+ withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>): T;
52
+ withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>): T;
53
+ /**
54
+ * Check if the given MIME is a JSON MIME.
55
+ * JSON MIME examples:
56
+ * application/json
57
+ * application/json; charset=UTF8
58
+ * APPLICATION/JSON
59
+ * application/vnd.company+json
60
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
61
+ * @return True if the given MIME is JSON, false otherwise.
62
+ */
63
+ protected isJsonMime(mime: string | null | undefined): boolean;
64
+ protected request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise<Response>;
65
+ private createFetchParams;
66
+ private fetchApi;
67
+ /**
68
+ * Create a shallow clone of `this` by constructing a new instance
69
+ * and then shallow cloning data members.
70
+ */
71
+ private clone;
72
+ }
73
+ declare class ResponseError extends Error {
74
+ response: Response;
75
+ name: "ResponseError";
76
+ constructor(response: Response, msg?: string);
77
+ }
78
+ declare class FetchError extends Error {
79
+ cause: Error;
80
+ name: "FetchError";
81
+ constructor(cause: Error, msg?: string);
82
+ }
83
+ declare class RequiredError extends Error {
84
+ field: string;
85
+ name: "RequiredError";
86
+ constructor(field: string, msg?: string);
87
+ }
88
+ declare const COLLECTION_FORMATS: {
89
+ csv: string;
90
+ ssv: string;
91
+ tsv: string;
92
+ pipes: string;
93
+ };
94
+ type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
95
+ type Json = any;
96
+ type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
97
+ type HTTPHeaders = {
98
+ [key: string]: string;
99
+ };
100
+ type HTTPQuery = {
101
+ [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery;
102
+ };
103
+ type HTTPBody = Json | FormData | URLSearchParams;
104
+ type HTTPRequestInit = {
105
+ headers?: HTTPHeaders;
106
+ method: HTTPMethod;
107
+ credentials?: RequestCredentials;
108
+ body?: HTTPBody;
109
+ };
110
+ type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
111
+ type InitOverrideFunction = (requestContext: {
112
+ init: HTTPRequestInit;
113
+ context: RequestOpts;
114
+ }) => Promise<RequestInit>;
115
+ interface FetchParams {
116
+ url: string;
117
+ init: RequestInit;
118
+ }
119
+ interface RequestOpts {
120
+ path: string;
121
+ method: HTTPMethod;
122
+ headers: HTTPHeaders;
123
+ query?: HTTPQuery;
124
+ body?: HTTPBody;
125
+ }
126
+ declare function querystring(params: HTTPQuery, prefix?: string): string;
127
+ declare function exists(json: any, key: string): boolean;
128
+ declare function mapValues(data: any, fn: (item: any) => any): {
129
+ [key: string]: any;
130
+ };
131
+ declare function canConsumeForm(consumes: Consume[]): boolean;
132
+ interface Consume {
133
+ contentType: string;
134
+ }
135
+ interface RequestContext {
136
+ fetch: FetchAPI;
137
+ url: string;
138
+ init: RequestInit;
139
+ }
140
+ interface ResponseContext {
141
+ fetch: FetchAPI;
142
+ url: string;
143
+ init: RequestInit;
144
+ response: Response;
145
+ }
146
+ interface ErrorContext {
147
+ fetch: FetchAPI;
148
+ url: string;
149
+ init: RequestInit;
150
+ error: unknown;
151
+ response?: Response;
152
+ }
153
+ interface Middleware {
154
+ pre?(context: RequestContext): Promise<FetchParams | void>;
155
+ post?(context: ResponseContext): Promise<Response | void>;
156
+ onError?(context: ErrorContext): Promise<Response | void>;
157
+ }
158
+ interface ApiResponse<T> {
159
+ raw: Response;
160
+ value(): Promise<T>;
161
+ }
162
+ interface ResponseTransformer<T> {
163
+ (json: any): T;
164
+ }
165
+ declare class JSONApiResponse<T> {
166
+ raw: Response;
167
+ private transformer;
168
+ constructor(raw: Response, transformer?: ResponseTransformer<T>);
169
+ value(): Promise<T>;
170
+ }
171
+ declare class VoidApiResponse {
172
+ raw: Response;
173
+ constructor(raw: Response);
174
+ value(): Promise<void>;
175
+ }
176
+ declare class BlobApiResponse {
177
+ raw: Response;
178
+ constructor(raw: Response);
179
+ value(): Promise<Blob>;
180
+ }
181
+ declare class TextApiResponse {
182
+ raw: Response;
183
+ constructor(raw: Response);
184
+ value(): Promise<string>;
185
+ }
186
+ //#endregion
187
+ //#region src/models/ValidationErrorLocInner.d.ts
188
+ /**
189
+ * Sensitive Data Protection API
190
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
191
+ *
192
+ * The version of the OpenAPI document: 0.0.1
193
+ *
194
+ *
195
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
196
+ * https://openapi-generator.tech
197
+ * Do not edit the class manually.
198
+ */
199
+ /**
200
+ *
201
+ * @export
202
+ * @interface ValidationErrorLocInner
203
+ */
204
+ interface ValidationErrorLocInner {}
205
+ /**
206
+ * Check if a given object implements the ValidationErrorLocInner interface.
207
+ */
208
+ declare function instanceOfValidationErrorLocInner(value: object): value is ValidationErrorLocInner;
209
+ declare function ValidationErrorLocInnerFromJSON(json: any): ValidationErrorLocInner;
210
+ declare function ValidationErrorLocInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): ValidationErrorLocInner;
211
+ declare function ValidationErrorLocInnerToJSON(json: any): ValidationErrorLocInner;
212
+ declare function ValidationErrorLocInnerToJSONTyped(value?: ValidationErrorLocInner | null, ignoreDiscriminator?: boolean): any;
213
+ //#endregion
214
+ //#region src/models/ValidationError.d.ts
215
+ /**
216
+ *
217
+ * @export
218
+ * @interface ValidationError
219
+ */
220
+ interface ValidationError {
221
+ /**
222
+ *
223
+ * @type {Array<ValidationErrorLocInner>}
224
+ * @memberof ValidationError
225
+ */
226
+ loc: Array<ValidationErrorLocInner>;
227
+ /**
228
+ *
229
+ * @type {string}
230
+ * @memberof ValidationError
231
+ */
232
+ msg: string;
233
+ /**
234
+ *
235
+ * @type {string}
236
+ * @memberof ValidationError
237
+ */
238
+ type: string;
239
+ }
240
+ /**
241
+ * Check if a given object implements the ValidationError interface.
242
+ */
243
+ declare function instanceOfValidationError(value: object): value is ValidationError;
244
+ declare function ValidationErrorFromJSON(json: any): ValidationError;
245
+ declare function ValidationErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): ValidationError;
246
+ declare function ValidationErrorToJSON(json: any): ValidationError;
247
+ declare function ValidationErrorToJSONTyped(value?: ValidationError | null, ignoreDiscriminator?: boolean): any;
248
+ //#endregion
249
+ //#region src/models/HTTPValidationError.d.ts
250
+ /**
251
+ *
252
+ * @export
253
+ * @interface HTTPValidationError
254
+ */
255
+ interface HTTPValidationError {
256
+ /**
257
+ *
258
+ * @type {Array<ValidationError>}
259
+ * @memberof HTTPValidationError
260
+ */
261
+ detail?: Array<ValidationError>;
262
+ }
263
+ /**
264
+ * Check if a given object implements the HTTPValidationError interface.
265
+ */
266
+ declare function instanceOfHTTPValidationError(value: object): value is HTTPValidationError;
267
+ declare function HTTPValidationErrorFromJSON(json: any): HTTPValidationError;
268
+ declare function HTTPValidationErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): HTTPValidationError;
269
+ declare function HTTPValidationErrorToJSON(json: any): HTTPValidationError;
270
+ declare function HTTPValidationErrorToJSONTyped(value?: HTTPValidationError | null, ignoreDiscriminator?: boolean): any;
271
+ //#endregion
272
+ //#region src/models/ScanRequestBody.d.ts
273
+ /**
274
+ * Sensitive Data Protection API
275
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
276
+ *
277
+ * The version of the OpenAPI document: 0.0.1
278
+ *
279
+ *
280
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
281
+ * https://openapi-generator.tech
282
+ * Do not edit the class manually.
283
+ */
284
+ /**
285
+ *
286
+ * @export
287
+ * @interface ScanRequestBody
288
+ */
289
+ interface ScanRequestBody {
290
+ /**
291
+ *
292
+ * @type {string}
293
+ * @memberof ScanRequestBody
294
+ */
295
+ text: string;
296
+ /**
297
+ *
298
+ * @type {string}
299
+ * @memberof ScanRequestBody
300
+ */
301
+ language?: string;
302
+ /**
303
+ *
304
+ * @type {Array<string>}
305
+ * @memberof ScanRequestBody
306
+ */
307
+ entities?: Array<string>;
308
+ /**
309
+ *
310
+ * @type {number}
311
+ * @memberof ScanRequestBody
312
+ */
313
+ confidence_threshold?: number | null;
314
+ }
315
+ /**
316
+ * Check if a given object implements the ScanRequestBody interface.
317
+ */
318
+ declare function instanceOfScanRequestBody(value: object): value is ScanRequestBody;
319
+ declare function ScanRequestBodyFromJSON(json: any): ScanRequestBody;
320
+ declare function ScanRequestBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ScanRequestBody;
321
+ declare function ScanRequestBodyToJSON(json: any): ScanRequestBody;
322
+ declare function ScanRequestBodyToJSONTyped(value?: ScanRequestBody | null, ignoreDiscriminator?: boolean): any;
323
+ //#endregion
324
+ //#region src/models/ScanResult.d.ts
325
+ /**
326
+ * Sensitive Data Protection API
327
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
328
+ *
329
+ * The version of the OpenAPI document: 0.0.1
330
+ *
331
+ *
332
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
333
+ * https://openapi-generator.tech
334
+ * Do not edit the class manually.
335
+ */
336
+ /**
337
+ *
338
+ * @export
339
+ * @interface ScanResult
340
+ */
341
+ interface ScanResult {
342
+ /**
343
+ *
344
+ * @type {number}
345
+ * @memberof ScanResult
346
+ */
347
+ start: number;
348
+ /**
349
+ *
350
+ * @type {number}
351
+ * @memberof ScanResult
352
+ */
353
+ end: number;
354
+ /**
355
+ *
356
+ * @type {number}
357
+ * @memberof ScanResult
358
+ */
359
+ score: number;
360
+ /**
361
+ *
362
+ * @type {string}
363
+ * @memberof ScanResult
364
+ */
365
+ entity_type: string;
366
+ }
367
+ /**
368
+ * Check if a given object implements the ScanResult interface.
369
+ */
370
+ declare function instanceOfScanResult(value: object): value is ScanResult;
371
+ declare function ScanResultFromJSON(json: any): ScanResult;
372
+ declare function ScanResultFromJSONTyped(json: any, ignoreDiscriminator: boolean): ScanResult;
373
+ declare function ScanResultToJSON(json: any): ScanResult;
374
+ declare function ScanResultToJSONTyped(value?: ScanResult | null, ignoreDiscriminator?: boolean): any;
375
+ //#endregion
376
+ //#region src/models/ScanResponseBody.d.ts
377
+ /**
378
+ *
379
+ * @export
380
+ * @interface ScanResponseBody
381
+ */
382
+ interface ScanResponseBody {
383
+ /**
384
+ *
385
+ * @type {Array<ScanResult>}
386
+ * @memberof ScanResponseBody
387
+ */
388
+ results: Array<ScanResult>;
389
+ }
390
+ /**
391
+ * Check if a given object implements the ScanResponseBody interface.
392
+ */
393
+ declare function instanceOfScanResponseBody(value: object): value is ScanResponseBody;
394
+ declare function ScanResponseBodyFromJSON(json: any): ScanResponseBody;
395
+ declare function ScanResponseBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ScanResponseBody;
396
+ declare function ScanResponseBodyToJSON(json: any): ScanResponseBody;
397
+ declare function ScanResponseBodyToJSONTyped(value?: ScanResponseBody | null, ignoreDiscriminator?: boolean): any;
398
+ //#endregion
399
+ //#region src/apis/SensitiveDataProtectionApi.d.ts
400
+ interface ScanTextRequest {
401
+ ScanRequestBody: ScanRequestBody;
402
+ }
403
+ /**
404
+ *
405
+ */
406
+ declare class SensitiveDataProtectionApi extends BaseAPI {
407
+ /**
408
+ * Return basic health probe result.
409
+ * Health
410
+ */
411
+ healthCheckRaw(initOverrides?: RequestInit | InitOverrideFunction): Promise<ApiResponse<string>>;
412
+ /**
413
+ * Return basic health probe result.
414
+ * Health
415
+ */
416
+ healthCheck(initOverrides?: RequestInit | InitOverrideFunction): Promise<string>;
417
+ /**
418
+ * Scan the provided text for sensitive data.
419
+ * Scan Text
420
+ */
421
+ scanTextRaw(requestParameters: ScanTextRequest, initOverrides?: RequestInit | InitOverrideFunction): Promise<ApiResponse<ScanResponseBody>>;
422
+ /**
423
+ * Scan the provided text for sensitive data.
424
+ * Scan Text
425
+ */
426
+ scanText(ScanRequestBody: ScanRequestBody, initOverrides?: RequestInit | InitOverrideFunction): Promise<ScanResponseBody>;
427
+ }
428
+ //#endregion
429
+ export { ApiResponse, BASE_PATH, BaseAPI, BlobApiResponse, COLLECTION_FORMATS, Configuration, ConfigurationParameters, Consume, DefaultConfig, ErrorContext, FetchAPI, FetchError, FetchParams, HTTPBody, HTTPHeaders, HTTPMethod, HTTPQuery, HTTPRequestInit, HTTPValidationError, HTTPValidationErrorFromJSON, HTTPValidationErrorFromJSONTyped, HTTPValidationErrorToJSON, HTTPValidationErrorToJSONTyped, InitOverrideFunction, JSONApiResponse, Json, Middleware, ModelPropertyNaming, RequestContext, RequestOpts, RequiredError, ResponseContext, ResponseError, ResponseTransformer, ScanRequestBody, ScanRequestBodyFromJSON, ScanRequestBodyFromJSONTyped, ScanRequestBodyToJSON, ScanRequestBodyToJSONTyped, ScanResponseBody, ScanResponseBodyFromJSON, ScanResponseBodyFromJSONTyped, ScanResponseBodyToJSON, ScanResponseBodyToJSONTyped, ScanResult, ScanResultFromJSON, ScanResultFromJSONTyped, ScanResultToJSON, ScanResultToJSONTyped, ScanTextRequest, SensitiveDataProtectionApi, TextApiResponse, ValidationError, ValidationErrorFromJSON, ValidationErrorFromJSONTyped, ValidationErrorLocInner, ValidationErrorLocInnerFromJSON, ValidationErrorLocInnerFromJSONTyped, ValidationErrorLocInnerToJSON, ValidationErrorLocInnerToJSONTyped, ValidationErrorToJSON, ValidationErrorToJSONTyped, VoidApiResponse, canConsumeForm, exists, instanceOfHTTPValidationError, instanceOfScanRequestBody, instanceOfScanResponseBody, instanceOfScanResult, instanceOfValidationError, instanceOfValidationErrorLocInner, mapValues, querystring };
package/dist/index.mjs ADDED
@@ -0,0 +1,504 @@
1
+ //#region src/runtime.ts
2
+ /**
3
+ * Sensitive Data Protection API
4
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+ *
6
+ * The version of the OpenAPI document: 0.0.1
7
+ *
8
+ *
9
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10
+ * https://openapi-generator.tech
11
+ * Do not edit the class manually.
12
+ */
13
+ const BASE_PATH = "https://app.quba.ae/api/sdp".replace(/\/+$/, "");
14
+ var Configuration = class {
15
+ constructor(configuration = {}) {
16
+ this.configuration = configuration;
17
+ }
18
+ set config(configuration) {
19
+ this.configuration = configuration;
20
+ }
21
+ get basePath() {
22
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
23
+ }
24
+ get fetchApi() {
25
+ return this.configuration.fetchApi;
26
+ }
27
+ get middleware() {
28
+ return this.configuration.middleware || [];
29
+ }
30
+ get queryParamsStringify() {
31
+ return this.configuration.queryParamsStringify || querystring;
32
+ }
33
+ get username() {
34
+ return this.configuration.username;
35
+ }
36
+ get password() {
37
+ return this.configuration.password;
38
+ }
39
+ get apiKey() {
40
+ const apiKey = this.configuration.apiKey;
41
+ if (apiKey) return typeof apiKey === "function" ? apiKey : () => apiKey;
42
+ }
43
+ get accessToken() {
44
+ const accessToken = this.configuration.accessToken;
45
+ if (accessToken) return typeof accessToken === "function" ? accessToken : async () => accessToken;
46
+ }
47
+ get headers() {
48
+ return this.configuration.headers;
49
+ }
50
+ get credentials() {
51
+ return this.configuration.credentials;
52
+ }
53
+ };
54
+ const DefaultConfig = new Configuration();
55
+ /**
56
+ * This is the base class for all generated API classes.
57
+ */
58
+ var BaseAPI = class BaseAPI {
59
+ static {
60
+ this.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
61
+ }
62
+ constructor(configuration = DefaultConfig) {
63
+ this.configuration = configuration;
64
+ this.fetchApi = async (url, init) => {
65
+ let fetchParams = {
66
+ url,
67
+ init
68
+ };
69
+ for (const middleware of this.middleware) if (middleware.pre) fetchParams = await middleware.pre({
70
+ fetch: this.fetchApi,
71
+ ...fetchParams
72
+ }) || fetchParams;
73
+ let response = void 0;
74
+ try {
75
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
76
+ } catch (e) {
77
+ for (const middleware of this.middleware) if (middleware.onError) response = await middleware.onError({
78
+ fetch: this.fetchApi,
79
+ url: fetchParams.url,
80
+ init: fetchParams.init,
81
+ error: e,
82
+ response: response ? response.clone() : void 0
83
+ }) || response;
84
+ if (response === void 0) if (e instanceof Error) throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
85
+ else throw e;
86
+ }
87
+ for (const middleware of this.middleware) if (middleware.post) response = await middleware.post({
88
+ fetch: this.fetchApi,
89
+ url: fetchParams.url,
90
+ init: fetchParams.init,
91
+ response: response.clone()
92
+ }) || response;
93
+ return response;
94
+ };
95
+ this.middleware = configuration.middleware;
96
+ }
97
+ withMiddleware(...middlewares) {
98
+ const next = this.clone();
99
+ next.middleware = next.middleware.concat(...middlewares);
100
+ return next;
101
+ }
102
+ withPreMiddleware(...preMiddlewares) {
103
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
104
+ return this.withMiddleware(...middlewares);
105
+ }
106
+ withPostMiddleware(...postMiddlewares) {
107
+ const middlewares = postMiddlewares.map((post) => ({ post }));
108
+ return this.withMiddleware(...middlewares);
109
+ }
110
+ /**
111
+ * Check if the given MIME is a JSON MIME.
112
+ * JSON MIME examples:
113
+ * application/json
114
+ * application/json; charset=UTF8
115
+ * APPLICATION/JSON
116
+ * application/vnd.company+json
117
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
118
+ * @return True if the given MIME is JSON, false otherwise.
119
+ */
120
+ isJsonMime(mime) {
121
+ if (!mime) return false;
122
+ return BaseAPI.jsonRegex.test(mime);
123
+ }
124
+ async request(context, initOverrides) {
125
+ const { url, init } = await this.createFetchParams(context, initOverrides);
126
+ const response = await this.fetchApi(url, init);
127
+ if (response && response.status >= 200 && response.status < 300) return response;
128
+ throw new ResponseError(response, "Response returned an error code");
129
+ }
130
+ async createFetchParams(context, initOverrides) {
131
+ let url = this.configuration.basePath + context.path;
132
+ if (context.query !== void 0 && Object.keys(context.query).length !== 0) url += "?" + this.configuration.queryParamsStringify(context.query);
133
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
134
+ Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
135
+ const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
136
+ const initParams = {
137
+ method: context.method,
138
+ headers,
139
+ body: context.body,
140
+ credentials: this.configuration.credentials
141
+ };
142
+ const overriddenInit = {
143
+ ...initParams,
144
+ ...await initOverrideFn({
145
+ init: initParams,
146
+ context
147
+ })
148
+ };
149
+ let body;
150
+ if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) body = overriddenInit.body;
151
+ else if (this.isJsonMime(headers["Content-Type"])) body = JSON.stringify(overriddenInit.body);
152
+ else body = overriddenInit.body;
153
+ const init = {
154
+ ...overriddenInit,
155
+ body
156
+ };
157
+ return {
158
+ url,
159
+ init
160
+ };
161
+ }
162
+ /**
163
+ * Create a shallow clone of `this` by constructing a new instance
164
+ * and then shallow cloning data members.
165
+ */
166
+ clone() {
167
+ const constructor = this.constructor;
168
+ const next = new constructor(this.configuration);
169
+ next.middleware = this.middleware.slice();
170
+ return next;
171
+ }
172
+ };
173
+ function isBlob(value) {
174
+ return typeof Blob !== "undefined" && value instanceof Blob;
175
+ }
176
+ function isFormData(value) {
177
+ return typeof FormData !== "undefined" && value instanceof FormData;
178
+ }
179
+ var ResponseError = class extends Error {
180
+ constructor(response, msg) {
181
+ super(msg);
182
+ this.response = response;
183
+ this.name = "ResponseError";
184
+ }
185
+ };
186
+ var FetchError = class extends Error {
187
+ constructor(cause, msg) {
188
+ super(msg);
189
+ this.cause = cause;
190
+ this.name = "FetchError";
191
+ }
192
+ };
193
+ var RequiredError = class extends Error {
194
+ constructor(field, msg) {
195
+ super(msg);
196
+ this.field = field;
197
+ this.name = "RequiredError";
198
+ }
199
+ };
200
+ const COLLECTION_FORMATS = {
201
+ csv: ",",
202
+ ssv: " ",
203
+ tsv: " ",
204
+ pipes: "|"
205
+ };
206
+ function querystring(params, prefix = "") {
207
+ return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
208
+ }
209
+ function querystringSingleKey(key, value, keyPrefix = "") {
210
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
211
+ if (value instanceof Array) {
212
+ const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
213
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
214
+ }
215
+ if (value instanceof Set) return querystringSingleKey(key, Array.from(value), keyPrefix);
216
+ if (value instanceof Date) return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
217
+ if (value instanceof Object) return querystring(value, fullKey);
218
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
219
+ }
220
+ function exists(json, key) {
221
+ const value = json[key];
222
+ return value !== null && value !== void 0;
223
+ }
224
+ function mapValues(data, fn) {
225
+ const result = {};
226
+ for (const key of Object.keys(data)) result[key] = fn(data[key]);
227
+ return result;
228
+ }
229
+ function canConsumeForm(consumes) {
230
+ for (const consume of consumes) if ("multipart/form-data" === consume.contentType) return true;
231
+ return false;
232
+ }
233
+ var JSONApiResponse = class {
234
+ constructor(raw, transformer = (jsonValue) => jsonValue) {
235
+ this.raw = raw;
236
+ this.transformer = transformer;
237
+ }
238
+ async value() {
239
+ return this.transformer(await this.raw.json());
240
+ }
241
+ };
242
+ var VoidApiResponse = class {
243
+ constructor(raw) {
244
+ this.raw = raw;
245
+ }
246
+ async value() {}
247
+ };
248
+ var BlobApiResponse = class {
249
+ constructor(raw) {
250
+ this.raw = raw;
251
+ }
252
+ async value() {
253
+ return await this.raw.blob();
254
+ }
255
+ };
256
+ var TextApiResponse = class {
257
+ constructor(raw) {
258
+ this.raw = raw;
259
+ }
260
+ async value() {
261
+ return await this.raw.text();
262
+ }
263
+ };
264
+
265
+ //#endregion
266
+ //#region src/models/ValidationErrorLocInner.ts
267
+ /**
268
+ * Check if a given object implements the ValidationErrorLocInner interface.
269
+ */
270
+ function instanceOfValidationErrorLocInner(value) {
271
+ return true;
272
+ }
273
+ function ValidationErrorLocInnerFromJSON(json) {
274
+ return ValidationErrorLocInnerFromJSONTyped(json, false);
275
+ }
276
+ function ValidationErrorLocInnerFromJSONTyped(json, ignoreDiscriminator) {
277
+ return json;
278
+ }
279
+ function ValidationErrorLocInnerToJSON(json) {
280
+ return ValidationErrorLocInnerToJSONTyped(json, false);
281
+ }
282
+ function ValidationErrorLocInnerToJSONTyped(value, ignoreDiscriminator = false) {
283
+ return value;
284
+ }
285
+
286
+ //#endregion
287
+ //#region src/models/ValidationError.ts
288
+ /**
289
+ * Check if a given object implements the ValidationError interface.
290
+ */
291
+ function instanceOfValidationError(value) {
292
+ if (!("loc" in value) || value["loc"] === void 0) return false;
293
+ if (!("msg" in value) || value["msg"] === void 0) return false;
294
+ if (!("type" in value) || value["type"] === void 0) return false;
295
+ return true;
296
+ }
297
+ function ValidationErrorFromJSON(json) {
298
+ return ValidationErrorFromJSONTyped(json, false);
299
+ }
300
+ function ValidationErrorFromJSONTyped(json, ignoreDiscriminator) {
301
+ if (json == null) return json;
302
+ return {
303
+ "loc": json["loc"].map(ValidationErrorLocInnerFromJSON),
304
+ "msg": json["msg"],
305
+ "type": json["type"]
306
+ };
307
+ }
308
+ function ValidationErrorToJSON(json) {
309
+ return ValidationErrorToJSONTyped(json, false);
310
+ }
311
+ function ValidationErrorToJSONTyped(value, ignoreDiscriminator = false) {
312
+ if (value == null) return value;
313
+ return {
314
+ "loc": value["loc"].map(ValidationErrorLocInnerToJSON),
315
+ "msg": value["msg"],
316
+ "type": value["type"]
317
+ };
318
+ }
319
+
320
+ //#endregion
321
+ //#region src/models/HTTPValidationError.ts
322
+ /**
323
+ * Check if a given object implements the HTTPValidationError interface.
324
+ */
325
+ function instanceOfHTTPValidationError(value) {
326
+ return true;
327
+ }
328
+ function HTTPValidationErrorFromJSON(json) {
329
+ return HTTPValidationErrorFromJSONTyped(json, false);
330
+ }
331
+ function HTTPValidationErrorFromJSONTyped(json, ignoreDiscriminator) {
332
+ if (json == null) return json;
333
+ return { "detail": json["detail"] == null ? void 0 : json["detail"].map(ValidationErrorFromJSON) };
334
+ }
335
+ function HTTPValidationErrorToJSON(json) {
336
+ return HTTPValidationErrorToJSONTyped(json, false);
337
+ }
338
+ function HTTPValidationErrorToJSONTyped(value, ignoreDiscriminator = false) {
339
+ if (value == null) return value;
340
+ return { "detail": value["detail"] == null ? void 0 : value["detail"].map(ValidationErrorToJSON) };
341
+ }
342
+
343
+ //#endregion
344
+ //#region src/models/ScanRequestBody.ts
345
+ /**
346
+ * Check if a given object implements the ScanRequestBody interface.
347
+ */
348
+ function instanceOfScanRequestBody(value) {
349
+ if (!("text" in value) || value["text"] === void 0) return false;
350
+ return true;
351
+ }
352
+ function ScanRequestBodyFromJSON(json) {
353
+ return ScanRequestBodyFromJSONTyped(json, false);
354
+ }
355
+ function ScanRequestBodyFromJSONTyped(json, ignoreDiscriminator) {
356
+ if (json == null) return json;
357
+ return {
358
+ "text": json["text"],
359
+ "language": json["language"] == null ? void 0 : json["language"],
360
+ "entities": json["entities"] == null ? void 0 : json["entities"],
361
+ "confidence_threshold": json["confidence_threshold"] == null ? void 0 : json["confidence_threshold"]
362
+ };
363
+ }
364
+ function ScanRequestBodyToJSON(json) {
365
+ return ScanRequestBodyToJSONTyped(json, false);
366
+ }
367
+ function ScanRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
368
+ if (value == null) return value;
369
+ return {
370
+ "text": value["text"],
371
+ "language": value["language"],
372
+ "entities": value["entities"],
373
+ "confidence_threshold": value["confidence_threshold"]
374
+ };
375
+ }
376
+
377
+ //#endregion
378
+ //#region src/models/ScanResult.ts
379
+ /**
380
+ * Check if a given object implements the ScanResult interface.
381
+ */
382
+ function instanceOfScanResult(value) {
383
+ if (!("start" in value) || value["start"] === void 0) return false;
384
+ if (!("end" in value) || value["end"] === void 0) return false;
385
+ if (!("score" in value) || value["score"] === void 0) return false;
386
+ if (!("entity_type" in value) || value["entity_type"] === void 0) return false;
387
+ return true;
388
+ }
389
+ function ScanResultFromJSON(json) {
390
+ return ScanResultFromJSONTyped(json, false);
391
+ }
392
+ function ScanResultFromJSONTyped(json, ignoreDiscriminator) {
393
+ if (json == null) return json;
394
+ return {
395
+ "start": json["start"],
396
+ "end": json["end"],
397
+ "score": json["score"],
398
+ "entity_type": json["entity_type"]
399
+ };
400
+ }
401
+ function ScanResultToJSON(json) {
402
+ return ScanResultToJSONTyped(json, false);
403
+ }
404
+ function ScanResultToJSONTyped(value, ignoreDiscriminator = false) {
405
+ if (value == null) return value;
406
+ return {
407
+ "start": value["start"],
408
+ "end": value["end"],
409
+ "score": value["score"],
410
+ "entity_type": value["entity_type"]
411
+ };
412
+ }
413
+
414
+ //#endregion
415
+ //#region src/models/ScanResponseBody.ts
416
+ /**
417
+ * Check if a given object implements the ScanResponseBody interface.
418
+ */
419
+ function instanceOfScanResponseBody(value) {
420
+ if (!("results" in value) || value["results"] === void 0) return false;
421
+ return true;
422
+ }
423
+ function ScanResponseBodyFromJSON(json) {
424
+ return ScanResponseBodyFromJSONTyped(json, false);
425
+ }
426
+ function ScanResponseBodyFromJSONTyped(json, ignoreDiscriminator) {
427
+ if (json == null) return json;
428
+ return { "results": json["results"].map(ScanResultFromJSON) };
429
+ }
430
+ function ScanResponseBodyToJSON(json) {
431
+ return ScanResponseBodyToJSONTyped(json, false);
432
+ }
433
+ function ScanResponseBodyToJSONTyped(value, ignoreDiscriminator = false) {
434
+ if (value == null) return value;
435
+ return { "results": value["results"].map(ScanResultToJSON) };
436
+ }
437
+
438
+ //#endregion
439
+ //#region src/apis/SensitiveDataProtectionApi.ts
440
+ /**
441
+ * Sensitive Data Protection API
442
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
443
+ *
444
+ * The version of the OpenAPI document: 0.0.1
445
+ *
446
+ *
447
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
448
+ * https://openapi-generator.tech
449
+ * Do not edit the class manually.
450
+ */
451
+ /**
452
+ *
453
+ */
454
+ var SensitiveDataProtectionApi = class extends BaseAPI {
455
+ /**
456
+ * Return basic health probe result.
457
+ * Health
458
+ */
459
+ async healthCheckRaw(initOverrides) {
460
+ const response = await this.request({
461
+ path: `/health`,
462
+ method: "GET",
463
+ headers: {},
464
+ query: {}
465
+ }, initOverrides);
466
+ if (this.isJsonMime(response.headers.get("content-type"))) return new JSONApiResponse(response);
467
+ else return new TextApiResponse(response);
468
+ }
469
+ /**
470
+ * Return basic health probe result.
471
+ * Health
472
+ */
473
+ async healthCheck(initOverrides) {
474
+ return await (await this.healthCheckRaw(initOverrides)).value();
475
+ }
476
+ /**
477
+ * Scan the provided text for sensitive data.
478
+ * Scan Text
479
+ */
480
+ async scanTextRaw(requestParameters, initOverrides) {
481
+ if (requestParameters["ScanRequestBody"] == null) throw new RequiredError("ScanRequestBody", "Required parameter \"ScanRequestBody\" was null or undefined when calling scanText().");
482
+ const queryParameters = {};
483
+ const headerParameters = {};
484
+ headerParameters["Content-Type"] = "application/json";
485
+ const response = await this.request({
486
+ path: `/scan`,
487
+ method: "POST",
488
+ headers: headerParameters,
489
+ query: queryParameters,
490
+ body: ScanRequestBodyToJSON(requestParameters["ScanRequestBody"])
491
+ }, initOverrides);
492
+ return new JSONApiResponse(response, (jsonValue) => ScanResponseBodyFromJSON(jsonValue));
493
+ }
494
+ /**
495
+ * Scan the provided text for sensitive data.
496
+ * Scan Text
497
+ */
498
+ async scanText(ScanRequestBody, initOverrides) {
499
+ return await (await this.scanTextRaw({ ScanRequestBody }, initOverrides)).value();
500
+ }
501
+ };
502
+
503
+ //#endregion
504
+ export { BASE_PATH, BaseAPI, BlobApiResponse, COLLECTION_FORMATS, Configuration, DefaultConfig, FetchError, HTTPValidationErrorFromJSON, HTTPValidationErrorFromJSONTyped, HTTPValidationErrorToJSON, HTTPValidationErrorToJSONTyped, JSONApiResponse, RequiredError, ResponseError, ScanRequestBodyFromJSON, ScanRequestBodyFromJSONTyped, ScanRequestBodyToJSON, ScanRequestBodyToJSONTyped, ScanResponseBodyFromJSON, ScanResponseBodyFromJSONTyped, ScanResponseBodyToJSON, ScanResponseBodyToJSONTyped, ScanResultFromJSON, ScanResultFromJSONTyped, ScanResultToJSON, ScanResultToJSONTyped, SensitiveDataProtectionApi, TextApiResponse, ValidationErrorFromJSON, ValidationErrorFromJSONTyped, ValidationErrorLocInnerFromJSON, ValidationErrorLocInnerFromJSONTyped, ValidationErrorLocInnerToJSON, ValidationErrorLocInnerToJSONTyped, ValidationErrorToJSON, ValidationErrorToJSONTyped, VoidApiResponse, canConsumeForm, exists, instanceOfHTTPValidationError, instanceOfScanRequestBody, instanceOfScanResponseBody, instanceOfScanResult, instanceOfValidationError, instanceOfValidationErrorLocInner, mapValues, querystring };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@quba/sensitive-data-protection",
3
+ "description": "SDK for Sensitive Data Protection Service",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "homepage": "https://quba.ae",
7
+ "version": "0.0.1",
8
+ "keywords": [
9
+ "sensitive data protection",
10
+ "sdp",
11
+ "de-identification",
12
+ "data privacy",
13
+ "data anonymization",
14
+ "dlp",
15
+ "data loss prevention",
16
+ "pii",
17
+ "personal data"
18
+ ],
19
+ "author": "Quba Ltd",
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "dist",
24
+ "src/docs",
25
+ "README.md"
26
+ ],
27
+ "exports": {
28
+ ".": {
29
+ "import": "./dist/index.js",
30
+ "types": "./dist/index.d.ts"
31
+ }
32
+ },
33
+ "scripts": {
34
+ "build": "tsdown"
35
+ },
36
+ "packageManager": "pnpm@10.26.2",
37
+ "devDependencies": {
38
+ "tsdown": "0.18.4",
39
+ "typescript": "^5.9.3"
40
+ }
41
+ }