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
2 changes: 1 addition & 1 deletion .github/workflows/common-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: '20.x'
registry-url: "https://registry.npmjs.org"
registry-url: "https://prekarilabs.jfrog.io/prekarilabs/api/npm/npm/"

- name: Install Packages
run: npm install
Expand Down
1 change: 1 addition & 0 deletions src/error/codes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ const SKYFLOW_ERROR_CODE = {
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 },
TOKEN_FORMAT_NOT_ALLOWED: { http_code: 400, message: errorMessages.VAULT_TOKEN_FORMAT_NOT_ALLOWED_FOR_DEIDENTIFY_FILES},
INVALID_TRANSFORMATIONS: { http_code: 400, message: errorMessages.INVALID_TRANSFORMATIONS },

INVALID_TEXT_IN_REIDENTIFY: { http_code: 400, message: errorMessages.INVALID_TEXT_IN_REIDENTIFY },
Expand Down
1 change: 1 addition & 0 deletions src/error/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ const errorMessages = {
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.`,
VAULT_TOKEN_FORMAT_NOT_ALLOWED_FOR_DEIDENTIFY_FILES: `${errorPrefix} Validation error. Vault token format is not allowed for deidentify file request.`,

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.`,
Expand Down
29 changes: 17 additions & 12 deletions src/utils/validations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,12 @@ export const validateTokensForInsertRequest = (

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

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

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

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

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

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

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

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

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

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

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

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

const tokenFormat = deidentifyFileOptions.getTokenFormat();
if(tokenFormat != null && tokenFormat.getVaultToken() != null && tokenFormat.getVaultToken()!.length > 0) {
throw new SkyflowError(SKYFLOW_ERROR_CODE.TOKEN_FORMAT_NOT_ALLOWED);
}

// Validate transformations
if (deidentifyFileOptions.getTransformations() && !(deidentifyFileOptions.getTransformations() instanceof Transformations)) {
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_TRANSFORMATIONS);
Expand Down
1 change: 0 additions & 1 deletion src/vault/controller/detect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ class DetectController {
} as TokenTypeWithoutVault,
allow_regex: options?.getAllowRegexList(),
restrict_regex: options?.getRestrictRegexList(),
transformations: this.getTransformations(options) as GeneratedTransformations,
};
return spreadsheetRequest;
}
Expand Down
12 changes: 6 additions & 6 deletions src/vault/controller/vault/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class VaultController {
private buildBatchInsertBody(request: InsertRequest, options?: InsertOptions): RecordServiceBatchOperationBody {
const records = request.data.map((record, index) => ({
fields: record as Record<string, unknown> || {},
tableName: request.tableName,
tableName: request.table,
tokenization: options?.getReturnTokens() || false,
method: BatchRecordMethod.Post,
tokens: this.getTokens(index, options?.getTokens()) as Record<string, unknown>,
Expand Down Expand Up @@ -235,7 +235,7 @@ class VaultController {


const operationType = isContinueOnError ? TYPES.INSERT_BATCH : TYPES.INSERT;
const tableName = request.tableName;
const tableName = request.table;
this.handleRequest<RecordsResponse>(
(headers: Records.RequestOptions | undefined) =>
isContinueOnError
Expand Down Expand Up @@ -281,7 +281,7 @@ class VaultController {
this.handleRequest<TokensResponse>(
(headers: Records.RequestOptions | undefined) => this.client.vaultAPI.recordServiceUpdateRecord(
this.client.vaultId,
request.tableName,
request.table,
skyflowId as string,
updateData,
headers
Expand Down Expand Up @@ -321,7 +321,7 @@ class VaultController {
this.handleRequest<DeleteResponse>(
(headers: Records.RequestOptions | undefined) => this.client.vaultAPI.recordServiceBulkDeleteRecord(
this.client.vaultId,
request.tableName,
request.table,
deleteRequest,
headers
).withRawResponse(),
Expand Down Expand Up @@ -382,7 +382,7 @@ class VaultController {
this.handleRequest<RecordsResponse>(
(headers: Records.RequestOptions | undefined) => this.client.vaultAPI.recordServiceBulkGetRecord(
this.client.vaultId,
request.tableName,
request.table,
payload,
headers
).withRawResponse(),
Expand Down Expand Up @@ -439,7 +439,7 @@ class VaultController {

const uploadFileV2Request: UploadFileV2Request = {
columnName:request.columnName,
tableName: request.tableName,
tableName: request.table,
skyflowID: request.skyflowId,
returnFileMetadata: false,
}
Expand Down
18 changes: 9 additions & 9 deletions src/vault/model/request/delete/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

class DeleteRequest {
//fields
private _tableName: string;
private _table: string;
private _ids: Array<string>;

// Constructor
constructor(tableName: string, deleteIds: Array<string>) {
this._tableName = tableName;
constructor(table: string, deleteIds: Array<string>) {
this._table = table;
this._ids = deleteIds;
}

// Getter for tableName
public get tableName(): string {
return this._tableName;
// Getter for table
public get table(): string {
return this._table;
}

// Setter for tableName
public set tableName(value: string) {
this._tableName = value;
// Setter for table
public set table(value: string) {
this._table = value;
}

// Getter for deleteData
Expand Down
14 changes: 7 additions & 7 deletions src/vault/model/request/file-upload/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// Imports

class FileUploadRequest {
private _tableName: string;
private _table: string;
private _skyflowId: string;
private _columnName: string;

// Constructor
constructor(tableName: string, skyflowId: string, columnName: string) {
this._tableName = tableName;
constructor(table: string, skyflowId: string, columnName: string) {
this._table = table;
this._skyflowId = skyflowId;
this._columnName = columnName;
}

// Getters and Setters
public get tableName(): string {
return this._tableName;
public get table(): string {
return this._table;
}
public set tableName(value: string) {
this._tableName = value;
public set table(value: string) {
this._table = value;
}

public get skyflowId(): string {
Expand Down
18 changes: 9 additions & 9 deletions src/vault/model/request/get-column/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
class GetColumnRequest {

//fields
private _tableName: string;
private _table: string;
private _columnName: string;
private _columnValues: Array<string>;

// Constructor
constructor(tableName: string, _columnName: string, _columnValues: Array<string>) {
this._tableName = tableName;
constructor(table: string, _columnName: string, _columnValues: Array<string>) {
this._table = table;
this._columnName = _columnName;
this._columnValues = _columnValues;
}

// Getter for tableName
public get tableName(): string {
return this._tableName;
// Getter for table
public get table(): string {
return this._table;
}

// Setter for tableName
public set tableName(value: string) {
this._tableName = value;
// Setter for table
public set table(value: string) {
this._table = value;
}

// Getter for columnName
Expand Down
18 changes: 9 additions & 9 deletions src/vault/model/request/get/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import { RedactionType } from "../../../../utils";
class GetRequest {

//fields
private _tableName: string;
private _table: string;
private _ids: Array<string>;

// Constructor
constructor(tableName: string, _ids: Array<string>) {
this._tableName = tableName;
constructor(table: string, _ids: Array<string>) {
this._table = table;
this._ids = _ids;
}

// Getter for tableName
public get tableName(): string {
return this._tableName;
// Getter for table
public get table(): string {
return this._table;
}

// Setter for tableName
public set tableName(value: string) {
this._tableName = value;
// Setter for table
public set table(value: string) {
this._table = value;
}

// Getter for ids
Expand Down
18 changes: 9 additions & 9 deletions src/vault/model/request/insert/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
class InsertRequest {

//fields
private _tableName: string;
private _table: string;
private _data: Record<string, unknown>[];

// Constructor
constructor(tableName: string, data: Record<string, unknown>[]) {
this._tableName = tableName;
constructor(table: string, data: Record<string, unknown>[]) {
this._table = table;
this._data = data;
}

// Getter for tableName
public get tableName(): string {
return this._tableName;
// Getter for table
public get table(): string {
return this._table;
}

// Setter for tableName
public set tableName(value: string) {
this._tableName = value;
// Setter for table
public set table(value: string) {
this._table = value;
}

// Getter for _data
Expand Down
18 changes: 9 additions & 9 deletions src/vault/model/request/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
class UpdateRequest {

//fields
private _tableName: string;
private _table: string;
private _data: Record<string, unknown>;

// Constructor
constructor(tableName: string, data: Record<string, unknown>) {
this._tableName = tableName;
constructor(table: string, data: Record<string, unknown>) {
this._table = table;
this._data = data;
}

// Getter for tableName
public get tableName(): string {
return this._tableName;
// Getter for table
public get table(): string {
return this._table;
}

// Setter for tableName
public set tableName(value: string) {
this._tableName = value;
// Setter for table
public set table(value: string) {
this._table = value;
}

// Getter for updateData
Expand Down
Loading