diff --git a/src/ _generated_/rest/api/resources/records/client/Client.ts b/src/ _generated_/rest/api/resources/records/client/Client.ts index c0682f3f..a5f28f51 100644 --- a/src/ _generated_/rest/api/resources/records/client/Client.ts +++ b/src/ _generated_/rest/api/resources/records/client/Client.ts @@ -850,9 +850,12 @@ export class Records { requestOptions?: Records.RequestOptions, ): Promise> { const _request = await core.newFormData(); - if (file != null && request.columnName != null) { - await _request.appendFile(request.columnName, file); - + if (file != null) { + await _request.appendFile("file", file); + } + + if (request.columnName != null) { + _request.append("columnName", request.columnName); } const _maybeEncodedRequest = await _request.getRequest(); @@ -1104,6 +1107,124 @@ export class Records { } } + /** + * Uploads the specified file to a record. If an existing record isn't specified, creates a new record and uploads the file to that record. + * + * @param {File | fs.ReadStream | Blob} file + * @param {string} vaultId + * @param {Skyflow.UploadFileV2Request} request + * @param {Records.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Skyflow.BadRequestError} + * @throws {@link Skyflow.UnauthorizedError} + * @throws {@link Skyflow.NotFoundError} + * @throws {@link Skyflow.InternalServerError} + * + * @example + * await client.records.uploadFileV2(fs.createReadStream("/path/to/your/file"), "d4410ea01d83473ca09a24c6b03096d4", { + * tableName: "tableName", + * columnName: "columnName" + * }) + */ + public uploadFileV2( + file: File | fs.ReadStream | Blob, + vaultId: string, + request: Skyflow.UploadFileV2Request, + requestOptions?: Records.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__uploadFileV2(file, vaultId, request, requestOptions)); + } + + private async __uploadFileV2( + file: File | fs.ReadStream | Blob, + vaultId: string, + request: Skyflow.UploadFileV2Request, + requestOptions?: Records.RequestOptions, + ): Promise> { + const _request = await core.newFormData(); + _request.append("tableName", request.tableName); + _request.append("columnName", request.columnName); + await _request.appendFile("file", file); + if (request.skyflowID != null) { + _request.append("skyflowID", request.skyflowID); + } + + if (request.returnFileMetadata != null) { + _request.append("returnFileMetadata", request.returnFileMetadata.toString()); + } + + const _maybeEncodedRequest = await _request.getRequest(); + 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, + `v2/vaults/${encodeURIComponent(vaultId)}/files/upload`, + ), + 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, + ..._maybeEncodedRequest.headers, + ...requestOptions?.headers, + }, + requestType: "file", + duplex: _maybeEncodedRequest.duplex, + body: _maybeEncodedRequest.body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Skyflow.UploadFileV2Response, 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 POST /v2/vaults/{vaultID}/files/upload.", + ); + 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/records/client/requests/UploadFileV2Request.ts b/src/ _generated_/rest/api/resources/records/client/requests/UploadFileV2Request.ts new file mode 100644 index 00000000..d514b3cf --- /dev/null +++ b/src/ _generated_/rest/api/resources/records/client/requests/UploadFileV2Request.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * tableName: "tableName", + * columnName: "columnName" + * } + */ +export interface UploadFileV2Request { + /** Name of the table to upload the file to. */ + tableName: string; + /** Name of the column to upload the file to. The column must have a `file` data type. */ + columnName: string; + /** Skyflow ID of the record to upload the file to. If `skyflowID` isn't specified, a new record will be created. */ + skyflowID?: string; + /** If `true`, returns metadata about the uploaded file. */ + returnFileMetadata?: boolean; +} diff --git a/src/ _generated_/rest/api/resources/records/client/requests/index.ts b/src/ _generated_/rest/api/resources/records/client/requests/index.ts index 85290118..9d13c62b 100644 --- a/src/ _generated_/rest/api/resources/records/client/requests/index.ts +++ b/src/ _generated_/rest/api/resources/records/client/requests/index.ts @@ -5,3 +5,4 @@ export { type RecordServiceBulkDeleteRecordBody } from "./RecordServiceBulkDelet export { type RecordServiceGetRecordRequest } from "./RecordServiceGetRecordRequest"; export { type RecordServiceUpdateRecordBody } from "./RecordServiceUpdateRecordBody"; export { type FileServiceUploadFileRequest } from "./FileServiceUploadFileRequest"; +export { type UploadFileV2Request } from "./UploadFileV2Request"; diff --git a/src/ _generated_/rest/api/types/DeidentifyStatusResponse.ts b/src/ _generated_/rest/api/types/DeidentifyStatusResponse.ts index 8b4589a3..8a5fa2c7 100644 --- a/src/ _generated_/rest/api/types/DeidentifyStatusResponse.ts +++ b/src/ _generated_/rest/api/types/DeidentifyStatusResponse.ts @@ -13,7 +13,7 @@ export interface DeidentifyStatusResponse { /** How the input file was specified. */ output: Skyflow.DeidentifyFileOutput[]; /** How the output file is specified. */ - output_type?: Skyflow.DeidentifyStatusResponseOutputType; + output_type: Skyflow.DeidentifyStatusResponseOutputType; /** Status details about the detect run. */ message: string; /** Number of words in the processed text. */ diff --git a/src/ _generated_/rest/api/types/DeidentifyStatusResponseOutputType.ts b/src/ _generated_/rest/api/types/DeidentifyStatusResponseOutputType.ts index 5e8dfc87..b1ae3780 100644 --- a/src/ _generated_/rest/api/types/DeidentifyStatusResponseOutputType.ts +++ b/src/ _generated_/rest/api/types/DeidentifyStatusResponseOutputType.ts @@ -5,8 +5,8 @@ /** * How the output file is specified. */ -export type DeidentifyStatusResponseOutputType = "base64" | "efs_path"; +export type DeidentifyStatusResponseOutputType = "BASE64" | "UNKNOWN"; export const DeidentifyStatusResponseOutputType = { - Base64: "base64", - EfsPath: "efs_path", + Base64: "BASE64", + Unknown: "UNKNOWN", } as const; diff --git a/src/ _generated_/rest/api/types/DeidentifyStatusResponseStatus.ts b/src/ _generated_/rest/api/types/DeidentifyStatusResponseStatus.ts index 78e92829..ec5e8a7a 100644 --- a/src/ _generated_/rest/api/types/DeidentifyStatusResponseStatus.ts +++ b/src/ _generated_/rest/api/types/DeidentifyStatusResponseStatus.ts @@ -5,9 +5,10 @@ /** * Status of the detect run. */ -export type DeidentifyStatusResponseStatus = "failed" | "in_progress" | "success"; +export type DeidentifyStatusResponseStatus = "FAILED" | "IN_PROGRESS" | "SUCCESS" | "UNKNOWN"; export const DeidentifyStatusResponseStatus = { - Failed: "failed", - InProgress: "in_progress", - Success: "success", + Failed: "FAILED", + InProgress: "IN_PROGRESS", + Success: "SUCCESS", + Unknown: "UNKNOWN", } as const; diff --git a/src/ _generated_/rest/api/types/EntityType.ts b/src/ _generated_/rest/api/types/EntityType.ts index 23372a0d..8dfef853 100644 --- a/src/ _generated_/rest/api/types/EntityType.ts +++ b/src/ _generated_/rest/api/types/EntityType.ts @@ -17,8 +17,8 @@ export type EntityType = | "credit_card_expiration" | "cvv" | "date" - | "day" | "date_interval" + | "day" | "dob" | "dose" | "driver_license" @@ -60,10 +60,10 @@ export type EntityType = | "passport_number" | "password" | "phone_number" - | "project" | "physical_attribute" | "political_affiliation" | "product" + | "project" | "religion" | "routing_number" | "sexuality" @@ -88,8 +88,8 @@ export const EntityType = { CreditCardExpiration: "credit_card_expiration", Cvv: "cvv", Date: "date", - Day: "day", DateInterval: "date_interval", + Day: "day", Dob: "dob", Dose: "dose", DriverLicense: "driver_license", @@ -131,10 +131,10 @@ export const EntityType = { PassportNumber: "passport_number", Password: "password", PhoneNumber: "phone_number", - Project: "project", PhysicalAttribute: "physical_attribute", PoliticalAffiliation: "political_affiliation", Product: "product", + Project: "project", Religion: "religion", RoutingNumber: "routing_number", Sexuality: "sexuality", diff --git a/src/ _generated_/rest/api/types/ErrorString.ts b/src/ _generated_/rest/api/types/ErrorString.ts deleted file mode 100644 index 78dd85f5..00000000 --- a/src/ _generated_/rest/api/types/ErrorString.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 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/ReidentifyFileResponse.ts b/src/ _generated_/rest/api/types/ReidentifyFileResponse.ts index 1b848c8c..b3d38617 100644 --- a/src/ _generated_/rest/api/types/ReidentifyFileResponse.ts +++ b/src/ _generated_/rest/api/types/ReidentifyFileResponse.ts @@ -11,6 +11,6 @@ export interface ReidentifyFileResponse { /** Status of the re-identify operation. */ status: Skyflow.ReidentifyFileResponseStatus; /** Format of the output file. */ - output_type: "BASE64"; + output_type: Skyflow.ReidentifyFileResponseOutputType; output: Skyflow.ReidentifyFileResponseOutput; } diff --git a/src/ _generated_/rest/api/types/ReidentifyFileResponseOutputType.ts b/src/ _generated_/rest/api/types/ReidentifyFileResponseOutputType.ts new file mode 100644 index 00000000..f874b5df --- /dev/null +++ b/src/ _generated_/rest/api/types/ReidentifyFileResponseOutputType.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Format of the output file. + */ +export type ReidentifyFileResponseOutputType = "BASE64" | "UNKNOWN"; +export const ReidentifyFileResponseOutputType = { + Base64: "BASE64", + Unknown: "UNKNOWN", +} as const; diff --git a/src/ _generated_/rest/api/types/ReidentifyFileResponseStatus.ts b/src/ _generated_/rest/api/types/ReidentifyFileResponseStatus.ts index a087e447..c613c7c4 100644 --- a/src/ _generated_/rest/api/types/ReidentifyFileResponseStatus.ts +++ b/src/ _generated_/rest/api/types/ReidentifyFileResponseStatus.ts @@ -5,9 +5,10 @@ /** * Status of the re-identify operation. */ -export type ReidentifyFileResponseStatus = "failed" | "in_progress" | "success"; +export type ReidentifyFileResponseStatus = "FAILED" | "IN_PROGRESS" | "SUCCESS" | "UNKNOWN"; export const ReidentifyFileResponseStatus = { - Failed: "failed", - InProgress: "in_progress", - Success: "success", + Failed: "FAILED", + InProgress: "IN_PROGRESS", + Success: "SUCCESS", + Unknown: "UNKNOWN", } as const; diff --git a/src/ _generated_/rest/api/types/ReidentifyStringResponse.ts b/src/ _generated_/rest/api/types/ReidentifyStringResponse.ts index a1d61ad4..c4e2dead 100644 --- a/src/ _generated_/rest/api/types/ReidentifyStringResponse.ts +++ b/src/ _generated_/rest/api/types/ReidentifyStringResponse.ts @@ -7,5 +7,5 @@ */ export interface ReidentifyStringResponse { /** Re-identified text. */ - processed_text?: string; + text?: string; } diff --git a/src/ _generated_/rest/api/types/UploadFileV2Response.ts b/src/ _generated_/rest/api/types/UploadFileV2Response.ts new file mode 100644 index 00000000..3a20c7b6 --- /dev/null +++ b/src/ _generated_/rest/api/types/UploadFileV2Response.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Response schema for uploading a file, optionally creating a new record. + */ +export interface UploadFileV2Response { + /** Skyflow ID of the record the file was uploaded to. */ + skyflowID?: string; + fileMetadata?: unknown; +} diff --git a/src/ _generated_/rest/api/types/index.ts b/src/ _generated_/rest/api/types/index.ts index c69a1321..583a3b80 100644 --- a/src/ _generated_/rest/api/types/index.ts +++ b/src/ _generated_/rest/api/types/index.ts @@ -1,3 +1,4 @@ +export * from "./UploadFileV2Response"; export * from "./AuditEventAuditResourceType"; export * from "./AuditEventContext"; export * from "./AuditEventData"; @@ -44,10 +45,10 @@ export * from "./V1VaultSchemaConfig"; export * from "./CheckGuardrailsResponseValidation"; export * from "./CheckGuardrailsResponse"; export * from "./EntityType"; -export * from "./ErrorString"; export * from "./ErrorResponseError"; export * from "./ErrorResponse"; export * from "./ReidentifyFileResponseStatus"; +export * from "./ReidentifyFileResponseOutputType"; export * from "./ReidentifyFileResponseOutput"; export * from "./ReidentifyFileResponse"; export * from "./DeidentifyStatusResponseStatus"; diff --git a/src/vault/controller/detect/index.ts b/src/vault/controller/detect/index.ts index a1914201..c16dcdee 100644 --- a/src/vault/controller/detect/index.ts +++ b/src/vault/controller/detect/index.ts @@ -369,7 +369,7 @@ class DetectController { }, waitTime * 1000); } } else if (response.status?.toUpperCase() === 'SUCCESS') { - resolve(response); // Resolve with the processed file response + resolve([response, runId]); // Resolve with the processed file response and runId } else if (response.status?.toUpperCase() === 'FAILED') { reject(new SkyflowError(SKYFLOW_ERROR_CODE.INTERNAL_SERVER_ERROR, [response.message])); @@ -475,7 +475,7 @@ class DetectController { return new DeidentifyFileResponse({ fileBase64: base64String, file: file, - type: data.output?.[0]?.processedFileType ?? '', + type: data.output?.[0]?.processedFileType ?? data.outputType ?? "", extension: extension, wordCount: data.wordCharacterCount?.wordCount ?? 0, charCount: data.wordCharacterCount?.characterCount ?? 0, @@ -606,7 +606,7 @@ class DetectController { this.waitTime = options?.getWaitTime() ?? this.waitTime; var reqType : DeidenitfyFileRequestTypes = this.getReqType(fileExtension); - var promiseReq: Promise; + var promiseReq: Promise<[DeidentifyFileDetectRunResponse, string]>; switch (reqType){ case DeidenitfyFileRequestTypes.AUDIO: promiseReq = this.buildAudioRequest(fileObj, options, fileExtension) @@ -709,17 +709,17 @@ class DetectController { break; } - promiseReq.then(data => { - if(data.runId){ + promiseReq.then(([data, runId]) => { + if(runId && data.status === "IN_PROGRESS") { resolve(new DeidentifyFileResponse({ - runId: data.runId, - status: 'IN_PROGRESS', + runId: runId, + status: data.status, })); } if (options?.getOutputDirectory() && data.status === "SUCCESS") { this.processDeidentifyFileResponse(data, options.getOutputDirectory() as string, fileBaseName); } - const deidentifiedFileResponse = this.parseDeidentifyFileResponse(data, undefined, data.status); + const deidentifiedFileResponse = this.parseDeidentifyFileResponse(data, runId, data.status); resolve(deidentifiedFileResponse); }).catch(error => { reject(error) diff --git a/src/vault/controller/vault/index.ts b/src/vault/controller/vault/index.ts index 797b5de1..7a53b64d 100644 --- a/src/vault/controller/vault/index.ts +++ b/src/vault/controller/vault/index.ts @@ -1,7 +1,7 @@ //imports import * as fs from 'fs'; import InsertRequest from "../../model/request/insert"; -import { BatchRecordMethod, QueryServiceExecuteQueryBody, RecordServiceBatchOperationBody, RecordServiceBulkDeleteRecordBody, RecordServiceInsertRecordBody, RecordServiceUpdateRecordBody, V1Byot, V1DetokenizePayload, V1DetokenizeRecordRequest, V1FieldRecords, V1TokenizePayload, V1TokenizeRecordRequest } from '../../../ _generated_/rest/api'; +import { BatchRecordMethod, QueryServiceExecuteQueryBody, RecordServiceBatchOperationBody, RecordServiceBulkDeleteRecordBody, RecordServiceInsertRecordBody, RecordServiceUpdateRecordBody, UploadFileV2Request, UploadFileV2Response, V1Byot, V1DetokenizePayload, V1DetokenizeRecordRequest, V1FieldRecords, V1TokenizePayload, V1TokenizeRecordRequest } from '../../../ _generated_/rest/api'; import InsertOptions from "../../model/options/insert"; import GetRequest from "../../model/request/get"; import GetOptions from "../../model/options/get"; @@ -437,20 +437,23 @@ class VaultController { fileBlob = options?.getFileObject(); } - this.handleRequest( - (headers: Records.RequestOptions | undefined) => this.client.vaultAPI.fileServiceUploadFile( + const uploadFileV2Request: UploadFileV2Request = { + columnName:request.columnName, + tableName: request.tableName, + skyflowID: request.skyflowId, + returnFileMetadata: false, + } + + this.handleRequest( + (headers: Records.RequestOptions | undefined) => this.client.vaultAPI.uploadFileV2( fileBlob as unknown as import('buffer').Blob, this.client.vaultId, - request.tableName, - request.skyflowId, - { - columnName: request.columnName - } + uploadFileV2Request, ).withRawResponse(), TYPES.FILE_UPLOAD ).then(data => { printLog(logs.infoLogs.FILE_UPLOAD_DATA_SUCCESS, MessageType.LOG, this.client.getLogLevel()); - resolve(new FileUploadResponse({ skyflowId: data.skyflow_id, errors: null })); + resolve(new FileUploadResponse({ skyflowId: data.skyflowID ?? "", errors: null })); }) .catch(error => { reject(error); diff --git a/src/vault/types/index.ts b/src/vault/types/index.ts index 09038aa6..e68f84ef 100644 --- a/src/vault/types/index.ts +++ b/src/vault/types/index.ts @@ -198,15 +198,14 @@ export interface DeidentifyFileOutput { processedFileExtension?: string; } -export type DeidentifyStatusResponseOutputType = "BASE64" | "EFS_PATH" | "UNKNOWN"; - +export type DeidentifyStatusResponseOutputType = "BASE64" | "UNKNOWN"; export type WordCharacterCount = { wordCount?: number; characterCount?: number; } export interface DeidentifyFileDetectRunResponse { - status: "FAILED" | "IN_PROGRESS" | "SUCCESS"; + status: "FAILED" | "IN_PROGRESS" | "SUCCESS" | "UNKNOWN"; output: DeidentifyFileOutput[]; outputType: DeidentifyStatusResponseOutputType; message: string; diff --git a/test/vault/controller/vault.test.js b/test/vault/controller/vault.test.js index eb27e8ec..74f3de31 100644 --- a/test/vault/controller/vault.test.js +++ b/test/vault/controller/vault.test.js @@ -1311,7 +1311,7 @@ describe('VaultController uploadFile method', () => { mockVaultClient = { getLogLevel: jest.fn().mockReturnValue('DEBUG'), vaultAPI: { - fileServiceUploadFile: jest.fn(), + uploadFileV2: jest.fn(), }, initAPI: jest.fn(), getCredentials: jest.fn().mockReturnValue({}), @@ -1341,9 +1341,9 @@ describe('VaultController uploadFile method', () => { jest.spyOn(mockFs, 'readFileSync').mockReturnValueOnce(mockFileBuffer); jest.spyOn(mockPath, 'basename').mockReturnValueOnce(mockFileName); - const mockResponseData = { skyflow_id: 'id123' }; + const mockResponseData = { skyflowID: 'id123' }; - mockVaultClient.vaultAPI.fileServiceUploadFile.mockImplementation(() => ({ + mockVaultClient.vaultAPI.uploadFileV2.mockImplementation(() => ({ withRawResponse: jest.fn().mockResolvedValueOnce({ data: mockResponseData, rawResponse: { headers: { get: jest.fn().mockReturnValue('request-id-123') } } @@ -1352,7 +1352,7 @@ describe('VaultController uploadFile method', () => { const response = await vaultController.uploadFile(mockRequest, mockOptions); - expect(mockVaultClient.vaultAPI.fileServiceUploadFile).toHaveBeenCalled(); + expect(mockVaultClient.vaultAPI.uploadFileV2).toHaveBeenCalled(); expect(response).toBeInstanceOf(FileUploadResponse); expect(response.skyflowId).toBe('id123'); expect(response.errors).toBeNull(); @@ -1371,8 +1371,8 @@ describe('VaultController uploadFile method', () => { getFileName: jest.fn().mockReturnValue('file.json'), }; const mockBuffer = Buffer.from('base64string', 'base64'); - const mockResponseData = { skyflow_id: 'id123' }; - mockVaultClient.vaultAPI.fileServiceUploadFile.mockImplementation(() => ({ + const mockResponseData = { skyflowID: 'id123' }; + mockVaultClient.vaultAPI.uploadFileV2.mockImplementation(() => ({ withRawResponse: jest.fn().mockResolvedValueOnce({ data: mockResponseData, rawResponse: { headers: { get: jest.fn().mockReturnValue('request-id-123') } } @@ -1381,7 +1381,7 @@ describe('VaultController uploadFile method', () => { const response = await vaultController.uploadFile(mockRequest, mockOptions); - expect(mockVaultClient.vaultAPI.fileServiceUploadFile).toHaveBeenCalled(); + expect(mockVaultClient.vaultAPI.uploadFileV2).toHaveBeenCalled(); expect(response).toBeInstanceOf(FileUploadResponse); expect(response.skyflowId).toBe('id123'); expect(response.errors).toBeNull(); @@ -1400,8 +1400,8 @@ describe('VaultController uploadFile method', () => { getFileObject: jest.fn().mockReturnValue(mockFileObject), getFileName: jest.fn(), }; - const mockResponseData = { skyflow_id: 'id123' }; - mockVaultClient.vaultAPI.fileServiceUploadFile.mockImplementation(() => ({ + const mockResponseData = { skyflowID: 'id123' }; + mockVaultClient.vaultAPI.uploadFileV2.mockImplementation(() => ({ withRawResponse: jest.fn().mockResolvedValueOnce({ data: mockResponseData, rawResponse: { headers: { get: jest.fn().mockReturnValue('request-id-123') } } @@ -1410,7 +1410,7 @@ describe('VaultController uploadFile method', () => { const response = await vaultController.uploadFile(mockRequest, mockOptions); - expect(mockVaultClient.vaultAPI.fileServiceUploadFile).toHaveBeenCalled(); + expect(mockVaultClient.vaultAPI.uploadFileV2).toHaveBeenCalled(); expect(response).toBeInstanceOf(FileUploadResponse); expect(response.skyflowId).toBe('id123'); expect(response.errors).toBeNull(); @@ -1435,7 +1435,7 @@ describe('VaultController uploadFile method', () => { await expect(vaultController.uploadFile(mockRequest, mockOptions)).rejects.toThrow('Validation error'); expect(validateUploadFileRequest).toHaveBeenCalled(); - expect(mockVaultClient.vaultAPI.fileServiceUploadFile).not.toHaveBeenCalled(); + expect(mockVaultClient.vaultAPI.uploadFileV2).not.toHaveBeenCalled(); }); test('should handle API errors during file upload', async () => { @@ -1452,7 +1452,7 @@ describe('VaultController uploadFile method', () => { }; const mockFileBuffer = Buffer.from('file content'); jest.spyOn(mockFs, 'readFileSync').mockReturnValueOnce(mockFileBuffer); - mockVaultClient.vaultAPI.fileServiceUploadFile.mockImplementation(() => { + mockVaultClient.vaultAPI.uploadFileV2.mockImplementation(() => { return { withRawResponse: jest.fn().mockRejectedValue(new Error('API error')), };