Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/common-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: 1.0.0

- name: Resolve Branch Name
id: resolve-branch
if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }}
if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }}
run: |
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }})

Expand Down Expand Up @@ -86,10 +86,12 @@ jobs:
npm publish
fi
elif [[ "${{ inputs.tag }}" == "internal" ]]; then
curl -u ${{ secrets.JFROG_USERNAME }}:${{ secrets.JFROG_PASSWORD }} https://prekarilabs.jfrog.io/prekarilabs/api/npm/auth/ > ~/.npmrc
JFROG_AUTH=$(echo -n "$JFROG_USERNAME:$JFROG_PASSWORD" | base64 -w 0)
npm config set registry https://prekarilabs.jfrog.io/prekarilabs/api/npm/npm/
npm config fix
npm config set //prekarilabs.jfrog.io/prekarilabs/api/npm/npm/:_auth "$JFROG_AUTH"
npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
JFROG_USERNAME: ${{ secrets.JFROG_USERNAME }}
JFROG_PASSWORD: ${{ secrets.JFROG_PASSWORD }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "skyflow-node",
"version": "2.0.2-dev.2a81ccd",
"version": "1.14.3-dev.2f42cd8",
"description": "Skyflow SDK for Node.js",
"main": "./lib/index.js",
"module": "./lib/index.js",
Expand Down
19 changes: 12 additions & 7 deletions src/vault/controller/detect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class DetectController {
if (response.status?.toUpperCase() === 'IN_PROGRESS'
) {
if (currentWaitTime >= maxWaitTime) {
resolve({ runId }); // Resolve with runId if max wait time is exceeded
resolve({ data: { status: 'IN_PROGRESS' }, runId });
} else {
const nextWaitTime = currentWaitTime * 2;
let waitTime = 0;
Expand All @@ -368,7 +368,7 @@ class DetectController {
}, waitTime * 1000);
}
} else if (response.status?.toUpperCase() === 'SUCCESS') {
resolve([response, runId]); // Resolve with the processed file response and runId
resolve({ data: response, runId });
}
else if (response.status?.toUpperCase() === 'FAILED') {
reject(new SkyflowError(SKYFLOW_ERROR_CODE.INTERNAL_SERVER_ERROR, [response.message]));
Expand Down Expand Up @@ -605,7 +605,10 @@ class DetectController {
this.waitTime = options?.getWaitTime() ?? this.waitTime;

var reqType : DeidenitfyFileRequestTypes = this.getReqType(fileExtension);
var promiseReq: Promise<[DeidentifyFileDetectRunResponse, string]>;
type PollResult =
| { data: DeidentifyFileDetectRunResponse; runId: string }
| { data: { status: string }; runId: string };
var promiseReq: Promise<PollResult>;
switch (reqType){
case DeidenitfyFileRequestTypes.AUDIO:
promiseReq = this.buildAudioRequest(fileObj, options, fileExtension)
Expand Down Expand Up @@ -708,17 +711,19 @@ class DetectController {
break;
}

promiseReq.then(([data, runId]) => {
promiseReq.then(({ data, runId }) => {
if(runId && data.status === "IN_PROGRESS") {
resolve(new DeidentifyFileResponse({
runId: runId,
status: data.status,
}));
return;
}
if (options?.getOutputDirectory() && data.status === "SUCCESS") {
this.processDeidentifyFileResponse(data, options.getOutputDirectory() as string, fileBaseName);
const fullResponse = data as DeidentifyFileDetectRunResponse;
if (options?.getOutputDirectory() && fullResponse.status === "SUCCESS") {
this.processDeidentifyFileResponse(fullResponse, options.getOutputDirectory() as string, fileBaseName);
}
const deidentifiedFileResponse = this.parseDeidentifyFileResponse(data, runId, data.status);
const deidentifiedFileResponse = this.parseDeidentifyFileResponse(fullResponse, runId, fullResponse.status);
resolve(deidentifiedFileResponse);
}).catch(error => {
reject(error)
Expand Down
50 changes: 50 additions & 0 deletions test/vault/controller/detect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1059,4 +1059,54 @@ describe('deidentifyFile', () => {
expect.any(Buffer)
);
});

test('should return runId and IN_PROGRESS status when waitTime is exceeded before processing completes', async () => {
const file = new File(['dummy content'], 'test.pdf', { type: 'application/pdf' });
const request = new DeidentifyFileRequest({ file });
const options = new DeidentifyFileOptions();
options.setWaitTime(1); // very small waitTime — will expire immediately

mockVaultClient.filesAPI.deidentifyPdf.mockImplementation(() => ({
withRawResponse: jest.fn().mockResolvedValue({
data: { run_id: 'run123' },
rawResponse: { headers: { get: jest.fn().mockReturnValue('req-id') } },
}),
}));

// Always IN_PROGRESS — never finishes within waitTime
mockVaultClient.filesAPI.getRun.mockResolvedValue({ status: 'IN_PROGRESS' });

const promise = detectController.deidentifyFile(request, options);
await jest.runAllTimersAsync();
const result = await promise;

expect(result.runId).toBe('run123');
expect(result.status).toBe('IN_PROGRESS');
});

test('should not call parseDeidentifyFileResponse when waitTime is exceeded (IN_PROGRESS early return)', async () => {
const file = new File(['dummy content'], 'test.pdf', { type: 'application/pdf' });
const request = new DeidentifyFileRequest({ file });
const options = new DeidentifyFileOptions();
options.setWaitTime(1);

mockVaultClient.filesAPI.deidentifyPdf.mockImplementation(() => ({
withRawResponse: jest.fn().mockResolvedValue({
data: { run_id: 'run456' },
rawResponse: { headers: { get: jest.fn().mockReturnValue('req-id') } },
}),
}));

mockVaultClient.filesAPI.getRun.mockResolvedValue({ status: 'IN_PROGRESS' });

const promise = detectController.deidentifyFile(request, options);
await jest.runAllTimersAsync();
const result = await promise;

// Only runId and status should be set — no file data
expect(result.runId).toBe('run456');
expect(result.status).toBe('IN_PROGRESS');
expect(result.fileBase64).toBeUndefined();
expect(result.extension).toBeUndefined();
});
});
Loading