fix(metadata): Fix metadata handling to address type assertion and data retrieval.

This commit is contained in:
Philipp Kunz 2024-11-18 11:24:11 +01:00
parent 7db4d24817
commit e7f60465ff
6 changed files with 5746 additions and 5642 deletions

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## 2024-11-18 - 3.0.24 - fix(metadata)
Fix metadata handling to address type assertion and data retrieval.
- Fixed type assertion issues in `MetaData` class properties with type non-null assertions.
- Corrected the handling of JSON data retrieval in `MetaData.storeCustomMetaData` function.
## 2024-10-16 - 3.0.23 - fix(dependencies) ## 2024-10-16 - 3.0.23 - fix(dependencies)
Update package dependencies for improved functionality and security. Update package dependencies for improved functionality and security.

11365
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -21,4 +21,8 @@ tap.test('should create a valid smartbucket', async () => {
expect(myBucket.name).toEqual('testzone'); expect(myBucket.name).toEqual('testzone');
}); });
tap.test('', async () => {
})
export default tap.start(); export default tap.start();

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartbucket', name: '@push.rocks/smartbucket',
version: '3.0.23', version: '3.0.24',
description: 'A TypeScript library offering simple and cloud-agnostic object storage with advanced features like bucket creation, file and directory management, and data streaming.' description: 'A TypeScript library offering simple and cloud-agnostic object storage with advanced features like bucket creation, file and directory management, and data streaming.'
} }

View File

@ -21,12 +21,12 @@ export class MetaData {
/** /**
* the file that contains the metadata * the file that contains the metadata
*/ */
metadataFile: File; metadataFile!: File;
/** /**
* the file that the metadata is for * the file that the metadata is for
*/ */
fileRef: File; fileRef!: File;
public async getFileType(optionsArg?: { public async getFileType(optionsArg?: {
useFileExtension?: boolean; useFileExtension?: boolean;
@ -44,13 +44,13 @@ export class MetaData {
const stat = await this.fileRef.parentDirectoryRef.bucketRef.fastStat({ const stat = await this.fileRef.parentDirectoryRef.bucketRef.fastStat({
path: this.fileRef.getBasePath(), path: this.fileRef.getBasePath(),
}); });
return stat.ContentLength; return stat.ContentLength!;
} }
private prefixCustomMetaData = 'custom_'; private prefixCustomMetaData = 'custom_';
public async storeCustomMetaData<T = any>(optionsArg: { key: string; value: T }) { public async storeCustomMetaData<T = any>(optionsArg: { key: string; value: T }) {
const data = await this.metadataFile.getContentsAsString(); const data = await this.metadataFile.getJsonData();
data[this.prefixCustomMetaData + optionsArg.key] = optionsArg.value; data[this.prefixCustomMetaData + optionsArg.key] = optionsArg.value;
await this.metadataFile.writeJsonData(data); await this.metadataFile.writeJsonData(data);
} }

View File

@ -6,7 +6,8 @@
"module": "NodeNext", "module": "NodeNext",
"moduleResolution": "NodeNext", "moduleResolution": "NodeNext",
"esModuleInterop": true, "esModuleInterop": true,
"verbatimModuleSyntax": true "verbatimModuleSyntax": true,
"strict": true
}, },
"exclude": [ "exclude": [
"dist_*/**/*.d.ts" "dist_*/**/*.d.ts"