@casual-simulation/aux-records
Advanced tools
Comparing version 2.0.31 to 2.0.34
import { NotLoggedInError, ServerError } from './Errors'; | ||
import { DataRecordsStore, EraseDataStoreResult, GetDataStoreResult, SetDataResult } from './DataRecordsStore'; | ||
import { DataRecordsStore, EraseDataStoreResult, GetDataStoreResult, SetDataResult, ListDataStoreResult } from './DataRecordsStore'; | ||
import { RecordsController, ValidatePublicRecordKeyFailure } from './RecordsController'; | ||
@@ -27,2 +27,3 @@ /** | ||
getData(recordName: string, address: string): Promise<GetDataResult>; | ||
listData(recordName: string, address: string | null): Promise<ListDataResult>; | ||
eraseData(recordKey: string, address: string): Promise<EraseDataResult>; | ||
@@ -80,2 +81,16 @@ } | ||
} | ||
export declare type ListDataResult = ListDataSuccess | ListDataFailure; | ||
export interface ListDataSuccess { | ||
success: true; | ||
recordName: string; | ||
items: { | ||
data: any; | ||
address: string; | ||
}[]; | ||
} | ||
export interface ListDataFailure { | ||
success: false; | ||
errorCode: ServerError | ListDataStoreResult['errorCode'] | 'not_supported'; | ||
errorMessage: string; | ||
} | ||
//# sourceMappingURL=DataRecordsController.d.ts.map |
@@ -86,2 +86,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
listData(recordName, address) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const result2 = yield this._store.listData(recordName, address); | ||
if (result2.success === false) { | ||
return { | ||
success: false, | ||
errorCode: result2.errorCode, | ||
errorMessage: result2.errorMessage, | ||
}; | ||
} | ||
return { | ||
success: true, | ||
recordName, | ||
items: result2.items, | ||
}; | ||
} | ||
catch (err) { | ||
return { | ||
success: false, | ||
errorCode: 'server_error', | ||
errorMessage: err.toString(), | ||
}; | ||
} | ||
}); | ||
} | ||
eraseData(recordKey, address) { | ||
@@ -88,0 +114,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -22,2 +22,8 @@ import { ServerError } from './Errors'; | ||
/** | ||
* Lists data stored in the given record starting with the given address. | ||
* @param recordName The name of the record. | ||
* @param address The address so start listing items at. | ||
*/ | ||
listData(recordName: string, address: string | null): Promise<ListDataStoreResult>; | ||
/** | ||
* Deletes the data stored in the given record and address. | ||
@@ -56,2 +62,11 @@ * @param recordName The name of the record that the data is in. | ||
} | ||
export interface ListDataStoreResult { | ||
success: boolean; | ||
items?: { | ||
data: any; | ||
address: string; | ||
}[]; | ||
errorCode?: ServerError; | ||
errorMessage?: string; | ||
} | ||
//# sourceMappingURL=DataRecordsStore.d.ts.map |
@@ -10,2 +10,5 @@ export * from './RecordsController'; | ||
export * from './MemoryFileRecordsStore'; | ||
export * from './EventRecordsController'; | ||
export * from './EventRecordsStore'; | ||
export * from './MemoryEventRecordsStore'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -10,2 +10,5 @@ export * from './RecordsController'; | ||
export * from './MemoryFileRecordsStore'; | ||
export * from './EventRecordsController'; | ||
export * from './EventRecordsStore'; | ||
export * from './MemoryEventRecordsStore'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { DataRecordsStore, EraseDataStoreResult, GetDataStoreResult, SetDataResult } from './DataRecordsStore'; | ||
import { DataRecordsStore, EraseDataStoreResult, GetDataStoreResult, ListDataStoreResult, SetDataResult } from './DataRecordsStore'; | ||
export declare class MemoryDataRecordsStore implements DataRecordsStore { | ||
@@ -7,4 +7,5 @@ private _buckets; | ||
eraseData(recordName: string, address: string): Promise<EraseDataStoreResult>; | ||
listData(recordName: string, address: string): Promise<ListDataStoreResult>; | ||
private _getRecord; | ||
} | ||
//# sourceMappingURL=MemoryDataRecordsStore.d.ts.map |
@@ -62,2 +62,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
listData(recordName, address) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let record = this._getRecord(recordName); | ||
let items = []; | ||
for (let [key, item] of record.entries()) { | ||
if (!address || key > address) { | ||
items.push({ | ||
address: key, | ||
data: item.data, | ||
}); | ||
} | ||
} | ||
return { | ||
success: true, | ||
items, | ||
}; | ||
}); | ||
} | ||
_getRecord(recordName) { | ||
@@ -64,0 +82,0 @@ let record = this._buckets.get(recordName); |
{ | ||
"name": "@casual-simulation/aux-records", | ||
"version": "2.0.31", | ||
"version": "2.0.34", | ||
"description": "Helpers and managers used by the CasualOS records system.", | ||
@@ -44,3 +44,3 @@ "keywords": [], | ||
}, | ||
"gitHead": "7dbb0b8d8d98060b770be7dd6489aae288600846" | ||
"gitHead": "964c230d49195946f361300aabd29c3ca7da0b66" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100040
48
1856