@rocketmakers/orbit-storage-typeorm 2.0.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/entities/bucketRegistration.js +8 -2
- package/lib/entities/bucketRegistration.js.map +1 -1
- package/lib/entities/folder.js +9 -2
- package/lib/entities/folder.js.map +1 -1
- package/lib/entities/upload.js +15 -2
- package/lib/entities/upload.js.map +1 -1
- package/lib/ioc/register.js +1 -2
- package/lib/ioc/register.js.map +1 -1
- package/lib/repositories/bucketRegistrationRepository.d.ts +2 -3
- package/lib/repositories/bucketRegistrationRepository.d.ts.map +1 -1
- package/lib/repositories/bucketRegistrationRepository.js +58 -70
- package/lib/repositories/bucketRegistrationRepository.js.map +1 -1
- package/lib/repositories/folderRepository.d.ts +2 -3
- package/lib/repositories/folderRepository.d.ts.map +1 -1
- package/lib/repositories/folderRepository.js +86 -93
- package/lib/repositories/folderRepository.js.map +1 -1
- package/lib/repositories/uploadRepository.d.ts +2 -3
- package/lib/repositories/uploadRepository.d.ts.map +1 -1
- package/lib/repositories/uploadRepository.js +53 -59
- package/lib/repositories/uploadRepository.js.map +1 -1
- package/package.json +33 -31
- package/lib/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -36,6 +36,6 @@ Hosted docs covering types, interfaces and all service class/method signatures w
|
|
|
36
36
|
|
|
37
37
|
Source code for this package can be found using the link below:
|
|
38
38
|
|
|
39
|
-
[Source code](https://gitlab.com/rocketmakers/
|
|
39
|
+
[Source code](https://gitlab.com/rocketmakers/core/orbit/-/tree/develop/packages/storage/orbit-storage-typeorm)
|
|
40
40
|
|
|
41
|
-
Contributing docs can be found in the [README.md](https://gitlab.com/rocketmakers/
|
|
41
|
+
Contributing docs can be found in the [README.md](https://gitlab.com/rocketmakers/core/orbit/-/blob/develop/README.md)
|
|
@@ -5,7 +5,14 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const orbit_db_typeorm_1 = require("@rocketmakers/orbit-db-typeorm");
|
|
6
6
|
const typeorm_1 = require("typeorm");
|
|
7
7
|
let BucketRegistrationEntity = class BucketRegistrationEntity extends orbit_db_typeorm_1.UpdatableCreatableEntity {
|
|
8
|
+
id;
|
|
9
|
+
bucketName;
|
|
10
|
+
pathPrefix;
|
|
11
|
+
deleteMode;
|
|
12
|
+
config;
|
|
13
|
+
maxFileSizeBytes;
|
|
8
14
|
};
|
|
15
|
+
exports.BucketRegistrationEntity = BucketRegistrationEntity;
|
|
9
16
|
tslib_1.__decorate([
|
|
10
17
|
(0, typeorm_1.PrimaryColumn)({ type: 'uuid' }),
|
|
11
18
|
tslib_1.__metadata("design:type", String)
|
|
@@ -30,8 +37,7 @@ tslib_1.__decorate([
|
|
|
30
37
|
(0, typeorm_1.Column)({ name: 'max_file_size_bytes', type: 'int', nullable: true }),
|
|
31
38
|
tslib_1.__metadata("design:type", Number)
|
|
32
39
|
], BucketRegistrationEntity.prototype, "maxFileSizeBytes", void 0);
|
|
33
|
-
BucketRegistrationEntity = tslib_1.__decorate([
|
|
40
|
+
exports.BucketRegistrationEntity = BucketRegistrationEntity = tslib_1.__decorate([
|
|
34
41
|
(0, typeorm_1.Entity)('bucket_registration', { schema: 'orbit_storage' })
|
|
35
42
|
], BucketRegistrationEntity);
|
|
36
|
-
exports.BucketRegistrationEntity = BucketRegistrationEntity;
|
|
37
43
|
//# sourceMappingURL=bucketRegistration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bucketRegistration.js","sourceRoot":"","sources":["../../src/entities/bucketRegistration.ts"],"names":[],"mappings":";;;;AAAA,qEAA0E;AAE1E,qCAAwD;
|
|
1
|
+
{"version":3,"file":"bucketRegistration.js","sourceRoot":"","sources":["../../src/entities/bucketRegistration.ts"],"names":[],"mappings":";;;;AAAA,qEAA0E;AAE1E,qCAAwD;AAGjD,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,2CAAwB;IAEpE,EAAE,CAAwB;IAG1B,UAAU,CAAc;IAGxB,UAAU,CAAU;IAGpB,UAAU,CAAc;IAGxB,MAAM,CAAU;IAGhB,gBAAgB,CAAU;CAC3B,CAAA;AAlBY,4DAAwB;AAEnC;IADC,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACN;AAG1B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4DACtB;AAGxB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4DAC1B;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4DACtB;AAGxB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wDACT;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kEAC3C;mCAjBf,wBAAwB;IADpC,IAAA,gBAAM,EAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;GAC9C,wBAAwB,CAkBpC"}
|
package/lib/entities/folder.js
CHANGED
|
@@ -5,7 +5,15 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const orbit_db_typeorm_1 = require("@rocketmakers/orbit-db-typeorm");
|
|
6
6
|
const typeorm_1 = require("typeorm");
|
|
7
7
|
let Folder = class Folder extends orbit_db_typeorm_1.UpdatableCreatableEntity {
|
|
8
|
+
id;
|
|
9
|
+
bucketName;
|
|
10
|
+
parentId;
|
|
11
|
+
folderName;
|
|
12
|
+
folderType;
|
|
13
|
+
deletedBy;
|
|
14
|
+
deletedOn;
|
|
8
15
|
};
|
|
16
|
+
exports.Folder = Folder;
|
|
9
17
|
tslib_1.__decorate([
|
|
10
18
|
(0, typeorm_1.PrimaryColumn)({ type: 'uuid' }),
|
|
11
19
|
tslib_1.__metadata("design:type", String)
|
|
@@ -34,8 +42,7 @@ tslib_1.__decorate([
|
|
|
34
42
|
(0, typeorm_1.Column)({ name: 'deleted_on', type: 'timestamp', transformer: orbit_db_typeorm_1.Transformers.dateTime }),
|
|
35
43
|
tslib_1.__metadata("design:type", String)
|
|
36
44
|
], Folder.prototype, "deletedOn", void 0);
|
|
37
|
-
Folder = tslib_1.__decorate([
|
|
45
|
+
exports.Folder = Folder = tslib_1.__decorate([
|
|
38
46
|
(0, typeorm_1.Entity)('folder', { schema: 'orbit_storage' })
|
|
39
47
|
], Folder);
|
|
40
|
-
exports.Folder = Folder;
|
|
41
48
|
//# sourceMappingURL=folder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder.js","sourceRoot":"","sources":["../../src/entities/folder.ts"],"names":[],"mappings":";;;;AACA,qEAAwF;AAExF,qCAAwD;
|
|
1
|
+
{"version":3,"file":"folder.js","sourceRoot":"","sources":["../../src/entities/folder.ts"],"names":[],"mappings":";;;;AACA,qEAAwF;AAExF,qCAAwD;AAGjD,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,2CAAwB;IAElD,EAAE,CAAY;IAGd,UAAU,CAAc;IAGxB,QAAQ,CAAY;IAGpB,UAAU,CAAU;IAGpB,UAAU,CAAc;IAGxB,SAAS,CAAU;IAGnB,SAAS,CAAkB;CAC5B,CAAA;AArBY,wBAAM;AAEjB;IADC,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCAClB;AAGd;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CACtB;AAGxB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wCACxB;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CAC1B;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CACtB;AAGxB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCAC1B;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,+BAAY,CAAC,QAAQ,EAAE,CAAC;;yCAC3D;iBApBhB,MAAM;IADlB,IAAA,gBAAM,EAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;GACjC,MAAM,CAqBlB"}
|
package/lib/entities/upload.js
CHANGED
|
@@ -5,7 +5,21 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const orbit_db_typeorm_1 = require("@rocketmakers/orbit-db-typeorm");
|
|
6
6
|
const typeorm_1 = require("typeorm");
|
|
7
7
|
let Upload = class Upload extends orbit_db_typeorm_1.CreatableEntity {
|
|
8
|
+
id;
|
|
9
|
+
folderId;
|
|
10
|
+
bucketName;
|
|
11
|
+
ticket;
|
|
12
|
+
filePath;
|
|
13
|
+
fileName;
|
|
14
|
+
fileSize;
|
|
15
|
+
contentType;
|
|
16
|
+
userId;
|
|
17
|
+
additionalMetadata;
|
|
18
|
+
completedOn;
|
|
19
|
+
deletedBy;
|
|
20
|
+
deletedOn;
|
|
8
21
|
};
|
|
22
|
+
exports.Upload = Upload;
|
|
9
23
|
tslib_1.__decorate([
|
|
10
24
|
(0, typeorm_1.PrimaryColumn)({ type: 'uuid' }),
|
|
11
25
|
tslib_1.__metadata("design:type", String)
|
|
@@ -58,8 +72,7 @@ tslib_1.__decorate([
|
|
|
58
72
|
(0, typeorm_1.Column)({ name: 'deleted_on', type: 'timestamp', transformer: orbit_db_typeorm_1.Transformers.dateTime, nullable: true }),
|
|
59
73
|
tslib_1.__metadata("design:type", String)
|
|
60
74
|
], Upload.prototype, "deletedOn", void 0);
|
|
61
|
-
Upload = tslib_1.__decorate([
|
|
75
|
+
exports.Upload = Upload = tslib_1.__decorate([
|
|
62
76
|
(0, typeorm_1.Entity)('upload', { schema: 'orbit_storage' })
|
|
63
77
|
], Upload);
|
|
64
|
-
exports.Upload = Upload;
|
|
65
78
|
//# sourceMappingURL=upload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../src/entities/upload.ts"],"names":[],"mappings":";;;;AACA,qEAA+E;AAG/E,qCAAwD;
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../src/entities/upload.ts"],"names":[],"mappings":";;;;AACA,qEAA+E;AAG/E,qCAAwD;AAGjD,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,kCAAe;IAEzC,EAAE,CAAY;IAGd,QAAQ,CAAY;IAGpB,UAAU,CAAc;IAGxB,MAAM,CAAgB;IAGtB,QAAQ,CAAU;IAGlB,QAAQ,CAAU;IAGlB,QAAQ,CAAU;IAGlB,WAAW,CAAU;IAGrB,MAAM,CAAU;IAGhB,kBAAkB,CAAe;IAGjC,WAAW,CAAkB;IAG7B,SAAS,CAAc;IAGvB,SAAS,CAAkB;CAC5B,CAAA;AAvCY,wBAAM;AAEjB;IADC,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCAClB;AAGd;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wCACxB;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CACtB;AAGxB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAA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Q,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;GACjC,MAAM,CAuClB"}
|
package/lib/ioc/register.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerStorageTypeormIoC =
|
|
3
|
+
exports.registerStorageTypeormIoC = registerStorageTypeormIoC;
|
|
4
4
|
const ioc_1 = require("@rocketmakers/ioc");
|
|
5
5
|
const repositories_1 = require("../repositories");
|
|
6
6
|
function registerStorageTypeormIoC(container) {
|
|
@@ -10,5 +10,4 @@ function registerStorageTypeormIoC(container) {
|
|
|
10
10
|
folderRepository: builder => builder.class(repositories_1.FolderRepository, ['timeService', 'uuidGeneratorService']).inSingletonScope(),
|
|
11
11
|
}, container);
|
|
12
12
|
}
|
|
13
|
-
exports.registerStorageTypeormIoC = registerStorageTypeormIoC;
|
|
14
13
|
//# sourceMappingURL=register.js.map
|
package/lib/ioc/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/ioc/register.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/ioc/register.ts"],"names":[],"mappings":";;AAoCA,8DAcC;AAlDD,2CAAyD;AAIzD,kDAAmG;AAgCnG,SAAgB,yBAAyB,CACvC,SAA0C;IAE1C,OAAO,IAAA,cAAQ,EACb;QACE,4BAA4B,EAAE,OAAO,CAAC,EAAE,CACtC,OAAO,CAAC,KAAK,CAAC,2CAA4B,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC,CAAC,gBAAgB,EAAE;QACzG,gBAAgB,EAAE,OAAO,CAAC,EAAE,CAC1B,OAAO,CAAC,KAAK,CAAC,+BAAgB,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC,CAAC,gBAAgB,EAAE;QAC7F,gBAAgB,EAAE,OAAO,CAAC,EAAE,CAC1B,OAAO,CAAC,KAAK,CAAC,+BAAgB,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC,CAAC,gBAAgB,EAAE;KAC9F,EACD,SAAS,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { DateTimeString, IQuery, IQueryResponse, ITimeService, IUuidGeneratorService } from '@rocketmakers/orbit-core';
|
|
2
|
-
import { IDataContext
|
|
2
|
+
import { IDataContext } from '@rocketmakers/orbit-db-core';
|
|
3
3
|
import { BucketName, BucketRegistration, BucketRegistrationId, BucketRegistrationRaw, IBucketRegistrationRepository, IBucketRegistrationUpdateRaw } from '@rocketmakers/orbit-storage-core';
|
|
4
|
-
import {
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
5
|
import { BucketRegistrationEntity } from '../entities';
|
|
6
6
|
export declare class BucketRegistrationRepository implements IBucketRegistrationRepository {
|
|
7
7
|
private timeService;
|
|
8
8
|
private uuidGenerator;
|
|
9
9
|
constructor(timeService: ITimeService, uuidGenerator: IUuidGeneratorService);
|
|
10
|
-
txCast(tx: OrbitTransaction): EntityManager;
|
|
11
10
|
protected getRepository(context: IDataContext): Repository<BucketRegistrationEntity>;
|
|
12
11
|
exists(context: IDataContext, bucketName: BucketName): Promise<boolean>;
|
|
13
12
|
getRawByName(context: IDataContext, bucketName: BucketName): Promise<BucketRegistrationRaw | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bucketRegistrationRepository.d.ts","sourceRoot":"","sources":["../../src/repositories/bucketRegistrationRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,MAAM,EACN,cAAc,EACd,YAAY,EACZ,qBAAqB,EAEtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"bucketRegistrationRepository.d.ts","sourceRoot":"","sources":["../../src/repositories/bucketRegistrationRepository.ts"],"names":[],"mapp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AAQ;IAWhB,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAsCzF,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,4BAA4B;IAYrE,OAAO,CAAC,GAAG;CAcZ"}
|
|
@@ -1,102 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BucketRegistrationRepository = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const orbit_core_1 = require("@rocketmakers/orbit-core");
|
|
6
5
|
const orbit_db_typeorm_1 = require("@rocketmakers/orbit-db-typeorm");
|
|
7
6
|
const entities_1 = require("../entities");
|
|
8
7
|
class BucketRegistrationRepository {
|
|
8
|
+
timeService;
|
|
9
|
+
uuidGenerator;
|
|
9
10
|
constructor(timeService, uuidGenerator) {
|
|
10
11
|
this.timeService = timeService;
|
|
11
12
|
this.uuidGenerator = uuidGenerator;
|
|
12
13
|
}
|
|
13
|
-
txCast(tx) {
|
|
14
|
-
return tx;
|
|
15
|
-
}
|
|
16
14
|
getRepository(context) {
|
|
17
|
-
return
|
|
15
|
+
return (0, orbit_db_typeorm_1.getRepository)(context.tx, entities_1.BucketRegistrationEntity);
|
|
18
16
|
}
|
|
19
|
-
exists(context, bucketName) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return value > 0;
|
|
23
|
-
});
|
|
17
|
+
async exists(context, bucketName) {
|
|
18
|
+
const value = await this.getRepository(context).countBy({ bucketName });
|
|
19
|
+
return value > 0;
|
|
24
20
|
}
|
|
25
|
-
getRawByName(context, bucketName) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return this.map(row);
|
|
32
|
-
});
|
|
21
|
+
async getRawByName(context, bucketName) {
|
|
22
|
+
const row = await this.getRepository(context).findOneBy({ bucketName });
|
|
23
|
+
if (!row) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return this.map(row);
|
|
33
27
|
}
|
|
34
|
-
getUpdatedOn(context, bucketName) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
return bucket.updatedOn;
|
|
28
|
+
async getUpdatedOn(context, bucketName) {
|
|
29
|
+
const bucket = await this.getRepository(context).findOne({
|
|
30
|
+
where: { bucketName },
|
|
31
|
+
select: ['updatedOn'],
|
|
41
32
|
});
|
|
33
|
+
if (!bucket) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return bucket.updatedOn;
|
|
42
37
|
}
|
|
43
|
-
deleteByName(context, bucketName) {
|
|
44
|
-
return
|
|
45
|
-
|
|
38
|
+
async deleteByName(context, bucketName) {
|
|
39
|
+
return orbit_db_typeorm_1.RepositoryExtensions.deleteEntity(this.getRepository(context), {
|
|
40
|
+
bucketName,
|
|
46
41
|
});
|
|
47
42
|
}
|
|
48
|
-
getAll(context, query) {
|
|
49
|
-
return
|
|
50
|
-
return orbit_db_typeorm_1.RepositoryExtensions.paginatedSearchWithMap(this.getRepository(context), query, {}, (b) => this.map(b));
|
|
51
|
-
});
|
|
43
|
+
async getAll(context, query) {
|
|
44
|
+
return orbit_db_typeorm_1.RepositoryExtensions.paginatedSearchWithMap(this.getRepository(context), query, {}, (b) => this.map(b));
|
|
52
45
|
}
|
|
53
46
|
getById(context, id) {
|
|
54
47
|
const repo = this.getRepository(context);
|
|
55
48
|
return this.findById(repo, id);
|
|
56
49
|
}
|
|
57
|
-
findById(repo, id) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return this.map(registration);
|
|
64
|
-
});
|
|
50
|
+
async findById(repo, id) {
|
|
51
|
+
const registration = await repo.findOneBy({ id });
|
|
52
|
+
if (!registration) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return this.map(registration);
|
|
65
56
|
}
|
|
66
|
-
create(context, reg) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
throw new Error('Created bucket registration not found!');
|
|
74
|
-
}
|
|
75
|
-
return bucket;
|
|
57
|
+
async create(context, reg) {
|
|
58
|
+
try {
|
|
59
|
+
const repo = this.getRepository(context);
|
|
60
|
+
const id = await orbit_db_typeorm_1.RepositoryExtensions.insertIdentifiableCreatableUpdatable(context, this.getRepository(context), { ...reg, bucketName: reg.name }, this.timeService, this.uuidGenerator);
|
|
61
|
+
const bucket = await this.findById(repo, id);
|
|
62
|
+
if (!bucket) {
|
|
63
|
+
throw new Error('Created bucket registration not found!');
|
|
76
64
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
65
|
+
return bucket;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const message = error instanceof Error ? error.message : undefined;
|
|
69
|
+
if (message && message.indexOf('uq_idx_bucket_registration') > -1) {
|
|
70
|
+
throw new orbit_core_1.ValidationError([
|
|
71
|
+
{
|
|
72
|
+
attribute: 'bucketName',
|
|
73
|
+
path: 'bucketName',
|
|
74
|
+
messages: {
|
|
75
|
+
friendly: 'Bucket name already used',
|
|
76
|
+
developer: 'Bucket name exists in the database',
|
|
88
77
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
value: reg.name,
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
92
81
|
}
|
|
93
|
-
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
94
84
|
}
|
|
95
|
-
update(context, reg) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return orbit_db_typeorm_1.RepositoryExtensions.updateIdentifiableCreatableUpdatable(context, this.getRepository(context), updatedOn, id, rest, this.timeService);
|
|
99
|
-
});
|
|
85
|
+
async update(context, reg) {
|
|
86
|
+
const { id, updatedOn, ...rest } = reg;
|
|
87
|
+
return orbit_db_typeorm_1.RepositoryExtensions.updateIdentifiableCreatableUpdatable(context, this.getRepository(context), updatedOn, id, rest, this.timeService);
|
|
100
88
|
}
|
|
101
89
|
map(registration) {
|
|
102
90
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bucketRegistrationRepository.js","sourceRoot":"","sources":["../../src/repositories/bucketRegistrationRepository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bucketRegistrationRepository.js","sourceRoot":"","sources":["../../src/repositories/bucketRegistrationRepository.ts"],"names":[],"mappings":";;;AAAA,yDAOkC;AAElC,qEAAqF;AAWrF,0CAAuD;AAEvD,MAAa,4BAA4B;IAE7B;IACA;IAFV,YACU,WAAyB,EACzB,aAAoC;QADpC,gBAAW,GAAX,WAAW,CAAc;QACzB,kBAAa,GAAb,aAAa,CAAuB;IAC3C,CAAC;IAEM,aAAa,CAAC,OAAqB;QAC3C,OAAO,IAAA,gCAAa,EAAC,OAAO,CAAC,EAAE,EAAE,mCAAwB,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAqB,EAAE,UAAsB;QACxD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QACxE,OAAO,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAAqB,EAAE,UAAsB;QAC9D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,SAAS,CAAC;QACnB,CAAC;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AAE,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC;QACvC,OAAO,uCAAoB,CAAC,oCAAoC,CAC9D,OAAO,EACP,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAC3B,SAAS,EACT,EAAE,EACF,IAAI,EACJ,IAAI,CAAC,WAAW,CACjB,CAAC;IACJ,CAAC;IAEO,GAAG,CAAC,YAAsC;QAChD,OAAO;YACL,EAAE,EAAE,YAAY,CAAC,EAAE;YACnB,UAAU,EAAE,YAAY,CAAC,UAAU;YACnC,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,IAAI,EAAE,YAAY,CAAC,UAAU;YAC7B,UAAU,EAAE,YAAY,CAAC,UAAU;YACnC,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;YAC/C,MAAM,EAAE,YAAY,CAAC,MAAM;SAC5B,CAAC;IACJ,CAAC;CACF;AAtID,oEAsIC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { IQuery, IQueryResponse, ITimeService, IUuidGeneratorService } from '@rocketmakers/orbit-core';
|
|
2
|
-
import { IDataContext
|
|
2
|
+
import { IDataContext } from '@rocketmakers/orbit-db-core';
|
|
3
3
|
import { BucketName, FolderId, FolderType, IFolder, IFolderCreate, IFolderMove, IFolderRename, IFolderRepository } from '@rocketmakers/orbit-storage-core';
|
|
4
|
-
import {
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
5
|
import { Folder } from '../entities';
|
|
6
6
|
export declare class FolderRepository implements IFolderRepository {
|
|
7
7
|
private timeService;
|
|
8
8
|
private uuidGenerator;
|
|
9
9
|
constructor(timeService: ITimeService, uuidGenerator: IUuidGeneratorService);
|
|
10
|
-
txCast(tx: OrbitTransaction): EntityManager;
|
|
11
10
|
protected getRepository(context: IDataContext): Repository<Folder>;
|
|
12
11
|
private getFolderIdsByParent;
|
|
13
12
|
private getChildFolderIdsRecursive;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folderRepository.d.ts","sourceRoot":"","sources":["../../src/repositories/folderRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,cAAc,EACd,YAAY,EACZ,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"folderRepository.d.ts","sourceRoot":"","sources":["../../src/repositories/folderRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,cAAc,EACd,YAAY,EACZ,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EACL,UAAU,EACV,QAAQ,EACR,UAAU,EACV,OAAO,EACP,aAAa,EACb,WAAW,EACX,aAAa,EACb,iBAAiB,EAClB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAwB,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrC,qBAAa,gBAAiB,YAAW,iBAAiB;IAEtD,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;gBADb,WAAW,EAAE,YAAY,EACzB,aAAa,EAAE,qBAAqB;IAG9C,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC;YAIpD,oBAAoB;YAQpB,0BAA0B;IAWlC,UAAU,CACd,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,GACrB,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAyC7B,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU;IAoB7E,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ;IAKtD,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa;IAWnD,UAAU,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW;YAuB7C,sBAAsB;YAYtB,sBAAsB;CAUrC"}
|
|
@@ -1,126 +1,119 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FolderRepository = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const orbit_core_1 = require("@rocketmakers/orbit-core");
|
|
6
5
|
const orbit_db_typeorm_1 = require("@rocketmakers/orbit-db-typeorm");
|
|
7
6
|
const typeorm_1 = require("typeorm");
|
|
8
7
|
const entities_1 = require("../entities");
|
|
9
8
|
class FolderRepository {
|
|
9
|
+
timeService;
|
|
10
|
+
uuidGenerator;
|
|
10
11
|
constructor(timeService, uuidGenerator) {
|
|
11
12
|
this.timeService = timeService;
|
|
12
13
|
this.uuidGenerator = uuidGenerator;
|
|
13
14
|
}
|
|
14
|
-
txCast(tx) {
|
|
15
|
-
return tx;
|
|
16
|
-
}
|
|
17
15
|
getRepository(context) {
|
|
18
|
-
return
|
|
16
|
+
return (0, orbit_db_typeorm_1.getRepository)(context.tx, entities_1.Folder);
|
|
19
17
|
}
|
|
20
|
-
getFolderIdsByParent(context, parentIds) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
async getFolderIdsByParent(context, parentIds) {
|
|
19
|
+
const f = await this.getRepository(context).find({
|
|
20
|
+
where: { parentId: (0, typeorm_1.In)(parentIds) },
|
|
21
|
+
select: ['id'],
|
|
24
22
|
});
|
|
23
|
+
return f ? f.map(g => g.id) : [];
|
|
25
24
|
}
|
|
26
|
-
getChildFolderIdsRecursive(context, id) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return folders;
|
|
35
|
-
});
|
|
25
|
+
async getChildFolderIdsRecursive(context, id) {
|
|
26
|
+
let parentIds = [id];
|
|
27
|
+
const folders = [];
|
|
28
|
+
while (parentIds.length) {
|
|
29
|
+
parentIds = await this.getFolderIdsByParent(context, parentIds);
|
|
30
|
+
folders.push(...parentIds);
|
|
31
|
+
}
|
|
32
|
+
return folders;
|
|
36
33
|
}
|
|
37
|
-
getFolders(context, bucketName, query) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const dictionary = m;
|
|
45
|
-
const folder = {
|
|
46
|
-
name: f.folderName,
|
|
47
|
-
id: f.id,
|
|
48
|
-
updatedOn: f.updatedOn,
|
|
49
|
-
updatedBy: f.updatedBy,
|
|
50
|
-
children: [],
|
|
51
|
-
};
|
|
52
|
-
dictionary[f.id] = folder;
|
|
53
|
-
return dictionary;
|
|
54
|
-
}, {});
|
|
55
|
-
const returns = [];
|
|
56
|
-
items.forEach(f => {
|
|
57
|
-
const current = folderDict[f.id];
|
|
58
|
-
if (f.parentId) {
|
|
59
|
-
folderDict[f.parentId].children.push(current);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
returns.push(current);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return { items: returns, itemCount, paging };
|
|
34
|
+
async getFolders(context, bucketName, query) {
|
|
35
|
+
const { items, itemCount, paging } = await orbit_db_typeorm_1.RepositoryExtensions.paginatedSearch(this.getRepository(context), query, {
|
|
36
|
+
where: { bucketName, ...(0, orbit_db_typeorm_1.createWhereClause)(query) },
|
|
37
|
+
order: {
|
|
38
|
+
parentId: 'ASC',
|
|
39
|
+
...query.order,
|
|
40
|
+
},
|
|
66
41
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
42
|
+
const folderDict = items.reduce((m, f) => {
|
|
43
|
+
const dictionary = m;
|
|
44
|
+
const folder = {
|
|
45
|
+
name: f.folderName,
|
|
46
|
+
id: f.id,
|
|
47
|
+
updatedOn: f.updatedOn,
|
|
48
|
+
updatedBy: f.updatedBy,
|
|
49
|
+
children: [],
|
|
50
|
+
};
|
|
51
|
+
dictionary[f.id] = folder;
|
|
52
|
+
return dictionary;
|
|
53
|
+
}, {});
|
|
54
|
+
const returns = [];
|
|
55
|
+
items.forEach(f => {
|
|
56
|
+
const current = folderDict[f.id];
|
|
57
|
+
if (f.parentId) {
|
|
58
|
+
folderDict[f.parentId].children.push(current);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
returns.push(current);
|
|
73
62
|
}
|
|
74
|
-
return orbit_db_typeorm_1.RepositoryExtensions.insertIdentifiableCreatableUpdatable(context, repo, {
|
|
75
|
-
bucketName: creation.bucketName,
|
|
76
|
-
folderName: creation.name,
|
|
77
|
-
parentId: creation.parentId,
|
|
78
|
-
folderType: type,
|
|
79
|
-
}, this.timeService, this.uuidGenerator);
|
|
80
63
|
});
|
|
64
|
+
return { items: returns, itemCount, paging };
|
|
81
65
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
66
|
+
async createFolder(context, creation, type) {
|
|
67
|
+
const repo = this.getRepository(context);
|
|
68
|
+
if (creation.parentId) {
|
|
69
|
+
await this.ensureParentIdInBucket(repo, creation.parentId, creation.bucketName);
|
|
70
|
+
}
|
|
71
|
+
return orbit_db_typeorm_1.RepositoryExtensions.insertIdentifiableCreatableUpdatable(context, repo, {
|
|
72
|
+
bucketName: creation.bucketName,
|
|
73
|
+
folderName: creation.name,
|
|
74
|
+
parentId: creation.parentId,
|
|
75
|
+
folderType: type,
|
|
76
|
+
}, this.timeService, this.uuidGenerator);
|
|
77
|
+
}
|
|
78
|
+
async deleteFolder(context, id) {
|
|
79
|
+
await this.getChildFolderIdsRecursive(context, id);
|
|
80
|
+
return orbit_db_typeorm_1.RepositoryExtensions.deleteById(this.getRepository(context), id);
|
|
87
81
|
}
|
|
88
82
|
renameFolder(context, update) {
|
|
89
83
|
return orbit_db_typeorm_1.RepositoryExtensions.updateIdentifiableCreatableUpdatable(context, this.getRepository(context), update.updatedOn, update.id, { folderName: update.name }, this.timeService);
|
|
90
84
|
}
|
|
91
|
-
moveFolder(context, update) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!existing) {
|
|
96
|
-
throw new orbit_core_1.ArgumentValidationError('Id is not a valid folder');
|
|
97
|
-
}
|
|
98
|
-
yield this.ensureParentIdInBucket(repo, update.parentId, existing.bucketName);
|
|
99
|
-
yield this.ensureNotMovingToChild(repo, update.id, update.parentId);
|
|
100
|
-
return orbit_db_typeorm_1.RepositoryExtensions.updateIdentifiableCreatableUpdatable(context, repo, update.updatedOn, update.id, { parentId: update.parentId }, this.timeService);
|
|
85
|
+
async moveFolder(context, update) {
|
|
86
|
+
const repo = this.getRepository(context);
|
|
87
|
+
const existing = await orbit_db_typeorm_1.RepositoryExtensions.findById(repo, update.id, {
|
|
88
|
+
select: ['bucketName'],
|
|
101
89
|
});
|
|
90
|
+
if (!existing) {
|
|
91
|
+
throw new orbit_core_1.ArgumentValidationError('Id is not a valid folder');
|
|
92
|
+
}
|
|
93
|
+
await this.ensureParentIdInBucket(repo, update.parentId, existing.bucketName);
|
|
94
|
+
await this.ensureNotMovingToChild(repo, update.id, update.parentId);
|
|
95
|
+
return orbit_db_typeorm_1.RepositoryExtensions.updateIdentifiableCreatableUpdatable(context, repo, update.updatedOn, update.id, { parentId: update.parentId }, this.timeService);
|
|
102
96
|
}
|
|
103
|
-
ensureParentIdInBucket(repo, parentId, bucketName) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (!parent) {
|
|
107
|
-
throw new orbit_core_1.ArgumentValidationError('ParentId is not a valid folder');
|
|
108
|
-
}
|
|
109
|
-
if (parent.bucketName !== bucketName) {
|
|
110
|
-
throw new orbit_core_1.ArgumentValidationError('Parent Folder is from a different bucket');
|
|
111
|
-
}
|
|
97
|
+
async ensureParentIdInBucket(repo, parentId, bucketName) {
|
|
98
|
+
const parent = await orbit_db_typeorm_1.RepositoryExtensions.findById(repo, parentId, {
|
|
99
|
+
select: ['bucketName'],
|
|
112
100
|
});
|
|
101
|
+
if (!parent) {
|
|
102
|
+
throw new orbit_core_1.ArgumentValidationError('ParentId is not a valid folder');
|
|
103
|
+
}
|
|
104
|
+
if (parent.bucketName !== bucketName) {
|
|
105
|
+
throw new orbit_core_1.ArgumentValidationError('Parent Folder is from a different bucket');
|
|
106
|
+
}
|
|
113
107
|
}
|
|
114
|
-
ensureNotMovingToChild(repo, folder, find) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
throw new orbit_core_1.ArgumentValidationError('You cannot move a folder into it own children');
|
|
119
|
-
}
|
|
120
|
-
for (const childFolder of childrenOfFolder) {
|
|
121
|
-
yield this.ensureNotMovingToChild(repo, childFolder.id, find);
|
|
122
|
-
}
|
|
108
|
+
async ensureNotMovingToChild(repo, folder, find) {
|
|
109
|
+
const childrenOfFolder = await repo.find({
|
|
110
|
+
where: { parentId: folder },
|
|
111
|
+
select: ['id'],
|
|
123
112
|
});
|
|
113
|
+
if (childrenOfFolder.some(f => f.id === find)) {
|
|
114
|
+
throw new orbit_core_1.ArgumentValidationError('You cannot move a folder into it own children');
|
|
115
|
+
}
|
|
116
|
+
await Promise.all(childrenOfFolder.map(f => this.ensureNotMovingToChild(repo, f.id, find)));
|
|
124
117
|
}
|
|
125
118
|
}
|
|
126
119
|
exports.FolderRepository = FolderRepository;
|