Skip to content

Commit 865619c

Browse files
SK-2209 fix inconsistencies in Node SDK V2 (#244)
* SK-2209: update fern code with updated upload api and detect changes * SK-2209: updated fileMetaData to false & fixed runId in deidentify file * SK-2209: fix tableName to table in data apis * SK-2209: add vault token validation and remove transformation which file does not support * SK-2209: update registry url
1 parent 0c55cad commit 865619c

File tree

14 files changed

+410
-112
lines changed

14 files changed

+410
-112
lines changed

.github/workflows/common-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/setup-node@v1
2020
with:
2121
node-version: '20.x'
22-
registry-url: "https://registry.npmjs.org"
22+
registry-url: "https://prekarilabs.jfrog.io/prekarilabs/api/npm/npm/"
2323

2424
- name: Install Packages
2525
run: npm install

src/error/codes/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ const SKYFLOW_ERROR_CODE = {
196196
INVALID_ALLOW_REGEX_LIST: { http_code: 400, message: errorMessages.INVALID_ALLOW_REGEX_LIST },
197197
INVALID_RESTRICT_REGEX_LIST: { http_code: 400, message: errorMessages.INVALID_RESTRICT_REGEX_LIST },
198198
INVALID_TOKEN_FORMAT: { http_code: 400, message: errorMessages.INVALID_TOKEN_FORMAT },
199+
TOKEN_FORMAT_NOT_ALLOWED: { http_code: 400, message: errorMessages.VAULT_TOKEN_FORMAT_NOT_ALLOWED_FOR_DEIDENTIFY_FILES},
199200
INVALID_TRANSFORMATIONS: { http_code: 400, message: errorMessages.INVALID_TRANSFORMATIONS },
200201

201202
INVALID_TEXT_IN_REIDENTIFY: { http_code: 400, message: errorMessages.INVALID_TEXT_IN_REIDENTIFY },

src/error/messages/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ const errorMessages = {
203203
INVALID_RESTRICT_REGEX_LIST: `${errorPrefix} Validation error. The restrictRegexList field must be an array of strings. Specify a valid restrictRegexList.`,
204204
INVALID_TOKEN_FORMAT: `${errorPrefix} Validation error. The tokenFormat key must be an instance of TokenFormat. Specify a valid token format.`,
205205
INVALID_TRANSFORMATIONS: `${errorPrefix} Validation error. The transformations key must be an instance of Transformations. Specify a valid transformations.`,
206+
VAULT_TOKEN_FORMAT_NOT_ALLOWED_FOR_DEIDENTIFY_FILES: `${errorPrefix} Validation error. Vault token format is not allowed for deidentify file request.`,
206207

207208
INVALID_TEXT_IN_REIDENTIFY: `${errorPrefix} Validation error. The text field is required and must be a non-empty string. Specify a valid text.`,
208209
INVALID_REDACTED_ENTITIES_IN_REIDENTIFY: `${errorPrefix} Validation error. The redactedEntities field must be an array of DetectEntities enums. Specify a valid redactedEntities.`,

src/utils/validations/index.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,12 @@ export const validateTokensForInsertRequest = (
539539

540540
export const validateInsertRequest = (insertRequest: InsertRequest, insertOptions?: InsertOptions, logLevel: LogLevel = LogLevel.ERROR) => { //
541541
if (insertRequest) {
542-
if (!insertRequest?.tableName || !Object.prototype.hasOwnProperty.call(insertRequest, '_tableName')) {
542+
if (!insertRequest?.table || !Object.prototype.hasOwnProperty.call(insertRequest, '_table')) {
543543
printLog(logs.errorLogs.EMPTY_TABLE_IN_INSERT, MessageType.ERROR, logLevel);
544544
throw new SkyflowError(SKYFLOW_ERROR_CODE.EMPTY_TABLE_NAME);
545545
}
546546

547-
if (typeof insertRequest.tableName !== 'string' || insertRequest.tableName.trim().length === 0) {
547+
if (typeof insertRequest.table !== 'string' || insertRequest.table.trim().length === 0) {
548548
printLog(logs.errorLogs.INVALID_TABLE_IN_INSERT, MessageType.ERROR, logLevel);
549549
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TABLE_NAME);
550550
}
@@ -600,12 +600,12 @@ export const validateUpdateOptions = (updateOptions?: UpdateOptions) => {
600600

601601
export const validateUpdateRequest = (updateRequest: UpdateRequest, updateOptions?: UpdateOptions, logLevel: LogLevel = LogLevel.ERROR) => {
602602
if (updateRequest) {
603-
if (!updateRequest?.tableName || !Object.prototype.hasOwnProperty.call(updateRequest, '_tableName')) {
603+
if (!updateRequest?.table || !Object.prototype.hasOwnProperty.call(updateRequest, '_table')) {
604604
printLog(logs.errorLogs.EMPTY_TABLE_IN_UPDATE, MessageType.ERROR, logLevel);
605605
throw new SkyflowError(SKYFLOW_ERROR_CODE.EMPTY_TABLE_NAME);
606606
}
607607

608-
if (typeof updateRequest.tableName !== 'string' || updateRequest.tableName.trim().length === 0) {
608+
if (typeof updateRequest.table !== 'string' || updateRequest.table.trim().length === 0) {
609609
printLog(logs.errorLogs.INVALID_TABLE_IN_UPDATE, MessageType.ERROR, logLevel);
610610
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TABLE_NAME);
611611
}
@@ -698,12 +698,12 @@ export const validateGetOptions = (getOptions?: GetOptions) => {
698698

699699
export const validateGetRequest = (getRequest: GetRequest, getOptions?: GetOptions, logLevel: LogLevel = LogLevel.ERROR) => {
700700
if (getRequest) {
701-
if (!getRequest?.tableName || !Object.prototype.hasOwnProperty.call(getRequest, '_tableName')) {
701+
if (!getRequest?.table || !Object.prototype.hasOwnProperty.call(getRequest, '_table')) {
702702
printLog(logs.errorLogs.EMPTY_TABLE_IN_GET, MessageType.ERROR, logLevel);
703703
throw new SkyflowError(SKYFLOW_ERROR_CODE.EMPTY_TABLE_NAME);
704704
}
705705

706-
if (typeof getRequest.tableName !== 'string' || getRequest.tableName.trim().length === 0) {
706+
if (typeof getRequest.table !== 'string' || getRequest.table.trim().length === 0) {
707707
printLog(logs.errorLogs.INVALID_TABLE_IN_GET, MessageType.ERROR, logLevel);
708708
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TABLE_NAME);
709709
}
@@ -738,12 +738,12 @@ export const validateGetRequest = (getRequest: GetRequest, getOptions?: GetOptio
738738

739739
export const validateGetColumnRequest = (getRequest: GetColumnRequest, getOptions?: GetOptions, logLevel: LogLevel = LogLevel.ERROR) => {
740740
if (getRequest) {
741-
if (!getRequest?.tableName || !Object.prototype.hasOwnProperty.call(getRequest, '_tableName')) {
741+
if (!getRequest?.table || !Object.prototype.hasOwnProperty.call(getRequest, '_table')) {
742742
printLog(logs.errorLogs.EMPTY_TABLE_IN_GET_COLUMN, MessageType.ERROR, logLevel);
743743
throw new SkyflowError(SKYFLOW_ERROR_CODE.EMPTY_TABLE_NAME);
744744
}
745745

746-
if (typeof getRequest.tableName !== 'string' || getRequest.tableName.trim().length === 0) {
746+
if (typeof getRequest.table !== 'string' || getRequest.table.trim().length === 0) {
747747
printLog(logs.errorLogs.INVALID_TABLE_IN_GET_COLUMN, MessageType.ERROR, logLevel);
748748
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TABLE_NAME);
749749
}
@@ -883,12 +883,12 @@ export const validateTokenizeRequest = (tokenizeRequest: TokenizeRequest, logLev
883883

884884
export const validateDeleteRequest = (deleteRequest: DeleteRequest, logLevel: LogLevel = LogLevel.ERROR) => {
885885
if (deleteRequest) {
886-
if (!deleteRequest?.tableName || !Object.prototype.hasOwnProperty.call(deleteRequest, '_tableName')) {
886+
if (!deleteRequest?.table || !Object.prototype.hasOwnProperty.call(deleteRequest, '_table')) {
887887
printLog(logs.errorLogs.EMPTY_TABLE_IN_DELETE, MessageType.ERROR, logLevel);
888888
throw new SkyflowError(SKYFLOW_ERROR_CODE.EMPTY_TABLE_NAME);
889889
}
890890

891-
if (typeof deleteRequest?.tableName !== 'string' || deleteRequest?.tableName.trim().length === 0) {
891+
if (typeof deleteRequest?.table !== 'string' || deleteRequest?.table.trim().length === 0) {
892892
printLog(logs.errorLogs.INVALID_TABLE_IN_DELETE, MessageType.ERROR, logLevel);
893893
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TABLE_NAME);
894894
}
@@ -926,12 +926,12 @@ export const validateUploadFileRequest = (fileRequest: FileUploadRequest, option
926926
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_FILE_UPLOAD_REQUEST);
927927
}
928928

929-
if (!fileRequest?.tableName || !Object.prototype.hasOwnProperty.call(fileRequest, '_tableName')) {
929+
if (!fileRequest?.table || !Object.prototype.hasOwnProperty.call(fileRequest, '_table')) {
930930
printLog(logs.errorLogs.EMPTY_TABLE_IN_FILE_UPLOAD, MessageType.ERROR, logLevel);
931931
throw new SkyflowError(SKYFLOW_ERROR_CODE.MISSING_TABLE_IN_UPLOAD_FILE);
932932
}
933933

934-
if (typeof fileRequest?.tableName !== 'string' || fileRequest?.tableName.trim().length === 0) {
934+
if (typeof fileRequest?.table !== 'string' || fileRequest?.table.trim().length === 0) {
935935
printLog(logs.errorLogs.INVALID_TABLE_IN_FILE_UPLOAD, MessageType.ERROR, logLevel);
936936
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TABLE_IN_UPLOAD_FILE);
937937
}
@@ -1152,6 +1152,11 @@ export const validateDeidentifyFileOptions = (deidentifyFileOptions: DeidentifyF
11521152
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TOKEN_FORMAT);
11531153
}
11541154

1155+
const tokenFormat = deidentifyFileOptions.getTokenFormat();
1156+
if(tokenFormat != null && tokenFormat.getVaultToken() != null && tokenFormat.getVaultToken()!.length > 0) {
1157+
throw new SkyflowError(SKYFLOW_ERROR_CODE.TOKEN_FORMAT_NOT_ALLOWED);
1158+
}
1159+
11551160
// Validate transformations
11561161
if (deidentifyFileOptions.getTransformations() && !(deidentifyFileOptions.getTransformations() instanceof Transformations)) {
11571162
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TRANSFORMATIONS);

src/vault/controller/detect/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ class DetectController {
202202
} as TokenTypeWithoutVault,
203203
allow_regex: options?.getAllowRegexList(),
204204
restrict_regex: options?.getRestrictRegexList(),
205-
transformations: this.getTransformations(options) as GeneratedTransformations,
206205
};
207206
return spreadsheetRequest;
208207
}

src/vault/controller/vault/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class VaultController {
184184
private buildBatchInsertBody(request: InsertRequest, options?: InsertOptions): RecordServiceBatchOperationBody {
185185
const records = request.data.map((record, index) => ({
186186
fields: record as Record<string, unknown> || {},
187-
tableName: request.tableName,
187+
tableName: request.table,
188188
tokenization: options?.getReturnTokens() || false,
189189
method: BatchRecordMethod.Post,
190190
tokens: this.getTokens(index, options?.getTokens()) as Record<string, unknown>,
@@ -235,7 +235,7 @@ class VaultController {
235235

236236

237237
const operationType = isContinueOnError ? TYPES.INSERT_BATCH : TYPES.INSERT;
238-
const tableName = request.tableName;
238+
const tableName = request.table;
239239
this.handleRequest<RecordsResponse>(
240240
(headers: Records.RequestOptions | undefined) =>
241241
isContinueOnError
@@ -281,7 +281,7 @@ class VaultController {
281281
this.handleRequest<TokensResponse>(
282282
(headers: Records.RequestOptions | undefined) => this.client.vaultAPI.recordServiceUpdateRecord(
283283
this.client.vaultId,
284-
request.tableName,
284+
request.table,
285285
skyflowId as string,
286286
updateData,
287287
headers
@@ -321,7 +321,7 @@ class VaultController {
321321
this.handleRequest<DeleteResponse>(
322322
(headers: Records.RequestOptions | undefined) => this.client.vaultAPI.recordServiceBulkDeleteRecord(
323323
this.client.vaultId,
324-
request.tableName,
324+
request.table,
325325
deleteRequest,
326326
headers
327327
).withRawResponse(),
@@ -382,7 +382,7 @@ class VaultController {
382382
this.handleRequest<RecordsResponse>(
383383
(headers: Records.RequestOptions | undefined) => this.client.vaultAPI.recordServiceBulkGetRecord(
384384
this.client.vaultId,
385-
request.tableName,
385+
request.table,
386386
payload,
387387
headers
388388
).withRawResponse(),
@@ -439,7 +439,7 @@ class VaultController {
439439

440440
const uploadFileV2Request: UploadFileV2Request = {
441441
columnName:request.columnName,
442-
tableName: request.tableName,
442+
tableName: request.table,
443443
skyflowID: request.skyflowId,
444444
returnFileMetadata: false,
445445
}

src/vault/model/request/delete/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
class DeleteRequest {
44
//fields
5-
private _tableName: string;
5+
private _table: string;
66
private _ids: Array<string>;
77

88
// Constructor
9-
constructor(tableName: string, deleteIds: Array<string>) {
10-
this._tableName = tableName;
9+
constructor(table: string, deleteIds: Array<string>) {
10+
this._table = table;
1111
this._ids = deleteIds;
1212
}
1313

14-
// Getter for tableName
15-
public get tableName(): string {
16-
return this._tableName;
14+
// Getter for table
15+
public get table(): string {
16+
return this._table;
1717
}
1818

19-
// Setter for tableName
20-
public set tableName(value: string) {
21-
this._tableName = value;
19+
// Setter for table
20+
public set table(value: string) {
21+
this._table = value;
2222
}
2323

2424
// Getter for deleteData

src/vault/model/request/file-upload/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
// Imports
22

33
class FileUploadRequest {
4-
private _tableName: string;
4+
private _table: string;
55
private _skyflowId: string;
66
private _columnName: string;
77

88
// Constructor
9-
constructor(tableName: string, skyflowId: string, columnName: string) {
10-
this._tableName = tableName;
9+
constructor(table: string, skyflowId: string, columnName: string) {
10+
this._table = table;
1111
this._skyflowId = skyflowId;
1212
this._columnName = columnName;
1313
}
1414

1515
// Getters and Setters
16-
public get tableName(): string {
17-
return this._tableName;
16+
public get table(): string {
17+
return this._table;
1818
}
19-
public set tableName(value: string) {
20-
this._tableName = value;
19+
public set table(value: string) {
20+
this._table = value;
2121
}
2222

2323
public get skyflowId(): string {

src/vault/model/request/get-column/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
class GetColumnRequest {
44

55
//fields
6-
private _tableName: string;
6+
private _table: string;
77
private _columnName: string;
88
private _columnValues: Array<string>;
99

1010
// Constructor
11-
constructor(tableName: string, _columnName: string, _columnValues: Array<string>) {
12-
this._tableName = tableName;
11+
constructor(table: string, _columnName: string, _columnValues: Array<string>) {
12+
this._table = table;
1313
this._columnName = _columnName;
1414
this._columnValues = _columnValues;
1515
}
1616

17-
// Getter for tableName
18-
public get tableName(): string {
19-
return this._tableName;
17+
// Getter for table
18+
public get table(): string {
19+
return this._table;
2020
}
2121

22-
// Setter for tableName
23-
public set tableName(value: string) {
24-
this._tableName = value;
22+
// Setter for table
23+
public set table(value: string) {
24+
this._table = value;
2525
}
2626

2727
// Getter for columnName

src/vault/model/request/get/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ import { RedactionType } from "../../../../utils";
55
class GetRequest {
66

77
//fields
8-
private _tableName: string;
8+
private _table: string;
99
private _ids: Array<string>;
1010

1111
// Constructor
12-
constructor(tableName: string, _ids: Array<string>) {
13-
this._tableName = tableName;
12+
constructor(table: string, _ids: Array<string>) {
13+
this._table = table;
1414
this._ids = _ids;
1515
}
1616

17-
// Getter for tableName
18-
public get tableName(): string {
19-
return this._tableName;
17+
// Getter for table
18+
public get table(): string {
19+
return this._table;
2020
}
2121

22-
// Setter for tableName
23-
public set tableName(value: string) {
24-
this._tableName = value;
22+
// Setter for table
23+
public set table(value: string) {
24+
this._table = value;
2525
}
2626

2727
// Getter for ids

0 commit comments

Comments
 (0)