Skip to content

Commit bcbef8e

Browse files
committed
chore(merge): Merge main
2 parents 94dd14e + 8e82fa1 commit bcbef8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1208
-1115
lines changed

src/api-key/api-key.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ describe('APIKeyController (e2e)', () => {
197197
await client.post('/api/v1/api-keys').send(apiKeyData).expect(403);
198198
});
199199

200-
it('should return 403 when user tries to create API key with resource they do not have write access to', async () => {
200+
it('should return 404 when user tries to create API key with resource they do not have write access to', async () => {
201201
const apiKeyData = {
202202
user_id: client.user.id,
203203
namespace_id: client.namespace.id,
@@ -212,6 +212,6 @@ describe('APIKeyController (e2e)', () => {
212212
},
213213
};
214214

215-
await client.post('/api/v1/api-keys').send(apiKeyData).expect(403);
215+
await client.post('/api/v1/api-keys').send(apiKeyData).expect(404);
216216
});
217217
});

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { TasksModule } from 'omniboxd/tasks/tasks.module';
1717
import { WizardModule } from 'omniboxd/wizard/wizard.module';
1818
import { APIKeyModule } from 'omniboxd/api-key/api-key.module';
1919
import { ConfigModule, ConfigService } from '@nestjs/config';
20-
import { ResourcesModule } from 'omniboxd/resources/resources.module';
20+
import { NamespaceResourcesModule } from 'omniboxd/namespace-resources/namespace-resources.module';
2121
import { SnakeCaseInterceptor } from 'omniboxd/interceptor/snake-case';
2222
import { NamespacesModule } from 'omniboxd/namespaces/namespaces.module';
2323
import { PermissionsModule } from 'omniboxd/permissions/permissions.module';
@@ -46,6 +46,7 @@ import { UpdateAttachmentUrls1755499552000 } from 'omniboxd/migrations/175549955
4646
import { ScanResourceAttachments1755504936756 } from 'omniboxd/migrations/1755504936756-scan-resource-attachments';
4747
import { OAuthModule } from 'omniboxd/oauth2/oauth.module';
4848
import { SharesAllResources1754471311959 } from 'omniboxd/migrations/1754471311959-shares-all-resources';
49+
import { ResourcesModule } from 'omniboxd/resources/resources.module';
4950

5051
@Module({})
5152
export class AppModule implements NestModule {
@@ -75,6 +76,7 @@ export class AppModule implements NestModule {
7576
UserModule,
7677
APIKeyModule,
7778
NamespacesModule,
79+
NamespaceResourcesModule,
7880
ResourcesModule,
7981
TasksModule,
8082
WizardModule,

src/attachments/attachments.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { TestClient } from 'test/test-client';
22
import { HttpStatus } from '@nestjs/common';
3-
import { uploadLanguageDatasets } from 'omniboxd/resources/file-resources.e2e-spec';
3+
import { uploadLanguageDatasets } from 'omniboxd/namespace-resources/file-resources.e2e-spec';
44

55
describe('AttachmentsController (e2e)', () => {
66
let client: TestClient;
@@ -114,7 +114,7 @@ describe('AttachmentsController (e2e)', () => {
114114
`/api/v1/namespaces/${client.namespace.id}/resources/${nonExistentResourceId}/attachments`,
115115
)
116116
.attach('file[]', Buffer.from(testContent), 'test.txt')
117-
.expect(403);
117+
.expect(HttpStatus.NOT_FOUND);
118118
});
119119
});
120120

src/resources/dto/create-resource.dto.ts renamed to src/namespace-resources/dto/create-resource.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
IsOptional,
77
IsNotEmpty,
88
} from 'class-validator';
9-
import { ResourceType } from 'omniboxd/resources/resources.entity';
9+
import { ResourceType } from 'omniboxd/resources/entities/resource.entity';
1010

1111
export class CreateResourceDto {
1212
@IsString()

src/resources/dto/resource.dto.ts renamed to src/namespace-resources/dto/resource.dto.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { ResourcePermission } from 'omniboxd/permissions/resource-permission.enum';
2-
import { Resource, ResourceType } from '../resources.entity';
2+
import {
3+
Resource,
4+
ResourceType,
5+
} from 'omniboxd/resources/entities/resource.entity';
36
import { TagDto } from 'omniboxd/tag/dto/tag.dto';
47

58
export enum SpaceType {

src/resources/dto/update-resource.dto.ts renamed to src/namespace-resources/dto/update-resource.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
IsOptional,
77
IsNotEmpty,
88
} from 'class-validator';
9-
import { ResourceType } from 'omniboxd/resources/resources.entity';
9+
import { ResourceType } from 'omniboxd/resources/entities/resource.entity';
1010

1111
export class UpdateResourceDto {
1212
@IsString()

src/resources/file-resources.controller.ts renamed to src/namespace-resources/file-resources.controller.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Request, Response } from 'express';
22
import { FileInterceptor } from '@nestjs/platform-express';
3-
import { ResourcesService } from 'omniboxd/resources/resources.service';
3+
import { NamespaceResourcesService } from 'omniboxd/namespace-resources/namespace-resources.service';
44
import {
55
Body,
66
Controller,
@@ -18,7 +18,9 @@ import { UserId } from 'omniboxd/decorators/user-id.decorator';
1818

1919
@Controller('api/v1/namespaces/:namespaceId/resources/files')
2020
export class FileResourcesController {
21-
constructor(private readonly resourcesService: ResourcesService) {}
21+
constructor(
22+
private readonly namespaceResourcesService: NamespaceResourcesService,
23+
) {}
2224

2325
@Post()
2426
@UseInterceptors(FileInterceptor('file'))
@@ -28,14 +30,14 @@ export class FileResourcesController {
2830
@Body('namespace_id') namespaceId: string,
2931
@Body('parent_id') parentId: string,
3032
) {
31-
const newResource = await this.resourcesService.uploadFile(
33+
const newResource = await this.namespaceResourcesService.uploadFile(
3234
userId,
3335
namespaceId,
3436
file,
3537
parentId,
3638
undefined,
3739
);
38-
return await this.resourcesService.getPath({
40+
return await this.namespaceResourcesService.getPath({
3941
namespaceId,
4042
userId,
4143
resourceId: newResource.id,
@@ -50,7 +52,7 @@ export class FileResourcesController {
5052
@Body('file_hash') fileHash: string,
5153
@Body('namespace_id') namespaceId: string,
5254
) {
53-
return this.resourcesService.uploadFileChunk(
55+
return this.namespaceResourcesService.uploadFileChunk(
5456
namespaceId,
5557
chunk,
5658
chunkNumber,
@@ -64,7 +66,7 @@ export class FileResourcesController {
6466
@Body('chunks_number') chunksNumber: string,
6567
@Body('file_hash') fileHash: string,
6668
) {
67-
return this.resourcesService.cleanFileChunks(
69+
return this.namespaceResourcesService.cleanFileChunks(
6870
namespaceId,
6971
chunksNumber,
7072
fileHash,
@@ -81,7 +83,7 @@ export class FileResourcesController {
8183
@Body('mimetype') mimetype: string,
8284
@Body('parent_id') parentId: string,
8385
) {
84-
const newResource = await this.resourcesService.mergeFileChunks(
86+
const newResource = await this.namespaceResourcesService.mergeFileChunks(
8587
req.user!.id,
8688
namespaceId,
8789
totalChunks,
@@ -90,7 +92,7 @@ export class FileResourcesController {
9092
mimetype,
9193
parentId,
9294
);
93-
return await this.resourcesService.getPath({
95+
return await this.namespaceResourcesService.getPath({
9496
namespaceId,
9597
userId: req.user!.id,
9698
resourceId: newResource.id,
@@ -105,7 +107,7 @@ export class FileResourcesController {
105107
@Body('namespace_id') namespaceId: string,
106108
@Body('resource_id') resourceId: string,
107109
) {
108-
return this.resourcesService.uploadFile(
110+
return this.namespaceResourcesService.uploadFile(
109111
userId,
110112
namespaceId,
111113
file,
@@ -119,6 +121,6 @@ export class FileResourcesController {
119121
@Param('resourceId') resourceId: string,
120122
@Res() res: Response,
121123
) {
122-
return await this.resourcesService.fileResponse(resourceId, res);
124+
return await this.namespaceResourcesService.fileResponse(resourceId, res);
123125
}
124126
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { Response } from 'express';
22
import { Controller, Get, Param, Res } from '@nestjs/common';
3-
import { ResourcesService } from 'omniboxd/resources/resources.service';
3+
import { NamespaceResourcesService } from 'omniboxd/namespace-resources/namespace-resources.service';
44
import { Public } from 'omniboxd/auth/decorators/public.auth.decorator';
55

66
@Controller('internal/api/v1/resources')
77
export class InternalResourcesController {
8-
constructor(private readonly resourcesService: ResourcesService) {}
8+
constructor(
9+
private readonly namespaceResourcesService: NamespaceResourcesService,
10+
) {}
911

1012
@Public()
1113
@Get('files/:id')
1214
async downloadFile(@Param('id') resourceId: string, @Res() res: Response) {
13-
return await this.resourcesService.fileResponse(resourceId, res);
15+
return await this.namespaceResourcesService.fileResponse(resourceId, res);
1416
}
1517
}

0 commit comments

Comments
 (0)