Compare commits

...

12 Commits

Author SHA1 Message Date
121c71102a 1.0.42 2021-12-18 01:00:08 +01:00
ec8f320317 fix(core): update 2021-12-18 01:00:07 +01:00
cca3ade103 1.0.41 2021-06-02 11:34:53 +02:00
caedf37288 fix(core): update 2021-06-02 11:34:52 +02:00
9255875d83 1.0.40 2021-06-02 11:14:25 +02:00
346269d399 fix(core): update 2021-06-02 11:14:24 +02:00
4bb6e2ef51 1.0.39 2021-04-07 19:01:36 +00:00
0ec7e1d6c6 fix(core): update 2021-04-07 19:01:35 +00:00
bac986ac85 1.0.38 2021-04-07 18:42:03 +00:00
476ff5bbce fix(core): update 2021-04-07 18:42:03 +00:00
178c360b89 1.0.37 2021-04-06 02:34:53 +00:00
191e0b8e05 fix(core): update 2021-04-06 02:34:52 +00:00
8 changed files with 20220 additions and 3972 deletions

View File

@ -36,6 +36,8 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production - npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- docker - docker
allow_failure: true
auditDevDependencies: auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci

24116
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartbucket", "name": "@pushrocks/smartbucket",
"version": "1.0.36", "version": "1.0.42",
"description": "simple cloud independent object storage", "description": "simple cloud independent object storage",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
@ -12,20 +12,20 @@
"build": "(tsbuild --web)" "build": "(tsbuild --web)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.28",
"@gitzone/tstest": "^1.0.52", "@gitzone/tstest": "^1.0.60",
"@pushrocks/tapbundle": "^3.2.9", "@pushrocks/tapbundle": "^3.2.15",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/qenv": "^4.0.10", "@pushrocks/qenv": "^4.0.10",
"@pushrocks/smartpath": "^4.0.3", "@pushrocks/smartpath": "^4.0.3",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartrx": "^2.0.19", "@pushrocks/smartrx": "^2.0.19",
"@pushrocks/streamfunction": "^2.0.1", "@pushrocks/streamfunction": "^2.0.1",
"@types/minio": "^7.0.6", "@types/minio": "^7.0.11",
"minio": "^7.0.16" "minio": "^7.0.25"
}, },
"private": false, "private": false,
"files": [ "files": [

View File

@ -13,16 +13,16 @@ tap.test('should create a valid smartbucket', async () => {
testSmartbucket = new smartbucket.SmartBucket({ testSmartbucket = new smartbucket.SmartBucket({
accessKey: testQenv.getEnvVarOnDemand('S3_KEY'), accessKey: testQenv.getEnvVarOnDemand('S3_KEY'),
accessSecret: testQenv.getEnvVarOnDemand('S3_SECRET'), accessSecret: testQenv.getEnvVarOnDemand('S3_SECRET'),
endpoint: 'fra1.digitaloceanspaces.com', endpoint: 's3.eu-central-1.wasabisys.com',
}); });
}); });
tap.skip.test('should create testbucket', async () => { tap.skip.test('should create testbucket', async () => {
await testSmartbucket.createBucket('testzone'); // await testSmartbucket.createBucket('testzone');
}); });
tap.skip.test('should remove testbucket', async () => { tap.skip.test('should remove testbucket', async () => {
await testSmartbucket.removeBucket('testzone'); // await testSmartbucket.removeBucket('testzone');
}); });
tap.test('should get a bucket', async () => { tap.test('should get a bucket', async () => {
@ -76,18 +76,6 @@ tap.test('should correctly build paths for sub directories', async () => {
console.log(dir4BasePath); console.log(dir4BasePath);
}); });
tap.test('should list huge file directory', async () => {
const servezoneBucket = await smartbucket.Bucket.getBucketByName(testSmartbucket, 'servezone');
const servezoneBaseDirectory = await servezoneBucket.getBaseDirectory();
const brandfileDirectory = await servezoneBaseDirectory.getSubDirectoryByName(
'public/brandfiles'
);
const files = await brandfileDirectory.listFiles();
const directories = await brandfileDirectory.listDirectories();
console.log(files);
console.log(directories);
});
tap.test('clean up directory style tests', async () => { tap.test('clean up directory style tests', async () => {
await myBucket.fastRemove('dir1/file1.txt'); await myBucket.fastRemove('dir1/file1.txt');
await myBucket.fastRemove('dir1/file2.txt'); await myBucket.fastRemove('dir1/file2.txt');

View File

@ -50,7 +50,7 @@ export class Bucket {
/** /**
* store file * store file
*/ */
public async fastStore(pathArg: string, fileContent: string) { public async fastStore(pathArg: string, fileContent: string | Buffer): Promise<void> {
const streamIntake = new plugins.streamfunction.Intake(); const streamIntake = new plugins.streamfunction.Intake();
const putPromise = this.smartbucketRef.minioClient const putPromise = this.smartbucketRef.minioClient
.putObject(this.name, pathArg, streamIntake.getReadable()) .putObject(this.name, pathArg, streamIntake.getReadable())
@ -63,14 +63,16 @@ export class Bucket {
/** /**
* get file * get file
*/ */
public async fastGet(pathArg: string) { public async fastGet(pathArg: string): Promise<Buffer> {
const done = plugins.smartpromise.defer(); const done = plugins.smartpromise.defer();
let completeFile: Buffer; let completeFile: Buffer;
const replaySubject = await this.fastGetStream(pathArg); const replaySubject = await this.fastGetStream(pathArg);
replaySubject.subscribe( const subscription = replaySubject.subscribe(
(chunk) => { (chunk) => {
if (completeFile) { if (completeFile) {
completeFile = Buffer.concat([completeFile, chunk]); completeFile = Buffer.concat([completeFile, chunk]);
} else {
completeFile = chunk;
} }
}, },
(err) => { (err) => {
@ -78,6 +80,7 @@ export class Bucket {
}, },
() => { () => {
done.resolve(); done.resolve();
subscription.unsubscribe();
} }
); );
await done.promise; await done.promise;

View File

@ -169,18 +169,19 @@ export class Directory {
*/ */
public async move() { public async move() {
// TODO // TODO
throw new Error('moving a directory is not yet implemented')
} }
/** /**
* creates a file within this directory * creates a file within this directory
* @param relativePathArg * @param relativePathArg
*/ */
public async createFile(relativePathArg) { public async createEmptyFile(relativePathArg: string) {
let completeFilePath: string = ''; const emtpyFile = await File.createFileFromString(this, relativePathArg, '');
} }
// file operations // file operations
public async fastStore(pathArg: string, contentArg: string) { public async fastStore(pathArg: string, contentArg: string | Buffer) {
const path = plugins.path.join(this.getBasePath(), pathArg); const path = plugins.path.join(this.getBasePath(), pathArg);
await this.bucketRef.fastStore(path, contentArg); await this.bucketRef.fastStore(path, contentArg);
} }
@ -201,4 +202,25 @@ export class Directory {
const path = plugins.path.join(this.getBasePath(), pathArg); const path = plugins.path.join(this.getBasePath(), pathArg);
await this.bucketRef.fastRemove(path); await this.bucketRef.fastRemove(path);
} }
/**
* deletes the directory with all its contents
*/
public async deleteWithAllContents() {
const deleteDirectory = async (directoryArg: Directory) => {
const childDirectories = await directoryArg.listDirectories();
if (childDirectories.length === 0) {
console.log('directory empty! Path complete!');
} else {
for (const childDir of childDirectories) {
await deleteDirectory(childDir);
}
}
const files = await directoryArg.listFiles();
for (const file of files) {
await directoryArg.fastRemove(file.name);
}
};
await deleteDirectory(this);
}
} }

View File

@ -76,8 +76,8 @@ export class File {
} }
public async streamContent() { public async streamContent() {
throw new Error('not yet implemented');
// TODO // TODO
throw new Error('not yet implemented');
} }
/** /**

View File

@ -3,6 +3,7 @@ import { Bucket } from './smartbucket.classes.bucket';
export interface ISmartBucketConfig { export interface ISmartBucketConfig {
endpoint: string; endpoint: string;
port?: number;
accessKey: string; accessKey: string;
accessSecret: string; accessSecret: string;
} }
@ -19,7 +20,7 @@ export class SmartBucket {
this.config = configArg; this.config = configArg;
this.minioClient = new plugins.minio.Client({ this.minioClient = new plugins.minio.Client({
endPoint: this.config.endpoint, endPoint: this.config.endpoint,
port: 443, port: configArg.port || 443,
useSSL: true, useSSL: true,
accessKey: this.config.accessKey, accessKey: this.config.accessKey,
secretKey: this.config.accessSecret, secretKey: this.config.accessSecret,