diff --git a/src/ _generated_/rest/Client.ts b/src/ _generated_/rest/Client.ts index ebbf651b..0ca90c4e 100644 --- a/src/ _generated_/rest/Client.ts +++ b/src/ _generated_/rest/Client.ts @@ -10,6 +10,9 @@ import { Records } from "./api/resources/records/client/Client"; import { Tokens } from "./api/resources/tokens/client/Client"; import { Query } from "./api/resources/query/client/Client"; import { Authentication } from "./api/resources/authentication/client/Client"; +import { Deprecated } from "./api/resources/deprecated/client/Client"; +import { Strings } from "./api/resources/strings/client/Client"; +import { Files } from "./api/resources/files/client/Client"; export declare namespace SkyflowClient { export interface Options { @@ -39,6 +42,9 @@ export class SkyflowClient { protected _tokens: Tokens | undefined; protected _query: Query | undefined; protected _authentication: Authentication | undefined; + protected _deprecated: Deprecated | undefined; + protected _strings: Strings | undefined; + protected _files: Files | undefined; constructor(protected readonly _options: SkyflowClient.Options) {} @@ -65,4 +71,16 @@ export class SkyflowClient { public get authentication(): Authentication { return (this._authentication ??= new Authentication(this._options)); } + + public get deprecated(): Deprecated { + return (this._deprecated ??= new Deprecated(this._options)); + } + + public get strings(): Strings { + return (this._strings ??= new Strings(this._options)); + } + + public get files(): Files { + return (this._files ??= new Files(this._options)); + } } diff --git a/src/ _generated_/rest/api/errors/BadRequestError.ts b/src/ _generated_/rest/api/errors/BadRequestError.ts index e19131a1..1776da9a 100644 --- a/src/ _generated_/rest/api/errors/BadRequestError.ts +++ b/src/ _generated_/rest/api/errors/BadRequestError.ts @@ -6,7 +6,7 @@ import * as errors from "../../errors/index"; import * as core from "../../core"; export class BadRequestError extends errors.SkyflowError { - constructor(body: Record, rawResponse?: core.RawResponse) { + constructor(body?: unknown, rawResponse?: core.RawResponse) { super({ message: "BadRequestError", statusCode: 400, diff --git a/src/ _generated_/rest/api/errors/InternalServerError.ts b/src/ _generated_/rest/api/errors/InternalServerError.ts new file mode 100644 index 00000000..4141147e --- /dev/null +++ b/src/ _generated_/rest/api/errors/InternalServerError.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors/index"; +import * as Skyflow from "../index"; +import * as core from "../../core"; + +export class InternalServerError extends errors.SkyflowError { + constructor(body: Skyflow.ErrorResponse, rawResponse?: core.RawResponse) { + super({ + message: "InternalServerError", + statusCode: 500, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, InternalServerError.prototype); + } +} diff --git a/src/ _generated_/rest/api/errors/NotFoundError.ts b/src/ _generated_/rest/api/errors/NotFoundError.ts index ff59e84a..357bc100 100644 --- a/src/ _generated_/rest/api/errors/NotFoundError.ts +++ b/src/ _generated_/rest/api/errors/NotFoundError.ts @@ -6,7 +6,7 @@ import * as errors from "../../errors/index"; import * as core from "../../core"; export class NotFoundError extends errors.SkyflowError { - constructor(body: Record, rawResponse?: core.RawResponse) { + constructor(body?: unknown, rawResponse?: core.RawResponse) { super({ message: "NotFoundError", statusCode: 404, diff --git a/src/ _generated_/rest/api/errors/UnauthorizedError.ts b/src/ _generated_/rest/api/errors/UnauthorizedError.ts index 73c2b114..5dc2279b 100644 --- a/src/ _generated_/rest/api/errors/UnauthorizedError.ts +++ b/src/ _generated_/rest/api/errors/UnauthorizedError.ts @@ -6,7 +6,7 @@ import * as errors from "../../errors/index"; import * as core from "../../core"; export class UnauthorizedError extends errors.SkyflowError { - constructor(body: Record, rawResponse?: core.RawResponse) { + constructor(body?: unknown, rawResponse?: core.RawResponse) { super({ message: "UnauthorizedError", statusCode: 401, diff --git a/src/ _generated_/rest/api/errors/index.ts b/src/ _generated_/rest/api/errors/index.ts index f88b64db..07acead1 100644 --- a/src/ _generated_/rest/api/errors/index.ts +++ b/src/ _generated_/rest/api/errors/index.ts @@ -1,3 +1,4 @@ export * from "./NotFoundError"; export * from "./BadRequestError"; export * from "./UnauthorizedError"; +export * from "./InternalServerError"; diff --git a/src/ _generated_/rest/api/resources/audit/client/Client.ts b/src/ _generated_/rest/api/resources/audit/client/Client.ts index 89b42416..a184cd0a 100644 --- a/src/ _generated_/rest/api/resources/audit/client/Client.ts +++ b/src/ _generated_/rest/api/resources/audit/client/Client.ts @@ -253,10 +253,7 @@ export class Audit { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, diff --git a/src/ _generated_/rest/api/resources/authentication/client/Client.ts b/src/ _generated_/rest/api/resources/authentication/client/Client.ts index 7c3b0039..63edf19c 100644 --- a/src/ _generated_/rest/api/resources/authentication/client/Client.ts +++ b/src/ _generated_/rest/api/resources/authentication/client/Client.ts @@ -91,20 +91,11 @@ export class Authentication { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Skyflow.BadRequestError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Skyflow.UnauthorizedError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, diff --git a/src/ _generated_/rest/api/resources/binLookup/client/Client.ts b/src/ _generated_/rest/api/resources/binLookup/client/Client.ts index 2a88056a..f25ff9d6 100644 --- a/src/ _generated_/rest/api/resources/binLookup/client/Client.ts +++ b/src/ _generated_/rest/api/resources/binLookup/client/Client.ts @@ -88,10 +88,7 @@ export class BinLookup { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, diff --git a/src/ _generated_/rest/api/resources/deprecated/client/Client.ts b/src/ _generated_/rest/api/resources/deprecated/client/Client.ts new file mode 100644 index 00000000..77006f92 --- /dev/null +++ b/src/ _generated_/rest/api/resources/deprecated/client/Client.ts @@ -0,0 +1,305 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Skyflow from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Deprecated { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + } +} + +export class Deprecated { + constructor(protected readonly _options: Deprecated.Options) {} + + /** + * Note: This operation is deprecated. Use one of the De-identify File operations.

Detects and deidentifies sensitive data from image, audio, and video files. + * + * @param {Skyflow.V1DetectFileRequest} request + * @param {Deprecated.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.NotFoundError} + * + * @example + * await client.deprecated.detectServiceDetectFileInput({ + * file: "fkdjfhdlnnggtsjj...", + * data_format: "mp3", + * input_type: "BASE64", + * vault_id: "a372f752689c9bfc8ca3d4dba", + * restrict_entity_types: ["name", "age", "location", "ssn", "bank_account", "credit_card", "credit_card_expiration", "cvv", "date", "date_interval", "dob", "driver_license", "email_address", "healthcare_number", "numerical_pii", "phone_number", "medical_code", "account_number", "gender_sexuality", "name_medical_professional", "occupation", "organization", "organization_medical_facility"], + * return_entities: true, + * accuracy: "high_multilingual", + * audio: { + * output_transcription: "none", + * output_processed_audio: false + * } + * }) + */ + public detectServiceDetectFileInput( + request: Skyflow.V1DetectFileRequest, + requestOptions?: Deprecated.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detectServiceDetectFileInput(request, requestOptions)); + } + + private async __detectServiceDetectFileInput( + request: Skyflow.V1DetectFileRequest, + requestOptions?: Deprecated.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/file", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.V1DetectFileResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError("Timeout exceeded when calling POST /v1/detect/file."); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Note: This operation is deprecated. Use Get Detect Run.

Returns the status of a file deidentification request. + * + * @param {string} id - ID of the deidentification request. + * @param {Skyflow.DetectServiceDetectStatusRequest} request + * @param {Deprecated.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.NotFoundError} + * + * @example + * await client.deprecated.detectServiceDetectStatus("ID") + */ + public detectServiceDetectStatus( + id: string, + request: Skyflow.DetectServiceDetectStatusRequest = {}, + requestOptions?: Deprecated.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detectServiceDetectStatus(id, request, requestOptions)); + } + + private async __detectServiceDetectStatus( + id: string, + request: Skyflow.DetectServiceDetectStatusRequest = {}, + requestOptions?: Deprecated.RequestOptions, + ): Promise> { + const { vault_id: vaultId } = request; + const _queryParams: Record = {}; + if (vaultId != null) { + _queryParams["vault_id"] = vaultId; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + `v1/detect/status/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.V1DetectStatusResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError("Timeout exceeded when calling GET /v1/detect/status/{ID}."); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Note: This operation is deprecated. Use De-identify String.

Detects and deidentifies sensitive data from text. + * + * @param {Skyflow.DetectServiceDetectTextRequest} request + * @param {Deprecated.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.NotFoundError} + * + * @example + * await client.deprecated.detectServiceDetectText({ + * text: "text", + * vault_id: "c848741aefb74bf38780da5399a76507" + * }) + */ + public detectServiceDetectText( + request: Skyflow.DetectServiceDetectTextRequest, + requestOptions?: Deprecated.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detectServiceDetectText(request, requestOptions)); + } + + private async __detectServiceDetectText( + request: Skyflow.DetectServiceDetectTextRequest, + requestOptions?: Deprecated.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/text", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.V1DetectTextResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError("Timeout exceeded when calling POST /v1/detect/text."); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/ _generated_/rest/api/resources/deprecated/client/index.ts b/src/ _generated_/rest/api/resources/deprecated/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/ _generated_/rest/api/resources/deprecated/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/ _generated_/rest/api/resources/deprecated/client/requests/DetectServiceDetectStatusRequest.ts b/src/ _generated_/rest/api/resources/deprecated/client/requests/DetectServiceDetectStatusRequest.ts new file mode 100644 index 00000000..aa322f8e --- /dev/null +++ b/src/ _generated_/rest/api/resources/deprecated/client/requests/DetectServiceDetectStatusRequest.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface DetectServiceDetectStatusRequest { + /** + * ID of the vault. + */ + vault_id?: string; +} diff --git a/src/ _generated_/rest/api/resources/deprecated/client/requests/DetectServiceDetectTextRequest.ts b/src/ _generated_/rest/api/resources/deprecated/client/requests/DetectServiceDetectTextRequest.ts new file mode 100644 index 00000000..2ca28786 --- /dev/null +++ b/src/ _generated_/rest/api/resources/deprecated/client/requests/DetectServiceDetectTextRequest.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * text: "text", + * vault_id: "c848741aefb74bf38780da5399a76507" + * } + */ +export interface DetectServiceDetectTextRequest { + /** Data to deidentify. */ + text: string; + /** ID of the vault. */ + vault_id: string; + /** Will give a handle to delete the tokens generated during a specific interaction. */ + session_id?: string; + /** Entities to detect and deidentify. */ + restrict_entity_types?: Skyflow.DetectDataEntities[]; + deidentify_token_format?: Skyflow.DetectRequestDeidentifyOption; + /** Regular expressions to ignore when detecting entities. */ + allow_regex?: string[]; + /** Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'. */ + restrict_regex?: string[]; + /** If `true`, returns the details for the detected entities. */ + return_entities?: boolean; + accuracy?: Skyflow.DetectDataAccuracy; + advanced_options?: Skyflow.V1AdvancedOptions; + /** Indicates whether entities should be stored in the vault. */ + store_entities?: boolean; +} diff --git a/src/ _generated_/rest/api/resources/deprecated/client/requests/V1DetectFileRequest.ts b/src/ _generated_/rest/api/resources/deprecated/client/requests/V1DetectFileRequest.ts new file mode 100644 index 00000000..8164b613 --- /dev/null +++ b/src/ _generated_/rest/api/resources/deprecated/client/requests/V1DetectFileRequest.ts @@ -0,0 +1,46 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * file: "fkdjfhdlnnggtsjj...", + * data_format: "mp3", + * input_type: "BASE64", + * vault_id: "a372f752689c9bfc8ca3d4dba", + * restrict_entity_types: ["name", "age", "location", "ssn", "bank_account", "credit_card", "credit_card_expiration", "cvv", "date", "date_interval", "dob", "driver_license", "email_address", "healthcare_number", "numerical_pii", "phone_number", "medical_code", "account_number", "gender_sexuality", "name_medical_professional", "occupation", "organization", "organization_medical_facility"], + * return_entities: true, + * accuracy: "high_multilingual", + * audio: { + * output_transcription: "none", + * output_processed_audio: false + * } + * } + */ +export interface V1DetectFileRequest { + /** Path of the file or base64-encoded data that has to be processed. */ + file: string; + data_format: Skyflow.V1FileDataFormat; + input_type: Skyflow.DetectFileRequestDataType; + /** ID of the vault. */ + vault_id: string; + /** Will give a handle to delete the tokens generated during a specific interaction. */ + session_id?: string; + /** Entities to detect and deidentify. */ + restrict_entity_types?: Skyflow.DetectDataEntities[]; + /** Regular expressions to ignore when detecting entities. */ + allow_regex?: string[]; + /** Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'. */ + restrict_regex?: string[]; + /** If `true`, returns the details for the detected entities. */ + return_entities?: boolean; + accuracy?: Skyflow.DetectDataAccuracy; + audio?: Skyflow.V1AudioConfig; + image?: Skyflow.V1ImageOptions; + pdf?: Skyflow.V1PdfConfig; + advanced_options?: Skyflow.V1AdvancedOptions; + deidentify_token_format?: Skyflow.DetectRequestDeidentifyOption; +} diff --git a/src/ _generated_/rest/api/resources/deprecated/client/requests/index.ts b/src/ _generated_/rest/api/resources/deprecated/client/requests/index.ts new file mode 100644 index 00000000..7720b72e --- /dev/null +++ b/src/ _generated_/rest/api/resources/deprecated/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type V1DetectFileRequest } from "./V1DetectFileRequest"; +export { type DetectServiceDetectStatusRequest } from "./DetectServiceDetectStatusRequest"; +export { type DetectServiceDetectTextRequest } from "./DetectServiceDetectTextRequest"; diff --git a/src/ _generated_/rest/api/resources/deprecated/index.ts b/src/ _generated_/rest/api/resources/deprecated/index.ts new file mode 100644 index 00000000..5ec76921 --- /dev/null +++ b/src/ _generated_/rest/api/resources/deprecated/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/ _generated_/rest/api/resources/files/client/Client.ts b/src/ _generated_/rest/api/resources/files/client/Client.ts new file mode 100644 index 00000000..02e6bfca --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/Client.ts @@ -0,0 +1,1100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Skyflow from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Files { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + } +} + +export class Files { + constructor(protected readonly _options: Files.Options) {} + + /** + * De-identifies sensitive data from a file. This operation includes options applicable to all supported file types.

For more specific options, see the category-specific operations (like De-identify Document) and the file type-specific opertions (like De-identify PDF). + * + * @param {Skyflow.DeidentifyFileRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.files.deidentifyFile({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "Zm9vYmFy", + * data_format: "txt" + * } + * }) + * + * @example + * await client.files.deidentifyFile({ + * vault_id: "VAULT_ID", + * file: { + * base64: "Zm9vYmFy", + * data_format: "txt" + * } + * }) + */ + public deidentifyFile( + request: Skyflow.DeidentifyFileRequest, + requestOptions?: Files.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deidentifyFile(request, requestOptions)); + } + + private async __deidentifyFile( + request: Skyflow.DeidentifyFileRequest, + requestOptions?: Files.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/deidentify/file", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyFileResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError("Timeout exceeded when calling POST /v1/detect/deidentify/file."); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * De-identifies sensitive data from a document file. This operation includes options applicable to all supported document file types.

For more specific options, see the file type-specific opertions (like De-identify PDF) where they're available. For broader file type support, see De-identify File. + * + * @param {Skyflow.DeidentifyDocumentRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.files.deidentifyDocument({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "docx" + * } + * }) + * + * @example + * await client.files.deidentifyDocument({ + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "docx" + * } + * }) + */ + public deidentifyDocument( + request: Skyflow.DeidentifyDocumentRequest, + requestOptions?: Files.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deidentifyDocument(request, requestOptions)); + } + + private async __deidentifyDocument( + request: Skyflow.DeidentifyDocumentRequest, + requestOptions?: Files.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/deidentify/file/document", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyFileResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError( + "Timeout exceeded when calling POST /v1/detect/deidentify/file/document.", + ); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * De-identifies sensitive data from a PDF file. This operation includes options specific to PDF files.

For broader file type support, see De-identify Document and De-identify File. + * + * @param {Skyflow.DeidentifyPdfRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.files.deidentifyPdf({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "pdf" + * } + * }) + * + * @example + * await client.files.deidentifyPdf({ + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "pdf" + * } + * }) + */ + public deidentifyPdf( + request: Skyflow.DeidentifyPdfRequest, + requestOptions?: Files.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deidentifyPdf(request, requestOptions)); + } + + private async __deidentifyPdf( + request: Skyflow.DeidentifyPdfRequest, + requestOptions?: Files.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/deidentify/file/document/pdf", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyFileResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError( + "Timeout exceeded when calling POST /v1/detect/deidentify/file/document/pdf.", + ); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * De-identifies sensitive data from an image file. This operation includes options applicable to all supported image file types.

For broader file type support, see De-identify File. + * + * @param {Skyflow.DeidentifyImageRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.files.deidentifyImage({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "jpg" + * } + * }) + * + * @example + * await client.files.deidentifyImage({ + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "jpg" + * } + * }) + */ + public deidentifyImage( + request: Skyflow.DeidentifyImageRequest, + requestOptions?: Files.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deidentifyImage(request, requestOptions)); + } + + private async __deidentifyImage( + request: Skyflow.DeidentifyImageRequest, + requestOptions?: Files.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/deidentify/file/image", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyFileResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError( + "Timeout exceeded when calling POST /v1/detect/deidentify/file/image.", + ); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * De-identifies sensitive data from a text file. This operation includes options applicable to all supported image text types.

For broader file type support, see De-identify File. + * + * @param {Skyflow.DeidentifyTextRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.files.deidentifyText({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "Zm9vYmFy", + * data_format: "txt" + * } + * }) + * + * @example + * await client.files.deidentifyText({ + * vault_id: "VAULT_ID", + * file: { + * base64: "Zm9vYmFy", + * data_format: "txt" + * } + * }) + */ + public deidentifyText( + request: Skyflow.DeidentifyTextRequest, + requestOptions?: Files.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deidentifyText(request, requestOptions)); + } + + private async __deidentifyText( + request: Skyflow.DeidentifyTextRequest, + requestOptions?: Files.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/deidentify/file/text", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyFileResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError( + "Timeout exceeded when calling POST /v1/detect/deidentify/file/text.", + ); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * De-identifies sensitive data from a structured text file. This operation includes options applicable to all supported structured text file types.

For broader file type support, see De-identify File. + * + * @param {Skyflow.DeidentifyStructuredTextRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.files.deidentifyStructuredText({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "json" + * } + * }) + * + * @example + * await client.files.deidentifyStructuredText({ + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "json" + * } + * }) + */ + public deidentifyStructuredText( + request: Skyflow.DeidentifyStructuredTextRequest, + requestOptions?: Files.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deidentifyStructuredText(request, requestOptions)); + } + + private async __deidentifyStructuredText( + request: Skyflow.DeidentifyStructuredTextRequest, + requestOptions?: Files.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/deidentify/file/structured_text", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyFileResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError( + "Timeout exceeded when calling POST /v1/detect/deidentify/file/structured_text.", + ); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * De-identifies sensitive data from a spreadsheet file. This operation includes options applicable to all supported spreadsheet file types.

For broader file type support, see De-identify File. + * + * @param {Skyflow.DeidentifySpreadsheetRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.files.deidentifySpreadsheet({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "csv" + * } + * }) + * + * @example + * await client.files.deidentifySpreadsheet({ + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "csv" + * } + * }) + */ + public deidentifySpreadsheet( + request: Skyflow.DeidentifySpreadsheetRequest, + requestOptions?: Files.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deidentifySpreadsheet(request, requestOptions)); + } + + private async __deidentifySpreadsheet( + request: Skyflow.DeidentifySpreadsheetRequest, + requestOptions?: Files.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/deidentify/file/spreadsheet", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyFileResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError( + "Timeout exceeded when calling POST /v1/detect/deidentify/file/spreadsheet.", + ); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * De-identifies sensitive data from a presentation file. This operation includes options applicable to all supported presentation file types.

For broader file type support, see De-identify File. + * + * @param {Skyflow.DeidentifyPresentationRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.files.deidentifyPresentation({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "pptx" + * } + * }) + * + * @example + * await client.files.deidentifyPresentation({ + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "pptx" + * } + * }) + */ + public deidentifyPresentation( + request: Skyflow.DeidentifyPresentationRequest, + requestOptions?: Files.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deidentifyPresentation(request, requestOptions)); + } + + private async __deidentifyPresentation( + request: Skyflow.DeidentifyPresentationRequest, + requestOptions?: Files.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/deidentify/file/presentation", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyFileResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError( + "Timeout exceeded when calling POST /v1/detect/deidentify/file/presentation.", + ); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * De-identifies sensitive data from an audio file. This operation includes options applicable to all supported audio file types.

For broader file type support, see De-identify File. + * + * @param {Skyflow.DeidentifyAudioRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.files.deidentifyAudio({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "mp3" + * } + * }) + * + * @example + * await client.files.deidentifyAudio({ + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "mp3" + * } + * }) + */ + public deidentifyAudio( + request: Skyflow.DeidentifyAudioRequest, + requestOptions?: Files.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deidentifyAudio(request, requestOptions)); + } + + private async __deidentifyAudio( + request: Skyflow.DeidentifyAudioRequest, + requestOptions?: Files.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/deidentify/file/audio", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyFileResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError( + "Timeout exceeded when calling POST /v1/detect/deidentify/file/audio.", + ); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Returns the status of the detect run. + * + * @param {Skyflow.Uuid} runId - ID of the detect run. + * @param {Skyflow.GetRunRequest} request + * @param {Files.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.NotFoundError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.files.getRun("run_id", { + * vault_id: "vault_id" + * }) + */ + public getRun( + runId: Skyflow.Uuid, + request: Skyflow.GetRunRequest, + requestOptions?: Files.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getRun(runId, request, requestOptions)); + } + + private async __getRun( + runId: Skyflow.Uuid, + request: Skyflow.GetRunRequest, + requestOptions?: Files.RequestOptions, + ): Promise> { + const { vault_id: vaultId } = request; + const _queryParams: Record = {}; + _queryParams["vault_id"] = vaultId; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + `v1/detect/runs/${encodeURIComponent(runId)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyStatusResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError("Timeout exceeded when calling GET /v1/detect/runs/{run_id}."); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/ _generated_/rest/api/resources/files/client/index.ts b/src/ _generated_/rest/api/resources/files/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyAudioRequest.ts b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyAudioRequest.ts new file mode 100644 index 00000000..1da9531d --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyAudioRequest.ts @@ -0,0 +1,47 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "mp3" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "mp3" + * } + * } + */ +export interface DeidentifyAudioRequest { + vault_id: Skyflow.VaultId; + /** File to de-identify. Files are specified as Base64-encoded data. */ + file: Skyflow.DeidentifyAudioRequestFile; + /** If `true`, includes processed audio file in the response. */ + output_processed_audio?: boolean; + /** Type of transcription to output. */ + output_transcription?: Skyflow.DeidentifyAudioRequestOutputTranscription; + /** Relative loudness of the bleep in dB. Positive values increase its loudness, and negative values decrease it. */ + bleep_gain?: number; + /** The pitch of the bleep sound, in Hz. The higher the number, the higher the pitch. */ + bleep_frequency?: number; + /** Padding added to the beginning of a bleep, in seconds. */ + bleep_start_padding?: number; + /** Padding added to the end of a bleep, in seconds. */ + bleep_stop_padding?: number; + entity_types?: Skyflow.EntityTypes; + token_type?: Skyflow.TokenTypeWithoutVault; + allow_regex?: Skyflow.AllowRegex; + restrict_regex?: Skyflow.RestrictRegex; + transformations?: Skyflow.Transformations; +} diff --git a/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyDocumentRequest.ts b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyDocumentRequest.ts new file mode 100644 index 00000000..3b4e7b89 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyDocumentRequest.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "docx" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "docx" + * } + * } + */ +export interface DeidentifyDocumentRequest { + vault_id: Skyflow.VaultId; + /** File to de-identify. Files are specified as Base64-encoded data. */ + file: Skyflow.DeidentifyDocumentRequestFile; + entity_types?: Skyflow.EntityTypes; + token_type?: Skyflow.TokenTypeWithoutVault; + allow_regex?: Skyflow.AllowRegex; + restrict_regex?: Skyflow.RestrictRegex; + transformations?: Skyflow.Transformations; +} diff --git a/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyFileRequest.ts b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyFileRequest.ts new file mode 100644 index 00000000..4a549f24 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyFileRequest.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "Zm9vYmFy", + * data_format: "txt" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * file: { + * base64: "Zm9vYmFy", + * data_format: "txt" + * } + * } + */ +export interface DeidentifyFileRequest { + vault_id: Skyflow.VaultId; + /** File to de-identify. Files are specified as Base64-encoded data. */ + file: Skyflow.DeidentifyFileRequestFile; + entity_types?: Skyflow.EntityTypes; + token_type?: Skyflow.TokenTypeWithoutVault; + allow_regex?: Skyflow.AllowRegex; + restrict_regex?: Skyflow.RestrictRegex; + transformations?: Skyflow.Transformations; +} diff --git a/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyImageRequest.ts b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyImageRequest.ts new file mode 100644 index 00000000..f34f70f2 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyImageRequest.ts @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "jpg" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "jpg" + * } + * } + */ +export interface DeidentifyImageRequest { + vault_id: Skyflow.VaultId; + /** File to de-identify. Files are specified as Base64-encoded data. */ + file: Skyflow.DeidentifyImageRequestFile; + /** If `true`, includes processed image in the output. */ + output_processed_image?: boolean; + /** If `true`, includes OCR text output in the response. */ + output_ocr_text?: boolean; + /** Method to mask the entities in the image. */ + masking_method?: Skyflow.DeidentifyImageRequestMaskingMethod; + entity_types?: Skyflow.EntityTypes; + token_type?: Skyflow.TokenTypeWithoutVault; + allow_regex?: Skyflow.AllowRegex; + restrict_regex?: Skyflow.RestrictRegex; + transformations?: Skyflow.Transformations; +} diff --git a/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyPdfRequest.ts b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyPdfRequest.ts new file mode 100644 index 00000000..0ffcd8fc --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyPdfRequest.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "pdf" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "pdf" + * } + * } + */ +export interface DeidentifyPdfRequest { + vault_id: Skyflow.VaultId; + /** File to de-identify. Files are specified as Base64-encoded data. */ + file: Skyflow.DeidentifyPdfRequestFile; + /** Pixel density at which to process the PDF file. */ + density?: number; + /** Max resolution at which to process the PDF file. */ + max_resolution?: number; + entity_types?: Skyflow.EntityTypes; + token_type?: Skyflow.TokenTypeWithoutVault; + allow_regex?: Skyflow.AllowRegex; + restrict_regex?: Skyflow.RestrictRegex; + transformations?: Skyflow.Transformations; +} diff --git a/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyPresentationRequest.ts b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyPresentationRequest.ts new file mode 100644 index 00000000..ee660819 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyPresentationRequest.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "pptx" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "pptx" + * } + * } + */ +export interface DeidentifyPresentationRequest { + vault_id: Skyflow.VaultId; + /** File to de-identify. Files are specified as Base64-encoded data. */ + file: Skyflow.DeidentifyPresentationRequestFile; + entity_types?: Skyflow.EntityTypes; + token_type?: Skyflow.TokenTypeWithoutVault; + allow_regex?: Skyflow.AllowRegex; + restrict_regex?: Skyflow.RestrictRegex; + transformations?: Skyflow.Transformations; +} diff --git a/src/ _generated_/rest/api/resources/files/client/requests/DeidentifySpreadsheetRequest.ts b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifySpreadsheetRequest.ts new file mode 100644 index 00000000..9560ed75 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifySpreadsheetRequest.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "csv" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "csv" + * } + * } + */ +export interface DeidentifySpreadsheetRequest { + vault_id: Skyflow.VaultId; + /** File to de-identify. Files are specified as Base64-encoded data. */ + file: Skyflow.DeidentifySpreadsheetRequestFile; + entity_types?: Skyflow.EntityTypes; + token_type?: Skyflow.TokenTypeWithoutVault; + allow_regex?: Skyflow.AllowRegex; + restrict_regex?: Skyflow.RestrictRegex; + transformations?: Skyflow.Transformations; +} diff --git a/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyStructuredTextRequest.ts b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyStructuredTextRequest.ts new file mode 100644 index 00000000..74daccbb --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyStructuredTextRequest.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "SGkgaSBhbSBEZXZhbnNodSwgbGl2...aW5nIGluIGNhbGlmb3JuaWEuIA==", + * data_format: "json" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * file: { + * base64: "BASE64_DATA", + * data_format: "json" + * } + * } + */ +export interface DeidentifyStructuredTextRequest { + vault_id: Skyflow.VaultId; + /** File to de-identify. Files are specified as Base64-encoded data. */ + file: Skyflow.DeidentifyStructuredTextRequestFile; + entity_types?: Skyflow.EntityTypes; + token_type?: Skyflow.TokenTypeWithoutVault; + allow_regex?: Skyflow.AllowRegex; + restrict_regex?: Skyflow.RestrictRegex; + transformations?: Skyflow.Transformations; +} diff --git a/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyTextRequest.ts b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyTextRequest.ts new file mode 100644 index 00000000..66af6144 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/DeidentifyTextRequest.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * file: { + * base64: "Zm9vYmFy", + * data_format: "txt" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * file: { + * base64: "Zm9vYmFy", + * data_format: "txt" + * } + * } + */ +export interface DeidentifyTextRequest { + vault_id: Skyflow.VaultId; + /** File to de-identify. Files are specified as Base64-encoded data. */ + file: Skyflow.DeidentifyTextRequestFile; + entity_types?: Skyflow.EntityTypes; + token_type?: Skyflow.TokenTypeWithoutVault; + allow_regex?: Skyflow.AllowRegex; + restrict_regex?: Skyflow.RestrictRegex; + transformations?: Skyflow.Transformations; +} diff --git a/src/ _generated_/rest/api/resources/files/client/requests/GetRunRequest.ts b/src/ _generated_/rest/api/resources/files/client/requests/GetRunRequest.ts new file mode 100644 index 00000000..4feb3c84 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/GetRunRequest.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "vault_id" + * } + * + * @example + * { + * vault_id: "vault_id" + * } + * + * @example + * { + * vault_id: "vault_id" + * } + */ +export interface GetRunRequest { + /** + * ID of the vault. + */ + vault_id: Skyflow.ResourceId; +} diff --git a/src/ _generated_/rest/api/resources/files/client/requests/index.ts b/src/ _generated_/rest/api/resources/files/client/requests/index.ts new file mode 100644 index 00000000..d01e1608 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/client/requests/index.ts @@ -0,0 +1,10 @@ +export { type DeidentifyFileRequest } from "./DeidentifyFileRequest"; +export { type DeidentifyDocumentRequest } from "./DeidentifyDocumentRequest"; +export { type DeidentifyPdfRequest } from "./DeidentifyPdfRequest"; +export { type DeidentifyImageRequest } from "./DeidentifyImageRequest"; +export { type DeidentifyTextRequest } from "./DeidentifyTextRequest"; +export { type DeidentifyStructuredTextRequest } from "./DeidentifyStructuredTextRequest"; +export { type DeidentifySpreadsheetRequest } from "./DeidentifySpreadsheetRequest"; +export { type DeidentifyPresentationRequest } from "./DeidentifyPresentationRequest"; +export { type DeidentifyAudioRequest } from "./DeidentifyAudioRequest"; +export { type GetRunRequest } from "./GetRunRequest"; diff --git a/src/ _generated_/rest/api/resources/files/index.ts b/src/ _generated_/rest/api/resources/files/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyAudioRequestFile.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyAudioRequestFile.ts new file mode 100644 index 00000000..fb5bb6a9 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyAudioRequestFile.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../index"; + +/** + * File to de-identify. Files are specified as Base64-encoded data. + */ +export interface DeidentifyAudioRequestFile { + /** Base64-encoded data of the file to de-identify. */ + base64: string; + /** Data format of the file. */ + data_format: Skyflow.DeidentifyAudioRequestFileDataFormat; +} diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyAudioRequestFileDataFormat.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyAudioRequestFileDataFormat.ts new file mode 100644 index 00000000..87938c0a --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyAudioRequestFileDataFormat.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Data format of the file. + */ +export type DeidentifyAudioRequestFileDataFormat = "mp3" | "wav"; +export const DeidentifyAudioRequestFileDataFormat = { + Mp3: "mp3", + Wav: "wav", +} as const; diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyAudioRequestOutputTranscription.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyAudioRequestOutputTranscription.ts new file mode 100644 index 00000000..b370f8b3 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyAudioRequestOutputTranscription.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Type of transcription to output. + */ +export type DeidentifyAudioRequestOutputTranscription = + | "diarized_transcription" + | "medical_diarized_transcription" + | "medical_transcription" + | "plaintext_transcription" + | "transcription"; +export const DeidentifyAudioRequestOutputTranscription = { + DiarizedTranscription: "diarized_transcription", + MedicalDiarizedTranscription: "medical_diarized_transcription", + MedicalTranscription: "medical_transcription", + PlaintextTranscription: "plaintext_transcription", + Transcription: "transcription", +} as const; diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyDocumentRequestFile.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyDocumentRequestFile.ts new file mode 100644 index 00000000..b3894b96 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyDocumentRequestFile.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../index"; + +/** + * File to de-identify. Files are specified as Base64-encoded data. + */ +export interface DeidentifyDocumentRequestFile { + /** Base64-encoded data of the file to de-identify. */ + base64: string; + /** Data format of the file. */ + data_format: Skyflow.DeidentifyDocumentRequestFileDataFormat; +} diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyDocumentRequestFileDataFormat.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyDocumentRequestFileDataFormat.ts new file mode 100644 index 00000000..850c863f --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyDocumentRequestFileDataFormat.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Data format of the file. + */ +export type DeidentifyDocumentRequestFileDataFormat = "doc" | "docx" | "pdf"; +export const DeidentifyDocumentRequestFileDataFormat = { + Doc: "doc", + Docx: "docx", + Pdf: "pdf", +} as const; diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyFileRequestFile.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyFileRequestFile.ts new file mode 100644 index 00000000..749adb46 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyFileRequestFile.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../index"; + +/** + * File to de-identify. Files are specified as Base64-encoded data. + */ +export interface DeidentifyFileRequestFile { + /** Base64-encoded data of the file to de-identify. */ + base64: string; + /** Data format of the file. */ + data_format: Skyflow.DeidentifyFileRequestFileDataFormat; +} diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyFileRequestFileDataFormat.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyFileRequestFileDataFormat.ts new file mode 100644 index 00000000..5927453a --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyFileRequestFileDataFormat.ts @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Data format of the file. + */ +export type DeidentifyFileRequestFileDataFormat = + | "bmp" + | "csv" + | "doc" + | "docx" + | "jpeg" + | "jpg" + | "json" + | "mp3" + | "pdf" + | "png" + | "ppt" + | "pptx" + | "tif" + | "tiff" + | "txt" + | "wav" + | "xls" + | "xlsx" + | "xml"; +export const DeidentifyFileRequestFileDataFormat = { + Bmp: "bmp", + Csv: "csv", + Doc: "doc", + Docx: "docx", + Jpeg: "jpeg", + Jpg: "jpg", + Json: "json", + Mp3: "mp3", + Pdf: "pdf", + Png: "png", + Ppt: "ppt", + Pptx: "pptx", + Tif: "tif", + Tiff: "tiff", + Txt: "txt", + Wav: "wav", + Xls: "xls", + Xlsx: "xlsx", + Xml: "xml", +} as const; diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyImageRequestFile.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyImageRequestFile.ts new file mode 100644 index 00000000..da7cb1c2 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyImageRequestFile.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../index"; + +/** + * File to de-identify. Files are specified as Base64-encoded data. + */ +export interface DeidentifyImageRequestFile { + /** Base64-encoded data of the file to de-identify. */ + base64: string; + /** Data format of the file. */ + data_format: Skyflow.DeidentifyImageRequestFileDataFormat; +} diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyImageRequestFileDataFormat.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyImageRequestFileDataFormat.ts new file mode 100644 index 00000000..00a407fa --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyImageRequestFileDataFormat.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Data format of the file. + */ +export type DeidentifyImageRequestFileDataFormat = "bmp" | "jpeg" | "jpg" | "png" | "tif" | "tiff"; +export const DeidentifyImageRequestFileDataFormat = { + Bmp: "bmp", + Jpeg: "jpeg", + Jpg: "jpg", + Png: "png", + Tif: "tif", + Tiff: "tiff", +} as const; diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyImageRequestMaskingMethod.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyImageRequestMaskingMethod.ts new file mode 100644 index 00000000..ced4ca50 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyImageRequestMaskingMethod.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Method to mask the entities in the image. + */ +export type DeidentifyImageRequestMaskingMethod = "blackout" | "blur"; +export const DeidentifyImageRequestMaskingMethod = { + Blackout: "blackout", + Blur: "blur", +} as const; diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyPdfRequestFile.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyPdfRequestFile.ts new file mode 100644 index 00000000..f8efc2b5 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyPdfRequestFile.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * File to de-identify. Files are specified as Base64-encoded data. + */ +export interface DeidentifyPdfRequestFile { + /** Base64-encoded data of the file to de-identify. */ + base64: string; + /** Data format of the file. */ + data_format: "pdf"; +} diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyPresentationRequestFile.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyPresentationRequestFile.ts new file mode 100644 index 00000000..57871605 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyPresentationRequestFile.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../index"; + +/** + * File to de-identify. Files are specified as Base64-encoded data. + */ +export interface DeidentifyPresentationRequestFile { + /** Base64-encoded data of the file to de-identify. */ + base64: string; + /** Data format of the file. */ + data_format: Skyflow.DeidentifyPresentationRequestFileDataFormat; +} diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyPresentationRequestFileDataFormat.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyPresentationRequestFileDataFormat.ts new file mode 100644 index 00000000..94f9d253 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyPresentationRequestFileDataFormat.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Data format of the file. + */ +export type DeidentifyPresentationRequestFileDataFormat = "ppt" | "pptx"; +export const DeidentifyPresentationRequestFileDataFormat = { + Ppt: "ppt", + Pptx: "pptx", +} as const; diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifySpreadsheetRequestFile.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifySpreadsheetRequestFile.ts new file mode 100644 index 00000000..41cb9fe2 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifySpreadsheetRequestFile.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../index"; + +/** + * File to de-identify. Files are specified as Base64-encoded data. + */ +export interface DeidentifySpreadsheetRequestFile { + /** Base64-encoded data of the file to de-identify. */ + base64: string; + /** Data format of the file. */ + data_format: Skyflow.DeidentifySpreadsheetRequestFileDataFormat; +} diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.ts new file mode 100644 index 00000000..041eb16e --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifySpreadsheetRequestFileDataFormat.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Data format of the file. + */ +export type DeidentifySpreadsheetRequestFileDataFormat = "csv" | "xls" | "xlsx"; +export const DeidentifySpreadsheetRequestFileDataFormat = { + Csv: "csv", + Xls: "xls", + Xlsx: "xlsx", +} as const; diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyStructuredTextRequestFile.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyStructuredTextRequestFile.ts new file mode 100644 index 00000000..66432e03 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyStructuredTextRequestFile.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../index"; + +/** + * File to de-identify. Files are specified as Base64-encoded data. + */ +export interface DeidentifyStructuredTextRequestFile { + /** Base64-encoded data of the file to de-identify. */ + base64: string; + /** Data format of the file. */ + data_format: Skyflow.DeidentifyStructuredTextRequestFileDataFormat; +} diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.ts new file mode 100644 index 00000000..74dc1435 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyStructuredTextRequestFileDataFormat.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Data format of the file. + */ +export type DeidentifyStructuredTextRequestFileDataFormat = "json" | "xml"; +export const DeidentifyStructuredTextRequestFileDataFormat = { + Json: "json", + Xml: "xml", +} as const; diff --git a/src/ _generated_/rest/api/resources/files/types/DeidentifyTextRequestFile.ts b/src/ _generated_/rest/api/resources/files/types/DeidentifyTextRequestFile.ts new file mode 100644 index 00000000..7b1a08ca --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/DeidentifyTextRequestFile.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * File to de-identify. Files are specified as Base64-encoded data. + */ +export interface DeidentifyTextRequestFile { + /** Base64-encoded data of the file to de-identify. */ + base64: string; + /** Data format of the file. */ + data_format: "txt"; +} diff --git a/src/ _generated_/rest/api/resources/files/types/index.ts b/src/ _generated_/rest/api/resources/files/types/index.ts new file mode 100644 index 00000000..51f03325 --- /dev/null +++ b/src/ _generated_/rest/api/resources/files/types/index.ts @@ -0,0 +1,18 @@ +export * from "./DeidentifyFileRequestFileDataFormat"; +export * from "./DeidentifyFileRequestFile"; +export * from "./DeidentifyDocumentRequestFileDataFormat"; +export * from "./DeidentifyDocumentRequestFile"; +export * from "./DeidentifyPdfRequestFile"; +export * from "./DeidentifyImageRequestFileDataFormat"; +export * from "./DeidentifyImageRequestFile"; +export * from "./DeidentifyImageRequestMaskingMethod"; +export * from "./DeidentifyTextRequestFile"; +export * from "./DeidentifyStructuredTextRequestFileDataFormat"; +export * from "./DeidentifyStructuredTextRequestFile"; +export * from "./DeidentifySpreadsheetRequestFileDataFormat"; +export * from "./DeidentifySpreadsheetRequestFile"; +export * from "./DeidentifyPresentationRequestFileDataFormat"; +export * from "./DeidentifyPresentationRequestFile"; +export * from "./DeidentifyAudioRequestFileDataFormat"; +export * from "./DeidentifyAudioRequestFile"; +export * from "./DeidentifyAudioRequestOutputTranscription"; diff --git a/src/ _generated_/rest/api/resources/index.ts b/src/ _generated_/rest/api/resources/index.ts index a6ae3aed..4d7fe175 100644 --- a/src/ _generated_/rest/api/resources/index.ts +++ b/src/ _generated_/rest/api/resources/index.ts @@ -2,13 +2,21 @@ export * as audit from "./audit"; export * from "./audit/types"; export * as records from "./records"; export * from "./records/types"; +export * as strings from "./strings"; +export * from "./strings/types"; +export * as files from "./files"; +export * from "./files/types"; export * as binLookup from "./binLookup"; export * as tokens from "./tokens"; export * as query from "./query"; export * as authentication from "./authentication"; +export * as deprecated from "./deprecated"; export * from "./audit/client/requests"; export * from "./binLookup/client/requests"; export * from "./records/client/requests"; export * from "./tokens/client/requests"; export * from "./query/client/requests"; export * from "./authentication/client/requests"; +export * from "./deprecated/client/requests"; +export * from "./strings/client/requests"; +export * from "./files/client/requests"; diff --git a/src/ _generated_/rest/api/resources/query/client/Client.ts b/src/ _generated_/rest/api/resources/query/client/Client.ts index d6339a16..8754ac4a 100644 --- a/src/ _generated_/rest/api/resources/query/client/Client.ts +++ b/src/ _generated_/rest/api/resources/query/client/Client.ts @@ -91,10 +91,7 @@ export class Query { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, diff --git a/src/ _generated_/rest/api/resources/records/client/Client.ts b/src/ _generated_/rest/api/resources/records/client/Client.ts index 96ea98ce..c0682f3f 100644 --- a/src/ _generated_/rest/api/resources/records/client/Client.ts +++ b/src/ _generated_/rest/api/resources/records/client/Client.ts @@ -117,10 +117,7 @@ export class Records { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, @@ -274,10 +271,7 @@ export class Records { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, @@ -387,10 +381,7 @@ export class Records { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, @@ -483,10 +474,7 @@ export class Records { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, @@ -602,10 +590,7 @@ export class Records { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, @@ -709,10 +694,7 @@ export class Records { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, @@ -802,10 +784,7 @@ export class Records { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, @@ -910,10 +889,7 @@ export class Records { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, @@ -1006,10 +982,7 @@ export class Records { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, @@ -1102,10 +1075,7 @@ export class Records { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, diff --git a/src/ _generated_/rest/api/resources/strings/client/Client.ts b/src/ _generated_/rest/api/resources/strings/client/Client.ts new file mode 100644 index 00000000..c0e588ea --- /dev/null +++ b/src/ _generated_/rest/api/resources/strings/client/Client.ts @@ -0,0 +1,277 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Skyflow from "../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors/index"; + +export declare namespace Strings { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + } +} + +export class Strings { + constructor(protected readonly _options: Strings.Options) {} + + /** + * De-identifies sensitive data from a string. + * + * @param {Skyflow.DeidentifyStringRequest} request + * @param {Strings.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.strings.deidentifyString({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * text: "My name is John Doe, and my email is johndoe@acme.com." + * }) + * + * @example + * await client.strings.deidentifyString({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * text: "S: 62yo female here for first visit. No concerns today. Her FP (Dr. Benyamin) is retiring soon. Up to date on pap, mammo, labs, BMD. On the waitlist for colonoscopy. Past Medical and Surgical hx: nil. Meds: nil. Allergies: Pn. Family and Social hx: see CPP. O: Temp 35.2;BP 145-73; HR 58. Appears well. A: First visit. P: CPP updated. RTC prn. A007. First visit. Type Name: Clinical Note" + * }) + * + * @example + * await client.strings.deidentifyString({ + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * text: "My name is John Doe, and my email is johndoe@acme.com.", + * entity_types: ["name", "email_address"], + * token_type: { + * default: "entity_only" + * } + * }) + * + * @example + * await client.strings.deidentifyString({ + * vault_id: "VAULT_ID", + * text: "My name is John Doe, and my email is johndoe@acme.com.", + * token_type: { + * default: "vault_token" + * } + * }) + * + * @example + * await client.strings.deidentifyString({ + * vault_id: "VAULT_ID", + * text: "My name is John Doe, and my email is johndoe@acme.com." + * }) + * + * @example + * await client.strings.deidentifyString({ + * vault_id: "VAULT_ID", + * text: "My name is John, and my email is johndoe@acme.com.", + * entity_types: ["name", "email_address"], + * token_type: { + * default: "entity_only" + * }, + * allow_regex: ["John"], + * transformations: { + * shift_dates: { + * max_days: 5, + * min_days: 1, + * entity_types: ["date"] + * } + * } + * }) + */ + public deidentifyString( + request: Skyflow.DeidentifyStringRequest, + requestOptions?: Strings.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deidentifyString(request, requestOptions)); + } + + private async __deidentifyString( + request: Skyflow.DeidentifyStringRequest, + requestOptions?: Strings.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/deidentify/string", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.DeidentifyStringResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError( + "Timeout exceeded when calling POST /v1/detect/deidentify/string.", + ); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Re-identifies tokens in a string. + * + * @param {Skyflow.ReidentifyStringRequest} request + * @param {Strings.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.strings.reidentifyString({ + * text: "My name is [NAME_1], and my email is [EMAIL_1].", + * vault_id: "1ad6db07-8405-46cf-9a1e-db148ff9f4c5" + * }) + */ + public reidentifyString( + request: Skyflow.ReidentifyStringRequest, + requestOptions?: Strings.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__reidentifyString(request, requestOptions)); + } + + private async __reidentifyString( + request: Skyflow.ReidentifyStringRequest, + requestOptions?: Strings.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.SkyflowEnvironment.Production, + "v1/detect/reidentify/string", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "skyflow", + "X-Fern-SDK-Version": "1.0.21", + "User-Agent": "skyflow/1.0.21", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.ReidentifyStringResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Skyflow.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Skyflow.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 500: + throw new Skyflow.InternalServerError( + _response.error.body as Skyflow.ErrorResponse, + _response.rawResponse, + ); + default: + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SkyflowError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.SkyflowTimeoutError( + "Timeout exceeded when calling POST /v1/detect/reidentify/string.", + ); + case "unknown": + throw new errors.SkyflowError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/ _generated_/rest/api/resources/strings/client/index.ts b/src/ _generated_/rest/api/resources/strings/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/ _generated_/rest/api/resources/strings/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/ _generated_/rest/api/resources/strings/client/requests/DeidentifyStringRequest.ts b/src/ _generated_/rest/api/resources/strings/client/requests/DeidentifyStringRequest.ts new file mode 100644 index 00000000..d157c3ce --- /dev/null +++ b/src/ _generated_/rest/api/resources/strings/client/requests/DeidentifyStringRequest.ts @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * text: "My name is John Doe, and my email is johndoe@acme.com." + * } + * + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * text: "S: 62yo female here for first visit. No concerns today. Her FP (Dr. Benyamin) is retiring soon. Up to date on pap, mammo, labs, BMD. On the waitlist for colonoscopy. Past Medical and Surgical hx: nil. Meds: nil. Allergies: Pn. Family and Social hx: see CPP. O: Temp 35.2;BP 145-73; HR 58. Appears well. A: First visit. P: CPP updated. RTC prn. A007. First visit. Type Name: Clinical Note" + * } + * + * @example + * { + * vault_id: "f4b3b3b33b3b3b3b3b3b3b3b3b3b3b3b", + * text: "My name is John Doe, and my email is johndoe@acme.com.", + * entity_types: ["name", "email_address"], + * token_type: { + * default: "entity_only" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * text: "My name is John Doe, and my email is johndoe@acme.com.", + * token_type: { + * default: "vault_token" + * } + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * text: "My name is John Doe, and my email is johndoe@acme.com." + * } + * + * @example + * { + * vault_id: "VAULT_ID", + * text: "My name is John, and my email is johndoe@acme.com.", + * entity_types: ["name", "email_address"], + * token_type: { + * default: "entity_only" + * }, + * allow_regex: ["John"], + * transformations: { + * shift_dates: { + * max_days: 5, + * min_days: 1, + * entity_types: ["date"] + * } + * } + * } + */ +export interface DeidentifyStringRequest { + vault_id: Skyflow.VaultId; + /** String to de-identify. */ + text: string; + entity_types?: Skyflow.EntityTypes; + token_type?: Skyflow.TokenType; + allow_regex?: Skyflow.AllowRegex; + restrict_regex?: Skyflow.RestrictRegex; + transformations?: Skyflow.Transformations; +} diff --git a/src/ _generated_/rest/api/resources/strings/client/requests/ReidentifyStringRequest.ts b/src/ _generated_/rest/api/resources/strings/client/requests/ReidentifyStringRequest.ts new file mode 100644 index 00000000..0a8a2f86 --- /dev/null +++ b/src/ _generated_/rest/api/resources/strings/client/requests/ReidentifyStringRequest.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../../index"; + +/** + * @example + * { + * text: "My name is [NAME_1], and my email is [EMAIL_1].", + * vault_id: "1ad6db07-8405-46cf-9a1e-db148ff9f4c5" + * } + */ +export interface ReidentifyStringRequest { + /** String to re-identify. */ + text: string; + /** ID of the vault where the entities are stored. */ + vault_id: string; + /** Mapping of perferred data formatting options to entity types. Returned values are dependent on the configuration of the vault storing the data and the permissions of the user or account making the request. */ + format?: Skyflow.ReidentifyStringRequestFormat; +} diff --git a/src/ _generated_/rest/api/resources/strings/client/requests/index.ts b/src/ _generated_/rest/api/resources/strings/client/requests/index.ts new file mode 100644 index 00000000..a10c579b --- /dev/null +++ b/src/ _generated_/rest/api/resources/strings/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type DeidentifyStringRequest } from "./DeidentifyStringRequest"; +export { type ReidentifyStringRequest } from "./ReidentifyStringRequest"; diff --git a/src/ _generated_/rest/api/resources/strings/index.ts b/src/ _generated_/rest/api/resources/strings/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/ _generated_/rest/api/resources/strings/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/ _generated_/rest/api/resources/strings/types/ReidentifyStringRequestFormat.ts b/src/ _generated_/rest/api/resources/strings/types/ReidentifyStringRequestFormat.ts new file mode 100644 index 00000000..712a5f81 --- /dev/null +++ b/src/ _generated_/rest/api/resources/strings/types/ReidentifyStringRequestFormat.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../../../index"; + +/** + * Mapping of perferred data formatting options to entity types. Returned values are dependent on the configuration of the vault storing the data and the permissions of the user or account making the request. + */ +export interface ReidentifyStringRequestFormat { + /** Entity types to fully redact. */ + redacted?: Skyflow.EntityType[]; + /** Entity types to mask. */ + masked?: Skyflow.EntityType[]; + /** Entity types to return in plaintext. */ + plaintext?: Skyflow.EntityType[]; +} diff --git a/src/ _generated_/rest/api/resources/strings/types/index.ts b/src/ _generated_/rest/api/resources/strings/types/index.ts new file mode 100644 index 00000000..58b77ca6 --- /dev/null +++ b/src/ _generated_/rest/api/resources/strings/types/index.ts @@ -0,0 +1 @@ +export * from "./ReidentifyStringRequestFormat"; diff --git a/src/ _generated_/rest/api/resources/tokens/client/Client.ts b/src/ _generated_/rest/api/resources/tokens/client/Client.ts index 5f5b90fc..8ce2956c 100644 --- a/src/ _generated_/rest/api/resources/tokens/client/Client.ts +++ b/src/ _generated_/rest/api/resources/tokens/client/Client.ts @@ -98,10 +98,7 @@ export class Tokens { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, @@ -187,10 +184,7 @@ export class Tokens { if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Skyflow.NotFoundError( - _response.error.body as Record, - _response.rawResponse, - ); + throw new Skyflow.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.SkyflowError({ statusCode: _response.error.statusCode, diff --git a/src/ _generated_/rest/api/types/AdvancedOptionsColumnMapping.ts b/src/ _generated_/rest/api/types/AdvancedOptionsColumnMapping.ts new file mode 100644 index 00000000..77a428f1 --- /dev/null +++ b/src/ _generated_/rest/api/types/AdvancedOptionsColumnMapping.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Contains map of what has to be stored in which column. + */ +export interface AdvancedOptionsColumnMapping { + /** Table name of the vault. */ + session_id: string; + /** Name of column to store data in when no explicit mapping exists. */ + default: string; + /** Column mapping for different entities. */ + entity_column_map?: Skyflow.AdvancedOptionsEntityColumnMap[]; +} diff --git a/src/ _generated_/rest/api/types/AdvancedOptionsEntityColumnMap.ts b/src/ _generated_/rest/api/types/AdvancedOptionsEntityColumnMap.ts new file mode 100644 index 00000000..20d3664f --- /dev/null +++ b/src/ _generated_/rest/api/types/AdvancedOptionsEntityColumnMap.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Contains map of what entity has to be stored in which column. + */ +export interface AdvancedOptionsEntityColumnMap { + entity_type?: Skyflow.DetectDataEntities; + /** Column name where the entity has to be stored. */ + column_name?: string; +} diff --git a/src/ _generated_/rest/api/types/AdvancedOptionsVaultSchema.ts b/src/ _generated_/rest/api/types/AdvancedOptionsVaultSchema.ts new file mode 100644 index 00000000..02dffb1c --- /dev/null +++ b/src/ _generated_/rest/api/types/AdvancedOptionsVaultSchema.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Contains table name and column mapping. + */ +export interface AdvancedOptionsVaultSchema { + /** Table name of the vault. */ + table_name: string; + mapping: Skyflow.AdvancedOptionsColumnMapping; +} diff --git a/src/ _generated_/rest/api/types/AllowRegex.ts b/src/ _generated_/rest/api/types/AllowRegex.ts new file mode 100644 index 00000000..e069febd --- /dev/null +++ b/src/ _generated_/rest/api/types/AllowRegex.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Regular expressions to display in plaintext. Expressions must match the entirety of a detected entity, not just a substring, for the entity to display in plaintext. Expressions don't match across entity boundaries. If a string or entity matches both `allow_regex` and `restrict_regex`, the entity is displayed in plaintext. + */ +export type AllowRegex = string[]; diff --git a/src/ _generated_/rest/api/types/AudioConfigTranscriptionType.ts b/src/ _generated_/rest/api/types/AudioConfigTranscriptionType.ts new file mode 100644 index 00000000..fc860d8b --- /dev/null +++ b/src/ _generated_/rest/api/types/AudioConfigTranscriptionType.ts @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Type of transcription. + * + * - none: Indicates transcriptionType is not set. + * - skyflow_transcription: Sends Skyflow transcribed text. + * - aws_transcription: Sends AWS transcribed text. + * - aws_transcription_diarize: Sends AWS diarized text. + * - aws_medical_transcription: Sends AWS medical transcribed text. + * - aws_medical_transcription_diarize: Sends AWS medical diarized text. + * - aws_transcription_diarize_json: Sends AWS transcribed redacted json. + * - deepgram_transcription_diarize: deepgram transcribed diarized text. + * - deepgram_transcription_json: deepgram transcribed redacted json. + * - deepgram_wrapper: deepgram diarized text. + */ +export type AudioConfigTranscriptionType = + | "none" + | "skyflow_transcription" + | "aws_transcription" + | "aws_transcription_diarize" + | "aws_medical_transcription" + | "aws_medical_transcription_diarize" + | "aws_transcription_diarize_json" + | "deepgram_transcription_diarize" + | "deepgram_transcription_json" + | "deepgram_wrapper"; +export const AudioConfigTranscriptionType = { + None: "none", + SkyflowTranscription: "skyflow_transcription", + AwsTranscription: "aws_transcription", + AwsTranscriptionDiarize: "aws_transcription_diarize", + AwsMedicalTranscription: "aws_medical_transcription", + AwsMedicalTranscriptionDiarize: "aws_medical_transcription_diarize", + AwsTranscriptionDiarizeJson: "aws_transcription_diarize_json", + DeepgramTranscriptionDiarize: "deepgram_transcription_diarize", + DeepgramTranscriptionJson: "deepgram_transcription_json", + DeepgramWrapper: "deepgram_wrapper", +} as const; diff --git a/src/ _generated_/rest/api/types/DeidentifyFileOutput.ts b/src/ _generated_/rest/api/types/DeidentifyFileOutput.ts new file mode 100644 index 00000000..f90709f8 --- /dev/null +++ b/src/ _generated_/rest/api/types/DeidentifyFileOutput.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Details and contents of the processed file. + */ +export interface DeidentifyFileOutput { + /** URL or base64-encoded data of the output. */ + processed_file?: string; + /** Type of the processed file. */ + processed_file_type?: Skyflow.DeidentifyFileOutputProcessedFileType; + /** Extension of the processed file. */ + processed_file_extension?: string; +} diff --git a/src/ _generated_/rest/api/types/DeidentifyFileOutputProcessedFileType.ts b/src/ _generated_/rest/api/types/DeidentifyFileOutputProcessedFileType.ts new file mode 100644 index 00000000..d47699a1 --- /dev/null +++ b/src/ _generated_/rest/api/types/DeidentifyFileOutputProcessedFileType.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Type of the processed file. + */ +export type DeidentifyFileOutputProcessedFileType = + | "entities" + | "plaintext_transcription" + | "redacted_audio" + | "redacted_diarized_transcription" + | "redacted_file" + | "redacted_image" + | "redacted_medical_diarized_transcription" + | "redacted_medical_transcription" + | "redacted_text" + | "redacted_transcription"; +export const DeidentifyFileOutputProcessedFileType = { + Entities: "entities", + PlaintextTranscription: "plaintext_transcription", + RedactedAudio: "redacted_audio", + RedactedDiarizedTranscription: "redacted_diarized_transcription", + RedactedFile: "redacted_file", + RedactedImage: "redacted_image", + RedactedMedicalDiarizedTranscription: "redacted_medical_diarized_transcription", + RedactedMedicalTranscription: "redacted_medical_transcription", + RedactedText: "redacted_text", + RedactedTranscription: "redacted_transcription", +} as const; diff --git a/src/ _generated_/rest/api/types/DeidentifyFileResponse.ts b/src/ _generated_/rest/api/types/DeidentifyFileResponse.ts new file mode 100644 index 00000000..81cc67e5 --- /dev/null +++ b/src/ _generated_/rest/api/types/DeidentifyFileResponse.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Response to de-identify a file. + */ +export interface DeidentifyFileResponse { + /** Status URL for the detect run. */ + run_id: string; +} diff --git a/src/ _generated_/rest/api/types/DeidentifyStatusResponse.ts b/src/ _generated_/rest/api/types/DeidentifyStatusResponse.ts new file mode 100644 index 00000000..8a5fa2c7 --- /dev/null +++ b/src/ _generated_/rest/api/types/DeidentifyStatusResponse.ts @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Response to get the status of a detect run. + */ +export interface DeidentifyStatusResponse { + /** Status of the detect run. */ + status: Skyflow.DeidentifyStatusResponseStatus; + /** How the input file was specified. */ + output: Skyflow.DeidentifyFileOutput[]; + /** How the output file is specified. */ + output_type: Skyflow.DeidentifyStatusResponseOutputType; + /** Status details about the detect run. */ + message: string; + /** Number of words in the processed text. */ + word_count?: number; + /** Number of characters in the processed text. */ + character_count?: number; + /** Size of the processed text in kilobytes (KB). */ + size?: number; + /** Duration of the processed audio in seconds. */ + duration?: number; + /** Number of pages in the processed PDF. */ + pages?: number; + /** Number of slides in the processed presentation. */ + slides?: number; +} diff --git a/src/ _generated_/rest/api/types/DeidentifyStatusResponseOutputType.ts b/src/ _generated_/rest/api/types/DeidentifyStatusResponseOutputType.ts new file mode 100644 index 00000000..5e8dfc87 --- /dev/null +++ b/src/ _generated_/rest/api/types/DeidentifyStatusResponseOutputType.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * How the output file is specified. + */ +export type DeidentifyStatusResponseOutputType = "base64" | "efs_path"; +export const DeidentifyStatusResponseOutputType = { + Base64: "base64", + EfsPath: "efs_path", +} as const; diff --git a/src/ _generated_/rest/api/types/DeidentifyStatusResponseStatus.ts b/src/ _generated_/rest/api/types/DeidentifyStatusResponseStatus.ts new file mode 100644 index 00000000..78e92829 --- /dev/null +++ b/src/ _generated_/rest/api/types/DeidentifyStatusResponseStatus.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Status of the detect run. + */ +export type DeidentifyStatusResponseStatus = "failed" | "in_progress" | "success"; +export const DeidentifyStatusResponseStatus = { + Failed: "failed", + InProgress: "in_progress", + Success: "success", +} as const; diff --git a/src/ _generated_/rest/api/types/DeidentifyStringResponse.ts b/src/ _generated_/rest/api/types/DeidentifyStringResponse.ts new file mode 100644 index 00000000..3ae4af74 --- /dev/null +++ b/src/ _generated_/rest/api/types/DeidentifyStringResponse.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Response to deidentify a string. + */ +export interface DeidentifyStringResponse { + /** De-identified text. */ + processed_text: string; + /** Detected entities. */ + entities: Skyflow.DetectedEntity[]; + /** Number of words from the input text. */ + word_count: number; + /** Number of characters from the input text. */ + character_count: number; +} diff --git a/src/ _generated_/rest/api/types/DetectDataAccuracy.ts b/src/ _generated_/rest/api/types/DetectDataAccuracy.ts new file mode 100644 index 00000000..9043bb6a --- /dev/null +++ b/src/ _generated_/rest/api/types/DetectDataAccuracy.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Accuracy of the detection. The higher the accuracy, the more time it takes to process the request. Use multilingual options if the input contains languages other than English. + * + * - unknown: Unknown accuracy. + * - standard: Base-level accuracy. + * - standard_plus: Improved accuracy. + * - standard_plus_multilingual: Improved accuracy with multilingual support. + * - standard_plus_automatic: Improved accuracy with automatic language detection. + * - high: High accuracy. + * - high_multilingual: High accuracy with multilingual support. + * - high_automatic: High accuracy with automatic language detection. + */ +export type DetectDataAccuracy = + | "unknown" + | "standard" + | "standard_plus" + | "standard_plus_multilingual" + | "standard_plus_automatic" + | "high" + | "high_multilingual" + | "high_automatic"; +export const DetectDataAccuracy = { + Unknown: "unknown", + Standard: "standard", + StandardPlus: "standard_plus", + StandardPlusMultilingual: "standard_plus_multilingual", + StandardPlusAutomatic: "standard_plus_automatic", + High: "high", + HighMultilingual: "high_multilingual", + HighAutomatic: "high_automatic", +} as const; diff --git a/src/ _generated_/rest/api/types/DetectDataEntities.ts b/src/ _generated_/rest/api/types/DetectDataEntities.ts new file mode 100644 index 00000000..758aefb6 --- /dev/null +++ b/src/ _generated_/rest/api/types/DetectDataEntities.ts @@ -0,0 +1,200 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Entities to detect and deidentify. + * + * - age: Numbers associated with an individual’s age. + * - bank_account: Bank account numbers and international equivalents. + * - credit_card: Credit card numbers. + * - credit_card_expiration: Expiration date of a credit card. + * - cvv: 3 or 4 digit card verification codes and equivalents. + * - date: Specific calendar dates, which can include days of the week, dates, months, or years. + * - date_interval: Broader time periods, including date ranges, months, seasons, years, and decades. + * - dob: Dates of birth. + * - driver_license: Driver's permit numbers. + * - email_address: Email addresses. + * - healthcare_number: Healthcare numbers and health plan beneficiary numbers. + * - ip_address: Internet IP address, including IPv4 and IPv6 formats. + * - location: Metaclass for any named location reference; See subclasses below. + * - name: Names of individuals, not including personal titles such as ‘Mrs.’ or ‘Mr.’. + * - numerical_pii: Numerical PII (including alphanumeric strings) such as device serial numbers, POS codes etc. + * - phone_number: Telephone or fax numbers. + * - ssn: Social Security Numbers or international equivalent government identification numbers. + * - url: Internet addresses. + * - vehicle_id: Vehicle identification numbers (VINs), vehicle serial numbers, and license plate numbers. + * - medical_code: Codes belonging to medical classification systems. + * - name_family: Names indicating a person’s family or community. + * - name_given: Names given to an individual, usually at birth. + * - account_number: Customer account or membership identification number. + * - event: Names of events or holidays. + * - filename: Names of computer files, including the extension or filepath. + * - gender_sexuality: Terms indicating gender identity or sexual orientation, including slang terms. + * - language: Names of natural languages. + * - location_address: Full or partial physical mailing addresses. + * - location_city: Municipality names, including villages, towns, and cities. + * - location_coordinate: Geographic positions referred to using latitude, longitude, and/or elevation coordinates. + * - location_country: Country names. + * - location_state: State, province, territory, or prefecture names. + * - location_zip: Zip codes (including Zip+4), postcodes, or postal codes. + * - marital_status: Terms indicating marital status. + * - money: Names and/or amounts of currency. + * - name_medical_professional: Full names, including professional titles and certifications, of medical professional, such as doctors and nurses + * - occupation: Job titles or professions. + * - organization: Names of organizations or departments within an organization. + * - organization_medical_facility: Names of medical facilities, such as hospitals, clinics, pharmacies, etc. + * - origin: Terms indicating nationality, ethnicity, or provenance. + * - passport_number: Passport numbers, issued by any country. + * - password: Account passwords, PINs, access keys, or verification answers. + * - physical_attribute: Distinctive bodily attributes, including terms indicating race. + * - political_affiliation: Terms referring to a political party, movement, or ideology. + * - religion: Terms indicating religious affiliation. + * - time: Expressions indicating clock times. + * - username: Usernames, login names, or handles. + * - zodiac_sign: Names of Zodiac signs. + * - blood_type: Blood types. + * - condition: Names of medical conditions. + * - dose: Medically prescribed quantity of a medication. + * - drug: Medications, vitamins, and supplements. + * - injury: Bodily injuries. + * - medical_process: Medical processes, including treatments, procedures, and tests. + * - statistics: Medical statistics. + * - routing_number: Routing number associated with a bank or financial institution. + * - corporate_action: Any action a company takes that could affect its stock value or its shareholders. + * - financial_metric: Financial metrics or financial ratios are quantitative indicators of a company’s financial health. + * - product: Names or model numbers of items made by an organization. + * - trend: A description of the “quality” or the direction in which a financial measurement is going. + * - duration: Periods of time, specified as a number and a unit of time. + * - location_address_street: A subclass of location_address, covering: a building number and street name, plus information like a unit numbers, office numbers, floor numbers and building names, where applicable. + * - all: Indicates all entities. + */ +export type DetectDataEntities = + | "age" + | "bank_account" + | "credit_card" + | "credit_card_expiration" + | "cvv" + | "date" + | "date_interval" + | "dob" + | "driver_license" + | "email_address" + | "healthcare_number" + | "ip_address" + | "location" + | "name" + | "numerical_pii" + | "phone_number" + | "ssn" + | "url" + | "vehicle_id" + | "medical_code" + | "name_family" + | "name_given" + | "account_number" + | "event" + | "filename" + | "gender_sexuality" + | "language" + | "location_address" + | "location_city" + | "location_coordinate" + | "location_country" + | "location_state" + | "location_zip" + | "marital_status" + | "money" + | "name_medical_professional" + | "occupation" + | "organization" + | "organization_medical_facility" + | "origin" + | "passport_number" + | "password" + | "physical_attribute" + | "political_affiliation" + | "religion" + | "time" + | "username" + | "zodiac_sign" + | "blood_type" + | "condition" + | "dose" + | "drug" + | "injury" + | "medical_process" + | "statistics" + | "routing_number" + | "corporate_action" + | "financial_metric" + | "product" + | "trend" + | "duration" + | "location_address_street" + | "all"; +export const DetectDataEntities = { + Age: "age", + BankAccount: "bank_account", + CreditCard: "credit_card", + CreditCardExpiration: "credit_card_expiration", + Cvv: "cvv", + Date: "date", + DateInterval: "date_interval", + Dob: "dob", + DriverLicense: "driver_license", + EmailAddress: "email_address", + HealthcareNumber: "healthcare_number", + IpAddress: "ip_address", + Location: "location", + Name: "name", + NumericalPii: "numerical_pii", + PhoneNumber: "phone_number", + Ssn: "ssn", + Url: "url", + VehicleId: "vehicle_id", + MedicalCode: "medical_code", + NameFamily: "name_family", + NameGiven: "name_given", + AccountNumber: "account_number", + Event: "event", + Filename: "filename", + GenderSexuality: "gender_sexuality", + Language: "language", + LocationAddress: "location_address", + LocationCity: "location_city", + LocationCoordinate: "location_coordinate", + LocationCountry: "location_country", + LocationState: "location_state", + LocationZip: "location_zip", + MaritalStatus: "marital_status", + Money: "money", + NameMedicalProfessional: "name_medical_professional", + Occupation: "occupation", + Organization: "organization", + OrganizationMedicalFacility: "organization_medical_facility", + Origin: "origin", + PassportNumber: "passport_number", + Password: "password", + PhysicalAttribute: "physical_attribute", + PoliticalAffiliation: "political_affiliation", + Religion: "religion", + Time: "time", + Username: "username", + ZodiacSign: "zodiac_sign", + BloodType: "blood_type", + Condition: "condition", + Dose: "dose", + Drug: "drug", + Injury: "injury", + MedicalProcess: "medical_process", + Statistics: "statistics", + RoutingNumber: "routing_number", + CorporateAction: "corporate_action", + FinancialMetric: "financial_metric", + Product: "product", + Trend: "trend", + Duration: "duration", + LocationAddressStreet: "location_address_street", + All: "all", +} as const; diff --git a/src/ _generated_/rest/api/types/DetectFileRequestDataType.ts b/src/ _generated_/rest/api/types/DetectFileRequestDataType.ts new file mode 100644 index 00000000..9117b503 --- /dev/null +++ b/src/ _generated_/rest/api/types/DetectFileRequestDataType.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * How the input file is specified. + * + * - UNKNOWN: Unknown data type. + * - BASE64: Base64 encoded data. + */ +export type DetectFileRequestDataType = "UNKNOWN" | "BASE64"; +export const DetectFileRequestDataType = { + Unknown: "UNKNOWN", + Base64: "BASE64", +} as const; diff --git a/src/ _generated_/rest/api/types/DetectRequestDeidentifyOption.ts b/src/ _generated_/rest/api/types/DetectRequestDeidentifyOption.ts new file mode 100644 index 00000000..b274cec9 --- /dev/null +++ b/src/ _generated_/rest/api/types/DetectRequestDeidentifyOption.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Type of token to generate for detected entities. + * + * - UNKNOWN: unknown. + * - ENTITY_UNQ_COUNTER: Sensitive words are replaced with the entity type and a unique number. For example, "John and Jane" becomes "[NAME_1] and [NAME_2]". + * - ENTITY_ONLY: Sensitive words are replaced with the entity type. For example, "John and Jane" becomes "[NAME] and [NAME]". + */ +export type DetectRequestDeidentifyOption = "UNKNOWN" | "ENTITY_UNQ_COUNTER" | "ENTITY_ONLY"; +export const DetectRequestDeidentifyOption = { + Unknown: "UNKNOWN", + EntityUnqCounter: "ENTITY_UNQ_COUNTER", + EntityOnly: "ENTITY_ONLY", +} as const; diff --git a/src/ _generated_/rest/api/types/DetectedEntity.ts b/src/ _generated_/rest/api/types/DetectedEntity.ts new file mode 100644 index 00000000..420f8297 --- /dev/null +++ b/src/ _generated_/rest/api/types/DetectedEntity.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Detected entities. + */ +export interface DetectedEntity { + /** Processed text of the entity. */ + token?: string; + /** Original text of the entity. */ + value?: string; + location?: Skyflow.EntityLocation; + /** Highest-rated label. */ + entity_type?: string; + /** entity_scores and their scores. */ + entity_scores?: Record; +} diff --git a/src/ _generated_/rest/api/types/EntityLocation.ts b/src/ _generated_/rest/api/types/EntityLocation.ts new file mode 100644 index 00000000..885c1a41 --- /dev/null +++ b/src/ _generated_/rest/api/types/EntityLocation.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Locations of an entity in the text. + */ +export interface EntityLocation { + /** Index of the first character of the string in the original text. */ + start_index?: number; + /** Index of the last character of the string in the original text. */ + end_index?: number; + /** Index of the first character of the string in the processed text. */ + start_index_processed?: number; + /** Index of the last character of the string in the processed text. */ + end_index_processed?: number; +} diff --git a/src/ _generated_/rest/api/types/EntityType.ts b/src/ _generated_/rest/api/types/EntityType.ts new file mode 100644 index 00000000..7d679f30 --- /dev/null +++ b/src/ _generated_/rest/api/types/EntityType.ts @@ -0,0 +1,136 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Kinds of entities to de-identify. For details on specific entity types, how they're processed, and language support, see [Entity types and languages](/detect-entity-types). + */ +export type EntityType = + | "account_number" + | "age" + | "all" + | "bank_account" + | "blood_type" + | "condition" + | "corporate_action" + | "credit_card" + | "credit_card_expiration" + | "cvv" + | "date" + | "date_interval" + | "dob" + | "dose" + | "driver_license" + | "drug" + | "duration" + | "email_address" + | "event" + | "filename" + | "financial_metric" + | "gender_sexuality" + | "healthcare_number" + | "injury" + | "ip_address" + | "language" + | "location" + | "location_address" + | "location_address_street" + | "location_city" + | "location_coordinate" + | "location_country" + | "location_state" + | "location_zip" + | "marital_status" + | "medical_code" + | "medical_process" + | "money" + | "name" + | "name_family" + | "name_given" + | "name_medical_professional" + | "numerical_pii" + | "occupation" + | "organization" + | "organization_medical_facility" + | "origin" + | "passport_number" + | "password" + | "phone_number" + | "physical_attribute" + | "political_affiliation" + | "product" + | "religion" + | "routing_number" + | "ssn" + | "statistics" + | "time" + | "trend" + | "url" + | "username" + | "vehicle_id" + | "zodiac_sign"; +export const EntityType = { + AccountNumber: "account_number", + Age: "age", + All: "all", + BankAccount: "bank_account", + BloodType: "blood_type", + Condition: "condition", + CorporateAction: "corporate_action", + CreditCard: "credit_card", + CreditCardExpiration: "credit_card_expiration", + Cvv: "cvv", + Date: "date", + DateInterval: "date_interval", + Dob: "dob", + Dose: "dose", + DriverLicense: "driver_license", + Drug: "drug", + Duration: "duration", + EmailAddress: "email_address", + Event: "event", + Filename: "filename", + FinancialMetric: "financial_metric", + GenderSexuality: "gender_sexuality", + HealthcareNumber: "healthcare_number", + Injury: "injury", + IpAddress: "ip_address", + Language: "language", + Location: "location", + LocationAddress: "location_address", + LocationAddressStreet: "location_address_street", + LocationCity: "location_city", + LocationCoordinate: "location_coordinate", + LocationCountry: "location_country", + LocationState: "location_state", + LocationZip: "location_zip", + MaritalStatus: "marital_status", + MedicalCode: "medical_code", + MedicalProcess: "medical_process", + Money: "money", + Name: "name", + NameFamily: "name_family", + NameGiven: "name_given", + NameMedicalProfessional: "name_medical_professional", + NumericalPii: "numerical_pii", + Occupation: "occupation", + Organization: "organization", + OrganizationMedicalFacility: "organization_medical_facility", + Origin: "origin", + PassportNumber: "passport_number", + Password: "password", + PhoneNumber: "phone_number", + PhysicalAttribute: "physical_attribute", + PoliticalAffiliation: "political_affiliation", + Product: "product", + Religion: "religion", + RoutingNumber: "routing_number", + Ssn: "ssn", + Statistics: "statistics", + Time: "time", + Trend: "trend", + Url: "url", + Username: "username", + VehicleId: "vehicle_id", + ZodiacSign: "zodiac_sign", +} as const; diff --git a/src/ _generated_/rest/api/types/EntityTypes.ts b/src/ _generated_/rest/api/types/EntityTypes.ts new file mode 100644 index 00000000..44630141 --- /dev/null +++ b/src/ _generated_/rest/api/types/EntityTypes.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Entities to detect and de-identify. + */ +export type EntityTypes = Skyflow.EntityType[]; diff --git a/src/ _generated_/rest/api/types/ErrorResponse.ts b/src/ _generated_/rest/api/types/ErrorResponse.ts new file mode 100644 index 00000000..822dd151 --- /dev/null +++ b/src/ _generated_/rest/api/types/ErrorResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +export interface ErrorResponse { + error: Skyflow.ErrorResponseError; +} diff --git a/src/ _generated_/rest/api/types/ErrorResponseError.ts b/src/ _generated_/rest/api/types/ErrorResponseError.ts new file mode 100644 index 00000000..6b4777f3 --- /dev/null +++ b/src/ _generated_/rest/api/types/ErrorResponseError.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ErrorResponseError { + /** gRPC status codes. See https://grpc.io/docs/guides/status-codes. */ + grpc_code: number; + /** HTTP status codes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status. */ + http_code: number; + /** HTTP status message. */ + http_status: string; + message: string; + details?: Record[]; +} diff --git a/src/ _generated_/rest/api/types/ErrorString.ts b/src/ _generated_/rest/api/types/ErrorString.ts new file mode 100644 index 00000000..78dd85f5 --- /dev/null +++ b/src/ _generated_/rest/api/types/ErrorString.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Error message. + */ +export type ErrorString = string; diff --git a/src/ _generated_/rest/api/types/ProcessedFileOutputProcessedFileType.ts b/src/ _generated_/rest/api/types/ProcessedFileOutputProcessedFileType.ts new file mode 100644 index 00000000..d70d15a5 --- /dev/null +++ b/src/ _generated_/rest/api/types/ProcessedFileOutputProcessedFileType.ts @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Indicates type of processed_file. + * + * - none: Nothing is set. + * - redacted_audio: Processed file is audio. + * - redacted_image: Processed file is image. + * - redacted_transcription: Processed file is transcribed data. + * - redacted_file: Processed file contains redacted file data. + * - redacted_text: Processed file contains redacted text. + * - entities: Processed file contains entities. + * - redacted_aws_transcription_diarize_json: Processed file contains aws transcribed redacted json. + * - redacted_deepgram_transcription_diarize_json: Processed file contains deepgram transcribed redacted json. + * - plaintext_transcribed: Processed file contains deepgram plain transcribed json. + */ +export type ProcessedFileOutputProcessedFileType = + | "none" + | "redacted_audio" + | "redacted_image" + | "redacted_transcription" + | "redacted_file" + | "redacted_text" + | "entities" + | "redacted_aws_transcription_diarize_json" + | "redacted_deepgram_transcription_diarize_json" + | "plaintext_transcribed"; +export const ProcessedFileOutputProcessedFileType = { + None: "none", + RedactedAudio: "redacted_audio", + RedactedImage: "redacted_image", + RedactedTranscription: "redacted_transcription", + RedactedFile: "redacted_file", + RedactedText: "redacted_text", + Entities: "entities", + RedactedAwsTranscriptionDiarizeJson: "redacted_aws_transcription_diarize_json", + RedactedDeepgramTranscriptionDiarizeJson: "redacted_deepgram_transcription_diarize_json", + PlaintextTranscribed: "plaintext_transcribed", +} as const; diff --git a/src/ _generated_/rest/api/types/ReidentifyStringResponse.ts b/src/ _generated_/rest/api/types/ReidentifyStringResponse.ts new file mode 100644 index 00000000..a1d61ad4 --- /dev/null +++ b/src/ _generated_/rest/api/types/ReidentifyStringResponse.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Re-identify string response. + */ +export interface ReidentifyStringResponse { + /** Re-identified text. */ + processed_text?: string; +} diff --git a/src/ _generated_/rest/api/types/ResourceId.ts b/src/ _generated_/rest/api/types/ResourceId.ts new file mode 100644 index 00000000..b9d80732 --- /dev/null +++ b/src/ _generated_/rest/api/types/ResourceId.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * ID of a resource. + */ +export type ResourceId = string; diff --git a/src/ _generated_/rest/api/types/RestrictRegex.ts b/src/ _generated_/rest/api/types/RestrictRegex.ts new file mode 100644 index 00000000..1f6a47aa --- /dev/null +++ b/src/ _generated_/rest/api/types/RestrictRegex.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Regular expressions to replace with '[RESTRICTED]'. Expressions must match the entirety of a detected entity, not just a substring, for the entity to be restricted. Expressions don't match across entity boundaries. If a string or entity matches both `allow_regex` and `restrict_regex`, the entity is displayed in plaintext. + */ +export type RestrictRegex = string[]; diff --git a/src/ _generated_/rest/api/types/TokenType.ts b/src/ _generated_/rest/api/types/TokenType.ts new file mode 100644 index 00000000..823af7cd --- /dev/null +++ b/src/ _generated_/rest/api/types/TokenType.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Mapping of tokens to generation for detected entities. Can't be specified together with `token_type`. + */ +export interface TokenType { + default?: Skyflow.TokenTypeDefault; + /** Entity types to replace with vault tokens. */ + vault_token?: Skyflow.EntityType[]; + /** Entity types to replace with entity tokens with unique counters. */ + entity_unq_counter?: Skyflow.EntityType[]; + /** Entity types to replace with entity tokens. */ + entity_only?: Skyflow.EntityType[]; +} diff --git a/src/ _generated_/rest/api/types/TokenTypeDefault.ts b/src/ _generated_/rest/api/types/TokenTypeDefault.ts new file mode 100644 index 00000000..6453d7c8 --- /dev/null +++ b/src/ _generated_/rest/api/types/TokenTypeDefault.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type TokenTypeDefault = "entity_only" | "entity_unq_counter" | "vault_token"; +export const TokenTypeDefault = { + EntityOnly: "entity_only", + EntityUnqCounter: "entity_unq_counter", + VaultToken: "vault_token", +} as const; diff --git a/src/ _generated_/rest/api/types/TokenTypeWithoutVault.ts b/src/ _generated_/rest/api/types/TokenTypeWithoutVault.ts new file mode 100644 index 00000000..07e0ff9b --- /dev/null +++ b/src/ _generated_/rest/api/types/TokenTypeWithoutVault.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Mapping of tokens to generation for detected entities. Can't be specified together with `token_type`. + */ +export interface TokenTypeWithoutVault { + default?: Skyflow.TokenTypeWithoutVaultDefault; + /** Entity types to replace with entity tokens with unique counters. */ + entity_unq_counter?: Skyflow.EntityType[]; + /** Entity types to replace with entity tokens. */ + entity_only?: Skyflow.EntityType[]; +} diff --git a/src/ _generated_/rest/api/types/TokenTypeWithoutVaultDefault.ts b/src/ _generated_/rest/api/types/TokenTypeWithoutVaultDefault.ts new file mode 100644 index 00000000..6e1a58df --- /dev/null +++ b/src/ _generated_/rest/api/types/TokenTypeWithoutVaultDefault.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type TokenTypeWithoutVaultDefault = "entity_only" | "entity_unq_counter"; +export const TokenTypeWithoutVaultDefault = { + EntityOnly: "entity_only", + EntityUnqCounter: "entity_unq_counter", +} as const; diff --git a/src/ _generated_/rest/api/types/Transformations.ts b/src/ _generated_/rest/api/types/Transformations.ts new file mode 100644 index 00000000..da11b88a --- /dev/null +++ b/src/ _generated_/rest/api/types/Transformations.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Transformations to apply to the detected entities. + */ +export interface Transformations { + /** Shift dates by a specified number of days. */ + shift_dates?: Skyflow.TransformationsShiftDates; +} diff --git a/src/ _generated_/rest/api/types/TransformationsShiftDates.ts b/src/ _generated_/rest/api/types/TransformationsShiftDates.ts new file mode 100644 index 00000000..ee24dfcb --- /dev/null +++ b/src/ _generated_/rest/api/types/TransformationsShiftDates.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Shift dates by a specified number of days. + */ +export interface TransformationsShiftDates { + /** Maximum number of days to shift the date by. */ + max_days?: number; + /** Minimum number of days to shift the date by. */ + min_days?: number; + /** Entity types to shift dates for. */ + entity_types?: Skyflow.TransformationsShiftDatesEntityTypesItem[]; +} diff --git a/src/ _generated_/rest/api/types/TransformationsShiftDatesEntityTypesItem.ts b/src/ _generated_/rest/api/types/TransformationsShiftDatesEntityTypesItem.ts new file mode 100644 index 00000000..60f41ebd --- /dev/null +++ b/src/ _generated_/rest/api/types/TransformationsShiftDatesEntityTypesItem.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type TransformationsShiftDatesEntityTypesItem = "date" | "date_interval" | "dob"; +export const TransformationsShiftDatesEntityTypesItem = { + Date: "date", + DateInterval: "date_interval", + Dob: "dob", +} as const; diff --git a/src/ _generated_/rest/api/types/Uuid.ts b/src/ _generated_/rest/api/types/Uuid.ts new file mode 100644 index 00000000..b5af5445 --- /dev/null +++ b/src/ _generated_/rest/api/types/Uuid.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * UUID. + */ +export type Uuid = string; diff --git a/src/ _generated_/rest/api/types/V1AdvancedOptions.ts b/src/ _generated_/rest/api/types/V1AdvancedOptions.ts new file mode 100644 index 00000000..33ca50f4 --- /dev/null +++ b/src/ _generated_/rest/api/types/V1AdvancedOptions.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Advanced options for post processing. + */ +export interface V1AdvancedOptions { + /** No. of days by which original date has to be shifted to. */ + date_shift?: number; + /** Custom client specific logic. */ + custom_client?: boolean; + schema?: Skyflow.AdvancedOptionsVaultSchema; +} diff --git a/src/ _generated_/rest/api/types/V1AudioConfig.ts b/src/ _generated_/rest/api/types/V1AudioConfig.ts new file mode 100644 index 00000000..33b4d814 --- /dev/null +++ b/src/ _generated_/rest/api/types/V1AudioConfig.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * How to handle audio files. + */ +export interface V1AudioConfig { + output_transcription?: Skyflow.AudioConfigTranscriptionType; + /** If `true`, includes processed audio file in the response. */ + output_processed_audio?: boolean; + options?: Skyflow.V1AudioOptions; +} diff --git a/src/ _generated_/rest/api/types/V1AudioOptions.ts b/src/ _generated_/rest/api/types/V1AudioOptions.ts new file mode 100644 index 00000000..c30377cd --- /dev/null +++ b/src/ _generated_/rest/api/types/V1AudioOptions.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Options for audio files. + */ +export interface V1AudioOptions { + /** Padding added to the beginning of a bleep, in seconds. */ + bleep_start_padding?: number; + /** Padding added to the end of a bleep, in seconds. */ + bleep_end_padding?: number; + /** Specifies how the distortion will be made. Providing a number more than 0 will result in a higher tone and a coefficient less than 0 will result in a lower tone. */ + distortion_steps?: number; + /** This parameter configures the frequency of the sine wave used for the bleep sound in an audio segment. */ + bleep_frequency?: number; + /** It controls the relative loudness of the bleep,positive values increase its loudness, and negative values decrease it. */ + bleep_gain?: number; +} diff --git a/src/ _generated_/rest/api/types/V1DetectFileResponse.ts b/src/ _generated_/rest/api/types/V1DetectFileResponse.ts new file mode 100644 index 00000000..51e69905 --- /dev/null +++ b/src/ _generated_/rest/api/types/V1DetectFileResponse.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Response to deidentify a file. + */ +export interface V1DetectFileResponse { + /** Status URL for the deidentification request. */ + status_url?: string; +} diff --git a/src/ _generated_/rest/api/types/V1DetectStatusResponse.ts b/src/ _generated_/rest/api/types/V1DetectStatusResponse.ts new file mode 100644 index 00000000..c6fdd92e --- /dev/null +++ b/src/ _generated_/rest/api/types/V1DetectStatusResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Response to get the status of a file deidentification request. + */ +export interface V1DetectStatusResponse { + status?: Skyflow.V1DetectStatusResponseStatus; + /** How the input file was specified. */ + output?: Skyflow.V1ProcessedFileOutput[]; + /** Status details about the deidentification request. */ + message?: string; +} diff --git a/src/ _generated_/rest/api/types/V1DetectStatusResponseStatus.ts b/src/ _generated_/rest/api/types/V1DetectStatusResponseStatus.ts new file mode 100644 index 00000000..ef62b56c --- /dev/null +++ b/src/ _generated_/rest/api/types/V1DetectStatusResponseStatus.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Status of the deidentification request. + * + * - UNKNOWN: Unknown status. + * - FAILED: Deidentification failed. + * - SUCCESS: Deidentification succeeded. + * - IN_PROGRESS: Deidentification ongoing. + */ +export type V1DetectStatusResponseStatus = "UNKNOWN" | "FAILED" | "SUCCESS" | "IN_PROGRESS"; +export const V1DetectStatusResponseStatus = { + Unknown: "UNKNOWN", + Failed: "FAILED", + Success: "SUCCESS", + InProgress: "IN_PROGRESS", +} as const; diff --git a/src/ _generated_/rest/api/types/V1DetectTextRequest.ts b/src/ _generated_/rest/api/types/V1DetectTextRequest.ts new file mode 100644 index 00000000..582e856f --- /dev/null +++ b/src/ _generated_/rest/api/types/V1DetectTextRequest.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Request to deidentify a string. + */ +export interface V1DetectTextRequest { + /** Data to deidentify. */ + text: string; + /** ID of the vault. */ + vault_id: string; + /** Will give a handle to delete the tokens generated during a specific interaction. */ + session_id?: string; + /** Entities to detect and deidentify. */ + restrict_entity_types?: Skyflow.DetectDataEntities[]; + deidentify_token_format?: Skyflow.DetectRequestDeidentifyOption; + /** Regular expressions to ignore when detecting entities. */ + allow_regex?: string[]; + /** Regular expressions to always restrict. Strings matching these regular expressions are replaced with 'RESTRICTED'. */ + restrict_regex?: string[]; + /** If `true`, returns the details for the detected entities. */ + return_entities?: boolean; + accuracy?: Skyflow.DetectDataAccuracy; + advanced_options?: Skyflow.V1AdvancedOptions; + /** Indicates whether entities should be stored in the vault. */ + store_entities?: boolean; +} diff --git a/src/ _generated_/rest/api/types/V1DetectTextResponse.ts b/src/ _generated_/rest/api/types/V1DetectTextResponse.ts new file mode 100644 index 00000000..be3c7788 --- /dev/null +++ b/src/ _generated_/rest/api/types/V1DetectTextResponse.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Response to deidentify a string. + */ +export interface V1DetectTextResponse { + /** Deidentified text. If the input was a file, text that was extracted or transcribed from the file and deidentified. */ + processed_text?: string; + /** Detected entities. */ + entities?: Skyflow.V1ResponseEntities[]; +} diff --git a/src/ _generated_/rest/api/types/V1FileDataFormat.ts b/src/ _generated_/rest/api/types/V1FileDataFormat.ts new file mode 100644 index 00000000..56c2ee64 --- /dev/null +++ b/src/ _generated_/rest/api/types/V1FileDataFormat.ts @@ -0,0 +1,68 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Supported input file data formats. + * + * - unknown: If data format is not provided. + * - mp3: Audio mp3 file. + * - wav: Audio wav file. + * - pdf: Text pdf file. + * - txt: Plain text file. + * - csv: CSV file. + * - json: JSON file. + * - jpg: JPG image file. + * - jpeg: JPEG image file. + * - tif: TIF image file. + * - tiff: TIFF image file. + * - png: PNG image file. + * - bmp: Bitmap image file. + * - xls: XLS Excel file. + * - xlsx: XLSX Excel file. + * - doc: DOC Word file. + * - docx: DOCS Word file. + * - ppt: PPT PowerPoint file. + * - pptx: PPTX PowerPoint file. + */ +export type V1FileDataFormat = + | "bmp" + | "csv" + | "doc" + | "docx" + | "jpeg" + | "jpg" + | "json" + | "mp3" + | "pdf" + | "png" + | "ppt" + | "pptx" + | "tif" + | "tiff" + | "txt" + | "unknown" + | "wav" + | "xls" + | "xlsx"; +export const V1FileDataFormat = { + Bmp: "bmp", + Csv: "csv", + Doc: "doc", + Docx: "docx", + Jpeg: "jpeg", + Jpg: "jpg", + Json: "json", + Mp3: "mp3", + Pdf: "pdf", + Png: "png", + Ppt: "ppt", + Pptx: "pptx", + Tif: "tif", + Tiff: "tiff", + Txt: "txt", + Unknown: "unknown", + Wav: "wav", + Xls: "xls", + Xlsx: "xlsx", +} as const; diff --git a/src/ _generated_/rest/api/types/V1ImageOptions.ts b/src/ _generated_/rest/api/types/V1ImageOptions.ts new file mode 100644 index 00000000..fb33b7fc --- /dev/null +++ b/src/ _generated_/rest/api/types/V1ImageOptions.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * How to handle image files. + */ +export interface V1ImageOptions { + /** If `true`, includes processed image in the output. */ + output_processed_image?: boolean; + /** If `true`, includes OCR text output in the response. */ + output_ocr_text?: boolean; +} diff --git a/src/ _generated_/rest/api/types/V1Locations.ts b/src/ _generated_/rest/api/types/V1Locations.ts new file mode 100644 index 00000000..82fc7d10 --- /dev/null +++ b/src/ _generated_/rest/api/types/V1Locations.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Locations of an entity in the text. + */ +export interface V1Locations { + /** Index of the first character of the string in the original text. */ + start_index?: number; + /** Index of the last character of the string in the original text. */ + end_index?: number; + /** Index of the first character of the string in the processed text. */ + start_index_processed?: number; + /** Index of the last character of the string in the processed text. */ + end_index_processed?: number; +} diff --git a/src/ _generated_/rest/api/types/V1PdfConfig.ts b/src/ _generated_/rest/api/types/V1PdfConfig.ts new file mode 100644 index 00000000..74d58161 --- /dev/null +++ b/src/ _generated_/rest/api/types/V1PdfConfig.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * How to handle PDF files. + */ +export interface V1PdfConfig { + options?: Skyflow.V1PdfOptions; +} diff --git a/src/ _generated_/rest/api/types/V1PdfOptions.ts b/src/ _generated_/rest/api/types/V1PdfOptions.ts new file mode 100644 index 00000000..efb2a664 --- /dev/null +++ b/src/ _generated_/rest/api/types/V1PdfOptions.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * How to handle PDF files. + */ +export interface V1PdfOptions { + /** Pixel density at which to process the PDF file. */ + density?: number; + /** Max resolution at which to process the PDF file. */ + max_resolution?: number; +} diff --git a/src/ _generated_/rest/api/types/V1ProcessedFileOutput.ts b/src/ _generated_/rest/api/types/V1ProcessedFileOutput.ts new file mode 100644 index 00000000..7d40c433 --- /dev/null +++ b/src/ _generated_/rest/api/types/V1ProcessedFileOutput.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Contains details and contents of the processed file. + */ +export interface V1ProcessedFileOutput { + output_type?: Skyflow.DetectFileRequestDataType; + /** URL or base64-encoded data of the output. */ + processed_file?: string; + processed_file_type?: Skyflow.ProcessedFileOutputProcessedFileType; +} diff --git a/src/ _generated_/rest/api/types/V1ResponseEntities.ts b/src/ _generated_/rest/api/types/V1ResponseEntities.ts new file mode 100644 index 00000000..9554698f --- /dev/null +++ b/src/ _generated_/rest/api/types/V1ResponseEntities.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Skyflow from "../index"; + +/** + * Detected entities. + */ +export interface V1ResponseEntities { + /** Processed text of the entity. */ + processed_text?: string; + /** Original text of the entity. */ + original_text?: string; + location?: Skyflow.V1Locations; + /** Highest rated label. */ + best_label?: string; + /** Labels and their scores. */ + labels?: Record; +} diff --git a/src/ _generated_/rest/api/types/VaultId.ts b/src/ _generated_/rest/api/types/VaultId.ts new file mode 100644 index 00000000..6d06d4de --- /dev/null +++ b/src/ _generated_/rest/api/types/VaultId.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * ID of a vault you have Detect Invoker or Vault Owner permissions for. + */ +export type VaultId = string; diff --git a/src/ _generated_/rest/api/types/index.ts b/src/ _generated_/rest/api/types/index.ts index b3448324..6db978dd 100644 --- a/src/ _generated_/rest/api/types/index.ts +++ b/src/ _generated_/rest/api/types/index.ts @@ -9,6 +9,15 @@ export * from "./DetokenizeRecordResponseValueType"; export * from "./V1GetAuthTokenResponse"; export * from "./RedactionEnumRedaction"; export * from "./RequestActionType"; +export * from "./AdvancedOptionsColumnMapping"; +export * from "./AdvancedOptionsEntityColumnMap"; +export * from "./AdvancedOptionsVaultSchema"; +export * from "./AudioConfigTranscriptionType"; +export * from "./DetectDataAccuracy"; +export * from "./DetectDataEntities"; +export * from "./DetectFileRequestDataType"; +export * from "./DetectRequestDeidentifyOption"; +export * from "./ProcessedFileOutputProcessedFileType"; export * from "./GooglerpcStatus"; export * from "./ProtobufAny"; export * from "./V1AuditAfterOptions"; @@ -41,3 +50,45 @@ export * from "./V1TokenizeResponse"; export * from "./V1UpdateRecordResponse"; export * from "./V1VaultFieldMapping"; export * from "./V1VaultSchemaConfig"; +export * from "./V1AdvancedOptions"; +export * from "./V1AudioConfig"; +export * from "./V1AudioOptions"; +export * from "./V1DetectFileResponse"; +export * from "./V1DetectStatusResponse"; +export * from "./V1DetectStatusResponseStatus"; +export * from "./V1DetectTextRequest"; +export * from "./V1DetectTextResponse"; +export * from "./V1FileDataFormat"; +export * from "./V1ImageOptions"; +export * from "./V1Locations"; +export * from "./V1PdfConfig"; +export * from "./V1PdfOptions"; +export * from "./V1ProcessedFileOutput"; +export * from "./V1ResponseEntities"; +export * from "./EntityType"; +export * from "./ErrorString"; +export * from "./ErrorResponseError"; +export * from "./ErrorResponse"; +export * from "./DeidentifyStatusResponseStatus"; +export * from "./DeidentifyStatusResponseOutputType"; +export * from "./DeidentifyStatusResponse"; +export * from "./EntityLocation"; +export * from "./DeidentifyFileOutputProcessedFileType"; +export * from "./DeidentifyFileOutput"; +export * from "./DetectedEntity"; +export * from "./TokenTypeDefault"; +export * from "./TokenType"; +export * from "./TokenTypeWithoutVaultDefault"; +export * from "./TokenTypeWithoutVault"; +export * from "./DeidentifyStringResponse"; +export * from "./TransformationsShiftDatesEntityTypesItem"; +export * from "./TransformationsShiftDates"; +export * from "./Transformations"; +export * from "./VaultId"; +export * from "./AllowRegex"; +export * from "./RestrictRegex"; +export * from "./EntityTypes"; +export * from "./DeidentifyFileResponse"; +export * from "./ReidentifyStringResponse"; +export * from "./Uuid"; +export * from "./ResourceId"; diff --git a/src/error/codes/index.ts b/src/error/codes/index.ts index fc312b84..0a30afe8 100644 --- a/src/error/codes/index.ts +++ b/src/error/codes/index.ts @@ -189,6 +189,18 @@ const SKYFLOW_ERROR_CODE = { EMPTY_VAULT_CLIENTS: { http_code: 400, message: errorMessages.EMPTY_VAULT_CLIENTS }, EMPTY_CONNECTION_CLIENTS: { http_code: 400, message: errorMessages.EMPTY_CONNECTION_CLIENTS }, + + INVALID_TEXT_IN_DEIDENTIFY: { http_code: 400, message: errorMessages.INVALID_TEXT_IN_DEIDENTIFY }, + INVALID_ENTITIES_IN_DEIDENTIFY: { http_code: 400, message: errorMessages.INVALID_ENTITIES_IN_DEIDENTIFY }, + INVALID_ALLOW_REGEX_LIST: { http_code: 400, message: errorMessages.INVALID_ALLOW_REGEX_LIST }, + INVALID_RESTRICT_REGEX_LIST: { http_code: 400, message: errorMessages.INVALID_RESTRICT_REGEX_LIST }, + INVALID_TOKEN_FORMAT: { http_code: 400, message: errorMessages.INVALID_TOKEN_FORMAT }, + INVALID_TRANSFORMATIONS: { http_code: 400, message: errorMessages.INVALID_TRANSFORMATIONS }, + + INVALID_TEXT_IN_REIDENTIFY: { http_code: 400, message: errorMessages.INVALID_TEXT_IN_REIDENTIFY }, + INVALID_REDACTED_ENTITIES_IN_REIDENTIFY: { http_code: 400, message: errorMessages.INVALID_REDACTED_ENTITIES_IN_REIDENTIFY }, + INVALID_MASKED_ENTITIES_IN_REIDENTIFY: { http_code: 400, message: errorMessages.INVALID_MASKED_ENTITIES_IN_REIDENTIFY }, + INVALID_PLAIN_TEXT_ENTITIES_IN_REIDENTIFY: { http_code: 400, message: errorMessages.INVALID_PLAIN_TEXT_ENTITIES_IN_REIDENTIFY }, }; export default SKYFLOW_ERROR_CODE; \ No newline at end of file diff --git a/src/error/messages/index.ts b/src/error/messages/index.ts index ccb56fb8..f9344a77 100644 --- a/src/error/messages/index.ts +++ b/src/error/messages/index.ts @@ -193,7 +193,19 @@ const errorMessages = { INVAILD_JSON_RESPONSE: `${errorPrefix} Validation error. The invalid json response. Please reach out to skyflow using requestId - %s1.`, EMPTY_VAULT_CLIENTS: `${errorPrefix} Validation error. No vault config found. Please add a vault config`, - EMPTY_CONNECTION_CLIENTS: `${errorPrefix} Validation error. No connection config found. Please add a connection config` + EMPTY_CONNECTION_CLIENTS: `${errorPrefix} Validation error. No connection config found. Please add a connection config`, + + INVALID_TEXT_IN_DEIDENTIFY: `${errorPrefix} Validation error. The text field is required and must be a non-empty string. Specify a valid text.`, + INVALID_ENTITIES_IN_DEIDENTIFY: `${errorPrefix} Validation error. The entities field must be an array of DetectEntities enums. Specify a valid entities.`, + INVALID_ALLOW_REGEX_LIST: `${errorPrefix} Validation error. The allowRegexList field must be an array of strings. Specify a valid allowRegexList.`, + INVALID_RESTRICT_REGEX_LIST: `${errorPrefix} Validation error. The restrictRegexList field must be an array of strings. Specify a valid restrictRegexList.`, + INVALID_TOKEN_FORMAT: `${errorPrefix} Validation error. The tokenFormat key must be an instance of TokenFormat. Specify a valid token format.`, + INVALID_TRANSFORMATIONS: `${errorPrefix} Validation error. The transformations key must be an instance of Transformations. Specify a valid transformations.`, + + INVALID_TEXT_IN_REIDENTIFY: `${errorPrefix} Validation error. The text field is required and must be a non-empty string. Specify a valid text.`, + INVALID_REDACTED_ENTITIES_IN_REIDENTIFY: `${errorPrefix} Validation error. The redactedEntities field must be an array of DetectEntities enums. Specify a valid redactedEntities.`, + INVALID_MASKED_ENTITIES_IN_REIDENTIFY: `${errorPrefix} Validation error. The maskedEntities field must be an array of DetectEntities enums. Specify a valid maskedEntities.`, + INVALID_PLAIN_TEXT_ENTITIES_IN_REIDENTIFY: `${errorPrefix} Validation error. The plainTextEntities field must be an array of DetectEntities enums. Specify a valid plainTextEntities.`, }; export default errorMessages; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 145621f4..27f55d2d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import Skyflow from './vault/skyflow'; -import { LogLevel, Env, RedactionType, RequestMethod, OrderByEnum, TokenMode } from './utils'; +import { LogLevel, Env, RedactionType, RequestMethod, OrderByEnum, TokenMode, DetectEntities } from './utils'; import InsertRequest from './vault/model/request/insert'; import InsertOptions from './vault/model/options/insert'; import GetRequest from './vault/model/request/get'; @@ -31,6 +31,14 @@ import { SkyflowConfig, TokenizeRequestType, DetokenizeData } from './vault/type import VaultConfig from './vault/config/vault'; import SkyflowError from './error'; import ConnectionConfig from './vault/config/connection'; +import DeidentifyTextRequest from './vault/model/request/deidentify-text'; +import DeidentifyTextOptions from './vault/model/options/deidentify-text'; +import DeidentifyTextResponse from './vault/model/response/deidentify-text'; +import ReidentifyTextRequest from './vault/model/request/reidentify-text'; +import ReidentifyTextOptions from './vault/model/options/reidentify-text'; +import ReidentifyTextResponse from './vault/model/response/reidentify-text'; +import TokenFormat from './vault/model/options/deidentify-text/token-format'; +import Transformations from './vault/model/options/deidentify-text/transformations'; export { Env, @@ -78,5 +86,14 @@ export { TokenizeRequest, TokenizeResponse, InvokeConnectionRequest, - InvokeConnectionResponse + InvokeConnectionResponse, + DeidentifyTextRequest, + DeidentifyTextOptions, + DetectEntities, + DeidentifyTextResponse, + ReidentifyTextRequest, + ReidentifyTextOptions, + ReidentifyTextResponse, + TokenFormat, + Transformations }; \ No newline at end of file diff --git a/src/utils/index.ts b/src/utils/index.ts index b75dce9f..c74cdaf6 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -96,9 +96,83 @@ export const TYPES = { GET: 'GET', FILE_UPLOAD: 'FILE_UPLOAD', QUERY: 'QUERY', + DETECT: 'DETECT', INVOKE_CONNECTION: 'INVOKE_CONNECTION', + DEIDENTIFY_TEXT: 'DEIDENTIFY_TEXT', }; +export const CONTROLLER_TYPES = { + DETECT: 'DETECT', + VAULT: 'VAULT', + CONNECTION: 'CONNECTION', +} + +export enum DetectEntities { + ACCOUNT_NUMBER = "account_number", + AGE = 'age', + ALL = 'all', + BANK_ACCOUNT = 'bank_account', + BLOOD_TYPE = 'blood_type', + CONDITION = 'condition', + CORPORATE_ACTION = 'corporate_action', + CREDIT_CARD = 'credit_card', + CREDIT_CARD_EXPIRATION = 'credit_card_expiration', + CVV = 'cvv', + DATE = 'date', + DATE_INTERVAL = 'date_interval', + DOB = 'dob', + DOSE = 'dose', + DRIVER_LICENSE = 'driver_license', + DRUG = 'drug', + DURATION = 'duration', + EMAIL_ADDRESS = 'email_address', + EVENT = 'event', + FILENAME = 'filename', + FINANCIAL_METRIC = 'financial_metric', + GENDER_SEXUALITY = 'gender_sexuality', + HEALTHCARE_NUMBER = 'healthcare_number', + INJURY = 'injury', + IP_ADDRESS = 'ip_address', + LANGUAGE = 'language', + LOCATION = 'location', + LOCATION_ADDRESS = 'location_address', + LOCATION_ADDRESS_STREET = 'location_address_street', + LOCATION_CITY = 'location_city', + LOCATION_COORDINATE = 'location_coordinate', + LOCATION_COUNTRY = 'location_country', + LOCATION_STATE = 'location_state', + LOCATION_ZIP = 'location_zip', + MARITAL_STATUS = 'marital_status', + MEDICAL_CODE = 'medical_code', + MEDICAL_PROCESS = 'medical_process', + MONEY = 'money', + NAME = 'name', + NAME_FAMILY = 'name_family', + NAME_GIVEN = 'name_given', + NAME_MEDICAL_PROFESSIONAL = 'name_medical_professional', + NUMERICAL_PII = 'numerical_pii', + OCCUPATION = 'occupation', + ORGANIZATION = 'organization', + ORGANIZATION_MEDICAL_FACILITY = 'organization_medical_facility', + ORIGIN = 'origin', + PASSPORT_NUMBER = 'passport_number', + PASSWORD = 'password', + PHONE_NUMBER = 'phone_number', + PHYSICAL_ATTRIBUTE = 'physical_attribute', + POLITICAL_AFFILIATION = 'political_affiliation', + PRODUCT = 'product', + RELIGION = 'religion', + ROUTING_NUMBER = 'routing_number', + SSN = 'ssn', + STATISTICS = 'statistics', + TIME = 'time', + TREND = 'trend', + URL = 'url', + USERNAME = 'username', + VEHICLE_ID = 'vehicle_id', + ZODIAC_SIGN = 'zodiac_sign', +} + export interface ISkyflowError { http_status?: string | number | null, grpc_code?: string | number | null, diff --git a/src/utils/logs/index.ts b/src/utils/logs/index.ts index 3b4211a4..5a4645fb 100644 --- a/src/utils/logs/index.ts +++ b/src/utils/logs/index.ts @@ -65,7 +65,11 @@ const logs = { USING_API_KEY: 'Using api key from credentials', USING_CREDENTIALS_STRING: 'Using credentials string from credentials', USING_PATH: 'Using path from credentials', - USING_SKYFLOW_CREDENTIALS_ENV: 'Using SKYFLOW_CREDENTIALS from env' + USING_SKYFLOW_CREDENTIALS_ENV: 'Using SKYFLOW_CREDENTIALS from env', + DEIDENTIFY_TEXT_TRIGGERED: 'Deidentify text method triggered', + VALIDATE_DEIDENTIFY_TEXT_INPUT: 'Validating deidentify text input', + REIDENTIFY_TEXT_TRIGGERED: 'Reidentify text method triggered', + VALIDATE_REIDENTIFY_TEXT_INPUT: 'Validating reidentify text input', }, errorLogs: { VAULT_CONFIG_KEY_MISSING: "Invalid skyflow config. Vaults configs key missing in skyflow config.", diff --git a/src/utils/validations/index.ts b/src/utils/validations/index.ts index 5409dd4d..67dda007 100644 --- a/src/utils/validations/index.ts +++ b/src/utils/validations/index.ts @@ -24,6 +24,12 @@ import * as fs from 'fs'; import { isExpired } from "../jwt-utils"; import logs from "../logs"; import FileUploadOptions from "../../vault/model/options/fileUpload"; +import DeidentifyTextRequest from "../../vault/model/request/deidentify-text"; +import DeidentifyTextOptions from "../../vault/model/options/deidentify-text"; +import TokenFormat from "../../vault/model/options/deidentify-text/token-format"; +import Transformations from "../../vault/model/options/deidentify-text/transformations"; +import ReidentifyTextRequest from "../../vault/model/request/reidentify-text"; +import ReidentifyTextOptions from "../../vault/model/options/reidentify-text"; export function isEnv(value?: string): boolean { return value !== undefined && Object.values(Env).includes(value as Env); @@ -941,6 +947,53 @@ export const validateQueryRequest = (queryRequest: QueryRequest, logLevel: LogLe } } +export const validateDeIdentifyTextRequest = (deIdentifyTextRequest: DeidentifyTextRequest, options?: DeidentifyTextOptions, logLevel: LogLevel = LogLevel.ERROR) => { + if (!deIdentifyTextRequest.text || typeof deIdentifyTextRequest.text !== 'string' || deIdentifyTextRequest.text.trim().length === 0) { + throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TEXT_IN_DEIDENTIFY); + } + + if (options) { + if (options.getEntities() && !Array.isArray(options.getEntities())) { + throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_ENTITIES_IN_DEIDENTIFY); + } + + if (options.getAllowRegexList() && !Array.isArray(options.getAllowRegexList())) { + throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_ALLOW_REGEX_LIST); + } + + if (options.getRestrictRegexList() && !Array.isArray(options.getRestrictRegexList())) { + throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_RESTRICT_REGEX_LIST); + } + + if (options.getTokenFormat() && !(options.getTokenFormat() instanceof TokenFormat)) { + throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TOKEN_FORMAT); + } + + if (options.getTransformations() && !(options.getTransformations() instanceof Transformations)) { + throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TRANSFORMATIONS); + } + } +}; + +export const validateReidentifyTextRequest = (request: ReidentifyTextRequest, options?: ReidentifyTextOptions, logLevel: LogLevel = LogLevel.ERROR) => { + if (!request.text || typeof request.text !== 'string' || request.text.trim().length === 0) { + throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TEXT_IN_REIDENTIFY); + } + + if (options) { + if (options.getRedactedEntities() && !Array.isArray(options.getRedactedEntities())) { + throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_REDACTED_ENTITIES_IN_REIDENTIFY); + } + + if (options.getMaskedEntities() && !Array.isArray(options.getMaskedEntities())) { + throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_MASKED_ENTITIES_IN_REIDENTIFY); + } + if (options.getPlainTextEntities() && !Array.isArray(options.getPlainTextEntities())) { + throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_PLAIN_TEXT_ENTITIES_IN_REIDENTIFY); + } + } +}; + function isStringKeyValueMap(obj: any): obj is StringKeyValueMapType { if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) { return false; diff --git a/src/vault/client/index.ts b/src/vault/client/index.ts index 2bd1095d..c3266c7e 100644 --- a/src/vault/client/index.ts +++ b/src/vault/client/index.ts @@ -1,6 +1,7 @@ // imports import { Query } from "../../ _generated_/rest/api/resources/query/client/Client"; import { Records } from "../../ _generated_/rest/api/resources/records/client/Client"; +import { Strings } from "../../ _generated_/rest/api/resources/strings/client/Client"; import { Tokens } from "../../ _generated_/rest/api/resources/tokens/client/Client"; import SkyflowError from "../../error"; import errorMessages from "../../error/messages"; @@ -23,6 +24,8 @@ class VaultClient { queryAPI!: Query; + stringsAPI!: Strings; + individualCredentials?: Credentials; skyflowCredentials?: Credentials; @@ -77,6 +80,8 @@ class VaultClient { case TYPES.QUERY: this.queryAPI = new Query(this.configuration); break; + case TYPES.DETECT: + this.stringsAPI = new Strings(this.configuration); default: break; } diff --git a/src/vault/controller/detect/index.ts b/src/vault/controller/detect/index.ts index e467a486..0ce94f5c 100644 --- a/src/vault/controller/detect/index.ts +++ b/src/vault/controller/detect/index.ts @@ -1,25 +1,154 @@ //imports +import { DetectedEntity, EntityType, Transformations } from "../../../ _generated_/rest/api"; +import { generateSDKMetrics, getBearerToken, MessageType, parameterizedString, printLog, removeSDKVersion, SDK_METRICS_HEADER_KEY, TYPES } from "../../../utils"; +import logs from "../../../utils/logs"; +import { validateDeIdentifyTextRequest, validateReidentifyTextRequest } from "../../../utils/validations"; +import VaultClient from "../../client"; +import DeidentifyTextOptions from "../../model/options/deidentify-text"; +import ReidentifyTextOptions from "../../model/options/reidentify-text"; +import DeidentifyTextRequest from "../../model/request/deidentify-text"; +import ReidentifyTextRequest from "../../model/request/reidentify-text"; +import DeidentifiedTextResponse from "../../model/response/deidentify-text"; +import DeidentifyTextResponse from "../../model/response/deidentify-text"; +import ReidentifyTextResponse from "../../model/response/reidentify-text"; + class DetectController { - constructor() { + private client: VaultClient; + + constructor(client: VaultClient) { + this.client = client; + printLog(logs.infoLogs.CONTROLLER_INITIALIZED, MessageType.LOG, this.client.getLogLevel()); + } + private createSdkHeaders() { + return { [SDK_METRICS_HEADER_KEY]: JSON.stringify(generateSDKMetrics()) }; } - static initialize() { - //return detect object + private handleRequest(apiCall: Function, requestType: string): Promise { + return new Promise((resolve, reject) => { + printLog(parameterizedString(logs.infoLogs.EMIT_REQUEST, TYPES[requestType]), MessageType.LOG, this.client.getLogLevel()); + const sdkHeaders = this.createSdkHeaders(); + + getBearerToken(this.client.getCredentials(), this.client.getLogLevel()).then(authInfo => { + this.client.initAPI(authInfo, requestType); + apiCall({ headers: { ...sdkHeaders } }) + .then((response: any) => { + const { data, rawResponse } = response; + const requestId = rawResponse?.headers?.get('x-request-id'); + printLog(logs.infoLogs[`${requestType}_REQUEST_RESOLVED`], MessageType.LOG, this.client.getLogLevel()); + switch (requestType) { + case TYPES.DETECT: + resolve({records: data, requestId}) + break; + } + }).catch((error: any) => { + printLog(logs.errorLogs[`${requestType}_REQUEST_REJECTED`], MessageType.ERROR, this.client.getLogLevel()); + this.client.failureResponse(error).catch((err) => reject(err)) + }); + }).catch(reject); + }); } - deIdentify() { - return this; + private buildDeidentifyTextRequest(request: DeidentifyTextRequest, options?: DeidentifyTextOptions) { + + return { + vault_id: this.client.vaultId, + text: request.text, + entity_types: options?.getEntities() as EntityType[], + allow_regex: options?.getAllowRegexList(), + restrict_regex: options?.getRestrictRegexList(), + transformations: { + shift_dates: { + max_days: options?.getTransformations()?.getShiftDays()?.max, + min_days: options?.getTransformations()?.getShiftDays()?.min, + entity_types: options?.getTransformations()?.getShiftDays()?.entities, + } + } as Transformations, + }; } - text() { + deidentifyText(request: DeidentifyTextRequest, options?: DeidentifyTextOptions): Promise { + return new Promise((resolve, reject) => { + try { + printLog(logs.infoLogs.DEIDENTIFY_TEXT_TRIGGERED, MessageType.LOG, this.client.getLogLevel()); + printLog(logs.infoLogs.VALIDATE_DEIDENTIFY_TEXT_INPUT, MessageType.LOG, this.client.getLogLevel()); + + validateDeIdentifyTextRequest(request, options, this.client.getLogLevel()); + const requestBody = this.buildDeidentifyTextRequest(request, options); + this.handleRequest( + () => this.client.stringsAPI.deidentifyString( + requestBody + ).withRawResponse(), + TYPES.DETECT + ).then(data => { + resolve(new DeidentifyTextResponse({ + processedText: data.records.processed_text, + entities: data.records.entities.map((entity: DetectedEntity) => ({ + token: entity.token, + value: entity.value, + textIndex: { + start: entity.location?.start_index, + end: entity.location?.end_index, + }, + processedIndex: { + start: entity.location?.start_index_processed, + end: entity.location?.end_index_processed, + }, + entity: entity.entity_type, + scores: entity.entity_scores, + })), + wordCount: data.records.word_count, + charCount: data.records.character_count, + })); + }).catch(error => { + reject(error) + }); + } catch (error) { + if (error instanceof Error) + printLog(removeSDKVersion(error.message), MessageType.ERROR, this.client.getLogLevel()); + reject(error); + } + }); } - file() { + reidentifyText(request: ReidentifyTextRequest, options?: ReidentifyTextOptions): Promise { + return new Promise((resolve, reject) => { + try { + printLog(logs.infoLogs.REIDENTIFY_TEXT_TRIGGERED, MessageType.LOG, this.client.getLogLevel()); + printLog(logs.infoLogs.VALIDATE_REIDENTIFY_TEXT_INPUT, MessageType.LOG, this.client.getLogLevel()); + validateReidentifyTextRequest(request, options, this.client.getLogLevel()); + + const requestBody = { + text: request.text, + vault_id: this.client.vaultId, + format: { + redacted: options?.getRedactedEntities(), + masked: options?.getMaskedEntities(), + plaintext: options?.getPlainTextEntities(), + } + }; + this.handleRequest( + () => this.client.stringsAPI.reidentifyString( + requestBody + ).withRawResponse(), + TYPES.DETECT + ).then(data => { + resolve(new ReidentifyTextResponse({ + processedText: data.records.text + })); + }).catch(error => { + reject(error) + }); + } catch (error) { + if (error instanceof Error) + printLog(removeSDKVersion(error.message), MessageType.ERROR, this.client.getLogLevel()); + reject(error); + } + }); } } diff --git a/src/vault/model/options/deidentify-text/index.ts b/src/vault/model/options/deidentify-text/index.ts new file mode 100644 index 00000000..0fcbb078 --- /dev/null +++ b/src/vault/model/options/deidentify-text/index.ts @@ -0,0 +1,56 @@ +import { DetectEntities } from "../../../../utils"; +import TokenFormat from "./token-format"; +import Transformations from "./transformations"; + +class DeidentifyTextOptions { + // Fields + private _entities?: DetectEntities[]; + private _allowRegexList?: string[]; + private _restrictRegexList?: string[]; + private _tokenFormat?: TokenFormat; + private _transformations?: Transformations; + + // Setters + setEntities(entities: DetectEntities[]) { + this._entities = entities; + } + + setAllowRegexList(allowRegexList: string[]) { + this._allowRegexList = allowRegexList; + } + + setRestrictRegexList(restrictRegexList: string[]) { + this._restrictRegexList = restrictRegexList; + } + + setTokenFormat(tokenFormat: TokenFormat) { + this._tokenFormat = tokenFormat; + } + + setTransformations(transformations: Transformations) { + this._transformations = transformations; + } + + // Getters + getEntities(): DetectEntities[] | undefined { + return this._entities; + } + + getAllowRegexList(): string[] | undefined { + return this._allowRegexList; + } + + getRestrictRegexList(): string[] | undefined { + return this._restrictRegexList; + } + + getTokenFormat(): TokenFormat | undefined { + return this._tokenFormat; + } + + getTransformations(): Transformations | undefined { + return this._transformations; + } +} + +export default DeidentifyTextOptions; \ No newline at end of file diff --git a/src/vault/model/options/deidentify-text/token-format/index.ts b/src/vault/model/options/deidentify-text/token-format/index.ts new file mode 100644 index 00000000..4ce1f47b --- /dev/null +++ b/src/vault/model/options/deidentify-text/token-format/index.ts @@ -0,0 +1,45 @@ +import { DetectEntities } from "../../../../../utils"; + +class TokenFormat { + // Fields + private _default?: DetectEntities; + private _vaultToken?: DetectEntities[]; + private _entityUniqueCounter?: DetectEntities[]; + private _entityOnly?: DetectEntities[]; + + // Setters + setDefault(defaultToken: DetectEntities) { + this._default = defaultToken; + } + + setVaultToken(vaultToken: DetectEntities[]) { + this._vaultToken = vaultToken; + } + + setEntityUniqueCounter(entityUniqueCounter: DetectEntities[]) { + this._entityUniqueCounter = entityUniqueCounter; + } + + setEntityOnly(entityOnly: DetectEntities[]) { + this._entityOnly = entityOnly; + } + + // Getters + getDefault(): string | undefined { + return this._default; + } + + getVaultToken(): string[] | undefined { + return this._vaultToken; + } + + getEntityUniqueCounter(): string[] | undefined { + return this._entityUniqueCounter; + } + + getEntityOnly(): string[] | undefined { + return this._entityOnly; + } +} + +export default TokenFormat; \ No newline at end of file diff --git a/src/vault/model/options/deidentify-text/transformations/index.ts b/src/vault/model/options/deidentify-text/transformations/index.ts new file mode 100644 index 00000000..85fa2612 --- /dev/null +++ b/src/vault/model/options/deidentify-text/transformations/index.ts @@ -0,0 +1,22 @@ +import { DetectEntities } from "../../../../../utils"; + +class Transformations { + // Fields + private _shiftDays?: { + max: number; + min: number; + entities: DetectEntities[]; + }; + + // Setters + setShiftDays(shiftDays: { max: number; min: number; entities: DetectEntities[] }) { + this._shiftDays = shiftDays; + } + + // Getters + getShiftDays(): { max: number; min: number; entities: DetectEntities[] } | undefined { + return this._shiftDays; + } +} + +export default Transformations; \ No newline at end of file diff --git a/src/vault/model/options/reidentify-text/index.ts b/src/vault/model/options/reidentify-text/index.ts new file mode 100644 index 00000000..3cbd69e9 --- /dev/null +++ b/src/vault/model/options/reidentify-text/index.ts @@ -0,0 +1,36 @@ +import { DetectEntities } from "../../../../utils"; + +class ReidentifyTextOptions { + // Fields + private _redactedEntities?: DetectEntities[]; + private _maskedEntities?: DetectEntities[]; + private _plainTextEntities?: DetectEntities[]; + + // Setters + setRedactedEntities(redactedEntities: DetectEntities[]) { + this._redactedEntities = redactedEntities; + } + + setMaskedEntities(maskedEntities: DetectEntities[]) { + this._maskedEntities = maskedEntities; + } + + setPlainTextEntities(plainTextEntities: DetectEntities[]) { + this._plainTextEntities = plainTextEntities; + } + + // Getters + getRedactedEntities(): DetectEntities[] | undefined { + return this._redactedEntities; + } + + getMaskedEntities(): DetectEntities[] | undefined { + return this._maskedEntities; + } + + getPlainTextEntities(): DetectEntities[] | undefined { + return this._plainTextEntities; + } +} + +export default ReidentifyTextOptions; \ No newline at end of file diff --git a/src/vault/model/request/deidentify-text/index.ts b/src/vault/model/request/deidentify-text/index.ts new file mode 100644 index 00000000..668a814c --- /dev/null +++ b/src/vault/model/request/deidentify-text/index.ts @@ -0,0 +1,21 @@ +class DeidentifyTextRequest { + // Field + private _text: string; + + // Constructor + constructor(text: string) { + this._text = text; + } + + // Getter for text + public get text(): string { + return this._text; + } + + // Setter for text + public set text(value: string) { + this._text = value; + } +} + +export default DeidentifyTextRequest; \ No newline at end of file diff --git a/src/vault/model/request/reidentify-text/index.ts b/src/vault/model/request/reidentify-text/index.ts new file mode 100644 index 00000000..d83d3809 --- /dev/null +++ b/src/vault/model/request/reidentify-text/index.ts @@ -0,0 +1,21 @@ +class ReidentifyTextRequest { + // Field + private _text: string; + + // Constructor + constructor(text: string) { + this._text = text; + } + + // Getter for text + public get text(): string { + return this._text; + } + + // Setter for text + public set text(value: string) { + this._text = value; + } +} + +export default ReidentifyTextRequest; \ No newline at end of file diff --git a/src/vault/model/response/deidentify-text/index.ts b/src/vault/model/response/deidentify-text/index.ts new file mode 100644 index 00000000..6d370720 --- /dev/null +++ b/src/vault/model/response/deidentify-text/index.ts @@ -0,0 +1,44 @@ +//imports + +class DeidentifyTextResponse { + //fields + processedText: string; + entities: Array<{ + token: string; + value: string; + textIndex: object; + processedIndex: object; + entity: string; + scores: object; + }>; + wordCount: number; + charCount: number; + + constructor({ + processedText, + entities, + wordCount, + charCount, + }: { + processedText: string; + entities: Array<{ + token: string; + value: string; + textIndex: object; + processedIndex: object; + entity: string; + scores: object; + }>; + wordCount: number; + charCount: number; + }) { + this.processedText = processedText; + this.entities = entities; + this.wordCount = wordCount; + this.charCount = charCount; + } + + //getters and setters +} + +export default DeidentifyTextResponse; \ No newline at end of file diff --git a/src/vault/model/response/reidentify-text/index.ts b/src/vault/model/response/reidentify-text/index.ts new file mode 100644 index 00000000..0aea2b99 --- /dev/null +++ b/src/vault/model/response/reidentify-text/index.ts @@ -0,0 +1,16 @@ +// imports + +class ReidentifyTextResponse { + //fields + processedText: string; + + constructor({ + processedText, + }: { + processedText: string; + }) { + this.processedText = processedText; + } +} + +export default ReidentifyTextResponse; \ No newline at end of file diff --git a/src/vault/skyflow/index.ts b/src/vault/skyflow/index.ts index 7e56b075..2eacd5bc 100644 --- a/src/vault/skyflow/index.ts +++ b/src/vault/skyflow/index.ts @@ -1,4 +1,4 @@ -import { CONNECTION_ID, CREDENTIALS, Env, getVaultURL, ISkyflowError, LOGLEVEL, LogLevel, MessageType, parameterizedString, printLog, VAULT_ID } from "../../utils"; +import { CONNECTION_ID, CONTROLLER_TYPES, CREDENTIALS, Env, getVaultURL, ISkyflowError, LOGLEVEL, LogLevel, MessageType, parameterizedString, printLog, VAULT_ID } from "../../utils"; import ConnectionConfig from "../config/connection"; import VaultConfig from "../config/vault"; import { SkyflowConfig, ClientObj } from "../types"; @@ -10,6 +10,7 @@ import SkyflowError from "../../error"; import logs from "../../utils/logs"; import { isLogLevel, validateConnectionConfig, validateSkyflowConfig, validateSkyflowCredentials, validateUpdateConnectionConfig, validateUpdateVaultConfig, validateVaultConfig } from "../../utils/validations"; import SKYFLOW_ERROR_CODE from "../../error/codes"; +import DetectController from "../controller/detect"; class Skyflow { @@ -49,16 +50,18 @@ class Skyflow { const env = config.env || Env.PROD; const vaultUrl = getVaultURL(config.clusterId, env); const client = new VaultClient(vaultUrl, config.vaultId, config?.credentials, this.commonCredentials, this.logLevel); - const controller = new VaultController(client); + const vaultController = new VaultController(client); + const detectController = new DetectController(client); printLog(parameterizedString(logs.infoLogs.VAULT_CONTROLLER_INITIALIZED, [config.vaultId]), MessageType.LOG, this.logLevel); - clients[config.vaultId] = { config, client, controller }; + // printLog for detect controller + clients[config.vaultId] = { config, client, vaultController, detectController }; } private addConnectionClient(config: ConnectionConfig, clients: ClientObj) { const client = new VaultClient(config.connectionUrl, '', config?.credentials, this.commonCredentials, this.logLevel); - const controller = new ConnectionController(client); + const connectionController = new ConnectionController(client); printLog(parameterizedString(logs.infoLogs.CONNECTION_CONTROLLER_INITIALIZED, [config.connectionId]), MessageType.LOG, this.logLevel); - clients[config.connectionId] = { config, client, controller }; + clients[config.connectionId] = { config, client, connectionController }; } addVaultConfig(config: VaultConfig) { @@ -201,20 +204,45 @@ class Skyflow { } vault(vaultId?: string) { - return this.getClient(vaultId, this.vaultClients, VAULT_ID) as VaultController; + return this.getClient(vaultId, this.vaultClients, VAULT_ID, CONTROLLER_TYPES.VAULT) as VaultController; + } + + detect(vaultId?: string) { + return this.getClient(vaultId, this.vaultClients, VAULT_ID, CONTROLLER_TYPES.DETECT) as DetectController; } connection(connectionId?: string) { - return this.getClient(connectionId, this.connectionClients, CONNECTION_ID) as ConnectionController; + return this.getClient(connectionId, this.connectionClients, CONNECTION_ID, CONTROLLER_TYPES.CONNECTION) as ConnectionController; } - private getClient(id: string | undefined, clients: ClientObj, idKey: string) { - if(Object.keys(clients).length === 0) this.throwErrorForEmptyClients(idKey) + private getClient( + id: string | undefined, + clients: ClientObj, + idKey: string, + controllerType: string + ) { + if (Object.keys(clients).length === 0) { + this.throwErrorForEmptyClients(idKey); + } + const clientId = id || Object.keys(clients)[0]; - if (clientId && clients[clientId]?.controller) { - return clients[clientId].controller; + if (clientId) { + const clientData = clients[clientId]; + + if (controllerType === CONTROLLER_TYPES.VAULT && clientData?.vaultController) { + return clientData.vaultController; + } + + if (controllerType === CONTROLLER_TYPES.DETECT && clientData?.detectController) { + return clientData.detectController; + } + + if (controllerType === CONTROLLER_TYPES.CONNECTION && clientData?.connectionController) { + return clientData.connectionController; + } + + this.throwErrorForUnknownId(clientId, idKey); } - if (clientId) this.throwErrorForUnknownId(clientId, idKey) } private updateClients(updateType: string) { diff --git a/src/vault/types/index.ts b/src/vault/types/index.ts index 55a68709..d98617be 100644 --- a/src/vault/types/index.ts +++ b/src/vault/types/index.ts @@ -5,6 +5,7 @@ import Credentials from "../config/credentials"; import VaultController from "../controller/vault"; import ConnectionController from "../controller/connections"; import VaultClient from "../client"; +import DetectController from "../controller/detect"; export interface SkyflowConfig { vaultConfigs: VaultConfig[]; @@ -15,7 +16,9 @@ export interface SkyflowConfig { export interface ClientConfig { config: VaultConfig | ConnectionConfig; - controller: VaultController | ConnectionController; + vaultController?: VaultController; + connectionController?: ConnectionController; + detectController?: DetectController; client: VaultClient; } diff --git a/test/vault/client/client.test.js b/test/vault/client/client.test.js index 7ac03949..da9c622b 100644 --- a/test/vault/client/client.test.js +++ b/test/vault/client/client.test.js @@ -5,11 +5,13 @@ import { Tokens } from '../../../src/ _generated_/rest/api/resources/tokens/clie import { AuthType, LogLevel, TYPES } from '../../../src/utils'; import { isExpired } from '../../../src/utils/jwt-utils'; import SkyflowError from '../../../src/error'; +import { Strings } from '../../../src/ _generated_/rest/api/resources/strings/client/Client'; jest.mock('../../../src/ _generated_/rest'); jest.mock('../../../src/ _generated_/rest/api/resources/records/client/Client'); jest.mock('../../../src/ _generated_/rest/api/resources/query/client/Client'); jest.mock('../../../src/ _generated_/rest/api/resources/tokens/client/Client'); +jest.mock('../../../src/ _generated_/rest/api/resources/strings/client/Client'); jest.mock('../../../src/utils/jwt-utils'); jest.mock('../../../src/error'); @@ -91,6 +93,11 @@ describe('VaultClient', () => { expect(Query).toHaveBeenCalled(); }); + test('should initialize Strings for DETECT', () => { + vaultClient.initAPI(authInfo, TYPES.DETECT); + expect(Strings).toHaveBeenCalled(); + }); + test('should not initialize API for unsupported type', () => { vaultClient.initAPI(authInfo, 'UNSUPPORTED_TYPE'); expect(Records).not.toHaveBeenCalled(); diff --git a/test/vault/controller/detect.test.js b/test/vault/controller/detect.test.js new file mode 100644 index 00000000..58b11d55 --- /dev/null +++ b/test/vault/controller/detect.test.js @@ -0,0 +1,299 @@ +import DetectController from '../../../src/vault/controller/detect'; +import { validateDeIdentifyTextRequest, validateReidentifyTextRequest } from '../../../src/utils/validations'; +import DeidentifyTextResponse from '../../../src/vault/model/response/deidentify-text'; +import ReidentifyTextResponse from '../../../src/vault/model/response/reidentify-text'; + +jest.mock('../../../src/utils', () => ({ + printLog: jest.fn(), + parameterizedString: jest.fn(), + removeSDKVersion: jest.fn(), + MessageType: { + LOG: 'LOG', + ERROR: 'ERROR', + }, + TYPES: { + DETECT: 'DETECT', + }, + generateSDKMetrics: jest.fn().mockReturnValue({ sdk: 'metrics' }), + getBearerToken: jest.fn().mockResolvedValue(Promise.resolve('your-bearer-token')), +})); + +jest.mock('../../../src/utils/validations', () => ({ + validateDeIdentifyTextRequest: jest.fn(), + validateReidentifyTextRequest: jest.fn(), +})); + +describe('DetectController', () => { + let mockVaultClient; + let detectController; + + beforeEach(() => { + mockVaultClient = { + getLogLevel: jest.fn().mockReturnValue('DEBUG'), + getCredentials: jest.fn().mockReturnValue({}), + initAPI: jest.fn(), + stringsAPI: { + deidentifyString: jest.fn(), + reidentifyString: jest.fn(), + }, + failureResponse: jest.fn().mockRejectedValue(new Error('API error')), + vaultId: 'vault123', + }; + jest.clearAllMocks(); + }); + + test('should initialize DetectController and call printLog with correct parameters', () => { + detectController = new DetectController(mockVaultClient); + expect(detectController).toBeInstanceOf(DetectController); + }); +}); + +describe('deidentifyText', () => { + + let mockVaultClient; + let detectController; + + beforeEach(() => { + mockVaultClient = { + getLogLevel: jest.fn().mockReturnValue('DEBUG'), + getCredentials: jest.fn().mockReturnValue({}), + initAPI: jest.fn(), + stringsAPI: { + deidentifyString: jest.fn(), + reidentifyString: jest.fn(), + }, + failureResponse: jest.fn().mockRejectedValue(new Error('API error')), + vaultId: 'vault123', + }; + detectController = new DetectController(mockVaultClient); + jest.clearAllMocks(); + }); + + test('should successfully deidentify text', async () => { + const mockRequest = { + text: 'Sensitive data to deidentify', + }; + const mockOptions = { + getEntities: jest.fn().mockReturnValue(['NAME', 'EMAIL']), + getAllowRegexList: jest.fn().mockReturnValue(['regex1']), + getRestrictRegexList: jest.fn().mockReturnValue(['regex2']), + getTransformations: jest.fn().mockReturnValue({ + getShiftDays: jest.fn().mockReturnValue({ + max: 10, + min: 5, + entities: ['DATE'], + }), + }), + }; + + const mockResponseData = { + processed_text: 'Processed text', + entities: [ + { + token: 'token1', + value: 'value1', + location: { + start_index: 0, + end_index: 5, + start_index_processed: 0, + end_index_processed: 5, + }, + entity_type: 'NAME', + entity_scores: [0.9], + }, + ], + word_count: 5, + character_count: 30, + }; + + mockVaultClient.stringsAPI.deidentifyString.mockImplementation(() => ({ + withRawResponse: jest.fn().mockResolvedValue({ + data: mockResponseData, + rawResponse: { headers: { get: jest.fn().mockReturnValue('request-id-123') } }, + }), + })); + + const response = await detectController.deidentifyText(mockRequest, mockOptions); + + expect(validateDeIdentifyTextRequest).toHaveBeenCalledWith(mockRequest, mockOptions, 'DEBUG'); + expect(mockVaultClient.stringsAPI.deidentifyString).toHaveBeenCalledWith( + expect.objectContaining({ + text: mockRequest.text, + vault_id: 'vault123', + entity_types: ['NAME', 'EMAIL'], + allow_regex: ['regex1'], + restrict_regex: ['regex2'], + transformations: { + shift_dates: { + max_days: 10, + min_days: 5, + entity_types: ['DATE'], + }, + }, + }) + ); + expect(response).toBeInstanceOf(DeidentifyTextResponse); + expect(response.processedText).toBe('Processed text'); + expect(response.entities).toHaveLength(1); + expect(response.wordCount).toBe(5); + expect(response.charCount).toBe(30); + }); + + test('should handle validation errors', async () => { + const mockRequest = { + text: 'Sensitive data to deidentify', + }; + const mockOptions = {}; + + validateDeIdentifyTextRequest.mockImplementation(() => { + throw new Error('Validation error'); + }); + + await expect(detectController.deidentifyText(mockRequest, mockOptions)).rejects.toThrow( + 'Validation error' + ); + expect(validateDeIdentifyTextRequest).toHaveBeenCalledWith(mockRequest, mockOptions, 'DEBUG'); + expect(mockVaultClient.stringsAPI.deidentifyString).not.toHaveBeenCalled(); + }); + + test('should handle API errors during deidentifyText', async () => { + jest.mock('../../../src/utils/validations', () => ({ + validateDeIdentifyTextRequest: jest.fn(), + validateReidentifyTextRequest: jest.fn(), + })); + validateDeIdentifyTextRequest.mockImplementation(() => { + // No validation error + }); + const mockRequest = { + text: 'Sensitive data to deidentify', + }; + const mockOptions = { + getEntities: jest.fn().mockReturnValue([]), // Return an empty array for entities + getAllowRegexList: jest.fn().mockReturnValue([]), // Return an empty array for allow regex + getRestrictRegexList: jest.fn().mockReturnValue([]), // Return an empty array for restrict regex + getTransformations: jest.fn().mockReturnValue({ + getShiftDays: jest.fn().mockReturnValue({ + max: 10, + min: 5, + entities: ['DATE'], + }), + }), + }; + + mockVaultClient.stringsAPI.deidentifyString.mockImplementation(() => ({ + withRawResponse: jest.fn().mockRejectedValue(new Error('API error')), + })); + + await expect(detectController.deidentifyText(mockRequest, mockOptions)).rejects.toThrow( + 'API error' + ); + expect(mockVaultClient.stringsAPI.deidentifyString).toHaveBeenCalled(); + }); +}); + +describe('reidentifyText', () => { + let mockVaultClient; + let detectController; + + beforeEach(() => { + mockVaultClient = { + getLogLevel: jest.fn().mockReturnValue('DEBUG'), + getCredentials: jest.fn().mockReturnValue({}), + initAPI: jest.fn(), + stringsAPI: { + deidentifyString: jest.fn(), + reidentifyString: jest.fn(), + }, + failureResponse: jest.fn().mockRejectedValue(new Error('API error')), + vaultId: 'vault123', + }; + detectController = new DetectController(mockVaultClient); + jest.clearAllMocks(); + }); + test('should successfully reidentify text', async () => { + const mockRequest = { + text: 'Redacted text to reidentify', + }; + const mockOptions = { + getRedactedEntities: jest.fn().mockReturnValue(['NAME']), + getMaskedEntities: jest.fn().mockReturnValue(['EMAIL']), + getPlainTextEntities: jest.fn().mockReturnValue(['PHONE']), + }; + + const mockResponseData = { + text: 'Reidentified text', + }; + + mockVaultClient.stringsAPI.reidentifyString.mockImplementation(() => ({ + withRawResponse: jest.fn().mockResolvedValue({ + data: mockResponseData, + rawResponse: { headers: { get: jest.fn().mockReturnValue('request-id-123') } }, + }), + })); + + const response = await detectController.reidentifyText(mockRequest, mockOptions); + + expect(validateReidentifyTextRequest).toHaveBeenCalledWith(mockRequest, mockOptions, 'DEBUG'); + expect(mockVaultClient.stringsAPI.reidentifyString).toHaveBeenCalledWith( + expect.objectContaining({ + text: mockRequest.text, + vault_id: 'vault123', + format: { + redacted: ['NAME'], + masked: ['EMAIL'], + plaintext: ['PHONE'], + }, + }) + ); + expect(response).toBeInstanceOf(ReidentifyTextResponse); + expect(response.processedText).toBe('Reidentified text'); + }); + + test('should handle validation errors', async () => { + const mockRequest = { + text: 'Redacted text to reidentify', + }; + const mockOptions = { + getRedactedEntities: jest.fn().mockReturnValue(['NAME']), + getMaskedEntities: jest.fn().mockReturnValue(['EMAIL']), + getPlainTextEntities: jest.fn().mockReturnValue(['PHONE']), + }; + + validateReidentifyTextRequest.mockImplementation(() => { + throw new Error('Validation error'); + }); + + await expect(detectController.reidentifyText(mockRequest, mockOptions)).rejects.toThrow( + 'Validation error' + ); + expect(validateReidentifyTextRequest).toHaveBeenCalledWith(mockRequest, mockOptions, 'DEBUG'); + expect(mockVaultClient.stringsAPI.reidentifyString).not.toHaveBeenCalled(); + }); + + test('should handle API errors during reidentifyText', async () => { + jest.mock('../../../src/utils/validations', () => ({ + validateDeIdentifyTextRequest: jest.fn(), + validateReidentifyTextRequest: jest.fn(), + })); + validateReidentifyTextRequest.mockImplementation(() => { + // No validation error + }); + const mockRequest = { + text: 'Redacted text to reidentify', + }; + const mockOptions = { + getRedactedEntities: jest.fn().mockReturnValue(['NAME']), + getMaskedEntities: jest.fn().mockReturnValue(['EMAIL']), + getPlainTextEntities: jest.fn().mockReturnValue(['PHONE']), + }; + + mockVaultClient.stringsAPI.reidentifyString.mockImplementation(() => ({ + withRawResponse: jest.fn().mockRejectedValue(new Error('API error')), + })); + + await expect(detectController.reidentifyText(mockRequest, mockOptions)).rejects.toThrow( + 'API error' + ); + expect(mockVaultClient.stringsAPI.reidentifyString).toHaveBeenCalled(); + }); +}); \ No newline at end of file diff --git a/test/vault/skyflow/skyflow.test.js b/test/vault/skyflow/skyflow.test.js index 76ac9a90..8addafee 100644 --- a/test/vault/skyflow/skyflow.test.js +++ b/test/vault/skyflow/skyflow.test.js @@ -86,6 +86,81 @@ describe('Skyflow initialization', () => { })).toThrowError(invalidConnectionConfigError); }); + + describe('Detect Controller Tests', () => { + const validVaultConfig = { + vaultId: "VAULT_ID", + clusterId: "CLUSTER_ID" + }; + + const noConfigFoundError = "No vault config found."; + const missingVaultConfigError = "VAULT_ID is missing from the config."; + + test('should return detect controller', () => { + const skyflow = new Skyflow({ + vaultConfigs: [validVaultConfig] + }); + expect(skyflow.detect("VAULT_ID")).toBeTruthy(); + }); + + test('should return detect controller when called without vault id', () => { + const skyflow = new Skyflow({ + vaultConfigs: [validVaultConfig] + }); + expect(skyflow.detect()).toBeTruthy(); + }); + + test('should throw error for invalid vault id in detect method', () => { + const skyflow = new Skyflow({ + vaultConfigs: [validVaultConfig], + }); + skyflow.removeVaultConfig("VAULT_ID"); + expect(() => skyflow.detect("ID")).toThrowError(noConfigFoundError); + }); + + test('should throw error when no vault configs exist for detect method', () => { + const skyflow = new Skyflow({ + vaultConfigs: [validVaultConfig], + }); + skyflow.removeVaultConfig("VAULT_ID"); + expect(() => skyflow.detect("ID")).toThrowError(noConfigFoundError); + }); + }); + + describe('Update Clients Tests', () => { + const validVaultConfig = { + vaultId: "VAULT_ID", + clusterId: "CLUSTER_ID" + }; + + const validConnectionConfig = { + connectionId: "CONN_ID", + connectionUrl: "https://connection-url.com" + }; + + test('should update log level for all clients', () => { + const skyflow = new Skyflow({ + vaultConfigs: [validVaultConfig], + connectionConfigs: [validConnectionConfig] + }); + skyflow.setLogLevel(LogLevel.OFF); + expect(skyflow.getLogLevel()).toBe(LogLevel.OFF); + }); + + test('should update credentials for all clients', () => { + const skyflow = new Skyflow({ + vaultConfigs: [validVaultConfig], + connectionConfigs: [validConnectionConfig], + skyflowCredentials: { + apiKey: "sky-KEY" + } + }); + const newCredentials = { apiKey: "sky-VALID_KEY" }; + skyflow.updateSkyflowCredentials(newCredentials); + expect(skyflow.getSkyflowCredentials()).toBe(newCredentials); + }); + }); + describe('Log Level Tests', () => { const validVaultConfig = [{ vaultId: "VAULT_ID",