Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@casual-simulation/aux-records

Package Overview
Dependencies
Maintainers
2
Versions
196
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@casual-simulation/aux-records - npm Package Compare versions

Comparing version 2.0.28 to 2.0.31

14

DataRecordsController.d.ts
import { NotLoggedInError, ServerError } from './Errors';
import { DataRecordsStore, GetDataStoreResult, SetDataResult } from './DataRecordsStore';
import { DataRecordsStore, EraseDataStoreResult, GetDataStoreResult, SetDataResult } from './DataRecordsStore';
import { RecordsController, ValidatePublicRecordKeyFailure } from './RecordsController';

@@ -27,2 +27,3 @@ /**

getData(recordName: string, address: string): Promise<GetDataResult>;
eraseData(recordKey: string, address: string): Promise<EraseDataResult>;
}

@@ -68,2 +69,13 @@ export declare type RecordDataResult = RecordDataSuccess | RecordDataFailure;

}
export declare type EraseDataResult = EraseDataSuccess | EraseDataFailure;
export interface EraseDataSuccess {
success: true;
recordName: string;
address: string;
}
export interface EraseDataFailure {
success: false;
errorCode: ServerError | EraseDataStoreResult['errorCode'] | ValidatePublicRecordKeyFailure['errorCode'];
errorMessage: string;
}
//# sourceMappingURL=DataRecordsController.d.ts.map

@@ -86,3 +86,38 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
eraseData(recordKey, address) {
return __awaiter(this, void 0, void 0, function* () {
try {
const result = yield this._manager.validatePublicRecordKey(recordKey);
if (result.success === false) {
return {
success: false,
errorCode: result.errorCode,
errorMessage: result.errorMessage,
};
}
const recordName = result.recordName;
const result2 = yield this._store.eraseData(recordName, address);
if (result2.success === false) {
return {
success: false,
errorCode: result2.errorCode,
errorMessage: result2.errorMessage,
};
}
return {
success: true,
recordName,
address,
};
}
catch (err) {
return {
success: false,
errorCode: 'server_error',
errorMessage: err.toString(),
};
}
});
}
}
//# sourceMappingURL=DataRecordsController.js.map

@@ -17,6 +17,12 @@ import { ServerError } from './Errors';

* Gets the data stored in the given record and address.
* @param recordName The name of hte record that the data is in.
* @param recordName The name of the record that the data is in.
* @param address The address that the data is stored at.
*/
getData(recordName: string, address: string): Promise<GetDataStoreResult>;
/**
* Deletes the data stored in the given record and address.
* @param recordName The name of the record that the data is in.
* @param address The address that the data is stored at.
*/
eraseData(recordName: string, address: string): Promise<EraseDataStoreResult>;
}

@@ -42,2 +48,10 @@ /**

}
/**
* Defines an interface that represents the result of a "erase data" operation.
*/
export interface EraseDataStoreResult {
success: boolean;
errorCode?: 'data_not_found' | ServerError;
errorMessage?: string;
}
//# sourceMappingURL=DataRecordsStore.d.ts.map

@@ -1,2 +0,2 @@

import { FileRecordsStore, AddFileFailure, MarkFileRecordAsUploadedFailure } from './FileRecordsStore';
import { FileRecordsStore, AddFileFailure, MarkFileRecordAsUploadedFailure, EraseFileStoreResult } from './FileRecordsStore';
import { NotLoggedInError, ServerError } from './Errors';

@@ -12,2 +12,3 @@ import { RecordsController, ValidatePublicRecordKeyFailure } from './RecordsController';

recordFile(recordKey: string, userId: string, request: RecordFileRequest): Promise<RecordFileResult>;
eraseFile(recordKey: string, fileName: string): Promise<EraseFileResult>;
markFileAsUploaded(recordName: string, fileName: string): Promise<FileUploadedResult>;

@@ -73,2 +74,13 @@ }

}
export declare type EraseFileResult = EraseFileSuccess | EraseFileFailure;
export interface EraseFileSuccess {
success: true;
recordName: string;
fileName: string;
}
export interface EraseFileFailure {
success: false;
errorCode: ServerError | EraseFileStoreResult['errorCode'] | NotLoggedInError | ValidatePublicRecordKeyFailure['errorCode'];
errorMessage: string;
}
export declare type FileUploadedResult = FileUploadedSuccess | FileUploadedFailure;

@@ -75,0 +87,0 @@ export interface FileUploadedSuccess {

@@ -94,2 +94,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
eraseFile(recordKey, fileName) {
return __awaiter(this, void 0, void 0, function* () {
try {
const keyResult = yield this._controller.validatePublicRecordKey(recordKey);
if (keyResult.success === false) {
return keyResult;
}
const publisherId = keyResult.ownerId;
const recordName = keyResult.recordName;
const eraseResult = yield this._store.eraseFileRecord(recordName, fileName);
if (eraseResult.success === false) {
return {
success: false,
errorCode: eraseResult.errorCode,
errorMessage: eraseResult.errorMessage,
};
}
return {
success: true,
recordName,
fileName,
};
}
catch (err) {
return {
success: false,
errorCode: 'server_error',
errorMessage: err.toString(),
};
}
});
}
markFileAsUploaded(recordName, fileName) {

@@ -96,0 +128,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -34,2 +34,8 @@ import { ServerError } from './Errors';

setFileRecordAsUploaded(recordName: string, fileName: string): Promise<MarkFileRecordAsUploadedResult>;
/**
* Attempts to delete the given file from the given record.
* @param recordName The name of the record that the file was recorded in.
* @param fileName The name of the file that should be deleted.
*/
eraseFileRecord(recordName: string, fileName: string): Promise<EraseFileStoreResult>;
}

@@ -147,2 +153,7 @@ export declare type GetFileRecordResult = GetFileRecordSuccess | GetFileRecordFailure;

}
export interface EraseFileStoreResult {
success: boolean;
errorCode?: ServerError | 'file_not_found';
errorMessage?: string;
}
//# sourceMappingURL=FileRecordsStore.d.ts.map

3

MemoryDataRecordsStore.d.ts

@@ -1,2 +0,2 @@

import { DataRecordsStore, GetDataStoreResult, SetDataResult } from './DataRecordsStore';
import { DataRecordsStore, EraseDataStoreResult, GetDataStoreResult, SetDataResult } from './DataRecordsStore';
export declare class MemoryDataRecordsStore implements DataRecordsStore {

@@ -6,4 +6,5 @@ private _buckets;

getData(recordName: string, address: string): Promise<GetDataStoreResult>;
eraseData(recordName: string, address: string): Promise<EraseDataStoreResult>;
private _getRecord;
}
//# sourceMappingURL=MemoryDataRecordsStore.d.ts.map

@@ -46,2 +46,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
eraseData(recordName, address) {
return __awaiter(this, void 0, void 0, function* () {
let record = this._getRecord(recordName);
let deleted = record.delete(address);
if (!deleted) {
return {
success: false,
errorCode: 'data_not_found',
errorMessage: 'The data was not found.',
};
}
return {
success: true,
};
});
}
_getRecord(recordName) {

@@ -48,0 +64,0 @@ let record = this._buckets.get(recordName);

@@ -1,2 +0,2 @@

import { AddFileResult, FileRecordsStore, GetFileRecordResult, MarkFileRecordAsUploadedResult, PresignFileUploadRequest, PresignFileUploadResult } from './FileRecordsStore';
import { AddFileResult, EraseFileStoreResult, FileRecordsStore, GetFileRecordResult, MarkFileRecordAsUploadedResult, PresignFileUploadRequest, PresignFileUploadResult } from './FileRecordsStore';
export declare class MemoryFileRecordsStore implements FileRecordsStore {

@@ -8,3 +8,4 @@ private _files;

setFileRecordAsUploaded(recordName: string, fileName: string): Promise<MarkFileRecordAsUploadedResult>;
eraseFileRecord(recordName: string, fileName: string): Promise<EraseFileStoreResult>;
}
//# sourceMappingURL=MemoryFileRecordsStore.d.ts.map

@@ -82,3 +82,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
eraseFileRecord(recordName, fileName) {
return __awaiter(this, void 0, void 0, function* () {
const deleted = this._files.delete(fileName);
if (!deleted) {
return {
success: false,
errorCode: 'file_not_found',
errorMessage: 'The file was not found in the store.',
};
}
return {
success: true,
};
});
}
}
//# sourceMappingURL=MemoryFileRecordsStore.js.map
{
"name": "@casual-simulation/aux-records",
"version": "2.0.28",
"version": "2.0.31",
"description": "Helpers and managers used by the CasualOS records system.",

@@ -44,3 +44,3 @@ "keywords": [],

},
"gitHead": "e1f6accd3dd4725ad13655550bbab3aa200afdb7"
"gitHead": "7dbb0b8d8d98060b770be7dd6489aae288600846"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc