Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SK-1621: node sdk v2 implementation #157

Merged
merged 1 commit into from
Oct 24, 2024
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
23 changes: 21 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Skyflow from './vault/skyflow';
import { LogLevel, Env, RedactionType } from './utils';
import { LogLevel, Env, RedactionType, METHOD } from './utils';
import InsertRequest from './vault/model/request/insert';
import InsertOptions from './vault/model/options/insert';
import GetRequest from './vault/model/request/get';
Expand All @@ -17,10 +17,20 @@ import { generateBearerToken, generateBearerTokenFromCreds, generateSignedDataTo
import { isExpired } from './utils/jwt-utils';
import UpdateOptions from './vault/model/options/update';
import InvokeConnectionRequest from './vault/model/request/inkove';
import GetColumnRequest from './vault/model/request/get-column';
import InsertResponse from './vault/model/response/insert';
import GetResponse from './vault/model/response/get';
import DetokenizeResponse from './vault/model/response/detokenize';
import DeleteResponse from './vault/model/response/delete';
import UpdateResponse from './vault/model/response/update';
import FileUploadResponse from './vault/model/response/file-upload';
import QueryResponse from './vault/model/response/query';
import InvokeConnectionResponse from './vault/model/response/invoke/invoke';

export {
Env,
LogLevel,
METHOD,
Skyflow,
generateBearerToken,
generateBearerTokenFromCreds,
Expand All @@ -31,16 +41,25 @@ export {
RedactionType,
InsertRequest,
InsertOptions,
InsertResponse,
GetRequest,
GetColumnRequest,
GetOptions,
GetResponse,
DetokenizeRequest,
DetokenizeOptions,
DetokenizeResponse,
DeleteRequest,
DeleteResponse,
UpdateRequest,
UpdateOptions,
UpdateResponse,
FileUploadRequest,
FileUploadResponse,
QueryRequest,
QueryResponse,
TokenizeRequest,
TokenizeResponse,
InvokeConnectionRequest
InvokeConnectionRequest,
InvokeConnectionResponse
};
4 changes: 2 additions & 2 deletions src/vault/controller/vault/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class VaultController {
TYPES.UPDATE
).then(data => {
const updatedRecord = {
skyflowID: data.skyflow_id,
skyflowId: data.skyflow_id,
...data?.tokens
};
resolve(new UpdateResponse({ updatedField: updatedRecord, errors: [] }));
Expand Down Expand Up @@ -403,7 +403,7 @@ class VaultController {
),
TYPES.FILE_UPLOAD
).then(data => {
resolve(new FileUploadResponse({ skyflowID: data.skyflow_id, errors: [] }));
resolve(new FileUploadResponse({ skyflowId: data.skyflow_id, errors: [] }));
})
.catch(error => {
if (error instanceof Error)
Expand Down
6 changes: 3 additions & 3 deletions src/vault/model/response/file-upload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
class FileUploadResponse {

//fields
skyflowID?: string;
skyflowId?: string;

errors?: Object;

constructor({ skyflowID, errors }: { skyflowID?: string, errors?: object }) {
this.skyflowID = skyflowID;
constructor({ skyflowId, errors }: { skyflowId?: string, errors?: object }) {
this.skyflowId = skyflowId;
this.errors = errors;
}

Expand Down
8 changes: 4 additions & 4 deletions test/vault/controller/vault.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ describe('VaultController update method', () => {
expect.any(Object) // Headers
);
expect(response).toBeInstanceOf(UpdateResponse);
expect(response.updatedField.skyflowID).toBe('id123');
expect(response.updatedField.skyflowId).toBe('id123');
expect(response.updatedField.field1).toBe('token123');
expect(response.errors).toHaveLength(0);
});
Expand All @@ -969,7 +969,7 @@ describe('VaultController update method', () => {
expect.any(Object) // Headers
);
expect(response).toBeInstanceOf(UpdateResponse);
expect(response.updatedField.skyflowID).toBe('id123');
expect(response.updatedField.skyflowId).toBe('id123');
expect(response.updatedField.field1).toBe('token123');
expect(response.errors).toHaveLength(0);
});
Expand Down Expand Up @@ -997,7 +997,7 @@ describe('VaultController update method', () => {
expect.any(Object) // Headers
);
expect(response).toBeInstanceOf(UpdateResponse);
expect(response.updatedField.skyflowID).toBe('id123');
expect(response.updatedField.skyflowId).toBe('id123');
expect(response.updatedField.field1).toBe('token123');
expect(response.errors).toHaveLength(0);
});
Expand Down Expand Up @@ -1127,7 +1127,7 @@ describe('VaultController uploadFile method', () => {
expect(mockFs.createReadStream).toHaveBeenCalledWith(mockRequest.filePath);

expect(response).toBeInstanceOf(FileUploadResponse);
expect(response.skyflowID).toBe('id123');
expect(response.skyflowId).toBe('id123');
expect(response.errors).toHaveLength(0);
});

Expand Down
Loading